Add a legalize_signature method to TargetIsa.
This entry point will be used for controlling ABI conventions when legalizing. Provide an empty implementation for RISC-V and let the other ISAs crash in legalization. This is just the scaffolding. We still need to: - Rewrite the entry block arguments to match the legalized signature. - Rewrite call and return instructions. - Implement the legalize_signature() function for all ISAs. - Add shared generic types to help with the legalize_signature() functions.
This commit is contained in:
@@ -23,6 +23,8 @@ use isa::{TargetIsa, Legalize};
|
||||
/// - Fill out `func.encodings`.
|
||||
///
|
||||
pub fn legalize_function(func: &mut Function, isa: &TargetIsa) {
|
||||
legalize_signatures(func, isa);
|
||||
|
||||
// TODO: This is very simplified and incomplete.
|
||||
func.encodings.resize(func.dfg.num_insts());
|
||||
let mut pos = Cursor::new(&mut func.layout);
|
||||
@@ -74,3 +76,15 @@ pub fn legalize_function(func: &mut Function, isa: &TargetIsa) {
|
||||
//
|
||||
// Concretely, this defines private functions `narrow()`, and `expand()`.
|
||||
include!(concat!(env!("OUT_DIR"), "/legalizer.rs"));
|
||||
|
||||
/// Legalize all the function signatures in `func`.
|
||||
///
|
||||
/// This changes all signatures to be ABI-compliant with full `ArgumentLoc` annotations. It doesn't
|
||||
/// change the entry block arguments, calls, or return instructions, so this can leave the function
|
||||
/// in a state with type discrepancies.
|
||||
fn legalize_signatures(func: &mut Function, isa: &TargetIsa) {
|
||||
isa.legalize_signature(&mut func.signature);
|
||||
for sig in func.dfg.signatures.keys() {
|
||||
isa.legalize_signature(&mut func.dfg.signatures[sig]);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user