Skip to content

Commit 57627ce

Browse files
committed
Rename to instances
1 parent 9f3d31b commit 57627ce

File tree

7 files changed

+66
-64
lines changed

7 files changed

+66
-64
lines changed

llvm/docs/TableGen/ProgRef.rst

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -223,10 +223,10 @@ TableGen provides "bang operators" that have a wide variety of uses:
223223
: !div !empty !eq !exists !filter
224224
: !find !foldl !foreach !ge !getdagarg
225225
: !getdagname !getdagop !gt !head !if
226-
: !initialized !interleave !isa !le !listconcat
227-
: !listflatten !listremove !listsplat !logtwo !lt
228-
: !match !mul !ne !not !or
229-
: !range !records !repr !setdagarg !setdagname
226+
: !initialized !instances !interleave !isa !le
227+
: !listconcat !listflatten !listremove !listsplat !logtwo
228+
: !lt !match !mul !ne !not
229+
: !or !range !repr !setdagarg !setdagname
230230
: !setdagop !shl !size !sra !srl
231231
: !strconcat !sub !subst !substr !tail
232232
: !tolower !toupper !xor
@@ -1836,6 +1836,12 @@ and non-0 as true.
18361836
This operator produces 1 if *a* is not the uninitialized value (``?``) and 0
18371837
otherwise.
18381838

1839+
``!instances<``\ *type*\ ``>([``\ *regex*\ ``])``
1840+
This operator produces a list of records whose type is *type*. If *regex*
1841+
is provided, only records whose name matches the regular expression *regex*
1842+
will be included. The format of *regex* is ERE (Extended POSIX Regular
1843+
Expressions).
1844+
18391845
``!interleave(``\ *list*\ ``,`` *delim*\ ``)``
18401846
This operator concatenates the items in the *list*, interleaving the
18411847
*delim* string between each pair, and produces the resulting string.
@@ -1920,12 +1926,6 @@ and non-0 as true.
19201926
``!range(``\ *list*\ ``)``
19211927
Equivalent to ``!range(0, !size(list))``.
19221928

1923-
``!records<``\ *type*\ ``>([``\ *regex*\ ``])``
1924-
This operator produces a list of records whose type is *type*. If *regex*
1925-
is provided, only records whose name matches the regular expression *regex*
1926-
will be included. The format of *regex* is ERE (Extended POSIX Regular
1927-
Expressions).
1928-
19291929
``!repr(``\ *value*\ ``)``
19301930
Represents *value* as a string. String format for the value is not
19311931
guaranteed to be stable. Intended for debugging purposes only.

