Convert MaskedValueIsZero and all its users to use APInt. Also add
[oota-llvm.git] / include / llvm / CodeGen / SelectionDAG.h
index a9ad9a452d4507b745195feee5c2c07f921768cc..cdb15a91cdcd764dc1b800bdd3d9825fd9ad8967 100644 (file)
@@ -139,11 +139,6 @@ public:
   /// SelectionDAG.
   void RemoveDeadNodes();
 
-  /// RemoveDeadNode - Remove the specified node from the system. If any of its
-  /// operands then becomes dead, remove them as well. The vector Deleted is
-  /// populated with nodes that are deleted.
-  void RemoveDeadNode(SDNode *N, std::vector<SDNode*> &Deleted);
-  
   /// DeleteNode - Remove the specified node from the system.  This node must
   /// have no referrers.
   void DeleteNode(SDNode *N);
@@ -177,10 +172,14 @@ public:
   //
   SDOperand getString(const std::string &Val);
   SDOperand getConstant(uint64_t Val, MVT::ValueType VT, bool isTarget = false);
+  SDOperand getConstant(const APInt &Val, MVT::ValueType VT, bool isTarget = false);
   SDOperand getIntPtrConstant(uint64_t Val, bool isTarget = false);
   SDOperand getTargetConstant(uint64_t Val, MVT::ValueType VT) {
     return getConstant(Val, VT, true);
   }
+  SDOperand getTargetConstant(const APInt &Val, MVT::ValueType VT) {
+    return getConstant(Val, VT, true);
+  }
   SDOperand getConstantFP(double Val, MVT::ValueType VT, bool isTarget = false);
   SDOperand getConstantFP(const APFloat& Val, MVT::ValueType VT, 
                           bool isTarget = false);
@@ -357,6 +356,16 @@ public:
   SDOperand getVAArg(MVT::ValueType VT, SDOperand Chain, SDOperand Ptr,
                      SDOperand SV);
 
+  /// getAtomic - Gets a node for an atomic op, produces result and chain, takes
+  // 3 operands
+  SDOperand getAtomic(unsigned Opcode, SDOperand Chain, SDOperand Ptr, 
+                      SDOperand Cmp, SDOperand Swp, MVT::ValueType VT);
+
+  /// getAtomic - Gets a node for an atomic op, produces result and chain, takes
+  // 2 operands
+  SDOperand getAtomic(unsigned Opcode, SDOperand Chain, SDOperand Ptr, 
+                      SDOperand Val, MVT::ValueType VT);
+
   /// 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.
   ///
@@ -381,8 +390,12 @@ public:
   SDOperand getIndexedStore(SDOperand OrigStoe, SDOperand Base,
                            SDOperand Offset, ISD::MemIndexedMode AM);
 
-  // getSrcValue - construct a node to track a Value* through the backend
-  SDOperand getSrcValue(const Value* I, int offset = 0);
+  // getSrcValue - Construct a node to track a Value* through the backend.
+  SDOperand getSrcValue(const Value *v);
+
+  // getMemOperand - Construct a node to track a memory reference
+  // through the backend.
+  SDOperand getMemOperand(const MemOperand &MO);
 
   /// UpdateNodeOperands - *Mutate* the specified node in-place to have the
   /// specified operands.  If the resultant node already exists in the DAG,
@@ -464,28 +477,41 @@ public:
   SDNode *getTargetNode(unsigned Opcode, std::vector<MVT::ValueType> &ResultTys,
                         const SDOperand *Ops, unsigned NumOps);
   
+  /// DAGUpdateListener - Clients of various APIs that cause global effects on
+  /// the DAG can optionally implement this interface.  This allows the clients
+  /// to handle the various sorts of updates that happen.
+  class DAGUpdateListener {
+  public:
+    virtual ~DAGUpdateListener();
+    virtual void NodeDeleted(SDNode *N) = 0;
+    virtual void NodeUpdated(SDNode *N) = 0;
+  };
+  
+  /// RemoveDeadNode - Remove the specified node from the system. If any of its
+  /// operands then becomes dead, remove them as well. Inform UpdateListener
+  /// for each node deleted.
+  void RemoveDeadNode(SDNode *N, DAGUpdateListener *UpdateListener = 0);
+  
   /// ReplaceAllUsesWith - Modify anything using 'From' to use 'To' instead.
   /// This can cause recursive merging of nodes in the DAG.  Use the first
   /// version if 'From' is known to have a single result, use the second
   /// if you have two nodes with identical results, use the third otherwise.
   ///
