Assign an affinity to function argument values.

Use the argument types from the function signature to initialize the
affinity of register and stack arguments.
This commit is contained in:
Jakob Stoklund Olesen
2017-04-26 10:47:43 -07:00
parent cd99eee86b
commit 93db01d38a
2 changed files with 24 additions and 7 deletions

View File

@@ -8,7 +8,8 @@
//! subclass. This is just a hint, and the register allocator is allowed to pick a register from a
//! larger register class instead.
use isa::{RegInfo, RegClassIndex, OperandConstraint, ConstraintKind};
use ir::{ArgumentType, ArgumentLoc};
use isa::{TargetIsa, RegInfo, RegClassIndex, OperandConstraint, ConstraintKind};
/// Preferred register allocation for an SSA value.
#[derive(Clone, Copy)]
@@ -42,6 +43,15 @@ impl Affinity {
}
}
/// Create an affinity that matches an ABI argument for `isa`.
pub fn abi(arg: &ArgumentType, isa: &TargetIsa) -> Affinity {
match arg.location {
ArgumentLoc::Unassigned => Affinity::Any,
ArgumentLoc::Reg(_) => Affinity::Reg(isa.regclass_for_abi_type(arg.value_type).into()),
ArgumentLoc::Stack(_) => Affinity::Stack,
}
}
/// Merge an operand constraint into this affinity.
///
/// Note that this does not guarantee that the register allocator will pick a register that