Skip to content

Commit f4e7c49

Browse files
committed
[TableGen] New tblgen Instruction bit to disable DAGISel pattern imports
Added a new DAGISelShouldIgnore property to class Instruction in Target.td, similar to FastISelShouldIgnore. This allows one to avoid a record's DAGISel .td implementation and .inc generation.
1 parent 5964c94 commit f4e7c49

File tree

4 files changed

+20
-1
lines changed

4 files changed

+20
-1
lines changed

llvm/include/llvm/Target/Target.td

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -777,6 +777,10 @@ class Instruction : InstructionEncoding {
777777
/// SelectionDAG can.
778778
bit FastISelShouldIgnore = false;
779779

780+
/// Should DAGISel ignore this instruction. In cases where lowering may
781+
/// be done elsewhere or is unneeded, DAGISel may skip over them.
782+
bit DAGISelShouldIgnore = false;
783+
780784
/// HasPositionOrder: Indicate tablegen to sort the instructions by record
781785
/// ID, so that instruction that is defined earlier can be sorted earlier
782786
/// in the assembly matching table.

llvm/utils/TableGen/Common/CodeGenInstruction.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -465,6 +465,7 @@ CodeGenInstruction::CodeGenInstruction(Record *R)
465465
isConvergent = R->getValueAsBit("isConvergent");
466466
hasNoSchedulingInfo = R->getValueAsBit("hasNoSchedulingInfo");
467467
FastISelShouldIgnore = R->getValueAsBit("FastISelShouldIgnore");
468+
DAGISelShouldIgnore = R->getValueAsBit("DAGISelShouldIgnore");
468469
variadicOpsAreDefs = R->getValueAsBit("variadicOpsAreDefs");
469470
isAuthenticated = R->getValueAsBit("isAuthenticated");
470471

llvm/utils/TableGen/Common/CodeGenInstruction.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,7 @@ class CodeGenInstruction {
282282
bool isConvergent : 1;
283283
bool hasNoSchedulingInfo : 1;
284284
bool FastISelShouldIgnore : 1;
285+
bool DAGISelShouldIgnore : 1;
285286
bool hasChain : 1;
286287
bool hasChain_Inferred : 1;
287288
bool variadicOpsAreDefs : 1;

llvm/utils/TableGen/DAGISelEmitter.cpp

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,8 +165,21 @@ void DAGISelEmitter::run(raw_ostream &OS) {
165165
// Add all the patterns to a temporary list so we can sort them.
166166
Records.startTimer("Sort patterns");
167167
std::vector<const PatternToMatch *> Patterns;
168-
for (const PatternToMatch &PTM : CGP.ptms())
168+
for (const PatternToMatch &PTM : CGP.ptms()) {
169+
170+
// Disable import of patterns marked as ignore.
171+
const TreePatternNode &Dst = PTM.getDstPattern();
172+
if (!Dst.isLeaf()) {
173+
const Record *Op = Dst.getOperator();
174+
const bool shouldIgnore =
175+
Op->isSubClassOf("Instruction") &&
176+
CGP.getTargetInfo().getInstruction(Op).DAGISelShouldIgnore;
177+
if (shouldIgnore)
178+
continue;
179+
}
180+
169181
Patterns.push_back(&PTM);
182+
}
170183

171184
// We want to process the matches in order of minimal cost. Sort the patterns
172185
// so the least cost one is at the start.

0 commit comments

Comments
 (0)