summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib/CodeGen')
-rw-r--r--llvm/lib/CodeGen/GlobalISel/InstructionSelect.cpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/llvm/lib/CodeGen/GlobalISel/InstructionSelect.cpp b/llvm/lib/CodeGen/GlobalISel/InstructionSelect.cpp
index 0f7a254075a..a38ff00ed41 100644
--- a/llvm/lib/CodeGen/GlobalISel/InstructionSelect.cpp
+++ b/llvm/lib/CodeGen/GlobalISel/InstructionSelect.cpp
@@ -176,3 +176,20 @@ bool InstructionSelect::runOnMachineFunction(MachineFunction &MF) {
// FIXME: Should we accurately track changes?
return true;
}
+
+bool InstructionSelector::isOperandImmEqual(
+ const MachineOperand &MO, int64_t Value,
+ const MachineRegisterInfo &MRI) const {
+ // TODO: We should also test isImm() and isCImm() too but this isn't required
+ // until a DAGCombine equivalent is implemented.
+
+ if (MO.isReg()) {
+ MachineInstr *Def = MRI.getVRegDef(MO.getReg());
+ if (Def->getOpcode() != TargetOpcode::G_CONSTANT)
+ return false;
+ assert(Def->getOperand(1).isImm() && "G_CONSTANT values must be constants");
+ return Def->getOperand(1).getImm() == Value;
+ }
+
+ return false;
+}
OpenPOWER on IntegriCloud