-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[TableGen][SelectionDAG] Make CheckValueTypeMatcher use MVT::SimpleValueType #99537
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@llvm/pr-subscribers-llvm-selectiondag Author: Brandon Wu (4vtomat) ChangesThe original Full diff: https://github.com/llvm/llvm-project/pull/99537.diff 4 Files Affected:
diff --git a/llvm/utils/TableGen/Common/DAGISelMatcher.cpp b/llvm/utils/TableGen/Common/DAGISelMatcher.cpp
index 3298965ab41d7..71bbeaaba9a91 100644
--- a/llvm/utils/TableGen/Common/DAGISelMatcher.cpp
+++ b/llvm/utils/TableGen/Common/DAGISelMatcher.cpp
@@ -218,7 +218,7 @@ void CheckChild2CondCodeMatcher::printImpl(raw_ostream &OS,
}
void CheckValueTypeMatcher::printImpl(raw_ostream &OS, unsigned indent) const {
- OS.indent(indent) << "CheckValueType MVT::" << TypeName << '\n';
+ OS.indent(indent) << "CheckValueType " << getEnumName(VT) << '\n';
}
void CheckComplexPatMatcher::printImpl(raw_ostream &OS, unsigned indent) const {
@@ -409,7 +409,7 @@ bool CheckChildIntegerMatcher::isContradictoryImpl(const Matcher *M) const {
bool CheckValueTypeMatcher::isContradictoryImpl(const Matcher *M) const {
if (const CheckValueTypeMatcher *CVT = dyn_cast<CheckValueTypeMatcher>(M))
- return CVT->getTypeName() != getTypeName();
+ return CVT->getVT() != getVT();
return false;
}
diff --git a/llvm/utils/TableGen/Common/DAGISelMatcher.h b/llvm/utils/TableGen/Common/DAGISelMatcher.h
index d4fe513e2e967..1d78b93310f1c 100644
--- a/llvm/utils/TableGen/Common/DAGISelMatcher.h
+++ b/llvm/utils/TableGen/Common/DAGISelMatcher.h
@@ -684,13 +684,13 @@ class CheckChild2CondCodeMatcher : public Matcher {
/// CheckValueTypeMatcher - This checks to see if the current node is a
/// VTSDNode with the specified type, if not it fails to match.
class CheckValueTypeMatcher : public Matcher {
- StringRef TypeName;
+ MVT::SimpleValueType VT;
public:
- CheckValueTypeMatcher(StringRef type_name)
- : Matcher(CheckValueType), TypeName(type_name) {}
+ CheckValueTypeMatcher(MVT::SimpleValueType SimpleVT)
+ : Matcher(CheckValueType), VT(SimpleVT) {}
- StringRef getTypeName() const { return TypeName; }
+ MVT::SimpleValueType getVT() const { return VT; }
static bool classof(const Matcher *N) {
return N->getKind() == CheckValueType;
@@ -699,7 +699,7 @@ class CheckValueTypeMatcher : public Matcher {
private:
void printImpl(raw_ostream &OS, unsigned indent) const override;
bool isEqualImpl(const Matcher *M) const override {
- return cast<CheckValueTypeMatcher>(M)->TypeName == TypeName;
+ return cast<CheckValueTypeMatcher>(M)->VT == VT;
}
bool isContradictoryImpl(const Matcher *M) const override;
};
diff --git a/llvm/utils/TableGen/DAGISelMatcherEmitter.cpp b/llvm/utils/TableGen/DAGISelMatcherEmitter.cpp
index ff508d6487333..229245ff40504 100644
--- a/llvm/utils/TableGen/DAGISelMatcherEmitter.cpp
+++ b/llvm/utils/TableGen/DAGISelMatcherEmitter.cpp
@@ -697,8 +697,8 @@ unsigned MatcherTableEmitter::EmitMatcher(const Matcher *N,
return 2;
case Matcher::CheckValueType:
- OS << "OPC_CheckValueType, MVT::"
- << cast<CheckValueTypeMatcher>(N)->getTypeName() << ",\n";
+ OS << "OPC_CheckValueType, "
+ << getEnumName(cast<CheckValueTypeMatcher>(N)->getVT()) << ",\n";
return 2;
case Matcher::CheckComplexPat: {
diff --git a/llvm/utils/TableGen/DAGISelMatcherGen.cpp b/llvm/utils/TableGen/DAGISelMatcherGen.cpp
index 99babdf07316f..6c0b788ead907 100644
--- a/llvm/utils/TableGen/DAGISelMatcherGen.cpp
+++ b/llvm/utils/TableGen/DAGISelMatcherGen.cpp
@@ -235,7 +235,8 @@ void MatcherGen::EmitLeafMatchCode(const TreePatternNode &N) {
if (N.hasName())
return;
// An unnamed ValueType as in (sext_inreg GPR:$foo, i8).
- return AddMatcher(new CheckValueTypeMatcher(LeafRec->getName()));
+ return AddMatcher(new CheckValueTypeMatcher(
+ static_cast<MVT::SimpleValueType>(LeafRec->getValueAsInt("Value"))));
}
if ( // Handle register references. Nothing to do here, they always match.
|
…lueType The original `CheckValueTypeMatcher` stores StringRef as the member variable type, however it's more efficient to use MVT::SimpleValueType since it prevents string comparison in isEqualImpl, it also reduce the memory consumption in each object.
33925ca
to
12978b5
Compare
Update commit message. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
…lueType (#99537) Summary: The original `CheckValueTypeMatcher` stores StringRef as the member variable type, however it's more efficient to use use MVT::SimpleValueType since it prevents string comparison in isEqualImpl, it also reduce the memory consumption in each object. Test Plan: Reviewers: Subscribers: Tasks: Tags: Differential Revision: https://phabricator.intern.facebook.com/D60251332
The original
CheckValueTypeMatcher
stores StringRef as the member variable type, however it's more efficient to use use MVT::SimpleValueType since it prevents string comparison in isEqualImpl, it also reduce the memory consumption in each object.