P4C
The P4 Compiler
 
Loading...
Searching...
No Matches
P4::ComputeDefUse Class Reference

Compute defuse info within P4Parser and P4Control blocks in the midend. More...

Inheritance diagram for P4::ComputeDefUse:

Classes

struct  loc_t
 
class  SetupJoinPoints
 

Public Member Functions

void clear ()
 
const ordered_set< const loc_t * > & getDefs (const IR::Node *n) const
 
const ordered_set< const loc_t * > & getUses (const IR::Node *n) const
 
- Public Member Functions inherited from P4::ResolutionContext
const IR::IDeclaration * getDeclaration (const IR::Path *path, bool notNull=false) const
 
const IR::IDeclaration * getDeclaration (const IR::This *, bool notNull=false) const
 
auto getDeclarations (const IR::INamespace *ns) const
 Returns the set of decls that exist in the given namespace.
 
auto getDeclsByName (const IR::INamespace *ns, cstring name) const
 Returns the set of decls with the given name that exist in the given namespace.
 
std::vector< const IR::IDeclaration * > resolve (const IR::ID &name, ResolutionType type) const
 Resolve references for name, restricted to type declarations.
 
virtual const IR::IDeclaration * resolvePath (const IR::Path *path, bool isType) const
 
const IR::Type * resolveType (const IR::Type *type) const
 Resolve a refrence to a type type.
 
const IR::IDeclaration * resolveUnique (const IR::ID &name, ResolutionType type, const IR::INamespace *=nullptr) const
 Resolve reference for name, restricted to type declarations, and expect one result.
 

Friends

std::ostream & operator<< (std::ostream &, const defuse_t &)
 
std::ostream & operator<< (std::ostream &, const loc_t &)
 
std::ostream & operator<< (std::ostream &out, const ComputeDefUse &cdu)
 

Additional Inherited Members

- Protected Member Functions inherited from P4::ResolutionContext
 ResolutionContext (bool ao)
 
std::vector< const IR::IDeclaration * > lookup (const IR::INamespace *ns, const IR::ID &name, ResolutionType type) const
 
std::vector< const IR::IDeclaration * > lookupMatchKind (const IR::ID &name) const
 
const IR::Vector< IR::Argument > * methodArguments (cstring name) const
 We are resolving a method call. Find the arguments from the context.
 
- Protected Attributes inherited from P4::ResolutionContext
bool anyOrder
 

Detailed Description

Compute defuse info within P4Parser and P4Control blocks in the midend.

This pass finds all uses and definitions of field/slice values in all controls and parsers in the program and stores maps of which defs reach which uses. After the pass runs, getDefs(use) will return all the definitions in the program that reach the argument use while getUses(def) will return all the uses of the given def. The returned values are sets of ComputeUseDef::loc_t objects which contain both the node that is def or use as well as the context path from the root of the IR to that node – actions that are used by mulitple tables or parser states reachable via multiple paths may have mulitple entries as a result

Precondition
Currently the code does not consider calls between controls or parsers, as it is expected to run after inlining when all such calls have been flattened. It could be extended to deal with the before inlining case.