P4C
The P4 Compiler
Loading...
Searching...
No Matches
param_binding.h
1
19#ifndef _MIDEND_PARAM_BINDING_H_
20#define _MIDEND_PARAM_BINDING_H_
21
22#include <map>
23
24#include "ir/ir.h"
25
26namespace P4 {
27class TypeMap;
28} // namespace P4
29
32class ParamBinding : public Inspector {
33 const P4::TypeMap *typeMap;
34 bool isV1;
35 std::map<const IR::Type *, const IR::InstanceRef *> by_type;
36 std::map<const IR::Parameter *, const IR::InstanceRef *> by_param;
37 std::map<const IR::Declaration_Variable *, const IR::InstanceRef *> by_declvar;
38
39 public:
40 explicit ParamBinding(const P4::TypeMap *typeMap, bool isV1 = false)
41 : typeMap(typeMap), isV1(isV1) {}
42
44 void bind(const IR::Parameter *param);
45
48 void bind(const IR::Declaration_Variable *var);
49
52 const IR::InstanceRef *get(const IR::Parameter *param) const {
53 return by_param.count(param) ? by_param.at(param) : nullptr;
54 }
55
58 const IR::InstanceRef *get(const IR::Declaration_Variable *var) const {
59 return by_declvar.count(var) ? by_declvar.at(var) : nullptr;
60 }
61
63 void postorder(const IR::Parameter *param);
64
67 void postorder(const IR::Declaration_Variable *var);
68};
69
70#endif /* _MIDEND_PARAM_BINDING_H_ */
Definition typeMap.h:41
Definition param_binding.h:32
const IR::InstanceRef * get(const IR::Parameter *param) const
Definition param_binding.h:52
void bind(const IR::Parameter *param)
Add a new header or metadata instance bound to the given parameter.
Definition param_binding.cpp:23
const IR::InstanceRef * get(const IR::Declaration_Variable *var) const
Definition param_binding.h:58
void postorder(const IR::Parameter *param)
Add a new header or metadata instance bound to the given parameter.
Definition param_binding.cpp:46
TODO: this is not really specific to BMV2, it should reside somewhere else.
Definition applyOptionsPragmas.cpp:24