[llvm-commits] CVS: llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp ScheduleDAG.cpp SelectionDAG.cpp SelectionDAGPrinter.cpp

Chris Lattner lattner at cs.uiuc.edu
Fri Aug 26 10:15:10 PDT 2005



Changes in directory llvm/lib/CodeGen/SelectionDAG:

LegalizeDAG.cpp updated: 1.173 -> 1.174
ScheduleDAG.cpp updated: 1.14 -> 1.15
SelectionDAG.cpp updated: 1.169 -> 1.170
SelectionDAGPrinter.cpp updated: 1.23 -> 1.24
---
Log message:

Change ConstantPoolSDNode to actually hold the Constant itself instead of
putting it into the constant pool.  This allows the isel machinery to 
create constants that it will end up deciding are not needed, without them
ending up in the resultant function constant pool.



---
Diffs of the changes:  (+24 -27)

 LegalizeDAG.cpp         |   14 +++-----------
 ScheduleDAG.cpp         |    8 ++++++--
 SelectionDAG.cpp        |   23 +++++++++++------------
 SelectionDAGPrinter.cpp |    6 ++++--
 4 files changed, 24 insertions(+), 27 deletions(-)


Index: llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
diff -u llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp:1.173 llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp:1.174
--- llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp:1.173	Thu Aug 25 19:43:46 2005
+++ llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp	Fri Aug 26 12:14:58 2005
@@ -12,7 +12,6 @@
 //===----------------------------------------------------------------------===//
 
 #include "llvm/CodeGen/SelectionDAG.h"
-#include "llvm/CodeGen/MachineConstantPool.h"
 #include "llvm/CodeGen/MachineFunction.h"
 #include "llvm/CodeGen/MachineFrameInfo.h"
 #include "llvm/Support/MathExtras.h"
@@ -248,9 +247,7 @@
   if (TLI.isLittleEndian()) FF <<= 32;
   static Constant *FudgeFactor = ConstantUInt::get(Type::ULongTy, FF);
 
-  MachineConstantPool *CP = DAG.getMachineFunction().getConstantPool();
-  SDOperand CPIdx = DAG.getConstantPool(CP->getConstantPoolIndex(FudgeFactor),
-                                        TLI.getPointerTy());
+  SDOperand CPIdx = DAG.getConstantPool(FudgeFactor, TLI.getPointerTy());
   CPIdx = DAG.getNode(ISD::ADD, TLI.getPointerTy(), CPIdx, CstOffset);
   SDOperand FudgeInReg;
   if (DestVT == MVT::f32)
@@ -529,8 +526,6 @@
 
     if (!isLegal) {
       // Otherwise we need to spill the constant to memory.
-      MachineConstantPool *CP = DAG.getMachineFunction().getConstantPool();
-
       bool Extend = false;
 
       // If a FP immediate is precise when represented as a float, we put it
@@ -549,8 +544,7 @@
         Extend = true;
       }
 
