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
This commit is contained in:
Andrew Lenharth
2005-04-27 20:10:01 +00:00
parent 22cab6c752
commit 2d86ea21dd
10 changed files with 145 additions and 67 deletions

View File

@@ -161,6 +161,8 @@ public:
SDOperand N1, SDOperand N2);
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);
@@ -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!");

View File

@@ -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) {
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) {
setValueTypes(VT1, VT2);
}
MVTSDNode(unsigned Opc, MVT::ValueType VT,
SDOperand Op0, SDOperand Op1, SDOperand Op2, SDOperand Op3, MVT::ValueType EVT)
: SDNode(Opc, Op0, Op1, Op2, Op3), ExtraValueType(EVT) {
setValueTypes(VT);
}
public: