19#ifndef BACKENDS_TOFINO_BF_P4C_ARCH_PSA_PSA_CONVERTERS_H_
20#define BACKENDS_TOFINO_BF_P4C_ARCH_PSA_PSA_CONVERTERS_H_
24#include "frontends/p4/cloner.h"
25#include "frontends/p4/coreLibrary.h"
27#include "lib/safe_vector.h"
28#include "programStructure.h"
40 CHECK_NULL(structure);
42 const IR::Expression *convert(
const IR::Node *node) {
43 auto result = node->apply(*
this);
44 return result->
to<IR::Expression>();
54 CHECK_NULL(structure);
56 const IR::Statement *convert(
const IR::Node *node) {
57 auto result = node->apply(*
this);
58 return result->
to<IR::Statement>();
68 CHECK_NULL(structure);
71 auto conv = node->apply(*
this);
79 CHECK_NULL(structure);
81 const IR::Node *postorder(IR::MethodCallExpression *node)
override;
87 CHECK_NULL(structure);
89 const IR::Node *postorder(IR::MethodCallExpression *node)
override;
95 CHECK_NULL(structure);
97 const IR::Node *postorder(IR::MethodCallExpression *node)
override;
104 template <
typename T>
106 auto *orig = getOriginal<T>();
107 if (structure->_map.count(orig)) {
108 auto result = structure->_map.at(orig);
116 CHECK_NULL(structure);
118 const IR::Node *postorder(IR::Declaration_Instance *decl)
override;
119 const IR::Node *postorder(IR::StatOrDecl *node)
override;
120 const IR::Node *postorder(IR::MethodCallExpression *node)
override;
121 const IR::P4Parser *convert(
const IR::Node *node) {
122 auto conv = node->apply(*
this);
123 auto result = conv->
to<IR::P4Parser>();
124 BUG_CHECK(result !=
nullptr,
"Conversion of %1% did not produce a parser", node);
132 CHECK_NULL(structure);
134 const IR::Node *postorder(IR::P4Parser *node)
override;
140 CHECK_NULL(structure);
149 template <
typename T>
151 auto *orig = getOriginal<T>();
152 if (structure->_map.count(orig)) {
153 auto result = structure->_map.at(orig);
161 CHECK_NULL(structure);
163 const IR::Node *postorder(IR::MethodCallExpression *node)
override;
164 const IR::Node *postorder(IR::Declaration_Instance *node)
override;
165 const IR::Node *postorder(IR::IfStatement *node)
override;
166 const IR::Node *postorder(IR::StatOrDecl *node)
override;
167 const IR::Node *postorder(IR::Property *node)
override;
168 const IR::Node *postorder(IR::Member *node)
override;
169 const IR::P4Control *convert(
const IR::Node *node) {
170 auto conv = node->apply(*
this);
171 auto result = conv->
to<IR::P4Control>();
172 BUG_CHECK(result !=
nullptr,
"Conversion of %1% did not produce a control", node);
180 CHECK_NULL(structure);
182 const IR::Node *postorder(IR::P4Control *node)
override;
188 CHECK_NULL(structure);
196 CHECK_NULL(structure);
198 const IR::Node *postorder(IR::P4Control *node)
override;
204 CHECK_NULL(structure);
206 const IR::Node *postorder(IR::P4Control *node)
override;
212 {
"PSA_HashAlgorithm_t"_cs, std::make_pair(
"HashAlgorithm_t"_cs,
false)},
213 {
"PSA_CounterType_t"_cs, std::make_pair(
"CounterType_t"_cs,
false)},
214 {
"PSA_MeterType_t"_cs, std::make_pair(
"MeterType_t"_cs,
false)},
215 {
"PSA_MeterColor_t"_cs, std::make_pair(
"MeterColor_t"_cs,
true)}};
222 CHECK_NULL(structure);
224 const IR::Node *postorder(IR::TypeNameExpression *node)
override;
225 const IR::Node *postorder(IR::Member *mem)
override;
233 {
"PSA_HashAlgorithm_t"_cs, std::make_pair(
"HashAlgorithm_t"_cs,
false)},
234 {
"PSA_CounterType_t"_cs, std::make_pair(
"CounterType_t"_cs,
false)},
235 {
"PSA_MeterType_t"_cs, std::make_pair(
"MeterType_t"_cs,
false)},
236 {
"PSA_MeterColor_t"_cs, std::make_pair(
"MeterColor_t"_cs,
true)}};
240 CHECK_NULL(structure);
242 const IR::Node *postorder(IR::Type_Name *node)
override;
248 CHECK_NULL(structure);
Definition psa_converters.h:145
Definition psa_converters.h:185
const IR::Node * postorder(IR::P4Control *node) override
Definition psa_converters.cpp:349
Definition psa_converters.h:201
Definition psa_converters.h:137
const IR::Node * postorder(IR::P4Parser *node) override
Definition psa_converters.cpp:212
Definition psa_converters.h:34
Definition psa_converters.h:62
Definition psa_converters.h:76
Definition psa_converters.h:177
Definition psa_converters.h:193
Definition psa_converters.h:129
Definition psa_converters.h:92
Definition psa_converters.h:100
Definition psa_converters.h:245
const IR::Node * postorder(IR::Member *node) override
map path expression
Definition psa_converters.cpp:631
Definition psa_converters.h:84
Definition psa_converters.h:48
Definition psa_converters.h:228
Definition psa_converters.h:209
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:99
T * to() noexcept
Definition rtti.h:226