Add a TargetIsa::regclass_for_abi_type() function.

The legalize_signature() function will return ArgumentLoc::Reg arguments
that contain a register unit. However, the register also needs to be
able to associate a register class with the argument values to fully
track the used registers.

When values are defined by instructions, the register class is part for
the operand constraints for the instruction. For values defined on ABI
boundaries like function arguments and return values from a call, the
register class is provided by the new regclass_for_abi_type() function.

Provide implementations of this function in abi modules of all the
targets, even those that don't have a legalize_signature()
implementation yet.

Since we're adding abi modules to all targets, move the
legalize_signature() stubs in there and make the function mandatory in
TargetIsa. All targets will eventually need this function.
This commit is contained in:
Jakob Stoklund Olesen
2017-04-26 10:11:50 -07:00
parent d078c546e5
commit e67f5e210f
9 changed files with 114 additions and 8 deletions

View File

@@ -168,7 +168,7 @@ pub trait TargetIsa {
/// The legalizer will adapt argument and return values as necessary at all ABI boundaries.
///
/// When this function is called to legalize the signature of the function currently begin
/// compiler, `_current` is true. The legalized signature can then also contain special purpose
/// compiler, `current` is true. The legalized signature can then also contain special purpose
/// arguments and return values such as:
///
/// - A `link` argument representing the link registers on RISC architectures that don't push
@@ -183,9 +183,15 @@ pub trait TargetIsa {
/// Arguments and return values for the caller's frame pointer and other callee-saved registers
/// should not be added by this function. These arguments are not added until after register
/// allocation.
fn legalize_signature(&self, _sig: &mut Signature, _current: bool) {
unimplemented!()
}
fn legalize_signature(&self, sig: &mut Signature, current: bool);
/// Get the register class that should be used to represent an ABI argument or return value of
/// type `ty`. This should be the top-level register class that contains the argument
/// registers.
///
/// This function can assume that it will only be asked to provide register classes for types
/// that `legalize_signature()` produces in `ArgumentLoc::Reg` entries.
fn regclass_for_abi_type(&self, ty: Type) -> RegClass;
/// Emit binary machine code for a single instruction into the `sink` trait object.
///