From 4b9371c2519f1608f3c13be1f0e3a35c7d134359 Mon Sep 17 00:00:00 2001 From: Craig Topper Date: Wed, 22 Nov 2017 07:11:01 +0000 Subject: [PATCH] [SelectionDAG] Add a isel matcher op to check the type of node results 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 --- include/llvm/CodeGen/SelectionDAGISel.h | 1 + lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp | 14 ++++++++++++++ utils/TableGen/DAGISelMatcherEmitter.cpp | 13 ++++++++----- 3 files changed, 23 insertions(+), 5 deletions(-) diff --git a/include/llvm/CodeGen/SelectionDAGISel.h b/include/llvm/CodeGen/SelectionDAGISel.h index bc14e052c732e..053ebaa1ddaf2 100644 --- a/include/llvm/CodeGen/SelectionDAGISel.h +++ b/include/llvm/CodeGen/SelectionDAGISel.h @@ -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, diff --git a/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp b/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp index d74bca1b9c136..cb37137d547f5 100644 --- a/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp +++ b/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp @@ -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: @@ -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; diff --git a/utils/TableGen/DAGISelMatcherEmitter.cpp b/utils/TableGen/DAGISelMatcherEmitter.cpp index edfc5a19b8204..e64943c1d0257 100644 --- a/utils/TableGen/DAGISelMatcherEmitter.cpp +++ b/utils/TableGen/DAGISelMatcherEmitter.cpp @@ -497,11 +497,14 @@ EmitMatcher(const Matcher *N, unsigned Indent, unsigned CurrentIdx, } case Matcher::CheckType: - assert(cast(N)->getResNo() == 0 && - "FIXME: Add support for CheckType of resno != 0"); - OS << "OPC_CheckType, " - << getEnumName(cast(N)->getType()) << ",\n"; - return 2; + if (cast(N)->getResNo() == 0) { + OS << "OPC_CheckType, " + << getEnumName(cast(N)->getType()) << ",\n"; + return 2; + } + OS << "OPC_CheckTypeRes, " << cast(N)->getResNo() + << ", " << getEnumName(cast(N)->getType()) << ",\n"; + return 3; case Matcher::CheckChildType: OS << "OPC_CheckChild"