Add a prologue_epilogue() hook to TargetIsa.

This will compute the stack frame layout as appropriate for the
function's calling convention and insert prologue and epilogue code.

The default implementation is not useful, each target ISA will need to
override this function.
This commit is contained in:
Jakob Stoklund Olesen
2017-08-03 13:48:30 -07:00
parent 39cc7efc2d
commit 92392c6041
2 changed files with 20 additions and 0 deletions

View File

@@ -68,6 +68,7 @@ impl Context {
self.legalize(isa)?;
self.regalloc(isa)?;
self.prologue_epilogue(isa)?;
self.relax_branches(isa)
}
@@ -135,6 +136,12 @@ impl Context {
.run(isa, &mut self.func, &self.cfg, &self.domtree)
}
/// Insert prologue and epilogues after computing the stack frame layout.
pub fn prologue_epilogue(&mut self, isa: &TargetIsa) -> CtonResult {
isa.prologue_epilogue(&mut self.func)?;
self.verify_if(isa)
}
/// Run the branch relaxation pass and return the final code size.
pub fn relax_branches(&mut self, isa: &TargetIsa) -> Result<CodeOffset, CtonError> {
let code_size = relax_branches(&mut self.func, isa)?;