Skip to content

[SelectionDAG] Add instantiated OPC_CheckChildType #73297

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 1 commit into from
Dec 12, 2023
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
19 changes: 19 additions & 0 deletions llvm/include/llvm/CodeGen/SelectionDAGISel.h
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,25 @@ class SelectionDAGISel : public MachineFunctionPass {
OPC_CheckChild5Type,
OPC_CheckChild6Type,
OPC_CheckChild7Type,

OPC_CheckChild0TypeI32,
OPC_CheckChild1TypeI32,
OPC_CheckChild2TypeI32,
OPC_CheckChild3TypeI32,
OPC_CheckChild4TypeI32,
OPC_CheckChild5TypeI32,
OPC_CheckChild6TypeI32,
OPC_CheckChild7TypeI32,

OPC_CheckChild0TypeI64,
OPC_CheckChild1TypeI64,
OPC_CheckChild2TypeI64,
OPC_CheckChild3TypeI64,
OPC_CheckChild4TypeI64,
OPC_CheckChild5TypeI64,
OPC_CheckChild6TypeI64,
OPC_CheckChild7TypeI64,

OPC_CheckInteger,
OPC_CheckChild0Integer,
OPC_CheckChild1Integer,
Expand Down
85 changes: 73 additions & 12 deletions llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2885,11 +2885,39 @@ static unsigned IsPredicateKnownToFail(const unsigned char *Table,
case SelectionDAGISel::OPC_CheckChild4Type:
case SelectionDAGISel::OPC_CheckChild5Type:
case SelectionDAGISel::OPC_CheckChild6Type:
case SelectionDAGISel::OPC_CheckChild7Type: {
Result =
!::CheckChildType(static_cast<MVT::SimpleValueType>(Table[Index++]), N,
SDISel.TLI, SDISel.CurDAG->getDataLayout(),
Opcode - SelectionDAGISel::OPC_CheckChild0Type);
case SelectionDAGISel::OPC_CheckChild7Type:
case SelectionDAGISel::OPC_CheckChild0TypeI32:
case SelectionDAGISel::OPC_CheckChild1TypeI32:
case SelectionDAGISel::OPC_CheckChild2TypeI32:
case SelectionDAGISel::OPC_CheckChild3TypeI32:
case SelectionDAGISel::OPC_CheckChild4TypeI32:
case SelectionDAGISel::OPC_CheckChild5TypeI32:
case SelectionDAGISel::OPC_CheckChild6TypeI32:
case SelectionDAGISel::OPC_CheckChild7TypeI32:
case SelectionDAGISel::OPC_CheckChild0TypeI64:
case SelectionDAGISel::OPC_CheckChild1TypeI64:
case SelectionDAGISel::OPC_CheckChild2TypeI64:
case SelectionDAGISel::OPC_CheckChild3TypeI64:
case SelectionDAGISel::OPC_CheckChild4TypeI64:
case SelectionDAGISel::OPC_CheckChild5TypeI64:
case SelectionDAGISel::OPC_CheckChild6TypeI64:
case SelectionDAGISel::OPC_CheckChild7TypeI64: {
MVT::SimpleValueType VT;
unsigned ChildNo;
if (Opcode >= SelectionDAGISel::OPC_CheckChild0TypeI32 &&
Opcode <= SelectionDAGISel::OPC_CheckChild7TypeI32) {
VT = MVT::i32;
ChildNo = Opcode - SelectionDAGISel::OPC_CheckChild0TypeI32;
} else if (Opcode >= SelectionDAGISel::OPC_CheckChild0TypeI64 &&
Opcode <= SelectionDAGISel::OPC_CheckChild7TypeI64) {
VT = MVT::i64;
ChildNo = Opcode - SelectionDAGISel::OPC_CheckChild0TypeI64;
} else {
VT = static_cast<MVT::SimpleValueType>(Table[Index++]);
ChildNo = Opcode - SelectionDAGISel::OPC_CheckChild0Type;
}
Result = !::CheckChildType(VT, N, SDISel.TLI,
SDISel.CurDAG->getDataLayout(), ChildNo);
return Index;
}
case SelectionDAGISel::OPC_CheckCondCode:
Expand Down Expand Up @@ -3412,15 +3440,48 @@ void SelectionDAGISel::SelectCodeCommon(SDNode *NodeToMatch,
<< '\n');
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:
if (!::CheckChildType(
static_cast<MVT::SimpleValueType>(MatcherTable[MatcherIndex++]),
N, TLI, CurDAG->getDataLayout(), Opcode - OPC_CheckChild0Type))
case OPC_CheckChild0Type:
case OPC_CheckChild1Type:
case OPC_CheckChild2Type:
case OPC_CheckChild3Type:
case OPC_CheckChild4Type:
case OPC_CheckChild5Type:
case OPC_CheckChild6Type:
case OPC_CheckChild7Type:
case OPC_CheckChild0TypeI32:
case OPC_CheckChild1TypeI32:
case OPC_CheckChild2TypeI32:
case OPC_CheckChild3TypeI32:
case OPC_CheckChild4TypeI32:
case OPC_CheckChild5TypeI32:
case OPC_CheckChild6TypeI32:
case OPC_CheckChild7TypeI32:
case OPC_CheckChild0TypeI64:
case OPC_CheckChild1TypeI64:
case OPC_CheckChild2TypeI64:
case OPC_CheckChild3TypeI64:
case OPC_CheckChild4TypeI64:
case OPC_CheckChild5TypeI64:
case OPC_CheckChild6TypeI64:
case OPC_CheckChild7TypeI64: {
MVT::SimpleValueType VT;
unsigned ChildNo;
if (Opcode >= SelectionDAGISel::OPC_CheckChild0TypeI32 &&
Opcode <= SelectionDAGISel::OPC_CheckChild7TypeI32) {
VT = MVT::i32;
ChildNo = Opcode - SelectionDAGISel::OPC_CheckChild0TypeI32;
} else if (Opcode >= SelectionDAGISel::OPC_CheckChild0TypeI64 &&
Opcode <= SelectionDAGISel::OPC_CheckChild7TypeI64) {
VT = MVT::i64;
ChildNo = Opcode - SelectionDAGISel::OPC_CheckChild0TypeI64;
} else {
VT = static_cast<MVT::SimpleValueType>(MatcherTable[MatcherIndex++]);
ChildNo = Opcode - SelectionDAGISel::OPC_CheckChild0Type;
}
if (!::CheckChildType(VT, N, TLI, CurDAG->getDataLayout(), ChildNo))
break;
continue;
}
case OPC_CheckCondCode:
if (!::CheckCondCode(MatcherTable, MatcherIndex, N)) break;
continue;
Expand Down
19 changes: 14 additions & 5 deletions llvm/utils/TableGen/DAGISelMatcherEmitter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -593,11 +593,20 @@ EmitMatcher(const Matcher *N, const unsigned Indent, unsigned CurrentIdx,
<< ", " << getEnumName(cast<CheckTypeMatcher>(N)->getType()) << ",\n";
return 3;

case Matcher::CheckChildType:
OS << "OPC_CheckChild"
<< cast<CheckChildTypeMatcher>(N)->getChildNo() << "Type, "
<< getEnumName(cast<CheckChildTypeMatcher>(N)->getType()) << ",\n";
return 2;
case Matcher::CheckChildType: {
MVT::SimpleValueType VT = cast<CheckChildTypeMatcher>(N)->getType();
switch (VT) {
case MVT::i32:
case MVT::i64:
OS << "OPC_CheckChild" << cast<CheckChildTypeMatcher>(N)->getChildNo()
<< "TypeI" << MVT(VT).getScalarSizeInBits() << ",\n";
return 1;
default:
OS << "OPC_CheckChild" << cast<CheckChildTypeMatcher>(N)->getChildNo()
<< "Type, " << getEnumName(VT) << ",\n";
return 2;
}
}

case Matcher::CheckInteger: {
OS << "OPC_CheckInteger, ";
Expand Down