17#ifndef BACKENDS_DPDK_DPDKPROGRAM_H_
18#define BACKENDS_DPDK_DPDKPROGRAM_H_
21#include "dpdkProgramStructure.h"
22#include "frontends/common/constantFolding.h"
23#include "frontends/common/resolveReferences/referenceMap.h"
24#include "frontends/p4/coreLibrary.h"
25#include "frontends/p4/enumInstance.h"
26#include "frontends/p4/evaluator/evaluator.h"
27#include "frontends/p4/methodInstance.h"
28#include "frontends/p4/simplify.h"
29#include "frontends/p4/typeMap.h"
30#include "frontends/p4/unusedDeclarations.h"
32#include "lib/big_int_util.h"
45 const IR::DpdkAsmProgram *dpdk_program;
50 : typemap(typemap), refmap(refmap), structure(structure), options(options) {}
52 const IR::DpdkAsmProgram *create(IR::P4Program *prog);
57 const IR::Node *preorder(IR::P4Program *p)
override;
58 const IR::DpdkAsmProgram *getDpdkProgram() {
return dpdk_program; }
60 IR::Type_Struct *metadata);
68 IR::Type_Struct *metadataStruct;
73 : refmap(refmap), typemap(typemap), structure(structure), metadataStruct(metadataStruct) {}
76 bool preorder(
const IR::P4Parser *a)
override;
77 bool preorder(
const IR::ParserState *s)
override;
78 void add_instr(
const IR::DpdkAsmStatement *s) { instructions.push_back(s); }
80 IR::Declaration_Variable *addNewTmpVarToMetadata(
cstring name,
const IR::Type *type);
81 void handleTupleExpression(
const IR::ListExpression *cl,
const IR::ListExpression *input,
83 void getCondVars(
const IR::Expression *sv,
const IR::Expression *ce, IR::Expression **leftExpr,
84 IR::Expression **rightExpr);
91 IR::Type_Struct *metadataStruct;
97 std::set<cstring> unique_actions;
103 bool deparser =
false)
106 structure(structure),
107 metadataStruct(metadataStruct),
108 deparser(deparser) {}
116 bool preorder(
const IR::P4Action *a)
override;
117 bool preorder(
const IR::P4Table *a)
override;
118 bool preorder(
const IR::P4Control *)
override;
121 void add_inst(
const IR::DpdkAsmStatement *s) { instructions.push_back(s); }
122 void add_table(
const IR::DpdkTable *t) { tables.push_back(t); }
123 void add_table(
const IR::DpdkSelector *s) { selectors.push_back(s); }
124 void add_table(
const IR::DpdkLearner *s) { learners.push_back(s); }
125 void add_action(
const IR::DpdkAction *a) { actions.push_back(a); }
127 std::optional<const IR::Member *> getMemExprFromProperty(
const IR::P4Table *,
cstring);
128 std::optional<int> getNumberFromProperty(
const IR::P4Table *,
cstring);
136 bool preorder(
const IR::ActionListElement *ale) {
137 if (
auto mce = ale->expression->to<IR::MethodCallExpression>()) {
138 if (
auto path = mce->method->to<IR::PathExpression>()) {
139 if (path->path->name.originalName ==
"NoAction")
140 actions.insert(
"NoAction"_cs);
142 actions.insert(path->path->name.name);
151 std::set<cstring> kept_actions;
155 const IR::Node *postorder(IR::DpdkAction *a)
override {
156 if (kept_actions.count(a->name.name) != 0)
return nullptr;
157 if (used_actions.find(a->name.name) != used_actions.end()) {
158 kept_actions.insert(a->name.name);
Definition dpdkProgram.h:131
Definition dpdkProgram.h:87
bool checkTableValid(const IR::P4Table *a)
Definition dpdkProgram.cpp:518
Definition dpdkProgram.h:63
void getCondVars(const IR::Expression *sv, const IR::Expression *ce, IR::Expression **leftExpr, IR::Expression **rightExpr)
Definition dpdkProgram.cpp:276
Definition dpdkProgram.h:40
IR::IndexedVector< IR::DpdkStructType > UpdateHeaderMetadata(IR::P4Program *prog, IR::Type_Struct *metadata)
Definition dpdkProgram.cpp:30
Definition backends/dpdk/options.h:24
Definition dpdkProgram.h:149
Definition dpdkProgram.h:168
Definition ir/pass_manager.h:40
Class used to encode maps from paths to declarations.
Definition referenceMap.h:66
Definition ordered_set.h:32
Definition dpdk/backend.cpp:37
Collect information related to P4 programs targeting dpdk.
Definition dpdkProgramStructure.h:16