[TableGen] ShouldIgnore Pattern bit to disable DAG pattern imports during GISel (#88382)
Added GISelShouldIgnore property to class Pattern in TargetSelectionDAG.td; it's similar to FastISelShouldIgnore. This bit can be put on a record to avoid its pattern import within GlobalISelEmitter. This allows one to avoid the record's GISel .td implementation, .inc generation, and any skipped pattern warnings from -warn-on-skipped-patterns.
This commit is contained in:
parent
933f49248b
commit
eae7554d3f
@ -1979,6 +1979,7 @@ class Pattern<dag patternToMatch, list<dag> resultInstrs> {
|
||||
list<dag> ResultInstrs = resultInstrs;
|
||||
list<Predicate> Predicates = []; // See class Instruction in Target.td.
|
||||
int AddedComplexity = 0; // See class Instruction in Target.td.
|
||||
bit GISelShouldIgnore = 0;
|
||||
}
|
||||
|
||||
// Pat - A simple (but common) form of a pattern, which produces a simple result
|
||||
|
@ -1,4 +1,6 @@
|
||||
// RUN: llvm-tblgen -warn-on-skipped-patterns -gen-global-isel -I %p/../../include %s -I %p/Common -o /dev/null 2>&1 | FileCheck %s
|
||||
// RUN: llvm-tblgen -warn-on-skipped-patterns -gen-global-isel -I %p/../../include %s -I %p/Common -o /dev/null -DIGNORE 2>&1 | FileCheck --allow-empty --check-prefix=IGNORED %s
|
||||
|
||||
include "llvm/Target/Target.td"
|
||||
include "GlobalISelEmitterCommon.td"
|
||||
|
||||
@ -23,6 +25,10 @@ def INSN : I<(outs GPR32:$dst), (ins GPR32:$src1, complex:$src2), []>;
|
||||
|
||||
//===- Bail out when we define a variable twice wrt complex suboperands. -===//
|
||||
|
||||
#ifdef IGNORE
|
||||
let GISelShouldIgnore = 1 in
|
||||
#endif
|
||||
// IGNORED-NOT: warning: Skipped pattern: Error: {{.*}}
|
||||
// CHECK: warning: Skipped pattern: Error: Complex suboperand x referenced by different operands: complex_rr:x:y and complex_rr:x:z.
|
||||
def : Pat<(add (complex_rr GPR32:$x, GPR32:$y),
|
||||
(complex_rr GPR32:$x, GPR32:$z)),
|
||||
|
@ -1,4 +1,5 @@
|
||||
// RUN: llvm-tblgen -gen-dag-isel -I %p/../../include %s 2>&1 | FileCheck %s
|
||||
// RUN: llvm-tblgen -gen-dag-isel -I %p/../../include -DIGNORE %s 2>&1 | FileCheck %s
|
||||
|
||||
include "llvm/Target/Target.td"
|
||||
|
||||
@ -29,6 +30,10 @@ def anyconvert : PatFrags<(ops node:$src),
|
||||
[(bitconvert node:$src),
|
||||
(specialconvert node:$src)]>;
|
||||
|
||||
#ifdef IGNORE
|
||||
// Ensure ShouldIgnore does not disable records in dag isel emitter
|
||||
let GISelShouldIgnore = 1 in
|
||||
#endif
|
||||
// And a rule that matches that PatFrag and turns it into i2f
|
||||
def : Pat<(f32 (anyconvert (i32 GPR:$val))), (i2f GPR:$val)>;
|
||||
|
||||
|
@ -4246,7 +4246,7 @@ static TreePatternNodePtr PromoteXForms(TreePatternNodePtr N) {
|
||||
|
||||
void CodeGenDAGPatterns::ParseOnePattern(
|
||||
Record *TheDef, TreePattern &Pattern, TreePattern &Result,
|
||||
const std::vector<Record *> &InstImpResults) {
|
||||
const std::vector<Record *> &InstImpResults, bool ShouldIgnore) {
|
||||
|
||||
// Inline pattern fragments and expand multiple alternatives.
|
||||
Pattern.InlinePatternFragments();
|
||||
@ -4332,7 +4332,7 @@ void CodeGenDAGPatterns::ParseOnePattern(
|
||||
AddPatternToMatch(&Pattern,
|
||||
PatternToMatch(TheDef, Preds, T, Temp.getOnlyTree(),
|
||||
InstImpResults, Complexity,
|
||||
TheDef->getID()));
|
||||
TheDef->getID(), ShouldIgnore));
|
||||
}
|
||||
} else {
|
||||
// Show a message about a dropped pattern with some info to make it
|
||||
@ -4378,7 +4378,8 @@ void CodeGenDAGPatterns::ParsePatterns() {
|
||||
FindPatternInputsAndOutputs(Pattern, Pattern.getTree(j), InstInputs,
|
||||
InstResults, InstImpResults);
|
||||
|
||||
ParseOnePattern(CurPattern, Pattern, Result, InstImpResults);
|
||||
ParseOnePattern(CurPattern, Pattern, Result, InstImpResults,
|
||||
CurPattern->getValueAsBit("GISelShouldIgnore"));
|
||||
}
|
||||
}
|
||||
|
||||
@ -4407,10 +4408,10 @@ void CodeGenDAGPatterns::ExpandHwModeBasedTypes() {
|
||||
return;
|
||||
}
|
||||
|
||||
PatternsToMatch.emplace_back(P.getSrcRecord(), P.getPredicates(),
|
||||
std::move(NewSrc), std::move(NewDst),
|
||||
P.getDstRegs(), P.getAddedComplexity(),
|
||||
Record::getNewUID(Records), Check);
|
||||
PatternsToMatch.emplace_back(
|
||||
P.getSrcRecord(), P.getPredicates(), std::move(NewSrc),
|
||||
std::move(NewDst), P.getDstRegs(), P.getAddedComplexity(),
|
||||
Record::getNewUID(Records), P.getGISelShouldIgnore(), Check);
|
||||
};
|
||||
|
||||
for (PatternToMatch &P : Copy) {
|
||||
@ -4781,6 +4782,7 @@ void CodeGenDAGPatterns::GenerateVariants() {
|
||||
Variant, PatternsToMatch[i].getDstPatternShared(),
|
||||
PatternsToMatch[i].getDstRegs(),
|
||||
PatternsToMatch[i].getAddedComplexity(), Record::getNewUID(Records),
|
||||
PatternsToMatch[i].getGISelShouldIgnore(),
|
||||
PatternsToMatch[i].getHwModeFeatures());
|
||||
}
|
||||
|
||||
|
@ -1057,17 +1057,19 @@ class PatternToMatch {
|
||||
TreePatternNodePtr DstPattern; // Resulting pattern.
|
||||
std::vector<Record *> Dstregs; // Physical register defs being matched.
|
||||
std::string HwModeFeatures;
|
||||
int AddedComplexity; // Add to matching pattern complexity.
|
||||
unsigned ID; // Unique ID for the record.
|
||||
int AddedComplexity; // Add to matching pattern complexity.
|
||||
bool GISelShouldIgnore; // Should GlobalISel ignore importing this pattern.
|
||||
unsigned ID; // Unique ID for the record.
|
||||
|
||||
public:
|
||||
PatternToMatch(Record *srcrecord, ListInit *preds, TreePatternNodePtr src,
|
||||
TreePatternNodePtr dst, std::vector<Record *> dstregs,
|
||||
int complexity, unsigned uid, const Twine &hwmodefeatures = "")
|
||||
int complexity, unsigned uid, bool ignore,
|
||||
const Twine &hwmodefeatures = "")
|
||||
: SrcRecord(srcrecord), Predicates(preds), SrcPattern(src),
|
||||
DstPattern(dst), Dstregs(std::move(dstregs)),
|
||||
HwModeFeatures(hwmodefeatures.str()), AddedComplexity(complexity),
|
||||
ID(uid) {}
|
||||
GISelShouldIgnore(ignore), ID(uid) {}
|
||||
|
||||
Record *getSrcRecord() const { return SrcRecord; }
|
||||
ListInit *getPredicates() const { return Predicates; }
|
||||
@ -1078,6 +1080,7 @@ public:
|
||||
const std::vector<Record *> &getDstRegs() const { return Dstregs; }
|
||||
StringRef getHwModeFeatures() const { return HwModeFeatures; }
|
||||
int getAddedComplexity() const { return AddedComplexity; }
|
||||
bool getGISelShouldIgnore() const { return GISelShouldIgnore; }
|
||||
unsigned getID() const { return ID; }
|
||||
|
||||
std::string getPredicateCheck() const;
|
||||
@ -1240,7 +1243,8 @@ private:
|
||||
|
||||
void ParseOnePattern(Record *TheDef, TreePattern &Pattern,
|
||||
TreePattern &Result,
|
||||
const std::vector<Record *> &InstImpResults);
|
||||
const std::vector<Record *> &InstImpResults,
|
||||
bool ShouldIgnore = false);
|
||||
void AddPatternToMatch(TreePattern *Pattern, PatternToMatch &&PTM);
|
||||
void FindPatternInputsAndOutputs(
|
||||
TreePattern &I, TreePatternNodePtr Pat,
|
||||
|
@ -2411,6 +2411,8 @@ void GlobalISelEmitter::run(raw_ostream &OS) {
|
||||
for (const PatternToMatch &Pat : CGP.ptms()) {
|
||||
++NumPatternTotal;
|
||||
|
||||
if (Pat.getGISelShouldIgnore())
|
||||
continue; // skip without warning
|
||||
auto MatcherOrErr = runOnPattern(Pat);
|
||||
|
||||
// The pattern analysis can fail, indicating an unsupported pattern.
|
||||
|
Loading…
x
Reference in New Issue
Block a user