P4C
The P4 Compiler
Loading...
Searching...
No Matches
tableKeyNames.h
1/*
2Copyright 2017 VMware, Inc.
3
4Licensed under the Apache License, Version 2.0 (the "License");
5you may not use this file except in compliance with the License.
6You may obtain a copy of the License at
7
8 http://www.apache.org/licenses/LICENSE-2.0
9
10Unless required by applicable law or agreed to in writing, software
11distributed under the License is distributed on an "AS IS" BASIS,
12WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13See the License for the specific language governing permissions and
14limitations under the License.
15*/
16
17#ifndef FRONTENDS_P4_TABLEKEYNAMES_H_
18#define FRONTENDS_P4_TABLEKEYNAMES_H_
19
20#include "frontends/p4/typeChecking/typeChecker.h"
21#include "frontends/p4/typeMap.h"
22#include "ir/ir.h"
23
24namespace P4 {
25
33 std::map<const IR::Expression *, cstring> name;
34 const TypeMap *typeMap; // can be nullptr
35
36 public:
37 explicit KeyNameGenerator(const TypeMap *typeMap) : typeMap(typeMap) {
38 setName("KeyNameGenerator");
39 }
40 void error(const IR::Expression *expression);
41 void postorder(const IR::Expression *expression) override;
42 void postorder(const IR::PathExpression *expression) override;
43 void postorder(const IR::Member *expression) override;
44 void postorder(const IR::ArrayIndex *expression) override;
45 void postorder(const IR::Constant *expression) override;
46 void postorder(const IR::Slice *expression) override;
47 void postorder(const IR::BAnd *expression) override;
48 void postorder(const IR::MethodCallExpression *expression) override;
49 cstring getName(const IR::Expression *expression) { return ::P4::get(name, expression); }
50};
51
79class DoTableKeyNames final : public Transform {
80 const TypeMap *typeMap;
81
82 public:
83 explicit DoTableKeyNames(const TypeMap *typeMap) : typeMap(typeMap) {
84 CHECK_NULL(typeMap);
85 setName("DoTableKeyNames");
86 }
87 const IR::Node *postorder(IR::KeyElement *keyElement) override;
88};
89
90class TableKeyNames final : public PassManager {
91 public:
92 explicit TableKeyNames(TypeMap *typeMap) {
93 passes.push_back(new TypeChecking(nullptr, typeMap));
94 passes.push_back(new DoTableKeyNames(typeMap));
95 setName("TableKeyNames");
96 }
97};
98
99} // namespace P4
100
101#endif /* FRONTENDS_P4_TABLEKEYNAMES_H_ */
Definition tableKeyNames.h:79
Definition node.h:94
Definition visitor.h:400
Definition tableKeyNames.h:32
Definition ir/pass_manager.h:40
Definition tableKeyNames.h:90
Definition visitor.h:424
Definition typeChecker.h:55
Definition typeMap.h:41
Definition cstring.h:85
TODO: this is not really specific to BMV2, it should reside somewhere else.
Definition applyOptionsPragmas.cpp:24