-  /// These methods all take an optional vector, which (if not null) is 
-  /// populated with any nodes that are deleted from the SelectionDAG, due to
-  /// new equivalences that are discovered.
+  /// These methods all take an optional UpdateListener, which (if not null) is 
+  /// informed about nodes that are deleted and modified due to recursive
+  /// changes in the dag.
   ///
   void ReplaceAllUsesWith(SDOperand From, SDOperand Op,
-                          std::vector<SDNode*> *Deleted = 0);
+                          DAGUpdateListener *UpdateListener = 0);
   void ReplaceAllUsesWith(SDNode *From, SDNode *To,
-                          std::vector<SDNode*> *Deleted = 0);
+                          DAGUpdateListener *UpdateListener = 0);
   void ReplaceAllUsesWith(SDNode *From, const SDOperand *To,
-                          std::vector<SDNode*> *Deleted = 0);
+                          DAGUpdateListener *UpdateListener = 0);
 
   /// ReplaceAllUsesOfValueWith - Replace any uses of From with To, leaving
-  /// uses of other values produced by From.Val alone.  The Deleted vector is
-  /// handled the same was as for ReplaceAllUsesWith, but it is required for
-  /// this method.
+  /// uses of other values produced by From.Val alone.
   void ReplaceAllUsesOfValueWith(SDOperand From, SDOperand To,
-                                 std::vector<SDNode*> *Deleted = 0);
+                                 DAGUpdateListener *UpdateListener = 0);
 
   /// AssignNodeIds - Assign a unique node id for each node in the DAG based on
   /// their allnodes order. It returns the maximum id.
@@ -529,10 +555,14 @@ public:
   SDOperand FoldSetCC(MVT::ValueType VT, SDOperand N1,
                       SDOperand N2, ISD::CondCode Cond);
   
+  /// SignBitIsZero - Return true if the sign bit of Op is known to be zero.  We
+  /// use this predicate to simplify operations downstream.
+  bool SignBitIsZero(SDOperand Op, unsigned Depth = 0) const;
+
   /// MaskedValueIsZero - Return true if 'Op & Mask' is known to be zero.  We
   /// use this predicate to simplify operations downstream.  Op and Mask are
   /// known to be the same type.
-  bool MaskedValueIsZero(SDOperand Op, uint64_t Mask, unsigned Depth = 0)
+  bool MaskedValueIsZero(SDOperand Op, const APInt &Mask, unsigned Depth = 0)
     const;
   
   /// ComputeMaskedBits - Determine which of the bits specified in Mask are
@@ -540,6 +570,12 @@ public:
   /// bitsets.  This code only analyzes bits in Mask, in order to short-circuit
   /// processing.  Targets can implement the computeMaskedBitsForTargetNode 
   /// method in the TargetLowering class to allow target nodes to be understood.
+  void ComputeMaskedBits(SDOperand Op, const APInt &Mask, APInt &KnownZero,
+                         APInt &KnownOne, unsigned Depth = 0) const;
+
+  /// ComputeMaskedBits - This is a wrapper around the APInt-using
+  /// form of ComputeMaskedBits for use by clients that haven't been converted
+  /// to APInt yet.
   void ComputeMaskedBits(SDOperand Op, uint64_t Mask, uint64_t &KnownZero,
                          uint64_t &KnownOne, unsigned Depth = 0) const;
     
@@ -551,6 +587,10 @@ public:
   /// implement the ComputeNumSignBitsForTarget method in the TargetLowering
   /// class to allow target nodes to be understood.
   unsigned ComputeNumSignBits(SDOperand Op, unsigned Depth = 0) const;
+
+  /// isVerifiedDebugInfoDesc - Returns true if the specified SDOperand has
+  /// been verified as a debug information descriptor.
+  bool isVerifiedDebugInfoDesc(SDOperand Op) const;
   
 private:
   void RemoveNodeFromCSEMaps(SDNode *N);