Skip to content

Commit 7a6dc3d

Browse files
committed
[TableGen] Remove unused ForceMode and CodeGen fields from TypeInfer. NFC
As well as the ForceMode field in PatternToMatch.
1 parent 76cc949 commit 7a6dc3d

File tree

3 files changed

+16
-28
lines changed

3 files changed

+16
-28
lines changed

llvm/utils/TableGen/CodeGenDAGPatterns.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4398,7 +4398,7 @@ void CodeGenDAGPatterns::ExpandHwModeBasedTypes() {
43984398
PatternsToMatch.emplace_back(P.getSrcRecord(), P.getPredicates(),
43994399
std::move(NewSrc), std::move(NewDst),
44004400
P.getDstRegs(), P.getAddedComplexity(),
4401-
Record::getNewUID(Records), Mode, Check);
4401+
Record::getNewUID(Records), Check);
44024402
};
44034403

44044404
for (PatternToMatch &P : Copy) {
@@ -4769,7 +4769,6 @@ void CodeGenDAGPatterns::GenerateVariants() {
47694769
Variant, PatternsToMatch[i].getDstPatternShared(),
47704770
PatternsToMatch[i].getDstRegs(),
47714771
PatternsToMatch[i].getAddedComplexity(), Record::getNewUID(Records),
4772-
PatternsToMatch[i].getForceMode(),
47734772
PatternsToMatch[i].getHwModeFeatures());
47744773
}
47754774

