summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Christopher <echristo@apple.com>2010-09-02 01:48:11 +0000
committerEric Christopher <echristo@apple.com>2010-09-02 01:48:11 +0000
commit1b61ef4b22c8ae0ef82685637142246a245f9ecb (patch)
tree04d605b1ea46f50d1d4f5031ff74a38456221d47
parenteaa204b2f8414a2ac5764a753c119c8cd40bade3 (diff)
downloadllvm-1b61ef4b22c8ae0ef82685637142246a245f9ecb.tar.gz
llvm-1b61ef4b22c8ae0ef82685637142246a245f9ecb.tar.bz2
llvm-1b61ef4b22c8ae0ef82685637142246a245f9ecb.tar.xz
This should be TargetMaterializeConstant instead.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@112795 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/Target/ARM/ARMFastISel.cpp66
1 files changed, 28 insertions, 38 deletions
diff --git a/lib/Target/ARM/ARMFastISel.cpp b/lib/Target/ARM/ARMFastISel.cpp
index 64ab2467d8..866b14fab3 100644
--- a/lib/Target/ARM/ARMFastISel.cpp
+++ b/lib/Target/ARM/ARMFastISel.cpp
@@ -105,6 +105,7 @@ class ARMFastISel : public FastISel {
// Backend specific FastISel code.
virtual bool TargetSelectInstruction(const Instruction *I);
+ virtual unsigned TargetMaterializeConstant(const Constant *C);
#include "ARMGenFastISel.inc"
@@ -321,6 +322,31 @@ unsigned ARMFastISel::FastEmitInst_extractsubreg(MVT RetVT,
return ResultReg;
}
+unsigned ARMFastISel::TargetMaterializeConstant(const Constant *C) {
+ const ConstantInt *CI = dyn_cast<ConstantInt>(C);
+ if (!CI) return 0;
+
+ unsigned Opc;
+ bool Signed = true;
+ EVT VT = TLI.getValueType(CI->getType(), true);
+
+ switch (VT.getSimpleVT().SimpleTy) {
+ default: return 0;
+ case MVT::i1: Signed = false; // FALLTHROUGH to handle as i8.
+ case MVT::i8:
+ case MVT::i16:
+ case MVT::i32:
+ Opc = isThumb ? ARM::t2MOVi32imm : ARM::MOVi32imm; break;
+ }
+
+ unsigned Reg = createResultReg(TLI.getRegClassFor(VT));
+ AddOptionalDefs(BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DL, TII.get(Opc),
+ Reg)
+ .addImm(Signed ? (uint64_t) CI->getSExtValue() :
+ CI->getZExtValue()));
+ return Reg;
+}
+
bool ARMFastISel::isTypeLegal(const Type *Ty, EVT &VT) {
VT = TLI.getValueType(Ty, true);
@@ -474,29 +500,6 @@ bool ARMFastISel::ARMEmitLoad(EVT VT, unsigned &ResultReg,
return true;
}
-bool ARMFastISel::ARMMaterializeConstant(const ConstantInt *CI, unsigned &Reg) {
- unsigned Opc;
- bool Signed = true;
- EVT VT = TLI.getValueType(CI->getType(), true);
-
- switch (VT.getSimpleVT().SimpleTy) {
- default: return false;
- case MVT::i1: Signed = false; // FALLTHROUGH to handle as i8.
- case MVT::i8:
- case MVT::i16:
- case MVT::i32:
- Opc = isThumb ? ARM::t2MOVi32imm : ARM::MOVi32imm; break;
- }
-
- Reg = createResultReg(TLI.getRegClassFor(VT));
- AddOptionalDefs(BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DL, TII.get(Opc),
- Reg)
- .addImm(Signed ? (uint64_t) CI->getSExtValue() :
- CI->getZExtValue()));
-
- return true;
-}
-
bool ARMFastISel::ARMStoreAlloca(const Instruction *I, unsigned SrcReg) {
Value *Op1 = I->getOperand(1);
@@ -548,22 +551,9 @@ bool ARMFastISel::ARMSelectStore(const Instruction *I) {
EVT VT;
if (!isLoadTypeLegal(I->getOperand(0)->getType(), VT))
return false;
-
- // First see if we're a constant that we want to store, we'll need to
- // materialize that into a register.
- // Handle 'null' like i32/i64 0.
- if (isa<ConstantPointerNull>(Op0))
- Op0 = Constant::getNullValue(TD.getIntPtrType(Op0->getContext()));
-
- // If this is a store of a simple constant, materialize the constant into
- // a register then emit the store into the location.
- if (const ConstantInt *CI = dyn_cast<ConstantInt>(Op0))
- if (!ARMMaterializeConstant(CI, SrcReg))
- return false;
- // If Reg is still 0, try to get the value into a register.
- if (SrcReg == 0)
- SrcReg = getRegForValue(Op0);
+ // Get the value to be stored into a register.
+ SrcReg = getRegForValue(Op0);
if (SrcReg == 0)
return false;