P4C
The P4 Compiler
Loading...
Searching...
No Matches
Parser & deparser

Content related to parser and deparser. More...

Collaboration diagram for Parser & deparser:

Topics

 DeparserCopyOpt
 decaf : a deparser optimization of copy assigned fields
 
 DesugarVarbitExtract
 Set of passes that rewrite usage of varbit.
 
 ExtractChecksum
 Extracts checksum from translated checksum extern.
 
 LowerParser
 Replace field-based parser and deparser IR with container-based parser and deparser IR.
 
 P4::SimplifyNestedIf
 Set of passes that simplify nested if statements in the deparser control block.
 
 ParserCopyProp
 PassManager that governs parser copy propagation.
 
 ResetInvalidatedChecksumHeaders
 Reset fields that are used in deparser checksum operations and were invalidated.
 

Namespaces

namespace  P4
 TODO: this is not really specific to BMV2, it should reside somewhere else.
 

Classes

class  AdjustExtract
 Adjusts extractions that extract from fields that are serialized from phv container, i.e. marshaled, because there might be some junk bits before and after the field. More...
 
class  BFN::ExtractDeparser
 Transforms midend deparser IR::BFN::TnaDeparser into backend deparser IR::BFN::Deparser. More...
 
class  BFN::ExtractParser
 Transforms midend parser IR::BFN::TnaParser into backend parser IR::BFN::Parser. More...
 
class  BFN::InitializeMirrorIOSelect
 Initializes eg_intr_md_for_dprsr.mirror_io_select on devices except Tofino1. More...
 
class  BFN::ParserEnforceDepthReq
 Enforce parser min/max depth requirements. More...
 
class  CheckFieldCorruption
 
struct  CheckParserMultiWrite
 Checks multiple writes to the same field on non-mutually exclusive paths. More...
 
class  CollectClotInfo
 
class  CollectParserInfoImpl< Parser, State, Transition >
 
class  ComputeDefUse
 Compute defuse info within P4Parser and P4Control blocks in the midend. More...
 
struct  DeparserAsmOutput
 
class  DeparserInspector
 
class  DeparserModifier
 
class  DeparserTransform
 
class  DirectedGraph
 
class  DumpParser
 Dumps the entire parser graphs (can be used before and also after parser lowering). More...
 
class  FieldDefUse
 
class  FindParserHeaderEncounterInfo
 Based on dominators and post-dominators of parser states, determines which other headers have also surely been encountered if a given header has been encountered and which other headers have not been encountered if a given header has not been encountered. More...
 
class  GreedyClotAllocator
 
class  HasFullMatchCoverage
 
class  ImplicitParserInit
 
class  InferPayloadOffset
 
class  LoweredParserMatchAllocator
 
struct  MergeParserStates
 Merges a chain of states into a large state (before parser lowering). Find the longest chain that: Forall states expect for the last tail state: More...
 
class  P4ParserGraphs
 Extends p4c's parser graph with various algorithms. More...
 
class  PardeInspector
 
class  PardeModifier
 
class  PardeTransform
 
struct  ParserAsmOutput
 
class  ParserDominatorBuilder
 Builds parser graphs and determines the dominators and post-dominators of all parser states. Using this information, you can infer many things. For example: More...
 
class  ParserGraphImpl< Parser, State, Transition >
 
class  ParserInspector
 
class  ParserModifier
 
struct  ParserStateMap< State >
 
class  ParserTransform
 
struct  Phase0AsmOutput
 
class  RenameArchParams
 Pass that governs replacement of the user-supplied parameter names with the corresponding parameter names defined in the architecture. More...
 
struct  ResolveNegativeExtract
 For extracts with negative source, i.e. source is in an earlier state, adjust the state's shift amount, and possibly move extracts, so that the source is within current state's input buffer. More...
 
class  ReversibleParserGraph
 
class  RewriteParserMatchDefs
 Looks for extracts into temporary local variables used in select statements. More...
 
class  StackPushShims
 Adds parser states to initialize the $stkvalid fields that are used to handle the push_front and pop_front primitives for header stacks. More...
 
class  WriteParserError
 

Typedefs

using CollectLoweredParserInfo
 
using CollectParserInfo
 

Detailed Description

Content related to parser and deparser.

General information

There are some basic visitors defined for parde:

The assembler representations for parde:

The parde can also be affected at the beginning of Midend by architecture translation, see BFN::ArchTranslation for more information.

Parser

In frontend and midend, the IR::P4Parser IR node is used to represent a parser. During architecture translation, i.e. within the BFN::ArchTranslation midend pass, the Tofino parser becomes represented with the IR::BFN::TnaParser IR node.

In backend, after transformation within the BFN::BackendConverter post-midend pass, the Tofino parser is represented with the IR::BFN::Parser IR node. Within the LowerParser pass, the parser is transformed (lowered) into the representation that is closer to how HW works. For Tofino 1/2, IR::BFN::LoweredParser is produced,

In assembler, the Tofino 1/2 parser is represented with the Parser class, Specific differences of Tofino versions are implemented using template specialization.

Frontend passes

Frontend passes operate on IR::P4Parser nodes representing parsers and IR::ParserState nodes representing parser states.

Frontend passes related to parser:

Midend passes

After midend pass BFN::ArchTranslation, the parser becomes represented with the IR::BFN::TnaParser node which inherits from IR::P4Parser and contains some additional useful metadata. The parser states are still represented with IR::ParserState nodes.

Generic midend passes related to parser (p4c):

Tofino-specific midend passes related to parser (bf-p4c):

Post-midend passes

Post-midend passes convert midend representation of parser (IR::BFN::TnaParser) into backend representation (IR::BFN::Parser).

Post-midend passes related to parser:

Backend passes

In backend, the parser is represented with IR::BFN::Parser node and the parser states with IR::BFN::ParserState nodes. Within LowerParser pass, the parser is transformed to its lowered form represented with IR::BFN::LoweredParser node and the parser states are represented with IR::BFN::LoweredParserState nodes. Both parser representations, before and after parser lowering, can be dumped to the dot files using DumpParser pass, which is often called between the individual steps during parser transformations so that these dumps can be used for debugging.

Backend passes related to parser before parser lowering:

Backend passes responsible for parser lowering within LowerParser:

Parser write modes

The parser supports several container extraction write modes. Tofino 1 provide a single configuration bit per container that enables or disables multiple writes. Containers with multi-writes disabled permit only one write per packet: any attempt to write multiple times causes a parser error and aborts parsing. Containers with multi-write enabled are in bitwise-OR mode: repeated writes to the container OR the new data with the existing container content. Tofino 2 adds a second configuration bit per container that chooses between bitwise-OR and clear-on-write (new data replaces existing data) when mutli-writes are enabled.

Bitwise-or and clear-on-write only make sense in the context of multiple writes. If a container only allows a single write, then there is never any existing content to OR/clear prior to a write. (All containers are zeroed at the start-of-packet.)

The compiler calculates write modes to determine how to configure each container. The three write modes are:

Containers should be marked as SINGLE_WRITE whenever possible because the hardware can detect and flag attempts to write to the container multiple times. This could indicate a compiler error or a packet with unexpected repeated headers/more repeated headers than supported by a header stack.

Write modes apply to containers. The compiler associates a write mode with each extract (via the write_mode attribute) rather than each container, so the compiler must verify that all extracts to the same container have the same write mode (or can be downgraded to be compatible).

Choosing write modes

Most header field extracts should be marked as SINGLE_WRITE or CLEAR_ON_WRITE. They should be marked as SINGLE_WRITE if the field is extracted no more than once on every path through the parse graph, otherwise they should be marked as CLEAR_ON_WRITE if multiple extractions can occur on a single path and the later extraction replaces the earlier extraction.

BITWISE_OR should typically only be used for metadata field extracts representing state, such as validity or error flags, that are written by constants. This includes narrow multi-bit fields (narrower than container size) that are written by constants. Setting state fields to BITWISE_OR allows multiple of them to be packed together in a single container, with different fields (bit ranges) within the container being written in different states.

Write mode downgrading

SINGLE_WRITE fields can be downgraded to BITWISE_OR to improve container packing. If a SINGLE_WRITE field is written at most once in any parser path, and only written by constants, then it can be downgraded to BITWISE_OR.

The downside of downgrading the write mode is that we lose the ability to check whether the field is written multiple times by any given packet.

Tofino 2 considerations

All containers within the parser are 16b. Parser containers are combined or split to form 32b and 8b MAU containers. Different write modes can be used for the two adjacent 16b parser containers that form a 32b MAU container. A single write most applies to the 16b parser container that is split to form two 8b MAU containers, so both 8b containers must have the same write mode.

Tofino 2 extractors can write a full 16b to a parser container, or they can write 8b to either the upper or lower half of a container. The container write mode is applied to any write to the container. An 8b extract to a SINGLE_WRITE marks the whole container as having been written, so a subsequent extract to the other 8b half will trigger a container multi-write error. Similarly, an 8b extract to a CLEAR_ON_WRITE container clears the whole container before writing the new data: an 8b extract to one half followed by an 8b extract to the other half of a CLEAR_ON_WRITE container results in only the second write being present. Except for very rare circumstances, containers should be set to BITWISE_OR if the upper and lower halves are expected to be written independently for any packet.

Deparser

The deparser reassembles packets prior to storage in TM (Tofino 1/2) and prior to transmission via the MAC (all chips).

Target constants

Tofino1:

Tofino2:


Class Documentation

◆ AddDeparserMetadata

class AddDeparserMetadata

Add deparser parameters for standard metadata.

Add deparser parameters for "standard metadata" required by the hardware. An example is the egress port information required required by TM: this is a parameter that the deparser needs to provide.

The ArchSpec for the current device defines the metadata parameters to add.

Inheritance diagram for AddDeparserMetadata:
[legend]

Public Member Functions

 AddDeparserMetadata (const IR::BFN::Pipe *pipe)
 
void addEgressMetadata (IR::BFN::Deparser *d)
 
void addIngressMetadata (IR::BFN::Deparser *d)
 Add ingress deparser parameters.
 
bool preorder (IR::BFN::Deparser *) override
 Process the deparser instances to add parameters.
 

Public Attributes

const IR::BFN::Pipe * pipe
 

◆ AddMetadataPOV

class AddMetadataPOV

Create POV bits for output metadata (JBAY)

Copyright (C) 2024 Intel Corporation

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

SPDX-License-Identifier: Apache-2.0

JBay requires POV bits to control output metadata as implicit PHV valid bits are gone. We create a single POV bit for each metadata in use and set the bit whenever the metadata is set.

Inheritance diagram for AddMetadataPOV:
[legend]

Public Member Functions

 AddMetadataPOV (PhvInfo &p)
 
- Public Member Functions inherited from P4::Transform
const IR::Nodeapply_visitor (const IR::Node *, const char *name=0) override
 
profile_t init_apply (const IR::Node *root) override
 
virtual void loop_revisit (const IR::Node *)
 
virtual const IR::Nodepostorder (IR::Node *n)
 
virtual const IR::Nodepreorder (IR::Node *n)
 
void prune ()
 
virtual void revisit (const IR::Node *, const IR::Node *)
 
void revisit_visited ()
 
bool visit_in_progress (const IR::Node *) const
 
void visitAgain () const override
 
void visitOnce () const override
 
- Public Member Functions inherited from P4::Visitor
virtual bool check_global (cstring)
 
virtual void clear_globals ()
 
virtual Visitorclone () const
 
virtual ControlFlowVisitorcontrolFlowVisitor ()
 
virtual void end_apply ()
 
virtual void end_apply (const IR::Node *root)
 
virtual void erase_global (cstring)
 
template<class T >
const T * findContext () const
 
template<class T >
const T * findContext (const Context *&c) const
 
template<class T >
const T * findOrigCtxt () const
 
template<class T >
const T * findOrigCtxt (const Context *&c) const
 
virtual Visitorflow_clone ()
 
virtual void flow_merge (Visitor &)
 
virtual bool flow_merge_closure (Visitor &)
 
virtual void flow_merge_global_from (cstring)
 
virtual void flow_merge_global_to (cstring)
 
const ContextgetChildContext () const
 
int getChildrenVisited () const
 
const ContextgetContext () const
 
int getContextDepth () const
 
const IR::NodegetCurrentNode () const
 
template<class T >
const T * getCurrentNode () const
 
const IR::NodegetOriginal () const
 
template<class T >
const T * getOriginal () const
 
template<class T >
const T * getParent () const
 
virtual bool has_flow_joins () const
 
profile_t init_apply (const IR::Node *root, const Context *parent_context)
 
bool isInContext (const IR::Node *n) const
 
virtual const char * name () const
 
template<class T >
void parallel_visit (const IR::Vector< T > &v, const char *name, int cidx)
 
template<class T >
void parallel_visit (const IR::Vector< T > &v, const char *name=0)
 
template<class T >
void parallel_visit (IR::Vector< T > &v, const char *name, int cidx)
 
template<class T >
void parallel_visit (IR::Vector< T > &v, const char *name=0)
 
void print_context () const
 
const VisitorsetCalledBy (const Visitor *visitor)
 
void setName (const char *name)
 
void visit (const IR::Node &n, const char *name, int cidx)
 
void visit (const IR::Node &n, const char *name=0)
 
void visit (const IR::Node *&n, const char *name, int cidx)
 
void visit (const IR::Node *&n, const char *name=0)
 
void visit (const IR::Node *const &n, const char *name, int cidx)
 
void visit (const IR::Node *const &n, const char *name=0)
 
void visit (IR::Node &n, const char *name, int cidx)
 
void visit (IR::Node &n, const char *name=0)
 
void visit (IR::Node *&, const char *=0, int=0)
 
template<class T , typename = std::enable_if_t<Util::has_SourceInfo_v<T> && !std::is_pointer_v<T>>, class... Args>
void warn (const int kind, const char *format, const T &node, Args &&...args)
 The const ref variant of the above.
 
template<class T , typename = std::enable_if_t<Util::has_SourceInfo_v<T>>, class... Args>
void warn (const int kind, const char *format, const T *node, Args &&...args)
 
bool warning_enabled (int warning_kind) const
 

Additional Inherited Members

- Public Types inherited from P4::Visitor
typedef Visitor_Context Context
 
- Static Public Member Functions inherited from P4::Visitor
static cstring demangle (const char *)
 
static bool warning_enabled (const Visitor *visitor, int warning_kind)
 
- Public Attributes inherited from P4::Visitor
const Visitorcalled_by = nullptr
 
cstring internalName
 
SplitFlowVisit_base *& split_link
 
SplitFlowVisit_basesplit_link_mem = nullptr
 
- Protected Member Functions inherited from P4::Transform
const IR::Nodetransform_child (const IR::Node *child)
 
- Protected Member Functions inherited from P4::Visitor
virtual void init_join_flows (const IR::Node *)
 
virtual bool join_flows (const IR::Node *)
 
