Fix constant pool loads, and remove broken versions of addConstantPoolReference.
authorOwen Anderson <resistor@mac.com>
Sat, 6 Sep 2008 01:11:01 +0000 (01:11 +0000)
committerOwen Anderson <resistor@mac.com>
Sat, 6 Sep 2008 01:11:01 +0000 (01:11 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@55868 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/CellSPU/SPUInstrBuilder.h
lib/Target/IA64/IA64InstrBuilder.h
lib/Target/PowerPC/PPCInstrBuilder.h
lib/Target/X86/X86FastISel.cpp
lib/Target/X86/X86InstrBuilder.h

index 00721d1b97bd5dd4a6f68e3e580e5f23c340cc10..5e268f8767c2c75945fdb6c1d51d23ab58e3809c 100644 (file)
@@ -38,18 +38,6 @@ addFrameReference(const MachineInstrBuilder &MIB, int FI, int Offset = 0,
     return MIB.addFrameIndex(FI).addImm(Offset);
 }
 
-/// addConstantPoolReference - This function is used to add a reference to the
-/// base of a constant value spilled to the per-function constant pool.  The
-/// reference has base register ConstantPoolIndex offset which is retained until
-/// either machine code emission or assembly output.  This allows an optional
-/// offset to be added as well.
-///
-inline const MachineInstrBuilder&
-addConstantPoolReference(const MachineInstrBuilder &MIB, unsigned CPI,
-                         int Offset = 0) {
-  return MIB.addImm(Offset).addConstantPoolIndex(CPI);
-}
-
 } // End llvm namespace
 
 #endif
index 51b3744312ed56398f8c4da22c25c0e2c1b80fff..a5d4dca530fb85f9555dcde425fefed6e7e78e8d 100644 (file)
@@ -34,18 +34,6 @@ addFrameReference(const MachineInstrBuilder &MIB, int FI, int Offset = 0,
     return MIB.addFrameIndex(FI).addImm(Offset);
 }
 
-/// addConstantPoolReference - This function is used to add a reference to the
-/// base of a constant value spilled to the per-function constant pool.  The
-/// reference has base register ConstantPoolIndex offset which is retained until
-/// either machine code emission or assembly output.  This allows an optional
-/// offset to be added as well.
-///
-inline const MachineInstrBuilder&
-addConstantPoolReference(const MachineInstrBuilder &MIB, unsigned CPI,
-                         int Offset = 0) {
-  return MIB.addImm(Offset).addConstantPoolIndex(CPI);
-}
-
 } // End llvm namespace
 
 #endif
index edb5103875d4b7c32ecb02f58bc18306548b6955..1de69116cd58ccc2fe2c440242d0249bb24558c3 100644 (file)
@@ -38,18 +38,6 @@ addFrameReference(const MachineInstrBuilder &MIB, int FI, int Offset = 0,
     return MIB.addFrameIndex(FI).addImm(Offset);
 }
 
-/// addConstantPoolReference - This function is used to add a reference to the
-/// base of a constant value spilled to the per-function constant pool.  The
-/// reference has base register ConstantPoolIndex offset which is retained until
-/// either machine code emission or assembly output.  This allows an optional
-/// offset to be added as well.
-///
-inline const MachineInstrBuilder&
-addConstantPoolReference(const MachineInstrBuilder &MIB, unsigned CPI,
-                         int Offset = 0) {
-  return MIB.addImm(Offset).addConstantPoolIndex(CPI);
-}
-
 } // End llvm namespace
 
 #endif
index bf939ab0fb6ee72902d412f1bef0df4bfde8a75e..211afd5fc87bdc008880188ab047a72aa0602900 100644 (file)
@@ -585,10 +585,6 @@ X86FastISel::TargetSelectInstruction(Instruction *I)  {
 
 unsigned X86FastISel::TargetMaterializeConstant(Constant *C,
                                                 MachineConstantPool* MCP) {
-  unsigned CPLoad = getRegForValue(C);
-  if (CPLoad != 0)
-    return CPLoad;
-  
   // Can't handle PIC-mode yet.
   if (TM.getRelocationModel() == Reloc::PIC_)
     return 0;
@@ -662,10 +658,17 @@ unsigned X86FastISel::TargetMaterializeConstant(Constant *C,
     return 0;
   }
   
+  // MachineConstantPool wants an explicit alignment.
+  unsigned Align =
+               TM.getTargetData()->getPreferredTypeAlignmentShift(C->getType());
+  if (Align == 0) {
+    // Alignment of vector types.  FIXME!
+    Align = TM.getTargetData()->getABITypeSize(C->getType());
+    Align = Log2_64(Align);
+  }
   
-  unsigned MCPOffset = MCP->getConstantPoolIndex(C, 0);
+  unsigned MCPOffset = MCP->getConstantPoolIndex(C, Align);
   addConstantPoolReference(BuildMI(MBB, TII.get(Opc), ResultReg), MCPOffset);
-  UpdateValueMap(C, ResultReg);
   return ResultReg;
 }
 
index d4e10bbb50e5eaf7f5186515378af7f5fdc188b9..b5924cb76116671987322c440bc94c83787c1b4d 100644 (file)
@@ -119,9 +119,7 @@ addFrameReference(const MachineInstrBuilder &MIB, int FI, int Offset = 0) {
 /// offset to be added as well.
 ///
 inline const MachineInstrBuilder &
-addConstantPoolReference(const MachineInstrBuilder &MIB, unsigned CPI,
-                         int Offset = 0) {
-  assert(Offset == 0 && "Non-zero offsets not supported!");
+addConstantPoolReference(const MachineInstrBuilder &MIB, unsigned CPI) {
   return MIB.addReg(0).addImm(1).addReg(0).addConstantPoolIndex(CPI);
 }