P4C
The P4 Compiler
Toggle main menu visibility
Main Page
P4C Repository Organization
Getting Started
P4C Intermediate Representation (IR)
Frontend
Midend
Backends
Behavioral Model Backend
DPDK Backend
eBPF Backend
TC Backend
uBPF Backend
P4test Backend
Graphs Backend
p4fmt (P4 Formatter)
P4Tools
P4Smith
P4Testgen
Contribute to the P4 Compiler Project
Releases
Namespaces
Namespace List
Namespace Members
All
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
r
s
t
w
x
z
Functions
a
c
d
e
f
g
h
i
l
m
n
o
p
r
s
t
w
x
Variables
Typedefs
Enumerations
Enumerator
Classes
Class List
Class Index
Class Hierarchy
Class Members
All
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
r
s
t
u
v
w
y
z
~
Functions
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
r
s
t
u
v
w
z
~
Variables
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
r
s
t
u
v
w
y
Typedefs
Enumerations
Enumerator
Related Symbols
•
All
Classes
Namespaces
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Modules
Pages
Loading...
Searching...
No Matches
frontends/common/model.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 FRONTENDS_COMMON_MODEL_H_
18
#define FRONTENDS_COMMON_MODEL_H_
19
20
#include "ir/id.h"
21
#include "lib/cstring.h"
22
23
// Classes for representing various P4 program models inside the compiler
24
25
namespace
P4::Model {
26
27
// Model element
28
struct
Elem {
29
explicit
Elem(
cstring
name) : name(name) {}
30
Elem() =
delete
;
31
32
cstring
name;
33
IR::ID
Id()
const
{
return
IR::ID
(name); }
34
IR::ID
Id(
Util::SourceInfo
srcInfo)
const
{
return
IR::ID
(srcInfo, name); }
35
IR::ID
Id(
Util::SourceInfo
srcInfo,
cstring
originalName)
const
{
36
return
IR::ID
(srcInfo, name, originalName);
37
}
38
const
char
*str()
const
{
return
name.c_str(); }
39
cstring
toString()
const
{
return
name; }
40
};
28
struct
Elem {
…
};
41
42
struct
Type_Model :
public
Elem {
43
explicit
Type_Model(
cstring
name) : Elem(name) {}
44
};
42
struct
Type_Model :
public
Elem {
…
};
45
47
struct
Enum_Model :
public
Type_Model {
48
explicit
Enum_Model(
cstring
name) : Type_Model(name) {}
49
};
47
struct
Enum_Model :
public
Type_Model {
…
};
50
52
struct
Extern_Model :
public
Type_Model {
53
explicit
Extern_Model(
cstring
name) : Type_Model(name) {}
54
};
52
struct
Extern_Model :
public
Type_Model {
…
};
55
57
struct
Param_Model :
public
Elem {
58
const
Type_Model
type;
59
const
unsigned
index;
60
Param_Model(
cstring
name,
Type_Model
type,
unsigned
index)
61
: Elem(name), type(type), index(index) {}
62
};
57
struct
Param_Model :
public
Elem {
…
};
63
64
class
Model
{};
65
66
}
// namespace P4::Model
67
68
#endif
/* FRONTENDS_COMMON_MODEL_H_ */
P4::Model::Model
Definition
frontends/common/model.h:64
P4::Util::SourceInfo
Definition
source_file.h:132
P4::cstring
Definition
cstring.h:85
P4::IR::ID
Definition
id.h:28
P4::Model::Type_Model
Definition
frontends/common/model.h:42
frontends
common
model.h
Generated by
1.13.0