P4C
The P4 Compiler
Loading...
Searching...
No Matches
parser_header_sequences.h
1
19
#ifndef BF_P4C_PARDE_PARSER_HEADER_SEQUENCES_H_
20
#define BF_P4C_PARDE_PARSER_HEADER_SEQUENCES_H_
21
22
#include "bf-p4c/ir/control_flow_visitor.h"
23
#include "bf-p4c/ir/gress.h"
24
#include "bf-p4c/parde/parde_visitor.h"
25
#include "bf-p4c/phv/phv_fields.h"
26
#include "ir/ir.h"
27
#include "ir/visitor.h"
28
29
namespace
{
30
31
static
constexpr
unsigned
int
numHeaderIDs = 255;
32
static
constexpr
unsigned
int
numHeadersPerSeq = 16;
33
static
constexpr
unsigned
int
payloadHeaderID = 254;
34
static
cstring
payloadHeaderStateName =
"$final"
_cs;
35
static
cstring
payloadHeaderName =
"payload"
_cs;
36
37
}
// namespace
38
42
class
ParserHeaderSequences
:
public
BFN::ControlFlowVisitor
,
public
PardeInspector
{
43
protected
:
44
PhvInfo
&phv;
45
49
void
record_header
(gress_t gress,
cstring
header,
size_t
size);
50
51
public
:
53
std::map<gress_t, ordered_set<cstring>>
headers
;
54
std::map<std::pair<gress_t, cstring>,
int
> header_ids;
55
57
std::map<gress_t, std::vector<ordered_set<cstring>>>
sequences
;
58
// Name to size in bits of headers extracted in the ingress.
59
std::map<cstring, size_t> header_sizes;
60
61
explicit
ParserHeaderSequences
(
PhvInfo
&phv) : phv(phv) {}
62
63
Visitor::profile_t
init_apply
(
const
IR::Node *node)
override
;
64
bool
preorder
(
const
IR::BFN::Parser *)
override
;
65
bool
preorder
(
const
IR::BFN::Extract *)
override
;
66
67
void
flow_merge
(
Visitor
&)
override
;
68
void
flow_copy(
::ControlFlowVisitor
&)
override
;
69
70
void
end_apply()
override
;
71
72
ParserHeaderSequences
*clone()
const override
{
return
new
ParserHeaderSequences
(*
this
); }
73
};
74
75
#endif
/* BF_P4C_PARDE_PARSER_HEADER_SEQUENCES_H_ */
P4::ControlFlowVisitor
Definition
visitor.h:463
P4::Visitor
Definition
visitor.h:75
P4::cstring
Definition
cstring.h:85
ParserHeaderSequences
Identify parsed header sequences.
Definition
parser_header_sequences.h:42
ParserHeaderSequences::record_header
void record_header(gress_t gress, cstring header, size_t size)
Record that header was parsed in gress.
Definition
parser_header_sequences.cpp:62
ParserHeaderSequences::flow_merge
void flow_merge(Visitor &) override
Definition
parser_header_sequences.cpp:35
ParserHeaderSequences::init_apply
Visitor::profile_t init_apply(const IR::Node *node) override
Definition
parser_header_sequences.cpp:21
ParserHeaderSequences::sequences
std::map< gress_t, std::vector< ordered_set< cstring > > > sequences
Definition
parser_header_sequences.h:57
ParserHeaderSequences::preorder
bool preorder(const IR::BFN::Parser *) override
Create an empty set of sequences for each parser.
Definition
parser_header_sequences.cpp:57
ParserHeaderSequences::headers
std::map< gress_t, ordered_set< cstring > > headers
Definition
parser_header_sequences.h:53
PhvInfo
Definition
phv_fields.h:1095
PardeInspector
Definition
parde_visitor.h:27
backends
tofino
bf-p4c
parde
parser_header_sequences.h
Generated by
1.12.0