[llvm] 3e24dd4 - [NFC] Rename variables to conform to LLVM coding standards (#109166)

via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 19 04:49:15 PDT 2024


Author: Rahul Joshi
Date: 2024-09-19T04:49:12-07:00
New Revision: 3e24dd42dded01a431070c3dda486eed2640b0c7

URL: https://github.com/llvm/llvm-project/commit/3e24dd42dded01a431070c3dda486eed2640b0c7
DIFF: https://github.com/llvm/llvm-project/commit/3e24dd42dded01a431070c3dda486eed2640b0c7.diff

LOG: [NFC] Rename variables to conform to LLVM coding standards (#109166)

Rename `indent` to `Indent` and `o` to `OS`.
Rename `Indentation` to `Indent`.
Remove unused argument from `emitPredicateMatch`.
Change `Indent` argument to `emitBinaryParser` to by value.

Added: 
    

Modified: 
    llvm/utils/TableGen/Common/DAGISelMatcher.cpp
    llvm/utils/TableGen/Common/DAGISelMatcher.h
    llvm/utils/TableGen/DecoderEmitter.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/utils/TableGen/Common/DAGISelMatcher.cpp b/llvm/utils/TableGen/Common/DAGISelMatcher.cpp
index d235114871b52c..d38b0992cf0e42 100644
--- a/llvm/utils/TableGen/Common/DAGISelMatcher.cpp
+++ b/llvm/utils/TableGen/Common/DAGISelMatcher.cpp
@@ -17,12 +17,12 @@ using namespace llvm;
 
 void Matcher::anchor() {}
 
-void Matcher::dump() const { print(errs(), 0); }
+void Matcher::dump() const { print(errs()); }
 
-void Matcher::print(raw_ostream &OS, unsigned indent) const {
-  printImpl(OS, indent);
+void Matcher::print(raw_ostream &OS, unsigned Indent) const {
+  printImpl(OS, Indent);
   if (Next)
-    return Next->print(OS, indent);
+    return Next->print(OS, Indent);
 }
 
 void Matcher::printOne(raw_ostream &OS) const { printImpl(OS, 0); }
@@ -111,156 +111,156 @@ 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, unsigned Indent) const {
+  OS.indent(Indent) << "Scope\n";
   for (const Matcher *C : Children) {
     if (!C)
-      OS.indent(indent + 1) << "NULL POINTER\n";
+      OS.indent(Indent + 1) << "NULL POINTER\n";
     else
-      C->print(OS, indent + 2);
+      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, unsigned Indent) const {
+  OS.indent(Indent) << "Record\n";
 }
 
-void RecordChildMatcher::printImpl(raw_ostream &OS, unsigned indent) const {
-  OS.indent(indent) << "RecordChild: " << ChildNo << '\n';
+void RecordChildMatcher::printImpl(raw_ostream &OS, unsigned Indent) const {
+  OS.indent(Indent) << "RecordChild: " << ChildNo << '\n';
 }
 
-void RecordMemRefMatcher::printImpl(raw_ostream &OS, unsigned indent) const {
-  OS.indent(indent) << "RecordMemRef\n";
+void RecordMemRefMatcher::printImpl(raw_ostream &OS, unsigned Indent) const {
+  OS.indent(Indent) << "RecordMemRef\n";
 }
 
 void CaptureGlueInputMatcher::printImpl(raw_ostream &OS,
-                                        unsigned indent) const {
-  OS.indent(indent) << "CaptureGlueInput\n";
+                                        unsigned Indent) const {
+  OS.indent(Indent) << "CaptureGlueInput\n";
 }
 
-void MoveChildMatcher::printImpl(raw_ostream &OS, unsigned indent) const {
-  OS.indent(indent) << "MoveChild " << ChildNo << '\n';
+void MoveChildMatcher::printImpl(raw_ostream &OS, unsigned Indent) const {
+  OS.indent(Indent) << "MoveChild " << ChildNo << '\n';
 }
 
 void MoveSiblingMatcher::printImpl(raw_ostream &OS, unsigned Indent) const {
   OS.indent(Indent) << "MoveSibling " << SiblingNo << '\n';
 }
 
-void MoveParentMatcher::printImpl(raw_ostream &OS, unsigned indent) const {
-  OS.indent(indent) << "MoveParent\n";
+void MoveParentMatcher::printImpl(raw_ostream &OS, unsigned Indent) const {
+  OS.indent(Indent) << "MoveParent\n";
 }
 
-void CheckSameMatcher::printImpl(raw_ostream &OS, unsigned indent) const {
-  OS.indent(indent) << "CheckSame " << MatchNumber << '\n';
+void CheckSameMatcher::printImpl(raw_ostream &OS, unsigned Indent) const {
+  OS.indent(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, unsigned Indent) const {
+  OS.indent(Indent) << "CheckChild" << ChildNo << "Same\n";
 }
 
 void CheckPatternPredicateMatcher::printImpl(raw_ostream &OS,
-                                             unsigned indent) const {
-  OS.indent(indent) << "CheckPatternPredicate " << Predicate << '\n';
+                                             unsigned Indent) const {
+  OS.indent(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, unsigned Indent) const {
+  OS.indent(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, unsigned Indent) const {
+  OS.indent(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, unsigned Indent) const {
+  OS.indent(Indent) << "SwitchOpcode: {\n";
   for (const auto &C : Cases) {
-    OS.indent(indent) << "case " << C.first->getEnumName() << ":\n";
-    C.second->print(OS, indent + 2);
+    OS.indent(Indent) << "case " << C.first->getEnumName() << ":\n";
+    C.second->print(OS, Indent + 2);
   }
-  OS.indent(indent) << "}\n";
+  OS.indent(Indent) << "}\n";
 }
 
-void CheckTypeMatcher::printImpl(raw_ostream &OS, unsigned indent) const {
-  OS.indent(indent) << "CheckType " << getEnumName(Type) << ", ResNo=" << ResNo
+void CheckTypeMatcher::printImpl(raw_ostream &OS, unsigned Indent) const {
+  OS.indent(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, unsigned Indent) const {
+  OS.indent(Indent) << "SwitchType: {\n";
   for (const auto &C : Cases) {
-    OS.indent(indent) << "case " << getEnumName(C.first) << ":\n";
-    C.second->print(OS, indent + 2);
+    OS.indent(Indent) << "case " << getEnumName(C.first) << ":\n";
+    C.second->print(OS, Indent + 2);
   }
-  OS.indent(indent) << "}\n";
+  OS.indent(Indent) << "}\n";
 }
 
-void CheckChildTypeMatcher::printImpl(raw_ostream &OS, unsigned indent) const {
-  OS.indent(indent) << "CheckChildType " << ChildNo << " " << getEnumName(Type)
+void CheckChildTypeMatcher::printImpl(raw_ostream &OS, unsigned Indent) const {
+  OS.indent(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, unsigned Indent) const {
+  OS.indent(Indent) << "CheckInteger " << Value << '\n';
 }
 
 void CheckChildIntegerMatcher::printImpl(raw_ostream &OS,
-                                         unsigned indent) const {
-  OS.indent(indent) << "CheckChildInteger " << ChildNo << " " << Value << '\n';
+                                         unsigned Indent) const {
+  OS.indent(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, unsigned Indent) const {
+  OS.indent(Indent) << "CheckCondCode ISD::" << CondCodeName << '\n';
 }
 
 void CheckChild2CondCodeMatcher::printImpl(raw_ostream &OS,
-                                           unsigned indent) const {
-  OS.indent(indent) << "CheckChild2CondCode ISD::" << CondCodeName << '\n';
+                                           unsigned Indent) const {
+  OS.indent(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, unsigned Indent) const {
+  OS.indent(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, unsigned Indent) const {
+  OS.indent(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, unsigned Indent) const {
+  OS.indent(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, unsigned Indent) const {
+  OS.indent(Indent) << "CheckOrImm " << Value << '\n';
 }
 
 void CheckFoldableChainNodeMatcher::printImpl(raw_ostream &OS,
-                                              unsigned indent) const {
-  OS.indent(indent) << "CheckFoldableChainNode\n";
+                                              unsigned Indent) const {
+  OS.indent(Indent) << "CheckFoldableChainNode\n";
 }
 
 void CheckImmAllOnesVMatcher::printImpl(raw_ostream &OS,
-                                        unsigned indent) const {
-  OS.indent(indent) << "CheckAllOnesV\n";
+                                        unsigned Indent) const {
+  OS.indent(Indent) << "CheckAllOnesV\n";
 }
 
 void CheckImmAllZerosVMatcher::printImpl(raw_ostream &OS,
-                                         unsigned indent) const {
-  OS.indent(indent) << "CheckAllZerosV\n";
+                                         unsigned Indent) const {
+  OS.indent(Indent) << "CheckAllZerosV\n";
 }
 
-void EmitIntegerMatcher::printImpl(raw_ostream &OS, unsigned indent) const {
-  OS.indent(indent) << "EmitInteger " << Val << " VT=" << getEnumName(VT)
+void EmitIntegerMatcher::printImpl(raw_ostream &OS, unsigned Indent) const {
+  OS.indent(Indent) << "EmitInteger " << Val << " VT=" << getEnumName(VT)
                     << '\n';
 }
 
 void EmitStringIntegerMatcher::printImpl(raw_ostream &OS,
-                                         unsigned indent) const {
-  OS.indent(indent) << "EmitStringInteger " << Val << " VT=" << getEnumName(VT)
+                                         unsigned Indent) const {
+  OS.indent(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, unsigned Indent) const {
+  OS.indent(Indent) << "EmitRegister ";
   if (Reg)
     OS << Reg->getName();
   else
@@ -269,26 +269,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';
+                                           unsigned Indent) const {
+  OS.indent(Indent) << "EmitConvertToTarget " << Slot << '\n';
 }
 
 void EmitMergeInputChainsMatcher::printImpl(raw_ostream &OS,
-                                            unsigned indent) const {
-  OS.indent(indent) << "EmitMergeInputChains <todo: args>\n";
+                                            unsigned Indent) const {
+  OS.indent(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, unsigned Indent) const {
+  OS.indent(Indent) << "EmitCopyToReg <todo: args>\n";
 }
 
-void EmitNodeXFormMatcher::printImpl(raw_ostream &OS, unsigned indent) const {
-  OS.indent(indent) << "EmitNodeXForm " << NodeXForm->getName()
+void EmitNodeXFormMatcher::printImpl(raw_ostream &OS, unsigned Indent) const {
+  OS.indent(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, unsigned Indent) const {
+  OS.indent(Indent);
   OS << (isa<MorphNodeToMatcher>(this) ? "MorphNodeTo: " : "EmitNode: ")
      << CGI.Namespace << "::" << CGI.TheDef->getName() << ": <todo flags> ";
 
@@ -300,10 +300,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, unsigned Indent) const {
+  OS.indent(Indent) << "CompleteMatch <todo args>\n";
+  OS.indent(Indent) << "Src = " << Pattern.getSrcPattern() << "\n";
+  OS.indent(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 49dc4726552af6..32924afdda0342 100644
--- a/llvm/utils/TableGen/Common/DAGISelMatcher.h
+++ b/llvm/utils/TableGen/Common/DAGISelMatcher.h
@@ -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, unsigned 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, unsigned 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, unsigned Indent) const override;
   bool isEqualImpl(const Matcher *M) const override {
     return cast<CheckChildSameMatcher>(M)->ChildNo == ChildNo &&
            cast<CheckChildSameMatcher>(M)->MatchNumber == MatchNumber;

diff  --git a/llvm/utils/TableGen/DecoderEmitter.cpp b/llvm/utils/TableGen/DecoderEmitter.cpp
index edecb9067bccf7..f3a4a77cc9b7f6 100644
--- a/llvm/utils/TableGen/DecoderEmitter.cpp
+++ b/llvm/utils/TableGen/DecoderEmitter.cpp
@@ -163,16 +163,15 @@ class DecoderEmitter {
       : RK(R), Target(R), PredicateNamespace(PredicateNamespace) {}
 
   // Emit the decoder state machine table.
-  void emitTable(formatted_raw_ostream &o, DecoderTable &Table,
-                 unsigned Indentation, unsigned BitWidth, StringRef Namespace,
+  void emitTable(formatted_raw_ostream &OS, DecoderTable &Table,
+                 unsigned Indent, unsigned BitWidth, StringRef Namespace,
                  const EncodingIDsVec &EncodingIDs) const;
   void emitInstrLenTable(formatted_raw_ostream &OS,
                          std::vector<unsigned> &InstrLen) const;
   void emitPredicateFunction(formatted_raw_ostream &OS,
-                             PredicateSet &Predicates,
-                             unsigned Indentation) const;
+                             PredicateSet &Predicates, unsigned Indent) const;
   void emitDecoderFunction(formatted_raw_ostream &OS, DecoderSet &Decoders,
-                           unsigned Indentation) const;
+                           unsigned Indent) const;
 
   // run - Output the code emitter
   void run(raw_ostream &o);
@@ -217,17 +216,17 @@ static bit_value_t bitFromBits(const BitsInit &bits, unsigned index) {
 }
 
 // Prints the bit value for each position.
-static void dumpBits(raw_ostream &o, const BitsInit &bits) {
+static void dumpBits(raw_ostream &OS, const BitsInit &bits) {
   for (unsigned index = bits.getNumBits(); index > 0; --index) {
     switch (bitFromBits(bits, index - 1)) {
     case BIT_TRUE:
-      o << "1";
+      OS << "1";
       break;
     case BIT_FALSE:
-      o << "0";
+      OS << "0";
       break;
     case BIT_UNSET:
-      o << "_";
+      OS << "_";
       break;
     default:
       llvm_unreachable("unexpected return value from bitFromBits");
@@ -497,12 +496,12 @@ class FilterChooser {
 
   /// dumpFilterArray - dumpFilterArray prints out debugging info for the given
   /// filter array as a series of chars.
-  void dumpFilterArray(raw_ostream &o,
+  void dumpFilterArray(raw_ostream &OS,
                        const std::vector<bit_value_t> &filter) const;
 
   /// dumpStack - dumpStack traverses the filter chooser chain and calls
   /// dumpFilterArray on each filter chooser up to the top level one.
-  void dumpStack(raw_ostream &o, const char *prefix) const;
+  void dumpStack(raw_ostream &OS, const char *prefix) const;
 
   Filter &bestFilter() {
     assert(BestIndex != -1 && "BestIndex not set");
@@ -524,8 +523,7 @@ class FilterChooser {
 
   // Emits code to check the Predicates member of an instruction are true.
   // Returns true if predicate matches were emitted, false otherwise.
-  bool emitPredicateMatch(raw_ostream &o, unsigned &Indentation,
-                          unsigned Opc) const;
+  bool emitPredicateMatch(raw_ostream &OS, unsigned Opc) const;
   bool emitPredicateMatchAux(const Init &Val, bool ParenIfBinOp,
                              raw_ostream &OS) const;
 
@@ -543,11 +541,11 @@ class FilterChooser {
   void emitSingletonTableEntry(DecoderTableInfo &TableInfo,
                                const Filter &Best) const;
 
-  void emitBinaryParser(raw_ostream &o, unsigned &Indentation,
+  void emitBinaryParser(raw_ostream &OS, unsigned Indent,
                         const OperandInfo &OpInfo,
                         bool &OpHasCompleteDecoder) const;
 
-  void emitDecoder(raw_ostream &OS, unsigned Indentation, unsigned Opc,
+  void emitDecoder(raw_ostream &OS, unsigned Indent, unsigned Opc,
                    bool &HasCompleteDecoder) const;
   unsigned getDecoderIndex(DecoderSet &Decoders, unsigned Opc,
                            bool &HasCompleteDecoder) const;
@@ -793,7 +791,7 @@ unsigned Filter::usefulness() const {
 
 // Emit the decoder state machine table.
 void DecoderEmitter::emitTable(formatted_raw_ostream &OS, DecoderTable &Table,
-                               unsigned Indentation, unsigned BitWidth,
+                               unsigned Indent, unsigned BitWidth,
                                StringRef Namespace,
                                const EncodingIDsVec &EncodingIDs) const {
   // We'll need to be able to map from a decoded opcode into the corresponding
@@ -804,10 +802,10 @@ void DecoderEmitter::emitTable(formatted_raw_ostream &OS, DecoderTable &Table,
   for (const auto &EI : EncodingIDs)
     OpcodeToEncodingID[EI.Opcode] = EI.EncodingID;
 
-  OS.indent(Indentation) << "static const uint8_t DecoderTable" << Namespace
-                         << BitWidth << "[] = {\n";
+  OS.indent(Indent) << "static const uint8_t DecoderTable" << Namespace
+                    << BitWidth << "[] = {\n";
 
-  Indentation += 2;
+  Indent += 2;
 
   // Emit ULEB128 encoded value to OS, returning the number of bytes emitted.
   auto emitULEB128 = [](DecoderTable::const_iterator I,
@@ -852,7 +850,7 @@ void DecoderEmitter::emitTable(formatted_raw_ostream &OS, DecoderTable &Table,
       PrintFatalError("invalid decode table opcode");
     case MCD::OPC_ExtractField: {
       ++I;
-      OS.indent(Indentation) << "MCD::OPC_ExtractField, ";
+      OS.indent(Indent) << "MCD::OPC_ExtractField, ";
 
       // ULEB128 encoded start value.
       const char *ErrMsg = nullptr;
@@ -870,7 +868,7 @@ void DecoderEmitter::emitTable(formatted_raw_ostream &OS, DecoderTable &Table,
     }
     case MCD::OPC_FilterValue: {
       ++I;
-      OS.indent(Indentation) << "MCD::OPC_FilterValue, ";
+      OS.indent(Indent) << "MCD::OPC_FilterValue, ";
       // The filter value is ULEB128 encoded.
       I += emitULEB128(I, OS);
 
@@ -882,7 +880,7 @@ void DecoderEmitter::emitTable(formatted_raw_ostream &OS, DecoderTable &Table,
     }
     case MCD::OPC_CheckField: {
       ++I;
-      OS.indent(Indentation) << "MCD::OPC_CheckField, ";
+      OS.indent(Indent) << "MCD::OPC_CheckField, ";
       // ULEB128 encoded start value.
       I += emitULEB128(I, OS);
       // 8-bit length.
@@ -899,7 +897,7 @@ void DecoderEmitter::emitTable(formatted_raw_ostream &OS, DecoderTable &Table,
     }
     case MCD::OPC_CheckPredicate: {
       ++I;
-      OS.indent(Indentation) << "MCD::OPC_CheckPredicate, ";
+      OS.indent(Indent) << "MCD::OPC_CheckPredicate, ";
       I += emitULEB128(I, OS);
 
       // 24-bit numtoskip value.
@@ -918,8 +916,7 @@ void DecoderEmitter::emitTable(formatted_raw_ostream &OS, DecoderTable &Table,
                                    Table.data() + Table.size(), &ErrMsg);
       assert(ErrMsg == nullptr && "ULEB128 value too large!");
 
-      OS.indent(Indentation)
-          << "MCD::OPC_" << (IsTry ? "Try" : "") << "Decode, ";
+      OS.indent(Indent) << "MCD::OPC_" << (IsTry ? "Try" : "") << "Decode, ";
       I += emitULEB128(I, OS);
 
       // Decoder index.
@@ -946,7 +943,7 @@ void DecoderEmitter::emitTable(formatted_raw_ostream &OS, DecoderTable &Table,
     }
     case MCD::OPC_SoftFail: {
       ++I;
-      OS.indent(Indentation) << "MCD::OPC_SoftFail";
+      OS.indent(Indent) << "MCD::OPC_SoftFail";
       // Positive mask
       uint64_t Value = 0;
       unsigned Shift = 0;
@@ -978,16 +975,16 @@ void DecoderEmitter::emitTable(formatted_raw_ostream &OS, DecoderTable &Table,
     }
     case MCD::OPC_Fail: {
       ++I;
-      OS.indent(Indentation) << "MCD::OPC_Fail,\n";
+      OS.indent(Indent) << "MCD::OPC_Fail,\n";
       break;
     }
     }
   }
-  OS.indent(Indentation) << "0\n";
+  OS.indent(Indent) << "0\n";
 
-  Indentation -= 2;
+  Indent -= 2;
 
-  OS.indent(Indentation) << "};\n\n";
+  OS.indent(Indent) << "};\n\n";
 }
 
 void DecoderEmitter::emitInstrLenTable(formatted_raw_ostream &OS,
@@ -1001,61 +998,60 @@ void DecoderEmitter::emitInstrLenTable(formatted_raw_ostream &OS,
 
 void DecoderEmitter::emitPredicateFunction(formatted_raw_ostream &OS,
                                            PredicateSet &Predicates,
-                                           unsigned Indentation) const {
+                                           unsigned Indent) const {
   // The predicate function is just a big switch statement based on the
   // input predicate index.
-  OS.indent(Indentation) << "static bool checkDecoderPredicate(unsigned Idx, "
-                         << "const FeatureBitset &Bits) {\n";
-  Indentation += 2;
+  OS.indent(Indent) << "static bool checkDecoderPredicate(unsigned Idx, "
+                    << "const FeatureBitset &Bits) {\n";
+  Indent += 2;
   if (!Predicates.empty()) {
-    OS.indent(Indentation) << "switch (Idx) {\n";
-    OS.indent(Indentation)
-        << "default: llvm_unreachable(\"Invalid index!\");\n";
+    OS.indent(Indent) << "switch (Idx) {\n";
+    OS.indent(Indent) << "default: llvm_unreachable(\"Invalid index!\");\n";
     unsigned Index = 0;
     for (const auto &Predicate : Predicates) {
-      OS.indent(Indentation) << "case " << Index++ << ":\n";
-      OS.indent(Indentation + 2) << "return (" << Predicate << ");\n";
+      OS.indent(Indent) << "case " << Index++ << ":\n";
+      OS.indent(Indent + 2) << "return (" << Predicate << ");\n";
     }
-    OS.indent(Indentation) << "}\n";
+    OS.indent(Indent) << "}\n";
   } else {
     // No case statement to emit
-    OS.indent(Indentation) << "llvm_unreachable(\"Invalid index!\");\n";
+    OS.indent(Indent) << "llvm_unreachable(\"Invalid index!\");\n";
   }
-  Indentation -= 2;
-  OS.indent(Indentation) << "}\n\n";
+  Indent -= 2;
+  OS.indent(Indent) << "}\n\n";
 }
 
 void DecoderEmitter::emitDecoderFunction(formatted_raw_ostream &OS,
                                          DecoderSet &Decoders,
-                                         unsigned Indentation) const {
+                                         unsigned Indent) const {
   // The decoder function is just a big switch statement based on the
   // input decoder index.
-  OS.indent(Indentation) << "template <typename InsnType>\n";
-  OS.indent(Indentation) << "static DecodeStatus decodeToMCInst(DecodeStatus S,"
-                         << " unsigned Idx, InsnType insn, MCInst &MI,\n";
-  OS.indent(Indentation)
+  OS.indent(Indent) << "template <typename InsnType>\n";
+  OS.indent(Indent) << "static DecodeStatus decodeToMCInst(DecodeStatus S,"
+                    << " unsigned Idx, InsnType insn, MCInst &MI,\n";
+  OS.indent(Indent)
       << "                                   uint64_t "
       << "Address, const MCDisassembler *Decoder, bool &DecodeComplete) {\n";
-  Indentation += 2;
-  OS.indent(Indentation) << "DecodeComplete = true;\n";
+  Indent += 2;
+  OS.indent(Indent) << "DecodeComplete = true;\n";
   // TODO: When InsnType is large, using uint64_t limits all fields to 64 bits
   // It would be better for emitBinaryParser to use a 64-bit tmp whenever
   // possible but fall back to an InsnType-sized tmp for truly large fields.
-  OS.indent(Indentation) << "using TmpType = "
-                            "std::conditional_t<std::is_integral<InsnType>::"
-                            "value, InsnType, uint64_t>;\n";
-  OS.indent(Indentation) << "TmpType tmp;\n";
-  OS.indent(Indentation) << "switch (Idx) {\n";
-  OS.indent(Indentation) << "default: llvm_unreachable(\"Invalid index!\");\n";
+  OS.indent(Indent) << "using TmpType = "
+                       "std::conditional_t<std::is_integral<InsnType>::"
+                       "value, InsnType, uint64_t>;\n";
+  OS.indent(Indent) << "TmpType tmp;\n";
+  OS.indent(Indent) << "switch (Idx) {\n";
+  OS.indent(Indent) << "default: llvm_unreachable(\"Invalid index!\");\n";
   unsigned Index = 0;
   for (const auto &Decoder : Decoders) {
-    OS.indent(Indentation) << "case " << Index++ << ":\n";
+    OS.indent(Indent) << "case " << Index++ << ":\n";
     OS << Decoder;
-    OS.indent(Indentation + 2) << "return S;\n";
+    OS.indent(Indent + 2) << "return S;\n";
   }
-  OS.indent(Indentation) << "}\n";
-  Indentation -= 2;
-  OS.indent(Indentation) << "}\n";
+  OS.indent(Indent) << "}\n";
+  Indent -= 2;
+  OS.indent(Indent) << "}\n";
 }
 
 // Populates the field of the insn given the start position and the number of
@@ -1083,20 +1079,20 @@ std::pair<bool, uint64_t> FilterChooser::fieldFromInsn(const insn_t &Insn,
 /// dumpFilterArray - dumpFilterArray prints out debugging info for the given
 /// filter array as a series of chars.
 void FilterChooser::dumpFilterArray(
-    raw_ostream &o, const std::vector<bit_value_t> &filter) const {
+    raw_ostream &OS, const std::vector<bit_value_t> &filter) const {
   for (unsigned bitIndex = BitWidth; bitIndex > 0; bitIndex--) {
     switch (filter[bitIndex - 1]) {
     case BIT_UNFILTERED:
-      o << ".";
+      OS << ".";
       break;
     case BIT_UNSET:
-      o << "_";
+      OS << "_";
       break;
     case BIT_TRUE:
-      o << "1";
+      OS << "1";
       break;
     case BIT_FALSE:
-      o << "0";
+      OS << "0";
       break;
     }
   }
@@ -1104,13 +1100,13 @@ void FilterChooser::dumpFilterArray(
 
 /// dumpStack - dumpStack traverses the filter chooser chain and calls
 /// dumpFilterArray on each filter chooser up to the top level one.
-void FilterChooser::dumpStack(raw_ostream &o, const char *prefix) const {
+void FilterChooser::dumpStack(raw_ostream &OS, const char *prefix) const {
   const FilterChooser *current = this;
 
   while (current) {
-    o << prefix;
-    dumpFilterArray(o, current->FilterBitValues);
-    o << '\n';
+    OS << prefix;
+    dumpFilterArray(OS, current->FilterBitValues);
+    OS << '\n';
     current = current->Parent;
   }
 }
@@ -1176,7 +1172,7 @@ unsigned FilterChooser::getIslands(std::vector<unsigned> &StartBits,
   return Num;
 }
 
-void FilterChooser::emitBinaryParser(raw_ostream &o, unsigned &Indentation,
+void FilterChooser::emitBinaryParser(raw_ostream &OS, unsigned Indent,
                                      const OperandInfo &OpInfo,
                                      bool &OpHasCompleteDecoder) const {
   const std::string &Decoder = OpInfo.Decoder;
@@ -1184,56 +1180,56 @@ void FilterChooser::emitBinaryParser(raw_ostream &o, unsigned &Indentation,
   bool UseInsertBits = OpInfo.numFields() != 1 || OpInfo.InitValue != 0;
 
   if (UseInsertBits) {
-    o.indent(Indentation) << "tmp = 0x";
-    o.write_hex(OpInfo.InitValue);
-    o << ";\n";
+    OS.indent(Indent) << "tmp = 0x";
+    OS.write_hex(OpInfo.InitValue);
+    OS << ";\n";
   }
 
   for (const EncodingField &EF : OpInfo) {
-    o.indent(Indentation);
+    OS.indent(Indent);
     if (UseInsertBits)
-      o << "insertBits(tmp, ";
+      OS << "insertBits(tmp, ";
     else
-      o << "tmp = ";
-    o << "fieldFromInstruction(insn, " << EF.Base << ", " << EF.Width << ')';
+      OS << "tmp = ";
+    OS << "fieldFromInstruction(insn, " << EF.Base << ", " << EF.Width << ')';
     if (UseInsertBits)
-      o << ", " << EF.Offset << ", " << EF.Width << ')';
+      OS << ", " << EF.Offset << ", " << EF.Width << ')';
     else if (EF.Offset != 0)
-      o << " << " << EF.Offset;
-    o << ";\n";
+      OS << " << " << EF.Offset;
+    OS << ";\n";
   }
 
   if (Decoder != "") {
     OpHasCompleteDecoder = OpInfo.HasCompleteDecoder;
-    o.indent(Indentation) << "if (!Check(S, " << Decoder
-                          << "(MI, tmp, Address, Decoder))) { "
-                          << (OpHasCompleteDecoder ? ""
-                                                   : "DecodeComplete = false; ")
-                          << "return MCDisassembler::Fail; }\n";
+    OS.indent(Indent) << "if (!Check(S, " << Decoder
+                      << "(MI, tmp, Address, Decoder))) { "
+                      << (OpHasCompleteDecoder ? ""
+                                               : "DecodeComplete = false; ")
+                      << "return MCDisassembler::Fail; }\n";
   } else {
     OpHasCompleteDecoder = true;
-    o.indent(Indentation) << "MI.addOperand(MCOperand::createImm(tmp));\n";
+    OS.indent(Indent) << "MI.addOperand(MCOperand::createImm(tmp));\n";
   }
 }
 
-void FilterChooser::emitDecoder(raw_ostream &OS, unsigned Indentation,
-                                unsigned Opc, bool &HasCompleteDecoder) const {
+void FilterChooser::emitDecoder(raw_ostream &OS, unsigned Indent, unsigned Opc,
+                                bool &HasCompleteDecoder) const {
   HasCompleteDecoder = true;
 
   for (const auto &Op : Operands.find(Opc)->second) {
     // If a custom instruction decoder was specified, use that.
     if (Op.numFields() == 0 && !Op.Decoder.empty()) {
       HasCompleteDecoder = Op.HasCompleteDecoder;
-      OS.indent(Indentation)
-          << "if (!Check(S, " << Op.Decoder
-          << "(MI, insn, Address, Decoder))) { "
-          << (HasCompleteDecoder ? "" : "DecodeComplete = false; ")
-          << "return MCDisassembler::Fail; }\n";
+      OS.indent(Indent) << "if (!Check(S, " << Op.Decoder
+                        << "(MI, insn, Address, Decoder))) { "
+                        << (HasCompleteDecoder ? ""
+                                               : "DecodeComplete = false; ")
+                        << "return MCDisassembler::Fail; }\n";
       break;
     }
 
     bool OpHasCompleteDecoder;
-    emitBinaryParser(OS, Indentation, Op, OpHasCompleteDecoder);
+    emitBinaryParser(OS, Indent, Op, OpHasCompleteDecoder);
     if (!OpHasCompleteDecoder)
       HasCompleteDecoder = false;
   }
@@ -1296,8 +1292,7 @@ bool FilterChooser::emitPredicateMatchAux(const Init &Val, bool ParenIfBinOp,
   return true;
 }
 
-bool FilterChooser::emitPredicateMatch(raw_ostream &o, unsigned &Indentation,
-                                       unsigned Opc) const {
+bool FilterChooser::emitPredicateMatch(raw_ostream &OS, unsigned Opc) const {
   ListInit *Predicates =
       AllInstructions[Opc].EncodingDef->getValueAsListInit("Predicates");
   bool IsFirstEmission = true;
@@ -1310,9 +1305,9 @@ bool FilterChooser::emitPredicateMatch(raw_ostream &o, unsigned &Indentation,
       continue;
 
     if (!IsFirstEmission)
-      o << " && ";
+      OS << " && ";
     if (emitPredicateMatchAux(*Pred->getValueAsDag("AssemblerCondDag"),
-                              Predicates->size() > 1, o))
+                              Predicates->size() > 1, OS))
       PrintFatalError(Pred->getLoc(), "Invalid AssemblerCondDag!");
     IsFirstEmission = false;
   }
@@ -1358,8 +1353,7 @@ void FilterChooser::emitPredicateTableEntry(DecoderTableInfo &TableInfo,
   // FIXME: emitPredicateMatch() functions can take a buffer directly rather
   // than a stream.
   raw_svector_ostream PS(Predicate);
-  unsigned I = 0;
-  emitPredicateMatch(PS, I, Opc);
+  emitPredicateMatch(PS, Opc);
 
   // Figure out the index into the predicate table for the predicate just
   // computed.


        


More information about the llvm-commits mailing list