Replace sext() and zext() with single ext() method
This commit is contained in:
parent
6a5f537fb9
commit
43968aa8b8
@ -15,7 +15,7 @@ use rustc_session::{DataTypeKind, FieldInfo, SizeKind, VariantInfo};
|
||||
use rustc_span::symbol::{Ident, Symbol};
|
||||
use rustc_span::DUMMY_SP;
|
||||
use rustc_target::abi::call::{
|
||||
ArgAbi, ArgAttribute, ArgAttributes, Conv, FnAbi, PassMode, Reg, RegKind,
|
||||
ArgAbi, ArgAttribute, ArgAttributes, ArgExtension, Conv, FnAbi, PassMode, Reg, RegKind,
|
||||
};
|
||||
use rustc_target::abi::*;
|
||||
use rustc_target::spec::{abi::Abi as SpecAbi, HasTargetSpec, PanicStrategy};
|
||||
@ -2619,7 +2619,7 @@ where
|
||||
is_return: bool| {
|
||||
// Booleans are always an i1 that needs to be zero-extended.
|
||||
if scalar.is_bool() {
|
||||
attrs.zext();
|
||||
attrs.ext(ArgExtension::Zext);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
use crate::abi::call::{ArgAbi, CastTarget, FnAbi, PassMode, Reg, RegKind, Uniform};
|
||||
use crate::abi::call::{ArgAbi, ArgExtension, CastTarget, FnAbi, PassMode, Reg, RegKind, Uniform};
|
||||
use crate::abi::{self, HasDataLayout, LayoutOf, Size, TyAndLayout, TyAndLayoutMethods};
|
||||
|
||||
fn extend_integer_width_mips<Ty>(arg: &mut ArgAbi<'_, Ty>, bits: u64) {
|
||||
@ -7,7 +7,7 @@ fn extend_integer_width_mips<Ty>(arg: &mut ArgAbi<'_, Ty>, bits: u64) {
|
||||
if let abi::Int(i, signed) = scalar.value {
|
||||
if !signed && i.size().bits() == 32 {
|
||||
if let PassMode::Direct(ref mut attrs) = arg.mode {
|
||||
attrs.sext();
|
||||
attrs.ext(ArgExtension::Sext);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -96,15 +96,9 @@ impl ArgAttributes {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn zext(&mut self) -> &mut Self {
|
||||
assert_ne!(self.arg_ext, ArgExtension::Sext);
|
||||
self.arg_ext = ArgExtension::Zext;
|
||||
self
|
||||
}
|
||||
|
||||
pub fn sext(&mut self) -> &mut Self {
|
||||
assert_ne!(self.arg_ext, ArgExtension::Zext);
|
||||
self.arg_ext = ArgExtension::Sext;
|
||||
pub fn ext(&mut self, ext: ArgExtension) -> &mut Self {
|
||||
assert!(self.arg_ext == ArgExtension::None || self.arg_ext == ext);
|
||||
self.arg_ext = ext;
|
||||
self
|
||||
}
|
||||
|
||||
@ -481,9 +475,9 @@ impl<'a, Ty> ArgAbi<'a, Ty> {
|
||||
if i.size().bits() < bits {
|
||||
if let PassMode::Direct(ref mut attrs) = self.mode {
|
||||
if signed {
|
||||
attrs.sext()
|
||||
attrs.ext(ArgExtension::Sext)
|
||||
} else {
|
||||
attrs.zext()
|
||||
attrs.ext(ArgExtension::Zext)
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -4,7 +4,7 @@
|
||||
// Reference: Clang RISC-V ELF psABI lowering code
|
||||
// https://github.com/llvm/llvm-project/blob/8e780252a7284be45cf1ba224cabd884847e8e92/clang/lib/CodeGen/TargetInfo.cpp#L9311-L9773
|
||||
|
||||
use crate::abi::call::{ArgAbi, CastTarget, FnAbi, PassMode, Reg, RegKind, Uniform};
|
||||
use crate::abi::call::{ArgAbi, ArgExtension, CastTarget, FnAbi, PassMode, Reg, RegKind, Uniform};
|
||||
use crate::abi::{
|
||||
self, Abi, FieldsShape, HasDataLayout, LayoutOf, Size, TyAndLayout, TyAndLayoutMethods,
|
||||
};
|
||||
@ -308,7 +308,7 @@ fn extend_integer_width<'a, Ty>(arg: &mut ArgAbi<'a, Ty>, xlen: u64) {
|
||||
// 32-bit integers are always sign-extended
|
||||
if i.size().bits() == 32 && xlen > 32 {
|
||||
if let PassMode::Direct(ref mut attrs) = arg.mode {
|
||||
attrs.sext();
|
||||
attrs.ext(ArgExtension::Sext);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user