Handle float->double extension.
authorEric Christopher <echristo@apple.com>
Thu, 9 Sep 2010 00:26:48 +0000 (00:26 +0000)
committerEric Christopher <echristo@apple.com>
Thu, 9 Sep 2010 00:26:48 +0000 (00:26 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@113455 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/ARM/ARMFastISel.cpp

index ca42079eb808f3218e00503b93906666c654d045..5c6dd566a2bf18da4a940a9fa58091704a437b36 100644 (file)
@@ -114,6 +114,7 @@ class ARMFastISel : public FastISel {
     virtual bool ARMSelectStore(const Instruction *I);
     virtual bool ARMSelectBranch(const Instruction *I);
     virtual bool ARMSelectCmp(const Instruction *I);
+    virtual bool ARMSelectFPExt(const Instruction *I);
 
     // Utility routines.
   private:
@@ -719,6 +720,26 @@ bool ARMFastISel::ARMSelectCmp(const Instruction *I) {
   return true;
 }
 
+bool ARMFastISel::ARMSelectFPExt(const Instruction *I) {
+  // Make sure we have VFP and that we're extending float to double.
+  if (!Subtarget->hasVFP2()) return false;
+  
+  Value *V = I->getOperand(0);
+  if (!I->getType()->isDoubleTy() ||
+      !V->getType()->isFloatTy()) return false;
+      
+  unsigned Op = getRegForValue(V);
+  if (Op == 0) return false;
+  
+  unsigned Result = createResultReg(ARM::DPRRegisterClass);
+
+  AddOptionalDefs(BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DL, 
+                          TII.get(ARM::VCVTDS), Result)
+                  .addReg(Op));
+  UpdateValueMap(I, Result);
+  return true;
+}
+
 // TODO: SoftFP support.
 bool ARMFastISel::TargetSelectInstruction(const Instruction *I) {
   // No Thumb-1 for now.
@@ -734,6 +755,8 @@ bool ARMFastISel::TargetSelectInstruction(const Instruction *I) {
     case Instruction::ICmp:
     case Instruction::FCmp:
         return ARMSelectCmp(I);
+    case Instruction::FPExt:
+        return ARMSelectFPExt(I);
     default: break;
   }
   return false;