Add a new node
[oota-llvm.git] / include / llvm / CodeGen / SelectionDAGNodes.h
index 37e0ed02071e4b284ba0110085caf59a4b905726..2011eb87710917ecffb984e7330242d5d89e71e8 100644 (file)
@@ -74,6 +74,9 @@ namespace ISD {
     // out.
     ImplicitDef,
 
+    // UNDEF - An undefined node
+    UNDEF,
+
     // EXTRACT_ELEMENT - This is used to get the first or second (determined by
     // a Constant, which is required to be operand #1), element of the aggregate
     // value specified as operand #0.  This is only for use before legalization,
@@ -89,6 +92,10 @@ namespace ISD {
     // Simple binary arithmetic operators.
     ADD, SUB, MUL, SDIV, UDIV, SREM, UREM,
 
+    // MULHU/MULHS - Multiply high - Multiply two integers of type iN, producing
+    // an unsigned/signed value of type i[2*n], then return the top part.
+    MULHU, MULHS,
+
     // Bitwise operators.
     AND, OR, XOR, SHL, SRA, SRL,
 
@@ -101,10 +108,18 @@ namespace ISD {
     // state.
     SETCC,
 
-    // addc - Three input, two output operator: (X, Y, C) -> (X+Y+C,
-    // Cout).  X,Y are integer inputs of agreeing size, C is a one bit
-    // value, and two values are produced: the sum and a carry out.
-    ADDC, SUBB,
+    // ADD_PARTS/SUB_PARTS - These operators take two logical operands which are
+    // broken into a multiple pieces each, and return the resulting pieces of
+    // doing an atomic add/sub operation.  This is used to handle add/sub of
+    // expanded types.  The operation ordering is:
+    //       [Lo,Hi] = op [LoLHS,HiLHS], [LoRHS,HiRHS]
+    ADD_PARTS, SUB_PARTS,
+
+    // SHL_PARTS/SRA_PARTS/SRL_PARTS - These operators are used for expanded
+    // integer shift operations, just like ADD/SUB_PARTS.  The operation
+    // ordering is:
+    //       [Lo,Hi] = op [LoLHS,HiLHS], Amt
+    SHL_PARTS, SRA_PARTS, SRL_PARTS,
 
     // Conversion operators.  These are all single input single output
     // operations.  For all of these, the result type must be strictly
@@ -153,6 +168,10 @@ namespace ISD {
     // FP_EXTEND - Extend a smaller FP type into a larger FP type.
     FP_EXTEND,
 
+    // FNEG, FABS - Perform unary floating point negation and absolute value
+    // operations.
+    FNEG, FABS,
+
     // Other operators.  LOAD and STORE have token chains as their first
     // operand, then the same operands as an LLVM load/store instruction.
     LOAD, STORE,
@@ -197,6 +216,13 @@ namespace ISD {
     // to if the condition is true.
     BRCOND,
 
+    // BRCONDTWOWAY - Two-way conditional branch.  The first operand is the
+    // chain, the second is the condition, the third is the block to branch to
+    // if true, and the forth is the block to branch to if false.  Targets
+    // usually do not implement this, preferring to have legalize demote the
+    // operation to BRCOND/BR pairs when necessary.
+    BRCONDTWOWAY,
+
     // RET - Return from function.  The first operand is the chain,
     // and any subsequent operands are the return values for the
     // function.  This operation can have variable number of operands.
@@ -223,6 +249,8 @@ namespace ISD {
     ADJCALLSTACKDOWN,  // Beginning of a call sequence
     ADJCALLSTACKUP,    // End of a call sequence
 
+    // PCMARKER - This corresponds to the pcmarker intrinsic.
+    PCMARKER,
 
     // BUILTIN_OP_END - This must be the last enum value in this list.
     BUILTIN_OP_END,
@@ -358,9 +386,10 @@ public:
   /// getValueType - Return the ValueType of the referenced return value.
   ///
   inline MVT::ValueType getValueType() const;
-
+  
   // Forwarding methods - These forward to the corresponding methods in SDNode.
   inline unsigned getOpcode() const;
+  inline unsigned getNodeDepth() const;
   inline unsigned getNumOperands() const;
   inline const SDOperand &getOperand(unsigned i) const;
 
@@ -389,7 +418,17 @@ template<> struct simplify_type<const SDOperand> {
 /// SDNode - Represents one node in the SelectionDAG.
 ///
 class SDNode {
-  unsigned NodeType;
+  /// NodeType - The operation that this node performs.
+  ///
+  unsigned short NodeType;
+
+  /// NodeDepth - Node depth is defined as MAX(Node depth of children)+1.  This
+  /// means that leaves have a depth of 1, things that use only leaves have a
+  /// depth of 2, etc.
+  unsigned short NodeDepth;
+
+  /// Operands - The values that are used by this operation.
+  ///
   std::vector<SDOperand> Operands;
 
   /// Values - The types of the values this node defines.  SDNode's may define
@@ -410,6 +449,10 @@ public:
   bool use_empty() const { return Uses.empty(); }
   bool hasOneUse() const { return Uses.size() == 1; }
 
+  /// getNodeDepth - Return the distance from this node to the leaves in the
+  /// graph.  The leaves have a depth of 1.
+  unsigned getNodeDepth() const { return NodeDepth; }
+
   typedef std::vector<SDNode*>::const_iterator use_iterator;
   use_iterator use_begin() const { return Uses.begin(); }
   use_iterator use_end() const { return Uses.end(); }
@@ -455,23 +498,33 @@ public:
 protected:
   friend class SelectionDAG;
 
-  SDNode(unsigned NT, MVT::ValueType VT) : NodeType(NT) {
+  SDNode(unsigned NT, MVT::ValueType VT) : NodeType(NT), NodeDepth(1) {
     Values.reserve(1);
     Values.push_back(VT);
   }
-
   SDNode(unsigned NT, SDOperand Op)
-    : NodeType(NT) {
+    : NodeType(NT), NodeDepth(Op.Val->getNodeDepth()+1) {
     Operands.reserve(1); Operands.push_back(Op);
     Op.Val->Uses.push_back(this);
   }
   SDNode(unsigned NT, SDOperand N1, SDOperand N2)
     : NodeType(NT) {
+    if (N1.Val->getNodeDepth() > N2.Val->getNodeDepth())
+      NodeDepth = N1.Val->getNodeDepth()+1;
+    else
+      NodeDepth = N2.Val->getNodeDepth()+1;
     Operands.reserve(2); Operands.push_back(N1); Operands.push_back(N2);
     N1.Val->Uses.push_back(this); N2.Val->Uses.push_back(this);
   }
   SDNode(unsigned NT, SDOperand N1, SDOperand N2, SDOperand N3)
     : 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();
+    NodeDepth = ND+1;
+
     Operands.reserve(3); Operands.push_back(N1); Operands.push_back(N2);
     Operands.push_back(N3);
     N1.Val->Uses.push_back(this); N2.Val->Uses.push_back(this);
@@ -479,8 +532,13 @@ protected:
   }
   SDNode(unsigned NT, std::vector<SDOperand> &Nodes) : NodeType(NT) {
     Operands.swap(Nodes);
-    for (unsigned i = 0, e = Operands.size(); i != e; ++i)
+    unsigned ND = 0;
+    for (unsigned i = 0, e = Operands.size(); i != e; ++i) {
       Operands[i].Val->Uses.push_back(this);
+      if (ND < Operands[i].Val->getNodeDepth())
+        ND = Operands[i].Val->getNodeDepth();
+    }
+    NodeDepth = ND+1;
   }
 
   virtual ~SDNode() {
@@ -519,6 +577,9 @@ protected:
 inline unsigned SDOperand::getOpcode() const {
   return Val->getOpcode();
 }
+inline unsigned SDOperand::getNodeDepth() const {
+  return Val->getNodeDepth();
+}
 inline MVT::ValueType SDOperand::getValueType() const {
   return Val->getValueType(ResNo);
 }
@@ -551,7 +612,9 @@ public:
 
   bool isNullValue() const { return Value == 0; }
   bool isAllOnesValue() const {
-    return Value == (1ULL << MVT::getSizeInBits(getValueType(0)))-1;
+    int NumBits = MVT::getSizeInBits(getValueType(0));
+    if (NumBits == 64) return Value+1 == 0;
+    return Value == (1ULL << NumBits)-1;
   }
 
   static bool classof(const ConstantSDNode *) { return true; }