[llvm-commits] CVS: llvm/include/llvm/CodeGen/SelectionDAG.h SelectionDAGNodes.h
Chris Lattner
lattner at cs.uiuc.edu
Tue Aug 9 13:19:45 PDT 2005
Changes in directory llvm/include/llvm/CodeGen:
SelectionDAG.h updated: 1.30 -> 1.31
SelectionDAGNodes.h updated: 1.45 -> 1.46
---
Log message:
Eliminate the SetCCSDNode in favor of a CondCodeSDNode class. This pulls the
CC out of the SetCC operation, making SETCC a standard ternary operation and
CC's a standard DAG leaf. This will make it possible for other node to use
CC's as operands in the future...
---
Diffs of the changes: (+26 -17)
SelectionDAG.h | 23 ++++++++++++++++-------
SelectionDAGNodes.h | 20 ++++++++++----------
2 files changed, 26 insertions(+), 17 deletions(-)
Index: llvm/include/llvm/CodeGen/SelectionDAG.h
diff -u llvm/include/llvm/CodeGen/SelectionDAG.h:1.30 llvm/include/llvm/CodeGen/SelectionDAG.h:1.31
--- llvm/include/llvm/CodeGen/SelectionDAG.h:1.30 Sat Jul 9 20:55:14 2005
+++ llvm/include/llvm/CodeGen/SelectionDAG.h Tue Aug 9 15:19:34 2005
@@ -152,9 +152,7 @@
return NN;
}
-
- SDOperand getSetCC(ISD::CondCode, MVT::ValueType VT,
- SDOperand LHS, SDOperand RHS);
+ SDOperand getCondCode(ISD::CondCode Cond);
/// getZeroExtendInReg - Return the expression required to zero extend the Op
/// value assuming it was the smaller SrcTy value.
@@ -178,7 +176,14 @@
SDOperand getNode(unsigned Opcode, std::vector<MVT::ValueType> &ResultTys,
std::vector<SDOperand> &Ops);
-
+ /// getSetCC - Helper function to make it easier to build SetCC's if you just
+ /// have an ISD::CondCode instead of an SDOperand.
+ ///
+ SDOperand getSetCC(MVT::ValueType VT, SDOperand LHS, SDOperand RHS,
+ ISD::CondCode Cond) {
+ return getNode(ISD::SETCC, VT, LHS, RHS, getCondCode(Cond));
+ }
+
/// 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.
///
@@ -199,16 +204,20 @@
private:
void DeleteNodeIfDead(SDNode *N, void *NodeSet);
+
+ // Try to simplify a setcc built with the specified operands and cc. If
+ // unable to simplify it, return a null SDOperand.
+ SDOperand SimplfySetCC(MVT::ValueType VT, SDOperand N1,
+ SDOperand N2, ISD::CondCode Cond);
+
// Maps to auto-CSE operations.
std::map<std::pair<unsigned, std::pair<SDOperand, MVT::ValueType> >,
SDNode *> UnaryOps;
std::map<std::pair<unsigned, std::pair<SDOperand, SDOperand> >,
SDNode *> BinaryOps;
- std::map<std::pair<std::pair<SDOperand, SDOperand>,
- std::pair<ISD::CondCode, MVT::ValueType> >,
- SetCCSDNode*> SetCCs;
+ std::vector<CondCodeSDNode*> CondCodeNodes;
std::map<std::pair<SDOperand, std::pair<SDOperand, MVT::ValueType> >,
SDNode *> Loads;
Index: llvm/include/llvm/CodeGen/SelectionDAGNodes.h
diff -u llvm/include/llvm/CodeGen/SelectionDAGNodes.h:1.45 llvm/include/llvm/CodeGen/SelectionDAGNodes.h:1.46
--- llvm/include/llvm/CodeGen/SelectionDAGNodes.h:1.45 Wed Jul 27 00:53:43 2005
+++ llvm/include/llvm/CodeGen/SelectionDAGNodes.h Tue Aug 9 15:19:34 2005
@@ -55,7 +55,7 @@
// Various leaf nodes.
Constant, ConstantFP, GlobalAddress, FrameIndex, ConstantPool,
- BasicBlock, ExternalSymbol, VALUETYPE,
+ BasicBlock, ExternalSymbol, VALUETYPE, CONDCODE,
// CopyToReg - This node has chain and child nodes, and an associated
// register number. The instruction selector must guarantee that the value
@@ -107,9 +107,9 @@
SELECT,
// SetCC operator - This evaluates to a boolean (i1) true value if the
- // condition is true. These nodes are instances of the
- // SetCCSDNode class, which contains the condition code as extra
- // state.
+ // condition is true. The operands to this are the left and right operands
+ // to compare (ops #0, and #1) and the condition code to compare them with
+ // (op #2) as a CondCodeSDNode.
SETCC,
// ADD_PARTS/SUB_PARTS - These operators take two logical operands which are
@@ -827,20 +827,20 @@
}
};
-class SetCCSDNode : public SDNode {
+class CondCodeSDNode : public SDNode {
ISD::CondCode Condition;
protected:
friend class SelectionDAG;
- SetCCSDNode(ISD::CondCode Cond, SDOperand LHS, SDOperand RHS)
- : SDNode(ISD::SETCC, LHS, RHS), Condition(Cond) {
+ CondCodeSDNode(ISD::CondCode Cond)
+ : SDNode(ISD::CONDCODE, MVT::Other), Condition(Cond) {
}
public:
- ISD::CondCode getCondition() const { return Condition; }
+ ISD::CondCode get() const { return Condition; }
- static bool classof(const SetCCSDNode *) { return true; }
+ static bool classof(const CondCodeSDNode *) { return true; }
static bool classof(const SDNode *N) {
- return N->getOpcode() == ISD::SETCC;
+ return N->getOpcode() == ISD::CONDCODE;
}
};
More information about the llvm-commits
mailing list