Make legalization actions configurable.
When an instruction doesn't have a valid encoding for the target ISA, it needs to be legalized. Different legalization strategies can be expressed as separate XFormGroup objects. Make the choice of XFormGroup configurable per CPU mode, rather than depending on a hard-coded default. Add a CPUMode.legalize_type() method which assigns an XFormGroup to controlling type variables and lets you set a default. Add a `legalize` field to Level1Entry so the first-level hash table lookup gives us the configured default legalization action for the instruction's controlling type variable.
This commit is contained in:
@@ -126,6 +126,20 @@ pub enum Legalize {
|
||||
Expand,
|
||||
}
|
||||
|
||||
/// Translate a legalization code into a `Legalize` enum.
|
||||
///
|
||||
/// This mapping is going away soon. It depends on matching the `TargetISA.legalize_code()`
|
||||
/// mapping.
|
||||
impl From<u8> for Legalize {
|
||||
fn from(x: u8) -> Legalize {
|
||||
match x {
|
||||
0 => Legalize::Narrow,
|
||||
1 => Legalize::Expand,
|
||||
_ => panic!("Unknown legalization code {}"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Methods that are specialized to a target ISA.
|
||||
pub trait TargetIsa {
|
||||
/// Get the name of this ISA.
|
||||
|
||||
Reference in New Issue
Block a user