17#ifndef BACKENDS_UBPF_UBPFMODEL_H_
18#define BACKENDS_UBPF_UBPFMODEL_H_
20#include "frontends/common/model.h"
21#include "frontends/p4/coreLibrary.h"
23#include "ir/pass_manager.h"
24#include "lib/cstring.h"
32 : Elem(
"Pipeline"_cs), parser(
"prs"_cs), control(
"p"_cs), deparser(
"dprs"_cs) {}
41 : Extern_Model(
"Register"_cs),
45 initial_value(
"initial_value"_cs),
70 : CPacketName(
"pkt"_cs),
71 packet(
"packet"_cs, P4::P4CoreLibrary::instance().packetIn, 0),
74 drop(
"mark_to_drop"_cs),
75 pass(
"mark_to_pass"_cs),
76 ubpf_time_get_ns(
"ubpf_time_get_ns"_cs),
77 truncate(
"truncate"_cs),
78 csum_replace2(
"csum_replace2"_cs),
79 csum_replace4(
"csum_replace4"_cs),
99 unsigned version = 20200515;
101 static cstring reserved(
cstring name) {
return reservedPrefix + name; }
103 int numberOfParserArguments()
const {
return version >= 20200515 ? 4 : 3; }
104 int numberOfControlBlockArguments()
const {
return version >= 20200515 ? 3 : 2; }
107 bool preorder(
const IR::Declaration_Constant *dc)
override {
108 if (dc->name ==
"__ubpf_model_version") {
109 auto val = dc->initializer->to<IR::Constant>();
110 UBPFModel::instance.version =
static_cast<unsigned>(val->value);
114 bool preorder(
const IR::Declaration *)
override {
return false; }
117 const IR::P4Program *run(
const IR::P4Program *program) {
118 if (program ==
nullptr)
return nullptr;
124 passes.setName(
"UBPFFrontEnd");
125 passes.setStopOnError(
true);
126 const IR::P4Program *result = program->apply(passes);
Definition frontends/common/model.h:64
Definition ir/pass_manager.h:40
Definition ubpfModel.h:106
Definition ubpfModel.h:67
Definition frontends/common/model.h:28
Enum_Model : Type_Model.
Definition frontends/common/model.h:47
Extern_Model : Type_Model.
Definition frontends/common/model.h:52
Param_Model : Elem.
Definition frontends/common/model.h:57
Definition ubpfModel.h:57
Definition ubpfModel.h:63
Definition ubpfModel.h:30
Definition ubpfModel.h:39