1
Fork 0

turns out Layout has some more things to worry about -- move ABI comparison into helper function

like is_bool, and some special magic extra fields
This commit is contained in:
Ralf Jung 2023-09-07 16:48:02 +02:00
parent 28d152935e
commit b0cf4c28ea
4 changed files with 38 additions and 25 deletions

View file

@ -60,7 +60,8 @@ pub enum PassMode {
impl PassMode {
/// Checks if these two `PassMode` are equal enough to be considered "the same for all
/// function call ABIs".
/// function call ABIs". However, the `Layout` can also impact ABI decisions,
/// so that needs to be compared as well!
pub fn eq_abi(&self, other: &Self) -> bool {
match (self, other) {
(PassMode::Ignore, PassMode::Ignore) => true, // can still be reached for the return type
@ -623,6 +624,14 @@ impl<'a, Ty> ArgAbi<'a, Ty> {
pub fn is_ignore(&self) -> bool {
matches!(self.mode, PassMode::Ignore)
}
/// Checks if these two `ArgAbi` are equal enough to be considered "the same for all
/// function call ABIs".
pub fn eq_abi(&self, other: &Self) -> bool {
// Ideally we'd just compare the `mode`, but that is not enough -- for some modes LLVM will look
// at the type.
self.layout.eq_abi(&other.layout) && self.mode.eq_abi(&other.mode)
}
}
#[derive(Copy, Clone, PartialEq, Eq, Hash, Debug, HashStable_Generic)]