P4C
The P4 Compiler
Loading...
Searching...
No Matches
tofino_model.h
1
19#ifndef BF_P4C_COMMON_TOFINO_MODEL_H_
20#define BF_P4C_COMMON_TOFINO_MODEL_H_
21
22#include "frontends/common/model.h"
23#include "frontends/p4/coreLibrary.h"
24#include "frontends/p4/methodInstance.h"
25#include "ir/ir.h"
26#include "lib/cstring.h"
27#include "lib/json.h"
28
29namespace P4 {
30
31using ::Model::Elem;
32using ::Model::Param_Model;
33using ::Model::Type_Model;
34
35struct IngressInMetadataType_Model : public ::Model::Type_Model {
37 : ::Model::Type_Model(name),
38 dropBit("drop"),
39 recirculate("recirculate_port"),
40 egress_spec("egress_spec") {}
41 ::Model::Elem dropBit;
42 ::Model::Elem recirculate;
43 ::Model::Elem egress_spec;
44};
45
46struct Ingress_Model : public ::Model::Elem {
47 Ingress_Model(cstring name, Model::Type_Model headersType, Model::Type_Model metadataType,
48 Model::Type_Model ingressInMetadataType, Model::Type_Model ingressOutMetadataType)
49 : Model::Elem(name),
50 headersParam("hdr", headersType, 0),
51 metadataParam("meta", metadataType, 1),
52 ingressInMetadataParam("mi", ingressInMetadataType, 2),
53 ingressOutMetadataParam("mo", ingressOutMetadataType, 3) {}
54 ::Model::Param_Model headersParam;
55 ::Model::Param_Model metadataParam;
56 ::Model::Param_Model ingressInMetadataParam;
57 ::Model::Param_Model ingressOutMetadataParam;
58};
59
60struct Egress_Model : public ::Model::Elem {
61 Egress_Model(cstring name, Model::Type_Model headersType, Model::Type_Model metadataType,
62 Model::Type_Model egressInMetadataType, Model::Type_Model egressOutMetadataType)
63 : Model::Elem(name),
64 headersParam("hdr", headersType, 0),
65 metadataParam("meta", metadataType, 1),
66 egressInMetadataParam("mi", egressInMetadataType, 2),
67 egressOutMetadataParam("mo", egressOutMetadataType, 3) {}
68 ::Model::Param_Model headersParam;
69 ::Model::Param_Model metadataParam;
70 ::Model::Param_Model egressInMetadataParam;
71 ::Model::Param_Model egressOutMetadataParam;
72};
73
74class TofinoModel : public ::Model::Model {
75 protected:
77 : Model::Model("0.1"),
78 headersType("headers"),
79 metadataType("metadata"),
80 ingressInMetadataType("ingress_in_metadata_t"),
81 ingressOutMetadataType("ingress_out_metadata_t"),
82 egressInMetadataType("egress_in_metadata_t"),
83 egressOutMetadataType("egress_out_metadata_t"),
84 ingress("ingress", headersType, metadataType, ingressInMetadataType,
85 ingressOutMetadataType),
86 egress("egress", headersType, metadataType, egressInMetadataType, egressOutMetadataType) {
87 }
88
89 public:
90 ::Model::Type_Model headersType;
91 ::Model::Type_Model metadataType;
92 IngressInMetadataType_Model ingressInMetadataType;
93 ::Model::Type_Model ingressOutMetadataType;
94 ::Model::Type_Model egressInMetadataType;
95 ::Model::Type_Model egressOutMetadataType;
96 Ingress_Model ingress;
97 Egress_Model egress;
98
99 static TofinoModel instance;
100};
101
102} // namespace P4
103
104#endif /* BF_P4C_COMMON_TOFINO_MODEL_H_ */
Definition frontends/common/model.h:64
Definition tofino_model.h:74
Definition cstring.h:85
TODO: this is not really specific to BMV2, it should reside somewhere else.
Definition applyOptionsPragmas.cpp:24
Definition tofino_model.h:60
Definition tofino_model.h:46
Definition tofino_model.h:35
Definition frontends/common/model.h:28
Definition frontends/common/model.h:42