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 "frontends/common/resolveReferences/referenceMap.h"
25
#include "frontends/p4/typeMap.h"
26
#include "helpers.h"
27
#include "ir/ir.h"
28
#include "lib/json.h"
29
#include "programStructure.h"
30
31
namespace
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 BMV2
65
66
#endif
/* BACKENDS_BMV2_COMMON_HEADER_H_ */
BMV2::HeaderConverter
Definition
header.h:35
BMV2::HeaderConverter::preorder
bool preorder(const IR::Parameter *param) override
Definition
header.cpp:440
BMV2::HeaderConverter::addTypesAndInstances
void addTypesAndInstances(const IR::Type_StructLike *type, bool meta)
Definition
header.cpp:42
BMV2::HeaderConverter::init_apply
Visitor::profile_t init_apply(const IR::Node *node) override
Definition
header.cpp:323
BMV2::SharedActionSelectorCheck
Definition
sharedActionSelectorCheck.h:40
Util::JsonArray
Definition
json.h:111
cstring
Definition
cstring.h:72
BMV2::ConversionContext
Definition
helpers.h:261
backends
bmv2
common
header.h
Generated on Tue Mar 26 2024 for