P4C
The P4 Compiler
Loading...
Searching...
No Matches
headerMetrics.h
1/*
2Collects global and per-definition header metrics. For each
3header definition, it loops over each field and unwraps
4its type, until the field's bit width can be extracted.
5*/
6
7#ifndef FRONTENDS_P4_METRICS_HEADERMETRICS_H_
8#define FRONTENDS_P4_METRICS_HEADERMETRICS_H_
9
10#include "frontends/p4/metrics/metricsStructure.h"
11#include "frontends/p4/typeMap.h"
12#include "ir/ir.h"
13
14namespace P4 {
15
16class HeaderMetricsPass : public Inspector {
17 private:
18 TypeMap *typeMap;
19 HeaderMetrics &metrics;
20 unsigned totalFieldsNum = 0;
21 unsigned totalFieldsSize = 0;
22
23 public:
24 explicit HeaderMetricsPass(TypeMap *typeMap, Metrics &metricsRef)
25 : typeMap(typeMap), metrics(metricsRef.headerMetrics) {
26 setName("HeaderMetricsPass");
27 }
28
29 void postorder(const IR::Type_Header *header) override;
30 void postorder(const IR::P4Program * /*program*/) override;
31};
32
33} // namespace P4
34
35#endif /* FRONTENDS_P4_METRICS_HEADERMETRICS_H_ */
Definition visitor.h:413
Definition typeMap.h:41
TODO: this is not really specific to BMV2, it should reside somewhere else.
Definition applyOptionsPragmas.cpp:24
Definition metricsStructure.h:110
Definition metricsStructure.h:119