diff options
author | Andrew Lenharth <andrewl@lenharth.org> | 2005-04-27 20:10:01 +0000 |
---|---|---|
committer | Andrew Lenharth <andrewl@lenharth.org> | 2005-04-27 20:10:01 +0000 |
commit | 2d86ea21dd76647cb054fd5d27df9e49efc672b6 (patch) | |
tree | 87a965525520ccbd1d200407f54627b3697cdb6a /include/llvm/CodeGen | |
parent | 22cab6c752c75f81c05c679befd437e613138f6f (diff) | |
download | external_llvm-2d86ea21dd76647cb054fd5d27df9e49efc672b6.zip external_llvm-2d86ea21dd76647cb054fd5d27df9e49efc672b6.tar.gz external_llvm-2d86ea21dd76647cb054fd5d27df9e49efc672b6.tar.bz2 |
Implement Value* tracking for loads and stores in the selection DAG. This enables one to use alias analysis in the backends.
(TRUNK)Stores and (EXT|ZEXT|SEXT)Loads have an extra SDOperand which is a SrcValueSDNode which contains the Value*. Note that if the operation is introduced by the backend, it will still have the operand, but the value* will be null.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21599 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm/CodeGen')
-rw-r--r-- | include/llvm/CodeGen/SelectionDAG.h | 9 | ||||
-rw-r--r-- | include/llvm/CodeGen/SelectionDAGNodes.h | 47 |
2 files changed, 51 insertions, 5 deletions
diff --git a/include/llvm/CodeGen/SelectionDAG.h b/include/llvm/CodeGen/SelectionDAG.h index 39d4ef4..f3d41ce 100644 --- a/include/llvm/CodeGen/SelectionDAG.h +++ b/include/llvm/CodeGen/SelectionDAG.h @@ -162,6 +162,8 @@ public: SDOperand getNode(unsigned Opcode, MVT::ValueType VT, SDOperand N1, SDOperand N2, SDOperand N3); SDOperand getNode(unsigned Opcode, MVT::ValueType VT, + SDOperand N1, SDOperand N2, SDOperand N3, SDOperand N4); + SDOperand getNode(unsigned Opcode, MVT::ValueType VT, std::vector<SDOperand> &Children); // getNode - These versions take an extra value type for extending and @@ -172,11 +174,16 @@ public: SDOperand N, MVT::ValueType EVT); SDOperand getNode(unsigned Opcode, MVT::ValueType VT, SDOperand N1, SDOperand N2, SDOperand N3, MVT::ValueType EVT); + SDOperand getNode(unsigned Opcode, MVT::ValueType VT, SDOperand N1, + SDOperand N2, SDOperand N3, SDOperand N4, MVT::ValueType EVT); /// getLoad - Loads are not normal binary operators: their result type is not /// determined by their operands, and they produce a value AND a token chain. /// - SDOperand getLoad(MVT::ValueType VT, SDOperand Chain, SDOperand Ptr); + SDOperand getLoad(MVT::ValueType VT, SDOperand Chain, SDOperand Ptr, SDOperand SV); + + // getSrcValue - construct a node to track a Value* through the backend + SDOperand getSrcValue(const Value* I); void replaceAllUsesWith(SDOperand Old, SDOperand New) { assert(Old != New && "RAUW self!"); diff --git a/include/llvm/CodeGen/SelectionDAGNodes.h b/include/llvm/CodeGen/SelectionDAGNodes.h index 35993d9..1df6513 100644 --- a/include/llvm/CodeGen/SelectionDAGNodes.h +++ b/include/llvm/CodeGen/SelectionDAGNodes.h @@ -20,6 +20,7 @@ #define LLVM_CODEGEN_SELECTIONDAGNODES_H #include "llvm/CodeGen/ValueTypes.h" +#include "llvm/Value.h" #include "llvm/ADT/GraphTraits.h" #include "llvm/ADT/GraphTraits.h" #include "llvm/ADT/iterator" @@ -251,6 +252,11 @@ namespace ISD { // PCMARKER - This corresponds to the pcmarker intrinsic. PCMARKER, + // SRCVALUE - This corresponds to a Value*, and is used to carry associate + // memory operations with their corrosponding load. This lets one use the + // pointer analysis information in the backend + SRCVALUE, + // BUILTIN_OP_END - This must be the last enum value in this list. BUILTIN_OP_END, }; @@ -529,6 +535,22 @@ protected: N1.Val->Uses.push_back(this); N2.Val->Uses.push_back(this); N3.Val->Uses.push_back(this); } + SDNode(unsigned NT, SDOperand N1, SDOperand N2, SDOperand N3, SDOperand N4) + : NodeType(NT) { + unsigned ND = N1.Val->getNodeDepth(); + if (ND < N2.Val->getNodeDepth()) + ND = N2.Val->getNodeDepth(); + if (ND < N3.Val->getNodeDepth()) + ND = N3.Val->getNodeDepth(); + if (ND < N4.Val->getNodeDepth()) + ND = N4.Val->getNodeDepth(); + NodeDepth = ND+1; + + Operands.reserve(3); Operands.push_back(N1); Operands.push_back(N2); + Operands.push_back(N3); Operands.push_back(N4); + N1.Val->Uses.push_back(this); N2.Val->Uses.push_back(this); + N3.Val->Uses.push_back(this); N4.Val->Uses.push_back(this); + } SDNode(unsigned NT, std::vector<SDOperand> &Nodes) : NodeType(NT) { Operands.swap(Nodes); unsigned ND = 0; @@ -724,6 +746,22 @@ public: } }; +class SrcValueSDNode : public SDNode { + const Value *V; +protected: + friend class SelectionDAG; + SrcValueSDNode(const Value* v) + : SDNode(ISD::SRCVALUE, MVT::Other), V(v) {} + +public: + const Value *getValue() const { return V; } + + static bool classof(const SrcValueSDNode *) { return true; } + static bool classof(const SDNode *N) { + return N->getOpcode() == ISD::SRCVALUE; + } +}; + class RegSDNode : public SDNode { unsigned Reg; @@ -791,13 +829,14 @@ protected: setValueTypes(VT1); } MVTSDNode(unsigned Opc, MVT::ValueType VT1, MVT::ValueType VT2, - SDOperand Op0, SDOperand Op1, MVT::ValueType EVT) - : SDNode(Opc, Op0, Op1), ExtraValueType(EVT) { + SDOperand Op0, SDOperand Op1, SDOperand Op2, MVT::ValueType EVT) + : SDNode(Opc, Op0, Op1, Op2), ExtraValueType(EVT) { setValueTypes(VT1, VT2); } + MVTSDNode(unsigned Opc, MVT::ValueType VT, - SDOperand Op0, SDOperand Op1, SDOperand Op2, MVT::ValueType EVT) - : SDNode(Opc, Op0, Op1, Op2), ExtraValueType(EVT) { + SDOperand Op0, SDOperand Op1, SDOperand Op2, SDOperand Op3, MVT::ValueType EVT) + : SDNode(Opc, Op0, Op1, Op2, Op3), ExtraValueType(EVT) { setValueTypes(VT); } public: |