Add an icmp_imm instruction.
Compare a scalar integer to an immediate constant. Both Intel and RISC-V ISAs have this operation. This requires the addition of a new IntCompareImm instruction format.
This commit is contained in:
@@ -38,6 +38,7 @@ InsertLane = InstructionFormat(VALUE, ('lane', uimm8), VALUE)
|
||||
ExtractLane = InstructionFormat(VALUE, ('lane', uimm8))
|
||||
|
||||
IntCompare = InstructionFormat(intcc, VALUE, VALUE)
|
||||
IntCompareImm = InstructionFormat(intcc, VALUE, imm64)
|
||||
FloatCompare = InstructionFormat(floatcc, VALUE, VALUE)
|
||||
|
||||
Jump = InstructionFormat(ebb, VARIABLE_ARGS)
|
||||
|
||||
@@ -367,6 +367,22 @@ icmp = Instruction(
|
||||
""",
|
||||
ins=(Cond, x, y), outs=a)
|
||||
|
||||
a = Operand('a', b1)
|
||||
x = Operand('x', iB)
|
||||
Y = Operand('Y', imm64)
|
||||
|
||||
icmp_imm = Instruction(
|
||||
'icmp_imm', r"""
|
||||
Compare scalar integer to a constant.
|
||||
|
||||
This is the same as the :inst:`icmp` instruction, except one operand is
|
||||
an immediate constant.
|
||||
|
||||
This instruction can only compare scalars. Use :inst:`icmp` for
|
||||
lane-wise vector comparisons.
|
||||
""",
|
||||
ins=(Cond, x, Y), outs=a)
|
||||
|
||||
a = Operand('a', Int)
|
||||
x = Operand('x', Int)
|
||||
y = Operand('y', Int)
|
||||
|
||||
@@ -175,6 +175,13 @@ pub enum InstructionData {
|
||||
cond: IntCC,
|
||||
args: [Value; 2],
|
||||
},
|
||||
IntCompareImm {
|
||||
opcode: Opcode,
|
||||
ty: Type,
|
||||
cond: IntCC,
|
||||
arg: Value,
|
||||
imm: Imm64,
|
||||
},
|
||||
FloatCompare {
|
||||
opcode: Opcode,
|
||||
ty: Type,
|
||||
|
||||
@@ -251,6 +251,7 @@ impl<'a> Verifier<'a> {
|
||||
&InsertLane { .. } |
|
||||
&ExtractLane { .. } |
|
||||
&IntCompare { .. } |
|
||||
&IntCompareImm { .. } |
|
||||
&FloatCompare { .. } => {}
|
||||
}
|
||||
|
||||
@@ -682,4 +683,4 @@ mod tests {
|
||||
let verifier = Verifier::new(&func);
|
||||
assert_err_with_msg!(verifier.run(), "instruction format");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -260,6 +260,7 @@ pub fn write_operands(w: &mut Write, dfg: &DataFlowGraph, inst: Inst) -> Result
|
||||
InsertLane { lane, args, .. } => write!(w, " {}, {}, {}", args[0], lane, args[1]),
|
||||
ExtractLane { lane, arg, .. } => write!(w, " {}, {}", arg, lane),
|
||||
IntCompare { cond, args, .. } => write!(w, " {}, {}, {}", cond, args[0], args[1]),
|
||||
IntCompareImm { cond, arg, imm, .. } => write!(w, " {}, {}, {}", cond, arg, imm),
|
||||
FloatCompare { cond, args, .. } => write!(w, " {}, {}, {}", cond, args[0], args[1]),
|
||||
Jump { destination, ref args, .. } => {
|
||||
if args.is_empty() {
|
||||
|
||||
Reference in New Issue
Block a user