mirror of
https://github.com/RPCS3/llvm.git
synced 2025-05-13 17:06:15 +00:00
contract movechild+checktype into a new checkchild node, shrinking the
x86 table by 1200 bytes. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@97053 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
d88360495a
commit
23cfda719e
@ -233,6 +233,9 @@ enum BuiltinOpcodes {
|
|||||||
OPC_CheckOpcode,
|
OPC_CheckOpcode,
|
||||||
OPC_CheckMultiOpcode,
|
OPC_CheckMultiOpcode,
|
||||||
OPC_CheckType,
|
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_CheckInteger1, OPC_CheckInteger2, OPC_CheckInteger4, OPC_CheckInteger8,
|
||||||
OPC_CheckCondCode,
|
OPC_CheckCondCode,
|
||||||
OPC_CheckValueType,
|
OPC_CheckValueType,
|
||||||
@ -481,6 +484,23 @@ SDNode *SelectCodeCommon(SDNode *NodeToMatch, const unsigned char *MatcherTable,
|
|||||||
}
|
}
|
||||||
continue;
|
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:
|
case OPC_CheckCondCode:
|
||||||
if (cast<CondCodeSDNode>(N)->get() !=
|
if (cast<CondCodeSDNode>(N)->get() !=
|
||||||
(ISD::CondCode)MatcherTable[MatcherIndex++]) break;
|
(ISD::CondCode)MatcherTable[MatcherIndex++]) break;
|
||||||
|
@ -91,6 +91,13 @@ void CheckTypeMatcherNode::print(raw_ostream &OS, unsigned indent) const {
|
|||||||
printNext(OS, indent);
|
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 {
|
void CheckIntegerMatcherNode::print(raw_ostream &OS, unsigned indent) const {
|
||||||
OS.indent(indent) << "CheckInteger " << Value << '\n';
|
OS.indent(indent) << "CheckInteger " << Value << '\n';
|
||||||
printNext(OS, indent);
|
printNext(OS, indent);
|
||||||
|
@ -54,6 +54,7 @@ public:
|
|||||||
CheckOpcode, // Fail if not opcode.
|
CheckOpcode, // Fail if not opcode.
|
||||||
CheckMultiOpcode, // Fail if not in opcode list.
|
CheckMultiOpcode, // Fail if not in opcode list.
|
||||||
CheckType, // Fail if not correct type.
|
CheckType, // Fail if not correct type.
|
||||||
|
CheckChildType, // Fail if child has wrong type.
|
||||||
CheckInteger, // Fail if wrong val.
|
CheckInteger, // Fail if wrong val.
|
||||||
CheckCondCode, // Fail if not condcode.
|
CheckCondCode, // Fail if not condcode.
|
||||||
CheckValueType,
|
CheckValueType,
|
||||||
@ -328,6 +329,26 @@ public:
|
|||||||
|
|
||||||
virtual void print(raw_ostream &OS, unsigned indent = 0) const;
|
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
|
/// CheckIntegerMatcherNode - This checks to see if the current node is a
|
||||||
/// ConstantSDNode with the specified integer value, if not it fails to match.
|
/// ConstantSDNode with the specified integer value, if not it fails to match.
|
||||||
|
@ -222,7 +222,12 @@ EmitMatcher(const MatcherNode *N, unsigned Indent, formatted_raw_ostream &OS) {
|
|||||||
OS << "OPC_CheckType, "
|
OS << "OPC_CheckType, "
|
||||||
<< getEnumName(cast<CheckTypeMatcherNode>(N)->getType()) << ",\n";
|
<< getEnumName(cast<CheckTypeMatcherNode>(N)->getType()) << ",\n";
|
||||||
return 2;
|
return 2;
|
||||||
|
case MatcherNode::CheckChildType:
|
||||||
|
OS << "OPC_CheckChild"
|
||||||
|
<< cast<CheckChildTypeMatcherNode>(N)->getChildNo() << "Type, "
|
||||||
|
<< getEnumName(cast<CheckChildTypeMatcherNode>(N)->getType()) << ",\n";
|
||||||
|
return 2;
|
||||||
|
|
||||||
case MatcherNode::CheckInteger: {
|
case MatcherNode::CheckInteger: {
|
||||||
int64_t Val = cast<CheckIntegerMatcherNode>(N)->getValue();
|
int64_t Val = cast<CheckIntegerMatcherNode>(N)->getValue();
|
||||||
OS << "OPC_CheckInteger" << ClassifyInt(Val) << ", ";
|
OS << "OPC_CheckInteger" << ClassifyInt(Val) << ", ";
|
||||||
@ -523,6 +528,7 @@ void MatcherTableEmitter::EmitHistogram(formatted_raw_ostream &OS) {
|
|||||||
case MatcherNode::CheckOpcode: OS << "OPC_CheckOpcode"; break;
|
case MatcherNode::CheckOpcode: OS << "OPC_CheckOpcode"; break;
|
||||||
case MatcherNode::CheckMultiOpcode: OS << "OPC_CheckMultiOpcode"; break;
|
case MatcherNode::CheckMultiOpcode: OS << "OPC_CheckMultiOpcode"; break;
|
||||||
case MatcherNode::CheckType: OS << "OPC_CheckType"; break;
|
case MatcherNode::CheckType: OS << "OPC_CheckType"; break;
|
||||||
|
case MatcherNode::CheckChildType: OS << "OPC_CheckChildType"; break;
|
||||||
case MatcherNode::CheckInteger: OS << "OPC_CheckInteger"; break;
|
case MatcherNode::CheckInteger: OS << "OPC_CheckInteger"; break;
|
||||||
case MatcherNode::CheckCondCode: OS << "OPC_CheckCondCode"; break;
|
case MatcherNode::CheckCondCode: OS << "OPC_CheckCondCode"; break;
|
||||||
case MatcherNode::CheckValueType: OS << "OPC_CheckValueType"; break;
|
case MatcherNode::CheckValueType: OS << "OPC_CheckValueType"; break;
|
||||||
|
@ -26,12 +26,19 @@ static void ContractNodes(OwningPtr<MatcherNode> &Matcher) {
|
|||||||
// If we found a movechild node with a node that comes in a 'foochild' form,
|
// If we found a movechild node with a node that comes in a 'foochild' form,
|
||||||
// transform it.
|
// transform it.
|
||||||
if (MoveChildMatcherNode *MC = dyn_cast<MoveChildMatcherNode>(N)) {
|
if (MoveChildMatcherNode *MC = dyn_cast<MoveChildMatcherNode>(N)) {
|
||||||
if (RecordMatcherNode *RM = dyn_cast<RecordMatcherNode>(MC->getNext())) {
|
MatcherNode *New = 0;
|
||||||
MatcherNode *New
|
if (RecordMatcherNode *RM = dyn_cast<RecordMatcherNode>(MC->getNext()))
|
||||||
= new RecordChildMatcherNode(MC->getChildNo(), RM->getWhatFor());
|
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());
|
New->setNext(Matcher.take());
|
||||||
Matcher.reset(New);
|
Matcher.reset(New);
|
||||||
MC->setNext(RM->takeNext());
|
// Remove the old one.
|
||||||
|
MC->setNext(MC->getNext()->takeNext());
|
||||||
return ContractNodes(Matcher);
|
return ContractNodes(Matcher);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user