llvm/include/llvm/TableGen/Record.h

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ class Init {
316316
IK_FoldOpInit,
317317
IK_IsAOpInit,
318318
IK_ExistsOpInit,
319-
IK_RecordsOpInit,
319+
IK_InstancesOpInit,
320320
IK_AnonymousNameInit,
321321
IK_StringInit,
322322
IK_VarInit,
@@ -1193,27 +1193,27 @@ class ExistsOpInit final : public TypedInit, public FoldingSetNode {
11931193
std::string getAsString() const override;
11941194
};
11951195

1196-
/// !records<type>([regex]) - Produces a list of records whose type is `type`.
1196+
/// !instances<type>([regex]) - Produces a list of records whose type is `type`.
11971197
/// If `regex` is provided, only records whose name matches the regular
11981198
/// expression `regex` will be included.
1199-
class RecordsOpInit final : public TypedInit, public FoldingSetNode {
1199+
class InstancesOpInit final : public TypedInit, public FoldingSetNode {
12001200
private:
12011201
const RecTy *Type;
12021202
const Init *Regex;
12031203

1204-
RecordsOpInit(const RecTy *Type, const Init *Regex)
1205-
: TypedInit(IK_RecordsOpInit, ListRecTy::get(Type)), Type(Type),
1204+
InstancesOpInit(const RecTy *Type, const Init *Regex)
1205+
: TypedInit(IK_InstancesOpInit, ListRecTy::get(Type)), Type(Type),
12061206
Regex(Regex) {}
12071207

12081208
public:
1209-
RecordsOpInit(const RecordsOpInit &) = delete;
1210-
RecordsOpInit &operator=(const RecordsOpInit &) = delete;
1209+
InstancesOpInit(const InstancesOpInit &) = delete;
1210+
InstancesOpInit &operator=(const InstancesOpInit &) = delete;
12111211

12121212
static bool classof(const Init *I) {
1213-
return I->getKind() == IK_RecordsOpInit;
1213+
return I->getKind() == IK_InstancesOpInit;
12141214
}
12151215

1216-
static const RecordsOpInit *get(const RecTy *Type, const Init *Regex);
1216+
static const InstancesOpInit *get(const RecTy *Type, const Init *Regex);
12171217

12181218
void Profile(FoldingSetNodeID &ID) const;
12191219

llvm/lib/TableGen/Record.cpp

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ struct RecordKeeperImpl {
8484
FoldingSet<FoldOpInit> TheFoldOpInitPool;
8585
FoldingSet<IsAOpInit> TheIsAOpInitPool;
8686
FoldingSet<ExistsOpInit> TheExistsOpInitPool;
87-
FoldingSet<RecordsOpInit> TheRecordsOpInitPool;
87+
FoldingSet<InstancesOpInit> TheInstancesOpInitPool;
8888
DenseMap<std::pair<const RecTy *, const Init *>, VarInit *> TheVarInitPool;
8989
DenseMap<std::pair<const TypedInit *, unsigned>, VarBitInit *>
9090
TheVarBitInitPool;
@@ -2223,32 +2223,33 @@ std::string ExistsOpInit::getAsString() const {
22232223
.str();
22242224
}
22252225

2226-
static void ProfileRecordsOpInit(FoldingSetNodeID &ID, const RecTy *Type,
2227-
const Init *Regex) {
2226+
static void ProfileInstancesOpInit(FoldingSetNodeID &ID, const RecTy *Type,
2227+
const Init *Regex) {
22282228
ID.AddPointer(Type);
22292229
ID.AddPointer(Regex);
22302230
}
22312231

2232-
const RecordsOpInit *RecordsOpInit::get(const RecTy *Type, const Init *Regex) {
2232+
const InstancesOpInit *InstancesOpInit::get(const RecTy *Type,
2233+
const Init *Regex) {
22332234
FoldingSetNodeID ID;
2234-
ProfileRecordsOpInit(ID, Type, Regex);
2235+
ProfileInstancesOpInit(ID, Type, Regex);
22352236

22362237
detail::RecordKeeperImpl &RK = Regex->getRecordKeeper().getImpl();
22372238
void *IP = nullptr;
2238-
if (const RecordsOpInit *I =
2239-
RK.TheRecordsOpInitPool.FindNodeOrInsertPos(ID, IP))
2239+
if (const InstancesOpInit *I =
2240+
RK.TheInstancesOpInitPool.FindNodeOrInsertPos(ID, IP))
22402241
return I;
22412242

2242-
RecordsOpInit *I = new (RK.Allocator) RecordsOpInit(Type, Regex);
2243-
RK.TheRecordsOpInitPool.InsertNode(I, IP);
2243+
InstancesOpInit *I = new (RK.Allocator) InstancesOpInit(Type, Regex);
2244+
RK.TheInstancesOpInitPool.InsertNode(I, IP);
22442245
return I;
22452246
}
22462247

2247-
void RecordsOpInit::Profile(FoldingSetNodeID &ID) const {
2248-
ProfileRecordsOpInit(ID, Type, Regex);
2248+
void InstancesOpInit::Profile(FoldingSetNodeID &ID) const {
2249+
ProfileInstancesOpInit(ID, Type, Regex);
22492250
}
22502251

2251-
const Init *RecordsOpInit::Fold() const {
2252+
const Init *InstancesOpInit::Fold() const {
22522253
const auto *RegexInit = dyn_cast<StringInit>(Regex);
22532254
if (!RegexInit)
22542255
return this;
@@ -2267,19 +2268,20 @@ const Init *RecordsOpInit::Fold() const {
22672268
return ListInit::get(Selected, Type);
22682269
}
22692270

2270-
const Init *RecordsOpInit::resolveReferences(Resolver &R) const {
2271+
const Init *InstancesOpInit::resolveReferences(Resolver &R) const {
22712272
const Init *NewRegex = Regex->resolveReferences(R);
22722273
if (Regex != NewRegex)
22732274
return get(Type, NewRegex)->Fold();
22742275
return this;
22752276
}
22762277

2277-
const Init *RecordsOpInit::getBit(unsigned Bit) const {
2278+
const Init *InstancesOpInit::getBit(unsigned Bit) const {
22782279
return VarBitInit::get(this, Bit);
22792280
}
22802281

2281-
std::string RecordsOpInit::getAsString() const {
2282-
return "!records<" + Type->getAsString() + ">(" + Regex->getAsString() + ")";
2282+
std::string InstancesOpInit::getAsString() const {
2283+
return "!instances<" + Type->getAsString() + ">(" + Regex->getAsString() +
2284+
")";
22832285
}
22842286

22852287
const RecTy *TypedInit::getFieldType(const StringInit *FieldName) const {

llvm/lib/TableGen/TGLexer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -629,10 +629,10 @@ tgtok::TokKind TGLexer::LexExclaim() {
629629
.Case("listsplat", tgtok::XListSplat)
630630
.Case("listremove", tgtok::XListRemove)
631631
.Case("range", tgtok::XRange)
632-
.Case("records", tgtok::XRecords)
633632
.Case("strconcat", tgtok::XStrConcat)
634633
.Case("initialized", tgtok::XInitialized)
635634
.Case("interleave", tgtok::XInterleave)
635+
.Case("instances", tgtok::XInstances)
636636
.Case("substr", tgtok::XSubstr)
637637
.Case("find", tgtok::XFind)
638638
.Cases("setdagop", "setop", tgtok::XSetDagOp) // !setop is deprecated.

llvm/lib/TableGen/TGLexer.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ enum TokKind {
137137
XSize,
138138
XEmpty,
139139
XInitialized,
140+
XInstances,
140141
XIf,
141142
XCond,
142143
XEq,
@@ -154,7 +155,6 @@ enum TokKind {
154155
XToLower,
155156
XToUpper,
156157
XRange,
157-
XRecords,
158158
XGetDagArg,
159159
XGetDagName,
160160
XSetDagArg,

llvm/lib/TableGen/TGParser.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1455,16 +1455,16 @@ const Init *TGParser::ParseOperation(Record *CurRec, const RecTy *ItemType) {
14551455
return (ExistsOpInit::get(Type, Expr))->Fold(CurRec);
14561456
}
14571457

1458-
case tgtok::XRecords: {
1459-
// Value ::= !records '<' Type '>' '(' Regex? ')'
1458+
case tgtok::XInstances: {
1459+
// Value ::= !instances '<' Type '>' '(' Regex? ')'
14601460
Lex.Lex(); // eat the operation.
14611461

14621462
const RecTy *Type = ParseOperatorType();
14631463
if (!Type)
14641464
return nullptr;
14651465

14661466
if (!consume(tgtok::l_paren)) {
1467-
TokError("expected '(' after type of !records");
1467+
TokError("expected '(' after type of !instances");
14681468
return nullptr;
14691469
}
14701470

@@ -1476,13 +1476,13 @@ const Init *TGParser::ParseOperation(Record *CurRec, const RecTy *ItemType) {
14761476

14771477
const auto *RegexType = dyn_cast<TypedInit>(Regex);
14781478
if (!RegexType) {
1479-
Error(RegexLoc, "expected string type argument in !records operator");
1479+
Error(RegexLoc, "expected string type argument in !instances operator");
14801480
return nullptr;
14811481
}
14821482

14831483
const auto *SType = dyn_cast<StringRecTy>(RegexType->getType());
14841484
if (!SType) {
1485-
Error(RegexLoc, "expected string type argument in !records operator");
1485+
Error(RegexLoc, "expected string type argument in !instances operator");
14861486
return nullptr;
14871487
}
14881488
} else {
@@ -1491,11 +1491,11 @@ const Init *TGParser::ParseOperation(Record *CurRec, const RecTy *ItemType) {
14911491
}
14921492

14931493
if (!consume(tgtok::r_paren)) {
1494-
TokError("expected ')' in !records");
1494+
TokError("expected ')' in !instances");
14951495
return nullptr;
14961496
}
14971497

1498-
return RecordsOpInit::get(Type, Regex)->Fold();
1498+
return InstancesOpInit::get(Type, Regex)->Fold();
14991499
}
15001500

15011501
case tgtok::XConcat:

llvm/test/TableGen/records.td

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -12,49 +12,49 @@ class B : A;
1212
def b0 : B;
1313
def b1 : B;
1414

15-
def records_A {
16-
list<A> records = !records<A>();
15+
def instances_A {
16+
list<A> instances = !instances<A>();
1717
}
1818

19-
def records_A_x0 {
20-
list<A> records = !records<A>(".*0");
19+
def instances_A_x0 {
20+
list<A> instances = !instances<A>(".*0");
2121
}
2222

23-
def records_A_x1 {
24-
list<A> records = !records<A>(".*1");
23+
def instances_A_x1 {
24+
list<A> instances = !instances<A>(".*1");
2525
}
2626

27-
def records_B {
28-
list<B> records = !records<B>();
27+
def instances_B {
28+
list<B> instances = !instances<B>();
2929
}
3030

31-
// CHECK-LABEL: def records_A {
32-
// CHECK-NEXT: list<A> records = [a0, a1, b0, b1];
31+
// CHECK-LABEL: def instances_A {
32+
// CHECK-NEXT: list<A> instances = [a0, a1, b0, b1];
3333
// CHECK-NEXT: }
3434

35-
// CHECK-LABEL: def records_A_x0 {
36-
// CHECK-NEXT: list<A> records = [a0, b0];
35+
// CHECK-LABEL: def instances_A_x0 {
36+
// CHECK-NEXT: list<A> instances = [a0, b0];
3737
// CHECK-NEXT: }
3838

39-
// CHECK-LABEL: def records_A_x1 {
40-
// CHECK-NEXT: list<A> records = [a1, b1];
39+
// CHECK-LABEL: def instances_A_x1 {
40+
// CHECK-NEXT: list<A> instances = [a1, b1];
4141
// CHECK-NEXT: }
4242

43-
// CHECK-LABEL: def records_B {
44-
// CHECK-NEXT: list<B> records = [b0, b1];
43+
// CHECK-LABEL: def instances_B {
44+
// CHECK-NEXT: list<B> instances = [b0, b1];
4545
// CHECK-NEXT: }
4646

4747
#ifdef ERROR1
48-
defvar error1 = !records<A>(123)
49-
// ERROR1: error: expected string type argument in !records operator
48+
defvar error1 = !instances<A>(123)
49+
// ERROR1: error: expected string type argument in !instances operator
5050
#endif
5151

5252
#ifdef ERROR2
53-
defvar error2 = !records<1>("")
53+
defvar error2 = !instances<1>("")
5454
// ERROR2: error: Unknown token when expecting a type
5555
#endif
5656

5757
#ifdef ERROR3
58-
defvar error3 = !records<A>("([)]")
58+
defvar error3 = !instances<A>("([)]")
5959
// ERROR3: error: invalid regex '([)]'
6060
#endif

0 commit comments

Comments
 (0)