P4C
The P4 Compiler
Loading...
Searching...
No Matches
nestingDepthMetric.h
1
/*
2
Determines the maximum nesting depth of the compiled program,
3
and of every major abstraction (controls, parsers, functions),
4
by increasing/decreasing a counter when entering/exiting block
5
statements, select statements and parser states.
6
*/
7
8
#ifndef FRONTENDS_P4_METRICS_NESTINGDEPTHMETRIC_H_
9
#define FRONTENDS_P4_METRICS_NESTINGDEPTHMETRIC_H_
10
11
#include "frontends/p4/metrics/metricsStructure.h"
12
#include "ir/ir.h"
13
14
namespace
P4
{
15
16
class
NestingDepthMetricPass :
public
Inspector
{
17
private
:
18
NestingDepthMetrics
&metrics;
19
unsigned
currentDepth;
20
unsigned
currentMax;
21
22
public
:
23
explicit
NestingDepthMetricPass(
Metrics
&metricsRef)
24
: metrics(metricsRef.nestingDepth), currentDepth(0), currentMax(0) {
25
setName(
"NestingDepthPass"
);
26
}
27
bool
increment();
28
void
decrement();
29
void
logDepth(
const
cstring
name);
30
bool
enter();
31
32
bool
preorder(
const
IR::P4Parser *
/*parser*/
)
override
;
33
bool
preorder(
const
IR::P4Control *
/*control*/
)
override
;
34
bool
preorder(
const
IR::Function *
/*function*/
)
override
;
35
void
postorder(
const
IR::P4Parser *parser)
override
;
36
void
postorder(
const
IR::P4Control *control)
override
;
37
void
postorder(
const
IR::Function *function)
override
;
38
bool
preorder(
const
IR::ParserState *
/*state*/
)
override
;
39
bool
preorder(
const
IR::SelectExpression *
/*stmt*/
)
override
;
40
bool
preorder(
const
IR::BlockStatement *
/*stmt*/
)
override
;
41
void
postorder(
const
IR::ParserState *
/*state*/
)
override
;
42
void
postorder(
const
IR::SelectExpression *
/*stmt*/
)
override
;
43
void
postorder(
const
IR::BlockStatement *
/*stmt*/
)
override
;
44
void
postorder(
const
IR::P4Program *
/*program*/
)
override
;
45
};
46
47
}
// namespace P4
48
49
#endif
/* FRONTENDS_P4_METRICS_NESTINGDEPTHMETRIC_H_ */
P4::Inspector
Definition
visitor.h:413
P4::cstring
Definition
cstring.h:85
P4
TODO: this is not really specific to BMV2, it should reside somewhere else.
Definition
applyOptionsPragmas.cpp:24
P4::Metrics
Definition
metricsStructure.h:119
P4::NestingDepthMetrics
Definition
metricsStructure.h:86
frontends
p4
metrics
nestingDepthMetric.h
Generated by
1.13.2