Fix Invalid Instruction format in fuzzgen (#4738)

* cranelift: Add assert to prevent wrong InstFormat being used for the wrong opcode

* cranelift: Use correct instruction format when inserting opcodes in fuzzgen (fixes #4733)

* cranelift: Use debug assert on InstFormat assert
This commit is contained in:
Afonso Bordado
2022-08-20 01:49:54 +01:00
committed by GitHub
parent 754cf7156a
commit d620705a32
3 changed files with 32 additions and 5 deletions

View File

@@ -902,6 +902,9 @@ fn gen_format_constructor(format: &InstructionFormat, fmt: &mut Formatter) {
fmtln!(fmt, "data.sign_extend_immediates(ctrl_typevar);");
}
// Assert that this opcode belongs to this format
fmtln!(fmt, "debug_assert_eq!(opcode.format(), InstructionFormat::from(&data), \"Wrong InstructionFormat for Opcode: {}\", opcode);");
fmt.line("self.build(data, ctrl_typevar)");
});
fmtln!(fmt, "}");