virtual void post_join_flows (const IR::Node *, const IR::Node *)
 
void visit_children (const IR::Node *, std::function< void()> fn)
 
- Protected Attributes inherited from P4::Transform
bool forceClone = false
 
- Protected Attributes inherited from P4::Visitor
bool dontForwardChildrenBeforePreorder = false
 
bool joinFlows = false
 
bool visitDagOnce = true
 

◆ AddParserMetadata

class AddParserMetadata

Extend parsers to extract standard metadata.

Copyright (C) 2024 Intel Corporation

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

SPDX-License-Identifier: Apache-2.0

"Standard metadata" refers to hardware-specific metadata, such as the ingress port or egress spec. Tofino prepends packets with metadata, which needs to be extracted by the parser before applying the user-supplied parser.

Inheritance diagram for AddParserMetadata:
[legend]

Public Member Functions

 AddParserMetadata (const IR::BFN::Pipe *pipe, bool isV1)
 

◆ AdjustExtract

class AdjustExtract

Adjusts extractions that extract from fields that are serialized from phv container, i.e. marshaled, because there might be some junk bits before and after the field.

Copyright (C) 2024 Intel Corporation

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

SPDX-License-Identifier: Apache-2.0

This is used for mirror/resubmit engine that directly pull data from phv container and then send to ingress/egress parser.

Inheritance diagram for AdjustExtract:
[legend]

Public Member Functions

 AdjustExtract (const PhvInfo &phv)
 

◆ BFN::ExtractDeparser

class BFN::ExtractDeparser

Transforms midend deparser IR::BFN::TnaDeparser into backend deparser IR::BFN::Deparser.

Precondition
Assume the nested if statements are already canonicalized to a single if statement enclosing any emit/pack method calls.
Inheritance diagram for BFN::ExtractDeparser:
[legend]

Public Member Functions

 ExtractDeparser (P4::ReferenceMap *refMap, P4::TypeMap *typeMap, IR::BFN::Pipe *rv)
 
void postorder (const IR::BFN::TnaDeparser *deparser) override
 
bool preorder (const IR::BFN::TnaDeparser *deparser) override
 

◆ BFN::ExtractParser

class BFN::ExtractParser

Transforms midend parser IR::BFN::TnaParser into backend parser IR::BFN::Parser.

Inheritance diagram for BFN::ExtractParser:
[legend]

Public Member Functions

 ExtractParser (P4::ReferenceMap *refMap, P4::TypeMap *typeMap, IR::BFN::Pipe *rv, ParseTna *arch)
 
void end_apply () override
 
profile_t init_apply (const IR::Node *root) override
 
void postorder (const IR::BFN::TnaParser *parser) override
 

◆ BFN::InitializeMirrorIOSelect

class BFN::InitializeMirrorIOSelect

Initializes eg_intr_md_for_dprsr.mirror_io_select on devices except Tofino1.

Inheritance diagram for BFN::InitializeMirrorIOSelect:
[legend]

Public Member Functions

 InitializeMirrorIOSelect (P4::ReferenceMap *refMap, P4::TypeMap *typeMap)
 
- Public Member Functions inherited from P4::PassManager
 PassManager (const PassManager &)=default
 
 PassManager (const std::initializer_list< VisitorRef > &init)
 
 PassManager (PassManager &&)=default
 
void addDebugHook (DebugHook h, bool recursive=false)
 
void addDebugHooks (std::vector< DebugHook > hooks, bool recursive=false)
 
void addPasses (const std::initializer_list< VisitorRef > &init)
 
const IR::Nodeapply_visitor (const IR::Node *, const char *=0) override
 
bool backtrack (trigger &trig) override
 
PassManagerclone () const override
 
void early_exit ()
 
void listPasses (std::ostream &, cstring sep) const
 
bool never_backtracks () override
 
void removePasses (const std::vector< cstring > &exclude)
 
void setStopOnError (bool stop)
 
- Public Member Functions inherited from P4::Visitor
virtual bool check_clone (const Visitor *a)
 
virtual bool check_global (cstring)
 
virtual void clear_globals ()
 
virtual ControlFlowVisitorcontrolFlowVisitor ()
 
virtual void end_apply ()
 
virtual void end_apply (const IR::Node *root)
 
virtual void erase_global (cstring)
 
template<class T >
const T * findContext () const
 
template<class T >
const T * findContext (const Context *&c) const
 
template<class T >
const T * findOrigCtxt () const
 
template<class T >
const T * findOrigCtxt (const Context *&c) const
 
virtual Visitorflow_clone ()
 
virtual void flow_merge (Visitor &)
 
virtual bool flow_merge_closure (Visitor &)
 
virtual void flow_merge_global_from (cstring)
 
virtual void flow_merge_global_to (cstring)
 
const ContextgetChildContext () const
 
int getChildrenVisited () const
 
const ContextgetContext () const
 
int getContextDepth () const
 
const IR::NodegetCurrentNode () const
 
template<class T >
const T * getCurrentNode () const
 
const IR::NodegetOriginal () const
 
template<class T >
const T * getOriginal () const
 
template<class T >
const T * getParent () const
 
virtual bool has_flow_joins () const
 
profile_t init_apply (const IR::Node *root, const Context *parent_context)
 
bool isInContext (const IR::Node *n) const
 
virtual const char * name () const
 
template<class T >
void parallel_visit (const IR::Vector< T > &v, const char *name, int cidx)
 
template<class T >
void parallel_visit (const IR::Vector< T > &v, const char *name=0)
 
template<class T >
void parallel_visit (IR::Vector< T > &v, const char *name, int cidx)
 
template<class T >
void parallel_visit (IR::Vector< T > &v, const char *name=0)
 
void print_context () const
 
const VisitorsetCalledBy (const Visitor *visitor)
 
void setName (const char *name)
 
void visit (const IR::Node &n, const char *name, int cidx)
 
void visit (const IR::Node &n, const char *name=0)
 
void visit (const IR::Node *&n, const char *name, int cidx)
 
void visit (const IR::Node *&n, const char *name=0)
 
void visit (const IR::Node *const &n, const char *name, int cidx)
 
void visit (const IR::Node *const &n, const char *name=0)
 
void visit (IR::Node &n, const char *name, int cidx)
 
void visit (IR::Node &n, const char *name=0)
 
void visit (IR::Node *&, const char *=0, int=0)
 
template<class T , typename = std::enable_if_t<Util::has_SourceInfo_v<T> && !std::is_pointer_v<T>>, class... Args>
void warn (const int kind, const char *format, const T &node, Args &&...args)
 The const ref variant of the above.
 
template<class T , typename = std::enable_if_t<Util::has_SourceInfo_v<T>>, class... Args>
void warn (const int kind, const char *format, const T *node, Args &&...args)
 
bool warning_enabled (int warning_kind) const
 
- Public Member Functions inherited from P4::Backtrack

Additional Inherited Members

- Public Types inherited from P4::Visitor
typedef Visitor_Context Context
 
- Static Public Member Functions inherited from P4::Visitor
static cstring demangle (const char *)
 
static bool warning_enabled (const Visitor *visitor, int warning_kind)
 
- Public Attributes inherited from P4::Visitor
const Visitorcalled_by = nullptr
 
cstring internalName
 
SplitFlowVisit_base *& split_link
 
SplitFlowVisit_basesplit_link_mem = nullptr
 
- Protected Member Functions inherited from P4::PassManager
profile_t init_apply (const IR::Node *root) override
 
void runDebugHooks (const char *visitorName, const IR::Node *node)
 
- Protected Member Functions inherited from P4::Visitor
virtual void init_join_flows (const IR::Node *)
 
virtual bool join_flows (const IR::Node *)
 
virtual void post_join_flows (const IR::Node *, const IR::Node *)
 
void visit_children (const IR::Node *, std::function< void()> fn)
 
virtual void visitAgain () const
 
virtual void visitOnce () const
 
- Protected Attributes inherited from P4::PassManager
safe_vector< DebugHookdebugHooks
 
safe_vector< Visitor * > passes
 
bool running = false
 
unsigned seqNo = 0
 
bool stop_on_error = true
 
- Protected Attributes inherited from P4::Visitor
bool dontForwardChildrenBeforePreorder = false
 
bool joinFlows = false
 
bool visitDagOnce = true
 

◆ BFN::ParserEnforceDepthReq

class BFN::ParserEnforceDepthReq

Enforce parser min/max depth requirements.

Programs that exceed the maximum parse depth are rejected. Programs that fall below the minimum parse depth have additional "pad" states added to enforce a minimum parse depth.

Inheritance diagram for BFN::ParserEnforceDepthReq:
[legend]

Public Member Functions

 ParserEnforceDepthReq (P4::ReferenceMap *rm, BFN::EvaluatorPass *ev)
 
- Public Member Functions inherited from P4::PassManager
 PassManager (const PassManager &)=default
 
 PassManager (const std::initializer_list< VisitorRef > &init)
 
 PassManager (PassManager &&)=default
 
void addDebugHook (DebugHook h, bool recursive=false)
 
void addDebugHooks (std::vector< DebugHook > hooks, bool recursive=false)
 
void addPasses (const std::initializer_list< VisitorRef > &init)
 
const IR::Nodeapply_visitor (const IR::Node *, const char *=0) override
 
bool backtrack (trigger &trig) override
 
PassManagerclone () const override
 
void early_exit ()
 
void listPasses (std::ostream &, cstring sep) const
 
bool never_backtracks () override
 
void removePasses (const std::vector< cstring > &exclude)
 
void setStopOnError (bool stop)
 
- Public Member Functions inherited from P4::Visitor
virtual bool check_clone (const Visitor *a)
 
virtual bool check_global (cstring)
 
virtual void clear_globals ()
 
virtual ControlFlowVisitorcontrolFlowVisitor ()
 
virtual void end_apply ()
 
virtual void end_apply (const IR::Node *root)
 
virtual void erase_global (cstring)
 
template<class T >
const T * findContext () const
 
template<class T >
const T * findContext (const Context *&c) const
 
template<class T >
const T * findOrigCtxt () const
 
template<class T >
const T * findOrigCtxt (const Context *&c) const
 
virtual Visitorflow_clone ()
 
virtual void flow_merge (Visitor &)
 
virtual bool flow_merge_closure (Visitor &)
 
virtual void flow_merge_global_from (cstring)
 
virtual void flow_merge_global_to (cstring)
 
const ContextgetChildContext () const
 
int getChildrenVisited () const
 
const ContextgetContext () const
 
int getContextDepth () const
 
const IR::NodegetCurrentNode () const
 
template<class T >
const T * getCurrentNode () const
 
const IR::NodegetOriginal () const
 
template<class T >
const T * getOriginal () const
 
template<class T >
const T * getParent () const
 
virtual bool has_flow_joins () const
 
profile_t init_apply (const IR::Node *root, const Context *parent_context)
 
bool isInContext (const IR::Node *n) const
 
virtual const char * name () const
 
template<class T >
void parallel_visit (const IR::Vector< T > &v, const char *name, int cidx)
 
template<class T >
void parallel_visit (const IR::Vector< T > &v, const char *name=0)
 
template<class T >
void parallel_visit (IR::Vector< T > &v, const char *name, int cidx)
 
template<class T >
void parallel_visit (IR::Vector< T > &v, const char *name=0)
 
void print_context () const
 
const VisitorsetCalledBy (const Visitor *visitor)
 
void setName (const char *name)
 
void visit (const IR::Node &n, const char *name, int cidx)
 
void visit (const IR::Node &n, const char *name=0)
 
void visit (const IR::Node *&n, const char *name, int cidx)
 
void visit (const IR::Node *&n, const char *name=0)
 
void visit (const IR::Node *const &n, const char *name, int cidx)
 
void visit (const IR::Node *const &n, const char *name=0)
 
void visit (IR::Node &n, const char *name, int cidx)
 
void visit (IR::Node &n, const char *name=0)
 
void visit (IR::Node *&, const char *=0, int=0)
 
template<class T , typename = std::enable_if_t<Util::has_SourceInfo_v<T> && !std::is_pointer_v<T>>, class... Args>
void warn (const int kind, const char *format, const T &node, Args &&...args)
 The const ref variant of the above.
 
template<class T , typename = std::enable_if_t<Util::has_SourceInfo_v<T>>, class... Args>
void warn (const int kind, const char *format, const T *node, Args &&...args)
 
bool warning_enabled (int warning_kind) const
 
- Public Member Functions inherited from P4::Backtrack

Static Public Attributes

static const cstring non_struct_pad_suf = "_padded"_cs
 
static const cstring pad_ctr_name = "min_parse_depth_counter"_cs
 
static const cstring pad_hdr_field = "packet_payload"_cs
 
static const cstring pad_hdr_name = "min_parse_depth_padding"_cs
 
static const cstring pad_hdr_type_name = "min_parse_depth_padding_t"_cs
 
static const cstring pad_state_name = "min_parse_depth"_cs
 

Additional Inherited Members

- Public Types inherited from P4::Visitor
typedef Visitor_Context Context
 
- Static Public Member Functions inherited from P4::Visitor
static cstring demangle (const char *)
 
static bool warning_enabled (const Visitor *visitor, int warning_kind)
 
- Public Attributes inherited from P4::Visitor
const Visitorcalled_by = nullptr
 
cstring internalName
 
SplitFlowVisit_base *& split_link
 
SplitFlowVisit_basesplit_link_mem = nullptr
 
- Protected Member Functions inherited from P4::PassManager
profile_t init_apply (const IR::Node *root) override
 
void runDebugHooks (const char *visitorName, const IR::Node *node)
 
- Protected Member Functions inherited from P4::Visitor
virtual void init_join_flows (const IR::Node *)
 
virtual bool join_flows (const IR::Node *)
 
virtual void post_join_flows (const IR::Node *, const IR::Node *)
 
void visit_children (const IR::Node *, std::function< void()> fn)
 
virtual void visitAgain () const
 
virtual void visitOnce () const
 
- Protected Attributes inherited from P4::PassManager
safe_vector< DebugHookdebugHooks
 
safe_vector< Visitor * > passes
 
bool running = false
 
unsigned seqNo = 0
 
bool stop_on_error = true
 
- Protected Attributes inherited from P4::Visitor
bool dontForwardChildrenBeforePreorder = false
 
bool joinFlows = false
 
bool visitDagOnce = true
 

◆ CheckFieldCorruption

class CheckFieldCorruption
Inheritance diagram for CheckFieldCorruption:
[legend]

Public Member Functions

 CheckFieldCorruption (const FieldDefUse &defuse, const PhvInfo &phv, const PHV::Pragmas &pragmas)
 
void end_apply () override
 
bool preorder (const IR::BFN::DeparserParameter *) override
 
bool preorder (const IR::BFN::Digest *) override
 
bool preorder (const IR::BFN::ParserZeroInit *) override
 
bool preorder (const IR::BFN::Pipe *) override
 
