]> git.lizzy.rs Git - rust.git/commitdiff
Turn `ArgAbi::pad` into a `bool`.
authorNicholas Nethercote <n.nethercote@gmail.com>
Thu, 25 Aug 2022 09:18:01 +0000 (19:18 +1000)
committerNicholas Nethercote <n.nethercote@gmail.com>
Fri, 26 Aug 2022 00:53:41 +0000 (10:53 +1000)
Because it's only ever set to `None` or `Some(Reg::i32())`.

compiler/rustc_codegen_gcc/src/abi.rs
compiler/rustc_codegen_llvm/src/abi.rs
compiler/rustc_codegen_ssa/src/mir/block.rs
compiler/rustc_codegen_ssa/src/mir/mod.rs
compiler/rustc_const_eval/src/interpret/terminator.rs
compiler/rustc_target/src/abi/call/mips.rs
compiler/rustc_target/src/abi/call/mod.rs
compiler/rustc_target/src/abi/call/sparc.rs

index 87b730d29cdf2118bd1d57595fbb4623c0146b1b..3186b363e359f8d804df49f061a159aa50453267 100644 (file)
@@ -126,8 +126,8 @@ fn gcc_type(&self, cx: &CodegenCx<'gcc, 'tcx>) -> (Type<'gcc>, Vec<Type<'gcc>>,
 
         for arg in self.args.iter() {
             // add padding
-            if let Some(ty) = arg.pad {
-                argument_tys.push(ty.gcc_type(cx));
+            if arg.pad_i32 {
+                argument_tys.push(Reg::i32().gcc_type(cx));
             }
 
             let arg_ty = match arg.mode {
index a06b07c11498952b1585bdb868c58844f074d8e0..168cf3d0b58fef4a0d20fbd9c545c2a2b3bae34d 100644 (file)
@@ -345,8 +345,8 @@ fn llvm_type(&self, cx: &CodegenCx<'ll, 'tcx>) -> &'ll Type {
 
         for arg in args {
             // add padding
-            if let Some(ty) = arg.pad {
-                llargument_tys.push(ty.llvm_type(cx));
+            if arg.pad_i32 {
+                llargument_tys.push(Reg::i32().llvm_type(cx));
             }
 
             let llarg_ty = match &arg.mode {
@@ -440,7 +440,7 @@ fn apply_attrs_llfn(&self, cx: &CodegenCx<'ll, 'tcx>, llfn: &'ll Value) {
             _ => {}
         }
         for arg in self.args.iter() {
-            if arg.pad.is_some() {
+            if arg.pad_i32 {
                 apply(&ArgAttributes::new());
             }
             match &arg.mode {
@@ -516,7 +516,7 @@ fn apply_attrs_callsite(&self, bx: &mut Builder<'_, 'll, 'tcx>, callsite: &'ll V
             }
         }
         for arg in self.args.iter() {
-            if arg.pad.is_some() {
+            if arg.pad_i32 {
                 apply(bx.cx, &ArgAttributes::new());
             }
             match &arg.mode {
index 187af47114f254a59cd99fa5e8505521aacb3caa..5b3f41263e7275ab10de6f0fe5bfbcf7ed6b88e4 100644 (file)
@@ -21,7 +21,7 @@
 use rustc_span::source_map::Span;
 use rustc_span::{sym, Symbol};
 use rustc_symbol_mangling::typeid::typeid_for_fnabi;
-use rustc_target::abi::call::{ArgAbi, FnAbi, PassMode};
+use rustc_target::abi::call::{ArgAbi, FnAbi, PassMode, Reg};
 use rustc_target::abi::{self, HasDataLayout, WrappingRange};
 use rustc_target::spec::abi::Abi;
 
@@ -1159,8 +1159,8 @@ fn codegen_argument(
         arg: &ArgAbi<'tcx, Ty<'tcx>>,
     ) {
         // Fill padding with undef value, where applicable.
-        if let Some(ty) = arg.pad {
-            llargs.push(bx.const_undef(bx.reg_backend_type(&ty)))
+        if arg.pad_i32 {
+            llargs.push(bx.const_undef(bx.reg_backend_type(&Reg::i32())))
         }
 
         if arg.is_ignore() {
index 8ee375fa9e3e9811395f746b91af6665e57afed4..f13b658b2ffbe585122c40dde5426b0d5d86c75e 100644 (file)
@@ -283,7 +283,7 @@ fn arg_local_refs<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
                 for i in 0..tupled_arg_tys.len() {
                     let arg = &fx.fn_abi.args[idx];
                     idx += 1;
-                    if arg.pad.is_some() {
+                    if arg.pad_i32 {
                         llarg_idx += 1;
                     }
                     let pr_field = place.project_field(bx, i);
@@ -309,7 +309,7 @@ fn arg_local_refs<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
 
             let arg = &fx.fn_abi.args[idx];
             idx += 1;
-            if arg.pad.is_some() {
+            if arg.pad_i32 {
                 llarg_idx += 1;
             }
 
index 27bb828feacf794a0fba1a1566461f8ae226fb42..2fcdf6ded9819a01a07af478441efb77ad593f20 100644 (file)
@@ -216,7 +216,7 @@ fn check_argument_compat(
             }
         };
         // Padding must be fully equal.
-        let pad_compat = || caller_abi.pad == callee_abi.pad;
+        let pad_compat = || caller_abi.pad_i32 == callee_abi.pad_i32;
         // When comparing the PassMode, we have to be smart about comparing the attributes.
         let arg_attr_compat = |a1: &ArgAttributes, a2: &ArgAttributes| {
             // There's only one regular attribute that matters for the call ABI: InReg.
index 83d8657af118ec75055362c9d086ab9b6703e2f0..ff8f32362148ca4cdbb6f4eadd6236cb207b76b2 100644 (file)
@@ -24,7 +24,7 @@ fn classify_arg<Ty, C>(cx: &C, arg: &mut ArgAbi<'_, Ty>, offset: &mut Size)
     if arg.layout.is_aggregate() {
         arg.cast_to(Uniform { unit: Reg::i32(), total: size });
         if !offset.is_aligned(align) {
-            arg.pad_with(Reg::i32());
+            arg.pad_with_i32();
         }
     } else {
         arg.extend_integer_width_to(32);
index bf30c24258e86a38b2a72bc8728f684cdcced63b..33f533e68f0e8c883f35993f7fb8bb343bd23453 100644 (file)
@@ -465,7 +465,7 @@ pub struct ArgAbi<'a, Ty> {
     pub layout: TyAndLayout<'a, Ty>,
 
     /// Dummy argument, which is emitted before the real argument.
-    pub pad: Option<Reg>,
+    pub pad_i32: bool,
 
     pub mode: PassMode,
 }
@@ -486,7 +486,7 @@ pub fn new(
             Abi::Vector { .. } => PassMode::Direct(ArgAttributes::new()),
             Abi::Aggregate { .. } => PassMode::Direct(ArgAttributes::new()),
         };
-        ArgAbi { layout, pad: None, mode }
+        ArgAbi { layout, pad_i32: false, mode }
     }
 
     fn indirect_pass_mode(layout: &TyAndLayout<'a, Ty>) -> PassMode {
@@ -551,8 +551,8 @@ pub fn cast_to<T: Into<CastTarget>>(&mut self, target: T) {
         self.mode = PassMode::Cast(Box::new(target.into()));
     }
 
-    pub fn pad_with(&mut self, reg: Reg) {
-        self.pad = Some(reg);
+    pub fn pad_with_i32(&mut self) {
+        self.pad_i32 = true;
     }
 
     pub fn is_indirect(&self) -> bool {
@@ -737,6 +737,6 @@ mod size_asserts {
     use super::*;
     use rustc_data_structures::static_assert_size;
     // These are in alphabetical order, which is easy to maintain.
-    static_assert_size!(ArgAbi<'_, usize>, 72);
-    static_assert_size!(FnAbi<'_, usize>, 96);
+    static_assert_size!(ArgAbi<'_, usize>, 64);
+    static_assert_size!(FnAbi<'_, usize>, 88);
 }
index 83d8657af118ec75055362c9d086ab9b6703e2f0..ff8f32362148ca4cdbb6f4eadd6236cb207b76b2 100644 (file)
@@ -24,7 +24,7 @@ fn classify_arg<Ty, C>(cx: &C, arg: &mut ArgAbi<'_, Ty>, offset: &mut Size)
     if arg.layout.is_aggregate() {
         arg.cast_to(Uniform { unit: Reg::i32(), total: size });
         if !offset.is_aligned(align) {
-            arg.pad_with(Reg::i32());
+            arg.pad_with_i32();
         }
     } else {
         arg.extend_integer_width_to(32);