]> git.lizzy.rs Git - rust.git/commitdiff
Move vtable_size and vtable_align impls to cg_ssa
authorbjorn3 <17426603+bjorn3@users.noreply.github.com>
Wed, 20 Jul 2022 13:40:30 +0000 (13:40 +0000)
committerRalf Jung <post@ralfj.de>
Wed, 20 Jul 2022 21:12:08 +0000 (17:12 -0400)
compiler/rustc_codegen_llvm/src/intrinsic.rs
compiler/rustc_codegen_ssa/src/mir/intrinsic.rs

index 9cca9bcf7246735c00d6d8b9dfb0d3aa7d47bb00..9f3647492877ccd3eda40354ac6c15e0da5b883a 100644 (file)
@@ -10,7 +10,6 @@
 use rustc_codegen_ssa::base::{compare_simd_types, wants_msvc_seh};
 use rustc_codegen_ssa::common::span_invalid_monomorphization_error;
 use rustc_codegen_ssa::common::{IntPredicate, TypeKind};
-use rustc_codegen_ssa::meth;
 use rustc_codegen_ssa::mir::operand::OperandRef;
 use rustc_codegen_ssa::mir::place::PlaceRef;
 use rustc_codegen_ssa::traits::*;
@@ -364,16 +363,6 @@ fn codegen_intrinsic_call(
                 return;
             }
 
-            sym::vtable_size | sym::vtable_align => {
-                let vtable = args[0].immediate();
-                let idx = match name {
-                    sym::vtable_size => ty::COMMON_VTABLE_ENTRIES_SIZE,
-                    sym::vtable_align => ty::COMMON_VTABLE_ENTRIES_ALIGN,
-                    _ => bug!(),
-                };
-                meth::VirtualIndex::from_index(idx).get_usize(self, vtable)
-            }
-
             _ if name.as_str().starts_with("simd_") => {
                 match generic_simd_intrinsic(self, name, callee_ty, args, ret_ty, llret_ty, span) {
                     Ok(llval) => llval,
index 645afae30d88729b518c338f656330a0670f84bd..1fffa3beaaa85174dc5b0745e901b7e310da35f6 100644 (file)
@@ -3,6 +3,7 @@
 use super::FunctionCx;
 use crate::common::{span_invalid_monomorphization_error, IntPredicate};
 use crate::glue;
+use crate::meth;
 use crate::traits::*;
 use crate::MemFlags;
 
@@ -102,6 +103,15 @@ pub fn codegen_intrinsic_call(
                     bx.const_usize(bx.layout_of(tp_ty).align.abi.bytes())
                 }
             }
+            sym::vtable_size | sym::vtable_align => {
+                let vtable = args[0].immediate();
+                let idx = match name {
+                    sym::vtable_size => ty::COMMON_VTABLE_ENTRIES_SIZE,
+                    sym::vtable_align => ty::COMMON_VTABLE_ENTRIES_ALIGN,
+                    _ => bug!(),
+                };
+                meth::VirtualIndex::from_index(idx).get_usize(bx, vtable)
+            }
             sym::pref_align_of
             | sym::needs_drop
             | sym::type_id