bool preorder (const IR::Expression *) override
 
- Public Member Functions inherited from P4::Inspector
const IR::Nodeapply_visitor (const IR::Node *, const char *name=0) override
 
profile_t init_apply (const IR::Node *root) override
 
virtual void loop_revisit (const IR::Node *)
 
virtual void postorder (const IR::Node *)
 
virtual bool preorder (const IR::Node *)
 
virtual void revisit (const IR::Node *)
 
void revisit_visited ()
 
bool visit_in_progress (const IR::Node *n) const
 
void visitAgain () const override
 
void visitOnce () const override
 
- Public Member Functions inherited from P4::Visitor
virtual bool check_global (cstring)
 
virtual void clear_globals ()
 
virtual Visitorclone () const
 
virtual ControlFlowVisitorcontrolFlowVisitor ()
 
virtual void end_apply (const IR::Node *root)
 
virtual void erase_global (cstring)
 
template<class T >
const T * findContext () const
 
template<class T >
const T * findContext (const Context *&c) const
 
template<class T >
const T * findOrigCtxt () const
 
template<class T >
const T * findOrigCtxt (const Context *&c) const
 
virtual Visitorflow_clone ()
 
virtual void flow_merge (Visitor &)
 
virtual bool flow_merge_closure (Visitor &)
 
virtual void flow_merge_global_from (cstring)
 
virtual void flow_merge_global_to (cstring)
 
const ContextgetChildContext () const
 
int getChildrenVisited () const
 
const ContextgetContext () const
 
int getContextDepth () const
 
const IR::NodegetCurrentNode () const
 
template<class T >
const T * getCurrentNode () const
 
const IR::NodegetOriginal () const
 
template<class T >
const T * getOriginal () const
 
template<class T >
const T * getParent () const
 
virtual bool has_flow_joins () const
 
profile_t init_apply (const IR::Node *root, const Context *parent_context)
 
bool isInContext (const IR::Node *n) const
 
virtual const char * name () const
 
template<class T >
void parallel_visit (const IR::Vector< T > &v, const char *name, int cidx)
 
template<class T >
void parallel_visit (const IR::Vector< T > &v, const char *name=0)
 
template<class T >
void parallel_visit (IR::Vector< T > &v, const char *name, int cidx)
 
template<class T >
void parallel_visit (IR::Vector< T > &v, const char *name=0)
 
void print_context () const
 
const VisitorsetCalledBy (const Visitor *visitor)
 
void setName (const char *name)
 
void visit (const IR::Node &n, const char *name, int cidx)
 
void visit (const IR::Node &n, const char *name=0)
 
void visit (const IR::Node *&n, const char *name, int cidx)
 
void visit (const IR::Node *&n, const char *name=0)
 
void visit (const IR::Node *const &n, const char *name, int cidx)
 
void visit (const IR::Node *const &n, const char *name=0)
 
void visit (IR::Node &n, const char *name, int cidx)
 
void visit (IR::Node &n, const char *name=0)
 
void visit (IR::Node *&, const char *=0, int=0)
 
template<class T , typename = std::enable_if_t<Util::has_SourceInfo_v<T> && !std::is_pointer_v<T>>, class... Args>
void warn (const int kind, const char *format, const T &node, Args &&...args)
 The const ref variant of the above.
 
template<class T , typename = std::enable_if_t<Util::has_SourceInfo_v<T>>, class... Args>
void warn (const int kind, const char *format, const T *node, Args &&...args)
 
bool warning_enabled (int warning_kind) const
 

Protected Member Functions

bool copackedFieldExtractedSeparately (const FieldDefUse::locpair &use)
 
- Protected Member Functions inherited from P4::Visitor
virtual void init_join_flows (const IR::Node *)
 
virtual bool join_flows (const IR::Node *)
 
virtual void post_join_flows (const IR::Node *, const IR::Node *)
 
void visit_children (const IR::Node *, std::function< void()> fn)
 

Additional Inherited Members

- Public Types inherited from P4::Visitor
typedef Visitor_Context Context
 
- Static Public Member Functions inherited from P4::Visitor
static cstring demangle (const char *)
 
static bool warning_enabled (const Visitor *visitor, int warning_kind)
 
- Public Attributes inherited from P4::Visitor
const Visitorcalled_by = nullptr
 
cstring internalName
 
SplitFlowVisit_base *& split_link
 
SplitFlowVisit_basesplit_link_mem = nullptr
 
- Protected Attributes inherited from P4::Visitor
bool dontForwardChildrenBeforePreorder = false
 
bool joinFlows = false
 
bool visitDagOnce = true
 

Member Function Documentation

◆ copackedFieldExtractedSeparately()

bool CheckFieldCorruption::copackedFieldExtractedSeparately ( const FieldDefUse::locpair & use)
protected

Check if any other fields that share a container with the field in use are extracted from packet data independenty from this field and are not mutually exclusive.

Parameters
useUse to check if there are other parser extractions
Returns
Boolean value indicating whether one or more other fields share a container with f that are extracted from packet data and not mutually exclusive.

◆ end_apply()

void CheckFieldCorruption::end_apply ( )
overridevirtual

Reimplemented from P4::Visitor.

◆ preorder()

bool CheckFieldCorruption::preorder ( const IR::BFN::Pipe * pipe)
override

Copyright (C) 2024 Intel Corporation

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

SPDX-License-Identifier: Apache-2.0

◆ CheckParserMultiWrite

struct CheckParserMultiWrite

Checks multiple writes to the same field on non-mutually exclusive paths.

Inheritance diagram for CheckParserMultiWrite:
[legend]

Public Member Functions

 CheckParserMultiWrite (const PhvInfo &phv)
 
- Public Member Functions inherited from P4::PassManager
 PassManager (const PassManager &)=default
 
 PassManager (const std::initializer_list< VisitorRef > &init)
 
 PassManager (PassManager &&)=default
 
void addDebugHook (DebugHook h, bool recursive=false)
 
void addDebugHooks (std::vector< DebugHook > hooks, bool recursive=false)
 
void addPasses (const std::initializer_list< VisitorRef > &init)
 
const IR::Nodeapply_visitor (const IR::Node *, const char *=0) override
 
bool backtrack (trigger &trig) override
 
PassManagerclone () const override
 
void early_exit ()
 
void listPasses (std::ostream &, cstring sep) const
 
bool never_backtracks () override
 
void removePasses (const std::vector< cstring > &exclude)
 
void setStopOnError (bool stop)
 
- Public Member Functions inherited from P4::Visitor
virtual bool check_clone (const Visitor *a)
 
virtual bool check_global (cstring)
 
virtual void clear_globals ()
 
virtual ControlFlowVisitorcontrolFlowVisitor ()
 
virtual void end_apply ()
 
virtual void end_apply (const IR::Node *root)
 
virtual void erase_global (cstring)
 
template<class T >
const T * findContext () const
 
template<class T >
const T * findContext (const Context *&c) const
 
template<class T >
const T * findOrigCtxt () const
 
template<class T >
const T * findOrigCtxt (const Context *&c) const
 
virtual Visitorflow_clone ()
 
virtual void flow_merge (Visitor &)
 
virtual bool flow_merge_closure (Visitor &)
 
virtual void flow_merge_global_from (cstring)
 
virtual void flow_merge_global_to (cstring)
 
const ContextgetChildContext () const
 
int getChildrenVisited () const
 
const ContextgetContext () const
 
int getContextDepth () const
 
const IR::NodegetCurrentNode () const
 
template<class T >
const T * getCurrentNode () const
 
const IR::NodegetOriginal () const
 
template<class T >
const T * getOriginal () const
 
template<class T >
const T * getParent () const
 
virtual bool has_flow_joins () const
 
profile_t init_apply (const IR::Node *root, const Context *parent_context)
 
bool isInContext (const IR::Node *n) const
 
virtual const char * name () const
 
template<class T >
void parallel_visit (const IR::Vector< T > &v, const char *name, int cidx)
 
template<class T >
void parallel_visit (const IR::Vector< T > &v, const char *name=0)
 
template<class T >
void parallel_visit (IR::Vector< T > &v, const char *name, int cidx)
 
template<class T >
void parallel_visit (IR::Vector< T > &v, const char *name=0)
 
void print_context () const
 
const VisitorsetCalledBy (const Visitor *visitor)
 
void setName (const char *name)
 
void visit (const IR::Node &n, const char *name, int cidx)
 
void visit (const IR::Node &n, const char *name=0)
 
void visit (const IR::Node *&n, const char *name, int cidx)
 
void visit (const IR::Node *&n, const char *name=0)
 
void visit (const IR::Node *const &n, const char *name, int cidx)
 
void visit (const IR::Node *const &n, const char *name=0)
 
void visit (IR::Node &n, const char *name, int cidx)
 
void visit (IR::Node &n, const char *name=0)
 
void visit (IR::Node *&, const char *=0, int=0)
 
template<class T , typename = std::enable_if_t<Util::has_SourceInfo_v<T> && !std::is_pointer_v<T>>, class... Args>
void warn (const int kind, const char *format, const T &node, Args &&...args)
 The const ref variant of the above.
 
template<class T , typename = std::enable_if_t<Util::has_SourceInfo_v<T>>, class... Args>
void warn (const int kind, const char *format, const T *node, Args &&...args)
 
bool warning_enabled (int warning_kind) const
 
- Public Member Functions inherited from P4::Backtrack

Public Attributes

const PhvInfophv
 
- Public Attributes inherited from P4::Visitor
const Visitorcalled_by = nullptr
 
cstring internalName
 
SplitFlowVisit_base *& split_link
 
SplitFlowVisit_basesplit_link_mem = nullptr
 

Additional Inherited Members

- Public Types inherited from P4::Visitor
typedef Visitor_Context Context
 
- Static Public Member Functions inherited from P4::Visitor
static cstring demangle (const char *)
 
static bool warning_enabled (const Visitor *visitor, int warning_kind)
 
- Protected Member Functions inherited from P4::PassManager
profile_t init_apply (const IR::Node *root) override
 
void runDebugHooks (const char *visitorName, const IR::Node *node)
 
- Protected Member Functions inherited from P4::Visitor
virtual void init_join_flows (const IR::Node *)
 
virtual bool join_flows (const IR::Node *)
 
virtual void post_join_flows (const IR::Node *, const IR::Node *)
 
void visit_children (const IR::Node *, std::function< void()> fn)
 
virtual void visitAgain () const
 
virtual void visitOnce () const
 
- Protected Attributes inherited from P4::PassManager
safe_vector< DebugHookdebugHooks
 
safe_vector< Visitor * > passes
 
bool running = false
 
unsigned seqNo = 0
 
bool stop_on_error = true
 
- Protected Attributes inherited from P4::Visitor
bool dontForwardChildrenBeforePreorder = false
 
bool joinFlows = false
 
bool visitDagOnce = true
 

◆ CollectClotInfo

class CollectClotInfo
Inheritance diagram for CollectClotInfo:
[legend]

Public Member Functions

 CollectClotInfo (const PhvInfo &phv, ClotInfo &clotInfo, const PragmaDoNotUseClot &pragmaDoNotUseClot)
 
- Public Member Functions inherited from P4::Inspector
const IR::Nodeapply_visitor (const IR::Node *, const char *name=0) override
 
profile_t init_apply (const IR::Node *root) override
 
virtual void loop_revisit (const IR::Node *)
 
virtual void postorder (const IR::Node *)
 
virtual bool preorder (const IR::Node *)
 
virtual void revisit (const IR::Node *)
 
void revisit_visited ()
 
bool visit_in_progress (const IR::Node *n) const
 
void visitAgain () const override
 
void visitOnce () const override
 
- Public Member Functions inherited from P4::Visitor
virtual bool check_global (cstring)
 
virtual void clear_globals ()
 
virtual Visitorclone () const
 
virtual ControlFlowVisitorcontrolFlowVisitor ()
 
virtual void end_apply ()
 
virtual void end_apply (const IR::Node *root)
 
virtual void erase_global (cstring)
 
template<class T >
const T * findContext () const
 
template<class T >
const T * findContext (const Context *&c) const
 
template<class T >
const T * findOrigCtxt () const
 
template<class T >
const T * findOrigCtxt (const Context *&c) const
 
virtual Visitorflow_clone ()
 
virtual void flow_merge (Visitor &)
 
virtual bool flow_merge_closure (Visitor &)
 
virtual void flow_merge_global_from (cstring)
 
virtual void flow_merge_global_to (cstring)
 
const ContextgetChildContext () const
 
int getChildrenVisited () const
 
const ContextgetContext () const
 
int getContextDepth () const
 
const IR::NodegetCurrentNode () const
 
template<class T >
const T * getCurrentNode () const
 
const IR::NodegetOriginal () const
 
template<class T >
const T * getOriginal () const
 
template<class T >
const T * getParent () const
 
virtual bool has_flow_joins () const
 
profile_t init_apply (const IR::Node *root, const Context *parent_context)
 
bool isInContext (const IR::Node *n) const
 
virtual const char * name () const
 
template<class T >
void parallel_visit (const IR::Vector< T > &v, const char *name, int cidx)
 
template<class T >
void parallel_visit (const IR::Vector< T > &v, const char *name=0)
 
template<class T >
void parallel_visit (IR::Vector< T > &v, const char *name, int cidx)
 
template<class T >
void parallel_visit (IR::Vector< T > &v, const char *name=0)
 
void print_context () const
 
const VisitorsetCalledBy (const Visitor *visitor)
 
void setName (const char *name)
 
void visit (const IR::Node &n, const char *name, int cidx)
 
void visit (const IR::Node &n, const char *name=0)
 
void visit (const IR::Node *&n, const char *name, int cidx)
 
void visit (const IR::Node *&n, const char *name=0)
 
void visit (const IR::Node *const &n, const char *name, int cidx)
 
void visit (const IR::Node *const &n, const char *name=0)
 
void visit (IR::Node &n, const char *name, int cidx)
 
void visit (IR::Node &n, const char *name=0)
 
void visit (IR::Node *&, const char *=0, int=0)
 
template<class T , typename = std::enable_if_t<Util::has_SourceInfo_v<T> && !std::is_pointer_v<T>>, class... Args>
void warn (const int kind, const char *format, const T &node, Args &&...args)
 The const ref variant of the above.
 
template<class T , typename = std::enable_if_t<Util::has_SourceInfo_v<T>>, class... Args>
void warn (const int kind, const char *format, const T *node, Args &&...args)
 
bool warning_enabled (int warning_kind) const
 

Additional Inherited Members

- Public Types inherited from P4::Visitor
typedef Visitor_Context Context
 
- Static Public Member Functions inherited from P4::Visitor
static cstring demangle (const char *)
 
static bool warning_enabled (const Visitor *visitor, int warning_kind)
 
- Public Attributes inherited from P4::Visitor
const Visitorcalled_by = nullptr
 
cstring internalName
 
SplitFlowVisit_base *& split_link
 
SplitFlowVisit_basesplit_link_mem = nullptr
 
- Protected Member Functions inherited from P4::Visitor
virtual void init_join_flows (const IR::Node *)
 
virtual bool join_flows (const IR::Node *)
 
virtual void post_join_flows (const IR::Node *, const IR::Node *)
 
void visit_children (const IR::Node *, std::function< void()> fn)
 
- Protected Attributes inherited from P4::Visitor
bool dontForwardChildrenBeforePreorder = false
 
bool joinFlows = false
 
bool visitDagOnce = true
 

◆ CollectParserInfoImpl

class CollectParserInfoImpl
template<class Parser, class State, class Transition>
class CollectParserInfoImpl< Parser, State, Transition >
Inheritance diagram for CollectParserInfoImpl< Parser, State, Transition >:
[legend]

Public Member Functions

const std::set< int > * get_all_shift_amounts (const State *dst) const
 
const std::set< int > * get_all_shift_amounts (const State *src, const State *dst) const
 
int get_max_shift_amount (const State *dst) const
 
int get_min_shift_amount (const State *dst) const
 
const GraphTypegraph (const Parser *p) const
 
const GraphTypegraph (const State *s) const
 
const ordered_map< const Parser *, GraphType * > & graphs () const
 
const Parser * parser (const State *state) const
 

Member Function Documentation

◆ get_all_shift_amounts() [1/2]

template<class Parser , class State , class Transition >
const std::set< int > * CollectParserInfoImpl< Parser, State, Transition >::get_all_shift_amounts ( const State * dst) const
inline
Returns
all possible shift amounts, in bits, for all paths from the start state to dst . If dst is the start state, then a singleton 0 is returned.

DANGER: This method assumes the parser graph is a DAG.

◆ get_all_shift_amounts() [2/2]

template<class Parser , class State , class Transition >
const std::set< int > * CollectParserInfoImpl< Parser, State, Transition >::get_all_shift_amounts ( const State * src,
const State * dst ) const
inline
Returns
all possible shift amounts, in bits, for all paths from src to dst. If the two states are the same, then a singleton 0 is returned. If the states are mutually exclusive, an empty set is returned. If src is an ancestor of dst, then the shift amounts will be positive; otherwise, if src is a descendant of dst, then the shift amounts will be negative.
Precondition
DANGER: This method assumes the parser graph is a DAG.

◆ get_max_shift_amount()

template<class Parser , class State , class Transition >
int CollectParserInfoImpl< Parser, State, Transition >::get_max_shift_amount ( const State * dst) const
inline
Returns
the maximum possible shift amount, in bits, of all paths from the start state to dst.
Precondition
DANGER: This method assumes the parser graph is a DAG.

◆ get_min_shift_amount()

template<class Parser , class State , class Transition >
int CollectParserInfoImpl< Parser, State, Transition >::get_min_shift_amount ( const State * dst) const
inline
Returns
the minimum possible shift amount, in bits, of all paths from the start state to dst.
Precondition
DANGER: This method assumes the parser graph is a DAG.

◆ ComputeDefUse

class ComputeDefUse

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

Copyright (C) 2024 Intel Corporation

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

SPDX-License-Identifier: Apache-2.0

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.
Inheritance diagram for ComputeDefUse:
[legend]

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::IDeclarationgetDeclaration (const IR::Path *path, bool notNull=false) const
 
