P4C
The P4 Compiler
 
Loading...
Searching...
No Matches
P4::DoLocalCopyPropagation Class Reference
Inheritance diagram for P4::DoLocalCopyPropagation:

Classes

class  ElimDead
 
class  RewriteTableKeys
 

Public Member Functions

 DoLocalCopyPropagation (ReferenceMap *refMap, TypeMap *typeMap, std::function< bool(const Context *, const IR::Expression *)> policy, bool eut)
 

Detailed Description

Local copy propagation and dead code elimination within a single pass. This pass is designed to be run after all declarations have received unique internal names. This is important because the locals map uses only the declaration name, and not the full path.

Precondition
Requires expression types be stored inline in the expression (obtained by running Typechecking(updateProgram = true)).

Requires that all declaration names be globally unique (obtained by running UniqueNames).

Requires that all variable declarations are at the top-level control scope (obtained using MoveDeclarations).

Parameters
policy

This predicate function will be called for any expression that could be copy-propagated to determine if it should be. It will only be called for expressions that are legal to propagate (so no side effects, or dependencies that would change the meaning), so the policy should only evaluate the potential cost of propagating, as propagated expressions may be evaluated mulitple times. The default policy just returns true – always propagate if legal to do so.