Turn ArgAbi::pad into a bool.

Because it's only ever set to `None` or `Some(Reg::i32())`.
This commit is contained in:
Nicholas Nethercote 2022-08-25 19:18:01 +10:00
parent feeaa4db3c
commit b853e8a619
8 changed files with 20 additions and 20 deletions

View file

@ -126,8 +126,8 @@ impl<'gcc, 'tcx> FnAbiGccExt<'gcc, 'tcx> for FnAbi<'tcx, Ty<'tcx>> {
for arg in self.args.iter() { for arg in self.args.iter() {
// add padding // add padding
if let Some(ty) = arg.pad { if arg.pad_i32 {
argument_tys.push(ty.gcc_type(cx)); argument_tys.push(Reg::i32().gcc_type(cx));
} }
let arg_ty = match arg.mode { let arg_ty = match arg.mode {

View file

@ -345,8 +345,8 @@ impl<'ll, 'tcx> FnAbiLlvmExt<'ll, 'tcx> for FnAbi<'tcx, Ty<'tcx>> {
for arg in args { for arg in args {
// add padding // add padding
if let Some(ty) = arg.pad { if arg.pad_i32 {
llargument_tys.push(ty.llvm_type(cx)); llargument_tys.push(Reg::i32().llvm_type(cx));
} }
let llarg_ty = match &arg.mode { let llarg_ty = match &arg.mode {
@ -440,7 +440,7 @@ impl<'ll, 'tcx> FnAbiLlvmExt<'ll, 'tcx> for FnAbi<'tcx, Ty<'tcx>> {
_ => {} _ => {}
} }
for arg in self.args.iter() { for arg in self.args.iter() {
if arg.pad.is_some() { if arg.pad_i32 {
apply(&ArgAttributes::new()); apply(&ArgAttributes::new());
} }
match &arg.mode { match &arg.mode {
@ -516,7 +516,7 @@ impl<'ll, 'tcx> FnAbiLlvmExt<'ll, 'tcx> for FnAbi<'tcx, Ty<'tcx>> {
} }
} }
for arg in self.args.iter() { for arg in self.args.iter() {
if arg.pad.is_some() { if arg.pad_i32 {
apply(bx.cx, &ArgAttributes::new()); apply(bx.cx, &ArgAttributes::new());
} }
match &arg.mode { match &arg.mode {

View file

@ -21,7 +21,7 @@ use rustc_middle::ty::{self, Instance, Ty, TypeVisitable};
use rustc_span::source_map::Span; use rustc_span::source_map::Span;
use rustc_span::{sym, Symbol}; use rustc_span::{sym, Symbol};
use rustc_symbol_mangling::typeid::typeid_for_fnabi; 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::abi::{self, HasDataLayout, WrappingRange};
use rustc_target::spec::abi::Abi; use rustc_target::spec::abi::Abi;
@ -1159,8 +1159,8 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
arg: &ArgAbi<'tcx, Ty<'tcx>>, arg: &ArgAbi<'tcx, Ty<'tcx>>,
) { ) {
// Fill padding with undef value, where applicable. // Fill padding with undef value, where applicable.
if let Some(ty) = arg.pad { if arg.pad_i32 {
llargs.push(bx.const_undef(bx.reg_backend_type(&ty))) llargs.push(bx.const_undef(bx.reg_backend_type(&Reg::i32())))
} }
if arg.is_ignore() { if arg.is_ignore() {

View file

@ -283,7 +283,7 @@ fn arg_local_refs<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
for i in 0..tupled_arg_tys.len() { for i in 0..tupled_arg_tys.len() {
let arg = &fx.fn_abi.args[idx]; let arg = &fx.fn_abi.args[idx];
idx += 1; idx += 1;
if arg.pad.is_some() { if arg.pad_i32 {
llarg_idx += 1; llarg_idx += 1;
} }
let pr_field = place.project_field(bx, i); 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]; let arg = &fx.fn_abi.args[idx];
idx += 1; idx += 1;
if arg.pad.is_some() { if arg.pad_i32 {
llarg_idx += 1; llarg_idx += 1;
} }

View file

@ -216,7 +216,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
} }
}; };
// Padding must be fully equal. // 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. // When comparing the PassMode, we have to be smart about comparing the attributes.
let arg_attr_compat = |a1: &ArgAttributes, a2: &ArgAttributes| { let arg_attr_compat = |a1: &ArgAttributes, a2: &ArgAttributes| {
// There's only one regular attribute that matters for the call ABI: InReg. // There's only one regular attribute that matters for the call ABI: InReg.

View file

@ -24,7 +24,7 @@ where
if arg.layout.is_aggregate() { if arg.layout.is_aggregate() {
arg.cast_to(Uniform { unit: Reg::i32(), total: size }); arg.cast_to(Uniform { unit: Reg::i32(), total: size });
if !offset.is_aligned(align) { if !offset.is_aligned(align) {
arg.pad_with(Reg::i32()); arg.pad_with_i32();
} }
} else { } else {
arg.extend_integer_width_to(32); arg.extend_integer_width_to(32);

View file

@ -465,7 +465,7 @@ pub struct ArgAbi<'a, Ty> {
pub layout: TyAndLayout<'a, Ty>, pub layout: TyAndLayout<'a, Ty>,
/// Dummy argument, which is emitted before the real argument. /// Dummy argument, which is emitted before the real argument.
pub pad: Option<Reg>, pub pad_i32: bool,
pub mode: PassMode, pub mode: PassMode,
} }
@ -486,7 +486,7 @@ impl<'a, Ty> ArgAbi<'a, Ty> {
Abi::Vector { .. } => PassMode::Direct(ArgAttributes::new()), Abi::Vector { .. } => PassMode::Direct(ArgAttributes::new()),
Abi::Aggregate { .. } => 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 { fn indirect_pass_mode(layout: &TyAndLayout<'a, Ty>) -> PassMode {
@ -551,8 +551,8 @@ impl<'a, Ty> ArgAbi<'a, Ty> {
self.mode = PassMode::Cast(Box::new(target.into())); self.mode = PassMode::Cast(Box::new(target.into()));
} }
pub fn pad_with(&mut self, reg: Reg) { pub fn pad_with_i32(&mut self) {
self.pad = Some(reg); self.pad_i32 = true;
} }
pub fn is_indirect(&self) -> bool { pub fn is_indirect(&self) -> bool {
@ -737,6 +737,6 @@ mod size_asserts {
use super::*; use super::*;
use rustc_data_structures::static_assert_size; use rustc_data_structures::static_assert_size;
// These are in alphabetical order, which is easy to maintain. // These are in alphabetical order, which is easy to maintain.
static_assert_size!(ArgAbi<'_, usize>, 72); static_assert_size!(ArgAbi<'_, usize>, 64);
static_assert_size!(FnAbi<'_, usize>, 96); static_assert_size!(FnAbi<'_, usize>, 88);
} }

View file

@ -24,7 +24,7 @@ where
if arg.layout.is_aggregate() { if arg.layout.is_aggregate() {
arg.cast_to(Uniform { unit: Reg::i32(), total: size }); arg.cast_to(Uniform { unit: Reg::i32(), total: size });
if !offset.is_aligned(align) { if !offset.is_aligned(align) {
arg.pad_with(Reg::i32()); arg.pad_with_i32();
} }
} else { } else {
arg.extend_integer_width_to(32); arg.extend_integer_width_to(32);