const IR::IDeclarationgetDeclaration (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::IDeclarationresolvePath (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::IDeclarationresolveUnique (const IR::ID &name, ResolutionType type, const IR::INamespace *=nullptr) const
 Resolve reference for name, restricted to type declarations, and expect one result.
 
- Public Member Functions inherited from P4::Visitor
virtual const IR::Nodeapply_visitor (const IR::Node *n, const char *name=0)=0
 
virtual bool check_clone (const Visitor *a)
 
virtual bool check_global (cstring)
 
virtual void clear_globals ()
 
virtual ControlFlowVisitorcontrolFlowVisitor ()
 
virtual void end_apply (const IR::Node *root)
 
virtual void erase_global (cstring)
 
template<class T >
const T * findContext () const
 
template<class T >
const T * findContext (const Context *&c) const
 
template<class T >
const T * findOrigCtxt () const
 
template<class T >
const T * findOrigCtxt (const Context *&c) const
 
virtual Visitorflow_clone ()
 
virtual void flow_merge (Visitor &)
 
virtual bool flow_merge_closure (Visitor &)
 
virtual void flow_merge_global_from (cstring)
 
virtual void flow_merge_global_to (cstring)
 
const ContextgetChildContext () const
 
int getChildrenVisited () const
 
const ContextgetContext () const
 
int getContextDepth () const
 
const IR::NodegetCurrentNode () const
 
template<class T >
const T * getCurrentNode () const
 
const IR::NodegetOriginal () const
 
template<class T >
const T * getOriginal () const
 
template<class T >
const T * getParent () const
 
virtual bool has_flow_joins () const
 
virtual profile_t init_apply (const IR::Node *root)
 
profile_t init_apply (const IR::Node *root, const Context *parent_context)
 
bool isInContext (const IR::Node *n) const
 
virtual const char * name () const
 
template<class T >
void parallel_visit (const IR::Vector< T > &v, const char *name, int cidx)
 
template<class T >
void parallel_visit (const IR::Vector< T > &v, const char *name=0)
 
template<class T >
void parallel_visit (IR::Vector< T > &v, const char *name, int cidx)
 
template<class T >
void parallel_visit (IR::Vector< T > &v, const char *name=0)
 
void print_context () const
 
const VisitorsetCalledBy (const Visitor *visitor)
 
void setName (const char *name)
 
void visit (const IR::Node &n, const char *name, int cidx)
 
void visit (const IR::Node &n, const char *name=0)
 
void visit (const IR::Node *&n, const char *name, int cidx)
 
void visit (const IR::Node *&n, const char *name=0)
 
void visit (const IR::Node *const &n, const char *name, int cidx)
 
void visit (const IR::Node *const &n, const char *name=0)
 
void visit (IR::Node &n, const char *name, int cidx)
 
void visit (IR::Node &n, const char *name=0)
 
void visit (IR::Node *&, const char *=0, int=0)
 
template<class T , typename = std::enable_if_t<Util::has_SourceInfo_v<T> && !std::is_pointer_v<T>>, class... Args>
void warn (const int kind, const char *format, const T &node, Args &&...args)
 The const ref variant of the above.
 
template<class T , typename = std::enable_if_t<Util::has_SourceInfo_v<T>>, class... Args>
void warn (const int kind, const char *format, const T *node, Args &&...args)
 
bool warning_enabled (int warning_kind) const
 
- Public Member Functions inherited from P4::DeclarationLookup

Friends

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

Additional Inherited Members

- Public Types inherited from P4::Visitor
typedef Visitor_Context Context
 
- Static Public Member Functions inherited from P4::Visitor
static cstring demangle (const char *)
 
static bool warning_enabled (const Visitor *visitor, int warning_kind)
 
- Public Attributes inherited from P4::Visitor
const Visitorcalled_by = nullptr
 
cstring internalName
 
SplitFlowVisit_base *& split_link
 
SplitFlowVisit_basesplit_link_mem = nullptr
 
- 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 Member Functions inherited from P4::Visitor
virtual void init_join_flows (const IR::Node *)
 
virtual bool join_flows (const IR::Node *)
 
virtual void post_join_flows (const IR::Node *, const IR::Node *)
 
void visit_children (const IR::Node *, std::function< void()> fn)
 
virtual void visitAgain () const
 
virtual void visitOnce () const
 
- Protected Attributes inherited from P4::ResolutionContext
bool anyOrder = false
 
- Protected Attributes inherited from P4::Visitor
bool dontForwardChildrenBeforePreorder = false
 
bool joinFlows = false
 
bool visitDagOnce = true
 

◆ DeparserAsmOutput

struct DeparserAsmOutput

Helper that can generate deparser assembly and write it to an output stream.

Public Member Functions

 DeparserAsmOutput (const IR::BFN::Pipe *pipe, const PhvInfo &phv, const ClotInfo &clot, gress_t)
 

Public Attributes

const ClotInfoclot
 
const PhvInfophv
 

Friends

std::ostream & operator<< (std::ostream &out, const DeparserAsmOutput &deparserOut)
 

◆ DeparserInspector

class DeparserInspector
Inheritance diagram for DeparserInspector:
[legend]

◆ DeparserModifier

class DeparserModifier
Inheritance diagram for DeparserModifier:
[legend]

◆ DeparserTransform

class DeparserTransform
Inheritance diagram for DeparserTransform:
[legend]

◆ DirectedGraph

class DirectedGraph
Inheritance diagram for DirectedGraph:
[legend]

Public Member Functions

 DirectedGraph (const DirectedGraph &other)
 
void add_edge (int src, int dst)
 
int add_vertex ()
 
void print_stats () const
 
std::vector< int > topological_sort () const
 

◆ DumpParser

class DumpParser

Dumps the entire parser graphs (can be used before and also after parser lowering).

Inheritance diagram for DumpParser:
[legend]

Public Member Functions

 DumpParser (std::string filename, bool detail=false, bool to_log=false)
 
 DumpParser (std::string filename, std::vector< assoc::set< void * > > &color_groups, bool detail=false, bool to_log=false)
 
- Public Member Functions inherited from P4::Visitor
virtual const IR::Nodeapply_visitor (const IR::Node *n, const char *name=0)=0
 
virtual bool check_clone (const Visitor *a)
 
virtual bool check_global (cstring)
 
virtual void clear_globals ()
 
virtual Visitorclone () const
 
virtual ControlFlowVisitorcontrolFlowVisitor ()
 
virtual void end_apply ()
 
virtual void end_apply (const IR::Node *root)
 
virtual void erase_global (cstring)
 
template<class T >
const T * findContext () const
 
template<class T >
const T * findContext (const Context *&c) const
 
template<class T >
const T * findOrigCtxt () const
 
template<class T >
const T * findOrigCtxt (const Context *&c) const
 
virtual Visitorflow_clone ()
 
virtual void flow_merge (Visitor &)
 
virtual bool flow_merge_closure (Visitor &)
 
virtual void flow_merge_global_from (cstring)
 
virtual void flow_merge_global_to (cstring)
 
const ContextgetChildContext () const
 
int getChildrenVisited () const
 
const ContextgetContext () const
 
int getContextDepth () const
 
const IR::NodegetCurrentNode () const
 
template<class T >
const T * getCurrentNode () const
 
const IR::NodegetOriginal () const
 
template<class T >
const T * getOriginal () const
 
template<class T >
const T * getParent () const
 
virtual bool has_flow_joins () const
 
virtual profile_t init_apply (const IR::Node *root)
 
profile_t init_apply (const IR::Node *root, const Context *parent_context)
 
bool isInContext (const IR::Node *n) const
 
virtual const char * name () const
 
template<class T >
void parallel_visit (const IR::Vector< T > &v, const char *name, int cidx)
 
template<class T >
void parallel_visit (const IR::Vector< T > &v, const char *name=0)
 
template<class T >
void parallel_visit (IR::Vector< T > &v, const char *name, int cidx)
 
template<class T >
void parallel_visit (IR::Vector< T > &v, const char *name=0)
 
void print_context () const
 
const VisitorsetCalledBy (const Visitor *visitor)
 
void setName (const char *name)
 
void visit (const IR::Node &n, const char *name, int cidx)
 
void visit (const IR::Node &n, const char *name=0)
 
void visit (const IR::Node *&n, const char *name, int cidx)
 
void visit (const IR::Node *&n, const char *name=0)
 
void visit (const IR::Node *const &n, const char *name, int cidx)
 
void visit (const IR::Node *const &n, const char *name=0)
 
void visit (IR::Node &n, const char *name, int cidx)
 
void visit (IR::Node &n, const char *name=0)
 
void visit (IR::Node *&, const char *=0, int=0)
 
template<class T , typename = std::enable_if_t<Util::has_SourceInfo_v<T> && !std::is_pointer_v<T>>, class... Args>
void warn (const int kind, const char *format, const T &node, Args &&...args)
 The const ref variant of the above.
 
template<class T , typename = std::enable_if_t<Util::has_SourceInfo_v<T>>, class... Args>
void warn (const int kind, const char *format, const T *node, Args &&...args)
 
bool warning_enabled (int warning_kind) const
 
- Public Member Functions inherited from DotDumper
 DotDumper (std::string filename, bool detail)
 
 DotDumper (std::string filename, std::vector< assoc::set< void * > > &color_groups, bool detail)
 

Additional Inherited Members

- Public Types inherited from P4::Visitor
typedef Visitor_Context Context
 
- Static Public Member Functions inherited from P4::Visitor
static cstring demangle (const char *)
 
static bool warning_enabled (const Visitor *visitor, int warning_kind)
 
- Public Attributes inherited from P4::Visitor
const Visitorcalled_by = nullptr
 
cstring internalName
 
SplitFlowVisit_base *& split_link
 
SplitFlowVisit_basesplit_link_mem = nullptr
 
- Protected Member Functions inherited from P4::Visitor
virtual void init_join_flows (const IR::Node *)
 
virtual bool join_flows (const IR::Node *)
 
virtual void post_join_flows (const IR::Node *, const IR::Node *)
 
void visit_children (const IR::Node *, std::function< void()> fn)
 
virtual void visitAgain () const
 
virtual void visitOnce () const
 
- Protected Member Functions inherited from DotDumper
void dump (const IR::BFN::LoweredParserGraph &graph, gress_t gress)
 
void dump (const IR::BFN::LoweredParserMatch *match)
 
void dump (const IR::BFN::LoweredParserState *state)
 
void dump (const IR::BFN::ParserGraph &graph, gress_t gress)
 
void dump (const IR::BFN::ParserState *state)
 
void dump (const IR::BFN::Transition *transition)
 
template<typename ParserGraphType >
void dump_graph (const ParserGraphType &graph, gress_t gress, int pipe_id)
 
std::string get_color (const IR::BFN::ParserState *state)
 
std::string lookup_color (void *obj)
 
std::ofstream * open_file (gress_t gress, int pipe_id, cstring directory="graphs"_cs)
 
std::string to_label (std::string label)
 
std::string to_label (std::string label, const void *what)
 
void write_to_file (std::ofstream *fs)
 
- Static Protected Member Functions inherited from DotDumper
static std::string escape (std::string s)
 
- Protected Attributes inherited from P4::Visitor
bool dontForwardChildrenBeforePreorder = false
 
bool joinFlows = false
 
bool visitDagOnce = true
 
- Protected Attributes inherited from DotDumper
std::string cluster_name
 
std::vector< assoc::set< void * > > * color_groups = nullptr
 
std::vector< std::string > colors
 
bool detail = true
 
std::string filename
 
std::stringstream out
 

◆ FieldDefUse

class FieldDefUse
Inheritance diagram for FieldDefUse:
[legend]

Public Types

typedef std::pair< const IR::BFN::Unit *, const IR::Expression * > locpair
 
typedef ordered_set< locpairLocPairSet
 
enum  VisitMode { VisitJustReads , VisitJustWrites , VisitAll }
 
- Public Types inherited from P4::Visitor
typedef Visitor_Context Context
 

Public Member Functions

 FieldDefUse (const PhvInfo &p)
 
const ordered_map< int, LocPairSet > & getAllDefs () const
 
const LocPairSetgetAllDefs (int fid) const
 
const LocPairSet getAllDefsAndUses (const PHV::Field *f) const
 
const LocPairSet getAllDefsAndUses (int fid) const
 
const ordered_map< int, LocPairSet > & getAllUses () const
 
const LocPairSetgetAllUses (int fid) const
 
const LocPairSetgetDefs (const IR::BFN::Unit *u, const IR::Expression *e) const
 
const LocPairSetgetDefs (const Visitor *v, const IR::Expression *e) const
 
const LocPairSetgetDefs (locpair use) const
 
const LocPairSetgetOutputDeps (const IR::BFN::Unit *u, const IR::Expression *e) const
 
const LocPairSetgetOutputDeps (const Visitor *v, const IR::Expression *e) const
 
const LocPairSetgetOutputDeps (locpair def) const
 
LocPairSet getParserDefs (const PHV::Field *f, std::optional< le_bitrange > bits) const
 
LocPairSet getParserDefs (const PHV::FieldSlice &fs) const
 
const ordered_set< const PHV::Field * > & getUninitializedFields () const
 
const LocPairSetgetUses (const IR::BFN::Unit *u, const IR::Expression *e) const
 
const LocPairSetgetUses (const Visitor *v, const IR::Expression *e) const
 
const LocPairSetgetUses (locpair def) const
 
bool hasDefAt (const PHV::Field *f, const IR::BFN::Unit *u) const
 
bool hasDefInParser (const PHV::Field *f, std::optional< le_bitrange > bits) const
 
bool hasDefInParser (const PHV::FieldSlice &fs) const
 
bool hasNonDarkContext (locpair info) const
 
bool hasUninitializedRead (int fid) const
 
bool hasUseAt (const PHV::Field *f, const IR::BFN::Unit *u) const
 
bool isUsedInParser (const PHV::Field *f) const
 
- Public Member Functions inherited from P4::ControlFlowVisitor
bool check_global (cstring key) override
 
void clear_globals () override
 
ControlFlowVisitorcontrolFlowVisitor () override
 
void erase_global (cstring key) override
 
ControlFlowVisitorflow_clone () override
 
virtual void flow_copy (ControlFlowVisitor &)=0
 
const flow_join_info_tflow_join_status (const IR::Node *n) const
 
void flow_merge_global_from (cstring key) override
 
void flow_merge_global_to (cstring key) override
 
bool has_flow_joins () const override
 
bool isUnreachable ()
 
bool operator!= (const ControlFlowVisitor &v) const
 
virtual bool operator== (const ControlFlowVisitor &) const
 
void restore_global (std::pair< cstring, ControlFlowVisitor * > saved)
 
std::pair< cstring, ControlFlowVisitor * > save_global (cstring key)
 
void setUnreachable ()
 
- Public Member Functions inherited from P4::Visitor
virtual void end_apply (const IR::Node *root)
 
template<class T >
const T * findContext () const
 
template<class T >
const T * findContext (const Context *&c) const
 
template<class T >
const T * findOrigCtxt () const
 
template<class T >
const T * findOrigCtxt (const Context *&c) const
 
virtual bool flow_merge_closure (Visitor &)
 
const ContextgetChildContext () const
 
int getChildrenVisited () const
 
const ContextgetContext () const
 
int getContextDepth () const
 
const IR::NodegetCurrentNode () const
 
template<class T >
const T * getCurrentNode () const
 
const IR::NodegetOriginal () const
 
template<class T >
const T * getOriginal () const
 
template<class T >
const T * getParent () const
 
profile_t init_apply (const IR::Node *root, const Context *parent_context)
 
bool isInContext (const IR::Node *n) const
 
virtual const char * name () const
 
template<class T >
void parallel_visit (const IR::Vector< T > &v, const char *name, int cidx)
 
template<class T >
void parallel_visit (const IR::Vector< T > &v, const char *name=0)
 
template<class T >
void parallel_visit (IR::Vector< T > &v, const char *name, int cidx)
 
template<class T >
void parallel_visit (IR::Vector< T > &v, const char *name=0)
 
void print_context () const
 
const VisitorsetCalledBy (const Visitor *visitor)
 
void setName (const char *name)
 
void visit (const IR::Node &n, const char *name, int cidx)
 
void visit (const IR::Node &n, const char *name=0)
 
void visit (const IR::Node *&n, const char *name, int cidx)
 
void visit (const IR::Node *&n, const char *name=0)
 
void visit (const IR::Node *const &n, const char *name, int cidx)
 
void visit (const IR::Node *const &n, const char *name=0)
 
void visit (IR::Node &n, const char *name, int cidx)
 
void visit (IR::Node &n, const char *name=0)
 
void visit (IR::Node *&, const char *=0, int=0)
 
template<class T , typename = std::enable_if_t<Util::has_SourceInfo_v<T> && !std::is_pointer_v<T>>, class... Args>
void warn (const int kind, const char *format, const T &node, Args &&...args)
 The const ref variant of the above.
 
template<class T , typename = std::enable_if_t<Util::has_SourceInfo_v<T>>, class... Args>
void warn (const int kind, const char *format, const T *node, Args &&...args)
 
bool warning_enabled (int warning_kind) const
 
- Public Member Functions inherited from P4::Inspector
const IR::Nodeapply_visitor (const IR::Node *, const char *name=0) override
 
profile_t init_apply (const IR::Node *root) override
 
virtual void loop_revisit (const IR::Node *)
 
virtual void postorder (const IR::Node *)
 
virtual bool preorder (const IR::Node *)
 
virtual void revisit (const IR::Node *)
 
void revisit_visited ()
 
bool visit_in_progress (const IR::Node *n) const
 
void visitAgain () const override
 
void visitOnce () const override
 

Public Attributes

VisitMode mode = VisitAll
 
- Public Attributes inherited from P4::Visitor
const Visitorcalled_by = nullptr
 
cstring internalName
 
SplitFlowVisit_base *& split_link
 
SplitFlowVisit_basesplit_link_mem = nullptr
 

Static Public Attributes

static const std::unordered_set< cstringwrite_by_parser
 

Friends

void dump (const FieldDefUse::info &a)
 
std::ostream & operator<< (std::ostream &out, const FieldDefUse &a)
 
std::ostream & operator<< (std::ostream &out, const FieldDefUse::info &i)
 

Additional Inherited Members

- Static Public Member Functions inherited from P4::Visitor
static cstring demangle (const char *)
 
static bool warning_enabled (const Visitor *visitor, int warning_kind)
 
- Protected Types inherited from P4::ControlFlowVisitor
typedef std::map< const IR::Node *, flow_join_info_tflow_join_points_t
 
- Protected Member Functions inherited from P4::ControlFlowVisitor
virtual void applySetupJoinPoints (const IR::Node *root)
 
virtual bool filter_join_point (const IR::Node *)
 
void init_join_flows (const IR::Node *root) override
 
bool join_flows (const IR::Node *n) override
 
void post_join_flows (const IR::Node *, const IR::Node *) override
 
- Protected Member Functions inherited from P4::Visitor
void visit_children (const IR::Node *, std::function< void()> fn)
 
- Protected Attributes inherited from P4::ControlFlowVisitor
bool BackwardsCompatibleBroken = false
 
flow_join_points_t * flow_join_points = 0
 
bool unreachable = false
 
- Protected Attributes inherited from P4::Visitor
bool dontForwardChildrenBeforePreorder = false
 
bool joinFlows = false
 
bool visitDagOnce = true
 

Member Typedef Documentation

◆ locpair

std::pair<const IR::BFN::Unit *, const IR::Expression *> FieldDefUse::locpair

A given expression for a field might appear multiple places in the IR dag (eg, an action used by mulitple tables), so we use a pair<Unit,Expr> to denote a particular use or definition in the code

Member Function Documentation

◆ getAllDefs()

const LocPairSet & FieldDefUse::getAllDefs ( int fid) const
inline

Get all defs of the PHV::Field with ID fid.

◆ getAllDefsAndUses() [1/2]

const LocPairSet FieldDefUse::getAllDefsAndUses ( const PHV::Field * f) const
inline

Get all defs and uses of the PHV::Field

◆ getAllDefsAndUses() [2/2]

const LocPairSet FieldDefUse::getAllDefsAndUses ( int fid) const
inline

Get all defs and uses of the PHV::Field with ID fid.

◆ getAllUses()

const LocPairSet & FieldDefUse::getAllUses ( int fid) const
inline

Get all uses of the PHV::Field with ID fid.

◆ getOutputDeps()

const LocPairSet & FieldDefUse::getOutputDeps ( locpair def) const
inline
Returns
all defs that the given def may overwrite.

◆ isUsedInParser()

bool FieldDefUse::isUsedInParser ( const PHV::Field * f) const
Returns
true if the field f is used in the parser.

Member Data Documentation

◆ write_by_parser

const std::unordered_set< cstring > FieldDefUse::write_by_parser
static
Initial value:
= {
"ingress::ig_intr_md_from_prsr.parser_err"_cs, "egress::eg_intr_md_from_prsr.parser_err"_cs}

TODO: move them to IR and remove this hack. These constant variables are fields with the bug that hardware behaviors are not correctly captured by our IR. For example, parser_err might be written in parser, but our IR does not have any node to represent it.

◆ FindParserHeaderEncounterInfo

class FindParserHeaderEncounterInfo

Based on dominators and post-dominators of parser states, determines which other headers have also surely been encountered if a given header has been encountered and which other headers have not been encountered if a given header has not been encountered.

Inheritance diagram for FindParserHeaderEncounterInfo:
[legend]

Public Member Functions

 FindParserHeaderEncounterInfo (PhvInfo &phv, HeaderInfo &header_info)
 
- Public Member Functions inherited from ParserDominatorBuilder

Additional Inherited Members

- Public Types inherited from ParserDominatorBuilder
using Graph = ReversibleParserGraph::Graph
 
using IndexImmediateDominatorMap = ordered_map<int, int>
 
using IndexMap = boost::property_map<Graph, boost::vertex_index_t>::type
 
using PredMap = boost::iterator_property_map<std::vector<Vertex>::iterator, IndexMap>
 
using StateImmediateDominatorMap
 
using Vertex = boost::graph_traits<Graph>::vertex_descriptor
 
- Protected Member Functions inherited from ParserDominatorBuilder
void end_apply () override
 
std::set< const IR::BFN::ParserState * > get_all_dominatees (const IR::BFN::ParserState *state, gress_t gress=INGRESS)
 Get all parser states that are dominated by state.
 
std::set< const IR::BFN::ParserState * > get_all_dominators (const IR::BFN::ParserState *state, gress_t gress=INGRESS)
 Get all parser states that dominate state.
 
std::set< const IR::BFN::ParserState * > get_all_post_dominatees (const IR::BFN::ParserState *state, gress_t gress=INGRESS)
 Get all parser states that are post-dominated by state.
 
std::set< const IR::BFN::ParserState * > get_all_post_dominators (const IR::BFN::ParserState *state, gress_t gress=INGRESS)
 Get all post-dominators of a given parser state.
 
profile_t init_apply (const IR::Node *root) override
 
- Protected Attributes inherited from ParserDominatorBuilder
ordered_map< gress_t, StateImmediateDominatorMapimmediate_dominators
 
ordered_map< gress_t, StateImmediateDominatorMapimmediate_post_dominators
 
ordered_map< gress_t, ReversibleParserGraphparser_graphs
 
std::set< const IR::BFN::ParserState * > states
 

◆ GreedyClotAllocator

class GreedyClotAllocator

Copyright (C) 2024 Intel Corporation

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

SPDX-License-Identifier: Apache-2.0

This implements a greedy CLOT-allocation algorithm, as described in CLOT allocator and metric (README.md).

Inheritance diagram for GreedyClotAllocator:
[legend]

Public Member Functions

 GreedyClotAllocator (const PhvInfo &phvInfo, ClotInfo &clotInfo, bool logAllocation)
 
- Public Member Functions inherited from P4::Visitor
virtual const IR::Nodeapply_visitor (const IR::Node *n, const char *name=0)=0
 
virtual bool check_clone (const Visitor *a)
 
virtual bool check_global (cstring)
 
virtual void clear_globals ()
 
virtual Visitorclone () const
 
virtual ControlFlowVisitorcontrolFlowVisitor ()
 
virtual void end_apply (const IR::Node *root)
 
virtual void erase_global (cstring)
 
template<class T >
const T * findContext () const
 
template<class T >
const T * findContext (const Context *&c) const
 
template<class T >
const T * findOrigCtxt () const
 
template<class T >
const T * findOrigCtxt (const Context *&c) const
 
virtual Visitorflow_clone ()
 
virtual void flow_merge (Visitor &)
 
virtual bool flow_merge_closure (Visitor &)
 
virtual void flow_merge_global_from (cstring)
 
virtual void flow_merge_global_to (cstring)
 
const ContextgetChildContext () const
 
int getChildrenVisited () const
 
const ContextgetContext () const
 
int getContextDepth () const
 
const IR::NodegetCurrentNode () const
 
template<class T >
const T * getCurrentNode () const
 
const IR::NodegetOriginal () const
 
template<class T >
const T * getOriginal () const
 
template<class T >
const T * getParent () const
 
virtual bool has_flow_joins () const
 
virtual profile_t init_apply (const IR::Node *root)
 
profile_t init_apply (const IR::Node *root, const Context *parent_context)
 
bool isInContext (const IR::Node *n) const
 
virtual const char * name () const
 
template<class T >
void parallel_visit (const IR::Vector< T > &v, const char *name, int cidx)
 
template<class T >
void parallel_visit (const IR::Vector< T > &v, const char *name=0)
 
template<class T >
void parallel_visit (IR::Vector< T > &v, const char *name, int cidx)
 
template<class T >
void parallel_visit (IR::Vector< T > &v, const char *name=0)
 
void print_context () const
 
const VisitorsetCalledBy (const Visitor *visitor)
 
void setName (const char *name)
 
void visit (const IR::Node &n, const char *name, int cidx)
 
void visit (const IR::Node &n, const char *name=0)
 
void visit (const IR::Node *&n, const char *name, int cidx)
 
void visit (const IR::Node *&n, const char *name=0)
 
void visit (const IR::Node *const &n, const char *name, int cidx)
 
void visit (const IR::Node *const &n, const char *name=0)
 
void visit (IR::Node &n, const char *name, int cidx)
 
void visit (IR::Node &n, const char *name=0)
 
void visit (IR::Node *&, const char *=0, int=0)
 
template<class T , typename = std::enable_if_t<Util::has_SourceInfo_v<T> && !std::is_pointer_v<T>>, class... Args>
void warn (const int kind, const char *format, const T &node, Args &&...args)
 The const ref variant of the above.
 
template<class T , typename = std::enable_if_t<Util::has_SourceInfo_v<T>>, class... Args>
void warn (const int kind, const char *format, const T *node, Args &&...args)
 
bool warning_enabled (int warning_kind) const
 

Additional Inherited Members

- Public Types inherited from P4::Visitor
typedef Visitor_Context Context
 
- Static Public Member Functions inherited from P4::Visitor
static cstring demangle (const char *)
 
static bool warning_enabled (const Visitor *visitor, int warning_kind)
 
- Public Attributes inherited from P4::Visitor
const Visitorcalled_by = nullptr
 
cstring internalName
 
SplitFlowVisit_base *& split_link
 
SplitFlowVisit_basesplit_link_mem = nullptr
 
- Protected Member Functions inherited from P4::Visitor
virtual void init_join_flows (const IR::Node *)
 
virtual bool join_flows (const IR::Node *)
 
virtual void post_join_flows (const IR::Node *, const IR::Node *)
 
void visit_children (const IR::Node *, std::function< void()> fn)
 
virtual void visitAgain () const
 
virtual void visitOnce () const
 
- Protected Attributes inherited from P4::Visitor
bool dontForwardChildrenBeforePreorder = false
 
bool joinFlows = false
 
bool visitDagOnce = true
 

◆ HasFullMatchCoverage

class HasFullMatchCoverage

Copyright (C) 2024 Intel Corporation

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

SPDX-License-Identifier: Apache-2.0

Public Member Functions

 HasFullMatchCoverage (const std::vector< match_t > &matches)
 

Public Attributes

bool rv = false
 

◆ ImplicitParserInit

class ImplicitParserInit

Represent the parser initialization that sets all fields to zero. This is actually a dummy subclass of IR::Expression to work with the locpair setup. NEVER insert this class to IR, because it is not a IR node, because it is not registered in visiter classes.

Inheritance diagram for ImplicitParserInit:
[legend]

Public Member Functions

 ImplicitParserInit (const PHV::Field *f)
 
void dbprint (std::ostream &out) const override
 
 DECLARE_TYPEINFO (ImplicitParserInit)
 

Public Attributes

const PHV::Fieldfield
 

◆ InferPayloadOffset

class InferPayloadOffset

Copyright (C) 2024 Intel Corporation

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

SPDX-License-Identifier: Apache-2.0

In JBay, parser has new feature of stopping the header length counter in any state, by asserting the hdr_len_inc_stop flag from output action RAM (In Tofino, the header length counter is stopped when parsing terminates). The application of this feature is deep packet parsing (peeking deep into packet without having to extract).

This also means the extraction of the last mutable (modifiable) field in the packet is effectively the header/payload boundary. The compiler can use this feature and infer where to assert hdr_len_inc_stop in the parse graph (what this pass does). After hdr_len_inc_stop is asserted, fields can still be extracted, for read-only operation in the MAU, but cannot not be deparsed anymore. The unused fields after hdr_len_inc_stop is asserted can be then dead-code eliminated, alleviating pressure on CLOT allocation, and potentially PHV allocation (if CLOT allocation spills fields onto PHV due to the 3-byte-gap constraint).

Concisely, we formalize the problem as below:

Given a parse graph G, and a set of states, M, with mutable fields to extract, we want to compute a set of states E where the hdr_len_inc_stop need to be asserted.

Consider the parse graph below where state b and c have mutable fields to extract.

              (a)
              /\
             /  \
            /   (b)
           |    /|\
           |   / | \
           |  /  |  \
           | /   |   |
          (c)    |   |
          / \    |   |
         /   \  /    |
        |    (d)     |
        |     |     /
         \    |    /
          \   |   /
           \  |  /
            [pipe]
  1. Compute the bi-partition of set of states, D, that are descendants of M, and its exclusion set D'. In this example,

    D = { d, ingress_pipe } D' = { start, a, b, c }

  2. Compute the cut-set, C, which consists of the transitions that cross the bi-parition, D and D'. In this example,

    C = { c->ingress_pipe, c->d, b->d, b->ingress_pipe }.

  3. Apply the following rules to absorb the transitions into the states in C.

    a) If all outgoing transitions of s in G is equal to all outgoing transitions of s in C b) If all incoming transitions of s in G is equal to all incoming transitions of s in C

    In this example, we end up with

    C = { c->ingress_pipe, b, d }

  4. Insert state on remaining transitions in C. In this example, we insert state $hdr_len_inc_stop_0 on c->ingress_pipe

    Finally, We arrive at solution of E = { c, d, $hdr_len_inc_stop_0 }

