P4C
The P4 Compiler
Loading...
Searching...
No Matches
header.h
1
/*
2
Copyright 2013-present Barefoot Networks, Inc.
3
4
Licensed under the Apache License, Version 2.0 (the "License");
5
you may not use this file except in compliance with the License.
6
You may obtain a copy of the License at
7
8
http://www.apache.org/licenses/LICENSE-2.0
9
10
Unless required by applicable law or agreed to in writing, software
11
distributed under the License is distributed on an "AS IS" BASIS,
12
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
See the License for the specific language governing permissions and
14
limitations under the License.
15
*/
16
17
#ifndef BACKENDS_BMV2_COMMON_HEADER_H_
18
#define BACKENDS_BMV2_COMMON_HEADER_H_
19
20
#include <list>
21
22
#include "JsonObjects.h"
23
#include "backends/bmv2/common/options.h"
24
#include "backends/common/programStructure.h"
25
#include "frontends/common/resolveReferences/referenceMap.h"
26
#include "frontends/p4/typeMap.h"
27
#include "helpers.h"
28
#include "ir/ir.h"
29
#include "lib/json.h"
30
31
namespace
P4::BMV2
{
32
33
class
Backend;
34
35
class
HeaderConverter
:
public
Inspector
{
36
ConversionContext
*ctxt;
37
cstring
scalarsName;
38
cstring
scalarsTypeName;
39
std::set<cstring> visitedHeaders;
40
41
const
unsigned
boolWidth = 1;
// convert booleans to 1-bit integers
42
const
unsigned
errorWidth = 32;
// convert errors to 32-bit integers
43
unsigned
scalars_width = 0;
44
45
protected
:
46
Util::JsonArray
*
pushNewArray
(
Util::JsonArray
*parent);
47
void
addHeaderType(
const
IR::Type_StructLike *st);
48
void
addHeaderField(
const
cstring
&header,
const
cstring
&name,
int
size,
bool
is_signed);
49
Util::JsonArray
*addHeaderUnionFields(
cstring
hdrName,
const
IR::Type_HeaderUnion *type);
50
51
public
:
52
void
addTypesAndInstances
(
const
IR::Type_StructLike *type,
bool
meta);
53
void
addHeaderStacks(
const
IR::Type_Struct *type);
54
bool
isHeaders(
const
IR::Type_StructLike *st);
55
56
Visitor::profile_t
init_apply
(
const
IR::Node
*node)
override
;
57
void
end_apply(
const
IR::Node
*node)
override
;
58
59
bool
preorder
(
const
IR::Parameter *param)
override
;
60
61
HeaderConverter
(
ConversionContext
*ctxt,
cstring
scalarsName);
62
};
63
64
}
// namespace P4::BMV2
65
66
#endif
/* BACKENDS_BMV2_COMMON_HEADER_H_ */
P4::BMV2::HeaderConverter
Definition
header.h:35
P4::BMV2::HeaderConverter::pushNewArray
Util::JsonArray * pushNewArray(Util::JsonArray *parent)
TODO(hanw): remove.
Definition
header.cpp:25
P4::BMV2::HeaderConverter::init_apply
Visitor::profile_t init_apply(const IR::Node *node) override
Definition
header.cpp:318
P4::BMV2::HeaderConverter::addTypesAndInstances
void addTypesAndInstances(const IR::Type_StructLike *type, bool meta)
Definition
header.cpp:39
P4::BMV2::HeaderConverter::preorder
bool preorder(const IR::Parameter *param) override
Definition
header.cpp:435
P4::IR::Node
Definition
node.h:94
P4::Inspector
Definition
visitor.h:400
P4::Util::JsonArray
Definition
json.h:115
P4::Visitor::profile_t
Definition
visitor.h:78
P4::cstring
Definition
cstring.h:85
P4::BMV2
TODO: this is not really specific to BMV2, it should reside somewhere else.
Definition
action.cpp:21
P4::BMV2::ConversionContext
Definition
bmv2/common/helpers.h:297
backends
bmv2
common
header.h
Generated by
1.12.0