]> git.lizzy.rs Git - rust.git/commitdiff
All CommonMethods now real methods (not static)
authorDenis Merigoux <denis.merigoux@gmail.com>
Thu, 30 Aug 2018 12:58:15 +0000 (14:58 +0200)
committerEduard-Mihai Burtescu <edy.burt@gmail.com>
Fri, 16 Nov 2018 12:11:59 +0000 (14:11 +0200)
src/librustc_codegen_llvm/base.rs
src/librustc_codegen_llvm/common.rs
src/librustc_codegen_llvm/glue.rs
src/librustc_codegen_llvm/interfaces/common.rs
src/librustc_codegen_llvm/intrinsic.rs
src/librustc_codegen_llvm/mir/block.rs
src/librustc_codegen_llvm/mir/rvalue.rs

index 6a2f437b1da4847007bc9f6929c17cf22cd74ec1..e13c488d2b74bb044272d5d4b23f64ad794e89f6 100644 (file)
@@ -1151,7 +1151,7 @@ fn module_codegen<'a, 'tcx>(
             if !cx.used_statics.borrow().is_empty() {
                 let name = const_cstr!("llvm.used");
                 let section = const_cstr!("llvm.metadata");
-                let array = CodegenCx::c_array(Type::i8(&cx).ptr_to(), &*cx.used_statics.borrow());
+                let array = cx.c_array(Type::i8(&cx).ptr_to(), &*cx.used_statics.borrow());
 
                 unsafe {
                     let g = llvm::LLVMAddGlobal(cx.llmod,
index 80f8bbeabda38c063250581716cd521f5f6cb52b..bd356047467317ac1bd2e9e3af3d1dc7e96de474 100644 (file)
@@ -321,13 +321,13 @@ fn c_struct(
         &self.c_struct_in_context(&self.llcx, elts, packed)
     }
 
-    fn c_array(ty: &'ll Type, elts: &[&'ll Value]) -> &'ll Value {
+    fn c_array(&self, ty: &'ll Type, elts: &[&'ll Value]) -> &'ll Value {
         unsafe {
             return llvm::LLVMConstArray(ty, elts.as_ptr(), elts.len() as c_uint);
         }
     }
 
-    fn c_vector(elts: &[&'ll Value]) -> &'ll Value {
+    fn c_vector(&self, elts: &[&'ll Value]) -> &'ll Value {
         unsafe {
             return llvm::LLVMConstVector(elts.as_ptr(), elts.len() as c_uint);
         }
@@ -337,7 +337,7 @@ fn c_bytes(&self, bytes: &[u8]) -> &'ll Value {
         &self.c_bytes_in_context(&self.llcx, bytes)
     }
 
-    fn const_get_elt(v: &'ll Value, idx: u64) -> &'ll Value {
+    fn const_get_elt(&self, v: &'ll Value, idx: u64) -> &'ll Value {
         unsafe {
             assert_eq!(idx as c_uint as u64, idx);
             let us = &[idx as c_uint];
@@ -350,9 +350,9 @@ fn const_get_elt(v: &'ll Value, idx: u64) -> &'ll Value {
         }
     }
 
-    fn const_get_real(v: &'ll Value) -> Option<(f64, bool)> {
+    fn const_get_real(&self, v: &'ll Value) -> Option<(f64, bool)> {
         unsafe {
-            if Self::is_const_real(v) {
+            if self.is_const_real(v) {
                 let mut loses_info: llvm::Bool = ::std::mem::uninitialized();
                 let r = llvm::LLVMConstRealGetDouble(v, &mut loses_info);
                 let loses_info = if loses_info == 1 { true } else { false };
@@ -363,27 +363,27 @@ fn const_get_real(v: &'ll Value) -> Option<(f64, bool)> {
         }
     }
 
-    fn const_to_uint(v: &'ll Value) -> u64 {
+    fn const_to_uint(&self, v: &'ll Value) -> u64 {
         unsafe {
             llvm::LLVMConstIntGetZExtValue(v)
         }
     }
 
-    fn is_const_integral(v: &'ll Value) -> bool {
+    fn is_const_integral(&self, v: &'ll Value) -> bool {
         unsafe {
             llvm::LLVMIsAConstantInt(v).is_some()
         }
     }
 
-    fn is_const_real(v: &'ll Value) -> bool {
+    fn is_const_real(&self, v: &'ll Value) -> bool {
         unsafe {
             llvm::LLVMIsAConstantFP(v).is_some()
         }
     }
 
-    fn const_to_opt_u128(v: &'ll Value, sign_ext: bool) -> Option<u128> {
+    fn const_to_opt_u128(&self, v: &'ll Value, sign_ext: bool) -> Option<u128> {
         unsafe {
-            if Self::is_const_integral(v) {
+            if self.is_const_integral(v) {
                 let (mut lo, mut hi) = (0u64, 0u64);
                 let success = llvm::LLVMRustConstInt128Get(v, sign_ext,
                                                            &mut hi, &mut lo);
index b2d2e3798986610f0e34ac55938df812d57c8710..09bd3ae264b401a6fa95eacdfa78ecb1a4396bc9 100644 (file)
@@ -34,8 +34,8 @@ pub fn size_and_align_of_dst(
         let (size, align) = bx.cx().size_and_align_of(t);
         debug!("size_and_align_of_dst t={} info={:?} size: {:?} align: {:?}",
                t, info, size, align);
-        let size = CodegenCx::c_usize(bx.cx(), size.bytes());
-        let align = CodegenCx::c_usize(bx.cx(), align.abi());
+        let size = bx.cx().c_usize(size.bytes());
+        let align = bx.cx().c_usize(align.abi());
         return (size, align);
     }
     match t.sty {
@@ -49,8 +49,8 @@ pub fn size_and_align_of_dst(
             // The info in this case is the length of the str, so the size is that
             // times the unit size.
             let (size, align) = bx.cx().size_and_align_of(unit);
-            (bx.mul(info.unwrap(), CodegenCx::c_usize(bx.cx(), size.bytes())),
-             CodegenCx::c_usize(bx.cx(), align.abi()))
+            (bx.mul(info.unwrap(), bx.cx().c_usize(size.bytes())),
+             bx.cx().c_usize(align.abi()))
         }
         _ => {
             let cx = bx.cx();
@@ -93,8 +93,8 @@ pub fn size_and_align_of_dst(
 
             // Choose max of two known alignments (combined value must
             // be aligned according to more restrictive of the two).
-            let align = match (CodegenCx::const_to_opt_u128(sized_align, false),
-                               CodegenCx::const_to_opt_u128(unsized_align, false)) {
+            let align = match (bx.cx().const_to_opt_u128(sized_align, false),
+                               bx.cx().const_to_opt_u128(unsized_align, false)) {
                 (Some(sized_align), Some(unsized_align)) => {
                     // If both alignments are constant, (the sized_align should always be), then
                     // pick the correct alignment statically.
index 9eaf94cff6607351bc7bad436e57178b7d9d8569..79fed084588d71b90c488b298090e8ca97c0d1f2 100644 (file)
@@ -40,16 +40,16 @@ fn c_struct(
         elts: &[Self::Value],
         packed: bool
     ) -> Self::Value;
-    fn c_array(ty: Self::Type, elts: &[Self::Value]) -> Self::Value;
-    fn c_vector(elts: &[Self::Value]) -> Self::Value;
+    fn c_array(&self, ty: Self::Type, elts: &[Self::Value]) -> Self::Value;
+    fn c_vector(&self, elts: &[Self::Value]) -> Self::Value;
     fn c_bytes(&self, bytes: &[u8]) -> Self::Value;
 
-    fn const_get_elt(v: Self::Value, idx: u64) -> Self::Value;
-    fn const_get_real(v: Self::Value) -> Option<(f64, bool)>;
-    fn const_to_uint(v: Self::Value) -> u64;
-    fn is_const_integral(v: Self::Value) -> bool;
-    fn is_const_real(v: Self::Value) -> bool;
-    fn const_to_opt_u128(v: Self::Value, sign_ext: bool) -> Option<u128>;
+    fn const_get_elt(&self, v: Self::Value, idx: u64) -> Self::Value;
+    fn const_get_real(&self, v: Self::Value) -> Option<(f64, bool)>;
+    fn const_to_uint(&self, v: Self::Value) -> u64;
+    fn is_const_integral(&self, v: Self::Value) -> bool;
+    fn is_const_real(&self, v: Self::Value) -> bool;
+    fn const_to_opt_u128(&self, v: Self::Value, sign_ext: bool) -> Option<u128>;
 }
 
 pub trait CommonWriteMethods : Backend {
index 490d3c45aa8f510e6ba0c9202ba8c9c0edad5c17..90837a95c60c0f416c157e7e3c59e9e4600073ae 100644 (file)
@@ -1114,8 +1114,8 @@ macro_rules! require_simd {
         let indices: Option<Vec<_>> = (0..n)
             .map(|i| {
                 let arg_idx = i;
-                let val = CodegenCx::const_get_elt(vector, i as u64);
-                match CodegenCx::const_to_opt_u128(val, true) {
+                let val = bx.cx().const_get_elt(vector, i as u64);
+                match bx.cx().const_to_opt_u128(val, true) {
                     None => {
                         emit_error!("shuffle index #{} is not a constant", arg_idx);
                         None
@@ -1136,7 +1136,7 @@ macro_rules! require_simd {
 
         return Ok(bx.shuffle_vector(args[0].immediate(),
                                     args[1].immediate(),
-                                    CodegenCx::c_vector(&indices)))
+                                    bx.cx().c_vector(&indices)))
     }
 
     if name == "simd_insert" {
@@ -1549,7 +1549,7 @@ macro_rules! arith_red {
                             //   code is generated
                             // * if the accumulator of the fmul isn't 1, incorrect
                             //   code is generated
-                            match CodegenCx::const_get_real(acc) {
+                            match bx.cx().const_get_real(acc) {
                                 None => return_error!("accumulator of {} is not a constant", $name),
                                 Some((v, loses_info)) => {
                                     if $name.contains("mul") && v != 1.0_f64 {
index 737b25a1231bb853639782672db2a44ecae5e1c3..b9599d505d330949703a83158d1aabd954975fdb 100644 (file)
@@ -324,7 +324,7 @@ fn codegen_terminator(&mut self,
 
             mir::TerminatorKind::Assert { ref cond, expected, ref msg, target, cleanup } => {
                 let cond = self.codegen_operand(&bx, cond).immediate();
-                let mut const_cond = CodegenCx::const_to_opt_u128(cond, false).map(|c| c == 1);
+                let mut const_cond = bx.cx().const_to_opt_u128(cond, false).map(|c| c == 1);
 
                 // This case can currently arise only from functions marked
                 // with #[rustc_inherit_overflow_checks] and inlined from
index 3c469cffaf3cb1103eda7dcf256f3b8918f8f47e..2496e10b74b1bed13bde4531cfd547610579e91c 100644 (file)
@@ -20,7 +20,6 @@
 use builder::Builder;
 use callee;
 use common::{self, IntPredicate, RealPredicate};
-use context::CodegenCx;
 use consts;
 use monomorphize;
 use type_::Type;
@@ -110,7 +109,7 @@ pub fn codegen_rvalue(&mut self,
                     let size = bx.cx().c_usize(dest.layout.size.bytes());
 
                     // Use llvm.memset.p0i8.* to initialize all zero arrays
-                    if CodegenCx::is_const_integral(v) && CodegenCx::const_to_uint(v) == 0 {
+                    if bx.cx().is_const_integral(v) && bx.cx().const_to_uint(v) == 0 {
                         let fill = bx.cx().c_u8(0);
                         base::call_memset(&bx, start, fill, size, align, false);
                         return bx;