TODO someone forgets stop the residual checksum calculation when hdr_len_inc_stop is asserted, compiler needs to apply SW workaround described in JBAY-2873.

Inheritance diagram for InferPayloadOffset:
[legend]

Public Member Functions

 InferPayloadOffset (const PhvInfo &phv, const FieldDefUse &defuse)
 
- Public Member Functions inherited from P4::PassManager
 PassManager (const PassManager &)=default
 
 PassManager (const std::initializer_list< VisitorRef > &init)
 
 PassManager (PassManager &&)=default
 
void addDebugHook (DebugHook h, bool recursive=false)
 
void addDebugHooks (std::vector< DebugHook > hooks, bool recursive=false)
 
void addPasses (const std::initializer_list< VisitorRef > &init)
 
const IR::Nodeapply_visitor (const IR::Node *, const char *=0) override
 
bool backtrack (trigger &trig) override
 
PassManagerclone () const override
 
void early_exit ()
 
void listPasses (std::ostream &, cstring sep) const
 
bool never_backtracks () override
 
void removePasses (const std::vector< cstring > &exclude)
 
void setStopOnError (bool stop)
 
- Public Member Functions inherited from P4::Visitor
virtual bool check_clone (const Visitor *a)
 
virtual bool check_global (cstring)
 
virtual void clear_globals ()
 
virtual ControlFlowVisitorcontrolFlowVisitor ()
 
virtual void end_apply ()
 
virtual void end_apply (const IR::Node *root)
 
virtual void erase_global (cstring)
 
template<class T >
const T * findContext () const
 
template<class T >
const T * findContext (const Context *&c) const
 
template<class T >
const T * findOrigCtxt () const
 
template<class T >
const T * findOrigCtxt (const Context *&c) const
 
virtual Visitorflow_clone ()
 
virtual void flow_merge (Visitor &)
 
virtual bool flow_merge_closure (Visitor &)
 
virtual void flow_merge_global_from (cstring)
 
virtual void flow_merge_global_to (cstring)
 
const ContextgetChildContext () const
 
int getChildrenVisited () const
 
const ContextgetContext () const
 
int getContextDepth () const
 
const IR::NodegetCurrentNode () const
 
template<class T >
const T * getCurrentNode () const
 
const IR::NodegetOriginal () const
 
template<class T >
const T * getOriginal () const
 
template<class T >
const T * getParent () const
 
virtual bool has_flow_joins () const
 
profile_t init_apply (const IR::Node *root, const Context *parent_context)
 
bool isInContext (const IR::Node *n) const
 
virtual const char * name () const
 
template<class T >
void parallel_visit (const IR::Vector< T > &v, const char *name, int cidx)
 
template<class T >
void parallel_visit (const IR::Vector< T > &v, const char *name=0)
 
template<class T >
void parallel_visit (IR::Vector< T > &v, const char *name, int cidx)
 
template<class T >
void parallel_visit (IR::Vector< T > &v, const char *name=0)
 
void print_context () const
 
const VisitorsetCalledBy (const Visitor *visitor)
 
void setName (const char *name)
 
void visit (const IR::Node &n, const char *name, int cidx)
 
void visit (const IR::Node &n, const char *name=0)
 
void visit (const IR::Node *&n, const char *name, int cidx)
 
void visit (const IR::Node *&n, const char *name=0)
 
void visit (const IR::Node *const &n, const char *name, int cidx)
 
void visit (const IR::Node *const &n, const char *name=0)
 
void visit (IR::Node &n, const char *name, int cidx)
 
void visit (IR::Node &n, const char *name=0)
 
void visit (IR::Node *&, const char *=0, int=0)
 
template<class T , typename = std::enable_if_t<Util::has_SourceInfo_v<T> && !std::is_pointer_v<T>>, class... Args>
void warn (const int kind, const char *format, const T &node, Args &&...args)
 The const ref variant of the above.
 
template<class T , typename = std::enable_if_t<Util::has_SourceInfo_v<T>>, class... Args>
void warn (const int kind, const char *format, const T *node, Args &&...args)
 
bool warning_enabled (int warning_kind) const
 
- Public Member Functions inherited from P4::Backtrack

Additional Inherited Members

- Public Types inherited from P4::Visitor
typedef Visitor_Context Context
 
- Static Public Member Functions inherited from P4::Visitor
static cstring demangle (const char *)
 
static bool warning_enabled (const Visitor *visitor, int warning_kind)
 
- Public Attributes inherited from P4::Visitor
const Visitorcalled_by = nullptr
 
cstring internalName
 
SplitFlowVisit_base *& split_link
 
SplitFlowVisit_basesplit_link_mem = nullptr
 
- Protected Member Functions inherited from P4::PassManager
profile_t init_apply (const IR::Node *root) override
 
void runDebugHooks (const char *visitorName, const IR::Node *node)
 
- Protected Member Functions inherited from P4::Visitor
virtual void init_join_flows (const IR::Node *)
 
virtual bool join_flows (const IR::Node *)
 
virtual void post_join_flows (const IR::Node *, const IR::Node *)
 
void visit_children (const IR::Node *, std::function< void()> fn)
 
virtual void visitAgain () const
 
virtual void visitOnce () const
 
- Protected Attributes inherited from P4::PassManager
safe_vector< DebugHookdebugHooks
 
safe_vector< Visitor * > passes
 
bool running = false
 
unsigned seqNo = 0
 
bool stop_on_error = true
 
- Protected Attributes inherited from P4::Visitor
bool dontForwardChildrenBeforePreorder = false
 
bool joinFlows = false
 
bool visitDagOnce = true
 

◆ LoweredParserMatchAllocator

class LoweredParserMatchAllocator

Copyright (C) 2024 Intel Corporation

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

SPDX-License-Identifier: Apache-2.0

Public Member Functions

 LoweredParserMatchAllocator (const IR::BFN::LoweredParserMatch *s, ClotInfo &clot)
 

Public Attributes

std::vector< const IR::BFN::LoweredParserChecksum * > checksums
 
ClotInfoclot
 
std::vector< const IR::BFN::LoweredExtractClot * > clot_extracts
 
std::vector< const IR::BFN::ParserCounterPrimitive * > counters
 
IR::Vector< IR::BFN::LoweredParserPrimitive > current_statements
 
std::vector< const IR::BFN::LoweredParserPrimitive * > others
 
std::vector< const IR::BFN::LoweredExtractPhv * > phv_extracts
 
bool spill_selects = false
 
IR::Vector< IR::BFN::LoweredParserPrimitive > spilled_statements
 
const IR::BFN::LoweredParserMatch * state
 

◆ MergeParserStates

struct MergeParserStates

Merges a chain of states into a large state (before parser lowering). Find the longest chain that: Forall states expect for the last tail state:

Copyright (C) 2024 Intel Corporation

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

SPDX-License-Identifier: Apache-2.0

  1. Only has one default branch. Forall states incluing the last:
  2. Is not a merge point of multiple states.
  3. Does not have match resiger def/use dependency.
Inheritance diagram for MergeParserStates:
[legend]

◆ P4ParserGraphs

class P4ParserGraphs

Extends p4c's parser graph with various algorithms.

Copyright (C) 2024 Intel Corporation

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

SPDX-License-Identifier: Apache-2.0

Inheritance diagram for P4ParserGraphs:
[legend]

Public Member Functions

 P4ParserGraphs (P4::ReferenceMap *refMap, bool dumpDot)
 
std::set< std::set< cstring > > compute_loops (const IR::P4Parser *parser) const
 
std::set< std::set< cstring > > compute_strongly_connected_components (const IR::P4Parser *parser) const
 
boost::adjacency_list< boost::vecS, boost::vecS, boost::directedS > create_boost_graph (const IR::P4Parser *parser, std::map< int, cstring > &id_to_state) const
 
ordered_set< const IR::ParserState * > get_all_ancestors (const IR::ParserState *state) const
 
ordered_set< const IR::ParserState * > get_all_descendants (const IR::ParserState *state) const
 
const IR::P4Parser * get_parser (const IR::ParserState *state) const
 a kludge due to base class's lack of state -> parser reverse map
 
const IR::ParserState * get_state (const IR::P4Parser *parser, cstring state) const
 
bool has_loops (const IR::P4Parser *parser) const
 
bool is_ancestor (cstring a, cstring b) const
 Is "a" an ancestor of "b"?
 
bool is_descendant (cstring a, cstring b) const
 Is "a" a descendant of "b"?
 
std::vector< cstring > topological_sort (const IR::P4Parser *parser) const
 

Public Attributes

bool dumpDot
 
std::map< cstring, ordered_set< cstring > > preds
 
std::map< cstring, ordered_set< cstring > > succs
 

Member Function Documentation

◆ compute_strongly_connected_components()

std::set< std::set< cstring > > P4ParserGraphs::compute_strongly_connected_components ( const IR::P4Parser * parser) const

Compute the strongly connected components in the frontend parser IR. We will use SCCs to figure out where the loops are in the parser.

◆ PardeInspector

class PardeInspector

Copyright (C) 2024 Intel Corporation

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

SPDX-License-Identifier: Apache-2.0

Inheritance diagram for PardeInspector:
[legend]

◆ PardeModifier

class PardeModifier
Inheritance diagram for PardeModifier:
[legend]

◆ PardeTransform

class PardeTransform
Inheritance diagram for PardeTransform:
[legend]

◆ ParserAsmOutput

struct ParserAsmOutput

Helper that can generate parser assembly and write it to an output stream.

Public Member Functions

 ParserAsmOutput (const IR::BFN::Pipe *pipe, const PhvInfo &phv, const ClotInfo &clot_info, gress_t gress)
 

Friends

std::ostream & operator<< (std::ostream &out, const ParserAsmOutput &parserOut)
 

◆ ParserDominatorBuilder

class ParserDominatorBuilder

Builds parser graphs and determines the dominators and post-dominators of all parser states. Using this information, you can infer many things. For example:

Copyright (C) 2024 Intel Corporation

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

SPDX-License-Identifier: Apache-2.0

