P4C
The P4 Compiler
Loading...
Searching...
No Matches
ir_utils.h
1
19
#ifndef BACKENDS_TOFINO_BF_P4C_COMMON_IR_UTILS_H_
20
#define BACKENDS_TOFINO_BF_P4C_COMMON_IR_UTILS_H_
21
22
#include "ir/ir.h"
23
24
using namespace
P4
;
25
26
IR::Member *gen_fieldref(
const
IR::HeaderOrMetadata *hdr,
cstring
field);
27
28
const
IR::HeaderOrMetadata *getMetadataType(
const
IR::BFN::Pipe *pipe,
cstring
typeName);
29
30
bool
isSigned(
const
IR::Type *);
31
32
// probably belongs in ir/ir.h or ir/node.h...
33
template
<
class
T>
34
inline
T *clone_update(
const
T *&ptr) {
35
T *rv = ptr->clone();
36
ptr = rv;
37
return
rv;
38
}
39
40
uint64_t bitMask(
unsigned
size);
41
big_int bigBitMask(
int
size);
42
43
// FIXME -- move to open source code (ir/pass_manager.h probably)
44
template
<
class
BT>
45
class
CatchBacktrack
:
public
Backtrack
{
46
std::function<void(BT *)> fn;
47
bool
backtrack(
trigger
&trig)
override
{
48
if
(
auto
t =
dynamic_cast<
BT *
>
(&trig)) {
49
fn(t);
50
return
true
;
51
}
else
{
52
return
false
;
53
}
54
}
55
// pass does nothing
56
const
IR::Node
*apply_visitor(
const
IR::Node
*n,
const
char
* = 0)
override
{
return
n; }
57
58
public
:
59
explicit
CatchBacktrack
(std::function<
void
(BT *)> f) : fn(f) {}
60
explicit
CatchBacktrack
(std::function<
void
()> f) : fn([f](BT *) { f(); }) {}
61
};
62
63
#endif
/* BACKENDS_TOFINO_BF_P4C_COMMON_IR_UTILS_H_ */
CatchBacktrack
Definition
ir_utils.h:45
P4::Backtrack
Definition
visitor.h:766
P4::IR::Node
Definition
node.h:94
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::Backtrack::trigger
Definition
visitor.h:768
backends
tofino
bf-p4c
common
ir_utils.h
Generated by
1.12.0