[llvm-commits] [llvm] r97053 - in /llvm/trunk: include/llvm/CodeGen/DAGISelHeader.h utils/TableGen/DAGISelMatcher.cpp utils/TableGen/DAGISelMatcher.h utils/TableGen/DAGISelMatcherEmitter.cpp utils/TableGen/DAGISelMatcherOpt.cpp
Chris Lattner
sabre at nondot.org
Wed Feb 24 12:15:25 PST 2010
Author: lattner
Date: Wed Feb 24 14:15:25 2010
New Revision: 97053
URL: http://llvm.org/viewvc/llvm-project?rev=97053&view=rev
Log:
contract movechild+checktype into a new checkchild node, shrinking the
x86 table by 1200 bytes.
Modified:
llvm/trunk/include/llvm/CodeGen/DAGISelHeader.h
llvm/trunk/utils/TableGen/DAGISelMatcher.cpp
llvm/trunk/utils/TableGen/DAGISelMatcher.h
llvm/trunk/utils/TableGen/DAGISelMatcherEmitter.cpp
llvm/trunk/utils/TableGen/DAGISelMatcherOpt.cpp
Modified: llvm/trunk/include/llvm/CodeGen/DAGISelHeader.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/DAGISelHeader.h?rev=97053&r1=97052&r2=97053&view=diff
==============================================================================
--- llvm/trunk/include/llvm/CodeGen/DAGISelHeader.h (original)
+++ llvm/trunk/include/llvm/CodeGen/DAGISelHeader.h Wed Feb 24 14:15:25 2010
@@ -233,6 +233,9 @@
OPC_CheckOpcode,
OPC_CheckMultiOpcode,
OPC_CheckType,
+ OPC_CheckChild0Type, OPC_CheckChild1Type, OPC_CheckChild2Type,
+ OPC_CheckChild3Type, OPC_CheckChild4Type, OPC_CheckChild5Type,
+ OPC_CheckChild6Type, OPC_CheckChild7Type,
OPC_CheckInteger1, OPC_CheckInteger2, OPC_CheckInteger4, OPC_CheckInteger8,
OPC_CheckCondCode,
OPC_CheckValueType,
@@ -481,6 +484,23 @@
}
continue;
}
+ case OPC_CheckChild0Type: case OPC_CheckChild1Type:
+ case OPC_CheckChild2Type: case OPC_CheckChild3Type:
+ case OPC_CheckChild4Type: case OPC_CheckChild5Type:
+ case OPC_CheckChild6Type: case OPC_CheckChild7Type: {
+ unsigned ChildNo = Opcode-OPC_CheckChild0Type;
+ if (ChildNo >= N.getNumOperands())
+ break; // Match fails if out of range child #.
+
+ MVT::SimpleValueType VT =
+ (MVT::SimpleValueType)MatcherTable[MatcherIndex++];
+ if (N.getOperand(ChildNo).getValueType() != VT) {
+ // Handle the case when VT is iPTR.
+ if (VT != MVT::iPTR || N.getValueType() != TLI.getPointerTy())
+ break;
+ }
+ continue;
+ }
case OPC_CheckCondCode:
if (cast<CondCodeSDNode>(N)->get() !=
(ISD::CondCode)MatcherTable[MatcherIndex++]) break;
Modified: llvm/trunk/utils/TableGen/DAGISelMatcher.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/DAGISelMatcher.cpp?rev=97053&r1=97052&r2=97053&view=diff
==============================================================================
--- llvm/trunk/utils/TableGen/DAGISelMatcher.cpp (original)
+++ llvm/trunk/utils/TableGen/DAGISelMatcher.cpp Wed Feb 24 14:15:25 2010
@@ -91,6 +91,13 @@
printNext(OS, indent);
}
+void CheckChildTypeMatcherNode::print(raw_ostream &OS, unsigned indent) const {
+ OS.indent(indent) << "CheckChildType " << ChildNo << " "
+ << getEnumName(Type) << '\n';
+ printNext(OS, indent);
+}
+
+
void CheckIntegerMatcherNode::print(raw_ostream &OS, unsigned indent) const {
OS.indent(indent) << "CheckInteger " << Value << '\n';
printNext(OS, indent);
Modified: llvm/trunk/utils/TableGen/DAGISelMatcher.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/DAGISelMatcher.h?rev=97053&r1=97052&r2=97053&view=diff
==============================================================================
--- llvm/trunk/utils/TableGen/DAGISelMatcher.h (original)
+++ llvm/trunk/utils/TableGen/DAGISelMatcher.h Wed Feb 24 14:15:25 2010
@@ -54,6 +54,7 @@
CheckOpcode, // Fail if not opcode.
CheckMultiOpcode, // Fail if not in opcode list.
CheckType, // Fail if not correct type.
+ CheckChildType, // Fail if child has wrong type.
CheckInteger, // Fail if wrong val.
CheckCondCode, // Fail if not condcode.
CheckValueType,
@@ -328,6 +329,26 @@
virtual void print(raw_ostream &OS, unsigned indent = 0) const;
};
+
+/// CheckChildTypeMatcherNode - This checks to see if a child node has the
+/// specified type, if not it fails to match.
+class CheckChildTypeMatcherNode : public MatcherNode {
+ unsigned ChildNo;
+ MVT::SimpleValueType Type;
+public:
+ CheckChildTypeMatcherNode(unsigned childno, MVT::SimpleValueType type)
+ : MatcherNode(CheckChildType), ChildNo(childno), Type(type) {}
+
+ unsigned getChildNo() const { return ChildNo; }
+ MVT::SimpleValueType getType() const { return Type; }
+
+ static inline bool classof(const MatcherNode *N) {
+ return N->getKind() == CheckChildType;
+ }
+
+ virtual void print(raw_ostream &OS, unsigned indent = 0) const;
+};
+
/// CheckIntegerMatcherNode - This checks to see if the current node is a
/// ConstantSDNode with the specified integer value, if not it fails to match.
Modified: llvm/trunk/utils/TableGen/DAGISelMatcherEmitter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/DAGISelMatcherEmitter.cpp?rev=97053&r1=97052&r2=97053&view=diff
==============================================================================
--- llvm/trunk/utils/TableGen/DAGISelMatcherEmitter.cpp (original)
+++ llvm/trunk/utils/TableGen/DAGISelMatcherEmitter.cpp Wed Feb 24 14:15:25 2010
@@ -222,7 +222,12 @@
OS << "OPC_CheckType, "
<< getEnumName(cast<CheckTypeMatcherNode>(N)->getType()) << ",\n";
return 2;
-
+ case MatcherNode::CheckChildType:
+ OS << "OPC_CheckChild"
+ << cast<CheckChildTypeMatcherNode>(N)->getChildNo() << "Type, "
+ << getEnumName(cast<CheckChildTypeMatcherNode>(N)->getType()) << ",\n";
+ return 2;
+
case MatcherNode::CheckInteger: {
int64_t Val = cast<CheckIntegerMatcherNode>(N)->getValue();
OS << "OPC_CheckInteger" << ClassifyInt(Val) << ", ";
@@ -523,6 +528,7 @@
case MatcherNode::CheckOpcode: OS << "OPC_CheckOpcode"; break;
case MatcherNode::CheckMultiOpcode: OS << "OPC_CheckMultiOpcode"; break;
case MatcherNode::CheckType: OS << "OPC_CheckType"; break;
+ case MatcherNode::CheckChildType: OS << "OPC_CheckChildType"; break;
case MatcherNode::CheckInteger: OS << "OPC_CheckInteger"; break;
case MatcherNode::CheckCondCode: OS << "OPC_CheckCondCode"; break;
case MatcherNode::CheckValueType: OS << "OPC_CheckValueType"; break;
Modified: llvm/trunk/utils/TableGen/DAGISelMatcherOpt.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/DAGISelMatcherOpt.cpp?rev=97053&r1=97052&r2=97053&view=diff
==============================================================================
--- llvm/trunk/utils/TableGen/DAGISelMatcherOpt.cpp (original)
+++ llvm/trunk/utils/TableGen/DAGISelMatcherOpt.cpp Wed Feb 24 14:15:25 2010
@@ -26,12 +26,19 @@
// If we found a movechild node with a node that comes in a 'foochild' form,
// transform it.
if (MoveChildMatcherNode *MC = dyn_cast<MoveChildMatcherNode>(N)) {
- if (RecordMatcherNode *RM = dyn_cast<RecordMatcherNode>(MC->getNext())) {
- MatcherNode *New
- = new RecordChildMatcherNode(MC->getChildNo(), RM->getWhatFor());
+ MatcherNode *New = 0;
+ if (RecordMatcherNode *RM = dyn_cast<RecordMatcherNode>(MC->getNext()))
+ New = new RecordChildMatcherNode(MC->getChildNo(), RM->getWhatFor());
+
+ if (CheckTypeMatcherNode *CT= dyn_cast<CheckTypeMatcherNode>(MC->getNext()))
+ New = new CheckChildTypeMatcherNode(MC->getChildNo(), CT->getType());
+
+ if (New) {
+ // Insert the new node.
New->setNext(Matcher.take());
Matcher.reset(New);
- MC->setNext(RM->takeNext());
+ // Remove the old one.
+ MC->setNext(MC->getNext()->takeNext());
return ContractNodes(Matcher);
}
}
More information about the llvm-commits
mailing list