Determining which other headers have also surely been encountered if a given header has been encountered and which other headers have not been encountered if a given header has not been encountered (see "bf-p4c/phv/analysis/header_mutex.h/cpp").

Inheritance diagram for ParserDominatorBuilder:
[legend]

Public Types

using Graph = ReversibleParserGraph::Graph
 
using IndexImmediateDominatorMap = ordered_map<int, int>
 
using IndexMap = boost::property_map<Graph, boost::vertex_index_t>::type
 
using PredMap = boost::iterator_property_map<std::vector<Vertex>::iterator, IndexMap>
 
using StateImmediateDominatorMap
 
using Vertex = boost::graph_traits<Graph>::vertex_descriptor
 

Protected Member Functions

void end_apply () override
 
std::set< const IR::BFN::ParserState * > get_all_dominatees (const IR::BFN::ParserState *state, gress_t gress=INGRESS)
 Get all parser states that are dominated by state.
 
std::set< const IR::BFN::ParserState * > get_all_dominators (const IR::BFN::ParserState *state, gress_t gress=INGRESS)
 Get all parser states that dominate state.
 
std::set< const IR::BFN::ParserState * > get_all_post_dominatees (const IR::BFN::ParserState *state, gress_t gress=INGRESS)
 Get all parser states that are post-dominated by state.
 
std::set< const IR::BFN::ParserState * > get_all_post_dominators (const IR::BFN::ParserState *state, gress_t gress=INGRESS)
 Get all post-dominators of a given parser state.
 
profile_t init_apply (const IR::Node *root) override
 

Protected Attributes

ordered_map< gress_t, StateImmediateDominatorMapimmediate_dominators
 
ordered_map< gress_t, StateImmediateDominatorMapimmediate_post_dominators
 
ordered_map< gress_t, ReversibleParserGraphparser_graphs
 
std::set< const IR::BFN::ParserState * > states
 

Member Typedef Documentation

◆ StateImmediateDominatorMap

Initial value:
ordered_map<const IR::BFN::ParserState *, const IR::BFN::ParserState *>

Member Function Documentation

◆ get_all_dominatees()

std::set< const IR::BFN::ParserState * > ParserDominatorBuilder::get_all_dominatees ( const IR::BFN::ParserState * state,
gress_t gress = INGRESS )
protected

Get all parser states that are dominated by state.

Parameters
stateParser state on which to perform search
gressOptional. Only used if state equals nullptr (End of Parser), as which gress the End of Parser belongs to cannot be deduced without it
Returns
std::set<const IR::BFN::ParserState*> A set of all dominatees of state

◆ get_all_dominators()

std::set< const IR::BFN::ParserState * > ParserDominatorBuilder::get_all_dominators ( const IR::BFN::ParserState * state,
gress_t gress = INGRESS )
protected

Get all parser states that dominate state.

Parameters
stateParser state on which to perform search
gressOptional. Only used if state equals nullptr (End of Parser), as which gress the End of Parser belongs to cannot be deduced without it
Returns
std::set<const IR::BFN::ParserState*> A set of all dominators of state

◆ get_all_post_dominatees()

std::set< const IR::BFN::ParserState * > ParserDominatorBuilder::get_all_post_dominatees ( const IR::BFN::ParserState * state,
gress_t gress = INGRESS )
protected

Get all parser states that are post-dominated by state.

Parameters
stateParser state on which to perform search
gressOptional. Only used if state equals nullptr (End of Parser), as which gress the End of Parser belongs to cannot be deduced without it
Returns
std::set<const IR::BFN::ParserState*> A set of all post-dominatees of state

◆ get_all_post_dominators()

std::set< const IR::BFN::ParserState * > ParserDominatorBuilder::get_all_post_dominators ( const IR::BFN::ParserState * state,
gress_t gress = INGRESS )
protected

Get all post-dominators of a given parser state.

Parameters
stateParser state on which to perform search
gressOptional. Only used if state equals nullptr (End of Parser), as which gress the End of Parser belongs to cannot be deduced without it
Returns
std::set<const IR::BFN::ParserState*> A set of all post-dominators of state

◆ init_apply()

Visitor::profile_t ParserDominatorBuilder::init_apply ( const IR::Node * root)
overrideprotected

Copyright (C) 2024 Intel Corporation

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

SPDX-License-Identifier: Apache-2.0

◆ ParserGraphImpl

class ParserGraphImpl
template<class Parser, class State, class Transition>
class ParserGraphImpl< Parser, State, Transition >
Inheritance diagram for ParserGraphImpl< Parser, State, Transition >:
[legend]

Public Member Functions

 ParserGraphImpl (const Parser *parser)
 
ordered_set< const State * > get_all_descendants (const State *src) const
 
const State * get_dst (const Transition *t) const
 
const State * get_src (const Transition *t) const
 
const State * get_state (cstring name) const
 
bool is_ancestor (const State *src, const State *dst) const
 Is "src" an ancestor of "dst"?
 
bool is_descendant (const State *src, const State *dst) const
 
bool is_dominated_by_set (const State *s, const ordered_set< const State * > &set)
 
bool is_loop_reachable (const State *src, const State *dst) const
 
std::pair< const State *, const State * > is_loopback_reassignment (const State *s, const ordered_set< const State * > &set)
 
bool is_loopback_state (cstring state) const
 
bool is_mutex (const ordered_set< const State * > &states) const
 
bool is_mutex (const State *a, const State *b) const
 
bool is_mutex (const Transition *a, const Transition *b) const
 
bool is_postdominated_by_set (const State *s, const ordered_set< const State * > &set)
 
bool is_reachable (const State *src, const State *dst) const
 
std::pair< unsigned, std::vector< const State * > > longest_path_bytes (const State *src) const
 
std::vector< const State * > longest_path_states (const State *src) const
 
std::vector< const State * > longest_path_states_to (const State *dest) const
 
ordered_map< std::pair< const State *, cstring >, ordered_set< const Transition * > > loopbacks () const
 
const ParserStateMap< State > & predecessors () const
 
std::pair< unsigned, std::vector< const State * > > shortest_path_bytes (const State *src) const
 
std::vector< const State * > shortest_path_states (const State *src) const
 
std::pair< unsigned, std::vector< const State * > > shortest_path_thru_bytes (const State *src) const
 
const ordered_set< const State * > & states () const
 
const ParserStateMap< State > & successors () const
 
const ordered_map< const State *, ordered_set< const Transition * > > & to_pipe () const
 
ordered_set< const Transition * > to_pipe (const State *src) const
 
std::vector< const State * > topological_sort () const
 
ordered_set< const Transition * > transitions (const State *src, const State *dst) const
 
ordered_set< const Transition * > transitions_to (const State *dst) const
 
- Public Member Functions inherited from DirectedGraph
 DirectedGraph (const DirectedGraph &other)
 
void add_edge (int src, int dst)
 
int add_vertex ()
 
void print_stats () const
 
std::vector< int > topological_sort () const
 

Public Attributes

const State *const root
 

Friends

template<class P , class S , class T >
class CollectParserInfoImpl
 

Member Function Documentation

◆ is_ancestor()

template<class Parser , class State , class Transition >
bool ParserGraphImpl< Parser, State, Transition >::is_ancestor ( const State * src,
const State * dst ) const
inline

Is "src" an ancestor of "dst"?

DANGER – this assumes parser graph is a unrolled DAG

◆ is_dominated_by_set()

template<class Parser , class State , class Transition >
bool ParserGraphImpl< Parser, State, Transition >::is_dominated_by_set ( const State * s,
const ordered_set< const State * > & set )
inline

Determines whether s is dominated by the set of states set. This means that every path from start to s leads through (at least) one of the states from set.

◆ is_loopback_reassignment()

template<class Parser , class State , class Transition >
std::pair< const State *, const State * > ParserGraphImpl< Parser, State, Transition >::is_loopback_reassignment ( const State * s,
const ordered_set< const State * > & set )
inline

Determines whether s is postdominated by the set of states set within any loopback and also the loop exit state of that loopback is dominated by the set of states set (or alternatively the loopback is reflexive on a state from set). This means that every path from start of the loop to loop exit leads through (at least) one of the states from set and also s is part of this loop and also every path from the start (of parsing) to loop exit leads through one of the states from set. More specifically this means that there is a loopback for which we are certain the following is always satisfied:

  • To even reach/take this loopback we had to go through one of the states from the set = loop exit is dominated by the set
  • After taking the loopback we will go through at least one the states again = loop start is postdominated by the set within the loop boundaries If the set of states is for example a set of all states extracting a given field this means that taking this loopback under any circumstances forces a reassignment of the given field. Loop start in this case is the first state within the loopback (the state the loopback transition goes to) and loop exit is the last state in the loopback (state that the loopback transition goes from).

◆ is_mutex() [1/2]

template<class Parser , class State , class Transition >
bool ParserGraphImpl< Parser, State, Transition >::is_mutex ( const ordered_set< const State * > & states) const
inline

Determines whether the states in the given set are all mutually exclusive on all paths through the parser graph.

◆ is_mutex() [2/2]

template<class Parser , class State , class Transition >
bool ParserGraphImpl< Parser, State, Transition >::is_mutex ( const State * a,
const State * b ) const
inline

Determines whether src and dst are mutually exclusive states on all paths through the parser graph.

◆ is_postdominated_by_set()

template<class Parser , class State , class Transition >
bool ParserGraphImpl< Parser, State, Transition >::is_postdominated_by_set ( const State * s,
const ordered_set< const State * > & set )
inline

Determines whether s is postdominated by the set of states set. This means that every path from s to exit leads through (at least) one of the states from set.

◆ is_reachable()

template<class Parser , class State , class Transition >
bool ParserGraphImpl< Parser, State, Transition >::is_reachable ( const State * src,
const State * dst ) const
inline

Determines whether dst can be reached from src. It can be reached directly (without taking any loops, essentially is_ancestor) or via loops. This function is essentially a recursive DFS.

First the function checks if dst is reachable from src directly. If it is not it tries to take any loop available. To take the loop we need to be able to (directly) reach the state that the loop loops from. Also the state that the loop takes us to should be some new state that we could not otherwise reach (without taking the loop). If we could reach the state directly then taking the loop does not make sense. Also it might create infinite recursion (see example below). Once we have found some new state that can be reached via a loop we just check (recursively) reachability from this new state (once again we can take another loop).

Example why we need to do this recursively and why we need to check if the loop takes us somewhere new follows. Let's assume the following part of a parse graph: ┌───────────────┐ │ │ ▼ │ ┌───┐ ┌───┐ ┌───┐ ┌───┐ │ A │──▶│ B │──▶│ C │──▶│ D │ └───┘ └───┘ └───┘ └───┘ ▲ │ │ │ └───────────────┘

Recursion example: Let's try is_reachable(D,A). It is not directly reachable, but we can take the D to B loopback (recurse into is_reacheable(B,A)). Still we cannot directly reach A from B, but we can do so by taking another loopback, this time C to A.

Infinite recursion example: Let's try is_reacheable(C,E). Let's assume that E is some state that is outside of the subparser shown and E is not directly reachable from any of the shown states (it is for example reachable only via loop from A). We could take the loopback from C to A (recurse into is_reacheable(A,E)). Now we could take the loopback from D to B, even though it does not take us anywhere new (recurse into is_reacheable(B,E)), where we would take the loopback from C to A again (recurse into is_reacheable(A,E) again). Now we would get stuck between A->D->B->C->A. This is one of the reasons why we never take a loop that does not take us somewhere new. Since we DO check if loop takes us somewhere new we would nrecursionloop does not happen).

◆ ParserInspector

class ParserInspector
Inheritance diagram for ParserInspector:
[legend]

◆ ParserModifier

class ParserModifier
Inheritance diagram for ParserModifier:
[legend]

◆ ParserStateMap

struct ParserStateMap
template<class State>
struct ParserStateMap< State >
Inheritance diagram for ParserStateMap< State >:
[legend]

Additional Inherited Members

- Public Types inherited from P4::ordered_map< const State *, ordered_set< const State * > >
typedef std::allocator< std::pair< const const State *, ordered_set< const State * > > > allocator_type
 
typedef list_type::const_iterator const_iterator
 
typedef const value_type & const_reference
 
typedef std::reverse_iterator< const_iterator > const_reverse_iterator
 
typedef list_type::iterator iterator
 
typedef std::less< const State * > key_compare
 
typedef const State * key_type
 
typedef ordered_set< const State * > mapped_type
 
typedef value_type & reference
 
typedef std::reverse_iterator< iterator > reverse_iterator
 
typedef map_type::size_type size_type
 
typedef std::pair< const const State *, ordered_set< const State * > > value_type
 
- Public Member Functions inherited from P4::ordered_map< const State *, ordered_set< const State * > >
 ordered_map (const ordered_map &a)
 
 ordered_map (InputIt first, InputIt last)
 
 ordered_map (ordered_map &&a)=default
 
 ordered_map (std::initializer_list< value_type > il)
 
ordered_set< const State * > & at (const const State *&x)
 
const ordered_set< const State * > & at (const const State *&x) const
 
const_iterator begin () const noexcept
 
iterator begin () noexcept
 
const_iterator cbegin () const noexcept
 
const_iterator cend () const noexcept
 
void clear ()
 
size_type count (const key_type &a) const
 
const_reverse_iterator crbegin () const noexcept
 
const_reverse_iterator crend () const noexcept
 
std::pair< iterator, bool > emplace (KK &&k, VV &&...v)
 
std::pair< iterator, bool > emplace_hint (iterator pos, KK &&k, VV &&...v)
 
bool empty () const noexcept
 
const_iterator end () const noexcept
 
iterator end () noexcept
 
size_type erase (const const State *&k)
 
iterator erase (const_iterator pos)
 
iterator find (const key_type &a)
 
const_iterator find (const key_type &a) const
 
std::pair< iterator, bool > insert (const value_type &v)
 
void insert (InputIterator b, InputIterator e)
 
std::pair< iterator, bool > insert (iterator pos, const value_type &v)
 
void insert (iterator pos, InputIterator b, InputIterator e)
 
iterator lower_bound (const key_type &a)
 
const_iterator lower_bound (const key_type &a) const
 
size_type max_size () const noexcept
 
bool operator!= (const ordered_map &a) const
 
bool operator< (const ordered_map &a) const
 
ordered_mapoperator= (const ordered_map &a)
 
ordered_mapoperator= (ordered_map &&a)=default
 
bool operator== (const ordered_map &a) const
 
ordered_set< const State * > & operator[] (const const State *&x)
 
ordered_set< const State * > & operator[] (const State *&&x)
 
const_reverse_iterator rbegin () const noexcept
 
reverse_iterator rbegin () noexcept
 
const_reverse_iterator rend () const noexcept
 
reverse_iterator rend () noexcept
 
size_type size () const noexcept
 
void sort (Compare comp)
 
iterator upper_bound (const key_type &a)
 
