[llvm-commits] [llvm] r113387 - /llvm/trunk/lib/Target/ARM/ARMFastISel.cpp

Eric Christopher echristo at apple.com
Wed Sep 8 11:56:34 PDT 2010


Author: echristo
Date: Wed Sep  8 13:56:34 2010
New Revision: 113387

URL: http://llvm.org/viewvc/llvm-project?rev=113387&view=rev
Log:
Rewrite TargetMaterializeConstant.

Modified:
    llvm/trunk/lib/Target/ARM/ARMFastISel.cpp

Modified: llvm/trunk/lib/Target/ARM/ARMFastISel.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMFastISel.cpp?rev=113387&r1=113386&r2=113387&view=diff
==============================================================================
--- llvm/trunk/lib/Target/ARM/ARMFastISel.cpp (original)
+++ llvm/trunk/lib/Target/ARM/ARMFastISel.cpp Wed Sep  8 13:56:34 2010
@@ -328,11 +328,12 @@
 
   // Only handle simple types.
   if (!VT.isSimple()) return 0;
+
+  // Handle double width floating point?
+  if (VT.getSimpleVT().SimpleTy == MVT::f64) return 0;
   
-  // TODO: This should be safe for fp because they're just bits from the
-  // Constant.
-  // TODO: Theoretically we could materialize fp constants with instructions
-  // from VFP3.
+  // TODO: Theoretically we could materialize fp constants directly with
+  // instructions from VFP3.
 
   // MachineConstantPool wants an explicit alignment.
   unsigned Align = TD.getPrefTypeAlignment(C->getType());
@@ -342,8 +343,7 @@
   }
   unsigned Idx = MCP.getConstantPoolIndex(C, Align);
 
-  unsigned DestReg = createResultReg(TLI.getRegClassFor(VT));
-  // Different addressing modes between ARM/Thumb2 for constant pool loads.
+  unsigned DestReg = createResultReg(TLI.getRegClassFor(MVT::i32));
   if (isThumb)
     AddOptionalDefs(BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DL,
                             TII.get(ARM::t2LDRpci))
@@ -351,8 +351,19 @@
   else
     AddOptionalDefs(BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DL,
                             TII.get(ARM::LDRcp))
-                    .addReg(DestReg).addConstantPoolIndex(Idx)
+                            .addReg(DestReg).addConstantPoolIndex(Idx)
                     .addReg(0).addImm(0));
+                  
+  // If we have a floating point constant we expect it in a floating point
+  // register.
+  // TODO: Make this use ARMBaseInstrInfo::copyPhysReg.
+  if (C->getType()->isFloatTy()) {
+    unsigned MoveReg = createResultReg(TLI.getRegClassFor(VT));
+    AddOptionalDefs(BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DL,
+                            TII.get(ARM::VMOVRS), MoveReg)
+                    .addReg(DestReg));
+    return MoveReg;
+  }
     
   return DestReg;
 }





More information about the llvm-commits mailing list