summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Target/ARM/ARMInstructionSelector.cpp
diff options
context:
space:
mode:
authorDiana Picus <diana.picus@linaro.org>2017-04-24 06:30:56 +0000
committerDiana Picus <diana.picus@linaro.org>2017-04-24 06:30:56 +0000
commit95a8aa93e231d7a6cd3ab5ef75d2b016f11dc004 (patch)
tree49c0bd84f684f068073a75c358c12133ec7a0523 /llvm/lib/Target/ARM/ARMInstructionSelector.cpp
parent01b880a954364f03ee42087a67a29bf289f1f1a5 (diff)
downloadbcm5719-llvm-95a8aa93e231d7a6cd3ab5ef75d2b016f11dc004.tar.gz
bcm5719-llvm-95a8aa93e231d7a6cd3ab5ef75d2b016f11dc004.zip
[ARM] GlobalISel: Select G_CONSTANT with CImm operands
When selecting a G_CONSTANT to a MOVi, we need the value to be an Imm operand. We used to just leave the G_CONSTANT operand unchanged, which works in some cases (such as the GEP offsets that we create when referring to stack slots). However, in many other places the G_CONSTANTs are created with CImm operands. This patch makes sure to handle those as well, and to error out gracefully if in the end we don't end up with an Imm operand. Thanks to Oliver Stannard for reporting this issue. llvm-svn: 301162
Diffstat (limited to 'llvm/lib/Target/ARM/ARMInstructionSelector.cpp')
-rw-r--r--llvm/lib/Target/ARM/ARMInstructionSelector.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/llvm/lib/Target/ARM/ARMInstructionSelector.cpp b/llvm/lib/Target/ARM/ARMInstructionSelector.cpp
index 3b62c3878c3..a99dc159d11 100644
--- a/llvm/lib/Target/ARM/ARMInstructionSelector.cpp
+++ b/llvm/lib/Target/ARM/ARMInstructionSelector.cpp
@@ -351,6 +351,18 @@ bool ARMInstructionSelector::select(MachineInstr &I) const {
"Expected constant to live in a GPR");
I.setDesc(TII.get(ARM::MOVi));
MIB.add(predOps(ARMCC::AL)).add(condCodeOp());
+
+ auto &Val = I.getOperand(1);
+ if (Val.isCImm()) {
+ if (Val.getCImm()->getBitWidth() > 32)
+ return false;
+ Val.ChangeToImmediate(Val.getCImm()->getZExtValue());
+ }
+
+ if (!Val.isImm()) {
+ return false;
+ }
+
break;
}
case G_STORE:
OpenPOWER on IntegriCloud