Skip to content

Commit a64741c

Browse files
committed
Prefixed const methods with "const" instead of "c"
1 parent 29c349b commit a64741c

File tree

18 files changed

+210
-210
lines changed

18 files changed

+210
-210
lines changed

src/librustc_codegen_llvm/abi.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ impl ArgTypeExt<'ll, 'tcx> for ArgType<'tcx, Ty<'tcx>> {
242242
base::call_memcpy(bx,
243243
bx.pointercast(dst.llval, cx.i8p()),
244244
bx.pointercast(llscratch, cx.i8p()),
245-
cx.c_usize(self.layout.size.bytes()),
245+
cx.const_usize(self.layout.size.bytes()),
246246
self.layout.align.min(scratch_align),
247247
MemFlags::empty());
248248

src/librustc_codegen_llvm/asm.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ pub fn codegen_inline_asm(
106106
let kind = llvm::LLVMGetMDKindIDInContext(bx.cx().llcx,
107107
key.as_ptr() as *const c_char, key.len() as c_uint);
108108

109-
let val: &'ll Value = bx.cx().c_i32(ia.ctxt.outer().as_u32() as i32);
109+
let val: &'ll Value = bx.cx().const_i32(ia.ctxt.outer().as_u32() as i32);
110110

111111
llvm::LLVMSetMetadata(r, kind,
112112
llvm::LLVMMDNodeInContext(bx.cx().llcx, &val, 1));

src/librustc_codegen_llvm/back/write.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -433,17 +433,17 @@ impl CommonWriteMethods for CodegenContext<'ll> {
433433
common::val_ty(v)
434434
}
435435

436-
fn c_bytes_in_context(&self, llcx: &'ll llvm::Context, bytes: &[u8]) -> &'ll Value {
437-
common::c_bytes_in_context(llcx, bytes)
436+
fn const_bytes_in_context(&self, llcx: &'ll llvm::Context, bytes: &[u8]) -> &'ll Value {
437+
common::const_bytes_in_context(llcx, bytes)
438438
}
439439

440-
fn c_struct_in_context(
440+
fn const_struct_in_context(
441441
&self,
442442
llcx: &'a llvm::Context,
443443
elts: &[&'a Value],
444444
packed: bool,
445445
) -> &'a Value {
446-
common::c_struct_in_context(llcx, elts, packed)
446+
common::const_struct_in_context(llcx, elts, packed)
447447
}
448448
}
449449

@@ -926,7 +926,7 @@ unsafe fn embed_bitcode(cgcx: &CodegenContext,
926926
llcx: &llvm::Context,
927927
llmod: &llvm::Module,
928928
bitcode: Option<&[u8]>) {
929-
let llconst = cgcx.c_bytes_in_context(llcx, bitcode.unwrap_or(&[]));
929+
let llconst = cgcx.const_bytes_in_context(llcx, bitcode.unwrap_or(&[]));
930930
let llglobal = llvm::LLVMAddGlobal(
931931
llmod,
932932
cgcx.val_ty(llconst),
@@ -946,7 +946,7 @@ unsafe fn embed_bitcode(cgcx: &CodegenContext,
946946
llvm::LLVMRustSetLinkage(llglobal, llvm::Linkage::PrivateLinkage);
947947
llvm::LLVMSetGlobalConstant(llglobal, llvm::True);
948948

949-
let llconst = cgcx.c_bytes_in_context(llcx, &[]);
949+
let llconst = cgcx.const_bytes_in_context(llcx, &[]);
950950
let llglobal = llvm::LLVMAddGlobal(
951951
llmod,
952952
cgcx.val_ty(llconst),

src/librustc_codegen_llvm/base.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ pub fn unsized_info(
198198
let (source, target) = cx.tcx.struct_lockstep_tails(source, target);
199199
match (&source.sty, &target.sty) {
200200
(&ty::Array(_, len), &ty::Slice(_)) => {
201-
cx.c_usize(len.unwrap_usize(cx.tcx))
201+
cx.const_usize(len.unwrap_usize(cx.tcx))
202202
}
203203
(&ty::Dynamic(..), &ty::Dynamic(..)) => {
204204
// For now, upcasts are limited to changes in marker
@@ -444,8 +444,8 @@ pub fn call_memcpy<'a, 'll: 'a, 'tcx: 'll>(
444444
let src_ptr = bx.pointercast(src, cx.i8p());
445445
let dst_ptr = bx.pointercast(dst, cx.i8p());
446446
let size = bx.intcast(n_bytes, cx.isize_ty, false);
447-
let align = cx.c_i32(align.abi() as i32);
448-
let volatile = cx.c_bool(flags.contains(MemFlags::VOLATILE));
447+
let align = cx.const_i32(align.abi() as i32);
448+
let volatile = cx.const_bool(flags.contains(MemFlags::VOLATILE));
449449
bx.call(memcpy, &[dst_ptr, src_ptr, size, align, volatile], None);
450450
}
451451

@@ -462,7 +462,7 @@ pub fn memcpy_ty<'a, 'll: 'a, 'tcx: 'll>(
462462
return;
463463
}
464464

465-
call_memcpy(bx, dst, src, bx.cx().c_usize(size), align, flags);
465+
call_memcpy(bx, dst, src, bx.cx().const_usize(size), align, flags);
466466
}
467467

468468
pub fn call_memset(
@@ -476,7 +476,7 @@ pub fn call_memset(
476476
let ptr_width = &bx.cx().sess().target.target.target_pointer_width;
477477
let intrinsic_key = format!("llvm.memset.p0i8.i{}", ptr_width);
478478
let llintrinsicfn = bx.cx().get_intrinsic(&intrinsic_key);
479-
let volatile = bx.cx().c_bool(volatile);
479+
let volatile = bx.cx().const_bool(volatile);
480480
bx.call(llintrinsicfn, &[ptr, fill_byte, size, align, volatile], None)
481481
}
482482

@@ -654,8 +654,8 @@ fn write_metadata<'a, 'gcx>(tcx: TyCtxt<'a, 'gcx, 'gcx>,
654654
DeflateEncoder::new(&mut compressed, Compression::fast())
655655
.write_all(&metadata.raw_data).unwrap();
656656

657-
let llmeta = llvm_module.c_bytes_in_context(metadata_llcx, &compressed);
658-
let llconst = llvm_module.c_struct_in_context(metadata_llcx, &[llmeta], false);
657+
let llmeta = llvm_module.const_bytes_in_context(metadata_llcx, &compressed);
658+
let llconst = llvm_module.const_struct_in_context(metadata_llcx, &[llmeta], false);
659659
let name = exported_symbols::metadata_symbol_name(tcx);
660660
let buf = CString::new(name).unwrap();
661661
let llglobal = unsafe {
@@ -1258,7 +1258,7 @@ fn compile_codegen_unit<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
12581258
if !cx.used_statics.borrow().is_empty() {
12591259
let name = const_cstr!("llvm.used");
12601260
let section = const_cstr!("llvm.metadata");
1261-
let array = cx.c_array(&cx.ptr_to(cx.i8()), &*cx.used_statics.borrow());
1261+
let array = cx.const_array(&cx.ptr_to(cx.i8()), &*cx.used_statics.borrow());
12621262

12631263
unsafe {
12641264
let g = llvm::LLVMAddGlobal(cx.llmod,

src/librustc_codegen_llvm/builder.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -542,8 +542,8 @@ impl BuilderMethods<'a, 'll, 'tcx>
542542
unsafe {
543543
let llty = self.cx.val_ty(load);
544544
let v = [
545-
self.cx.c_uint_big(llty, range.start),
546-
self.cx.c_uint_big(llty, range.end)
545+
self.cx.const_uint_big(llty, range.start),
546+
self.cx.const_uint_big(llty, range.end)
547547
];
548548

549549
llvm::LLVMSetMetadata(load, llvm::MD_range as c_uint,
@@ -608,7 +608,7 @@ impl BuilderMethods<'a, 'll, 'tcx>
608608
// *always* point to a metadata value of the integer 1.
609609
//
610610
// [1]: http://llvm.org/docs/LangRef.html#store-instruction
611-
let one = self.cx.c_i32(1);
611+
let one = self.cx.const_i32(1);
612612
let node = llvm::LLVMMDNodeInContext(self.cx.llcx, &one, 1);
613613
llvm::LLVMSetMetadata(store, llvm::MD_nontemporal as c_uint, node);
614614
}
@@ -849,9 +849,9 @@ impl BuilderMethods<'a, 'll, 'tcx>
849849
unsafe {
850850
let elt_ty = self.cx.val_ty(elt);
851851
let undef = llvm::LLVMGetUndef(&self.cx().vector(elt_ty, num_elts as u64));
852-
let vec = self.insert_element(undef, elt, self.cx.c_i32(0));
852+
let vec = self.insert_element(undef, elt, self.cx.const_i32(0));
853853
let vec_i32_ty = &self.cx().vector(&self.cx().i32(), num_elts as u64);
854-
self.shuffle_vector(vec, undef, self.cx().c_null(vec_i32_ty))
854+
self.shuffle_vector(vec, undef, self.cx().const_null(vec_i32_ty))
855855
}
856856
}
857857

@@ -1246,7 +1246,7 @@ impl BuilderMethods<'a, 'll, 'tcx>
12461246
let lifetime_intrinsic = self.cx.get_intrinsic(intrinsic);
12471247

12481248
let ptr = self.pointercast(ptr, self.cx.i8p());
1249-
self.call(lifetime_intrinsic, &[self.cx.c_u64(size), ptr], None);
1249+
self.call(lifetime_intrinsic, &[self.cx.const_u64(size), ptr], None);
12501250
}
12511251

12521252
fn call(&self, llfn: &'ll Value, args: &[&'ll Value],

src/librustc_codegen_llvm/common.rs

Lines changed: 37 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -206,71 +206,71 @@ impl Backend for CodegenCx<'ll, 'tcx, &'ll Value> {
206206
impl<'ll, 'tcx : 'll> CommonMethods for CodegenCx<'ll, 'tcx, &'ll Value> {
207207

208208
// LLVM constant constructors.
209-
fn c_null(&self, t: &'ll Type) -> &'ll Value {
209+
fn const_null(&self, t: &'ll Type) -> &'ll Value {
210210
unsafe {
211211
llvm::LLVMConstNull(t)
212212
}
213213
}
214214

215-
fn c_undef(&self, t: &'ll Type) -> &'ll Value {
215+
fn const_undef(&self, t: &'ll Type) -> &'ll Value {
216216
unsafe {
217217
llvm::LLVMGetUndef(t)
218218
}
219219
}
220220

221-
fn c_int(&self, t: &'ll Type, i: i64) -> &'ll Value {
221+
fn const_int(&self, t: &'ll Type, i: i64) -> &'ll Value {
222222
unsafe {
223223
llvm::LLVMConstInt(t, i as u64, True)
224224
}
225225
}
226226

227-
fn c_uint(&self, t: &'ll Type, i: u64) -> &'ll Value {
227+
fn const_uint(&self, t: &'ll Type, i: u64) -> &'ll Value {
228228
unsafe {
229229
llvm::LLVMConstInt(t, i, False)
230230
}
231231
}
232232

233-
fn c_uint_big(&self, t: &'ll Type, u: u128) -> &'ll Value {
233+
fn const_uint_big(&self, t: &'ll Type, u: u128) -> &'ll Value {
234234
unsafe {
235235
let words = [u as u64, (u >> 64) as u64];
236236
llvm::LLVMConstIntOfArbitraryPrecision(t, 2, words.as_ptr())
237237
}
238238
}
239239

240-
fn c_bool(&self, val: bool) -> &'ll Value {
241-
&self.c_uint(&self.i1(), val as u64)
240+
fn const_bool(&self, val: bool) -> &'ll Value {
241+
&self.const_uint(&self.i1(), val as u64)
242242
}
243243

244-
fn c_i32(&self, i: i32) -> &'ll Value {
245-
&self.c_int(&self.i32(), i as i64)
244+
fn const_i32(&self, i: i32) -> &'ll Value {
245+
&self.const_int(&self.i32(), i as i64)
246246
}
247247

248-
fn c_u32(&self, i: u32) -> &'ll Value {
249-
&self.c_uint(&self.i32(), i as u64)
248+
fn const_u32(&self, i: u32) -> &'ll Value {
249+
&self.const_uint(&self.i32(), i as u64)
250250
}
251251

252-
fn c_u64(&self, i: u64) -> &'ll Value {
253-
&self.c_uint(&self.i64(), i)
252+
fn const_u64(&self, i: u64) -> &'ll Value {
253+
&self.const_uint(&self.i64(), i)
254254
}
255255

256-
fn c_usize(&self, i: u64) -> &'ll Value {
256+
fn const_usize(&self, i: u64) -> &'ll Value {
257257
let bit_size = self.data_layout().pointer_size.bits();
258258
if bit_size < 64 {
259259
// make sure it doesn't overflow
260260
assert!(i < (1<<bit_size));
261261
}
262262

263-
&self.c_uint(&self.isize_ty, i)
263+
&self.const_uint(&self.isize_ty, i)
264264
}
265265

266-
fn c_u8(&self, i: u8) -> &'ll Value {
267-
&self.c_uint(&self.i8(), i as u64)
266+
fn const_u8(&self, i: u8) -> &'ll Value {
267+
&self.const_uint(&self.i8(), i as u64)
268268
}
269269

270270

271271
// This is a 'c-like' raw string, which differs from
272272
// our boxed-and-length-annotated strings.
273-
fn c_cstr(
273+
fn const_cstr(
274274
&self,
275275
s: LocalInternedString,
276276
null_terminated: bool,
@@ -299,45 +299,45 @@ impl<'ll, 'tcx : 'll> CommonMethods for CodegenCx<'ll, 'tcx, &'ll Value> {
299299

300300
// NB: Do not use `do_spill_noroot` to make this into a constant string, or
301301
// you will be kicked off fast isel. See issue #4352 for an example of this.
302-
fn c_str_slice(&self, s: LocalInternedString) -> &'ll Value {
302+
fn const_str_slice(&self, s: LocalInternedString) -> &'ll Value {
303303
let len = s.len();
304-
let cs = consts::ptrcast(&self.c_cstr(s, false),
304+
let cs = consts::ptrcast(&self.const_cstr(s, false),
305305
&self.ptr_to(&self.layout_of(&self.tcx.mk_str()).llvm_type(&self)));
306-
&self.c_fat_ptr(cs, &self.c_usize(len as u64))
306+
&self.const_fat_ptr(cs, &self.const_usize(len as u64))
307307
}
308308

309-
fn c_fat_ptr(
309+
fn const_fat_ptr(
310310
&self,
311311
ptr: &'ll Value,
312312
meta: &'ll Value
313313
) -> &'ll Value {
314314
assert_eq!(abi::FAT_PTR_ADDR, 0);
315315
assert_eq!(abi::FAT_PTR_EXTRA, 1);
316-
&self.c_struct(&[ptr, meta], false)
316+
&self.const_struct(&[ptr, meta], false)
317317
}
318318

319-
fn c_struct(
319+
fn const_struct(
320320
&self,
321321
elts: &[&'ll Value],
322322
packed: bool
323323
) -> &'ll Value {
324-
&self.c_struct_in_context(&self.llcx, elts, packed)
324+
&self.const_struct_in_context(&self.llcx, elts, packed)
325325
}
326326

327-
fn c_array(&self, ty: &'ll Type, elts: &[&'ll Value]) -> &'ll Value {
327+
fn const_array(&self, ty: &'ll Type, elts: &[&'ll Value]) -> &'ll Value {
328328
unsafe {
329329
return llvm::LLVMConstArray(ty, elts.as_ptr(), elts.len() as c_uint);
330330
}
331331
}
332332

333-
fn c_vector(&self, elts: &[&'ll Value]) -> &'ll Value {
333+
fn const_vector(&self, elts: &[&'ll Value]) -> &'ll Value {
334334
unsafe {
335335
return llvm::LLVMConstVector(elts.as_ptr(), elts.len() as c_uint);
336336
}
337337
}
338338

339-
fn c_bytes(&self, bytes: &[u8]) -> &'ll Value {
340-
&self.c_bytes_in_context(&self.llcx, bytes)
339+
fn const_bytes(&self, bytes: &[u8]) -> &'ll Value {
340+
&self.const_bytes_in_context(&self.llcx, bytes)
341341
}
342342

343343
fn const_get_elt(&self, v: &'ll Value, idx: u64) -> &'ll Value {
@@ -408,14 +408,14 @@ pub fn val_ty(v: &'ll Value) -> &'ll Type {
408408
}
409409
}
410410

411-
pub fn c_bytes_in_context(llcx: &'ll llvm::Context, bytes: &[u8]) -> &'ll Value {
411+
pub fn const_bytes_in_context(llcx: &'ll llvm::Context, bytes: &[u8]) -> &'ll Value {
412412
unsafe {
413413
let ptr = bytes.as_ptr() as *const c_char;
414414
return llvm::LLVMConstStringInContext(llcx, ptr, bytes.len() as c_uint, True);
415415
}
416416
}
417417

418-
pub fn c_struct_in_context(
418+
pub fn const_struct_in_context(
419419
llcx: &'a llvm::Context,
420420
elts: &[&'a Value],
421421
packed: bool,
@@ -432,17 +432,17 @@ impl<'ll, 'tcx : 'll> CommonWriteMethods for CodegenCx<'ll, 'tcx, &'ll Value> {
432432
val_ty(v)
433433
}
434434

435-
fn c_bytes_in_context(&self, llcx: &'ll llvm::Context, bytes: &[u8]) -> &'ll Value {
436-
c_bytes_in_context(llcx, bytes)
435+
fn const_bytes_in_context(&self, llcx: &'ll llvm::Context, bytes: &[u8]) -> &'ll Value {
436+
const_bytes_in_context(llcx, bytes)
437437
}
438438

439-
fn c_struct_in_context(
439+
fn const_struct_in_context(
440440
&self,
441441
llcx: &'a llvm::Context,
442442
elts: &[&'a Value],
443443
packed: bool,
444444
) -> &'a Value {
445-
c_struct_in_context(llcx, elts, packed)
445+
const_struct_in_context(llcx, elts, packed)
446446
}
447447
}
448448

@@ -516,9 +516,9 @@ pub fn shift_mask_val(
516516
// i8/u8 can shift by at most 7, i16/u16 by at most 15, etc.
517517
let val = bx.cx().int_width(llty) - 1;
518518
if invert {
519-
bx.cx.c_int(mask_llty, !val as i64)
519+
bx.cx.const_int(mask_llty, !val as i64)
520520
} else {
521-
bx.cx.c_uint(mask_llty, val)
521+
bx.cx.const_uint(mask_llty, val)
522522
}
523523
},
524524
TypeKind::Vector => {

src/librustc_codegen_llvm/debuginfo/gdb.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ pub fn insert_reference_to_gdb_debug_scripts_section_global(bx: &Builder<'_, 'll
2929
let gdb_debug_scripts_section = get_or_insert_gdb_debug_scripts_section_global(bx.cx());
3030
// Load just the first byte as that's all that's necessary to force
3131
// LLVM to keep around the reference to the global.
32-
let indices = [bx.cx().c_i32(0), bx.cx().c_i32(0)];
32+
let indices = [bx.cx().const_i32(0), bx.cx().const_i32(0)];
3333
let element = bx.inbounds_gep(gdb_debug_scripts_section, &indices);
3434
let volative_load_instruction = bx.volatile_load(element);
3535
unsafe {
@@ -63,7 +63,7 @@ pub fn get_or_insert_gdb_debug_scripts_section_global(cx: &CodegenCx<'ll, '_, &'
6363
bug!("symbol `{}` is already defined", section_var_name)
6464
});
6565
llvm::LLVMSetSection(section_var, section_name.as_ptr() as *const _);
66-
llvm::LLVMSetInitializer(section_var, cx.c_bytes(section_contents));
66+
llvm::LLVMSetInitializer(section_var, cx.const_bytes(section_contents));
6767
llvm::LLVMSetGlobalConstant(section_var, llvm::True);
6868
llvm::LLVMSetUnnamedAddr(section_var, llvm::True);
6969
llvm::LLVMRustSetLinkage(section_var, llvm::Linkage::LinkOnceODRLinkage);

0 commit comments

Comments
 (0)