P4C
The P4 Compiler
Loading...
Searching...
No Matches
metermap.h
1/*
2 * SPDX-FileCopyrightText: 2013 Barefoot Networks, Inc.
3 * Copyright 2013-present Barefoot Networks, Inc.
4 *
5 * SPDX-License-Identifier: Apache-2.0
6 */
7
8#ifndef BACKENDS_COMMON_METERMAP_H_
9#define BACKENDS_COMMON_METERMAP_H_
10
11#include "ir/ir.h"
12
13namespace P4 {
14
15// TODO: This file should be in the BMv2 folder, but ProgramStructure still depends on it.
16class DirectMeterMap final {
17 public:
18 struct DirectMeterInfo {
19 const IR::Expression *destinationField;
20 const IR::P4Table *table;
21 unsigned tableSize;
22
23 DirectMeterInfo() : destinationField(nullptr), table(nullptr), tableSize(0) {}
24 };
25
26 private:
28 std::map<const IR::IDeclaration *, DirectMeterInfo *> directMeter;
29 DirectMeterInfo *createInfo(const IR::IDeclaration *meter);
30
31 public:
32 DirectMeterInfo *getInfo(const IR::IDeclaration *meter);
33 void setDestination(const IR::IDeclaration *meter, const IR::Expression *destination);
34 void setTable(const IR::IDeclaration *meter, const IR::P4Table *table);
35 void setSize(const IR::IDeclaration *meter, unsigned size);
36};
37
38} // namespace P4
39
40#endif /* BACKENDS_COMMON_METERMAP_H_ */
Definition metermap.h:16
void setSize(const IR::IDeclaration *meter, unsigned size)
Set the size of the table that a meter is attached to.
Definition metermap.cpp:69
void setDestination(const IR::IDeclaration *meter, const IR::Expression *destination)
Set the destination that a meter is attached to??
Definition metermap.cpp:52
void setTable(const IR::IDeclaration *meter, const IR::P4Table *table)
Set the table that a direct meter is attached to.
Definition metermap.cpp:23
The Declaration interface, representing objects with names.
Definition declaration.h:17
TODO: this is not really specific to BMV2, it should reside somewhere else.
Definition applyOptionsPragmas.cpp:13
Definition metermap.h:18