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:
@@ -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)
|
||||
|
||||
@@ -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), &[]);
|
||||
|
||||
@@ -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 },
|
||||
|
||||
@@ -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());
|
||||
|
||||
@@ -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),
|
||||
|
||||
@@ -1828,7 +1828,6 @@ impl<'a> Parser<'a> {
|
||||
opcode: Opcode,
|
||||
) -> Result<InstructionData> {
|
||||
let idata = match opcode.format() {
|
||||
InstructionFormat::Nullary => InstructionData::Nullary { opcode },
|
||||
InstructionFormat::Unary => {
|
||||
InstructionData::Unary {
|
||||
opcode,
|
||||
|
||||
Reference in New Issue
Block a user