Implement SystemV struct argument passing

This commit is contained in:
bjorn3
2020-04-20 12:01:53 +02:00
committed by Benjamin Bouvier
parent 2f368ed5d6
commit 4431ac1108
15 changed files with 298 additions and 50 deletions

View File

@@ -407,6 +407,8 @@ impl fmt::Debug for VectorType {
#[derive(Clone, Copy, PartialEq, Eq, Hash)]
pub(crate) enum SpecialType {
Flag(shared_types::Flag),
// FIXME remove once the old style backends are removed.
StructArgument,
}
impl SpecialType {
@@ -421,6 +423,9 @@ impl SpecialType {
"CPU flags representing the result of a floating point comparison. These
flags can be tested with a :type:`floatcc` condition code.",
),
SpecialType::StructArgument => {
String::from("After legalization sarg__ arguments will get this type.")
}
}
}
@@ -428,6 +433,7 @@ impl SpecialType {
pub fn lane_bits(self) -> u64 {
match self {
SpecialType::Flag(_) => 0,
SpecialType::StructArgument => 0,
}
}
@@ -436,6 +442,7 @@ impl SpecialType {
match self {
SpecialType::Flag(shared_types::Flag::IFlags) => 1,
SpecialType::Flag(shared_types::Flag::FFlags) => 2,
SpecialType::StructArgument => 3,
}
}
}
@@ -445,6 +452,7 @@ impl fmt::Display for SpecialType {
match *self {
SpecialType::Flag(shared_types::Flag::IFlags) => write!(f, "iflags"),
SpecialType::Flag(shared_types::Flag::FFlags) => write!(f, "fflags"),
SpecialType::StructArgument => write!(f, "sarg__"),
}
}
}
@@ -456,6 +464,7 @@ impl fmt::Debug for SpecialType {
"{}",
match *self {
SpecialType::Flag(_) => format!("FlagsType({})", self),
SpecialType::StructArgument => format!("StructArgument"),
}
)
}
@@ -469,12 +478,14 @@ impl From<shared_types::Flag> for SpecialType {
pub(crate) struct SpecialTypeIterator {
flag_iter: shared_types::FlagIterator,
done: bool,
}
impl SpecialTypeIterator {
fn new() -> Self {
Self {
flag_iter: shared_types::FlagIterator::new(),
done: false,
}
}
}
@@ -485,7 +496,12 @@ impl Iterator for SpecialTypeIterator {
if let Some(f) = self.flag_iter.next() {
Some(SpecialType::from(f))
} else {
None
if !self.done {
self.done = true;
Some(SpecialType::StructArgument)
} else {
None
}
}
}
}