Remove the unused Nullary instruction format.

This format was only used by the trap instruction which has its own
format now.
This commit is contained in:
Jakob Stoklund Olesen
2017-09-20 15:59:13 -07:00
parent e8723be33f
commit 8def91b4ad
6 changed files with 18 additions and 14 deletions

View File

@@ -13,8 +13,6 @@ from .immediates import boolean, intcc, floatcc, memflags, regunit, trapcode
from . import entities from . import entities
from .entities import ebb, sig_ref, func_ref, stack_slot, heap from .entities import ebb, sig_ref, func_ref, stack_slot, heap
Nullary = InstructionFormat()
Unary = InstructionFormat(VALUE) Unary = InstructionFormat(VALUE)
UnaryImm = InstructionFormat(imm64) UnaryImm = InstructionFormat(imm64)
UnaryIeee32 = InstructionFormat(ieee32) UnaryIeee32 = InstructionFormat(ieee32)

View File

@@ -898,20 +898,26 @@ impl<'a> fmt::Display for DisplayInst<'a> {
mod tests { mod tests {
use super::*; use super::*;
use ir::types; use ir::types;
use ir::{Function, Cursor, CursorBase, Opcode, InstructionData}; use ir::{Function, Cursor, CursorBase, Opcode, InstructionData, TrapCode};
#[test] #[test]
fn make_inst() { fn make_inst() {
let mut dfg = DataFlowGraph::new(); 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 next = dfg.next_inst();
let inst = dfg.make_inst(idata); let inst = dfg.make_inst(idata);
assert_eq!(next, inst); assert_eq!(next, inst);
dfg.make_inst_results(inst, types::I32); dfg.make_inst_results(inst, types::I32);
assert_eq!(inst.to_string(), "inst0"); 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. // Immutable reference resolution.
{ {
@@ -941,9 +947,12 @@ mod tests {
fn no_results() { fn no_results() {
let mut dfg = DataFlowGraph::new(); 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); 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. // Result slice should be empty.
assert_eq!(dfg.inst_results(inst), &[]); assert_eq!(dfg.inst_results(inst), &[]);

View File

@@ -103,7 +103,6 @@ impl FromStr for Opcode {
#[derive(Clone, Debug, Hash, PartialEq, Eq)] #[derive(Clone, Debug, Hash, PartialEq, Eq)]
#[allow(missing_docs)] #[allow(missing_docs)]
pub enum InstructionData { pub enum InstructionData {
Nullary { opcode: Opcode },
Unary { opcode: Opcode, arg: Value }, Unary { opcode: Opcode, arg: Value },
UnaryImm { opcode: Opcode, imm: Imm64 }, UnaryImm { opcode: Opcode, imm: Imm64 },
UnaryIeee32 { opcode: Opcode, imm: Ieee32 }, UnaryIeee32 { opcode: Opcode, imm: Ieee32 },

View File

@@ -321,7 +321,6 @@ impl<'a> Verifier<'a> {
} }
// Exhaustive list so we can't forget to add new formats // Exhaustive list so we can't forget to add new formats
Nullary { .. } |
Unary { .. } | Unary { .. } |
UnaryImm { .. } | UnaryImm { .. } |
UnaryIeee32 { .. } | UnaryIeee32 { .. } |
@@ -1048,9 +1047,10 @@ mod tests {
let mut func = Function::new(); let mut func = Function::new();
let ebb0 = func.dfg.make_ebb(); let ebb0 = func.dfg.make_ebb();
func.layout.append_ebb(ebb0); func.layout.append_ebb(ebb0);
let nullary_with_bad_opcode = func.dfg.make_inst( let nullary_with_bad_opcode = func.dfg.make_inst(InstructionData::UnaryImm {
InstructionData::Nullary { opcode: Opcode::Jump }, opcode: Opcode::Jump,
); imm: 0.into(),
});
func.layout.append_inst(nullary_with_bad_opcode, ebb0); func.layout.append_inst(nullary_with_bad_opcode, ebb0);
let flags = &settings::Flags::new(&settings::builder()); let flags = &settings::Flags::new(&settings::builder());
let verifier = Verifier::new(&func, flags.into()); let verifier = Verifier::new(&func, flags.into());

View File

@@ -269,7 +269,6 @@ pub fn write_operands(
let pool = &dfg.value_lists; let pool = &dfg.value_lists;
use ir::instructions::InstructionData::*; use ir::instructions::InstructionData::*;
match dfg[inst] { match dfg[inst] {
Nullary { .. } => write!(w, ""),
Unary { arg, .. } => write!(w, " {}", arg), Unary { arg, .. } => write!(w, " {}", arg),
UnaryImm { imm, .. } => write!(w, " {}", imm), UnaryImm { imm, .. } => write!(w, " {}", imm),
UnaryIeee32 { imm, .. } => write!(w, " {}", imm), UnaryIeee32 { imm, .. } => write!(w, " {}", imm),

View File

@@ -1828,7 +1828,6 @@ impl<'a> Parser<'a> {
opcode: Opcode, opcode: Opcode,
) -> Result<InstructionData> { ) -> Result<InstructionData> {
let idata = match opcode.format() { let idata = match opcode.format() {
InstructionFormat::Nullary => InstructionData::Nullary { opcode },
InstructionFormat::Unary => { InstructionFormat::Unary => {
InstructionData::Unary { InstructionData::Unary {
opcode, opcode,