Skip to content

Commit 4a922a2

Browse files
authored
Global rename Type_Stack -> Type_Array (#5337)
Signed-off-by: Chris Dodd <[email protected]>
1 parent e765cfe commit 4a922a2

File tree

85 files changed

+237
-237
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

85 files changed

+237
-237
lines changed

backends/bmv2/common/action.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ cstring ActionConverter::jsonAssignment(const IR::Type *type) {
2626
if (type->is<IR::Type_Varbits>()) return "assign_VL"_cs;
2727
if (type->is<IR::Type_HeaderUnion>()) return "assign_union"_cs;
2828
if (type->is<IR::Type_Header>() || type->is<IR::Type_Struct>()) return "assign_header"_cs;
29-
if (auto ts = type->to<IR::Type_Stack>()) {
29+
if (auto ts = type->to<IR::Type_Array>()) {
3030
auto et = ts->elementType;
3131
if (et->is<IR::Type_HeaderUnion>())
3232
return "assign_union_stack"_cs;
@@ -185,12 +185,12 @@ void ActionConverter::convertActionBody(const IR::Vector<IR::StatOrDecl> *body,
185185
prim = "add_header"_cs;
186186
} else if (builtin->name == IR::Type_Header::setInvalid) {
187187
prim = "remove_header"_cs;
188-
} else if (builtin->name == IR::Type_Stack::push_front) {
188+
} else if (builtin->name == IR::Type_Array::push_front) {
189189
BUG_CHECK(mc->arguments->size() == 1, "Expected 1 argument for %1%", mc);
190190
auto arg = ctxt->conv->convert(mc->arguments->at(0)->expression);
191191
prim = "push"_cs;
192192
parameters->append(arg);
193-
} else if (builtin->name == IR::Type_Stack::pop_front) {
193+
} else if (builtin->name == IR::Type_Array::pop_front) {
194194
BUG_CHECK(mc->arguments->size() == 1, "Expected 1 argument for %1%", mc);
195195
auto arg = ctxt->conv->convert(mc->arguments->at(0)->expression);
196196
prim = "pop"_cs;

backends/bmv2/common/expression.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ void ExpressionConverter::postorder(const IR::Member *expression) {
285285
return;
286286
}
287287
// convert normal parameters
288-
if (auto st = type->to<IR::Type_Stack>()) {
288+
if (auto st = type->to<IR::Type_Array>()) {
289289
auto et = typeMap->getTypeType(st->elementType, true);
290290
if (et->is<IR::Type_HeaderUnion>())
291291
result->emplace("type", "header_union_stack");
@@ -354,10 +354,10 @@ void ExpressionConverter::postorder(const IR::Member *expression) {
354354
if (expression->expr->is<IR::Member>()) {
355355
auto mem = expression->expr->to<IR::Member>();
356356
auto memtype = typeMap->getType(mem->expr, true);
357-
if (memtype->is<IR::Type_Stack>() && mem->member == IR::Type_Stack::next)
357+
if (memtype->is<IR::Type_Array>() && mem->member == IR::Type_Array::next)
358358
::P4::error(ErrorType::ERR_UNINITIALIZED, "%1% uninitialized: next field read", mem);
359359
// array.last.field => type: "stack_field", value: [ array, field ]
360-
if (memtype->is<IR::Type_Stack>() && mem->member == IR::Type_Stack::last) {
360+
if (memtype->is<IR::Type_Array>() && mem->member == IR::Type_Array::last) {
361361
auto l = get(mem->expr);
362362
if (!l) return;
363363
result->emplace("type", "stack_field");
@@ -391,8 +391,8 @@ void ExpressionConverter::postorder(const IR::Member *expression) {
391391
a->append(fieldName);
392392
result->emplace("value"_cs, a);
393393
}
394-
} else if (parentType->is<IR::Type_Stack>() &&
395-
expression->member == IR::Type_Stack::lastIndex) {
394+
} else if (parentType->is<IR::Type_Array>() &&
395+
expression->member == IR::Type_Array::lastIndex) {
396396
auto l = get(expression->expr);
397397
if (!l) return;
398398
result->emplace("type", "expression");
@@ -402,7 +402,7 @@ void ExpressionConverter::postorder(const IR::Member *expression) {
402402
e->emplace("left", Util::JsonValue::null);
403403
e->emplace("right", l);
404404
} else {
405-
const char *fieldRef = parentType->is<IR::Type_Stack>() ? "stack_field" : "field";
405+
const char *fieldRef = parentType->is<IR::Type_Array>() ? "stack_field" : "field";
406406
Util::JsonArray *e = nullptr;
407407
bool st = isArrayIndexRuntime(expression);
408408
if (!st) {
@@ -698,7 +698,7 @@ void ExpressionConverter::postorder(const IR::PathExpression *expression) {
698698
auto f = mkArrayField(r, "value"_cs);
699699
f->append(scalarsName);
700700
f->append(var->name);
701-
} else if (auto st = type->to<IR::Type_Stack>()) {
701+
} else if (auto st = type->to<IR::Type_Array>()) {
702702
auto et = typeMap->getTypeType(st->elementType, true);
703703
if (et->is<IR::Type_HeaderUnion>())
704704
result->emplace("type", "header_union_stack");

backends/bmv2/common/header.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ void HeaderConverter::addTypesAndInstances(const IR::Type_StructLike *type, bool
8080
BUG("Unexpected type %1%", ft);
8181
}
8282
}
83-
} else if (ft->is<IR::Type_Stack>()) {
83+
} else if (ft->is<IR::Type_Array>()) {
8484
// Done elsewhere
8585
LOG3("stack generation done elsewhere");
8686
continue;
@@ -140,7 +140,7 @@ void HeaderConverter::addHeaderStacks(const IR::Type_Struct *headersStruct) {
140140
LOG2("Creating stack " << headersStruct);
141141
for (auto f : headersStruct->fields) {
142142
auto ft = ctxt->typeMap->getType(f, true);
143-
auto stack = ft->to<IR::Type_Stack>();
143+
auto stack = ft->to<IR::Type_Array>();
144144
if (stack == nullptr) continue;
145145
auto stack_name = f->controlPlaneName();
146146
auto stack_size = stack->getSize();
@@ -178,7 +178,7 @@ void HeaderConverter::addHeaderStacks(const IR::Type_Struct *headersStruct) {
178178
bool HeaderConverter::isHeaders(const IR::Type_StructLike *st) {
179179
bool result = false;
180180
for (auto f : st->fields) {
181-
if (f->type->is<IR::Type_Header>() || f->type->is<IR::Type_Stack>()) {
181+
if (f->type->is<IR::Type_Header>() || f->type->is<IR::Type_Array>()) {
182182
result = true;
183183
}
184184
}
@@ -246,7 +246,7 @@ void HeaderConverter::addHeaderType(const IR::Type_StructLike *st) {
246246
field->append(32);
247247
field->append(false);
248248
max_length += 32;
249-
} else if (ftype->to<IR::Type_Stack>()) {
249+
} else if (ftype->to<IR::Type_Array>()) {
250250
BUG("%1%: nested stack", st);
251251
} else {
252252
BUG("%1%: unexpected type for %2%.%3%", ftype, st, f->name);
@@ -336,7 +336,7 @@ Visitor::profile_t HeaderConverter::init_apply(const IR::Node *node) {
336336
ctxt->json->add_metadata(metadata_type, v->name);
337337
}
338338
addHeaderType(st);
339-
} else if (auto stack = type->to<IR::Type_Stack>()) {
339+
} else if (auto stack = type->to<IR::Type_Array>()) {
340340
auto type = ctxt->typeMap->getTypeType(stack->elementType, true);
341341
if (type->is<IR::Type_Header>()) {
342342
auto ht = type->to<IR::Type_Header>();

backends/bmv2/common/parser.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ namespace P4::BMV2 {
2828
cstring ParserConverter::jsonAssignment(const IR::Type *type) {
2929
if (type->is<IR::Type_HeaderUnion>()) return "assign_union"_cs;
3030
if (type->is<IR::Type_Header>() || type->is<IR::Type_Struct>()) return "assign_header"_cs;
31-
if (auto ts = type->to<IR::Type_Stack>()) {
31+
if (auto ts = type->to<IR::Type_Array>()) {
3232
auto et = ts->elementType;
3333
if (et->is<IR::Type_HeaderUnion>())
3434
return "assign_union_stack"_cs;
@@ -151,8 +151,8 @@ Util::IJson *ParserConverter::convertParserStatement(const IR::StatOrDecl *stat)
151151

152152
if (auto mem = arg->expression->to<IR::Member>()) {
153153
auto baseType = ctxt->typeMap->getType(mem->expr, true);
154-
if (baseType->is<IR::Type_Stack>()) {
155-
if (mem->member == IR::Type_Stack::next) {
154+
if (baseType->is<IR::Type_Array>()) {
155+
if (mem->member == IR::Type_Array::next) {
156156
// stack.next
157157
type = "stack"_cs;
158158
j = ctxt->conv->convert(mem->expr);
@@ -163,9 +163,9 @@ Util::IJson *ParserConverter::convertParserStatement(const IR::StatOrDecl *stat)
163163
auto parent = mem->expr->to<IR::Member>();
164164
if (parent != nullptr) {
165165
auto parentType = ctxt->typeMap->getType(parent->expr, true);
166-
if (parentType->is<IR::Type_Stack>()) {
166+
if (parentType->is<IR::Type_Array>()) {
167167
// stack.next.unionfield
168-
if (parent->member == IR::Type_Stack::next) {
168+
if (parent->member == IR::Type_Array::next) {
169169
type = "union_stack"_cs;
170170
j = ctxt->conv->convert(parent->expr);
171171
Util::JsonArray *a;
@@ -308,9 +308,9 @@ Util::IJson *ParserConverter::convertParserStatement(const IR::StatOrDecl *stat)
308308
primitive = "add_header"_cs;
309309
} else if (bi->name == IR::Type_Header::setInvalid) {
310310
primitive = "remove_header"_cs;
311-
} else if (bi->name == IR::Type_Stack::push_front ||
312-
bi->name == IR::Type_Stack::pop_front) {
313-
if (bi->name == IR::Type_Stack::push_front)
311+
} else if (bi->name == IR::Type_Array::push_front ||
312+
bi->name == IR::Type_Array::pop_front) {
313+
if (bi->name == IR::Type_Array::push_front)
314314
primitive = "push"_cs;
315315
else
316316
primitive = "pop"_cs;

backends/bmv2/pna_nic/pnaProgramStructure.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,9 +105,9 @@ void InspectPnaProgram::addTypesAndInstances(const IR::Type_StructLike *type, bo
105105
pinfo->metadata_types.emplace(type->getName(), type->to<IR::Type_Struct>());
106106
addHeaderInstance(type, f->controlPlaneName());
107107
}
108-
} else if (ft->is<IR::Type_Stack>()) {
109-
LOG5("Field is Type_Stack " << ft->toString());
110-
auto stack = ft->to<IR::Type_Stack>();
108+
} else if (ft->is<IR::Type_Array>()) {
109+
LOG5("Field is Type_Array " << ft->toString());
110+
auto stack = ft->to<IR::Type_Array>();
111111
// auto stack_name = f->controlPlaneName();
112112
auto stack_size = stack->getSize();
113113
auto type = typeMap->getTypeType(stack->elementType, true);

backends/bmv2/portable_common/portable.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ void PortableCodeGenerator::createStructLike(ConversionContext *ctxt, const IR::
6060
field->append(error_width);
6161
field->append(false);
6262
max_length += error_width;
63-
} else if (ftype->to<IR::Type_Stack>()) {
63+
} else if (ftype->to<IR::Type_Array>()) {
6464
BUG("%1%: nested stack", st);
6565
} else {
6666
BUG("%1%: unexpected type for %2%.%3%", ftype, st, f->name);

backends/bmv2/simple_switch/simpleSwitch.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1143,7 +1143,7 @@ void SimpleSwitchBackend::convert(const IR::ToplevelBlock *tlb) {
11431143
LOG2("Headers type is " << st);
11441144
for (auto f : st->fields) {
11451145
auto t = typeMap->getType(f, true);
1146-
if (!t->is<IR::Type_Header>() && !t->is<IR::Type_Stack>() &&
1146+
if (!t->is<IR::Type_Header>() && !t->is<IR::Type_Array>() &&
11471147
!t->is<IR::Type_HeaderUnion>()) {
11481148
::P4::error(ErrorType::ERR_EXPECTED,
11491149
"%1%: the type should be a struct of headers, stacks, or unions",

backends/common/portableProgramStructure.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ using namespace P4::literals;
2323
bool InspectPortableProgram::isHeaders(const IR::Type_StructLike *st) {
2424
bool result = false;
2525
for (auto f : st->fields) {
26-
if (f->type->is<IR::Type_Header>() || f->type->is<IR::Type_Stack>()) {
26+
if (f->type->is<IR::Type_Header>() || f->type->is<IR::Type_Array>()) {
2727
result = true;
2828
}
2929
}

backends/common/psaProgramStructure.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,9 +106,9 @@ void InspectPsaProgram::addTypesAndInstances(const IR::Type_StructLike *type, bo
106106
pinfo->metadata_types.emplace(type->getName(), type->to<IR::Type_Struct>());
107107
addHeaderInstance(type, f->controlPlaneName());
108108
}
109-
} else if (ft->is<IR::Type_Stack>()) {
110-
LOG5("Field is Type_Stack " << ft->toString());
111-
auto stack = ft->to<IR::Type_Stack>();
109+
} else if (ft->is<IR::Type_Array>()) {
110+
LOG5("Field is Type_Array " << ft->toString());
111+
auto stack = ft->to<IR::Type_Array>();
112112
// auto stack_name = f->controlPlaneName();
113113
auto stack_size = stack->getSize();
114114
auto type = typeMap->getTypeType(stack->elementType, true);

backends/dpdk/dpdkProgramStructure.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ bool ParseDpdkArchitecture::preorder(const IR::PackageBlock *block) {
121121
bool InspectDpdkProgram::isHeaders(const IR::Type_StructLike *st) {
122122
bool result = false;
123123
for (auto f : st->fields) {
124-
if (f->type->is<IR::Type_Header>() || f->type->is<IR::Type_Stack>()) {
124+
if (f->type->is<IR::Type_Header>() || f->type->is<IR::Type_Array>()) {
125125
result = true;
126126
}
127127
}
@@ -203,9 +203,9 @@ void InspectDpdkProgram::addTypesAndInstances(const IR::Type_StructLike *type, b
203203
structure->metadata_types.emplace(type->getName(), type->to<IR::Type_Struct>());
204204
addHeaderInstance(type, f->controlPlaneName());
205205
}
206-
} else if (ft->is<IR::Type_Stack>()) {
207-
LOG5("Field is Type_Stack " << ft->toString());
208-
auto stack = ft->to<IR::Type_Stack>();
206+
} else if (ft->is<IR::Type_Array>()) {
207+
LOG5("Field is Type_Array " << ft->toString());
208+
auto stack = ft->to<IR::Type_Array>();
209209
auto stack_size = stack->getSize();
210210
auto type = typeMap->getTypeType(stack->elementType, true);
211211
BUG_CHECK(type->is<IR::Type_Header>(), "%1% not a header type", stack->elementType);

0 commit comments

Comments
 (0)