const_iterator upper_bound (const key_type &a) const
 
iterator upper_bound_pred (const key_type &a)
 
const_iterator upper_bound_pred (const key_type &a) const
 

◆ ParserTransform

class ParserTransform
Inheritance diagram for ParserTransform:
[legend]

◆ Phase0AsmOutput

struct Phase0AsmOutput

Helper that can generate phase0 assembly and write it to an output stream.

Public Member Functions

 Phase0AsmOutput (const IR::BFN::Pipe *pipe, const IR::BFN::Phase0 *phase0)
 

Public Attributes

const IR::BFN::Phase0 * phase0
 
const IR::BFN::Pipe * pipe
 

Friends

std::ostream & operator<< (std::ostream &, const Phase0AsmOutput &)
 

◆ RenameArchParams

class RenameArchParams

Pass that governs replacement of the user-supplied parameter names with the corresponding parameter names defined in the architecture.

Inheritance diagram for RenameArchParams:
[legend]

Public Member Functions

 RenameArchParams (P4::ReferenceMap *refMap, P4::TypeMap *typeMap)
 

◆ ResolveNegativeExtract

struct ResolveNegativeExtract

For extracts with negative source, i.e. source is in an earlier state, adjust the state's shift amount, and possibly move extracts, so that the source is within current state's input buffer.

Copyright (C) 2024 Intel Corporation

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

SPDX-License-Identifier: Apache-2.0

Inheritance diagram for ResolveNegativeExtract:
[legend]

Additional Inherited Members

- Public Types inherited from P4::Visitor
typedef Visitor_Context Context
 
- Public Member Functions inherited from P4::PassManager
 PassManager (const PassManager &)=default
 
 PassManager (const std::initializer_list< VisitorRef > &init)
 
 PassManager (PassManager &&)=default
 
void addDebugHook (DebugHook h, bool recursive=false)
 
void addDebugHooks (std::vector< DebugHook > hooks, bool recursive=false)
 
void addPasses (const std::initializer_list< VisitorRef > &init)
 
const IR::Nodeapply_visitor (const IR::Node *, const char *=0) override
 
bool backtrack (trigger &trig) override
 
PassManagerclone () const override
 
void early_exit ()
 
void listPasses (std::ostream &, cstring sep) const
 
bool never_backtracks () override
 
void removePasses (const std::vector< cstring > &exclude)
 
void setStopOnError (bool stop)
 
- Public Member Functions inherited from P4::Visitor
virtual bool check_clone (const Visitor *a)
 
virtual bool check_global (cstring)
 
virtual void clear_globals ()
 
virtual ControlFlowVisitorcontrolFlowVisitor ()
 
virtual void end_apply ()
 
virtual void end_apply (const IR::Node *root)
 
virtual void erase_global (cstring)
 
template<class T >
const T * findContext () const
 
template<class T >
const T * findContext (const Context *&c) const
 
template<class T >
const T * findOrigCtxt () const
 
template<class T >
const T * findOrigCtxt (const Context *&c) const
 
virtual Visitorflow_clone ()
 
virtual void flow_merge (Visitor &)
 
virtual bool flow_merge_closure (Visitor &)
 
virtual void flow_merge_global_from (cstring)
 
virtual void flow_merge_global_to (cstring)
 
const ContextgetChildContext () const
 
int getChildrenVisited () const
 
const ContextgetContext () const
 
int getContextDepth () const
 
const IR::NodegetCurrentNode () const
 
template<class T >
const T * getCurrentNode () const
 
const IR::NodegetOriginal () const
 
template<class T >
const T * getOriginal () const
 
template<class T >
const T * getParent () const
 
virtual bool has_flow_joins () const
 
profile_t init_apply (const IR::Node *root, const Context *parent_context)
 
bool isInContext (const IR::Node *n) const
 
virtual const char * name () const
 
template<class T >
void parallel_visit (const IR::Vector< T > &v, const char *name, int cidx)
 
template<class T >
void parallel_visit (const IR::Vector< T > &v, const char *name=0)
 
template<class T >
void parallel_visit (IR::Vector< T > &v, const char *name, int cidx)
 
template<class T >
void parallel_visit (IR::Vector< T > &v, const char *name=0)
 
void print_context () const
 
const VisitorsetCalledBy (const Visitor *visitor)
 
void setName (const char *name)
 
void visit (const IR::Node &n, const char *name, int cidx)
 
void visit (const IR::Node &n, const char *name=0)
 
void visit (const IR::Node *&n, const char *name, int cidx)
 
void visit (const IR::Node *&n, const char *name=0)
 
void visit (const IR::Node *const &n, const char *name, int cidx)
 
void visit (const IR::Node *const &n, const char *name=0)
 
void visit (IR::Node &n, const char *name, int cidx)
 
void visit (IR::Node &n, const char *name=0)
 
void visit (IR::Node *&, const char *=0, int=0)
 
template<class T , typename = std::enable_if_t<Util::has_SourceInfo_v<T> && !std::is_pointer_v<T>>, class... Args>
void warn (const int kind, const char *format, const T &node, Args &&...args)
 The const ref variant of the above.
 
template<class T , typename = std::enable_if_t<Util::has_SourceInfo_v<T>>, class... Args>
void warn (const int kind, const char *format, const T *node, Args &&...args)
 
bool warning_enabled (int warning_kind) const
 
- Public Member Functions inherited from P4::Backtrack
- Static Public Member Functions inherited from P4::Visitor
static cstring demangle (const char *)
 
static bool warning_enabled (const Visitor *visitor, int warning_kind)
 
- Public Attributes inherited from P4::Visitor
const Visitorcalled_by = nullptr
 
cstring internalName
 
SplitFlowVisit_base *& split_link
 
SplitFlowVisit_basesplit_link_mem = nullptr
 
- Protected Member Functions inherited from P4::PassManager
profile_t init_apply (const IR::Node *root) override
 
void runDebugHooks (const char *visitorName, const IR::Node *node)
 
- Protected Member Functions inherited from P4::Visitor
virtual void init_join_flows (const IR::Node *)
 
virtual bool join_flows (const IR::Node *)
 
virtual void post_join_flows (const IR::Node *, const IR::Node *)
 
void visit_children (const IR::Node *, std::function< void()> fn)
 
virtual void visitAgain () const
 
virtual void visitOnce () const
 
- Protected Attributes inherited from P4::PassManager
safe_vector< DebugHookdebugHooks
 
safe_vector< Visitor * > passes
 
bool running = false
 
unsigned seqNo = 0
 
bool stop_on_error = true
 
- Protected Attributes inherited from P4::Visitor
bool dontForwardChildrenBeforePreorder = false
 
bool joinFlows = false
 
bool visitDagOnce = true
 

◆ ReversibleParserGraph

class ReversibleParserGraph

This data structure uses different template parameters of boost::adjacency_list than the ones used by the ParserGraphImpl class in order to be able to build a graph who's edges can be reversed using the boost::make_reverse_graph function. This is particularly useful to determine post dominators using the boost::lengauer_tarjan_dominator_tree function. It also uses custom properties to bind ParserStates and Transitions directly to vertices and edges respectively.

Public Types

typedef boost::adjacency_list< boost::vecS, boost::vecS, boost::bidirectionalS, boost::property< boost::vertex_state_t, const IR::BFN::ParserState * >, boost::property< boost::edge_transition_t, const IR::BFN::Transition * > > Graph
 

Public Member Functions

 ReversibleParserGraph (const ReversibleParserGraph &other)
 
std::pair< typename Graph::edge_descriptor, bool > add_edge (const IR::BFN::ParserState *source, const IR::BFN::ParserState *destination, const IR::BFN::Transition *transition)
 
Graph::vertex_descriptor add_vertex (const IR::BFN::ParserState *state)
 
bool contains (const IR::BFN::ParserState *state)
 
bool empty () const
 
Graph::vertex_descriptor get_entry_point ()
 

Public Attributes

std::optional< typename Graph::vertex_descriptor > end
 
Graph graph
 
std::optional< gress_t > gress
 
const IR::BFN::Parser * parser = nullptr
 
ordered_map< const IR::BFN::ParserState *, typename Graph::vertex_descriptor > state_to_vertex
 
ordered_map< typename Graph::vertex_descriptor, const IR::BFN::ParserState * > vertex_to_state
 

◆ RewriteParserMatchDefs

class RewriteParserMatchDefs

Looks for extracts into temporary local variables used in select statements.

A parser can extract fields into temporary local variables and use it in select statements. This pass looks for such extracts and changes the type of its destination to IR::BFN::MatchLVal. The main purpose of this is to avoid phv allocation of such local fields.

Inheritance diagram for RewriteParserMatchDefs:
[legend]

Public Member Functions

 RewriteParserMatchDefs (const PhvInfo &phv)
 
- Public Member Functions inherited from P4::PassManager
 PassManager (const PassManager &)=default
 
 PassManager (const std::initializer_list< VisitorRef > &init)
 
 PassManager (PassManager &&)=default
 
void addDebugHook (DebugHook h, bool recursive=false)
 
void addDebugHooks (std::vector< DebugHook > hooks, bool recursive=false)
 
void addPasses (const std::initializer_list< VisitorRef > &init)
 
const IR::Nodeapply_visitor (const IR::Node *, const char *=0) override
 
bool backtrack (trigger &trig) override
 
PassManagerclone () const override
 
void early_exit ()
 
void listPasses (std::ostream &, cstring sep) const
 
bool never_backtracks () override
 
void removePasses (const std::vector< cstring > &exclude)
 
void setStopOnError (bool stop)
 
- Public Member Functions inherited from P4::Visitor
virtual bool check_clone (const Visitor *a)
 
virtual bool check_global (cstring)
 
virtual void clear_globals ()
 
virtual ControlFlowVisitorcontrolFlowVisitor ()
 
virtual void end_apply ()
 
virtual void end_apply (const IR::Node *root)
 
virtual void erase_global (cstring)
 
template<class T >
const T * findContext () const
 
template<class T >
const T * findContext (const Context *&c) const
 
template<class T >
const T * findOrigCtxt () const
 
template<class T >
const T * findOrigCtxt (const Context *&c) const
 
virtual Visitorflow_clone ()
 
virtual void flow_merge (Visitor &)
 
virtual bool flow_merge_closure (Visitor &)
 
virtual void flow_merge_global_from (cstring)
 
virtual void flow_merge_global_to (cstring)
 
const ContextgetChildContext () const
 
int getChildrenVisited () const
 
const ContextgetContext () const
 
int getContextDepth () const
 
const IR::NodegetCurrentNode () const
 
template<class T >
const T * getCurrentNode () const
 
const IR::NodegetOriginal () const
 
template<class T >
const T * getOriginal () const
 
template<class T >
const T * getParent () const
 
virtual bool has_flow_joins () const
 
profile_t init_apply (const IR::Node *root, const Context *parent_context)
 
bool isInContext (const IR::Node *n) const
 
virtual const char * name () const
 
template<class T >
void parallel_visit (const IR::Vector< T > &v, const char *name, int cidx)
 
template<class T >
void parallel_visit (const IR::Vector< T > &v, const char *name=0)
 
template<class T >
void parallel_visit (IR::Vector< T > &v, const char *name, int cidx)
 
template<class T >
void parallel_visit (IR::Vector< T > &v, const char *name=0)
 
void print_context () const
 
const VisitorsetCalledBy (const Visitor *visitor)
 
void setName (const char *name)
 
void visit (const IR::Node &n, const char *name, int cidx)
 
void visit (const IR::Node &n, const char *name=0)
 
void visit (const IR::Node *&n, const char *name, int cidx)
 
void visit (const IR::Node *&n, const char *name=0)
 
void visit (const IR::Node *const &n, const char *name, int cidx)
 
void visit (const IR::Node *const &n, const char *name=0)
 
void visit (IR::Node &n, const char *name, int cidx)
 
void visit (IR::Node &n, const char *name=0)
 
void visit (IR::Node *&, const char *=0, int=0)
 
template<class T , typename = std::enable_if_t<Util::has_SourceInfo_v<T> && !std::is_pointer_v<T>>, class... Args>
void warn (const int kind, const char *format, const T &node, Args &&...args)
 The const ref variant of the above.
 
template<class T , typename = std::enable_if_t<Util::has_SourceInfo_v<T>>, class... Args>
void warn (const int kind, const char *format, const T *node, Args &&...args)
 
bool warning_enabled (int warning_kind) const
 
- Public Member Functions inherited from P4::Backtrack

Additional Inherited Members

- Public Types inherited from P4::Visitor
typedef Visitor_Context Context
 
- Static Public Member Functions inherited from P4::Visitor
static cstring demangle (const char *)
 
static bool warning_enabled (const Visitor *visitor, int warning_kind)
 
- Public Attributes inherited from P4::Visitor
const Visitorcalled_by = nullptr
 
cstring internalName
 
SplitFlowVisit_base *& split_link
 
SplitFlowVisit_basesplit_link_mem = nullptr
 
- Protected Member Functions inherited from P4::PassManager
profile_t init_apply (const IR::Node *root) override
 
void runDebugHooks (const char *visitorName, const IR::Node *node)
 
- Protected Member Functions inherited from P4::Visitor
virtual void init_join_flows (const IR::Node *)
 
virtual bool join_flows (const IR::Node *)
 
virtual void post_join_flows (const IR::Node *, const IR::Node *)
 
void visit_children (const IR::Node *, std::function< void()> fn)
 
virtual void visitAgain () const
 
virtual void visitOnce () const
 
- Protected Attributes inherited from P4::PassManager
safe_vector< DebugHookdebugHooks
 
safe_vector< Visitor * > passes
 
bool running = false
 
unsigned seqNo = 0
 
bool stop_on_error = true
 
- Protected Attributes inherited from P4::Visitor
bool dontForwardChildrenBeforePreorder = false
 
bool joinFlows = false
 
bool visitDagOnce = true
 

◆ StackPushShims

class StackPushShims

Adds parser states to initialize the $stkvalid fields that are used to handle the push_front and pop_front primitives for header stacks.

Copyright (C) 2024 Intel Corporation

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

SPDX-License-Identifier: Apache-2.0

See also
HeaderPushPop for more discussion.
Inheritance diagram for StackPushShims:
[legend]

◆ WriteParserError

class WriteParserError

Represent a parser error write. TODO: move to actual IR.

Inheritance diagram for WriteParserError:
[legend]

Public Member Functions

 WriteParserError (const PHV::Field *f)
 
void dbprint (std::ostream &out) const override
 
 DECLARE_TYPEINFO (WriteParserError)
 

Public Attributes

const PHV::Fieldfield
 

Typedef Documentation

◆ CollectLoweredParserInfo

Initial value:
CollectParserInfoImpl<IR::BFN::LoweredParser, IR::BFN::LoweredParserState,
IR::BFN::LoweredParserMatch>
Definition parser_info.h:739

◆ CollectParserInfo