From db8049deef4e3d247849e4ce2b77c69aec89d014 Mon Sep 17 00:00:00 2001 From: Michael Liao Date: Sat, 10 Jun 2023 22:03:33 -0400 Subject: [PATCH] [TableGen] Fix indentation. NFC --- llvm/lib/TableGen/TGParser.h | 218 +++++++++++++++++++++---------------------- 1 file changed, 108 insertions(+), 110 deletions(-) diff --git a/llvm/lib/TableGen/TGParser.h b/llvm/lib/TableGen/TGParser.h index 91c68fb..d43f292 100644 --- a/llvm/lib/TableGen/TGParser.h +++ b/llvm/lib/TableGen/TGParser.h @@ -19,124 +19,122 @@ #include namespace llvm { - class SourceMgr; - class Twine; - struct ForeachLoop; - struct MultiClass; - struct SubClassReference; - struct SubMultiClassReference; - - struct LetRecord { - StringInit *Name; - std::vector Bits; - Init *Value; - SMLoc Loc; - LetRecord(StringInit *N, ArrayRef B, Init *V, SMLoc L) - : Name(N), Bits(B), Value(V), Loc(L) { - } - }; +class SourceMgr; +class Twine; +struct ForeachLoop; +struct MultiClass; +struct SubClassReference; +struct SubMultiClassReference; + +struct LetRecord { + StringInit *Name; + std::vector Bits; + Init *Value; + SMLoc Loc; + LetRecord(StringInit *N, ArrayRef B, Init *V, SMLoc L) + : Name(N), Bits(B), Value(V), Loc(L) {} +}; - /// RecordsEntry - Holds exactly one of a Record, ForeachLoop, or - /// AssertionInfo. - struct RecordsEntry { - std::unique_ptr Rec; - std::unique_ptr Loop; - std::unique_ptr Assertion; - - void dump() const; - - RecordsEntry() = default; - RecordsEntry(std::unique_ptr Rec) : Rec(std::move(Rec)) {} - RecordsEntry(std::unique_ptr Loop) - : Loop(std::move(Loop)) {} - RecordsEntry(std::unique_ptr Assertion) - : Assertion(std::move(Assertion)) {} - }; +/// RecordsEntry - Holds exactly one of a Record, ForeachLoop, or +/// AssertionInfo. +struct RecordsEntry { + std::unique_ptr Rec; + std::unique_ptr Loop; + std::unique_ptr Assertion; - /// ForeachLoop - Record the iteration state associated with a for loop. - /// This is used to instantiate items in the loop body. - /// - /// IterVar is allowed to be null, in which case no iteration variable is - /// defined in the loop at all. (This happens when a ForeachLoop is - /// constructed by desugaring an if statement.) - struct ForeachLoop { - SMLoc Loc; - VarInit *IterVar; - Init *ListValue; - std::vector Entries; - - void dump() const; - - ForeachLoop(SMLoc Loc, VarInit *IVar, Init *LValue) + void dump() const; + + RecordsEntry() = default; + RecordsEntry(std::unique_ptr Rec) : Rec(std::move(Rec)) {} + RecordsEntry(std::unique_ptr Loop) : Loop(std::move(Loop)) {} + RecordsEntry(std::unique_ptr Assertion) + : Assertion(std::move(Assertion)) {} +}; + +/// ForeachLoop - Record the iteration state associated with a for loop. +/// This is used to instantiate items in the loop body. +/// +/// IterVar is allowed to be null, in which case no iteration variable is +/// defined in the loop at all. (This happens when a ForeachLoop is +/// constructed by desugaring an if statement.) +struct ForeachLoop { + SMLoc Loc; + VarInit *IterVar; + Init *ListValue; + std::vector Entries; + + void dump() const; + + ForeachLoop(SMLoc Loc, VarInit *IVar, Init *LValue) : Loc(Loc), IterVar(IVar), ListValue(LValue) {} - }; +}; - struct DefsetRecord { - SMLoc Loc; - RecTy *EltTy = nullptr; - SmallVector Elements; - }; +struct DefsetRecord { + SMLoc Loc; + RecTy *EltTy = nullptr; + SmallVector Elements; +}; - struct MultiClass { - Record Rec; // Placeholder for template args and Name. - std::vector Entries; +struct MultiClass { + Record Rec; // Placeholder for template args and Name. + std::vector Entries; - void dump() const; + void dump() const; - MultiClass(StringRef Name, SMLoc Loc, RecordKeeper &Records) - : Rec(Name, Loc, Records) {} - }; + MultiClass(StringRef Name, SMLoc Loc, RecordKeeper &Records) + : Rec(Name, Loc, Records) {} +}; - class TGVarScope { - public: - enum ScopeKind { SK_Local, SK_Record, SK_ForeachLoop, SK_MultiClass }; - - private: - ScopeKind Kind; - std::unique_ptr Parent; - // A scope to hold variable definitions from defvar. - std::map> Vars; - Record *CurRec = nullptr; - ForeachLoop *CurLoop = nullptr; - MultiClass *CurMultiClass = nullptr; - - public: - TGVarScope(std::unique_ptr Parent) - : Kind(SK_Local), Parent(std::move(Parent)) {} - TGVarScope(std::unique_ptr Parent, Record *Rec) - : Kind(SK_Record), Parent(std::move(Parent)), CurRec(Rec) {} - TGVarScope(std::unique_ptr Parent, ForeachLoop *Loop) - : Kind(SK_ForeachLoop), Parent(std::move(Parent)), CurLoop(Loop) {} - TGVarScope(std::unique_ptr Parent, MultiClass *Multiclass) - : Kind(SK_MultiClass), Parent(std::move(Parent)), - CurMultiClass(Multiclass) {} - - std::unique_ptr extractParent() { - // This is expected to be called just before we are destructed, so - // it doesn't much matter what state we leave 'parent' in. - return std::move(Parent); - } - - Init *getVar(RecordKeeper &Records, MultiClass *ParsingMultiClass, - StringInit *Name, SMRange NameLoc, - bool TrackReferenceLocs) const; - - bool varAlreadyDefined(StringRef Name) const { - // When we check whether a variable is already defined, for the purpose of - // reporting an error on redefinition, we don't look up to the parent - // scope, because it's all right to shadow an outer definition with an - // inner one. - return Vars.find(Name) != Vars.end(); - } - - void addVar(StringRef Name, Init *I) { - bool Ins = Vars.insert(std::make_pair(std::string(Name), I)).second; - (void)Ins; - assert(Ins && "Local variable already exists"); - } - - bool isOutermost() const { return Parent == nullptr; } - }; +class TGVarScope { +public: + enum ScopeKind { SK_Local, SK_Record, SK_ForeachLoop, SK_MultiClass }; + +private: + ScopeKind Kind; + std::unique_ptr Parent; + // A scope to hold variable definitions from defvar. + std::map> Vars; + Record *CurRec = nullptr; + ForeachLoop *CurLoop = nullptr; + MultiClass *CurMultiClass = nullptr; + +public: + TGVarScope(std::unique_ptr Parent) + : Kind(SK_Local), Parent(std::move(Parent)) {} + TGVarScope(std::unique_ptr Parent, Record *Rec) + : Kind(SK_Record), Parent(std::move(Parent)), CurRec(Rec) {} + TGVarScope(std::unique_ptr Parent, ForeachLoop *Loop) + : Kind(SK_ForeachLoop), Parent(std::move(Parent)), CurLoop(Loop) {} + TGVarScope(std::unique_ptr Parent, MultiClass *Multiclass) + : Kind(SK_MultiClass), Parent(std::move(Parent)), + CurMultiClass(Multiclass) {} + + std::unique_ptr extractParent() { + // This is expected to be called just before we are destructed, so + // it doesn't much matter what state we leave 'parent' in. + return std::move(Parent); + } + + Init *getVar(RecordKeeper &Records, MultiClass *ParsingMultiClass, + StringInit *Name, SMRange NameLoc, + bool TrackReferenceLocs) const; + + bool varAlreadyDefined(StringRef Name) const { + // When we check whether a variable is already defined, for the purpose of + // reporting an error on redefinition, we don't look up to the parent + // scope, because it's all right to shadow an outer definition with an + // inner one. + return Vars.find(Name) != Vars.end(); + } + + void addVar(StringRef Name, Init *I) { + bool Ins = Vars.insert(std::make_pair(std::string(Name), I)).second; + (void)Ins; + assert(Ins && "Local variable already exists"); + } + + bool isOutermost() const { return Parent == nullptr; } +}; class TGParser { TGLexer Lex; -- 2.7.4