P4C
The P4 Compiler
Loading...
Searching...
No Matches
tofino/bf-p4c/arch/arch_spec.h
1
19#ifndef BACKENDS_TOFINO_BF_P4C_ARCH_ARCH_SPEC_H_
20#define BACKENDS_TOFINO_BF_P4C_ARCH_ARCH_SPEC_H_
21
22#include "backends/tofino/bf-p4c/ir/gress.h"
23#include "ir/ir.h"
24
26 public:
27 std::string name;
28 std::string asm_name;
29 explicit IntrinsicField(std::string n) : name(n), asm_name(n) {}
30 IntrinsicField(std::string n, std::string an) : name(n), asm_name(an) {}
31};
32
34 public:
35 std::string type;
36 std::string name;
37 IntrinsicParam(std::string t, std::string n) : type(t), name(n) {}
38};
39
47class ArchSpec {
48 protected:
49 std::vector<IntrinsicField> intrinsic_metadata[GRESS_T_COUNT];
50 std::vector<IntrinsicField> intrinsic_metadata_for_tm[GRESS_T_COUNT];
51 std::vector<IntrinsicField> intrinsic_metadata_from_parser[GRESS_T_COUNT];
52 std::vector<IntrinsicField> intrinsic_metadata_for_deparser[GRESS_T_COUNT];
53 std::vector<IntrinsicField> intrinsic_metadata_for_output_port[GRESS_T_COUNT];
54
55 std::vector<IntrinsicParam> parser_intrinsic_types[GRESS_T_COUNT];
56 std::vector<IntrinsicParam> mauppu_intrinsic_types[GRESS_T_COUNT];
57 std::vector<IntrinsicParam> deparser_intrinsic_types[GRESS_T_COUNT];
58
59 int deparser_intrinsic_metadata_for_deparser_param_index = -1;
60
61 public:
62 enum ArchType_t { TNA, T2NA };
63
64 ArchSpec();
65
66 std::vector<IntrinsicField> getIngressIntrinsicMetadata() const {
67 return intrinsic_metadata[INGRESS];
68 }
69
70 std::vector<IntrinsicField> getIngressInstrinicMetadataFromParser() const {
71 return intrinsic_metadata_from_parser[INGRESS];
72 }
73
74 std::vector<IntrinsicField> getIngressInstrinicMetadataForTM() const {
75 return intrinsic_metadata_for_tm[INGRESS];
76 }
77
78 std::vector<IntrinsicField> getIngressInstrinicMetadataForDeparser() const {
79 return intrinsic_metadata_for_deparser[INGRESS];
80 }
81
82 std::vector<IntrinsicField> getEgressIntrinsicMetadata() const {
83 return intrinsic_metadata[EGRESS];
84 }
85
86 std::vector<IntrinsicField> getEgressIntrinsicMetadataFromParser() const {
87 return intrinsic_metadata_from_parser[EGRESS];
88 }
89
90 std::vector<IntrinsicField> getEgressIntrinsicMetadataForTM() const {
91 return intrinsic_metadata_for_tm[EGRESS];
92 }
93
94 std::vector<IntrinsicField> getEgressIntrinsicMetadataForDeparser() const {
95 return intrinsic_metadata_for_deparser[EGRESS];
96 }
97
98 std::vector<IntrinsicField> getEgressIntrinsicMetadataForOutputPort() const {
99 return intrinsic_metadata_for_output_port[EGRESS];
100 }
101
102 void add_md(gress_t gress, IntrinsicField f) { intrinsic_metadata[gress].push_back(f); }
103
104 void add_tm_md(gress_t gress, IntrinsicField f) {
105 intrinsic_metadata_for_tm[gress].push_back(f);
106 }
107
108 void add_prsr_md(gress_t gress, IntrinsicField f) {
109 intrinsic_metadata_from_parser[gress].push_back(f);
110 }
111
112 void add_dprsr_md(gress_t gress, IntrinsicField f) {
113 intrinsic_metadata_for_deparser[gress].push_back(f);
114 }
115
116 void add_outport_md(gress_t gress, IntrinsicField f) {
117 intrinsic_metadata_for_output_port[gress].push_back(f);
118 }
119
120 std::vector<IntrinsicParam> getParserIntrinsicTypes(gress_t g) const {
121 return parser_intrinsic_types[g];
122 }
123
124 std::vector<IntrinsicParam> getMAUIntrinsicTypes(gress_t g) const {
125 return mauppu_intrinsic_types[g];
126 }
127
128 std::vector<IntrinsicParam> getPPUIntrinsicTypes(gress_t g) const {
129 return mauppu_intrinsic_types[g];
130 }
131
132 std::vector<IntrinsicParam> getDeparserIntrinsicTypes(gress_t g) const {
133 return deparser_intrinsic_types[g];
134 }
135
144 return deparser_intrinsic_metadata_for_deparser_param_index;
145 }
146
147 void setTofinoIntrinsicTypes();
148};
149
150class TofinoArchSpec : public ArchSpec {
151 public:
153};
154
155class JBayArchSpec : public ArchSpec {
156 public:
157 JBayArchSpec();
158};
159
160#endif /* BACKENDS_TOFINO_BF_P4C_ARCH_ARCH_SPEC_H_ */
Definition tofino/bf-p4c/arch/arch_spec.h:47
int getDeparserIntrinsicMetadataForDeparserParamIndex() const
Get the index of the intrinsic metadata for deparser parameter in the deparser.
Definition tofino/bf-p4c/arch/arch_spec.h:143
ArchSpec()
Definition tofino/bf-p4c/arch/arch_spec.cpp:21
Definition tofino/bf-p4c/arch/arch_spec.h:155
Definition tofino/bf-p4c/arch/arch_spec.h:150
Definition tofino/bf-p4c/arch/arch_spec.h:25
Definition tofino/bf-p4c/arch/arch_spec.h:33