P4C
The P4 Compiler
|
Various substitutions that must be applied for each instance. More...
#include <inlining.h>
Classes | |
struct | key_equal |
struct | key_hash |
Public Types | |
typedef std::pair< const IR::MethodCallStatement *, const IR::PathExpression * > | InlinedInvocationInfo |
Public Member Functions | |
const IR::MethodCallStatement * | uniqueCaller (const IR::Declaration_Instance *instance) const |
Public Attributes | |
std::map< const IR::MethodCallStatement *, const IR::Declaration_Instance * > | callToInstance |
For each invocation (key) call the instance that is invoked. | |
std::map< const IR::Declaration_Instance *, const IR::IContainer * > | declToCallee |
For each instance (key) the container that is intantiated. | |
std::unordered_map< const InlinedInvocationInfo, const IR::ID, key_hash, key_equal > | invocationToState |
std::map< const IR::Declaration_Instance *, PerInstanceSubstitutions * > | substitutions |
For each instance (key) we must apply a bunch of substitutions. | |
Various substitutions that must be applied for each instance.
std::pair<const IR::MethodCallStatement *, const IR::PathExpression *> P4::InlineSummary::PerCaller::InlinedInvocationInfo |
Pair identifying all the invocations of the subparser which can use the same inlined states because the path after returning from the subparser is identical for all such invocations.
Invocations are characterized by:
Additional conditions which need to be met:
|
inline |
std::unordered_map<const InlinedInvocationInfo, const IR::ID, key_hash, key_equal> P4::InlineSummary::PerCaller::invocationToState |
For each distinct invocation of the subparser identified by InlinedInvocationInfo we store the ID of the next caller parser state which is a new state replacing the start state of the callee parser (subparser). Transition to this state is used in case there is another subparser invocation which has the equivalent InlinedInvocationInfo.
Subparser invocations are considered to be equivalent when following conditions are met (which means that the path in the parse graph is the same after returning from subparser call):
Example of the optimization
Parser and subparser before Inline pass:
Parser after Inline pass without optimization:
Parser after Inline pass with optimization: