diff options
author | Evan Cheng <evan.cheng@apple.com> | 2006-09-12 21:00:35 +0000 |
---|---|---|
committer | Evan Cheng <evan.cheng@apple.com> | 2006-09-12 21:00:35 +0000 |
commit | d6594ae54cfde4db4d30272192645c0a45fb9902 (patch) | |
tree | 7b89d2a0c89f9fc9bdb58acad508acd59cf3702d /lib/CodeGen/SelectionDAG/SelectionDAG.cpp | |
parent | cd5731d98b15c9de236bd0dd6c9c57d9bcecbceb (diff) |
Added support for machine specific constantpool values. These are useful for
representing expressions that can only be resolved at link time, etc.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@30278 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/SelectionDAG/SelectionDAG.cpp')
-rw-r--r-- | lib/CodeGen/SelectionDAG/SelectionDAG.cpp | 30 |
1 files changed, 29 insertions, 1 deletions
diff --git a/lib/CodeGen/SelectionDAG/SelectionDAG.cpp b/lib/CodeGen/SelectionDAG/SelectionDAG.cpp index 044a2fa976..df6d604bd1 100644 --- a/lib/CodeGen/SelectionDAG/SelectionDAG.cpp +++ b/lib/CodeGen/SelectionDAG/SelectionDAG.cpp @@ -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(Constant *C, MVT::ValueType VT, } +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 @@ void SDNode::dump(const SelectionDAG *G) const { 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 @@ void SelectionDAG::dump() const { std::cerr << "\n\n"; } +const Type *ConstantPoolSDNode::getType() const { + if (isMachineConstantPoolEntry()) + return Val.MachineCPVal->getType(); + return Val.ConstVal->getType(); +} |