]> git.lizzy.rs Git - rust.git/blobdiff - src/librustc_codegen_llvm/common.rs
Remove is_const_integral method from ConstMethods
[rust.git] / src / librustc_codegen_llvm / common.rs
index c337e35460e1829e0f0c9ebda938bf825ce2aab6..cc2f1b6776e457b002a489c0e9751206a0aa493d 100644 (file)
@@ -86,6 +86,8 @@ pub fn bundle(&self) -> &OperandBundleDef<'ll> {
 
 impl BackendTypes for CodegenCx<'ll, 'tcx> {
     type Value = &'ll Value;
+    type FuncId = &'ll Value;
+
     type BasicBlock = &'ll BasicBlock;
     type Type = &'ll Type;
     type Funclet = Funclet<'ll>;
@@ -243,21 +245,19 @@ fn const_struct(
         struct_in_context(self.llcx, elts, packed)
     }
 
-    fn const_to_uint(&self, v: &'ll Value) -> u64 {
-        unsafe {
-            llvm::LLVMConstIntGetZExtValue(v)
-        }
-    }
-
-    fn is_const_integral(&self, v: &'ll Value) -> bool {
-        unsafe {
-            llvm::LLVMIsAConstantInt(v).is_some()
+    fn const_to_opt_uint(&self, v: &'ll Value) -> Option<u64> {
+        if is_const_integral(v) {
+            unsafe {
+                Some(llvm::LLVMConstIntGetZExtValue(v))
+            }
+        } else {
+            None
         }
     }
 
     fn const_to_opt_u128(&self, v: &'ll Value, sign_ext: bool) -> Option<u128> {
         unsafe {
-            if self.is_const_integral(v) {
+            if is_const_integral(v) {
                 let (mut lo, mut hi) = (0u64, 0u64);
                 let success = llvm::LLVMRustConstInt128Get(v, sign_ext,
                                                            &mut hi, &mut lo);
@@ -349,7 +349,7 @@ fn from_const_alloc(
             )};
             self.const_bitcast(llval, llty)
         };
-        PlaceRef::new_sized(llval, layout, alloc.align)
+        PlaceRef::new_sized(llval, layout)
     }
 
     fn const_ptrcast(&self, val: &'ll Value, ty: &'ll Type) -> &'ll Value {
@@ -386,3 +386,9 @@ pub fn struct_in_context(
 fn hi_lo_to_u128(lo: u64, hi: u64) -> u128 {
     ((hi as u128) << 64) | (lo as u128)
 }
+
+fn is_const_integral(v: &'ll Value) -> bool {
+    unsafe {
+        llvm::LLVMIsAConstantInt(v).is_some()
+    }
+}