Add the br_icmp instruction.
This instruction behaves like icmp fused with brnz, and it can be used to represent fused compare+branch instruction on Intel when optimizing for macro-op fusion. RISC-V provides compare-and-branch instructions directly, and it is needed there too.
This commit is contained in:
@@ -200,6 +200,13 @@ pub enum InstructionData {
|
||||
destination: Ebb,
|
||||
args: ValueList,
|
||||
},
|
||||
BranchIcmp {
|
||||
opcode: Opcode,
|
||||
ty: Type,
|
||||
cond: IntCC,
|
||||
destination: Ebb,
|
||||
args: ValueList,
|
||||
},
|
||||
BranchTable {
|
||||
opcode: Opcode,
|
||||
ty: Type,
|
||||
@@ -303,6 +310,9 @@ impl InstructionData {
|
||||
&InstructionData::Branch { destination, ref args, .. } => {
|
||||
BranchInfo::SingleDest(destination, &args.as_slice(pool)[1..])
|
||||
}
|
||||
&InstructionData::BranchIcmp { destination, ref args, .. } => {
|
||||
BranchInfo::SingleDest(destination, &args.as_slice(pool)[2..])
|
||||
}
|
||||
&InstructionData::BranchTable { table, .. } => BranchInfo::Table(table),
|
||||
_ => BranchInfo::NotABranch,
|
||||
}
|
||||
|
||||
@@ -218,11 +218,9 @@ impl<'a> Verifier<'a> {
|
||||
&MultiAry { ref args, .. } => {
|
||||
self.verify_value_list(inst, args)?;
|
||||
}
|
||||
&Jump { destination, ref args, .. } => {
|
||||
self.verify_ebb(inst, destination)?;
|
||||
self.verify_value_list(inst, args)?;
|
||||
}
|
||||
&Branch { destination, ref args, .. } => {
|
||||
&Jump { destination, ref args, .. } |
|
||||
&Branch { destination, ref args, .. } |
|
||||
&BranchIcmp { destination, ref args, .. } => {
|
||||
self.verify_ebb(inst, destination)?;
|
||||
self.verify_value_list(inst, args)?;
|
||||
}
|
||||
|
||||
@@ -274,15 +274,19 @@ pub fn write_operands(w: &mut Write, dfg: &DataFlowGraph, inst: Inst) -> Result
|
||||
}
|
||||
Branch { destination, ref args, .. } => {
|
||||
let args = args.as_slice(pool);
|
||||
if args.len() == 1 {
|
||||
write!(w, " {}, {}", args[0], destination)
|
||||
} else {
|
||||
write!(w,
|
||||
" {}, {}({})",
|
||||
args[0],
|
||||
destination,
|
||||
DisplayValues(&args[1..]))
|
||||
write!(w, " {}, {}", args[0], destination)?;
|
||||
if args.len() > 1 {
|
||||
write!(w, "({})", DisplayValues(&args[1..]))?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
BranchIcmp { cond, destination, ref args, .. } => {
|
||||
let args = args.as_slice(pool);
|
||||
write!(w, " {}, {}, {}, {}", cond, args[0], args[1], destination)?;
|
||||
if args.len() > 2 {
|
||||
write!(w, "({})", DisplayValues(&args[2..]))?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
BranchTable { arg, table, .. } => write!(w, " {}, {}", arg, table),
|
||||
Call { func_ref, ref args, .. } => {
|
||||
|
||||
Reference in New Issue
Block a user