diff options
| author | Denis Merigoux <denis.merigoux@gmail.com> | 2018-09-10 16:28:47 +0200 |
|---|---|---|
| committer | Eduard-Mihai Burtescu <edy.burt@gmail.com> | 2018-11-16 14:11:59 +0200 |
| commit | 3c082a23e838a4a852eefdaa9da61fd3dfe1e2d0 (patch) | |
| tree | c56c08b3f0c17d474d39882a3cdac849af087dbf /src/librustc_codegen_llvm/mir | |
| parent | d77e34f35ba276b514459b1669818605c9fbf416 (diff) | |
| download | rust-3c082a23e838a4a852eefdaa9da61fd3dfe1e2d0.tar.gz rust-3c082a23e838a4a852eefdaa9da61fd3dfe1e2d0.zip | |
Added StaticMethods trait
Diffstat (limited to 'src/librustc_codegen_llvm/mir')
| -rw-r--r-- | src/librustc_codegen_llvm/mir/block.rs | 29 | ||||
| -rw-r--r-- | src/librustc_codegen_llvm/mir/constant.rs | 15 | ||||
| -rw-r--r-- | src/librustc_codegen_llvm/mir/place.rs | 10 | ||||
| -rw-r--r-- | src/librustc_codegen_llvm/mir/rvalue.rs | 5 |
4 files changed, 30 insertions, 29 deletions
diff --git a/src/librustc_codegen_llvm/mir/block.rs b/src/librustc_codegen_llvm/mir/block.rs index 0fd1e28d5a6..c5e3ad54ef3 100644 --- a/src/librustc_codegen_llvm/mir/block.rs +++ b/src/librustc_codegen_llvm/mir/block.rs @@ -19,7 +19,6 @@ use base; use callee; use builder::{Builder, MemFlags}; use common::{self, IntPredicate}; -use consts; use meth; use monomorphize; use type_of::LayoutLlvmExt; @@ -28,6 +27,7 @@ use value::Value; use interfaces::{ BuilderMethods, ConstMethods, BaseTypeMethods, DerivedTypeMethods, DerivedIntrinsicMethods, + StaticMethods, }; use syntax::symbol::Symbol; @@ -380,10 +380,11 @@ impl FunctionCx<'a, 'll, 'tcx, &'ll Value> { let index = self.codegen_operand(&mut bx, index).immediate(); let file_line_col = bx.cx().const_struct(&[filename, line, col], false); - let file_line_col = consts::addr_of(bx.cx(), - file_line_col, - align, - Some("panic_bounds_check_loc")); + let file_line_col = bx.cx().static_addr_of( + file_line_col, + align, + Some("panic_bounds_check_loc") + ); (lang_items::PanicBoundsCheckFnLangItem, vec![file_line_col, index, len]) } @@ -395,10 +396,11 @@ impl FunctionCx<'a, 'll, 'tcx, &'ll Value> { &[msg_str, filename, line, col], false ); - let msg_file_line_col = consts::addr_of(bx.cx(), - msg_file_line_col, - align, - Some("panic_loc")); + let msg_file_line_col = bx.cx().static_addr_of( + msg_file_line_col, + align, + Some("panic_loc") + ); (lang_items::PanicFnLangItem, vec![msg_file_line_col]) } @@ -518,10 +520,11 @@ impl FunctionCx<'a, 'll, 'tcx, &'ll Value> { &[msg_str, filename, line, col], false, ); - let msg_file_line_col = consts::addr_of(bx.cx, - msg_file_line_col, - align, - Some("panic_loc")); + let msg_file_line_col = bx.cx.static_addr_of( + msg_file_line_col, + align, + Some("panic_loc"), + ); // Obtain the panic entry point. let def_id = diff --git a/src/librustc_codegen_llvm/mir/constant.rs b/src/librustc_codegen_llvm/mir/constant.rs index d9be3fbfb2a..d448ca1735b 100644 --- a/src/librustc_codegen_llvm/mir/constant.rs +++ b/src/librustc_codegen_llvm/mir/constant.rs @@ -19,13 +19,12 @@ use rustc::ty::{self, Ty}; use rustc::ty::layout::{self, HasDataLayout, LayoutOf, Size}; use builder::Builder; use common::{CodegenCx}; -use consts; use type_of::LayoutLlvmExt; use type_::Type; use syntax::ast::Mutability; use syntax::source_map::Span; use value::Value; -use interfaces::{BuilderMethods, ConstMethods, BaseTypeMethods, DerivedTypeMethods}; +use interfaces::{BuilderMethods, ConstMethods, BaseTypeMethods, DerivedTypeMethods, StaticMethods}; use super::super::callee; use super::FunctionCx; @@ -48,7 +47,7 @@ pub fn scalar_to_llvm( if layout.value == layout::Pointer { unsafe { llvm::LLVMConstIntToPtr(llval, llty) } } else { - consts::bitcast(llval, llty) + cx.static_bitcast(llval, llty) } }, Scalar::Ptr(ptr) => { @@ -57,9 +56,9 @@ pub fn scalar_to_llvm( Some(AllocType::Memory(alloc)) => { let init = const_alloc_to_llvm(cx, alloc); if alloc.mutability == Mutability::Mutable { - consts::addr_of_mut(cx, init, alloc.align, None) + cx.static_addr_of_mut(init, alloc.align, None) } else { - consts::addr_of(cx, init, alloc.align, None) + cx.static_addr_of(init, alloc.align, None) } } Some(AllocType::Function(fn_instance)) => { @@ -67,19 +66,19 @@ pub fn scalar_to_llvm( } Some(AllocType::Static(def_id)) => { assert!(cx.tcx.is_static(def_id).is_some()); - consts::get_static(cx, def_id) + cx.get_static(def_id) } None => bug!("missing allocation {:?}", ptr.alloc_id), }; let llval = unsafe { llvm::LLVMConstInBoundsGEP( - consts::bitcast(base_addr, cx.type_i8p()), + cx.static_bitcast(base_addr, cx.type_i8p()), &cx.const_usize(ptr.offset.bytes()), 1, ) }; if layout.value != layout::Pointer { unsafe { llvm::LLVMConstPtrToInt(llval, llty) } } else { - consts::bitcast(llval, llty) + cx.static_bitcast(llval, llty) } } } diff --git a/src/librustc_codegen_llvm/mir/place.rs b/src/librustc_codegen_llvm/mir/place.rs index 1c119f6a0a3..f419be8fe3e 100644 --- a/src/librustc_codegen_llvm/mir/place.rs +++ b/src/librustc_codegen_llvm/mir/place.rs @@ -16,7 +16,6 @@ use rustc::mir::tcx::PlaceTy; use base; use builder::Builder; use common::{CodegenCx, IntPredicate}; -use consts; use type_of::LayoutLlvmExt; use value::Value; use glue; @@ -24,6 +23,7 @@ use mir::constant::const_alloc_to_llvm; use interfaces::{ BuilderMethods, ConstMethods, BaseTypeMethods, DerivedTypeMethods, DerivedIntrinsicMethods, + StaticMethods, }; use super::{FunctionCx, LocalRef}; @@ -66,14 +66,14 @@ impl PlaceRef<'tcx, &'ll Value> { offset: Size, ) -> PlaceRef<'tcx, &'ll Value> { let init = const_alloc_to_llvm(bx.cx(), alloc); - let base_addr = consts::addr_of(bx.cx(), init, layout.align, None); + let base_addr = bx.cx().static_addr_of(init, layout.align, None); let llval = unsafe { LLVMConstInBoundsGEP( - consts::bitcast(base_addr, bx.cx().type_i8p()), + bx.cx().static_bitcast(base_addr, bx.cx().type_i8p()), &bx.cx().const_usize(offset.bytes()), 1, )}; - let llval = consts::bitcast(llval, bx.cx().type_ptr_to(layout.llvm_type(bx.cx()))); + let llval = bx.cx().static_bitcast(llval, bx.cx().type_ptr_to(layout.llvm_type(bx.cx()))); PlaceRef::new_sized(llval, layout, alloc.align) } @@ -497,7 +497,7 @@ impl FunctionCx<'a, 'll, 'tcx, &'ll Value> { } mir::Place::Static(box mir::Static { def_id, ty }) => { let layout = cx.layout_of(self.monomorphize(&ty)); - PlaceRef::new_sized(consts::get_static(cx, def_id), layout, layout.align) + PlaceRef::new_sized(cx.get_static(def_id), layout, layout.align) }, mir::Place::Projection(box mir::Projection { ref base, diff --git a/src/librustc_codegen_llvm/mir/rvalue.rs b/src/librustc_codegen_llvm/mir/rvalue.rs index 56e3aa56e60..08d528ba921 100644 --- a/src/librustc_codegen_llvm/mir/rvalue.rs +++ b/src/librustc_codegen_llvm/mir/rvalue.rs @@ -20,7 +20,6 @@ use base; use builder::Builder; use callee; use common::{self, IntPredicate, RealPredicate}; -use consts; use monomorphize; use type_::Type; use type_of::LayoutLlvmExt; @@ -841,7 +840,7 @@ fn cast_int_to_float(bx: &Builder<'_, 'll, '_>, let max = bx.cx().const_uint_big(int_ty, MAX_F32_PLUS_HALF_ULP); let overflow = bx.icmp(IntPredicate::IntUGE, x, max); let infinity_bits = bx.cx().const_u32(ieee::Single::INFINITY.to_bits() as u32); - let infinity = consts::bitcast(infinity_bits, float_ty); + let infinity = bx.bitcast(infinity_bits, float_ty); bx.select(overflow, infinity, bx.uitofp(x, float_ty)) } else { if signed { @@ -922,7 +921,7 @@ fn cast_float_to_int(bx: &Builder<'_, 'll, '_>, 64 => bx.cx().const_u64(bits as u64), n => bug!("unsupported float width {}", n), }; - consts::bitcast(bits_llval, float_ty) + bx.bitcast(bits_llval, float_ty) }; let (f_min, f_max) = match bx.cx().float_width(float_ty) { 32 => compute_clamp_bounds_single(signed, int_ty), |
