[llvm] [LLVM][TableGen] Adopt `indent` for indentation (PR #109275)
via llvm-commits
llvm-commits at lists.llvm.org
Thu Sep 19 06:35:56 PDT 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-llvm-selectiondag
Author: Rahul Joshi (jurahul)
<details>
<summary>Changes</summary>
Adopt `indent` for indentation DAGISelMatcher and DecoderEmitter.
---
Patch is 42.17 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/109275.diff
4 Files Affected:
- (modified) llvm/utils/TableGen/Common/DAGISelMatcher.cpp (+87-93)
- (modified) llvm/utils/TableGen/Common/DAGISelMatcher.h (+39-39)
- (modified) llvm/utils/TableGen/DAGISelMatcherOpt.cpp (+3-2)
- (modified) llvm/utils/TableGen/DecoderEmitter.cpp (+63-66)
``````````diff
diff --git a/llvm/utils/TableGen/Common/DAGISelMatcher.cpp b/llvm/utils/TableGen/Common/DAGISelMatcher.cpp
index d38b0992cf0e42..8780c4f5b61c27 100644
--- a/llvm/utils/TableGen/Common/DAGISelMatcher.cpp
+++ b/llvm/utils/TableGen/Common/DAGISelMatcher.cpp
@@ -19,13 +19,13 @@ void Matcher::anchor() {}
void Matcher::dump() const { print(errs()); }
-void Matcher::print(raw_ostream &OS, unsigned Indent) const {
+void Matcher::print(raw_ostream &OS, indent Indent) const {
printImpl(OS, Indent);
if (Next)
return Next->print(OS, Indent);
}
-void Matcher::printOne(raw_ostream &OS) const { printImpl(OS, 0); }
+void Matcher::printOne(raw_ostream &OS) const { printImpl(OS, indent(0)); }
/// unlinkNode - Unlink the specified node from this chain. If Other == this,
/// we unlink the next pointer and return it. Otherwise we unlink Other from
@@ -111,156 +111,150 @@ unsigned CheckPredicateMatcher::getOperandNo(unsigned i) const {
// printImpl methods.
-void ScopeMatcher::printImpl(raw_ostream &OS, unsigned Indent) const {
- OS.indent(Indent) << "Scope\n";
+void ScopeMatcher::printImpl(raw_ostream &OS, indent Indent) const {
+ OS << Indent << "Scope\n";
for (const Matcher *C : Children) {
if (!C)
- OS.indent(Indent + 1) << "NULL POINTER\n";
+ OS << Indent + 1 << "NULL POINTER\n";
else
C->print(OS, Indent + 2);
}
}
-void RecordMatcher::printImpl(raw_ostream &OS, unsigned Indent) const {
- OS.indent(Indent) << "Record\n";
+void RecordMatcher::printImpl(raw_ostream &OS, indent Indent) const {
+ OS << Indent << "Record\n";
}
-void RecordChildMatcher::printImpl(raw_ostream &OS, unsigned Indent) const {
- OS.indent(Indent) << "RecordChild: " << ChildNo << '\n';
+void RecordChildMatcher::printImpl(raw_ostream &OS, indent Indent) const {
+ OS << Indent << "RecordChild: " << ChildNo << '\n';
}
-void RecordMemRefMatcher::printImpl(raw_ostream &OS, unsigned Indent) const {
- OS.indent(Indent) << "RecordMemRef\n";
+void RecordMemRefMatcher::printImpl(raw_ostream &OS, indent Indent) const {
+ OS << Indent << "RecordMemRef\n";
}
-void CaptureGlueInputMatcher::printImpl(raw_ostream &OS,
- unsigned Indent) const {
- OS.indent(Indent) << "CaptureGlueInput\n";
+void CaptureGlueInputMatcher::printImpl(raw_ostream &OS, indent Indent) const {
+ OS << Indent << "CaptureGlueInput\n";
}
-void MoveChildMatcher::printImpl(raw_ostream &OS, unsigned Indent) const {
- OS.indent(Indent) << "MoveChild " << ChildNo << '\n';
+void MoveChildMatcher::printImpl(raw_ostream &OS, indent Indent) const {
+ OS << Indent << "MoveChild " << ChildNo << '\n';
}
-void MoveSiblingMatcher::printImpl(raw_ostream &OS, unsigned Indent) const {
- OS.indent(Indent) << "MoveSibling " << SiblingNo << '\n';
+void MoveSiblingMatcher::printImpl(raw_ostream &OS, indent Indent) const {
+ OS << Indent << "MoveSibling " << SiblingNo << '\n';
}
-void MoveParentMatcher::printImpl(raw_ostream &OS, unsigned Indent) const {
- OS.indent(Indent) << "MoveParent\n";
+void MoveParentMatcher::printImpl(raw_ostream &OS, indent Indent) const {
+ OS << Indent << "MoveParent\n";
}
-void CheckSameMatcher::printImpl(raw_ostream &OS, unsigned Indent) const {
- OS.indent(Indent) << "CheckSame " << MatchNumber << '\n';
+void CheckSameMatcher::printImpl(raw_ostream &OS, indent Indent) const {
+ OS << Indent << "CheckSame " << MatchNumber << '\n';
}
-void CheckChildSameMatcher::printImpl(raw_ostream &OS, unsigned Indent) const {
- OS.indent(Indent) << "CheckChild" << ChildNo << "Same\n";
+void CheckChildSameMatcher::printImpl(raw_ostream &OS, indent Indent) const {
+ OS << Indent << "CheckChild" << ChildNo << "Same\n";
}
void CheckPatternPredicateMatcher::printImpl(raw_ostream &OS,
- unsigned Indent) const {
- OS.indent(Indent) << "CheckPatternPredicate " << Predicate << '\n';
+ indent Indent) const {
+ OS << Indent << "CheckPatternPredicate " << Predicate << '\n';
}
-void CheckPredicateMatcher::printImpl(raw_ostream &OS, unsigned Indent) const {
- OS.indent(Indent) << "CheckPredicate " << getPredicate().getFnName() << '\n';
+void CheckPredicateMatcher::printImpl(raw_ostream &OS, indent Indent) const {
+ OS << Indent << "CheckPredicate " << getPredicate().getFnName() << '\n';
}
-void CheckOpcodeMatcher::printImpl(raw_ostream &OS, unsigned Indent) const {
- OS.indent(Indent) << "CheckOpcode " << Opcode.getEnumName() << '\n';
+void CheckOpcodeMatcher::printImpl(raw_ostream &OS, indent Indent) const {
+ OS << Indent << "CheckOpcode " << Opcode.getEnumName() << '\n';
}
-void SwitchOpcodeMatcher::printImpl(raw_ostream &OS, unsigned Indent) const {
- OS.indent(Indent) << "SwitchOpcode: {\n";
+void SwitchOpcodeMatcher::printImpl(raw_ostream &OS, indent Indent) const {
+ OS << Indent << "SwitchOpcode: {\n";
for (const auto &C : Cases) {
- OS.indent(Indent) << "case " << C.first->getEnumName() << ":\n";
+ OS << Indent << "case " << C.first->getEnumName() << ":\n";
C.second->print(OS, Indent + 2);
}
- OS.indent(Indent) << "}\n";
+ OS << Indent << "}\n";
}
-void CheckTypeMatcher::printImpl(raw_ostream &OS, unsigned Indent) const {
- OS.indent(Indent) << "CheckType " << getEnumName(Type) << ", ResNo=" << ResNo
- << '\n';
+void CheckTypeMatcher::printImpl(raw_ostream &OS, indent Indent) const {
+ OS << Indent << "CheckType " << getEnumName(Type) << ", ResNo=" << ResNo
+ << '\n';
}
-void SwitchTypeMatcher::printImpl(raw_ostream &OS, unsigned Indent) const {
- OS.indent(Indent) << "SwitchType: {\n";
+void SwitchTypeMatcher::printImpl(raw_ostream &OS, indent Indent) const {
+ OS << Indent << "SwitchType: {\n";
for (const auto &C : Cases) {
- OS.indent(Indent) << "case " << getEnumName(C.first) << ":\n";
+ OS << Indent << "case " << getEnumName(C.first) << ":\n";
C.second->print(OS, Indent + 2);
}
- OS.indent(Indent) << "}\n";
+ OS << Indent << "}\n";
}
-void CheckChildTypeMatcher::printImpl(raw_ostream &OS, unsigned Indent) const {
- OS.indent(Indent) << "CheckChildType " << ChildNo << " " << getEnumName(Type)
- << '\n';
+void CheckChildTypeMatcher::printImpl(raw_ostream &OS, indent Indent) const {
+ OS << Indent << "CheckChildType " << ChildNo << " " << getEnumName(Type)
+ << '\n';
}
-void CheckIntegerMatcher::printImpl(raw_ostream &OS, unsigned Indent) const {
- OS.indent(Indent) << "CheckInteger " << Value << '\n';
+void CheckIntegerMatcher::printImpl(raw_ostream &OS, indent Indent) const {
+ OS << Indent << "CheckInteger " << Value << '\n';
}
-void CheckChildIntegerMatcher::printImpl(raw_ostream &OS,
- unsigned Indent) const {
- OS.indent(Indent) << "CheckChildInteger " << ChildNo << " " << Value << '\n';
+void CheckChildIntegerMatcher::printImpl(raw_ostream &OS, indent Indent) const {
+ OS << Indent << "CheckChildInteger " << ChildNo << " " << Value << '\n';
}
-void CheckCondCodeMatcher::printImpl(raw_ostream &OS, unsigned Indent) const {
- OS.indent(Indent) << "CheckCondCode ISD::" << CondCodeName << '\n';
+void CheckCondCodeMatcher::printImpl(raw_ostream &OS, indent Indent) const {
+ OS << Indent << "CheckCondCode ISD::" << CondCodeName << '\n';
}
void CheckChild2CondCodeMatcher::printImpl(raw_ostream &OS,
- unsigned Indent) const {
- OS.indent(Indent) << "CheckChild2CondCode ISD::" << CondCodeName << '\n';
+ indent Indent) const {
+ OS << Indent << "CheckChild2CondCode ISD::" << CondCodeName << '\n';
}
-void CheckValueTypeMatcher::printImpl(raw_ostream &OS, unsigned Indent) const {
- OS.indent(Indent) << "CheckValueType " << getEnumName(VT) << '\n';
+void CheckValueTypeMatcher::printImpl(raw_ostream &OS, indent Indent) const {
+ OS << Indent << "CheckValueType " << getEnumName(VT) << '\n';
}
-void CheckComplexPatMatcher::printImpl(raw_ostream &OS, unsigned Indent) const {
- OS.indent(Indent) << "CheckComplexPat " << Pattern.getSelectFunc() << '\n';
+void CheckComplexPatMatcher::printImpl(raw_ostream &OS, indent Indent) const {
+ OS << Indent << "CheckComplexPat " << Pattern.getSelectFunc() << '\n';
}
-void CheckAndImmMatcher::printImpl(raw_ostream &OS, unsigned Indent) const {
- OS.indent(Indent) << "CheckAndImm " << Value << '\n';
+void CheckAndImmMatcher::printImpl(raw_ostream &OS, indent Indent) const {
+ OS << Indent << "CheckAndImm " << Value << '\n';
}
-void CheckOrImmMatcher::printImpl(raw_ostream &OS, unsigned Indent) const {
- OS.indent(Indent) << "CheckOrImm " << Value << '\n';
+void CheckOrImmMatcher::printImpl(raw_ostream &OS, indent Indent) const {
+ OS << Indent << "CheckOrImm " << Value << '\n';
}
void CheckFoldableChainNodeMatcher::printImpl(raw_ostream &OS,
- unsigned Indent) const {
- OS.indent(Indent) << "CheckFoldableChainNode\n";
+ indent Indent) const {
+ OS << Indent << "CheckFoldableChainNode\n";
}
-void CheckImmAllOnesVMatcher::printImpl(raw_ostream &OS,
- unsigned Indent) const {
- OS.indent(Indent) << "CheckAllOnesV\n";
+void CheckImmAllOnesVMatcher::printImpl(raw_ostream &OS, indent Indent) const {
+ OS << Indent << "CheckAllOnesV\n";
}
-void CheckImmAllZerosVMatcher::printImpl(raw_ostream &OS,
- unsigned Indent) const {
- OS.indent(Indent) << "CheckAllZerosV\n";
+void CheckImmAllZerosVMatcher::printImpl(raw_ostream &OS, indent Indent) const {
+ OS << Indent << "CheckAllZerosV\n";
}
-void EmitIntegerMatcher::printImpl(raw_ostream &OS, unsigned Indent) const {
- OS.indent(Indent) << "EmitInteger " << Val << " VT=" << getEnumName(VT)
- << '\n';
+void EmitIntegerMatcher::printImpl(raw_ostream &OS, indent Indent) const {
+ OS << Indent << "EmitInteger " << Val << " VT=" << getEnumName(VT) << '\n';
}
-void EmitStringIntegerMatcher::printImpl(raw_ostream &OS,
- unsigned Indent) const {
- OS.indent(Indent) << "EmitStringInteger " << Val << " VT=" << getEnumName(VT)
- << '\n';
+void EmitStringIntegerMatcher::printImpl(raw_ostream &OS, indent Indent) const {
+ OS << Indent << "EmitStringInteger " << Val << " VT=" << getEnumName(VT)
+ << '\n';
}
-void EmitRegisterMatcher::printImpl(raw_ostream &OS, unsigned Indent) const {
- OS.indent(Indent) << "EmitRegister ";
+void EmitRegisterMatcher::printImpl(raw_ostream &OS, indent Indent) const {
+ OS << Indent << "EmitRegister ";
if (Reg)
OS << Reg->getName();
else
@@ -269,26 +263,26 @@ void EmitRegisterMatcher::printImpl(raw_ostream &OS, unsigned Indent) const {
}
void EmitConvertToTargetMatcher::printImpl(raw_ostream &OS,
- unsigned Indent) const {
- OS.indent(Indent) << "EmitConvertToTarget " << Slot << '\n';
+ indent Indent) const {
+ OS << Indent << "EmitConvertToTarget " << Slot << '\n';
}
void EmitMergeInputChainsMatcher::printImpl(raw_ostream &OS,
- unsigned Indent) const {
- OS.indent(Indent) << "EmitMergeInputChains <todo: args>\n";
+ indent Indent) const {
+ OS << Indent << "EmitMergeInputChains <todo: args>\n";
}
-void EmitCopyToRegMatcher::printImpl(raw_ostream &OS, unsigned Indent) const {
- OS.indent(Indent) << "EmitCopyToReg <todo: args>\n";
+void EmitCopyToRegMatcher::printImpl(raw_ostream &OS, indent Indent) const {
+ OS << Indent << "EmitCopyToReg <todo: args>\n";
}
-void EmitNodeXFormMatcher::printImpl(raw_ostream &OS, unsigned Indent) const {
- OS.indent(Indent) << "EmitNodeXForm " << NodeXForm->getName()
- << " Slot=" << Slot << '\n';
+void EmitNodeXFormMatcher::printImpl(raw_ostream &OS, indent Indent) const {
+ OS << Indent << "EmitNodeXForm " << NodeXForm->getName() << " Slot=" << Slot
+ << '\n';
}
-void EmitNodeMatcherCommon::printImpl(raw_ostream &OS, unsigned Indent) const {
- OS.indent(Indent);
+void EmitNodeMatcherCommon::printImpl(raw_ostream &OS, indent Indent) const {
+ OS << Indent;
OS << (isa<MorphNodeToMatcher>(this) ? "MorphNodeTo: " : "EmitNode: ")
<< CGI.Namespace << "::" << CGI.TheDef->getName() << ": <todo flags> ";
@@ -300,10 +294,10 @@ void EmitNodeMatcherCommon::printImpl(raw_ostream &OS, unsigned Indent) const {
OS << ")\n";
}
-void CompleteMatchMatcher::printImpl(raw_ostream &OS, unsigned Indent) const {
- OS.indent(Indent) << "CompleteMatch <todo args>\n";
- OS.indent(Indent) << "Src = " << Pattern.getSrcPattern() << "\n";
- OS.indent(Indent) << "Dst = " << Pattern.getDstPattern() << "\n";
+void CompleteMatchMatcher::printImpl(raw_ostream &OS, indent Indent) const {
+ OS << Indent << "CompleteMatch <todo args>\n";
+ OS << Indent << "Src = " << Pattern.getSrcPattern() << "\n";
+ OS << Indent << "Dst = " << Pattern.getDstPattern() << "\n";
}
bool CheckOpcodeMatcher::isEqualImpl(const Matcher *M) const {
diff --git a/llvm/utils/TableGen/Common/DAGISelMatcher.h b/llvm/utils/TableGen/Common/DAGISelMatcher.h
index 32924afdda0342..44ca704a2351e5 100644
--- a/llvm/utils/TableGen/Common/DAGISelMatcher.h
+++ b/llvm/utils/TableGen/Common/DAGISelMatcher.h
@@ -185,12 +185,12 @@ class Matcher {
return Other->isContradictoryImpl(this);
}
- void print(raw_ostream &OS, unsigned indent = 0) const;
+ void print(raw_ostream &OS, indent Indent = indent(0)) const;
void printOne(raw_ostream &OS) const;
void dump() const;
protected:
- virtual void printImpl(raw_ostream &OS, unsigned indent) const = 0;
+ virtual void printImpl(raw_ostream &OS, indent Indent) const = 0;
virtual bool isEqualImpl(const Matcher *M) const = 0;
virtual bool isContradictoryImpl(const Matcher *M) const { return false; }
};
@@ -234,7 +234,7 @@ class ScopeMatcher : public Matcher {
static bool classof(const Matcher *N) { return N->getKind() == Scope; }
private:
- void printImpl(raw_ostream &OS, unsigned indent) const override;
+ void printImpl(raw_ostream &OS, indent Indent) const override;
bool isEqualImpl(const Matcher *M) const override { return false; }
};
@@ -258,7 +258,7 @@ class RecordMatcher : public Matcher {
static bool classof(const Matcher *N) { return N->getKind() == RecordNode; }
private:
- void printImpl(raw_ostream &OS, unsigned indent) const override;
+ void printImpl(raw_ostream &OS, indent Indent) const override;
bool isEqualImpl(const Matcher *M) const override { return true; }
};
@@ -289,7 +289,7 @@ class RecordChildMatcher : public Matcher {
static bool classof(const Matcher *N) { return N->getKind() == RecordChild; }
private:
- void printImpl(raw_ostream &OS, unsigned indent) const override;
+ void printImpl(raw_ostream &OS, indent Indent) const override;
bool isEqualImpl(const Matcher *M) const override {
return cast<RecordChildMatcher>(M)->getChildNo() == getChildNo();
}
@@ -303,7 +303,7 @@ class RecordMemRefMatcher : public Matcher {
static bool classof(const Matcher *N) { return N->getKind() == RecordMemRef; }
private:
- void printImpl(raw_ostream &OS, unsigned indent) const override;
+ void printImpl(raw_ostream &OS, indent Indent) const override;
bool isEqualImpl(const Matcher *M) const override { return true; }
};
@@ -318,7 +318,7 @@ class CaptureGlueInputMatcher : public Matcher {
}
private:
- void printImpl(raw_ostream &OS, unsigned indent) const override;
+ void printImpl(raw_ostream &OS, indent Indent) const override;
bool isEqualImpl(const Matcher *M) const override { return true; }
};
@@ -335,7 +335,7 @@ class MoveChildMatcher : public Matcher {
static bool classof(const Matcher *N) { return N->getKind() == MoveChild; }
private:
- void printImpl(raw_ostream &OS, unsigned indent) const override;
+ void printImpl(raw_ostream &OS, indent Indent) const override;
bool isEqualImpl(const Matcher *M) const override {
return cast<MoveChildMatcher>(M)->getChildNo() == getChildNo();
}
@@ -355,7 +355,7 @@ class MoveSiblingMatcher : public Matcher {
static bool classof(const Matcher *N) { return N->getKind() == MoveSibling; }
private:
- void printImpl(raw_ostream &OS, unsigned Indent) const override;
+ void printImpl(raw_ostream &OS, indent Indent) const override;
bool isEqualImpl(const Matcher *M) const override {
return cast<MoveSiblingMatcher>(M)->getSiblingNo() == getSiblingNo();
}
@@ -370,7 +370,7 @@ class MoveParentMatcher : public Matcher {
static bool classof(const Matcher *N) { return N->getKind() == MoveParent; }
private:
- void printImpl(raw_ostream &OS, unsigned Indent) const override;
+ void printImpl(raw_ostream &OS, indent Indent) const override;
bool isEqualImpl(const Matcher *M) const override { return true; }
};
@@ -389,7 +389,7 @@ class CheckSameMatcher : public Matcher {
static bool classof(const Matcher *N) { return N->getKind() == CheckSame; }
private:
- void printImpl(raw_ostream &OS, unsigned Indent) const override;
+ void printImpl(raw_ostream &OS, indent Indent) const override;
bool isEqualImpl(const Matcher *M) const override {
return cast<CheckSameMatcher>(M)->getMatchNumber() == getMatchNumber();
}
@@ -414,7 +414,7 @@ class CheckChildSameMatcher : public Matcher {
}
private:
- void printImpl(raw_ostream &OS, unsigned Indent) const override;
+ void printImpl(raw_ostream &OS, indent Indent) const override;
bool isEqualImpl(const Matcher *M) const override {
return cast<CheckChildSameMatcher>(M)->ChildNo == ChildNo &&
cast<CheckChildSameMatcher>(M)->MatchNumber == MatchNumber;
@@ -438,7 +438,7 @@ class CheckPatternPredicateMatcher : public Matcher {
}
private:
- void printImpl(raw_ostream &OS, unsigned indent) const override;
+ void printImpl(raw_ostream &OS, indent Indent) const override;
bool isEqualImpl(const Matcher *M) const override {
return cast<CheckPatternPredicateMatcher>(M)->getPredicate() == Predicate;
}
@@ -463,7 +463,7 @@ class CheckPredicateMatcher : public Matcher {
}
private:
- void printImpl(raw_ostream &OS, unsigned indent) const override;
+ void printImpl(raw_ostream &OS, indent Indent) const override;
bool isEqualImpl(const Matcher *M) const override {
return cast<CheckPredicateMatcher>(M)->Pred == Pred;
}
@@ -483,7 +483,7 @@ class CheckOpcodeMatcher : public Matcher {
static bool classof(const Matcher *N) { return N->getKind() == CheckOpcode; }
private:
- void printImpl(raw_ostream &OS, unsigned indent) const override;
+ void printImpl(raw_ostream &OS, indent Indent) const override;
bool isEqualImpl(const Matcher *M) const override;
bool isContradictoryImpl(const Matcher *M) const override;
};
@@ -510,7 +510,7 @@ class SwitchOpcodeMatcher : public Matcher {
const Matcher *getCaseMatcher(unsigned i) const { return Cases[i].second; }
private:
- void printImpl(raw_ostream &OS, unsigned indent) const override;
+ void printImpl(raw_ostream &OS, indent Indent) const override;
bool isEqualImpl(const Matcher *M) const override { return false; }
};
@@ -530,7 +530,7 @@ class CheckTypeMatcher : public Matcher {
static bool classof(const Matcher *N) { return N->getKind() == CheckType; }
private:
- void printImpl(raw_ostream &OS, unsigned indent) const override;
+ void printImpl(raw_ostream &OS, indent Indent) const override;
bool isEqualImpl(const Matcher *M) const override {
return cast<CheckTypeMatcher>(M)->Type == Type;
}
@@ -559,7 +559,7 @@ class SwitchTypeMatcher : public Matcher {
const Matcher *getCaseMatcher(unsigned i) const { return Cases[i].second; }
private:
- void printImpl(raw_ostream &OS, unsigned indent) const override;
+ void printImpl(raw_ostream &OS, indent Indent) const override;
bool isEqualImpl(const Matcher *M) const override { return false; }
};
@@ -581,7 +581,7 @@ class CheckChildTypeMatcher : public Matcher {
}
private:
- void printImpl(raw_ostream &OS, unsigned indent) const override;
+ void printImpl(raw_ostream &OS, indent Indent) const override;
bool isEqualImpl(const Matcher *M) const override {
...
[truncated]
``````````
</details>
https://github.com/llvm/llvm-project/pull/109275
More information about the llvm-commits
mailing list