@@ -894,7 +894,7 @@ Init *UnOpInit::Fold(Record *CurRec, bool IsFinal) const {
894
894
break ;
895
895
}
896
896
897
- DefInit *DI = DefInit::get (D );
897
+ DefInit *DI = D-> getDefInit ( );
898
898
if (!DI->getType ()->typeIsA (getType ())) {
899
899
PrintFatalErrorHelper (Twine (" Expected type '" ) +
900
900
getType ()->getAsString () + " ', got '" +
@@ -1682,7 +1682,7 @@ Init *TernOpInit::Fold(Record *CurRec) const {
1682
1682
Record *Val = RHSd->getDef ();
1683
1683
if (LHSd->getAsString () == RHSd->getAsString ())
1684
1684
Val = MHSd->getDef ();
1685
- return DefInit::get ( Val);
1685
+ return Val-> getDefInit ( );
1686
1686
}
1687
1687
if (LHSv && MHSv && RHSv) {
1688
1688
std::string Val = std::string (RHSv->getName ());
@@ -2083,7 +2083,7 @@ Init *ExistsOpInit::Fold(Record *CurRec, bool IsFinal) const {
2083
2083
if (D) {
2084
2084
// Check if types are compatible.
2085
2085
return IntInit::get (getRecordKeeper (),
2086
- DefInit::get (D )->getType ()->typeIsA (CheckType));
2086
+ D-> getDefInit ( )->getType ()->typeIsA (CheckType));
2087
2087
}
2088
2088
2089
2089
if (CurRec) {
@@ -2235,10 +2235,6 @@ Init *VarBitInit::resolveReferences(Resolver &R) const {
2235
2235
DefInit::DefInit (Record *D)
2236
2236
: TypedInit(IK_DefInit, D->getType ()), Def(D) {}
2237
2237
2238
- DefInit *DefInit::get (Record *R) {
2239
- return R->getDefInit ();
2240
- }
2241
-
2242
2238
Init *DefInit::convertInitializerTo (RecTy *Ty) const {
2243
2239
if (auto *RRT = dyn_cast<RecordRecTy>(Ty))
2244
2240
if (getType ()->typeIsConvertibleTo (RRT))
@@ -2290,64 +2286,62 @@ void VarDefInit::Profile(FoldingSetNodeID &ID) const {
2290
2286
}
2291
2287
2292
2288
DefInit *VarDefInit::instantiate () {
2293
- if (!Def) {
2294
- RecordKeeper &Records = Class->getRecords ();
2295
- auto NewRecOwner =
2296
- std::make_unique<Record>(Records.getNewAnonymousName (), Class->getLoc (),
2297
- Records, Record::RK_AnonymousDef);
2298
- Record *NewRec = NewRecOwner.get ();
2299
-
2300
- // Copy values from class to instance
2301
- for (const RecordVal &Val : Class->getValues ())
2302
- NewRec->addValue (Val);
2303
-
2304
- // Copy assertions from class to instance.
2305
- NewRec->appendAssertions (Class);
2306
-
2307
- // Copy dumps from class to instance.
2308
- NewRec->appendDumps (Class);
2309
-
2310
- // Substitute and resolve template arguments
2311
- ArrayRef<Init *> TArgs = Class->getTemplateArgs ();
2312
- MapResolver R (NewRec);
2313
-
2314
- for (Init *Arg : TArgs) {
2315
- R.set (Arg, NewRec->getValue (Arg)->getValue ());
2316
- NewRec->removeValue (Arg);
2317
- }
2318
-
2319
- for (auto *Arg : args ()) {
2320
- if (Arg->isPositional ())
2321
- R.set (TArgs[Arg->getIndex ()], Arg->getValue ());
2322
- if (Arg->isNamed ())
2323
- R.set (Arg->getName (), Arg->getValue ());
2324
- }
2289
+ if (Def)
2290
+ return Def;
2325
2291
2326
- NewRec->resolveReferences (R);
2292
+ RecordKeeper &Records = Class->getRecords ();
2293
+ auto NewRecOwner =
2294
+ std::make_unique<Record>(Records.getNewAnonymousName (), Class->getLoc (),
2295
+ Records, Record::RK_AnonymousDef);
2296
+ Record *NewRec = NewRecOwner.get ();
2327
2297
2328
- // Add superclasses.
2329
- ArrayRef<std::pair<Record *, SMRange>> SCs = Class->getSuperClasses ();
2330
- for (const auto &SCPair : SCs)
2331
- NewRec->addSuperClass (SCPair.first , SCPair.second );
2298
+ // Copy values from class to instance
2299
+ for (const RecordVal &Val : Class->getValues ())
2300
+ NewRec->addValue (Val);
2332
2301
2333
- NewRec->addSuperClass (Class,
2334
- SMRange (Class->getLoc ().back (),
2335
- Class->getLoc ().back ()));
2302
+ // Copy assertions from class to instance.
2303
+ NewRec->appendAssertions (Class);
2336
2304
2337
- // Resolve internal references and store in record keeper
2338
- NewRec->resolveReferences ();
2339
- Records.addDef (std::move (NewRecOwner));
2305
+ // Copy dumps from class to instance.
2306
+ NewRec->appendDumps (Class);
2340
2307
2341
- // Check the assertions.
2342
- NewRec->checkRecordAssertions ();
2308
+ // Substitute and resolve template arguments
2309
+ ArrayRef<Init *> TArgs = Class->getTemplateArgs ();
2310
+ MapResolver R (NewRec);
2343
2311
2344
- // Check the assertions.
2345
- NewRec->emitRecordDumps ();
2312
+ for (Init *Arg : TArgs) {
2313
+ R.set (Arg, NewRec->getValue (Arg)->getValue ());
2314
+ NewRec->removeValue (Arg);
2315
+ }
2346
2316
2347
- Def = DefInit::get (NewRec);
2317
+ for (auto *Arg : args ()) {
2318
+ if (Arg->isPositional ())
2319
+ R.set (TArgs[Arg->getIndex ()], Arg->getValue ());
2320
+ if (Arg->isNamed ())
2321
+ R.set (Arg->getName (), Arg->getValue ());
2348
2322
}
2349
2323
2350
- return Def;
2324
+ NewRec->resolveReferences (R);
2325
+
2326
+ // Add superclasses.
2327
+ ArrayRef<std::pair<Record *, SMRange>> SCs = Class->getSuperClasses ();
2328
+ for (const auto &SCPair : SCs)
2329
+ NewRec->addSuperClass (SCPair.first , SCPair.second );
2330
+
2331
+ NewRec->addSuperClass (
2332
+ Class, SMRange (Class->getLoc ().back (), Class->getLoc ().back ()));
2333
+
2334
+ // Resolve internal references and store in record keeper
2335
+ NewRec->resolveReferences ();
2336
+ Records.addDef (std::move (NewRecOwner));
2337
+
2338
+ // Check the assertions.
2339
+ NewRec->checkRecordAssertions ();
2340
+
2341
+ // Check the assertions.
2342
+ NewRec->emitRecordDumps ();
2343
+
2344
+ return Def = NewRec->getDefInit ();
2351
2345
}
2352
2346
2353
2347
Init *VarDefInit::resolveReferences (Resolver &R) const {
0 commit comments