@@ -176,7 +176,7 @@ class SharedActionSelectorCheck : public Inspector {
176
176
177
177
auto key = table->getKey ();
178
178
Input input;
179
- for (auto ke : * key->keyElements ) {
179
+ for (auto ke : key->keyElements ) {
180
180
auto mt = refMap->getDeclaration (ke->matchType ->path , true )->to <IR::Declaration_ID>();
181
181
BUG_CHECK (mt != nullptr , " %1%: could not find declaration" , ke->matchType );
182
182
if (mt->name .name != v1model.selectorMatchType .name ) continue ;
@@ -631,7 +631,7 @@ class ExpressionConverter : public Inspector {
631
631
return ;
632
632
}
633
633
634
- for (auto e : * expression->components ) {
634
+ for (auto e : expression->components ) {
635
635
auto t = get (e);
636
636
result->append (t);
637
637
}
@@ -813,16 +813,16 @@ cstring JsonConverter::createCalculation(cstring algo, const IR::Expression* fie
813
813
calc->emplace (" algo" , algo);
814
814
if (!fields->is <IR::ListExpression>()) {
815
815
// expand it into a list
816
- auto vec = new IR::Vector<IR::Expression>( );
816
+ auto list = new IR::ListExpression ({} );
817
817
auto type = typeMap->getType (fields, true );
818
818
BUG_CHECK (type->is <IR::Type_StructLike>(), " %1%: expected a struct" , fields);
819
- for (auto f : * type->to <IR::Type_StructLike>()->fields ) {
819
+ for (auto f : type->to <IR::Type_StructLike>()->fields ) {
820
820
auto e = new IR::Member (fields, f->name );
821
821
auto ftype = typeMap->getType (f);
822
822
typeMap->setType (e, ftype);
823
- vec ->push_back (e);
823
+ list ->push_back (e);
824
824
}
825
- fields = new IR::ListExpression (vec) ;
825
+ fields = list ;
826
826
typeMap->setType (fields, type);
827
827
}
828
828
auto jright = conv->convert (fields);
@@ -838,8 +838,8 @@ JsonConverter::convertActionBody(const IR::Vector<IR::StatOrDecl>* body,
838
838
for (auto s : *body) {
839
839
if (!s->is <IR::Statement>()) {
840
840
continue ;
841
- } else if (s->is <IR::BlockStatement>()) {
842
- convertActionBody (s-> to <IR::BlockStatement>() ->components , result, fieldLists,
841
+ } else if (auto block = s->to <IR::BlockStatement>()) {
842
+ convertActionBody (&block ->components , result, fieldLists,
843
843
calculations, learn_lists);
844
844
continue ;
845
845
} else if (s->is <IR::ReturnStatement>()) {
@@ -982,7 +982,7 @@ JsonConverter::convertActionBody(const IR::Vector<IR::StatOrDecl>* body,
982
982
if (ef->method ->name == v1model.clone .name ) {
983
983
BUG_CHECK (mc->arguments ->size () == 2 , " Expected 2 arguments for %1%" , mc);
984
984
cstring name = refMap->newName (" fl" );
985
- auto emptylist = new IR::ListExpression (new IR::Vector<IR::Expression>() );
985
+ auto emptylist = new IR::ListExpression ({} );
986
986
id = createFieldList (emptylist, " field_lists" , name, fieldLists);
987
987
} else {
988
988
BUG_CHECK (mc->arguments ->size () == 3 , " Expected 3 arguments for %1%" , mc);
@@ -1117,7 +1117,7 @@ JsonConverter::convertActionBody(const IR::Vector<IR::StatOrDecl>* body,
1117
1117
void JsonConverter::addToFieldList (const IR::Expression* expr, Util::JsonArray* fl) {
1118
1118
if (expr->is <IR::ListExpression>()) {
1119
1119
auto le = expr->to <IR::ListExpression>();
1120
- for (auto e : * le->components ) {
1120
+ for (auto e : le->components ) {
1121
1121
addToFieldList (e, fl);
1122
1122
}
1123
1123
return ;
@@ -1127,7 +1127,7 @@ void JsonConverter::addToFieldList(const IR::Expression* expr, Util::JsonArray*
1127
1127
if (type->is <IR::Type_StructLike>()) {
1128
1128
// recursively add all fields
1129
1129
auto st = type->to <IR::Type_StructLike>();
1130
- for (auto f : * st->fields ) {
1130
+ for (auto f : st->fields ) {
1131
1131
auto member = new IR::Member (expr, f->name );
1132
1132
typeMap->setType (member, typeMap->getType (f, true ));
1133
1133
addToFieldList (member, fl);
@@ -1197,7 +1197,7 @@ Util::JsonArray* JsonConverter::createActions(Util::JsonArray* fieldLists,
1197
1197
params->append (param);
1198
1198
}
1199
1199
auto body = mkArrayField (jact, " primitives" );
1200
- convertActionBody (action->body ->components , body, fieldLists, calculations, learn_lists);
1200
+ convertActionBody (& action->body ->components , body, fieldLists, calculations, learn_lists);
1201
1201
result->append (jact);
1202
1202
}
1203
1203
return result;
@@ -1246,15 +1246,15 @@ void JsonConverter::convertTableEntries(const IR::P4Table *table,
1246
1246
1247
1247
auto entries = mkArrayField (jsonTable, " entries" );
1248
1248
int entryPriority = 1 ; // default priority is defined by index position
1249
- for (auto e : * entriesList->entries ) {
1249
+ for (auto e : entriesList->entries ) {
1250
1250
auto entry = new Util::JsonObject ();
1251
1251
1252
1252
auto keyset = e->getKeys ();
1253
1253
auto matchKeys = mkArrayField (entry, " match_key" );
1254
1254
int keyIndex = 0 ;
1255
- for (auto k : * keyset->components ) {
1255
+ for (auto k : keyset->components ) {
1256
1256
auto key = new Util::JsonObject ();
1257
- auto tableKey = table->getKey ()->keyElements -> at (keyIndex);
1257
+ auto tableKey = table->getKey ()->keyElements . at (keyIndex);
1258
1258
auto keyWidth = tableKey->expression ->type ->width_bits ();
1259
1259
auto k8 = ROUNDUP (keyWidth, 8 );
1260
1260
auto matchType = getKeyMatchType (tableKey);
@@ -1418,7 +1418,7 @@ bool JsonConverter::handleTableImplementation(const IR::Property* implementation
1418
1418
selector->emplace (" algo" , algo);
1419
1419
}
1420
1420
auto input = mkArrayField (selector, " input" );
1421
- for (auto ke : * key->keyElements ) {
1421
+ for (auto ke : key->keyElements ) {
1422
1422
auto mt = refMap->getDeclaration (ke->matchType ->path , true )
1423
1423
->to <IR::Declaration_ID>();
1424
1424
BUG_CHECK (mt != nullptr , " %1%: could not find declaration" , ke->matchType );
@@ -1532,7 +1532,7 @@ JsonConverter::convertTable(const CFG::TableNode* node,
1532
1532
conv->simpleExpressionsOnly = true ;
1533
1533
1534
1534
if (key != nullptr ) {
1535
- for (auto ke : * key->keyElements ) {
1535
+ for (auto ke : key->keyElements ) {
1536
1536
auto match_type = getKeyMatchType (ke);
1537
1537
if (match_type == v1model.selectorMatchType .name )
1538
1538
continue ;
@@ -1740,7 +1740,7 @@ JsonConverter::convertTable(const CFG::TableNode* node,
1740
1740
auto al = table->getActionList ();
1741
1741
1742
1742
std::map<cstring, cstring> useActionName;
1743
- for (auto a : * al->actionList ) {
1743
+ for (auto a : al->actionList ) {
1744
1744
if (a->expression ->is <IR::MethodCallExpression>()) {
1745
1745
auto mce = a->expression ->to <IR::MethodCallExpression>();
1746
1746
if (mce->arguments ->size () > 0 )
@@ -1804,7 +1804,7 @@ JsonConverter::convertTable(const CFG::TableNode* node,
1804
1804
// Generate labels which don't show up and send them to
1805
1805
// the nextLabel.
1806
1806
if (!hitMiss) {
1807
- for (auto a : * al->actionList ) {
1807
+ for (auto a : al->actionList ) {
1808
1808
cstring name = a->getName ().name ;
1809
1809
cstring label = ::get (useActionName, name);
1810
1810
if (labelsDone.find (label) == labelsDone.end ())
@@ -1914,7 +1914,7 @@ Util::IJson* JsonConverter::convertControl(const IR::ControlBlock* block, cstrin
1914
1914
}
1915
1915
}
1916
1916
1917
- for (auto c : * cont->controlLocals ) {
1917
+ for (auto c : cont->controlLocals ) {
1918
1918
if (c->is <IR::Declaration_Constant>() ||
1919
1919
c->is <IR::Declaration_Variable>() ||
1920
1920
c->is <IR::P4Action>() ||
@@ -2077,7 +2077,7 @@ unsigned JsonConverter::nextId(cstring group) {
2077
2077
}
2078
2078
2079
2079
void JsonConverter::addHeaderStacks (const IR::Type_Struct* headersStruct) {
2080
- for (auto f : * headersStruct->fields ) {
2080
+ for (auto f : headersStruct->fields ) {
2081
2081
auto ft = typeMap->getType (f, true );
2082
2082
auto stack = ft->to <IR::Type_Stack>();
2083
2083
if (stack == nullptr )
@@ -2381,7 +2381,7 @@ void JsonConverter::createForceArith(const IR::Type* meta, cstring name,
2381
2381
if (!meta->is <IR::Type_Struct>())
2382
2382
return ;
2383
2383
auto st = meta->to <IR::Type_StructLike>();
2384
- for (auto f : * st->fields ) {
2384
+ for (auto f : st->fields ) {
2385
2385
auto field = pushNewArray (force);
2386
2386
field->append (name);
2387
2387
field->append (f->name .name );
@@ -2392,7 +2392,7 @@ void JsonConverter::generateUpdate(const IR::BlockStatement *block,
2392
2392
Util::JsonArray* checksums, Util::JsonArray* calculations) {
2393
2393
// Currently this is very hacky to target the very limited support for checksums in BMv2
2394
2394
// This will work much better when BMv2 offers a checksum extern.
2395
- for (auto stat : * block->components ) {
2395
+ for (auto stat : block->components ) {
2396
2396
if (stat->is <IR::IfStatement>()) {
2397
2397
// The way checksums work in Json, they always ignore the condition!
2398
2398
stat = stat->to <IR::IfStatement>()->ifTrue ;
@@ -2438,7 +2438,7 @@ void JsonConverter::generateUpdate(const IR::P4Control* updateControl,
2438
2438
}
2439
2439
2440
2440
void JsonConverter::addTypesAndInstances (const IR::Type_StructLike* type, bool meta) {
2441
- for (auto f : * type->fields ) {
2441
+ for (auto f : type->fields ) {
2442
2442
auto ft = typeMap->getType (f, true );
2443
2443
if (ft->is <IR::Type_StructLike>()) {
2444
2444
// The headers struct can not contain nested structures.
@@ -2451,7 +2451,7 @@ void JsonConverter::addTypesAndInstances(const IR::Type_StructLike* type, bool m
2451
2451
}
2452
2452
}
2453
2453
2454
- for (auto f : * type->fields ) {
2454
+ for (auto f : type->fields ) {
2455
2455
auto ft = typeMap->getType (f, true );
2456
2456
if (ft->is <IR::Type_StructLike>()) {
2457
2457
auto json = new Util::JsonObject ();
@@ -2492,7 +2492,7 @@ void JsonConverter::addTypesAndInstances(const IR::Type_StructLike* type, bool m
2492
2492
2493
2493
void JsonConverter::pushFields (cstring prefix, const IR::Type_StructLike *st,
2494
2494
Util::JsonArray *fields) {
2495
- for (auto f : * st->fields ) {
2495
+ for (auto f : st->fields ) {
2496
2496
auto ftype = typeMap->getType (f, true );
2497
2497
if (ftype->to <IR::Type_StructLike>()) {
2498
2498
BUG (" %1%: nested structure" , st);
@@ -2545,8 +2545,8 @@ void JsonConverter::convertDeparserBody(const IR::Vector<IR::StatOrDecl>* body,
2545
2545
Util::JsonArray* result) {
2546
2546
conv->simpleExpressionsOnly = true ;
2547
2547
for (auto s : *body) {
2548
- if (s->is <IR::BlockStatement>()) {
2549
- convertDeparserBody (s-> to <IR::BlockStatement>() ->components , result);
2548
+ if (auto block = s->to <IR::BlockStatement>()) {
2549
+ convertDeparserBody (&block ->components , result);
2550
2550
continue ;
2551
2551
} else if (s->is <IR::ReturnStatement>() || s->is <IR::ExitStatement>()) {
2552
2552
break ;
@@ -2596,7 +2596,7 @@ Util::IJson* JsonConverter::convertDeparser(const IR::P4Control* ctrl) {
2596
2596
result->emplace (" name" , " deparser" ); // at least in simple_router this name is hardwired
2597
2597
result->emplace (" id" , nextId (" deparser" ));
2598
2598
auto order = mkArrayField (result, " order" );
2599
- convertDeparserBody (ctrl->body ->components , order);
2599
+ convertDeparserBody (& ctrl->body ->components , order);
2600
2600
return result;
2601
2601
}
2602
2602
@@ -2607,7 +2607,7 @@ Util::IJson* JsonConverter::toJson(const IR::P4Parser* parser) {
2607
2607
result->emplace (" init_state" , IR::ParserState::start);
2608
2608
auto states = mkArrayField (result, " parse_states" );
2609
2609
2610
- for (auto state : * parser->states ) {
2610
+ for (auto state : parser->states ) {
2611
2611
auto json = toJson (state);
2612
2612
if (json != nullptr )
2613
2613
states->append (json);
@@ -2758,15 +2758,15 @@ unsigned JsonConverter::combine(const IR::Expression* keySet,
2758
2758
return totalWidth;
2759
2759
} else if (keySet->is <IR::ListExpression>()) {
2760
2760
auto le = keySet->to <IR::ListExpression>();
2761
- BUG_CHECK (le->components -> size () == select ->components -> size (),
2761
+ BUG_CHECK (le->components . size () == select ->components . size (),
2762
2762
" %1%: mismatched select" , select );
2763
2763
unsigned index = 0 ;
2764
2764
2765
2765
bool noMask = true ;
2766
- for (auto it = select ->components -> begin ();
2767
- it != select ->components -> end (); ++it) {
2766
+ for (auto it = select ->components . begin ();
2767
+ it != select ->components . end (); ++it) {
2768
2768
auto e = *it;
2769
- auto keyElement = le->components -> at (index );
2769
+ auto keyElement = le->components . at (index );
2770
2770
2771
2771
auto type = typeMap->getType (e, true );
2772
2772
int width = type->width_bits ();
@@ -2790,9 +2790,9 @@ unsigned JsonConverter::combine(const IR::Expression* keySet,
2790
2790
mask = -1 ;
2791
2791
return totalWidth;
2792
2792
} else {
2793
- BUG_CHECK (select ->components -> size () == 1 , " %1%: mismatched select/label" , select );
2793
+ BUG_CHECK (select ->components . size () == 1 , " %1%: mismatched select/label" , select );
2794
2794
convertSimpleKey (keySet, value, mask);
2795
- auto type = typeMap->getType (select ->components -> at (0 ), true );
2795
+ auto type = typeMap->getType (select ->components . at (0 ), true );
2796
2796
return type->width_bits () / 8 ;
2797
2797
}
2798
2798
}
@@ -2816,7 +2816,7 @@ Util::IJson* JsonConverter::toJson(const IR::ParserState* state) {
2816
2816
result->emplace (" name" , extVisibleName (state));
2817
2817
result->emplace (" id" , nextId (" parse_states" ));
2818
2818
auto operations = mkArrayField (result, " parser_ops" );
2819
- for (auto s : * state->components ) {
2819
+ for (auto s : state->components ) {
2820
2820
auto j = convertParserStatement (s);
2821
2821
operations->append (j);
2822
2822
}
0 commit comments