P4C
The P4 Compiler
Loading...
Searching...
No Matches
normalize_params.h
1
19#ifndef _MIDEND_NORMALIZE_PARAMS_H_
20#define _MIDEND_NORMALIZE_PARAMS_H_
21
22#include "backends/tofino/bf-p4c/midend/type_checker.h"
23#include "frontends/common/resolveReferences/referenceMap.h"
24#include "frontends/p4/typeMap.h"
25#include "ir/ir.h"
26
65// TODO: Rather than producing an error, it would be better to rewrite the
66// conflicting user-supplied instance names.
67class NormalizeParams : public Modifier {
70 using Renaming = ordered_map<const IR::Parameter *, cstring>;
71 ordered_map<const IR::Node *, Renaming> renaming;
72
73 Modifier::profile_t init_apply(const IR::Node *root) override;
74 bool preorder(IR::P4Parser *parser) override;
75 bool preorder(IR::P4Control *control) override;
76
77 public:
78 explicit NormalizeParams(const IR::ToplevelBlock *) {}
79};
80
87class RenameArchParams : public PassManager {
88 const IR::ToplevelBlock *toplevel;
89
90 public:
92 auto evaluator = new BFN::EvaluatorPass(refMap, typeMap);
93 auto eval =
94 new VisitFunctor([this, evaluator]() { toplevel = evaluator->getToplevelBlock(); });
95 passes.push_back(eval);
96 passes.push_back(new NormalizeParams(toplevel));
97 }
98};
99
100#endif /* _MIDEND_NORMALIZE_PARAMS_H_ */
Definition normalize_params.h:67
Definition evaluator.h:115
Class used to encode maps from paths to declarations.
Definition referenceMap.h:66
Definition typeMap.h:41
Pass that governs replacement of the user-supplied parameter names with the corresponding parameter n...
Definition normalize_params.h:87