ARM64 backend, part 1 / 11: misc changes to existing code.
- Add a `simple_legalize()` function that invokes a predetermined set of legalizations, without depending on the details of the current backend design. This will be used by the new backend pipeline. - Separate out `has_side_effect()` from the DCE pass. This will be used by the new backends' lowering code. - Add documentation for the `Arm64Call` relocation type.
This commit is contained in:
@@ -196,6 +196,55 @@ pub fn legalize_function(func: &mut ir::Function, cfg: &mut ControlFlowGraph, is
|
||||
}
|
||||
}
|
||||
|
||||
/// Perform a simple legalization by expansion of the function, without
|
||||
/// platform-specific transforms.
|
||||
pub fn simple_legalize(func: &mut ir::Function, cfg: &mut ControlFlowGraph, isa: &dyn TargetIsa) {
|
||||
let mut pos = FuncCursor::new(func);
|
||||
let func_begin = pos.position();
|
||||
pos.set_position(func_begin);
|
||||
while let Some(_block) = pos.next_block() {
|
||||
let mut prev_pos = pos.position();
|
||||
while let Some(inst) = pos.next_inst() {
|
||||
let expanded = match pos.func.dfg[inst].opcode() {
|
||||
ir::Opcode::BrIcmp
|
||||
| ir::Opcode::GlobalValue
|
||||
| ir::Opcode::HeapAddr
|
||||
| ir::Opcode::StackLoad
|
||||
| ir::Opcode::StackStore
|
||||
| ir::Opcode::TableAddr
|
||||
| ir::Opcode::Trapnz
|
||||
| ir::Opcode::Trapz
|
||||
| ir::Opcode::BandImm
|
||||
| ir::Opcode::BorImm
|
||||
| ir::Opcode::BxorImm
|
||||
| ir::Opcode::IaddImm
|
||||
| ir::Opcode::IfcmpImm
|
||||
| ir::Opcode::ImulImm
|
||||
| ir::Opcode::IrsubImm
|
||||
| ir::Opcode::IshlImm
|
||||
| ir::Opcode::RotlImm
|
||||
| ir::Opcode::RotrImm
|
||||
| ir::Opcode::SdivImm
|
||||
| ir::Opcode::SremImm
|
||||
| ir::Opcode::SshrImm
|
||||
| ir::Opcode::UdivImm
|
||||
| ir::Opcode::UremImm
|
||||
| ir::Opcode::UshrImm
|
||||
| ir::Opcode::IcmpImm => expand(inst, &mut pos.func, cfg, isa),
|
||||
_ => false,
|
||||
};
|
||||
|
||||
if expanded {
|
||||
// Legalization implementations require fixpoint loop
|
||||
// here. TODO: fix this.
|
||||
pos.set_position(prev_pos);
|
||||
} else {
|
||||
prev_pos = pos.position();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Include legalization patterns that were generated by `gen_legalizer.rs` from the
|
||||
// `TransformGroup` in `cranelift-codegen/meta/shared/legalize.rs`.
|
||||
//
|
||||
|
||||
Reference in New Issue
Block a user