Skip to content

Commit b853e8a

Browse files
committedAug 26, 2022
Turn ArgAbi::pad into a bool.
Because it's only ever set to `None` or `Some(Reg::i32())`.
1 parent feeaa4d commit b853e8a

File tree

8 files changed

+20
-20
lines changed

8 files changed

+20
-20
lines changed
 

Diff for: ‎compiler/rustc_codegen_gcc/src/abi.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -126,8 +126,8 @@ impl<'gcc, 'tcx> FnAbiGccExt<'gcc, 'tcx> for FnAbi<'tcx, Ty<'tcx>> {
126126

127127
for arg in self.args.iter() {
128128
// add padding
129-
if let Some(ty) = arg.pad {
130-
argument_tys.push(ty.gcc_type(cx));
129+
if arg.pad_i32 {
130+
argument_tys.push(Reg::i32().gcc_type(cx));
131131
}
132132

133133
let arg_ty = match arg.mode {

Diff for: ‎compiler/rustc_codegen_llvm/src/abi.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -345,8 +345,8 @@ impl<'ll, 'tcx> FnAbiLlvmExt<'ll, 'tcx> for FnAbi<'tcx, Ty<'tcx>> {
345345

346346
for arg in args {
347347
// add padding
348-
if let Some(ty) = arg.pad {
349-
llargument_tys.push(ty.llvm_type(cx));
348+
if arg.pad_i32 {
349+
llargument_tys.push(Reg::i32().llvm_type(cx));
350350
}
351351

352352
let llarg_ty = match &arg.mode {
@@ -440,7 +440,7 @@ impl<'ll, 'tcx> FnAbiLlvmExt<'ll, 'tcx> for FnAbi<'tcx, Ty<'tcx>> {
440440
_ => {}
441441
}
442442
for arg in self.args.iter() {
443-
if arg.pad.is_some() {
443+
if arg.pad_i32 {
444444
apply(&ArgAttributes::new());
445445
}
446446
match &arg.mode {
@@ -516,7 +516,7 @@ impl<'ll, 'tcx> FnAbiLlvmExt<'ll, 'tcx> for FnAbi<'tcx, Ty<'tcx>> {
516516
}
517517
}
518518
for arg in self.args.iter() {
519-
if arg.pad.is_some() {
519+
if arg.pad_i32 {
520520
apply(bx.cx, &ArgAttributes::new());
521521
}
522522
match &arg.mode {

Diff for: ‎compiler/rustc_codegen_ssa/src/mir/block.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ use rustc_middle::ty::{self, Instance, Ty, TypeVisitable};
2121
use rustc_span::source_map::Span;
2222
use rustc_span::{sym, Symbol};
2323
use rustc_symbol_mangling::typeid::typeid_for_fnabi;
24-
use rustc_target::abi::call::{ArgAbi, FnAbi, PassMode};
24+
use rustc_target::abi::call::{ArgAbi, FnAbi, PassMode, Reg};
2525
use rustc_target::abi::{self, HasDataLayout, WrappingRange};
2626
use rustc_target::spec::abi::Abi;
2727

@@ -1159,8 +1159,8 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
11591159
arg: &ArgAbi<'tcx, Ty<'tcx>>,
11601160
) {
11611161
// Fill padding with undef value, where applicable.
1162-
if let Some(ty) = arg.pad {
1163-
llargs.push(bx.const_undef(bx.reg_backend_type(&ty)))
1162+
if arg.pad_i32 {
1163+
llargs.push(bx.const_undef(bx.reg_backend_type(&Reg::i32())))
11641164
}
11651165

11661166
if arg.is_ignore() {

Diff for: ‎compiler/rustc_codegen_ssa/src/mir/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ fn arg_local_refs<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
283283
for i in 0..tupled_arg_tys.len() {
284284
let arg = &fx.fn_abi.args[idx];
285285
idx += 1;
286-
if arg.pad.is_some() {
286+
if arg.pad_i32 {
287287
llarg_idx += 1;
288288
}
289289
let pr_field = place.project_field(bx, i);
@@ -309,7 +309,7 @@ fn arg_local_refs<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
309309

310310
let arg = &fx.fn_abi.args[idx];
311311
idx += 1;
312-
if arg.pad.is_some() {
312+
if arg.pad_i32 {
313313
llarg_idx += 1;
314314
}
315315

Diff for: ‎compiler/rustc_const_eval/src/interpret/terminator.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
216216
}
217217
};
218218
// Padding must be fully equal.
219-
let pad_compat = || caller_abi.pad == callee_abi.pad;
219+
let pad_compat = || caller_abi.pad_i32 == callee_abi.pad_i32;
220220
// When comparing the PassMode, we have to be smart about comparing the attributes.
221221
let arg_attr_compat = |a1: &ArgAttributes, a2: &ArgAttributes| {
222222
// There's only one regular attribute that matters for the call ABI: InReg.

Diff for: ‎compiler/rustc_target/src/abi/call/mips.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ where
2424
if arg.layout.is_aggregate() {
2525
arg.cast_to(Uniform { unit: Reg::i32(), total: size });
2626
if !offset.is_aligned(align) {
27-
arg.pad_with(Reg::i32());
27+
arg.pad_with_i32();
2828
}
2929
} else {
3030
arg.extend_integer_width_to(32);

Diff for: ‎compiler/rustc_target/src/abi/call/mod.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -465,7 +465,7 @@ pub struct ArgAbi<'a, Ty> {
465465
pub layout: TyAndLayout<'a, Ty>,
466466

467467
/// Dummy argument, which is emitted before the real argument.
468-
pub pad: Option<Reg>,
468+
pub pad_i32: bool,
469469

470470
pub mode: PassMode,
471471
}
@@ -486,7 +486,7 @@ impl<'a, Ty> ArgAbi<'a, Ty> {
486486
Abi::Vector { .. } => PassMode::Direct(ArgAttributes::new()),
487487
Abi::Aggregate { .. } => PassMode::Direct(ArgAttributes::new()),
488488
};
489-
ArgAbi { layout, pad: None, mode }
489+
ArgAbi { layout, pad_i32: false, mode }
490490
}
491491

492492
fn indirect_pass_mode(layout: &TyAndLayout<'a, Ty>) -> PassMode {
@@ -551,8 +551,8 @@ impl<'a, Ty> ArgAbi<'a, Ty> {
551551
self.mode = PassMode::Cast(Box::new(target.into()));
552552
}
553553

554-
pub fn pad_with(&mut self, reg: Reg) {
555-
self.pad = Some(reg);
554+
pub fn pad_with_i32(&mut self) {
555+
self.pad_i32 = true;
556556
}
557557

558558
pub fn is_indirect(&self) -> bool {
@@ -737,6 +737,6 @@ mod size_asserts {
737737
use super::*;
738738
use rustc_data_structures::static_assert_size;
739739
// These are in alphabetical order, which is easy to maintain.
740-
static_assert_size!(ArgAbi<'_, usize>, 72);
741-
static_assert_size!(FnAbi<'_, usize>, 96);
740+
static_assert_size!(ArgAbi<'_, usize>, 64);
741+
static_assert_size!(FnAbi<'_, usize>, 88);
742742
}

Diff for: ‎compiler/rustc_target/src/abi/call/sparc.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ where
2424
if arg.layout.is_aggregate() {
2525
arg.cast_to(Uniform { unit: Reg::i32(), total: size });
2626
if !offset.is_aligned(align) {
27-
arg.pad_with(Reg::i32());
27+
arg.pad_with_i32();
2828
}
2929
} else {
3030
arg.extend_integer_width_to(32);

0 commit comments

Comments
 (0)
Please sign in to comment.