P4C
The P4 Compiler
Loading...
Searching...
No Matches
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_COMMON_METERMAP_H_
18#define BACKENDS_COMMON_METERMAP_H_
19
20#include "ir/ir.h"
21
22namespace P4 {
23
24// TODO: This file should be in the BMv2 folder, but ProgramStructure still depends on it.
25class DirectMeterMap final {
26 public:
28 const IR::Expression *destinationField;
29 const IR::P4Table *table;
30 unsigned tableSize;
31
32 DirectMeterInfo() : destinationField(nullptr), table(nullptr), tableSize(0) {}
33 };
34
35 private:
37 std::map<const IR::IDeclaration *, DirectMeterInfo *> directMeter;
38 DirectMeterInfo *createInfo(const IR::IDeclaration *meter);
39
40 public:
41 DirectMeterInfo *getInfo(const IR::IDeclaration *meter);
42 void setDestination(const IR::IDeclaration *meter, const IR::Expression *destination);
43 void setTable(const IR::IDeclaration *meter, const IR::P4Table *table);
44 void setSize(const IR::IDeclaration *meter, unsigned size);
45};
46
47} // namespace P4
48
49#endif /* BACKENDS_COMMON_METERMAP_H_ */
Definition metermap.h:25
void setSize(const IR::IDeclaration *meter, unsigned size)
Set the size of the table that a meter is attached to.
Definition metermap.cpp:80
void setDestination(const IR::IDeclaration *meter, const IR::Expression *destination)
Set the destination that a meter is attached to??
Definition metermap.cpp:63
void setTable(const IR::IDeclaration *meter, const IR::P4Table *table)
Set the table that a direct meter is attached to.
Definition metermap.cpp:34
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 applyOptionsPragmas.cpp:24
Definition metermap.h:27