P4C
The P4 Compiler
Loading...
Searching...
No Matches
adjust_byte_count.h
1
19#ifndef BACKENDS_TOFINO_BF_P4C_MAU_ADJUST_BYTE_COUNT_H_
20#define BACKENDS_TOFINO_BF_P4C_MAU_ADJUST_BYTE_COUNT_H_
21
22#include "backends/tofino/bf-p4c/logging/pass_manager.h"
23#include "backends/tofino/bf-p4c/mau/mau_visitor.h"
24namespace BFN {
25
26using namespace P4;
27
28// This pass sets up the adjust byte count value on a counter or a meter.
29// It first scans the IR for any counter/meter extern objects and checks if
30// their respective methods (count/execute) have an 'adjust_byte_count'
31// argument. For all method calls for the same counter/meter the argument value
32// is verified to be the same. This is required the counter/meter can only set a
33// single value as adjust byte count. Post verification the value is stored in
34// the extern object
36 std::map<const IR::MAU::AttachedMemory *, const int64_t> adjust_byte_counts;
37
38 class Scan : public MauInspector {
40
41 public:
42 explicit Scan(AdjustByteCountSetup &self) : self(self) {}
43 bool preorder(const IR::MAU::Primitive *prim) override;
44 };
45
46 class Update : public MauTransform {
48
49 public:
50 int get_bytecount(IR::MAU::AttachedMemory *am);
51 const IR::MAU::Counter *preorder(IR::MAU::Counter *counter) override;
52 const IR::MAU::Meter *preorder(IR::MAU::Meter *meter) override;
53 explicit Update(AdjustByteCountSetup &self) : self(self) {}
54 };
55
56 public:
58};
59
60} // namespace BFN
61
62#endif /* BACKENDS_TOFINO_BF_P4C_MAU_ADJUST_BYTE_COUNT_H_ */
Definition adjust_byte_count.h:35
Definition mau_visitor.h:29
Definition mau_visitor.h:55
Definition ir/pass_manager.h:40
The namespace encapsulating Barefoot/Intel-specific stuff.
Definition add_t2na_meta.cpp:21
TODO: this is not really specific to BMV2, it should reside somewhere else.
Definition applyOptionsPragmas.cpp:24