summaryrefslogtreecommitdiffstats
path: root/llvm/lib/TableGen/TGParser.h
diff options
context:
space:
mode:
authorNicolai Haehnle <nhaehnle@gmail.com>2018-03-21 17:12:53 +0000
committerNicolai Haehnle <nhaehnle@gmail.com>2018-03-21 17:12:53 +0000
commit420e28c78c9fe51345686c0ac48b64a06a1907c1 (patch)
tree1386135665492a59f228ed5da4cad1f60080745c /llvm/lib/TableGen/TGParser.h
parent3507b0489f541f066e910f765fa8131cdb1402c9 (diff)
downloadbcm5719-llvm-420e28c78c9fe51345686c0ac48b64a06a1907c1.tar.gz
bcm5719-llvm-420e28c78c9fe51345686c0ac48b64a06a1907c1.zip
TableGen: Streamline how defs are instantiated
Summary: Instantiating def's and defm's needs to perform the following steps: - for defm's, clone multiclass def prototypes and subsitute template args - for def's and defm's, add subclass definitions, substituting template args - clone the record based on foreach loops and substitute loop iteration variables - override record variables based on the global 'let' stack - resolve the record name (this should be simple, but unfortunately it's not due to existing .td files relying on rather silly implementation details) - for def(m)s in multiclasses, add the unresolved record as a multiclass prototype - for top-level def(m)s, resolve all internal variable references and add them to the record keeper and any active defsets This change streamlines how we go through these steps, by having both def's and defm's feed into a single addDef() method that handles foreach, final resolve, and routing the record to the right place. This happens to make foreach inside of multiclasses work, as the new test case demonstrates. Previously, foreach inside multiclasses was not forbidden by the parser, but it was de facto broken. Another side effect is that the order of "instantiated from" notes in error messages is reversed, as the modified test case shows. This is arguably clearer, since the initial error message ends up pointing directly to whatever triggered the error, and subsequent notes will point to increasingly outer layers of multiclasses. This is consistent with how C++ compilers report nested #includes and nested template instantiations. Change-Id: Ica146d0db2bc133dd7ed88054371becf24320447 Reviewers: arsenm, craig.topper, tra, MartinO Subscribers: wdng, llvm-commits Differential Revision: https://reviews.llvm.org/D44478 llvm-svn: 328117
Diffstat (limited to 'llvm/lib/TableGen/TGParser.h')
-rw-r--r--llvm/lib/TableGen/TGParser.h20
1 files changed, 4 insertions, 16 deletions
diff --git a/llvm/lib/TableGen/TGParser.h b/llvm/lib/TableGen/TGParser.h
index d4ee5be5d98..7948df27208 100644
--- a/llvm/lib/TableGen/TGParser.h
+++ b/llvm/lib/TableGen/TGParser.h
@@ -126,28 +126,16 @@ private: // Semantic analysis methods.
// iteration space.
typedef std::vector<IterRecord> IterSet;
- bool ProcessForeachDefs(Record *CurRec, SMLoc Loc);
- bool ProcessForeachDefs(Record *CurRec, SMLoc Loc, IterSet &IterVals);
-
- bool addToDefsets(Record &R);
+ bool addDefOne(std::unique_ptr<Record> Rec, Init *DefmName,
+ IterSet &IterVals);
+ bool addDefForeach(Record *Rec, Init *DefmName, IterSet &IterVals);
+ bool addDef(std::unique_ptr<Record> Rec, Init *DefmName);
private: // Parser methods.
bool ParseObjectList(MultiClass *MC = nullptr);
bool ParseObject(MultiClass *MC);
bool ParseClass();
bool ParseMultiClass();
- Record *InstantiateMulticlassDef(MultiClass &MC, Record *DefProto,
- Init *&DefmPrefix, SMRange DefmPrefixRange,
- ArrayRef<Init *> TArgs,
- ArrayRef<Init *> TemplateVals);
- bool ResolveMulticlassDefArgs(MultiClass &MC, Record *DefProto,
- SMLoc DefmPrefixLoc, SMLoc SubClassLoc,
- ArrayRef<Init *> TArgs,
- ArrayRef<Init *> TemplateVals, bool DeleteArgs);
- bool ResolveMulticlassDef(MultiClass &MC,
- Record *CurRec,
- Record *DefProto,
- SMLoc DefmPrefixLoc);
bool ParseDefm(MultiClass *CurMultiClass);
bool ParseDef(MultiClass *CurMultiClass);
bool ParseDefset();
OpenPOWER on IntegriCloud