P4C
The P4 Compiler
Loading...
Searching...
No Matches
bmv2/common/metermap.h
1/*
2Copyright 2013-present Barefoot Networks, 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 BACKENDS_BMV2_COMMON_METERMAP_H_
18#define BACKENDS_BMV2_COMMON_METERMAP_H_
19
20#include "ir/ir.h"
21
22namespace BMV2 {
23
24class DirectMeterMap final {
25 public:
27 const IR::Expression *destinationField;
28 const IR::P4Table *table;
29 unsigned tableSize;
30
31 DirectMeterInfo() : destinationField(nullptr), table(nullptr), tableSize(0) {}
32 };
33
34 private:
36 std::map<const IR::IDeclaration *, DirectMeterInfo *> directMeter;
37 DirectMeterInfo *createInfo(const IR::IDeclaration *meter);
38
39 public:
40 DirectMeterInfo *getInfo(const IR::IDeclaration *meter);
41 void setDestination(const IR::IDeclaration *meter, const IR::Expression *destination);
42 void setTable(const IR::IDeclaration *meter, const IR::P4Table *table);
43 void setSize(const IR::IDeclaration *meter, unsigned size);
44};
45
46} // namespace BMV2
47
48#endif /* BACKENDS_BMV2_COMMON_METERMAP_H_ */
Definition bmv2/common/metermap.h:24
void setDestination(const IR::IDeclaration *meter, const IR::Expression *destination)
Set the destination that a meter is attached to??
Definition bmv2/common/metermap.cpp:63
void setTable(const IR::IDeclaration *meter, const IR::P4Table *table)
Set the table that a direct meter is attached to.
Definition bmv2/common/metermap.cpp:34
void setSize(const IR::IDeclaration *meter, unsigned size)
Set the size of the table that a meter is attached to.
Definition bmv2/common/metermap.cpp:80
The Declaration interface, representing objects with names.
Definition declaration.h:26
TODO: this is not really specific to BMV2, it should reside somewhere else.
Definition action.cpp:21
Definition bmv2/common/metermap.h:26