Avoid infer_rex() and w() on the same x86 encoding template, resolves #1342
In cranelift x86 encodings, it seemed unintuitive to specialize Templates with both `infer_rex()`` and `w()`: if `w()` is specified, the REX.W bit must be set so a REX prefix is alway required--no need to infer it. This change forces us to write `rex().w()``--it's more explicit and shows more clearly what cranelift will emit. This change also modifies the tests that expected DynRex recipes.
This commit is contained in:
@@ -156,7 +156,7 @@ impl PerCpuModeEncodings {
|
||||
self.enc64(inst.bind(I32), template.infer_rex());
|
||||
|
||||
// I64 on x86_64: REX.W set; REX.RXB determined at runtime from registers.
|
||||
self.enc64(inst.bind(I64), template.infer_rex().w());
|
||||
self.enc64(inst.bind(I64), template.rex().w());
|
||||
}
|
||||
|
||||
/// Adds I32/I64 encodings as appropriate for a typed instruction.
|
||||
@@ -192,7 +192,7 @@ impl PerCpuModeEncodings {
|
||||
self.enc64(inst.bind(B32), template.infer_rex());
|
||||
|
||||
// B64 on x86_64: REX.W set; REX.RXB determined at runtime from registers.
|
||||
self.enc64(inst.bind(B64), template.infer_rex().w());
|
||||
self.enc64(inst.bind(B64), template.rex().w());
|
||||
}
|
||||
|
||||
/// Add encodings for `inst.i32` to X86_32.
|
||||
|
||||
@@ -335,6 +335,7 @@ impl<'builder> Template<'builder> {
|
||||
("Rex".to_string() + opcode, self.op_bytes.len() as u64 + 1)
|
||||
}
|
||||
RecipePrefixKind::InferRex => {
|
||||
assert_eq!(self.w_bit, 0, "A REX.W bit always requires a REX prefix; avoid using `infer_rex().w()` and use `rex().w()` instead.");
|
||||
// Hook up the right function for inferred compute_size().
|
||||
assert!(
|
||||
self.inferred_rex_compute_size.is_some(),
|
||||
|
||||
Reference in New Issue
Block a user