about summary refs log tree commit diff
path: root/compiler
diff options
context:
space:
mode:
Diffstat (limited to 'compiler')
-rw-r--r--compiler/rustc_smir/src/rustc_smir/convert/abi.rs21
-rw-r--r--compiler/stable_mir/src/abi.rs15
2 files changed, 23 insertions, 13 deletions
diff --git a/compiler/rustc_smir/src/rustc_smir/convert/abi.rs b/compiler/rustc_smir/src/rustc_smir/convert/abi.rs
index 46ae0929bcd..632e97b32f5 100644
--- a/compiler/rustc_smir/src/rustc_smir/convert/abi.rs
+++ b/compiler/rustc_smir/src/rustc_smir/convert/abi.rs
@@ -66,11 +66,14 @@ impl<'tcx> Stable<'tcx> for rustc_target::abi::call::FnAbi<'tcx, ty::Ty<'tcx>> {
     type T = FnAbi;
 
     fn stable(&self, tables: &mut Tables<'tcx>) -> Self::T {
+        assert!(self.args.len() >= self.fixed_count as usize);
+        assert!(!self.c_variadic || matches!(self.conv, Conv::C));
         FnAbi {
             args: self.args.as_ref().stable(tables),
             ret: self.ret.stable(tables),
             fixed_count: self.fixed_count,
             conv: self.conv.stable(tables),
+            c_variadic: self.c_variadic,
         }
     }
 }
@@ -122,10 +125,20 @@ impl<'tcx> Stable<'tcx> for rustc_target::abi::call::PassMode {
     fn stable(&self, _tables: &mut Tables<'tcx>) -> Self::T {
         match self {
             rustc_target::abi::call::PassMode::Ignore => PassMode::Ignore,
-            rustc_target::abi::call::PassMode::Direct(_) => PassMode::Direct,
-            rustc_target::abi::call::PassMode::Pair(_, _) => PassMode::Pair,
-            rustc_target::abi::call::PassMode::Cast { .. } => PassMode::Cast,
-            rustc_target::abi::call::PassMode::Indirect { .. } => PassMode::Indirect,
+            rustc_target::abi::call::PassMode::Direct(attr) => PassMode::Direct(opaque(attr)),
+            rustc_target::abi::call::PassMode::Pair(first, second) => {
+                PassMode::Pair(opaque(first), opaque(second))
+            }
+            rustc_target::abi::call::PassMode::Cast { pad_i32, cast } => {
+                PassMode::Cast { pad_i32: *pad_i32, cast: opaque(cast) }
+            }
+            rustc_target::abi::call::PassMode::Indirect { attrs, meta_attrs, on_stack } => {
+                PassMode::Indirect {
+                    attrs: opaque(attrs),
+                    meta_attrs: opaque(meta_attrs),
+                    on_stack: *on_stack,
+                }
+            }
         }
     }
 }
diff --git a/compiler/stable_mir/src/abi.rs b/compiler/stable_mir/src/abi.rs
index d4e8e874c1f..53dac6abefb 100644
--- a/compiler/stable_mir/src/abi.rs
+++ b/compiler/stable_mir/src/abi.rs
@@ -21,12 +21,9 @@ pub struct FnAbi {
 
     /// The ABI convention.
     pub conv: CallConvention,
-}
 
-impl FnAbi {
-    pub fn is_c_variadic(&self) -> bool {
-        self.args.len() > self.fixed_count as usize
-    }
+    /// Whether this is a variadic C function,
+    pub c_variadic: bool,
 }
 
 /// Information about the ABI of a function's argument, or return value.
@@ -47,15 +44,15 @@ pub enum PassMode {
     /// Pass the argument directly.
     ///
     /// The argument has a layout abi of `Scalar` or `Vector`.
-    Direct,
+    Direct(Opaque),
     /// Pass a pair's elements directly in two arguments.
     ///
     /// The argument has a layout abi of `ScalarPair`.
-    Pair,
+    Pair(Opaque, Opaque),
     /// Pass the argument after casting it.
-    Cast,
+    Cast { pad_i32: bool, cast: Opaque },
     /// Pass the argument indirectly via a hidden pointer.
-    Indirect,
+    Indirect { attrs: Opaque, meta_attrs: Opaque, on_stack: bool },
 }
 
 /// The layout of a type, alongside the type itself.