[llvm-commits] CVS: llvm/include/llvm/CodeGen/SelectionDAG.h SelectionDAGNodes.h

Andrew Lenharth alenhar2 at cs.uiuc.edu
Wed Apr 27 13:10:17 PDT 2005



Changes in directory llvm/include/llvm/CodeGen:

SelectionDAG.h updated: 1.21 -> 1.22
SelectionDAGNodes.h updated: 1.33 -> 1.34
---
Log message:

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.



---
Diffs of the changes:  (+51 -5)

 SelectionDAG.h      |    9 ++++++++-
 SelectionDAGNodes.h |   47 +++++++++++++++++++++++++++++++++++++++++++----
 2 files changed, 51 insertions(+), 5 deletions(-)


Index: llvm/include/llvm/CodeGen/SelectionDAG.h
diff -u llvm/include/llvm/CodeGen/SelectionDAG.h:1.21 llvm/include/llvm/CodeGen/SelectionDAG.h:1.22
--- llvm/include/llvm/CodeGen/SelectionDAG.h:1.21	Thu Apr 21 15:38:00 2005
+++ llvm/include/llvm/CodeGen/SelectionDAG.h	Wed Apr 27 15:10:01 2005
@@ -162,6 +162,8 @@
   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 @@
                     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!");


Index: llvm/include/llvm/CodeGen/SelectionDAGNodes.h
diff -u llvm/include/llvm/CodeGen/SelectionDAGNodes.h:1.33 llvm/include/llvm/CodeGen/SelectionDAGNodes.h:1.34
--- llvm/include/llvm/CodeGen/SelectionDAGNodes.h:1.33	Thu Apr 21 15:38:00 2005
+++ llvm/include/llvm/CodeGen/SelectionDAGNodes.h	Wed Apr 27 15:10:01 2005
@@ -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 @@
     // 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 @@
     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 @@
   }
 };
 
+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 @@
     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:






More information about the llvm-commits mailing list