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

Performs actual inlining work. More...

Inheritance diagram for P4::GeneralInliner:

Public Member Functions

 GeneralInliner (ReferenceMap *refMap, bool _optimizeParserInlining)
 
Visitor::profile_t init_apply (const IR::Node *node) override
 
template<class P4Block , class P4BlockType >
void inline_subst (P4Block *caller, IR::IndexedVector< IR::Declaration > P4Block::*blockLocals, const P4BlockType *P4Block::*blockType)
 
const IR::Node * preorder (IR::MethodCallStatement *statement) override
 
const IR::Node * preorder (IR::P4Control *caller) override
 
const IR::Node * preorder (IR::P4Parser *caller) override
 
const IR::Node * preorder (IR::ParserState *state) override
 
- Public Member Functions inherited from P4::AbstractInliner< InlineList, InlineSummary >
Visitor::profile_t init_apply (const IR::Node *node)
 
void prepare (InlineList *list, InlineSummary *toInline)
 

Additional Inherited Members

- Protected Attributes inherited from P4::AbstractInliner< InlineList, InlineSummary >
InlineListlist
 
InlineSummarytoInline
 

Detailed Description

Performs actual inlining work.

Member Function Documentation

◆ inline_subst()

template<class P4Block , class P4BlockType >
void P4::GeneralInliner::inline_subst ( P4Block * caller,
IR::IndexedVector< IR::Declaration > P4Block::* blockLocals,
const P4BlockType *P4Block::* blockType )

Build the substitutions needed for args and locals of the thing being inlined. P4Block here should be either P4Control or P4Parser. P4BlockType should be either Type_Control or Type_Parser to match the P4Block.

◆ preorder()

const IR::Node * P4::GeneralInliner::preorder ( IR::ParserState * state)
override

Check if there are already inlined states of the callee subparser of the same instance as this one with the same arguments, no statements after this call and transition to the same state (without select expression). If yes, we can reuse those states as after returning from callee subparser the parser continues in the same path.

If there is no other statement after this invocation of the subparser and transition does not use select expression, we store the ID of the inlined subparser's start state, currently processed invocation statement and the transition statement expression.