Skip to content

Commit

Permalink
[TableGen] Remove unused ForceMode and CodeGen fields from TypeInfer.…
Browse files Browse the repository at this point in the history
… NFC

As well as the ForceMode field in PatternToMatch.
  • Loading branch information
topperc committed Apr 24, 2023
1 parent 76cc949 commit 7a6dc3d
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 28 deletions.
3 changes: 1 addition & 2 deletions llvm/utils/TableGen/CodeGenDAGPatterns.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4398,7 +4398,7 @@ void CodeGenDAGPatterns::ExpandHwModeBasedTypes() {
PatternsToMatch.emplace_back(P.getSrcRecord(), P.getPredicates(),
std::move(NewSrc), std::move(NewDst),
P.getDstRegs(), P.getAddedComplexity(),
Record::getNewUID(Records), Mode, Check);
Record::getNewUID(Records), Check);
};

for (PatternToMatch &P : Copy) {
Expand Down Expand Up @@ -4769,7 +4769,6 @@ void CodeGenDAGPatterns::GenerateVariants() {
Variant, PatternsToMatch[i].getDstPatternShared(),
PatternsToMatch[i].getDstRegs(),
PatternsToMatch[i].getAddedComplexity(), Record::getNewUID(Records),
PatternsToMatch[i].getForceMode(),
PatternsToMatch[i].getHwModeFeatures());
}

Expand Down
10 changes: 3 additions & 7 deletions llvm/utils/TableGen/CodeGenDAGPatterns.h
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ struct TypeSetByHwMode : public InfoByHwMode<MachineValueTypeSet> {
raw_ostream &operator<<(raw_ostream &OS, const TypeSetByHwMode &T);

struct TypeInfer {
TypeInfer(TreePattern &T) : TP(T), ForceMode(0) {}
TypeInfer(TreePattern &T) : TP(T) {}

bool isConcrete(const TypeSetByHwMode &VTS, bool AllowEmpty) const {
return VTS.isValueTypeByHwMode(AllowEmpty);
Expand Down Expand Up @@ -352,8 +352,6 @@ struct TypeInfer {
};

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

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

public:
PatternToMatch(Record *srcrecord, ListInit *preds, TreePatternNodePtr src,
TreePatternNodePtr dst, std::vector<Record *> dstregs,
int complexity, unsigned uid, unsigned setmode = 0,
int complexity, unsigned uid,
const Twine &hwmodefeatures = "")
: SrcRecord(srcrecord), Predicates(preds), SrcPattern(src),
DstPattern(dst), Dstregs(std::move(dstregs)),
HwModeFeatures(hwmodefeatures.str()), AddedComplexity(complexity),
ID(uid), ForceMode(setmode) {}
ID(uid) {}

Record *getSrcRecord() const { return SrcRecord; }
ListInit *getPredicates() const { return Predicates; }
Expand All @@ -1101,7 +1098,6 @@ class PatternToMatch {
StringRef getHwModeFeatures() const { return HwModeFeatures; }
int getAddedComplexity() const { return AddedComplexity; }
unsigned getID() const { return ID; }
unsigned getForceMode() const { return ForceMode; }

std::string getPredicateCheck() const;
void getPredicateRecords(SmallVectorImpl<Record *> &PredicateRecs) const;
Expand Down
31 changes: 12 additions & 19 deletions llvm/utils/TableGen/DAGISelMatcherGen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,15 +110,13 @@ namespace {
Matcher *GetMatcher() const { return TheMatcher; }
private:
void AddMatcher(Matcher *NewNode);
void InferPossibleTypes(unsigned ForceMode);
void InferPossibleTypes();

// Matcher Generation.
void EmitMatchCode(const TreePatternNode *N, TreePatternNode *NodeNoTypes,
unsigned ForceMode);
void EmitMatchCode(const TreePatternNode *N, TreePatternNode *NodeNoTypes);
void EmitLeafMatchCode(const TreePatternNode *N);
void EmitOperatorMatchCode(const TreePatternNode *N,
TreePatternNode *NodeNoTypes,
unsigned ForceMode);
TreePatternNode *NodeNoTypes);

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

// If there are types that are manifestly known, infer them.
InferPossibleTypes(Pattern.getForceMode());
InferPossibleTypes();
}

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

bool MadeChange = true;
while (MadeChange)
Expand Down Expand Up @@ -304,8 +300,7 @@ void MatcherGen::EmitLeafMatchCode(const TreePatternNode *N) {
}

void MatcherGen::EmitOperatorMatchCode(const TreePatternNode *N,
TreePatternNode *NodeNoTypes,
unsigned ForceMode) {
TreePatternNode *NodeNoTypes) {
assert(!N->isLeaf() && "Not an operator?");

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

// Match the LHS of the AND as appropriate.
AddMatcher(new MoveChildMatcher(0));
EmitMatchCode(N->getChild(0), NodeNoTypes->getChild(0), ForceMode);
EmitMatchCode(N->getChild(0), NodeNoTypes->getChild(0));
AddMatcher(new MoveParentMatcher());
return;
}
Expand Down Expand Up @@ -458,7 +453,7 @@ void MatcherGen::EmitOperatorMatchCode(const TreePatternNode *N,
// Get the code suitable for matching this child. Move to the child, check
// it then move back to the parent.
AddMatcher(new MoveChildMatcher(OpNo));
EmitMatchCode(N->getChild(i), NodeNoTypes->getChild(i), ForceMode);
EmitMatchCode(N->getChild(i), NodeNoTypes->getChild(i));
AddMatcher(new MoveParentMatcher());
}
}
Expand Down Expand Up @@ -499,8 +494,7 @@ bool MatcherGen::recordUniqueNode(ArrayRef<std::string> Names) {
}

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

Expand All @@ -531,7 +525,7 @@ void MatcherGen::EmitMatchCode(const TreePatternNode *N,
if (N->isLeaf())
EmitLeafMatchCode(N);
else
EmitOperatorMatchCode(N, NodeNoTypes, ForceMode);
EmitOperatorMatchCode(N, NodeNoTypes);

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

// Emit the matcher for the pattern structure and types.
EmitMatchCode(Pattern.getSrcPattern(), PatWithNoTypes.get(),
Pattern.getForceMode());
EmitMatchCode(Pattern.getSrcPattern(), PatWithNoTypes.get());

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

0 comments on commit 7a6dc3d

Please sign in to comment.