P4C
The P4 Compiler
Loading...
Searching...
No Matches
desugar_varbit_extract.h
1
100#ifndef BF_P4C_MIDEND_DESUGAR_VARBIT_EXTRACT_H_
101#define BF_P4C_MIDEND_DESUGAR_VARBIT_EXTRACT_H_
102
103#include "backends/tofino/bf-p4c/common/utils.h"
104#include "backends/tofino/bf-p4c/midend/type_checker.h"
105#include "frontends/common/resolveReferences/referenceMap.h"
106#include "frontends/p4/cloner.h"
107#include "ir/ir.h"
108
109namespace BFN {
110
115 IR::Node *preorder(IR::ParserState *state) override {
116 for (const auto *component : state->components) {
117 const auto *statement = component->to<IR::MethodCallStatement>();
118 if (!statement) continue;
119 const IR::MethodCallExpression *call = statement->methodCall;
120 if (!call) continue;
121 const auto *method = call->method->to<IR::Member>();
122 if (!method) continue;
123
124 if (method->member == "extract" && call->arguments->size() == 2) {
125 IR::Annotations *annotations = state->annotations->clone();
126 annotations->add(new IR::Annotation(IR::ID("dontmerge"), {}));
127 state->annotations = annotations;
128 break;
129 }
130 }
131 return state;
132 }
133};
134
144 public:
146};
147
153 public:
154 explicit DesugarVarbitExtract(P4::ReferenceMap *refMap, P4::TypeMap *typeMap);
155};
156
157} // namespace BFN
158
159#endif /* BF_P4C_MIDEND_DESUGAR_VARBIT_EXTRACT_H_ */
Definition node.h:94
Definition ir/pass_manager.h:40
Class used to encode maps from paths to declarations.
Definition referenceMap.h:66
Definition visitor.h:424
Definition typeMap.h:41
Definition desugar_varbit_extract.h:114
Checks that varbit accesses in pipeline are valid.
Definition desugar_varbit_extract.h:143
Top level PassManager that governs the rewrite of varbit usage.
Definition desugar_varbit_extract.h:152
The namespace encapsulating Barefoot/Intel-specific stuff.
Definition add_t2na_meta.cpp:21
Definition id.h:28