Cranelift: Make Opcode represented as a u8 instead of u16 and remove vestigial conversion impls (#5042)
* Cranelift: Make `Opcode` represented as a `u8` instead of `u16` * Cranelift: Remove unused conversion impls for `Opcode` These are vestigial, left over from Peepmatic.
This commit is contained in:
@@ -405,7 +405,7 @@ fn gen_opcodes(all_inst: &AllInstructions, fmt: &mut Formatter) {
|
||||
All instructions from all supported ISAs are present.
|
||||
"#,
|
||||
);
|
||||
fmt.line("#[repr(u16)]");
|
||||
fmt.line("#[repr(u8)]");
|
||||
fmt.line("#[derive(Copy, Clone, PartialEq, Eq, Debug, Hash)]");
|
||||
fmt.line(
|
||||
r#"#[cfg_attr(
|
||||
@@ -572,24 +572,6 @@ fn gen_opcodes(all_inst: &AllInstructions, fmt: &mut Formatter) {
|
||||
fmt.empty_line();
|
||||
}
|
||||
|
||||
fn gen_try_from(all_inst: &AllInstructions, fmt: &mut Formatter) {
|
||||
fmt.line("impl core::convert::TryFrom<u16> for Opcode {");
|
||||
fmt.indent(|fmt| {
|
||||
fmt.line("type Error = ();");
|
||||
fmt.line("#[inline]");
|
||||
fmt.line("fn try_from(x: u16) -> Result<Self, ()> {");
|
||||
fmt.indent(|fmt| {
|
||||
fmtln!(fmt, "if 0 < x && x <= {} {{", all_inst.len());
|
||||
fmt.indent(|fmt| fmt.line("Ok(unsafe { core::mem::transmute(x) })"));
|
||||
fmt.line("} else {");
|
||||
fmt.indent(|fmt| fmt.line("Err(())"));
|
||||
fmt.line("}");
|
||||
});
|
||||
fmt.line("}");
|
||||
});
|
||||
fmt.line("}");
|
||||
}
|
||||
|
||||
/// Get the value type constraint for an SSA value operand, where
|
||||
/// `ctrl_typevar` is the controlling type variable.
|
||||
///
|
||||
@@ -1420,8 +1402,6 @@ pub(crate) fn generate(
|
||||
gen_opcodes(all_inst, &mut fmt);
|
||||
fmt.empty_line();
|
||||
gen_type_constraints(all_inst, &mut fmt);
|
||||
fmt.empty_line();
|
||||
gen_try_from(all_inst, &mut fmt);
|
||||
fmt.update_file(opcode_filename, out_dir)?;
|
||||
|
||||
// ISLE DSL.
|
||||
|
||||
Reference in New Issue
Block a user