Skip to content

[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

Merged
merged 2 commits into from
Jul 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions llvm/utils/TableGen/Common/DAGISelMatcher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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;
}

Expand Down
10 changes: 5 additions & 5 deletions llvm/utils/TableGen/Common/DAGISelMatcher.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
};
Expand Down
4 changes: 2 additions & 2 deletions llvm/utils/TableGen/DAGISelMatcherEmitter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down
2 changes: 1 addition & 1 deletion llvm/utils/TableGen/DAGISelMatcherGen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ 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(llvm::getValueType(LeafRec)));
}

if ( // Handle register references. Nothing to do here, they always match.
Expand Down
Loading