llvm/utils/TableGen/CodeGenDAGPatterns.h

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ struct TypeSetByHwMode : public InfoByHwMode<MachineValueTypeSet> {
256256
raw_ostream &operator<<(raw_ostream &OS, const TypeSetByHwMode &T);
257257

258258
struct TypeInfer {
259-
TypeInfer(TreePattern &T) : TP(T), ForceMode(0) {}
259+
TypeInfer(TreePattern &T) : TP(T) {}
260260

261261
bool isConcrete(const TypeSetByHwMode &VTS, bool AllowEmpty) const {
262262
return VTS.isValueTypeByHwMode(AllowEmpty);
@@ -352,8 +352,6 @@ struct TypeInfer {
352352
};
353353

354354
TreePattern &TP;
355-
unsigned ForceMode; // Mode to use when set.
356-
bool CodeGen = false; // Set during generation of matcher code.
357355
bool Validate = true; // Indicate whether to validate types.
358356

359357
private:
@@ -1079,17 +1077,16 @@ class PatternToMatch {
10791077
std::string HwModeFeatures;
10801078
int AddedComplexity; // Add to matching pattern complexity.
10811079
unsigned ID; // Unique ID for the record.
1082-
unsigned ForceMode; // Force this mode in type inference when set.
10831080

10841081
public:
10851082
PatternToMatch(Record *srcrecord, ListInit *preds, TreePatternNodePtr src,
10861083
TreePatternNodePtr dst, std::vector<Record *> dstregs,
1087-
int complexity, unsigned uid, unsigned setmode = 0,
1084+
int complexity, unsigned uid,
10881085
const Twine &hwmodefeatures = "")
10891086
: SrcRecord(srcrecord), Predicates(preds), SrcPattern(src),
10901087
DstPattern(dst), Dstregs(std::move(dstregs)),
10911088
HwModeFeatures(hwmodefeatures.str()), AddedComplexity(complexity),
1092-
ID(uid), ForceMode(setmode) {}
1089+
ID(uid) {}
10931090

10941091
Record *getSrcRecord() const { return SrcRecord; }
10951092
ListInit *getPredicates() const { return Predicates; }
@@ -1101,7 +1098,6 @@ class PatternToMatch {
11011098
StringRef getHwModeFeatures() const { return HwModeFeatures; }
11021099
int getAddedComplexity() const { return AddedComplexity; }
11031100
unsigned getID() const { return ID; }
1104-
unsigned getForceMode() const { return ForceMode; }
11051101

11061102
std::string getPredicateCheck() const;
11071103
void getPredicateRecords(SmallVectorImpl<Record *> &PredicateRecs) const;

llvm/utils/TableGen/DAGISelMatcherGen.cpp

Lines changed: 12 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -110,15 +110,13 @@ namespace {
110110
Matcher *GetMatcher() const { return TheMatcher; }
111111
private:
112112
void AddMatcher(Matcher *NewNode);
113-
void InferPossibleTypes(unsigned ForceMode);
113+
void InferPossibleTypes();
114114

115115
// Matcher Generation.
116-
void EmitMatchCode(const TreePatternNode *N, TreePatternNode *NodeNoTypes,
117-
unsigned ForceMode);
116+
void EmitMatchCode(const TreePatternNode *N, TreePatternNode *NodeNoTypes);
118117
void EmitLeafMatchCode(const TreePatternNode *N);
119118
void EmitOperatorMatchCode(const TreePatternNode *N,
120-
TreePatternNode *NodeNoTypes,
121-
unsigned ForceMode);
119+
TreePatternNode *NodeNoTypes);
122120

123121
/// If this is the first time a node with unique identifier Name has been
124122
/// seen, record it. Otherwise, emit a check to make sure this is the same
@@ -167,19 +165,17 @@ MatcherGen::MatcherGen(const PatternToMatch &pattern,
167165
PatWithNoTypes->RemoveAllTypes();
168166

169167
// If there are types that are manifestly known, infer them.
170-
InferPossibleTypes(Pattern.getForceMode());
168+
InferPossibleTypes();
171169
}
172170

173171
/// InferPossibleTypes - As we emit the pattern, we end up generating type
174172
/// checks and applying them to the 'PatWithNoTypes' tree. As we do this, we
175173
/// want to propagate implied types as far throughout the tree as possible so
176174
/// that we avoid doing redundant type checks. This does the type propagation.
177-
void MatcherGen::InferPossibleTypes(unsigned ForceMode) {
175+
void MatcherGen::InferPossibleTypes() {
178176
// TP - Get *SOME* tree pattern, we don't care which. It is only used for
179177
// diagnostics, which we know are impossible at this point.
180178
TreePattern &TP = *CGP.pf_begin()->second;
181-
TP.getInfer().CodeGen = true;
182-
TP.getInfer().ForceMode = ForceMode;
183179

184180
bool MadeChange = true;
185181
while (MadeChange)
@@ -304,8 +300,7 @@ void MatcherGen::EmitLeafMatchCode(const TreePatternNode *N) {
304300
}
305301

306302
void MatcherGen::EmitOperatorMatchCode(const TreePatternNode *N,
307-
TreePatternNode *NodeNoTypes,
308-
unsigned ForceMode) {
303+
TreePatternNode *NodeNoTypes) {
309304
assert(!N->isLeaf() && "Not an operator?");
310305

311306
if (N->getOperator()->isSubClassOf("ComplexPattern")) {
@@ -359,7 +354,7 @@ void MatcherGen::EmitOperatorMatchCode(const TreePatternNode *N,
359354

360355
// Match the LHS of the AND as appropriate.
361356
AddMatcher(new MoveChildMatcher(0));
362-
EmitMatchCode(N->getChild(0), NodeNoTypes->getChild(0), ForceMode);
357+
EmitMatchCode(N->getChild(0), NodeNoTypes->getChild(0));
363358
AddMatcher(new MoveParentMatcher());
364359
return;
365360
}
@@ -458,7 +453,7 @@ void MatcherGen::EmitOperatorMatchCode(const TreePatternNode *N,
458453
// Get the code suitable for matching this child. Move to the child, check
459454
// it then move back to the parent.
460455
AddMatcher(new MoveChildMatcher(OpNo));
461-
EmitMatchCode(N->getChild(i), NodeNoTypes->getChild(i), ForceMode);
456+
EmitMatchCode(N->getChild(i), NodeNoTypes->getChild(i));
462457
AddMatcher(new MoveParentMatcher());
463458
}
464459
}
@@ -499,8 +494,7 @@ bool MatcherGen::recordUniqueNode(ArrayRef<std::string> Names) {
499494
}
500495

501496
void MatcherGen::EmitMatchCode(const TreePatternNode *N,
502-
TreePatternNode *NodeNoTypes,
503-
unsigned ForceMode) {
497+
TreePatternNode *NodeNoTypes) {
504498
// If N and NodeNoTypes don't agree on a type, then this is a case where we
505499
// need to do a type check. Emit the check, apply the type to NodeNoTypes and
506500
// reinfer any correlated types.
@@ -509,7 +503,7 @@ void MatcherGen::EmitMatchCode(const TreePatternNode *N,
509503
for (unsigned i = 0, e = NodeNoTypes->getNumTypes(); i != e; ++i) {
510504
if (NodeNoTypes->getExtType(i) == N->getExtType(i)) continue;
511505
NodeNoTypes->setType(i, N->getExtType(i));
512-
InferPossibleTypes(ForceMode);
506+
InferPossibleTypes();
513507
ResultsToTypeCheck.push_back(i);
514508
}
515509

@@ -531,7 +525,7 @@ void MatcherGen::EmitMatchCode(const TreePatternNode *N,
531525
if (N->isLeaf())
532526
EmitLeafMatchCode(N);
533527
else
534-
EmitOperatorMatchCode(N, NodeNoTypes, ForceMode);
528+
EmitOperatorMatchCode(N, NodeNoTypes);
535529

536530
// If there are node predicates for this node, generate their checks.
537531
for (unsigned i = 0, e = N->getPredicateCalls().size(); i != e; ++i) {
@@ -573,8 +567,7 @@ bool MatcherGen::EmitMatcherCode(unsigned Variant) {
573567
}
574568

575569
// Emit the matcher for the pattern structure and types.
576-
EmitMatchCode(Pattern.getSrcPattern(), PatWithNoTypes.get(),
577-
Pattern.getForceMode());
570+
EmitMatchCode(Pattern.getSrcPattern(), PatWithNoTypes.get());
578571

579572
// If the pattern has a predicate on it (e.g. only enabled when a subtarget
580573
// feature is around, do the check).

0 commit comments

Comments
 (0)