51 void initPipeConstraints()
override {
53 validInMainControl.setbit(MAIN_CONTROL);
59 cstring getBlockName(
int bit)
override {
60 static const std::array<cstring, BLOCK_COUNT> lookup = {
61 "main parser"_cs,
"pre control"_cs,
"main control"_cs,
"main deparser"_cs};
62 return lookup[bit % BLOCK_COUNT];
65 const IR::P4Parser *getParser(
const cstring parserName) {
66 if (
auto p = findContext<IR::P4Parser>()) {
67 if (structure->parsers.count(parserName) != 0 &&
68 structure->parsers.at(parserName)->name == p->name) {
75 const IR::P4Control *getControl(
const cstring controlName) {
76 if (
auto c = findContext<IR::P4Control>()) {
77 if (structure->pipelines.count(controlName) != 0 &&
78 structure->pipelines.at(controlName)->name == c->name) {
85 const IR::P4Control *getDeparser(
const cstring deparserName) {
86 if (
auto d = findContext<IR::P4Control>()) {
87 if (structure->deparsers.count(deparserName) != 0 &&
88 structure->deparsers.at(deparserName)->name == d->name) {
95 void checkBlock(
const IR::MethodCallExpression *expr,
const cstring externType,
99 LOG4(
"externType: " << externType <<
", externName: " << externName);
101 if (pipeConstraints.count(externType)) {
102 if (
auto block = getParser(
"MainParserT"_cs)) {
103 LOG4(
"MainParser: " << (
void *)block <<
" " << dbp(block));
104 pos.setbit(MAIN_PARSER);
106 }
else if (
auto block = getControl(
"PreControlT"_cs)) {
107 LOG4(
"PreControl: " << (
void *)block <<
" " << dbp(block));
108 pos.setbit(PRE_CONTROL);
110 }
else if (
auto block = getControl(
"MainControlT"_cs)) {
111 LOG4(
"MainControl: " << (
void *)block <<
" " << dbp(block));
112 pos.setbit(MAIN_CONTROL);
114 }
else if (
auto block = getDeparser(
"MainDeparserT"_cs)) {
115 LOG4(
"MainDeparser: " << (
void *)block <<
" " << dbp(block));
116 pos.setbit(MAIN_DEPARSER);
122 LOG1(
"Pipe constraints not defined for: " << externType);
127 const IR::MethodCallExpression *expr)
override {
128 LOG3(
"ExternMethod: " << extMethod <<
", MethodCallExpression: " << expr);
129 checkBlock(expr, extMethod->originalExternType->name, extMethod->
object->
getName().name);
133 const IR::MethodCallExpression *expr)
override {
134 LOG3(
"ExternFunction: " << extFunction <<
", MethodCallExpression: " << expr);
135 checkBlock(expr, expr->method->toString(), cstring::empty);
141 initPipeConstraints();
void checkPipeConstraints(cstring extType, bitvec bv, const IR::MethodCallExpression *expr, cstring extName, cstring pipe)
Check if the invocation of extern object method or extern function is valid in the block where it is ...
Definition checkExternInvocationCommon.h:137
TODO: this is not really specific to BMV2, it should reside somewhere else.
Definition applyOptionsPragmas.cpp:24