[llvm] [TableGen][NFC] convert TreePatternNode pointers to references (PR #81134)

via llvm-commits llvm-commits at lists.llvm.org
Fri Feb 9 04:59:53 PST 2024


github-actions[bot] wrote:

<!--LLVM CODE FORMAT COMMENT: {clang-format}-->


:warning: C/C++ code formatter, clang-format found issues in your code. :warning:

<details>
<summary>
You can test this locally with the following command:
</summary>

``````````bash
git-clang-format --diff a8d4a024e6bea3ae71d6187f0c040b2b25e4bf69 7a611cff7a06f9d4e7c9e9d375b0a284cd67dc72 -- llvm/utils/TableGen/CodeGenDAGPatterns.cpp llvm/utils/TableGen/CodeGenDAGPatterns.h llvm/utils/TableGen/DAGISelEmitter.cpp llvm/utils/TableGen/DAGISelMatcher.cpp llvm/utils/TableGen/DAGISelMatcherEmitter.cpp llvm/utils/TableGen/DAGISelMatcherGen.cpp llvm/utils/TableGen/DAGISelMatcherOpt.cpp llvm/utils/TableGen/FastISelEmitter.cpp llvm/utils/TableGen/GlobalISelEmitter.cpp
``````````

</details>

<details>
<summary>
View the diff from clang-format here.
</summary>

``````````diff
diff --git a/llvm/utils/TableGen/CodeGenDAGPatterns.cpp b/llvm/utils/TableGen/CodeGenDAGPatterns.cpp
index 4ae987e9c3..a9046e09a6 100644
--- a/llvm/utils/TableGen/CodeGenDAGPatterns.cpp
+++ b/llvm/utils/TableGen/CodeGenDAGPatterns.cpp
@@ -1453,7 +1453,7 @@ static unsigned getPatternSize(const TreePatternNode &P,
     }
     if (Child.isLeaf()) {
       if (isa<IntInit>(Child.getLeafValue()))
-        Size += 5;  // Matches a ConstantSDNode (+3) and a specific value (+2).
+        Size += 5; // Matches a ConstantSDNode (+3) and a specific value (+2).
       else if (Child.getComplexPatternInfo(CGP))
         Size += getPatternSize(Child, CGP);
       else if (isImmAllOnesAllZerosMatch(Child))
@@ -1596,8 +1596,8 @@ static TreePatternNode &getOperandNum(unsigned OpNo, TreePatternNode &N,
   if (OpNo >= N.getNumChildren()) {
     std::string S;
     raw_string_ostream OS(S);
-    OS << "Invalid operand number in type constraint "
-           << (OpNo+NumResults) << " ";
+    OS << "Invalid operand number in type constraint " << (OpNo + NumResults)
+       << " ";
     N.print(OS);
     PrintFatalError(S);
   }
@@ -2508,7 +2508,7 @@ bool TreePatternNode::ApplyTypeConstraints(TreePattern &TP, bool NotRegisters) {
     // Apply type info to the intrinsic ID.
     MadeChange |= getChild(0).UpdateNodeType(0, MVT::iPTR, TP);
 
-    for (unsigned i = 0, e = getNumChildren()-1; i != e; ++i) {
+    for (unsigned i = 0, e = getNumChildren() - 1; i != e; ++i) {
       MadeChange |= getChild(i + 1).ApplyTypeConstraints(TP, NotRegisters);
 
       MVT::SimpleValueType OpVT =
@@ -2638,7 +2638,7 @@ bool TreePatternNode::ApplyTypeConstraints(TreePattern &TP, bool NotRegisters) {
       }
 
       TreePatternNode *Child = &getChild(ChildNo++);
-      unsigned ChildResNo = 0;  // Instructions always use res #0 of their op.
+      unsigned ChildResNo = 0; // Instructions always use res #0 of their op.
 
       // If the operand has sub-operands, they may be provided by distinct
       // child patterns, so attempt to match each sub-operand separately.
@@ -3918,7 +3918,7 @@ void CodeGenDAGPatterns::parseInstructionPattern(CodeGenInstruction &CGI,
   TreePatternNodePtr SrcPattern;
   if (Pattern->getOperator()->getName() == "set") {
     SrcPattern = Pattern->getChild(Pattern->getNumChildren() - 1).clone();
-  } else{
+  } else {
     // Not a set (store or something?)
     SrcPattern = Pattern;
   }
diff --git a/llvm/utils/TableGen/CodeGenDAGPatterns.h b/llvm/utils/TableGen/CodeGenDAGPatterns.h
index 67923defb9..823c40c922 100644
--- a/llvm/utils/TableGen/CodeGenDAGPatterns.h
+++ b/llvm/utils/TableGen/CodeGenDAGPatterns.h
@@ -1069,8 +1069,8 @@ public:
         HwModeFeatures(hwmodefeatures.str()), AddedComplexity(complexity),
         ID(uid) {}
 
-  Record          *getSrcRecord()  const { return SrcRecord; }
-  ListInit        *getPredicates() const { return Predicates; }
+  Record *getSrcRecord() const { return SrcRecord; }
+  ListInit *getPredicates() const { return Predicates; }
   TreePatternNode &getSrcPattern() const { return *SrcPattern; }
   TreePatternNodePtr getSrcPatternShared() const { return SrcPattern; }
   TreePatternNode &getDstPattern() const { return *DstPattern; }
diff --git a/llvm/utils/TableGen/DAGISelMatcherGen.cpp b/llvm/utils/TableGen/DAGISelMatcherGen.cpp
index 87c65df40d..956cb5e4a6 100644
--- a/llvm/utils/TableGen/DAGISelMatcherGen.cpp
+++ b/llvm/utils/TableGen/DAGISelMatcherGen.cpp
@@ -116,7 +116,7 @@ private:
   void EmitMatchCode(const TreePatternNode &N, TreePatternNode &NodeNoTypes);
   void EmitLeafMatchCode(const TreePatternNode &N);
   void EmitOperatorMatchCode(const TreePatternNode &N,
-                              TreePatternNode &NodeNoTypes);
+                             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
@@ -131,17 +131,17 @@ private:
     return VarMapEntry - 1;
   }
 
-    void EmitResultOperand(const TreePatternNode &N,
-                           SmallVectorImpl<unsigned> &ResultOps);
-    void EmitResultOfNamedOperand(const TreePatternNode &N,
-                                  SmallVectorImpl<unsigned> &ResultOps);
-    void EmitResultLeafAsOperand(const TreePatternNode &N,
-                                 SmallVectorImpl<unsigned> &ResultOps);
-    void EmitResultInstructionAsOperand(const TreePatternNode &N,
-                                        SmallVectorImpl<unsigned> &ResultOps);
-    void EmitResultSDNodeXFormAsOperand(const TreePatternNode &N,
-                                        SmallVectorImpl<unsigned> &ResultOps);
-    };
+  void EmitResultOperand(const TreePatternNode &N,
+                         SmallVectorImpl<unsigned> &ResultOps);
+  void EmitResultOfNamedOperand(const TreePatternNode &N,
+                                SmallVectorImpl<unsigned> &ResultOps);
+  void EmitResultLeafAsOperand(const TreePatternNode &N,
+                               SmallVectorImpl<unsigned> &ResultOps);
+  void EmitResultInstructionAsOperand(const TreePatternNode &N,
+                                      SmallVectorImpl<unsigned> &ResultOps);
+  void EmitResultSDNodeXFormAsOperand(const TreePatternNode &N,
+                                      SmallVectorImpl<unsigned> &ResultOps);
+};
 
 } // end anonymous namespace
 
@@ -511,7 +511,8 @@ void MatcherGen::EmitMatchCode(const TreePatternNode &N,
     Names.push_back(N.getName());
 
   for (const ScopedName &Name : N.getNamesAsPredicateArg()) {
-    Names.push_back(("pred:" + Twine(Name.getScope()) + ":" + Name.getIdentifier()).str());
+    Names.push_back(
+        ("pred:" + Twine(Name.getScope()) + ":" + Name.getIdentifier()).str());
   }
 
   if (!Names.empty()) {
@@ -554,9 +555,11 @@ bool MatcherGen::EmitMatcherCode(unsigned Variant) {
   // check.
   if (const ComplexPattern *CP =
           Pattern.getSrcPattern().getComplexPatternInfo(CGP)) {
-    const std::vector<Record*> &OpNodes = CP->getRootNodes();
-    assert(!OpNodes.empty() &&"Complex Pattern must specify what it can match");
-    if (Variant >= OpNodes.size()) return true;
+    const std::vector<Record *> &OpNodes = CP->getRootNodes();
+    assert(!OpNodes.empty() &&
+           "Complex Pattern must specify what it can match");
+    if (Variant >= OpNodes.size())
+      return true;
 
     AddMatcher(new CheckOpcodeMatcher(CGP.getSDNodeInfo(OpNodes[Variant])));
   } else {
@@ -672,8 +675,7 @@ void MatcherGen::EmitResultLeafAsOperand(const TreePatternNode &N,
   if (DefInit *DI = dyn_cast<DefInit>(N.getLeafValue())) {
     Record *Def = DI->getDef();
     if (Def->isSubClassOf("Register")) {
-      const CodeGenRegister *Reg =
-        CGP.getTargetInfo().getRegBank().getReg(Def);
+      const CodeGenRegister *Reg = CGP.getTargetInfo().getRegBank().getReg(Def);
       AddMatcher(new EmitRegisterMatcher(Reg, N.getSimpleType(0)));
       ResultOps.push_back(NextRecordedOperandNo++);
       return;
@@ -857,7 +859,7 @@ void MatcherGen::EmitResultInstructionAsOperand(
       // If the operand is an instruction and it produced multiple results, just
       // take the first one.
       if (!Child.isLeaf() && Child.getOperator()->isSubClassOf("Instruction"))
-        InstOps.resize(BeforeAddingNumOps+1);
+        InstOps.resize(BeforeAddingNumOps + 1);
 
       ++ChildNo;
     }

``````````

</details>


https://github.com/llvm/llvm-project/pull/81134


More information about the llvm-commits mailing list