summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Target/ARM/ARMFastISel.cpp
diff options
context:
space:
mode:
authorEric Christopher <echristo@apple.com>2010-09-08 23:13:45 +0000
committerEric Christopher <echristo@apple.com>2010-09-08 23:13:45 +0000
commitc3e9c404aa36c696986b30689f52acea7c382ba6 (patch)
treed2e209fd80c1865fb605459da77a7bdfb96bad49 /llvm/lib/Target/ARM/ARMFastISel.cpp
parent8084dbaf8e32b41f306adcdfba3e4c2a8c05f056 (diff)
downloadbcm5719-llvm-c3e9c404aa36c696986b30689f52acea7c382ba6.tar.gz
bcm5719-llvm-c3e9c404aa36c696986b30689f52acea7c382ba6.zip
Very basic compare support.
llvm-svn: 113440
Diffstat (limited to 'llvm/lib/Target/ARM/ARMFastISel.cpp')
-rw-r--r--llvm/lib/Target/ARM/ARMFastISel.cpp48
1 files changed, 48 insertions, 0 deletions
diff --git a/llvm/lib/Target/ARM/ARMFastISel.cpp b/llvm/lib/Target/ARM/ARMFastISel.cpp
index 7fbb1f2380d..dabfe9c9f2f 100644
--- a/llvm/lib/Target/ARM/ARMFastISel.cpp
+++ b/llvm/lib/Target/ARM/ARMFastISel.cpp
@@ -113,6 +113,7 @@ class ARMFastISel : public FastISel {
virtual bool ARMSelectLoad(const Instruction *I);
virtual bool ARMSelectStore(const Instruction *I);
virtual bool ARMSelectBranch(const Instruction *I);
+ virtual bool ARMSelectCmp(const Instruction *I);
// Utility routines.
private:
@@ -650,6 +651,50 @@ bool ARMFastISel::ARMSelectBranch(const Instruction *I) {
return true;
}
+bool ARMFastISel::ARMSelectCmp(const Instruction *I) {
+ const CmpInst *CI = cast<CmpInst>(I);
+
+ EVT VT;
+ const Type *Ty = CI->getOperand(0)->getType();
+ if (!isTypeLegal(Ty, VT))
+ return false;
+
+ bool isFloat = (Ty->isDoubleTy() || Ty->isFloatTy());
+ if (isFloat && !Subtarget->hasVFP2())
+ return false;
+
+ unsigned CmpOpc;
+ switch (VT.getSimpleVT().SimpleTy) {
+ default: return false;
+ // TODO: Verify compares.
+ case MVT::f32:
+ CmpOpc = ARM::VCMPES;
+ break;
+ case MVT::f64:
+ CmpOpc = ARM::VCMPED;
+ break;
+ case MVT::i32:
+ CmpOpc = isThumb ? ARM::t2CMPrr : ARM::CMPrr;
+ break;
+ }
+
+ unsigned Arg1 = getRegForValue(CI->getOperand(0));
+ if (Arg1 == 0) return false;
+
+ unsigned Arg2 = getRegForValue(CI->getOperand(1));
+ if (Arg2 == 0) return false;
+
+ AddOptionalDefs(BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DL, TII.get(CmpOpc))
+ .addReg(Arg1).addReg(Arg2));
+
+ // For floating point we need to move the result to a register we can
+ // actually do something with.
+ if (isFloat)
+ AddOptionalDefs(BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DL,
+ TII.get(ARM::FMSTAT)));
+ return true;
+}
+
// TODO: SoftFP support.
bool ARMFastISel::TargetSelectInstruction(const Instruction *I) {
// No Thumb-1 for now.
@@ -662,6 +707,9 @@ bool ARMFastISel::TargetSelectInstruction(const Instruction *I) {
return ARMSelectStore(I);
case Instruction::Br:
return ARMSelectBranch(I);
+ case Instruction::ICmp:
+ case Instruction::FCmp:
+ return ARMSelectCmp(I);
default: break;
}
return false;
OpenPOWER on IntegriCloud