62 IR::BFN::Deparser *dprsr =
nullptr;
67 std::set<ordered_set<cstring> *> userEnforcedHeaderOrdering;
69 void generateEmits(
const IR::MethodCallExpression *mc);
70 void generateDigest(IR::BFN::Digest *&digest,
cstring name,
const IR::Expression *list,
71 const IR::Expression *select,
int digest_index,
72 cstring controlPlaneName =
nullptr);
73 void convertConcatToList(std::vector<const IR::Expression *> &slices,
const IR::Concat *expr);
76 std::tuple<int, const IR::Expression *> getDigestIndex(
const IR::IfStatement *,
cstring name,
77 bool singleEntry =
false);
78 int getDigestIndex(
const IR::Declaration_Instance *);
79 void processMirrorEmit(
const IR::MethodCallExpression *,
const IR::Expression *,
int idx);
80 void processMirrorEmit(
const IR::MethodCallExpression *,
int idx);
81 void processResubmitEmit(
const IR::MethodCallExpression *,
const IR::Expression *,
int idx);
82 void processResubmitEmit(
const IR::MethodCallExpression *,
int idx);
83 void processDigestPack(
const IR::MethodCallExpression *,
int,
cstring);
84 void enforceHeaderOrdering();
87 IR::ID getTnaParamName(
const IR::BFN::TnaDeparser *deparser,
IR::ID orig_name);
89 bool preorder(
const IR::Annotation *annot)
override;
90 bool preorder(
const IR::AssignmentStatement *stmt)
override;
91 void postorder(
const IR::MethodCallExpression *mc)
override;
92 void end_apply()
override;
96 : typeMap(typeMap), refMap(refMap), rv(rv) {
97 setName(
"ExtractDeparser");
100 bool preorder(
const IR::BFN::TnaDeparser *deparser)
override {
101 gress_t thread = deparser->thread;
102 dprsr =
new IR::BFN::Deparser(thread);
107 void postorder(
const IR::BFN::TnaDeparser *deparser)
override {
108 for (
const auto &kv : digests) {
109 auto name = kv.first;
110 auto digest = kv.second;
111 if (!digest)
continue;
112 for (
auto fieldList : digest->fieldLists) {
113 if (fieldList->idx < 0 ||
114 fieldList->idx >
static_cast<int>(Device::maxCloneId(deparser->thread))) {
115 error(
"Invalid %1% index %2% in %3%", name, fieldList->idx,
116 int(deparser->thread));
120 rv->thread[deparser->thread].deparser = dprsr;
126 const IR::Type *left =
nullptr;
130 void postorder(
const IR::MethodCallExpression *methodCall)
override {
131 auto member = methodCall->method->to<IR::Member>();
132 auto expr = member->expr->to<IR::PathExpression>();
134 const IR::Type_Extern *type =
nullptr;
135 if (
auto spType = expr->type->to<IR::Type_SpecializedCanonical>()) {
136 type = spType->baseType->to<IR::Type_Extern>();
138 type = expr->type->to<IR::Type_Extern>();
141 if (type->name !=
"Mirror" && type->name !=
"Digest" && type->name !=
"Resubmit") {
144 auto arguments = *methodCall->arguments;
145 for (
auto argument : arguments) {
146 if (argument->expression->type->equiv(*left)) {
TODO: this is not really specific to BMV2, it should reside somewhere else.
Definition applyOptionsPragmas.cpp:24
void error(const char *format, Args &&...args)
Report an error with the given message.
Definition lib/error.h:51