1#ifndef COMMON_COMPILER_REACHABILITY_H_ 
    2#define COMMON_COMPILER_REACHABILITY_H_ 
    7#include <unordered_map> 
    8#include <unordered_set> 
   12#include "frontends/p4/callGraph.h" 
   16#include "ir/visitor.h" 
   17#include "lib/cstring.h" 
   23using DCGVertexTypeSet = std::unordered_set<const DCGVertexType *>;
 
   24using ReachabilityHashType = std::unordered_map<cstring, std::unordered_set<const DCGVertexType *>>;
 
   29    ReachabilityHashType hash;
 
   33    const ReachabilityHashType &getHash()
 const { 
return hash; }
 
   38        if (name.name.size() == 0) {
 
   41        auto i = hash.find(name.name);
 
   42        if (i == hash.end()) {
 
   43            std::unordered_set<const DCGVertexType *> s;
 
   45            hash.emplace(name.name, s);
 
   47            i->second.insert(vertex);
 
   49        const auto *prev = name.name.findlast(
'.');
 
   50        if (prev != 
nullptr) {
 
   51            cstring newName = name.name.before(prev);
 
   52            i = hash.find(newName);
 
   53            if (i == hash.end()) {
 
 
   59    bool isReachable(T start, T element)
 const {
 
   65        while (!work.empty()) {
 
   66            auto *node = *work.begin();
 
   67            if (node->equiv(*element)) {
 
   71            if (visited.find(node) != visited.end()) {
 
   74            visited.emplace(node);
 
   75            auto edges = this->out_edges.find(node);
 
   76            if (edges == this->out_edges.end()) {
 
   79            for (
auto c : *(edges->second)) {
 
 
   87using NodesCallGraph = ExtendedCallGraph<DCGVertexType *>;
 
   92    DCGVertexTypeSet prev;
 
   93    std::unordered_set<const DCGVertexType *> visited;
 
   94    const IR::P4Program *p4program;
 
   99    bool preorder(
const IR::Annotation *annotation) 
override;
 
  100    bool preorder(
const IR::ConstructorCallExpression *callExpr) 
override;
 
  101    bool preorder(
const IR::MethodCallExpression *method) 
override;
 
  102    bool preorder(
const IR::MethodCallStatement *method) 
override;
 
  103    bool preorder(
const IR::P4Action *action) 
override;
 
  104    bool preorder(
const IR::P4Parser *parser) 
override;
 
  105    bool preorder(
const IR::P4Table *table) 
override;
 
  106    bool preorder(
const IR::ParserState *parserState) 
override;
 
  107    bool preorder(
const IR::P4Control *control) 
override;
 
  108    bool preorder(
const IR::P4Program *program) 
override;
 
  109    bool preorder(
const IR::P4ValueSet *valueSet) 
override;
 
  110    bool preorder(
const IR::SelectExpression *selectExpression) 
override;
 
  111    bool preorder(
const IR::IfStatement *ifStatement) 
override;
 
  112    bool preorder(
const IR::SwitchStatement *switchStatement) 
override;
 
  113    bool preorder(
const IR::StatOrDecl *statOrDecl) 
override;
 
 
  124    std::list<const DCGVertexType *> state;
 
  132    std::list<const DCGVertexType *> 
getState();
 
  134    void setState(std::list<const DCGVertexType *>);
 
 
  145using ReachabilityResult = std::pair<bool, const IR::Expression *>;
 
  161    const ReachabilityHashType &hash;
 
  162    std::unordered_map<const DCGVertexType *, std::list<const DCGVertexType *>> userTransitions;
 
  163    std::unordered_map<const DCGVertexType *, const IR::Expression *> conditions;
 
  164    std::unordered_set<const DCGVertexType *> forbiddenVertexes;
 
  172                       bool eliminateAnnotations = 
false);
 
  185                                std::unordered_set<const DCGVertexType *> &s);
 
  189    std::unordered_set<const DCGVertexType *> 
getName(std::string name);
 
  193    const IR::Expression *
addCondition(
const IR::Expression *prev,
 
  197    static const IR::Expression *
stringToNode(std::string name);
 
 
Definition callGraph.h:41