P4C
The P4 Compiler
Loading...
Searching...
No Matches
check_duplicate.h
1
19
#ifndef BACKENDS_TOFINO_BF_P4C_MAU_CHECK_DUPLICATE_H_
20
#define BACKENDS_TOFINO_BF_P4C_MAU_CHECK_DUPLICATE_H_
21
22
#include "ir/dump.h"
23
24
using namespace
P4
;
25
26
class
CheckTableNameDuplicate
:
public
MauInspector
{
27
std::set<cstring> names;
28
profile_t
init_apply(
const
IR::Node
*root)
override
{
29
names.clear();
30
return
MauInspector::init_apply(root);
31
}
32
bool
preorder(
const
IR::MAU::Table *t)
override
{
33
auto
name = t->name;
34
if
(t->is_placed()) name = t->unique_id().build_name();
35
if
(names.count(name)) BUG(
"Multiple tables named '%s'"
, name);
36
names.insert(name);
37
return
true
;
38
}
39
};
40
41
class
CheckDuplicateAttached
:
public
Inspector
{
42
std::map<cstring, const IR::MAU::AttachedMemory *> attached;
43
44
public
:
45
const
char
*pass =
""
;
46
bool
ok =
true
;
47
profile_t
init_apply(
const
IR::Node
*root) {
48
attached.clear();
49
return
Inspector::init_apply(root);
50
}
51
bool
preorder(
const
IR::MAU::AttachedMemory *at) {
52
if
(attached.count(at->name)) {
53
LOG1(
"Duplicated attached table "
<< at->name <<
" after "
<< pass);
54
ok =
false
;
55
}
56
attached[at->name] = at;
57
return
true
;
58
}
59
void
end_apply(
const
IR::Node
*root) {
60
if
(!ok && LOGGING(3)) {
61
std::cout <<
"---------- After "
<< pass <<
" ----------"
<< std::endl;
62
dump(root);
63
}
64
BUG_CHECK(ok,
"abort after %s"
, pass);
65
}
66
};
67
68
#endif
/* BACKENDS_TOFINO_BF_P4C_MAU_CHECK_DUPLICATE_H_ */
CheckDuplicateAttached
Definition
check_duplicate.h:41
CheckTableNameDuplicate
Definition
check_duplicate.h:26
MauInspector
Definition
mau_visitor.h:29
P4::IR::Node
Definition
node.h:95
P4::Inspector
Definition
visitor.h:400
P4::Visitor::profile_t
Definition
visitor.h:78
P4
TODO: this is not really specific to BMV2, it should reside somewhere else.
Definition
applyOptionsPragmas.cpp:24
backends
tofino
bf-p4c
mau
check_duplicate.h
Generated by
1.12.0