Coalesce some formats into MultiAry.

Allow some flexibility in the signature matching for instruction
formats. In particular, look for a value list format as a second chance
option.

The Return, ReturnReg, and TernaryOverflow formats all fit the single
MultiAry catch-all format for instructions without immediate operands.
This commit is contained in:
Jakob Stoklund Olesen
2017-03-10 12:17:12 -08:00
parent 6021da8e1c
commit 519eb1934b
8 changed files with 50 additions and 99 deletions

View File

@@ -3,7 +3,7 @@
//! A `Builder` provides a convenient interface for inserting instructions into a Cretonne
//! function. Many of its methods are generated from the meta language instruction definitions.
use ir::{types, instructions};
use ir::types;
use ir::{InstructionData, DataFlowGraph, Cursor};
use ir::{Opcode, Type, Inst, Value, Ebb, JumpTable, SigRef, FuncRef, ValueList};
use ir::immediates::{Imm64, Uimm8, Ieee32, Ieee64};

View File

@@ -151,11 +151,11 @@ pub enum InstructionData {
ty: Type,
args: [Value; 3],
},
TernaryOverflow {
MultiAry {
opcode: Opcode,
ty: Type,
second_result: PackedOption<Value>,
data: Box<TernaryOverflowData>,
args: ValueList,
},
InsertLane {
opcode: Opcode,
@@ -213,16 +213,6 @@ pub enum InstructionData {
sig_ref: SigRef,
args: ValueList,
},
Return {
opcode: Opcode,
ty: Type,
args: ValueList,
},
ReturnReg {
opcode: Opcode,
ty: Type,
args: ValueList,
},
}
/// A variable list of `Value` operands used for function call arguments and passing arguments to
@@ -289,19 +279,6 @@ impl Default for VariableArgs {
}
}
/// Payload data for ternary instructions with multiple results, such as `iadd_carry`.
#[derive(Clone, Debug)]
pub struct TernaryOverflowData {
/// Value arguments.
pub args: [Value; 3],
}
impl Display for TernaryOverflowData {
fn fmt(&self, f: &mut Formatter) -> fmt::Result {
write!(f, "{}, {}, {}", self.args[0], self.args[1], self.args[2])
}
}
/// Analyzing an instruction.
///
/// Avoid large matches on instruction formats by using the methods defined here to examine

View File

@@ -238,7 +238,15 @@ fn write_instruction(w: &mut Write,
BinaryImm { arg, imm, .. } => writeln!(w, " {}, {}", arg, imm),
BinaryOverflow { args, .. } => writeln!(w, " {}, {}", args[0], args[1]),
Ternary { args, .. } => writeln!(w, " {}, {}, {}", args[0], args[1], args[2]),
TernaryOverflow { ref data, .. } => writeln!(w, " {}", data),
MultiAry { ref args, .. } => {
if args.is_empty() {
writeln!(w, "")
} else {
writeln!(w,
" {}",
DisplayValues(args.as_slice(&func.dfg.value_lists)))
}
}
InsertLane { lane, args, .. } => writeln!(w, " {}, {}, {}", args[0], lane, args[1]),
ExtractLane { lane, arg, .. } => writeln!(w, " {}, {}", arg, lane),
IntCompare { cond, args, .. } => writeln!(w, " {}, {}, {}", cond, args[0], args[1]),
@@ -280,20 +288,6 @@ fn write_instruction(w: &mut Write,
args[0],
DisplayValues(&args[1..]))
}
Return { ref args, .. } => {
if args.is_empty() {
writeln!(w, "")
} else {
writeln!(w,
" {}",
DisplayValues(args.as_slice(&func.dfg.value_lists)))
}
}
ReturnReg { ref args, .. } => {
writeln!(w,
" {}",
DisplayValues(args.as_slice(&func.dfg.value_lists)))
}
}
}