[llvm-commits] CVS: llvm/lib/CodeGen/SelectionDAG/ScheduleDAG.cpp SelectionDAG.cpp SelectionDAGCSEMap.cpp SelectionDAGPrinter.cpp
Evan Cheng
evan.cheng at apple.com
Tue Sep 12 14:00:52 PDT 2006
Changes in directory llvm/lib/CodeGen/SelectionDAG:
ScheduleDAG.cpp updated: 1.102 -> 1.103
SelectionDAG.cpp updated: 1.337 -> 1.338
SelectionDAGCSEMap.cpp updated: 1.8 -> 1.9
SelectionDAGPrinter.cpp updated: 1.33 -> 1.34
---
Log message:
Added support for machine specific constantpool values. These are useful for
representing expressions that can only be resolved at link time, etc.
---
Diffs of the changes: (+57 -13)
ScheduleDAG.cpp | 14 +++++++++-----
SelectionDAG.cpp | 30 +++++++++++++++++++++++++++++-
SelectionDAGCSEMap.cpp | 7 ++++++-
SelectionDAGPrinter.cpp | 19 +++++++++++++------
4 files changed, 57 insertions(+), 13 deletions(-)
Index: llvm/lib/CodeGen/SelectionDAG/ScheduleDAG.cpp
diff -u llvm/lib/CodeGen/SelectionDAG/ScheduleDAG.cpp:1.102 llvm/lib/CodeGen/SelectionDAG/ScheduleDAG.cpp:1.103
--- llvm/lib/CodeGen/SelectionDAG/ScheduleDAG.cpp:1.102 Mon Sep 4 21:31:13 2006
+++ llvm/lib/CodeGen/SelectionDAG/ScheduleDAG.cpp Tue Sep 12 16:00:35 2006
@@ -324,22 +324,26 @@
dyn_cast<ConstantPoolSDNode>(Op)) {
int Offset = CP->getOffset();
unsigned Align = CP->getAlignment();
+ const Type *Type = CP->getType();
// MachineConstantPool wants an explicit alignment.
if (Align == 0) {
- if (CP->get()->getType() == Type::DoubleTy)
+ if (Type == Type::DoubleTy)
Align = 3; // always 8-byte align doubles.
else {
- Align = TM.getTargetData()
- ->getTypeAlignmentShift(CP->get()->getType());
+ Align = TM.getTargetData()->getTypeAlignmentShift(Type);
if (Align == 0) {
// Alignment of packed types. FIXME!
- Align = TM.getTargetData()->getTypeSize(CP->get()->getType());
+ Align = TM.getTargetData()->getTypeSize(Type);
Align = Log2_64(Align);
}
}
}
- unsigned Idx = ConstPool->getConstantPoolIndex(CP->get(), Align);
+ unsigned Idx;
+ if (CP->isMachineConstantPoolEntry())
+ Idx = ConstPool->getConstantPoolIndex(CP->getMachineCPVal(), Align);
+ else
+ Idx = ConstPool->getConstantPoolIndex(CP->getConstVal(), Align);
MI->addConstantPoolIndexOperand(Idx, Offset);
} else if (ExternalSymbolSDNode *ES =
dyn_cast<ExternalSymbolSDNode>(Op)) {
Index: llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
diff -u llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp:1.337 llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp:1.338
--- llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp:1.337 Sat Sep 9 01:03:30 2006
+++ llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp Tue Sep 12 16:00:35 2006
@@ -17,6 +17,7 @@
#include "llvm/Intrinsics.h"
#include "llvm/Assembly/Writer.h"
#include "llvm/CodeGen/MachineBasicBlock.h"
+#include "llvm/CodeGen/MachineConstantPool.h"
#include "llvm/Support/MathExtras.h"
#include "llvm/Target/MRegisterInfo.h"
#include "llvm/Target/TargetLowering.h"
@@ -587,6 +588,25 @@
}
+SDOperand SelectionDAG::getConstantPool(MachineConstantPoolValue *C,
+ MVT::ValueType VT,
+ unsigned Alignment, int Offset,
+ bool isTarget) {
+ unsigned Opc = isTarget ? ISD::TargetConstantPool : ISD::ConstantPool;
+ SelectionDAGCSEMap::NodeID ID(Opc, getVTList(VT));
+ ID.AddInteger(Alignment);
+ ID.AddInteger(Offset);
+ C->AddSelectionDAGCSEId(&ID);
+ void *IP = 0;
+ if (SDNode *E = CSEMap.FindNodeOrInsertPos(ID, IP))
+ return SDOperand(E, 0);
+ SDNode *N = new ConstantPoolSDNode(isTarget, C, VT, Offset, Alignment);
+ CSEMap.InsertNode(N, IP);
+ AllNodes.push_back(N);
+ return SDOperand(N, 0);
+}
+
+
SDOperand SelectionDAG::getBasicBlock(MachineBasicBlock *MBB) {
SelectionDAGCSEMap::NodeID ID(ISD::BasicBlock, getVTList(MVT::Other));
ID.AddPointer(MBB);
@@ -2586,7 +2606,10 @@
std::cerr << "<" << FIDN->getIndex() << ">";
} else if (const ConstantPoolSDNode *CP = dyn_cast<ConstantPoolSDNode>(this)){
int offset = CP->getOffset();
- std::cerr << "<" << *CP->get() << ">";
+ if (CP->isMachineConstantPoolEntry())
+ std::cerr << "<" << *CP->getMachineCPVal() << ">";
+ else
+ std::cerr << "<" << *CP->getConstVal() << ">";
if (offset > 0)
std::cerr << " + " << offset;
else
@@ -2648,3 +2671,8 @@
std::cerr << "\n\n";
}
+const Type *ConstantPoolSDNode::getType() const {
+ if (isMachineConstantPoolEntry())
+ return Val.MachineCPVal->getType();
+ return Val.ConstVal->getType();
+}
Index: llvm/lib/CodeGen/SelectionDAG/SelectionDAGCSEMap.cpp
diff -u llvm/lib/CodeGen/SelectionDAG/SelectionDAGCSEMap.cpp:1.8 llvm/lib/CodeGen/SelectionDAG/SelectionDAGCSEMap.cpp:1.9
--- llvm/lib/CodeGen/SelectionDAG/SelectionDAGCSEMap.cpp:1.8 Tue Aug 15 14:11:05 2006
+++ llvm/lib/CodeGen/SelectionDAG/SelectionDAGCSEMap.cpp Tue Sep 12 16:00:35 2006
@@ -12,6 +12,7 @@
//===----------------------------------------------------------------------===//
#include "llvm/CodeGen/SelectionDAG.h"
+#include "llvm/CodeGen/MachineConstantPool.h"
#include "llvm/Support/MathExtras.h"
using namespace llvm;
@@ -70,7 +71,11 @@
case ISD::TargetConstantPool:
AddInteger(cast<ConstantPoolSDNode>(N)->getAlignment());
AddInteger(cast<ConstantPoolSDNode>(N)->getOffset());
- AddPointer(cast<ConstantPoolSDNode>(N)->get());
+ if (cast<ConstantPoolSDNode>(N)->isMachineConstantPoolEntry())
+ cast<ConstantPoolSDNode>(N)->getMachineCPVal()->
+ AddSelectionDAGCSEId(this);
+ else
+ AddPointer(cast<ConstantPoolSDNode>(N)->getConstVal());
break;
}
}
Index: llvm/lib/CodeGen/SelectionDAG/SelectionDAGPrinter.cpp
diff -u llvm/lib/CodeGen/SelectionDAG/SelectionDAGPrinter.cpp:1.33 llvm/lib/CodeGen/SelectionDAG/SelectionDAGPrinter.cpp:1.34
--- llvm/lib/CodeGen/SelectionDAG/SelectionDAGPrinter.cpp:1.33 Tue Jun 27 11:49:46 2006
+++ llvm/lib/CodeGen/SelectionDAG/SelectionDAGPrinter.cpp Tue Sep 12 16:00:35 2006
@@ -15,6 +15,7 @@
#include "llvm/Function.h"
#include "llvm/Assembly/Writer.h"
#include "llvm/CodeGen/SelectionDAG.h"
+#include "llvm/CodeGen/MachineConstantPool.h"
#include "llvm/CodeGen/MachineFunction.h"
#include "llvm/Target/MRegisterInfo.h"
#include "llvm/Target/TargetMachine.h"
@@ -80,14 +81,20 @@
} else if (const FrameIndexSDNode *FIDN = dyn_cast<FrameIndexSDNode>(Node)) {
Op += " " + itostr(FIDN->getIndex());
} else if (const ConstantPoolSDNode *CP = dyn_cast<ConstantPoolSDNode>(Node)){
- if (ConstantFP *CFP = dyn_cast<ConstantFP>(CP->get()))
- Op += "<" + ftostr(CFP->getValue()) + ">";
- else if (ConstantInt *CI = dyn_cast<ConstantInt>(CP->get()))
- Op += "<" + utostr(CI->getZExtValue()) + ">";
- else {
+ if (CP->isMachineConstantPoolEntry()) {
std::ostringstream SS;
- WriteAsOperand(SS, CP->get(), false);
+ CP->getMachineCPVal()->print(SS);
Op += "<" + SS.str() + ">";
+ } else {
+ if (ConstantFP *CFP = dyn_cast<ConstantFP>(CP->getConstVal()))
+ Op += "<" + ftostr(CFP->getValue()) + ">";
+ else if (ConstantInt *CI = dyn_cast<ConstantInt>(CP->getConstVal()))
+ Op += "<" + utostr(CI->getZExtValue()) + ">";
+ else {
+ std::ostringstream SS;
+ WriteAsOperand(SS, CP->getConstVal(), false);
+ Op += "<" + SS.str() + ">";
+ }
}
} else if (const BasicBlockSDNode *BBDN = dyn_cast<BasicBlockSDNode>(Node)) {
Op = "BB: ";
More information about the llvm-commits
mailing list