aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/TableGen
diff options
context:
space:
mode:
authorMichael Liao <michael.hliao@gmail.com>2023-06-10 22:03:33 -0400
committerMichael Liao <michael.hliao@gmail.com>2023-06-10 22:56:03 -0400
commitdb8049deef4e3d247849e4ce2b77c69aec89d014 (patch)
tree82ce5c9e272f6c1e8465c067b0f9fcf1e5f12d9c /llvm/lib/TableGen
parentf8897f866c1a33d4896062f2c63142de7f2442f1 (diff)
downloadllvm-db8049deef4e3d247849e4ce2b77c69aec89d014.zip
llvm-db8049deef4e3d247849e4ce2b77c69aec89d014.tar.gz
llvm-db8049deef4e3d247849e4ce2b77c69aec89d014.tar.bz2
[TableGen] Fix indentation. NFC
Diffstat (limited to 'llvm/lib/TableGen')
-rw-r--r--llvm/lib/TableGen/TGParser.h218
1 files 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 <map>
namespace llvm {
- class SourceMgr;
- class Twine;
- struct ForeachLoop;
- struct MultiClass;
- struct SubClassReference;
- struct SubMultiClassReference;
-
- struct LetRecord {
- StringInit *Name;
- std::vector<unsigned> Bits;
- Init *Value;
- SMLoc Loc;
- LetRecord(StringInit *N, ArrayRef<unsigned> 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<unsigned> Bits;
+ Init *Value;
+ SMLoc Loc;
+ LetRecord(StringInit *N, ArrayRef<unsigned> 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<Record> Rec;
- std::unique_ptr<ForeachLoop> Loop;
- std::unique_ptr<Record::AssertionInfo> Assertion;
-
- void dump() const;
-
- RecordsEntry() = default;
- RecordsEntry(std::unique_ptr<Record> Rec) : Rec(std::move(Rec)) {}
- RecordsEntry(std::unique_ptr<ForeachLoop> Loop)
- : Loop(std::move(Loop)) {}
- RecordsEntry(std::unique_ptr<Record::AssertionInfo> Assertion)
- : Assertion(std::move(Assertion)) {}
- };
+/// RecordsEntry - Holds exactly one of a Record, ForeachLoop, or
+/// AssertionInfo.
+struct RecordsEntry {
+ std::unique_ptr<Record> Rec;
+ std::unique_ptr<ForeachLoop> Loop;
+ std::unique_ptr<Record::AssertionInfo> 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<RecordsEntry> Entries;
-
- void dump() const;
-
- ForeachLoop(SMLoc Loc, VarInit *IVar, Init *LValue)
+ void dump() const;
+
+ RecordsEntry() = default;
+ RecordsEntry(std::unique_ptr<Record> Rec) : Rec(std::move(Rec)) {}
+ RecordsEntry(std::unique_ptr<ForeachLoop> Loop) : Loop(std::move(Loop)) {}
+ RecordsEntry(std::unique_ptr<Record::AssertionInfo> 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<RecordsEntry> 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<Init *, 16> Elements;
- };
+struct DefsetRecord {
+ SMLoc Loc;
+ RecTy *EltTy = nullptr;
+ SmallVector<Init *, 16> Elements;
+};
- struct MultiClass {
- Record Rec; // Placeholder for template args and Name.
- std::vector<RecordsEntry> Entries;
+struct MultiClass {
+ Record Rec; // Placeholder for template args and Name.
+ std::vector<RecordsEntry> 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<TGVarScope> Parent;
- // A scope to hold variable definitions from defvar.
- std::map<std::string, Init *, std::less<>> Vars;
- Record *CurRec = nullptr;
- ForeachLoop *CurLoop = nullptr;
- MultiClass *CurMultiClass = nullptr;
-
- public:
- TGVarScope(std::unique_ptr<TGVarScope> Parent)
- : Kind(SK_Local), Parent(std::move(Parent)) {}
- TGVarScope(std::unique_ptr<TGVarScope> Parent, Record *Rec)
- : Kind(SK_Record), Parent(std::move(Parent)), CurRec(Rec) {}
- TGVarScope(std::unique_ptr<TGVarScope> Parent, ForeachLoop *Loop)
- : Kind(SK_ForeachLoop), Parent(std::move(Parent)), CurLoop(Loop) {}
- TGVarScope(std::unique_ptr<TGVarScope> Parent, MultiClass *Multiclass)
- : Kind(SK_MultiClass), Parent(std::move(Parent)),
- CurMultiClass(Multiclass) {}
-
- std::unique_ptr<TGVarScope> 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<TGVarScope> Parent;
+ // A scope to hold variable definitions from defvar.
+ std::map<std::string, Init *, std::less<>> Vars;
+ Record *CurRec = nullptr;
+ ForeachLoop *CurLoop = nullptr;
+ MultiClass *CurMultiClass = nullptr;
+
+public:
+ TGVarScope(std::unique_ptr<TGVarScope> Parent)
+ : Kind(SK_Local), Parent(std::move(Parent)) {}
+ TGVarScope(std::unique_ptr<TGVarScope> Parent, Record *Rec)
+ : Kind(SK_Record), Parent(std::move(Parent)), CurRec(Rec) {}
+ TGVarScope(std::unique_ptr<TGVarScope> Parent, ForeachLoop *Loop)
+ : Kind(SK_ForeachLoop), Parent(std::move(Parent)), CurLoop(Loop) {}
+ TGVarScope(std::unique_ptr<TGVarScope> Parent, MultiClass *Multiclass)
+ : Kind(SK_MultiClass), Parent(std::move(Parent)),
+ CurMultiClass(Multiclass) {}
+
+ std::unique_ptr<TGVarScope> 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;