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:
Jakob Stoklund Olesen
2017-04-03 09:49:44 -07:00
parent f70ae03b47
commit e23d12bbc7
8 changed files with 48 additions and 6 deletions

View File

@@ -216,11 +216,12 @@ impl<'a> Context<'a> {
InstructionData::UnaryIeee32 { .. } |
InstructionData::UnaryIeee64 { .. } => {}
InstructionData::Unary { ref mut arg, .. } |
InstructionData::UnarySplit { ref mut arg, .. } |
InstructionData::BinaryImm { ref mut arg, .. } |
InstructionData::BranchTable { ref mut arg, .. } |
InstructionData::ExtractLane { ref mut arg, .. } |
InstructionData::BranchTable { ref mut arg, .. } => {
InstructionData::IntCompareImm { ref mut arg, .. } |
InstructionData::Unary { ref mut arg, .. } |
InstructionData::UnarySplit { ref mut arg, .. } => {
self.map.rewrite_value(arg, loc)?;
}
@@ -1557,6 +1558,20 @@ impl<'a> Parser<'a> {
args: [lhs, rhs],
}
}
InstructionFormat::IntCompareImm => {
let cond = self.match_enum("expected intcc condition code")?;
self.match_token(Token::Comma, "expected ',' between operands")?;
let lhs = self.match_value("expected SSA value first operand")?;
self.match_token(Token::Comma, "expected ',' between operands")?;
let rhs = self.match_imm64("expected immediate second operand")?;
InstructionData::IntCompareImm {
opcode: opcode,
ty: VOID,
cond: cond,
arg: lhs,
imm: rhs,
}
}
InstructionFormat::FloatCompare => {
let cond = self.match_enum("expected floatcc condition code")?;
self.match_token(Token::Comma, "expected ',' between operands")?;