-      SDOperand CPIdx = DAG.getConstantPool(CP->getConstantPoolIndex(LLVMC),
-                                            TLI.getPointerTy());
+      SDOperand CPIdx = DAG.getConstantPool(LLVMC, TLI.getPointerTy());
       if (Extend) {
         Result = DAG.getExtLoad(ISD::EXTLOAD, MVT::f64, DAG.getEntryNode(),
                                 CPIdx, DAG.getSrcValue(NULL), MVT::f32);
@@ -2751,9 +2745,7 @@
     if (TLI.isLittleEndian()) FF <<= 32;
     static Constant *FudgeFactor = ConstantUInt::get(Type::ULongTy, FF);
 
-    MachineConstantPool *CP = DAG.getMachineFunction().getConstantPool();
-    SDOperand CPIdx = DAG.getConstantPool(CP->getConstantPoolIndex(FudgeFactor),
-                                          TLI.getPointerTy());
+    SDOperand CPIdx = DAG.getConstantPool(FudgeFactor, TLI.getPointerTy());
     CPIdx = DAG.getNode(ISD::ADD, TLI.getPointerTy(), CPIdx, CstOffset);
     SDOperand FudgeInReg;
     if (DestTy == MVT::f32)


Index: llvm/lib/CodeGen/SelectionDAG/ScheduleDAG.cpp
diff -u llvm/lib/CodeGen/SelectionDAG/ScheduleDAG.cpp:1.14 llvm/lib/CodeGen/SelectionDAG/ScheduleDAG.cpp:1.15
--- llvm/lib/CodeGen/SelectionDAG/ScheduleDAG.cpp:1.14	Thu Aug 25 12:48:54 2005
+++ llvm/lib/CodeGen/SelectionDAG/ScheduleDAG.cpp	Fri Aug 26 12:14:58 2005
@@ -13,6 +13,7 @@
 //===----------------------------------------------------------------------===//
 
 #define DEBUG_TYPE "sched"
+#include "llvm/CodeGen/MachineConstantPool.h"
 #include "llvm/CodeGen/MachineFunction.h"
 #include "llvm/CodeGen/SelectionDAGISel.h"
 #include "llvm/CodeGen/SelectionDAG.h"
@@ -38,12 +39,14 @@
     const TargetInstrInfo &TII;
     const MRegisterInfo &MRI;
     SSARegMap *RegMap;
+    MachineConstantPool *ConstPool;
     
     std::map<SDNode *, unsigned> EmittedOps;
   public:
     SimpleSched(SelectionDAG &D, MachineBasicBlock *bb)
       : DAG(D), BB(bb), TM(D.getTarget()), TII(*TM.getInstrInfo()),
-        MRI(*TM.getRegisterInfo()), RegMap(BB->getParent()->getSSARegMap()) {
+        MRI(*TM.getRegisterInfo()), RegMap(BB->getParent()->getSSARegMap()),
+        ConstPool(BB->getParent()->getConstantPool()) {
       assert(&TII && "Target doesn't provide instr info?");
       assert(&MRI && "Target doesn't provide register info?");
     }
@@ -148,7 +151,8 @@
         MI->addFrameIndexOperand(FI->getIndex());
       } else if (ConstantPoolSDNode *CP = 
                     dyn_cast<ConstantPoolSDNode>(Op.getOperand(i))) {
-        MI->addConstantPoolIndexOperand(CP->getIndex());
+        unsigned Idx = ConstPool->getConstantPoolIndex(CP->get());
+        MI->addConstantPoolIndexOperand(Idx);
       } else if (ExternalSymbolSDNode *ES = 
                  dyn_cast<ExternalSymbolSDNode>(Op.getOperand(i))) {
         MI->addExternalSymbolOperand(ES->getSymbol(), false);


Index: llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
diff -u llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp:1.169 llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp:1.170
--- llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp:1.169	Fri Aug 26 11:36:26 2005
+++ llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp	Fri Aug 26 12:14:58 2005
@@ -265,10 +265,10 @@
     TargetFrameIndices.erase(cast<FrameIndexSDNode>(N)->getIndex());
     break;
   case ISD::ConstantPool:
-    ConstantPoolIndices.erase(cast<ConstantPoolSDNode>(N)->getIndex());
+    ConstantPoolIndices.erase(cast<ConstantPoolSDNode>(N)->get());
     break;
   case ISD::TargetConstantPool:
-    TargetConstantPoolIndices.erase(cast<ConstantPoolSDNode>(N)->getIndex());
+    TargetConstantPoolIndices.erase(cast<ConstantPoolSDNode>(N)->get());
     break;
   case ISD::BasicBlock:
     BBNodes.erase(cast<BasicBlockSDNode>(N)->getBasicBlock());
@@ -452,19 +452,18 @@
   return SDOperand(N, 0);
 }
 
-SDOperand SelectionDAG::getConstantPool(unsigned CPIdx, MVT::ValueType VT) {
-  SDNode *N = ConstantPoolIndices[CPIdx];
+SDOperand SelectionDAG::getConstantPool(Constant *C, MVT::ValueType VT) {
+  SDNode *&N = ConstantPoolIndices[C];
   if (N) return SDOperand(N, 0);
-  N = new ConstantPoolSDNode(CPIdx, VT, false);
+  N = new ConstantPoolSDNode(C, VT, false);
   AllNodes.push_back(N);
   return SDOperand(N, 0);
 }
 
-SDOperand SelectionDAG::getTargetConstantPool(unsigned CPIdx,
-                                              MVT::ValueType VT) {
-  SDNode *N = TargetConstantPoolIndices[CPIdx];
+SDOperand SelectionDAG::getTargetConstantPool(Constant *C, MVT::ValueType VT) {
+  SDNode *&N = TargetConstantPoolIndices[C];
   if (N) return SDOperand(N, 0);
-  N = new ConstantPoolSDNode(CPIdx, VT, true);
+  N = new ConstantPoolSDNode(C, VT, true);
   AllNodes.push_back(N);
   return SDOperand(N, 0);
 }
@@ -2134,8 +2133,8 @@
   case ISD::BasicBlock:    return "BasicBlock";
   case ISD::Register:      return "Register";
   case ISD::ExternalSymbol: return "ExternalSymbol";
-  case ISD::ConstantPool:  return "ConstantPoolIndex";
-  case ISD::TargetConstantPool:  return "TargetConstantPoolIndex";
+  case ISD::ConstantPool:  return "ConstantPool";
+  case ISD::TargetConstantPool:  return "TargetConstantPool";
   case ISD::CopyToReg:     return "CopyToReg";
   case ISD::CopyFromReg:   return "CopyFromReg";
   case ISD::ImplicitDef:   return "ImplicitDef";
@@ -2287,7 +2286,7 @@
   } else if (const FrameIndexSDNode *FIDN = dyn_cast<FrameIndexSDNode>(this)) {
     std::cerr << "<" << FIDN->getIndex() << ">";
   } else if (const ConstantPoolSDNode *CP = dyn_cast<ConstantPoolSDNode>(this)){
-    std::cerr << "<" << CP->getIndex() << ">";
+    std::cerr << "<" << *CP->get() << ">";
   } else if (const BasicBlockSDNode *BBDN = dyn_cast<BasicBlockSDNode>(this)) {
     std::cerr << "<";
     const Value *LBB = (const Value*)BBDN->getBasicBlock()->getBasicBlock();


Index: llvm/lib/CodeGen/SelectionDAG/SelectionDAGPrinter.cpp
diff -u llvm/lib/CodeGen/SelectionDAG/SelectionDAGPrinter.cpp:1.23 llvm/lib/CodeGen/SelectionDAG/SelectionDAGPrinter.cpp:1.24
--- llvm/lib/CodeGen/SelectionDAG/SelectionDAGPrinter.cpp:1.23	Wed Aug 24 13:30:00 2005
+++ llvm/lib/CodeGen/SelectionDAG/SelectionDAGPrinter.cpp	Fri Aug 26 12:14:58 2005
@@ -11,11 +11,12 @@
 //
 //===----------------------------------------------------------------------===//
 
+#include "llvm/Constants.h"
+#include "llvm/Function.h"
 #include "llvm/CodeGen/SelectionDAG.h"
 #include "llvm/CodeGen/MachineFunction.h"
 #include "llvm/Target/MRegisterInfo.h"
 #include "llvm/Target/TargetMachine.h"
-#include "llvm/Function.h"
 #include "llvm/Support/GraphWriter.h"
 #include "llvm/ADT/StringExtras.h"
 #include "llvm/Config/config.h"
@@ -67,7 +68,8 @@
   } else if (const FrameIndexSDNode *FIDN = dyn_cast<FrameIndexSDNode>(Node)) {
     Op += " " + itostr(FIDN->getIndex());
   } else if (const ConstantPoolSDNode *CP = dyn_cast<ConstantPoolSDNode>(Node)){
-    Op += "<" + utostr(CP->getIndex()) + ">";
+    if (ConstantFP *CFP = dyn_cast<ConstantFP>(CP->get()))
+      Op += "<" + ftostr(CFP->getValue()) + ">";
   } else if (const BasicBlockSDNode *BBDN = dyn_cast<BasicBlockSDNode>(Node)) {
     Op = "BB: ";
     const Value *LBB = (const Value*)BBDN->getBasicBlock()->getBasicBlock();






More information about the llvm-commits mailing list