17#ifndef MIDEND_CHECKEXTERNINVOCATIONCOMMON_H_ 
   18#define MIDEND_CHECKEXTERNINVOCATIONCOMMON_H_ 
   20#include "frontends/p4/methodInstance.h" 
   22#include "ir/visitor.h" 
   23#include "lib/bitvec.h" 
   90                             const IR::MethodCallExpression *expr) {
 
 
  102        int bit = vec.ffs(0);
 
  103        BUG_CHECK(vec.ffs(bit), 
"Trying to extract multiple block encodings");
 
 
  117        if (!pipeConstraints.count(extType)) {
 
  118            pipeConstraints.emplace(extType, vec);
 
  120            auto &cons = pipeConstraints.at(extType);
 
 
  140        BUG_CHECK(pipeConstraints.count(extType), 
"pipe constraints not defined for %1%", extType);
 
  141        auto constraint = pipeConstraints.at(extType) & bv;
 
  142        if (!bv.empty() && constraint.empty()) {
 
  144                ::error(ErrorType::ERR_UNSUPPORTED, 
"%s %s %s cannot be used in the %s %s",
 
  145                        expr->srcInfo, extType, extName, pipe, 
extractBlock(bv));
 
  147                ::error(ErrorType::ERR_UNSUPPORTED, 
"%s %s cannot be used in the %s %s",
 
 
  153        : refMap(refMap), typeMap(typeMap) {}
 
  156    bool preorder(
const IR::MethodCallExpression *expr)
 override {
 
  158        if (
auto extMethod = mi->to<ExternMethod>()) {
 
  160        } 
else if (
auto extFunction = mi->to<ExternFunction>()) {
 
 
Base class which can be used to prepare classes for checking constraints for invocations of externs (...
Definition checkExternInvocationCommon.h:41
 
void setPipeConstraints(cstring extType, bitvec vec)
Set the pipe (parser/control block) constraints.
Definition checkExternInvocationCommon.h:116
 
cstring extractBlock(bitvec vec)
Get the name of the block which is represented by bit set in the bitvec.
Definition checkExternInvocationCommon.h:101
 
virtual cstring getBlockName(int bit)=0
Get the name of the block which is represented in bit vector (bitvec) by bit with index given by 'bit...
 
virtual void initPipeConstraints()=0
Method used to initialize the constraints.
 
virtual void checkExtern(const ExternMethod *extMethod, const IR::MethodCallExpression *expr)
Method for checking constraints of extern method given by parameters.
Definition checkExternInvocationCommon.h:75
 
virtual void checkExtern(const ExternFunction *extFunction, const IR::MethodCallExpression *expr)
Method for checking constraints of extern functions given by parameters.
Definition checkExternInvocationCommon.h:89
 
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:138
 
Definition methodInstance.h:181
 
Definition methodInstance.h:149
 
static MethodInstance * resolve(const IR::MethodCallExpression *mce, const DeclarationLookup *refMap, TypeMap *typeMap, bool useExpressionType=false, const Visitor::Context *ctxt=nullptr, bool incomplete=false)
Definition methodInstance.cpp:27
 
Class used to encode maps from paths to declarations.
Definition referenceMap.h:66
 
Definition applyOptionsPragmas.cpp:24