Skip to content
This repository has been archived by the owner on Apr 23, 2020. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
[SelectionDAG] Add a isel matcher op to check the type of node result…
…s other than result 0.

I plan to use this to check the type of the mask result of masked gathers in the X86 backend.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@318820 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
topperc committed Nov 22, 2017
1 parent f66b47b commit 4b9371c
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 5 deletions.
1 change: 1 addition & 0 deletions include/llvm/CodeGen/SelectionDAGISel.h
Expand Up @@ -130,6 +130,7 @@ class SelectionDAGISel : public MachineFunctionPass {
OPC_CheckOpcode,
OPC_SwitchOpcode,
OPC_CheckType,
OPC_CheckTypeRes,
OPC_SwitchType,
OPC_CheckChild0Type, OPC_CheckChild1Type, OPC_CheckChild2Type,
OPC_CheckChild3Type, OPC_CheckChild4Type, OPC_CheckChild5Type,
Expand Down
14 changes: 14 additions & 0 deletions lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
Expand Up @@ -2775,6 +2775,12 @@ static unsigned IsPredicateKnownToFail(const unsigned char *Table,
Result = !::CheckType(Table, Index, N, SDISel.TLI,
SDISel.CurDAG->getDataLayout());
return Index;
case SelectionDAGISel::OPC_CheckTypeRes: {
unsigned Res = Table[Index++];
Result = !::CheckType(Table, Index, N.getValue(Res), SDISel.TLI,
SDISel.CurDAG->getDataLayout());
return Index;
}
case SelectionDAGISel::OPC_CheckChild0Type:
case SelectionDAGISel::OPC_CheckChild1Type:
case SelectionDAGISel::OPC_CheckChild2Type:
Expand Down Expand Up @@ -3177,6 +3183,14 @@ void SelectionDAGISel::SelectCodeCommon(SDNode *NodeToMatch,
break;
continue;

case OPC_CheckTypeRes: {
unsigned Res = MatcherTable[MatcherIndex++];
if (!::CheckType(MatcherTable, MatcherIndex, N.getValue(Res), TLI,
CurDAG->getDataLayout()))
break;
continue;
}

case OPC_SwitchOpcode: {
unsigned CurNodeOpcode = N.getOpcode();
unsigned SwitchStart = MatcherIndex-1; (void)SwitchStart;
Expand Down
13 changes: 8 additions & 5 deletions utils/TableGen/DAGISelMatcherEmitter.cpp
Expand Up @@ -497,11 +497,14 @@ EmitMatcher(const Matcher *N, unsigned Indent, unsigned CurrentIdx,
}

case Matcher::CheckType:
assert(cast<CheckTypeMatcher>(N)->getResNo() == 0 &&
"FIXME: Add support for CheckType of resno != 0");
OS << "OPC_CheckType, "
<< getEnumName(cast<CheckTypeMatcher>(N)->getType()) << ",\n";
return 2;
if (cast<CheckTypeMatcher>(N)->getResNo() == 0) {
OS << "OPC_CheckType, "
<< getEnumName(cast<CheckTypeMatcher>(N)->getType()) << ",\n";
return 2;
}
OS << "OPC_CheckTypeRes, " << cast<CheckTypeMatcher>(N)->getResNo()
<< ", " << getEnumName(cast<CheckTypeMatcher>(N)->getType()) << ",\n";
return 3;

case Matcher::CheckChildType:
OS << "OPC_CheckChild"
Expand Down

0 comments on commit 4b9371c

Please sign in to comment.