[codegen] add intcc conditions for reading overflow flag
Add conditions to IntCC for checking the overflow flag (Overflow, NotOverflow).
This commit is contained in:
committed by
Benjamin Bouvier
parent
dfdd504edc
commit
43a891dfa2
@@ -2920,21 +2920,9 @@ pub(crate) fn define<'shared>(
|
||||
{{PUT_OP}}(bits, rex2(in_reg0, in_reg1), sink);
|
||||
modrm_rr(in_reg0, in_reg1, sink);
|
||||
// `setCC` instruction, no REX.
|
||||
use crate::ir::condcodes::IntCC::*;
|
||||
let setcc = match cond {
|
||||
Equal => 0x94,
|
||||
NotEqual => 0x95,
|
||||
SignedLessThan => 0x9c,
|
||||
SignedGreaterThanOrEqual => 0x9d,
|
||||
SignedGreaterThan => 0x9f,
|
||||
SignedLessThanOrEqual => 0x9e,
|
||||
UnsignedLessThan => 0x92,
|
||||
UnsignedGreaterThanOrEqual => 0x93,
|
||||
UnsignedGreaterThan => 0x97,
|
||||
UnsignedLessThanOrEqual => 0x96,
|
||||
};
|
||||
let setcc = 0x90 | icc2opc(cond);
|
||||
sink.put1(0x0f);
|
||||
sink.put1(setcc);
|
||||
sink.put1(setcc as u8);
|
||||
modrm_rr(out_reg0, 0, sink);
|
||||
"#,
|
||||
),
|
||||
@@ -2971,21 +2959,9 @@ pub(crate) fn define<'shared>(
|
||||
let imm: i64 = imm.into();
|
||||
sink.put1(imm as u8);
|
||||
// `setCC` instruction, no REX.
|
||||
use crate::ir::condcodes::IntCC::*;
|
||||
let setcc = match cond {
|
||||
Equal => 0x94,
|
||||
NotEqual => 0x95,
|
||||
SignedLessThan => 0x9c,
|
||||
SignedGreaterThanOrEqual => 0x9d,
|
||||
SignedGreaterThan => 0x9f,
|
||||
SignedLessThanOrEqual => 0x9e,
|
||||
UnsignedLessThan => 0x92,
|
||||
UnsignedGreaterThanOrEqual => 0x93,
|
||||
UnsignedGreaterThan => 0x97,
|
||||
UnsignedLessThanOrEqual => 0x96,
|
||||
};
|
||||
let setcc = 0x90 | icc2opc(cond);
|
||||
sink.put1(0x0f);
|
||||
sink.put1(setcc);
|
||||
sink.put1(setcc as u8);
|
||||
modrm_rr(out_reg0, 0, sink);
|
||||
"#,
|
||||
),
|
||||
@@ -3006,21 +2982,9 @@ pub(crate) fn define<'shared>(
|
||||
let imm: i64 = imm.into();
|
||||
sink.put4(imm as u32);
|
||||
// `setCC` instruction, no REX.
|
||||
use crate::ir::condcodes::IntCC::*;
|
||||
let setcc = match cond {
|
||||
Equal => 0x94,
|
||||
NotEqual => 0x95,
|
||||
SignedLessThan => 0x9c,
|
||||
SignedGreaterThanOrEqual => 0x9d,
|
||||
SignedGreaterThan => 0x9f,
|
||||
SignedLessThanOrEqual => 0x9e,
|
||||
UnsignedLessThan => 0x92,
|
||||
UnsignedGreaterThanOrEqual => 0x93,
|
||||
UnsignedGreaterThan => 0x97,
|
||||
UnsignedLessThanOrEqual => 0x96,
|
||||
};
|
||||
let setcc = 0x90 | icc2opc(cond);
|
||||
sink.put1(0x0f);
|
||||
sink.put1(setcc);
|
||||
sink.put1(setcc as u8);
|
||||
modrm_rr(out_reg0, 0, sink);
|
||||
"#,
|
||||
),
|
||||
|
||||
@@ -129,6 +129,8 @@ impl Immediates {
|
||||
intcc_values.insert("ugt", "UnsignedGreaterThan");
|
||||
intcc_values.insert("ule", "UnsignedLessThanOrEqual");
|
||||
intcc_values.insert("ult", "UnsignedLessThan");
|
||||
intcc_values.insert("of", "Overflow");
|
||||
intcc_values.insert("nof", "NotOverflow");
|
||||
Builder::new_enum("intcc", intcc_values)
|
||||
.doc("An integer comparison condition code.")
|
||||
.default_member("cond")
|
||||
|
||||
@@ -1587,6 +1587,7 @@ pub(crate) fn define(
|
||||
let y = &operand("y", Int);
|
||||
|
||||
// TODO(ryzokuken): Add documentation for unsigned overflow.
|
||||
// TODO(ryzokuken): Add documentation for signed overflow.
|
||||
ig.push(
|
||||
Inst::new(
|
||||
"icmp",
|
||||
|
||||
Reference in New Issue
Block a user