-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1494 from cfallin/arm64-merge
Add new `MachInst` backend and ARM64 support.
- Loading branch information
Showing
63 changed files
with
16,668 additions
and
322 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
//! Instruction predicates/properties, shared by various analyses. | ||
use crate::ir::{DataFlowGraph, Function, Inst, InstructionData, Opcode}; | ||
use cranelift_entity::EntityRef; | ||
|
||
/// Preserve instructions with used result values. | ||
pub fn any_inst_results_used(inst: Inst, live: &[bool], dfg: &DataFlowGraph) -> bool { | ||
dfg.inst_results(inst).iter().any(|v| live[v.index()]) | ||
} | ||
|
||
/// Test whether the given opcode is unsafe to even consider as side-effect-free. | ||
fn trivially_has_side_effects(opcode: Opcode) -> bool { | ||
opcode.is_call() | ||
|| opcode.is_branch() | ||
|| opcode.is_terminator() | ||
|| opcode.is_return() | ||
|| opcode.can_trap() | ||
|| opcode.other_side_effects() | ||
|| opcode.can_store() | ||
} | ||
|
||
/// Load instructions without the `notrap` flag are defined to trap when | ||
/// operating on inaccessible memory, so we can't treat them as side-effect-free even if the loaded | ||
/// value is unused. | ||
fn is_load_with_defined_trapping(opcode: Opcode, data: &InstructionData) -> bool { | ||
if !opcode.can_load() { | ||
return false; | ||
} | ||
match *data { | ||
InstructionData::StackLoad { .. } => false, | ||
InstructionData::Load { flags, .. } => !flags.notrap(), | ||
_ => true, | ||
} | ||
} | ||
|
||
/// Does the given instruction have any side-effect that would preclude it from being removed when | ||
/// its value is unused? | ||
pub fn has_side_effect(func: &Function, inst: Inst) -> bool { | ||
let data = &func.dfg[inst]; | ||
let opcode = data.opcode(); | ||
trivially_has_side_effects(opcode) || is_load_with_defined_trapping(opcode, data) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.