diff --git a/lib/cretonne/meta/base/formats.py b/lib/cretonne/meta/base/formats.py index 1746217958..7fd93de1f9 100644 --- a/lib/cretonne/meta/base/formats.py +++ b/lib/cretonne/meta/base/formats.py @@ -13,8 +13,6 @@ from .immediates import boolean, intcc, floatcc, memflags, regunit, trapcode from . import entities from .entities import ebb, sig_ref, func_ref, stack_slot, heap -Nullary = InstructionFormat() - Unary = InstructionFormat(VALUE) UnaryImm = InstructionFormat(imm64) UnaryIeee32 = InstructionFormat(ieee32) diff --git a/lib/cretonne/src/ir/dfg.rs b/lib/cretonne/src/ir/dfg.rs index b81bbe96fc..47c53100cf 100644 --- a/lib/cretonne/src/ir/dfg.rs +++ b/lib/cretonne/src/ir/dfg.rs @@ -898,20 +898,26 @@ impl<'a> fmt::Display for DisplayInst<'a> { mod tests { use super::*; use ir::types; - use ir::{Function, Cursor, CursorBase, Opcode, InstructionData}; + use ir::{Function, Cursor, CursorBase, Opcode, InstructionData, TrapCode}; #[test] fn make_inst() { let mut dfg = DataFlowGraph::new(); - let idata = InstructionData::Nullary { opcode: Opcode::Iconst }; + let idata = InstructionData::UnaryImm { + opcode: Opcode::Iconst, + imm: 0.into(), + }; let next = dfg.next_inst(); let inst = dfg.make_inst(idata); assert_eq!(next, inst); dfg.make_inst_results(inst, types::I32); assert_eq!(inst.to_string(), "inst0"); - assert_eq!(dfg.display_inst(inst, None).to_string(), "v0 = iconst.i32"); + assert_eq!( + dfg.display_inst(inst, None).to_string(), + "v0 = iconst.i32 0" + ); // Immutable reference resolution. { @@ -941,9 +947,12 @@ mod tests { fn no_results() { let mut dfg = DataFlowGraph::new(); - let idata = InstructionData::Nullary { opcode: Opcode::Trap }; + let idata = InstructionData::Trap { + opcode: Opcode::Trap, + code: TrapCode::User(0), + }; let inst = dfg.make_inst(idata); - assert_eq!(dfg.display_inst(inst, None).to_string(), "trap"); + assert_eq!(dfg.display_inst(inst, None).to_string(), "trap user0"); // Result slice should be empty. assert_eq!(dfg.inst_results(inst), &[]); diff --git a/lib/cretonne/src/ir/instructions.rs b/lib/cretonne/src/ir/instructions.rs index 0b3c671cc6..14bd3de726 100644 --- a/lib/cretonne/src/ir/instructions.rs +++ b/lib/cretonne/src/ir/instructions.rs @@ -103,7 +103,6 @@ impl FromStr for Opcode { #[derive(Clone, Debug, Hash, PartialEq, Eq)] #[allow(missing_docs)] pub enum InstructionData { - Nullary { opcode: Opcode }, Unary { opcode: Opcode, arg: Value }, UnaryImm { opcode: Opcode, imm: Imm64 }, UnaryIeee32 { opcode: Opcode, imm: Ieee32 }, diff --git a/lib/cretonne/src/verifier/mod.rs b/lib/cretonne/src/verifier/mod.rs index 3fd6685133..82ba075f39 100644 --- a/lib/cretonne/src/verifier/mod.rs +++ b/lib/cretonne/src/verifier/mod.rs @@ -321,7 +321,6 @@ impl<'a> Verifier<'a> { } // Exhaustive list so we can't forget to add new formats - Nullary { .. } | Unary { .. } | UnaryImm { .. } | UnaryIeee32 { .. } | @@ -1048,9 +1047,10 @@ mod tests { let mut func = Function::new(); let ebb0 = func.dfg.make_ebb(); func.layout.append_ebb(ebb0); - let nullary_with_bad_opcode = func.dfg.make_inst( - InstructionData::Nullary { opcode: Opcode::Jump }, - ); + let nullary_with_bad_opcode = func.dfg.make_inst(InstructionData::UnaryImm { + opcode: Opcode::Jump, + imm: 0.into(), + }); func.layout.append_inst(nullary_with_bad_opcode, ebb0); let flags = &settings::Flags::new(&settings::builder()); let verifier = Verifier::new(&func, flags.into()); diff --git a/lib/cretonne/src/write.rs b/lib/cretonne/src/write.rs index 6dd6f333df..2cbc8766ab 100644 --- a/lib/cretonne/src/write.rs +++ b/lib/cretonne/src/write.rs @@ -269,7 +269,6 @@ pub fn write_operands( let pool = &dfg.value_lists; use ir::instructions::InstructionData::*; match dfg[inst] { - Nullary { .. } => write!(w, ""), Unary { arg, .. } => write!(w, " {}", arg), UnaryImm { imm, .. } => write!(w, " {}", imm), UnaryIeee32 { imm, .. } => write!(w, " {}", imm), diff --git a/lib/reader/src/parser.rs b/lib/reader/src/parser.rs index 8ce55d4445..331ca5eb92 100644 --- a/lib/reader/src/parser.rs +++ b/lib/reader/src/parser.rs @@ -1828,7 +1828,6 @@ impl<'a> Parser<'a> { opcode: Opcode, ) -> Result { let idata = match opcode.format() { - InstructionFormat::Nullary => InstructionData::Nullary { opcode }, InstructionFormat::Unary => { InstructionData::Unary { opcode,