17#ifndef BACKENDS_DPDK_DPDKHELPERS_H_
18#define BACKENDS_DPDK_DPDKHELPERS_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"
34#include "midend/removeComplexExpressions.h"
36#define TOSTR_DECLA(NAME) std::ostream &toStr(std::ostream &, IR::NAME *)
40class ConvertStatementToDpdk;
51const char DirectResourceTableEntryIndex[] =
"table_entry_index";
124 if (n->
is<IR::LAnd>() || n->
is<IR::LOr>()) {
139 void postorder(
const IR::Type_Varbits *type)
override {
140 LOG3(
"Validating Type_Varbits: " << type);
141 if (type->size % 8 != 0) {
142 ::P4::error(ErrorType::ERR_UNSUPPORTED,
"%1% varbit width (%2%) not aligned to 8 bits",
143 type->srcInfo, type->size);
153 const IR::P4Parser *parser =
nullptr;
155 IR::Type_Struct *metadataStruct =
nullptr;
156 bool createSandboxHeaderType =
false;
157 bool createTmpVar =
false;
161 bool checkIfBelongToSameHdrMdStructure(
const IR::Argument *field);
163 cstring getHdrMdStrName(
const IR::Member *mem);
164 bool checkIfConsecutiveHdrMdfields(
const IR::Argument *field);
165 void createSandboxHeader();
166 void createTmpVarForSandbox();
172 : typemap(typemap), refmap(refmap), structure(structure) {
173 visitDagOnce =
false;
177 : typemap(typemap), refmap(refmap), structure(structure), metadataStruct(metadataStruct) {
178 visitDagOnce =
false;
181 void branchingInstructionGeneration(
cstring true_label,
cstring false_label,
182 const IR::Expression *expr);
183 bool preorder(
const IR::AssignmentStatement *a)
override;
184 bool preorder(
const IR::IfStatement *a)
override;
185 bool preorder(
const IR::MethodCallStatement *a)
override;
186 bool preorder(
const IR::SwitchStatement *a)
override;
188 void add_instr(
const IR::DpdkAsmStatement *s) { instructions.push_back(s); }
190 void process_logical_operation(
const IR::Expression *,
const IR::Operation_Binary *);
193 void set_parser(
const IR::P4Parser *p) { parser = p; }
194 void set_parent(
const IR::Node *p) { parent = p; }
195 bool handleConstSwitch(
const IR::SwitchStatement *a);
196 bool checkIf128bitOp(
const IR::Expression *,
const IR::Expression *);
197 void add128bitwiseInstr(
const IR::Expression *src1Op,
const IR::Expression *src2Op,
199 void add128ComparisonInstr(
cstring true_label,
const IR::Expression *src1Op,
200 const IR::Expression *src2Op,
const char *op);
201 void add128bitComplInstr(
const IR::Expression *,
const IR::Expression *);
205 const std::set<cstring> *process;
208 explicit ProcessControls(
const std::set<cstring> *process) : process(process) {
211 bool convert(
const IR::P4Control *control)
const {
212 if (process->find(control->name) != process->end())
return true;
Definition dpdkHelpers.h:119
bool generate(const IR::Expression *, cstring, cstring, bool)
Definition dpdkHelpers.cpp:815
Definition dpdkHelpers.h:148
void process_relation_operation(const IR::Expression *, const IR::Operation_Relation *)
Definition dpdkHelpers.cpp:31
bool preorder(const IR::AssignmentStatement *a) override
Definition dpdkHelpers.cpp:124
Only simplify complex expression in ingress/egress.
Definition dpdkHelpers.h:204
bool convert(const IR::P4Control *control) const
Definition dpdkHelpers.h:211
Definition dpdkHelpers.h:138
Class used to encode maps from paths to declarations.
Definition referenceMap.h:66
Definition removeComplexExpressions.h:30
Definition dpdk/backend.cpp:37
const char PnaMainOutputMetadataOutputPortName[]
Name of the metadata used as output port.
Definition dpdkHelpers.h:50
const IR::Expression * convert(const IR::Expression *expression, const IR::Type *type)
Definition structInitializers.cpp:26
void error(const char *format, Args &&...args)
Report an error with the given message.
Definition lib/error.h:51
Collect information related to P4 programs targeting dpdk.
Definition dpdkProgramStructure.h:16
bool is() const noexcept
Definition rtti.h:216