P4C
The P4 Compiler
Loading...
Searching...
No Matches
backends/tofino/bf-p4c/arch/psa/programStructure.h
1
19#ifndef BACKENDS_TOFINO_BF_P4C_ARCH_PSA_PROGRAMSTRUCTURE_H_
20#define BACKENDS_TOFINO_BF_P4C_ARCH_PSA_PROGRAMSTRUCTURE_H_
21
22#include "bf-p4c/arch/program_structure.h"
23#include "bf-p4c/arch/psa/psa_model.h"
24#include "bf-p4c/ir/gress.h"
25#include "bf-p4c/midend/path_linearizer.h"
26#include "bf-p4c/midend/type_categories.h"
27#include "frontends/common/resolveReferences/resolveReferences.h"
28#include "frontends/p4/evaluator/evaluator.h"
29#include "ir/ir.h"
30#include "ir/namemap.h"
31#include "lib/ordered_set.h"
32#include "midend/eliminateSerEnums.h"
33
34namespace BFN {
35
36namespace PSA {
37
38// structure to describe the info related to resubmit/clone/recirc/bridge in a PSA program
42
45
48
50 bool exists = false;
51
54
57
60 const IR::Type *p4Type = nullptr;
61 const IR::Type *structType = nullptr;
62 // the statements in deparser to emit resubmit/clone/recir metadata, in PSA, the emit
63 // is represented with assignments to out parameter in the deparser block.
64 // the source typically has the following code pattern.
65 // if (psa_resubmit(istd)) {
66 // resub_meta = user_meta.resub_meta;
67 // }
68 const IR::IfStatement *ifStatement = nullptr;
69
71};
72
74
76 ParamInfo psaParams;
77};
78
79enum PSA_TYPES {
80 TYPE_IH = 0,
81 TYPE_IM,
82 TYPE_EH,
83 TYPE_EM,
84 TYPE_NM,
85 TYPE_CI2EM,
86 TYPE_CE2EM,
87 TYPE_RESUBM,
88 TYPE_RECIRCM,
89 PSA_TOTAL_TYPES
90};
91
92static const cstring INP_INTR_MD = "__psa_inp_intrinsic_md__"_cs;
93static const cstring OUT_INTR_MD = "__psa_out_intrinsic_md__"_cs;
94static const cstring IG_INP_INTR_MD_TYPE = "psa_ingress_input_metadata_t"_cs;
95static const cstring EG_INP_INTR_MD_TYPE = "psa_egress_input_metadata_t"_cs;
96static const cstring IG_OUT_INTR_MD_TYPE = "psa_ingress_output_metadata_t"_cs;
97static const cstring EG_OUT_INTR_MD_TYPE = "psa_egress_output_metadata_t"_cs;
98
100 cstring type_params[PSA_TOTAL_TYPES];
101
102 PsaModel &psa_model;
103
105
106 const IR::Type *metadataType = nullptr;
107
108 PacketPathInfo resubmit;
109 PacketPathInfo clone_i2e;
110 PacketPathInfo clone_e2e;
111 PacketPathInfo recirculate;
112 PacketPathInfo bridge;
113
114 PsaBlockInfo ingress_parser;
115 PsaBlockInfo ingress;
116 PsaBlockInfo ingress_deparser;
117 PsaBlockInfo egress_parser;
118 PsaBlockInfo egress;
119 PsaBlockInfo egress_deparser;
120
121 void createParsers() override;
122 void createControls() override;
123 void createMain() override;
124 void createPipeline();
125 std::map<cstring, int> error_to_constant;
126
127 std::map<gress_t, std::map<cstring, const IR::MethodCallExpression *>> state_to_verify;
128
129 // Vector of bridge field assignment in deparser in PSA. These will be moved to ingress
130 // control later
131 std::vector<IR::AssignmentStatement *> bridgeFieldAssignments;
132 const IR::P4Program *create(const IR::P4Program *program) override;
133 void loadModel();
134
135 ProgramStructure() : BFN::ProgramStructure(), psa_model(PsaModel::instance) {}
136};
137
138} // namespace PSA
139
140} // namespace BFN
141
142#endif /* BACKENDS_TOFINO_BF_P4C_ARCH_PSA_PROGRAMSTRUCTURE_H_ */
Definition psa_model.h:449
Definition backends/common/programStructure.h:32
Definition cstring.h:85
Definition ordered_map.h:32
The namespace encapsulating Barefoot/Intel-specific stuff.
Definition add_t2na_meta.cpp:21
Definition backends/tofino/bf-p4c/arch/psa/programStructure.h:39
ordered_map< cstring, cstring > dstParams
Map arch-defined param name to user-defined name in dest block.
Definition backends/tofino/bf-p4c/arch/psa/programStructure.h:56
cstring paramNameInDeparser
The name of the metadata in egress deparser param.
Definition backends/tofino/bf-p4c/arch/psa/programStructure.h:44
bool exists
If packet path exists.
Definition backends/tofino/bf-p4c/arch/psa/programStructure.h:50
ordered_map< cstring, cstring > srcParams
Map user-defined name to arch-defined param name in source block.
Definition backends/tofino/bf-p4c/arch/psa/programStructure.h:53
cstring generatedName
name in compiler_generated_meta
Definition backends/tofino/bf-p4c/arch/psa/programStructure.h:47
const IR::Type * p4Type
Definition backends/tofino/bf-p4c/arch/psa/programStructure.h:60
cstring paramNameInParser
The name of the metadata in ingress parser param.
Definition backends/tofino/bf-p4c/arch/psa/programStructure.h:41
Definition backends/tofino/bf-p4c/arch/psa/programStructure.h:99
Definition backends/tofino/bf-p4c/arch/psa/programStructure.h:75