P4C
The P4 Compiler
Loading...
Searching...
No Matches
Midend

Overview of midend passes. More...

Collaboration diagram for Midend:

Topics

 BFN::AlpmImplementation
 Set of passes that implement ALPM.
 
 BFN::AnnotateWithInHash
 Set of passes that annotate specific assignment statements with the @in_hash annotation.
 
 BFN::ArchTranslation
 Set of passes that normalize variations in the architectures.
 
 BFN::CheckDesignPattern
 Set of passes that check for design patterns.
 
 BFN::ElimCasts
 Set of passes that simplify the complex expressions with multiple casts into simpler expressions.
 
 BFN::RemoveActionParameters
 Set of passes that specialize the p4c/frontends/RemoveActionParameters class.
 
 BFN::RemoveSelectBooleans
 Set of passes that convert boolean values in select statements to bit<1> values. The node is also transformed to IR:BFN:ReinterpretCasts.
 
 BFN::RewriteFlexibleStruct
 Set of passes that moves flexible annotation from structure to its fields.
 
 BFN::SimplifyEmitArgs
 Set of passes that simplify headers and emits.
 
 DesugarVarbitExtract
 Set of passes that rewrite usage of varbit.
 
 P4::SimplifyIfStatement
 Set of passes that simplify if statements.
 
 P4::SimplifyNestedIf
 Set of passes that simplify nested if statements in the deparser control block.
 

Classes

class  BFN::CheckRegisterActions
 PassManager that checks if the RegisterActions work on proper Registers. More...
 
class  BFN::CheckUnsupported
 Check for unsupported features in the backend compiler. More...
 
class  BFN::CollectPipelines
 Inspector pass that collects information about all pipelines declared in the Switch. For given pipeline (given by its numeric id), it is possible to extract the pipeline components (e.g. parsers, deparsers and gress control for all gresses and possible ghost gress). More...
 
class  BFN::CompileTimeOperations
 Pass that checks for operations that are defined at compile time (Div, Mod). More...
 
class  BFN::EnumOn32Bits
 Class that implements a policy suitable for the ConvertEnums pass. More...
 
class  BFN::EvaluatorPass
 A modified version of P4::EvaluatorPass that uses BFN::TypeChecking. More...
 
class  BFN::FoldConstantHashes
 PassManager that substitutes the calls of the get methods of the Hash externs whose inputs are constants with the resulting hash value. More...
 
class  BFN::InitializeMirrorIOSelect
 Initializes eg_intr_md_for_dprsr.mirror_io_select on devices except Tofino1. More...
 
class  BFN::MidEndLast
 Final midend pass. More...
 
class  BFN::OptionalToTernaryMatchTypeConverter
 Pass that converts optional match type to ternary. More...
 
class  BFN::ParserEnforceDepthReq
 Enforce parser min/max depth requirements. More...
 
class  BFN::PingPongGeneration
 PassManager that adds the ping pong mechanism for ghost thread. More...
 
class  BFN::SetDefaultSize
 Pass that sets default table size to 512 entries. More...
 
class  BFN::TypeChecking
 A TypeChecking pass in BFN namespace that uses the extended TypeInference pass. This should be used in our midend. More...
 
class  BFN::TypeInference
 Extended type inference pass from p4c used in barefoot's midend. More...
 
class  CollectSourceInfoLogging
 Pass that collects source information. More...
 
class  ComputeDefUse
 Compute defuse info within P4Parser and P4Control blocks in the midend. More...
 
class  CopyBlockPragmas
 Pass that copies block annotations to the block's tables. More...
 

Functions

template<class T >
const T * BFN::findContext (const Visitor::Context *c)
 
bool BFN::skipRegisterActionOutput (const Visitor::Context *ctxt, const IR::Expression *)
 

Detailed Description

Overview of midend passes.

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

The mid-end performs a mix of passes from p4c and bf-p4c. These passes modify the IR, usually making transformations that keep the functionality of the code, but changes it to be more optimal (removing unnecessary code, moving stuff around, ...). The goal of midend is mostly to transform the IR into a shape that is easily translatable for the backend.

The form of mid-end IR is the same as the form of front-end IR. The passes from p4c are enclosed in the P4 namespace while the passes from bf-p4c are enclosed in the BFN namespace.

There are two main structures used across most of the passes:

Tied to those structures there are also some general passes that fill them out (that are invoked repeatedly, usually after/before each IR modification) or clear them:

There are also some best practices that are tied to using BFN::TypeChecking and P4::ReferenceMap/P4TypeMap:

There are also some other helpful passes that are used repeatedly:

Details on some of the passes can be found in the modules and classes sections of this page. The following P4 (parts) passes are used as they are and have no further description yet:


Class Documentation

◆ BFN::CheckRegisterActions

class BFN::CheckRegisterActions

PassManager that checks if the RegisterActions work on proper Registers.

Registers and their RegisterActions use don't care types that are unified. This pass just checks if the RegisterAction works with register that has the same width. If not we can still allow it, but only if the index width is appropriately increased/decreased.

Inheritance diagram for BFN::CheckRegisterActions:
[legend]

Public Member Functions

 CheckRegisterActions (P4::TypeMap *typeMap)
 
- 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
 

◆ BFN::CheckUnsupported

class BFN::CheckUnsupported

Check for unsupported features in the backend compiler.

Inheritance diagram for BFN::CheckUnsupported:
[legend]

Public Member Functions

 CheckUnsupported (P4::ReferenceMap *, P4::TypeMap *)
 
- 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
 

◆ BFN::CollectPipelines

class BFN::CollectPipelines

Inspector pass that collects information about all pipelines declared in the Switch. For given pipeline (given by its numeric id), it is possible to extract the pipeline components (e.g. parsers, deparsers and gress control for all gresses and possible ghost gress).

Inheritance diagram for BFN::CollectPipelines:
[legend]

Public Types

using PipeSet = std::set<Pipe>
 
- Public Types inherited from P4::Visitor
typedef Visitor_Context Context
 

Public Member Functions

 CollectPipelines (P4::ReferenceMap *refMap, Pipelines *pipelines)
 
- 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

- 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
 

Constructor & Destructor Documentation

◆ CollectPipelines()

BFN::CollectPipelines::CollectPipelines ( P4::ReferenceMap * refMap,
Pipelines * pipelines )
inlineexplicit

Pipelines data filed by the pass. Arguments must be non-null, no other asumptions taken.

◆ BFN::CompileTimeOperations

class BFN::CompileTimeOperations

Pass that checks for operations that are defined at compile time (Div, Mod).

FIXME – perhaps just remove this pass altogether and check for unsupported div/mod in instruction selection.

Inheritance diagram for BFN::CompileTimeOperations:
[legend]

Additional Inherited Members

- Public Types inherited from P4::Visitor
typedef Visitor_Context Context
 
- Public Member Functions inherited from P4::CompileTimeOperations
void err (const IR::Node *expression)
 
void postorder (const IR::Div *expression) override
 
void postorder (const IR::Mod *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 ()
 
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
 
- 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
 

◆ BFN::EnumOn32Bits

class BFN::EnumOn32Bits

Class that implements a policy suitable for the ConvertEnums pass.

This class implements a policy suitable for the ConvertEnums pass. The policy is: convert all enums that are not part of the architecture files, and are not used as the output type from a RegisterAction. These latter enums will get a special encoding later to be compatible with the stateful alu predicate output. Use 32-bit values for all enums.

Inheritance diagram for BFN::EnumOn32Bits:
[legend]

Additional Inherited Members

- Public Member Functions inherited from P4::ChooseEnumRepresentation
virtual unsigned encoding (const IR::Type_Enum *, unsigned n) const
 

◆ BFN::EvaluatorPass

class BFN::EvaluatorPass

A modified version of P4::EvaluatorPass that uses BFN::TypeChecking.

See also
P4::EvaluatorPass
P4::Evaluator
Inheritance diagram for BFN::EvaluatorPass:
[legend]

Public Member Functions

 EvaluatorPass (P4::ReferenceMap *refMap, P4::TypeMap *typeMap)
 
IR::ToplevelBlock * getToplevelBlock () const override
 
- 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 Member Functions inherited from P4::IHasBlock

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
 

Member Function Documentation

◆ getToplevelBlock()

IR::ToplevelBlock * BFN::EvaluatorPass::getToplevelBlock ( ) const
inlineoverridevirtual

Implements P4::IHasBlock.

◆ BFN::FoldConstantHashes

class BFN::FoldConstantHashes

PassManager that substitutes the calls of the get methods of the Hash externs whose inputs are constants with the resulting hash value.

The input can be a constant value or a list of constant values. The width of the resulting value is determined by the Hash extern.

E.g.:

Hash<bit<16>>(HashAlgorithm_t.IDENTITY) hash;
value = hash.get<tuple<bit<8>, bit<8>, bit<8>, bit<8>>>({ 1, 2, 3, 4 });

is replaced with:

value = 772;  // which is 0x0304

The original object of the Hash extern is removed.

In the case of the identity hash, if a list of constant values is used, the first element is placed on the highest bits of the result. The elements that overflow are ignored.

The Hash extern objects on which the substitution has taken place are checked and if not used elsewhere, their declaration is remove. The same applies to the CRCPolynomial extern objects used in the Hash extern objects of the custom type.

Inheritance diagram for BFN::FoldConstantHashes:
[legend]

Public Member Functions

 FoldConstantHashes (P4::ReferenceMap *refMap, P4::TypeMap *typeMap, BFN::TypeChecking *typeChecking=nullptr)
 
- 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::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::MidEndLast

class BFN::MidEndLast

Final midend pass.

Inheritance diagram for BFN::MidEndLast:
[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
 

◆ BFN::OptionalToTernaryMatchTypeConverter

class BFN::OptionalToTernaryMatchTypeConverter

Pass that converts optional match type to ternary.

This class implements a pass to convert optional match type to ternary. Optional is a special case of ternary which allows for 2 cases

  1. Is Valid = true , mask = all 1's (Exact Match)
  2. Is Valid = false, mask = dont care (Any value)

The control plane API does the necessary checks for valid use cases and programs the ternary accordingly.

Currently the support exists in PSA & V1Model. But as the pass is common to all archs, in future if TNA needs this simply add 'optional' to tofino.p4

BF-RT API Additions: https://wiki.ith.intel.com/display/BXDHOME/BFRT+Optional+match+support

Inheritance diagram for BFN::OptionalToTernaryMatchTypeConverter:
[legend]

Public Member Functions

const IR::Nodepostorder (IR::PathExpression *path)
 
- 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
 

◆ 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
 

◆ BFN::PingPongGeneration

class BFN::PingPongGeneration

PassManager that adds the ping pong mechanism for ghost thread.

Detects registers that are used by ingress and ghost, creates a duplicate tables and registers if needed and attaches a ping-pong mechanism onto them.

There are some helpful visitors (that find/modify something specific within a given sub-tree of the IR) and functions.

Passes work with member variables of the main PassManager (PingPongGeneration) - these variables serve as a storage for saving registers/actions/tables identified for duplication.

Inheritance diagram for BFN::PingPongGeneration:
[legend]

Public Member Functions

 PingPongGeneration (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
 

Constructor & Destructor Documentation

◆ PingPongGeneration()

BFN::PingPongGeneration::PingPongGeneration ( P4::ReferenceMap * refMap,
P4::TypeMap * typeMap )
inline

Constructor that adds all of the passes.

◆ BFN::RewriteEgressIntrinsicMetadataHeader

class BFN::RewriteEgressIntrinsicMetadataHeader

Pass that updates egress intrinsic metadata.

Inheritance diagram for BFN::RewriteEgressIntrinsicMetadataHeader:
[legend]

Public Member Functions

 RewriteEgressIntrinsicMetadataHeader (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::SetDefaultSize

class BFN::SetDefaultSize

Pass that sets default table size to 512 entries.

If no 'size' parameter is set on the table, p4info picks a default value of 1024. p4c/frontends/p4-14/fromv1.0/v1model.h: const unsigned defaultTableSize = 1024; This pass is run again in the MidEnd to modify IR and set this value. BF-RT does not modify program IR used by Midend.

Inheritance diagram for BFN::SetDefaultSize:
[legend]

Public Member Functions

 SetDefaultSize (bool warn)
 
- Public Member Functions inherited from P4::Modifier
const IR::Nodeapply_visitor (const IR::Node *n, const char *name=0) override
 
profile_t init_apply (const IR::Node *root) override
 
virtual void loop_revisit (const IR::Node *)
 
virtual void postorder (IR::Node *)
 
virtual bool preorder (IR::Node *)
 
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::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::Modifier
bool forceClone = false
 
- Protected Attributes inherited from P4::Visitor
bool dontForwardChildrenBeforePreorder = false
 
bool joinFlows = false
 
bool visitDagOnce = true
 

◆ BFN::TypeChecking

class BFN::TypeChecking

A TypeChecking pass in BFN namespace that uses the extended TypeInference pass. This should be used in our midend.

See also
P4::TypeChecking
Inheritance diagram for BFN::TypeChecking:
[legend]

Public Member Functions

 TypeChecking (P4::ReferenceMap *refMap, P4::TypeMap *typeMap, bool updateExpressions=false)
 
- Public Member Functions inherited from P4::TypeChecking
 TypeChecking (ReferenceMap *refMap, TypeMap *typeMap, bool updateExpressions=false)
 
- 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::TypeInference

class BFN::TypeInference

Extended type inference pass from p4c used in barefoot's midend.

See also
P4::TypeInference
Inheritance diagram for BFN::TypeInference:
[legend]

Public Member Functions

 TypeInference (P4::TypeMap *typeMap, bool readOnly=false)
 
TypeInferenceclone () const override
 
const IR::Nodepostorder (IR::BFN::ReinterpretCast *) override
 
const IR::Nodepostorder (IR::BFN::SignExtend *) override
 
const IR::Nodepostorder (IR::Member *) override
 
- Public Member Functions inherited from P4::TypeInference
 TypeInference (TypeMap *typeMap, bool readOnly=true, bool checkArrays=true, bool errorOnNullDecls=false)
 
const IR::Nodeapply_visitor (const IR::Node *, const char *name=nullptr) override
 
void end_apply (const IR::Node *Node) override
 
Visitor::profile_t init_apply (const IR::Node *node) override
 
const IR::Nodepostorder (IR::ActionList *al) override
 
const IR::Nodepostorder (IR::ActionListElement *elem) override
 
const IR::Nodepostorder (IR::Add *expression) override
 
const IR::Nodepostorder (IR::AddSat *expression) override
 
const IR::Nodepostorder (IR::Annotation *annotation) override
 
const IR::Nodepostorder (IR::Argument *arg) override
 
const IR::Nodepostorder (IR::ArrayIndex *expression) override
 
const IR::Nodepostorder (IR::AssignmentStatement *stat) override
 
const IR::Nodepostorder (IR::AttribLocal *local) override
 
const IR::Nodepostorder (IR::BAnd *expression) override
 
const IR::Nodepostorder (IR::BoolLiteral *expression) override
 
const IR::Nodepostorder (IR::BOr *expression) override
 
const IR::Nodepostorder (IR::BXor *expression) override
 
const IR::Nodepostorder (IR::Cast *expression) override
 
const IR::Nodepostorder (IR::Cmpl *expression) override
 
const IR::Nodepostorder (IR::Concat *expression) override
 
const IR::Nodepostorder (IR::Constant *expression) override
 
const IR::Nodepostorder (IR::ConstructorCallExpression *expression) override
 
const IR::Nodepostorder (IR::Declaration_Constant *constant) override
 
const IR::Nodepostorder (IR::Declaration_MatchKind *decl) override
 
const IR::Nodepostorder (IR::Declaration_Variable *decl) override
 
const IR::Nodepostorder (IR::DefaultExpression *expression) override
 
const IR::Nodepostorder (IR::Div *expression) override
 
const IR::Nodepostorder (IR::Dots *expression) override
 
const IR::Nodepostorder (IR::Entry *e) override
 
const IR::Nodepostorder (IR::ForInStatement *stat) override
 
const IR::Nodepostorder (IR::HeaderStackExpression *expression) override
 
const IR::Nodepostorder (IR::IfStatement *stat) override
 
const IR::Nodepostorder (IR::Invalid *expression) override
 
const IR::Nodepostorder (IR::InvalidHeader *expression) override
 
const IR::Nodepostorder (IR::InvalidHeaderUnion *expression) override
 
const IR::Nodepostorder (IR::Key *key) override
 
const IR::Nodepostorder (IR::KeyElement *elem) override
 
const IR::Nodepostorder (IR::LAnd *expression) override
 
const IR::Nodepostorder (IR::ListExpression *expression) override
 
const IR::Nodepostorder (IR::LNot *expression) override
 
const IR::Nodepostorder (IR::LOr *expression) override
 
const IR::Nodepostorder (IR::Mask *expression) override
 
const IR::Nodepostorder (IR::Member *expression) override
 
const IR::Nodepostorder (IR::Method *method) override
 
const IR::Nodepostorder (IR::MethodCallExpression *expression) override
 
const IR::Nodepostorder (IR::MethodCallStatement *mcs) override
 
const IR::Nodepostorder (IR::Mod *expression) override
 
const IR::Nodepostorder (IR::Mul *expression) override
 
const IR::Nodepostorder (IR::Mux *expression) override
 
const IR::Nodepostorder (IR::Neg *expression) override
 
virtual const IR::Nodepostorder (IR::Node *n)
 
const IR::Nodepostorder (IR::Operation_Relation *expression) override
 
const IR::Nodepostorder (IR::P4Action *type) override
 
const IR::Nodepostorder (IR::P4Control *cont) override
 
const IR::Nodepostorder (IR::P4ListExpression *expression) override
 
const IR::Nodepostorder (IR::P4Parser *cont) override
 
const IR::Nodepostorder (IR::P4Table *type) override
 
const IR::Nodepostorder (IR::P4ValueSet *type) override
 
const IR::Nodepostorder (IR::Parameter *param) override
 
const IR::Nodepostorder (IR::PathExpression *expression) override
 
const IR::Nodepostorder (IR::PlusSlice *expression) override
 
const IR::Nodepostorder (IR::Property *elem) override
 
const IR::Nodepostorder (IR::Range *expression) override
 
const IR::Nodepostorder (IR::ReturnStatement *stat) override
 
const IR::Nodepostorder (IR::SelectCase *elem) override
 
const IR::Nodepostorder (IR::SelectExpression *expression) override
 
const IR::Nodepostorder (IR::SerEnumMember *member) override
 
const IR::Nodepostorder (IR::Shl *expression) override
 
const IR::Nodepostorder (IR::Shr *expression) override
 
const IR::Nodepostorder (IR::Slice *expression) override
 
const IR::Nodepostorder (IR::StringLiteral *expression) override
 
const IR::Nodepostorder (IR::StructExpression *expression) override
 
const IR::Nodepostorder (IR::StructField *field) override
 
const IR::Nodepostorder (IR::Sub *expression) override
 
const IR::Nodepostorder (IR::SubSat *expression) override
 
const IR::Nodepostorder (IR::SwitchStatement *stat) override
 
const IR::Nodepostorder (IR::This *expression) override
 
const IR::Nodepostorder (IR::Type_Action *type) override
 
const IR::Nodepostorder (IR::Type_ActionEnum *type) override
 
const IR::Nodepostorder (IR::Type_ArchBlock *type) override
 
const IR::Nodepostorder (IR::Type_Base *type) override
 
const IR::Nodepostorder (IR::Type_Enum *type) override
 
const IR::Nodepostorder (IR::Type_Error *decl) override
 
const IR::Nodepostorder (IR::Type_Extern *type) override
 
const IR::Nodepostorder (IR::Type_Header *type) override
 
const IR::Nodepostorder (IR::Type_HeaderUnion *type) override
 
const IR::Nodepostorder (IR::Type_InfInt *type) override
 
const IR::Nodepostorder (IR::Type_List *type) override
 
const IR::Nodepostorder (IR::Type_Method *type) override
 
const IR::Nodepostorder (IR::Type_Name *type) override
 
const IR::Nodepostorder (IR::Type_Newtype *type) override
 
const IR::Nodepostorder (IR::Type_P4List *type) override
 
const IR::Nodepostorder (IR::Type_Package *type) override
 
const IR::Nodepostorder (IR::Type_Set *type) override
 
const IR::Nodepostorder (IR::Type_Specialized *type) override
 
const IR::Nodepostorder (IR::Type_SpecializedCanonical *type) override
 
const IR::Nodepostorder (IR::Type_Stack *type) override
 
const IR::Nodepostorder (IR::Type_Struct *type) override
 
const IR::Nodepostorder (IR::Type_Table *type) override
 
const IR::Nodepostorder (IR::Type_Tuple *type) override
 
const IR::Nodepostorder (IR::Type_Type *type) override
 
const IR::Nodepostorder (IR::Type_Typedef *type) override
 
const IR::Nodepostorder (IR::Type_Var *type) override
 
const IR::Nodepostorder (IR::TypeNameExpression *expression) override
 
const IR::Nodepostorder (IR::UPlus *expression) override
 
const IR::Nodepreorder (IR::Declaration_Instance *decl) override
 
const IR::Nodepreorder (IR::EntriesList *el) override
 
const IR::Nodepreorder (IR::Expression *expression) override
 
const IR::Nodepreorder (IR::Function *function) override
 
virtual const IR::Nodepreorder (IR::Node *n)
 
const IR::Nodepreorder (IR::P4Program *program) override
 
const IR::Nodepreorder (IR::Type *type) override
 
const IR::Nodepreorder (IR::Type_SerEnum *type) override
 
const IR::NodepruneIfDone (const IR::Node *node)
 
- Public Member Functions inherited from P4::Transform
virtual void loop_revisit (const IR::Node *)
 
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 ControlFlowVisitorcontrolFlowVisitor ()
 
virtual void end_apply ()
 
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::TypeInferenceBase
 TypeInferenceBase (TypeMap *typeMap, bool readOnly=false, bool checkArrays=true, bool errorOnNullDecls=false)
 
bool compare (const IR::Node *errorPosition, const IR::Type *ltype, const IR::Type *rtype, Comparison *compare)
 
void finish (const IR::Node *Node)
 
bool learn (const IR::Node *node, Visitor *caller, const Visitor::Context *ctxt)
 
const IR::Nodepostorder (const IR::ActionList *al)
 
const IR::Nodepostorder (const IR::ActionListElement *elem)
 
const IR::Nodepostorder (const IR::Add *expression)
 
const IR::Nodepostorder (const IR::AddSat *expression)
 
const IR::Nodepostorder (const IR::Annotation *annotation)
 
const IR::Nodepostorder (const IR::Argument *arg)
 
const IR::Nodepostorder (const IR::ArrayIndex *expression)
 
const IR::Nodepostorder (const IR::AssignmentStatement *stat)
 
const IR::Nodepostorder (const IR::AttribLocal *local)
 
const IR::Nodepostorder (const IR::BAnd *expression)
 
const IR::Nodepostorder (const IR::BoolLiteral *expression)
 
const IR::Nodepostorder (const IR::BOr *expression)
 
const IR::Nodepostorder (const IR::BXor *expression)
 
const IR::Nodepostorder (const IR::Cast *expression)
 
const IR::Nodepostorder (const IR::Cmpl *expression)
 
const IR::Nodepostorder (const IR::Concat *expression)
 
const IR::Nodepostorder (const IR::Constant *expression)
 
const IR::Nodepostorder (const IR::ConstructorCallExpression *expression)
 
const IR::Nodepostorder (const IR::Declaration_Constant *constant)
 
const IR::Nodepostorder (const IR::Declaration_MatchKind *decl)
 
const IR::Nodepostorder (const IR::Declaration_Variable *decl)
 
const IR::Nodepostorder (const IR::DefaultExpression *expression)
 
const IR::Nodepostorder (const IR::Div *expression)
 
const IR::Nodepostorder (const IR::Dots *expression)
 
const IR::Nodepostorder (const IR::Entry *e)
 
const IR::Nodepostorder (const IR::ForInStatement *stat)
 
const IR::Nodepostorder (const IR::HeaderStackExpression *expression)
 
const IR::Nodepostorder (const IR::IfStatement *stat)
 
const IR::Nodepostorder (const IR::Invalid *expression)
 
const IR::Nodepostorder (const IR::InvalidHeader *expression)
 
const IR::Nodepostorder (const IR::InvalidHeaderUnion *expression)
 
const IR::Nodepostorder (const IR::Key *key)
 
const IR::Nodepostorder (const IR::KeyElement *elem)
 
const IR::Nodepostorder (const IR::LAnd *expression)
 
const IR::Nodepostorder (const IR::ListExpression *expression)
 
const IR::Nodepostorder (const IR::LNot *expression)
 
const IR::Nodepostorder (const IR::LOr *expression)
 
const IR::Nodepostorder (const IR::Mask *expression)
 
const IR::Nodepostorder (const IR::Member *expression)
 
const IR::Nodepostorder (const IR::Method *method)
 
const IR::Nodepostorder (const IR::MethodCallExpression *expression)
 
const IR::Nodepostorder (const IR::MethodCallStatement *mcs)
 
const IR::Nodepostorder (const IR::Mod *expression)
 
const IR::Nodepostorder (const IR::Mul *expression)
 
const IR::Nodepostorder (const IR::Mux *expression)
 
const IR::Nodepostorder (const IR::Neg *expression)
 
const IR::Nodepostorder (const IR::Operation_Relation *expression)
 
const IR::Nodepostorder (const IR::P4Action *type)
 
const IR::Nodepostorder (const IR::P4Control *cont)
 
const IR::Nodepostorder (const IR::P4ListExpression *expression)
 
const IR::Nodepostorder (const IR::P4Parser *cont)
 
const IR::Nodepostorder (const IR::P4Table *type)
 
const IR::Nodepostorder (const IR::P4ValueSet *type)
 
const IR::Nodepostorder (const IR::Parameter *param)
 
const IR::Nodepostorder (const IR::PathExpression *expression)
 
const IR::Nodepostorder (const IR::PlusSlice *expression)
 
const IR::Nodepostorder (const IR::Property *elem)
 
const IR::Nodepostorder (const IR::Range *expression)
 
const IR::Nodepostorder (const IR::ReturnStatement *stat)
 
const IR::Nodepostorder (const IR::SelectCase *elem)
 
const IR::Nodepostorder (const IR::SelectExpression *expression)
 
const IR::Nodepostorder (const IR::SerEnumMember *member)
 
const IR::Nodepostorder (const IR::Shl *expression)
 
const IR::Nodepostorder (const IR::Shr *expression)
 
const IR::Nodepostorder (const IR::Slice *expression)
 
const IR::Nodepostorder (const IR::StringLiteral *expression)
 
const IR::Nodepostorder (const IR::StructExpression *expression)
 
const IR::Nodepostorder (const IR::StructField *field)
 
const IR::Nodepostorder (const IR::Sub *expression)
 
const IR::Nodepostorder (const IR::SubSat *expression)
 
const IR::Nodepostorder (const IR::SwitchStatement *stat)
 
const IR::Nodepostorder (const IR::This *expression)
 
const IR::Nodepostorder (const IR::Type_Action *type)
 
const IR::Nodepostorder (const IR::Type_ActionEnum *type)
 
const IR::Nodepostorder (const IR::Type_ArchBlock *type)
 
const IR::Nodepostorder (const IR::Type_Base *type)
 
const IR::Nodepostorder (const IR::Type_Enum *type)
 
const IR::Nodepostorder (const IR::Type_Error *decl)
 
const IR::Nodepostorder (const IR::Type_Extern *type)
 
const IR::Nodepostorder (const IR::Type_Header *type)
 
const IR::Nodepostorder (const IR::Type_HeaderUnion *type)
 
const IR::Nodepostorder (const IR::Type_InfInt *type)
 
const IR::Nodepostorder (const IR::Type_List *type)
 
const IR::Nodepostorder (const IR::Type_Method *type)
 
const IR::Nodepostorder (const IR::Type_Name *type)
 
const IR::Nodepostorder (const IR::Type_Newtype *type)
 
const IR::Nodepostorder (const IR::Type_P4List *type)
 
const IR::Nodepostorder (const IR::Type_Package *type)
 
const IR::Nodepostorder (const IR::Type_Set *type)
 
const IR::Nodepostorder (const IR::Type_Specialized *type)
 
const IR::Nodepostorder (const IR::Type_SpecializedCanonical *type)
 
const IR::Nodepostorder (const IR::Type_Stack *type)
 
const IR::Nodepostorder (const IR::Type_Struct *type)
 
const IR::Nodepostorder (const IR::Type_Table *type)
 
const IR::Nodepostorder (const IR::Type_Tuple *type)
 
const IR::Nodepostorder (const IR::Type_Type *type)
 
const IR::Nodepostorder (const IR::Type_Typedef *type)
 
const IR::Nodepostorder (const IR::Type_Var *type)
 
const IR::Nodepostorder (const IR::TypeNameExpression *expression)
 
const IR::Nodepostorder (const IR::UPlus *expression)
 
PreorderResult preorder (const IR::Declaration_Instance *decl)
 
PreorderResult preorder (const IR::EntriesList *el)
 
PreorderResult preorder (const IR::Function *function)
 
PreorderResult preorder (const IR::P4Program *program)
 
PreorderResult preorder (const IR::Type_SerEnum *type)
 
PreorderResult preorder (IR::Declaration_Instance *decl)
 
PreorderResult preorder (IR::Function *function)
 
ReadOnlyTypeInferencereadOnlyClone () const
 
void start (const IR::Node *node)
 
- 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::DeclarationLookup

Protected Member Functions

const IR::Type * setTypeType (const IR::Type *type, bool learn=true) override
 
- 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 Member Functions inherited from P4::TypeInferenceBase
 TypeInferenceBase (TypeMap *typeMap, std::shared_ptr< MinimalNameGenerator > nameGen)
 
const IR::Expression * actionCall (bool inActionList, const IR::MethodCallExpression *actionCall)
 
void addSubstitutions (const TypeVariableSubstitution *tvs)
 
const IR::Expression * assignment (const IR::Node *errorPosition, const IR::Type *destType, const IR::Expression *sourceExpression)
 
const IR::NodebinaryArith (const IR::Operation_Binary *op)
 
const IR::NodebinaryBool (const IR::Operation_Binary *op)
 
bool canCastBetween (const IR::Type *dest, const IR::Type *src) const
 
virtual const IR::Type * canonicalize (const IR::Type *type)
 
template<class Ctor >
const IR::Type * canonicalizeFields (const IR::Type_StructLike *type, Ctor constructor)
 
virtual const IR::ParameterList * canonicalizeParameters (const IR::ParameterList *params)
 
bool checkAbstractMethods (const IR::Declaration_Instance *inst, const IR::Type_Extern *type)
 
std::pair< const IR::Type *, const IR::Vector< IR::Argument > * > checkExternConstructor (const IR::Node *errorPosition, const IR::Type_Extern *ext, const IR::Vector< IR::Argument > *arguments)
 
bool checkParameters (const IR::ParameterList *paramList, bool forbidModules=false, bool forbidPackage=false) const
 
const IR::Type_Bits * checkUnderlyingEnumType (const IR::Type *enumType)
 
const IR::Type * cloneWithFreshTypeVariables (const IR::IMayBeGenericType *type)
 
const IR::Expression * constantFold (const IR::Expression *expression)
 
std::pair< const IR::Type *, const IR::Vector< IR::Argument > * > containerInstantiation (const IR::Node *node, const IR::Vector< IR::Argument > *args, const IR::IContainer *container)
 
bool containsActionEnum (const IR::Type *type) const
 
bool containsHeader (const IR::Type *canonType)
 
bool done () const
 
const IR::NodegetInitialNode () const
 
const IR::Type * getType (const IR::Node *element) const
 
const IR::Type * getTypeType (const IR::Node *element) const
 
bool isCompileTimeConstant (const IR::Expression *expression) const
 
bool isLeftValue (const IR::Expression *expression) const
 
const IR::SelectCase * matchCase (const IR::SelectExpression *select, const IR::Type_BaseList *selectType, const IR::SelectCase *selectCase, const IR::Type *caseType)
 
bool onlyBitsOrBitStructs (const IR::Type *type) const
 
template<class Node >
PreorderResult preorderDeclarationInstanceImpl (Node *decl)
 
template<class Node >
PreorderResult preorderFunctionImpl (Node *function)
 
void setCompileTimeConstant (const IR::Expression *expression)
 
void setLeftValue (const IR::Expression *expression)
 
void setType (const IR::Node *element, const IR::Type *type)
 
const IR::Nodeshift (const IR::Operation_Binary *op)
 
const IR::NodetypeSet (const IR::Operation_Binary *op)
 
TypeVariableSubstitutionunify (const IR::Node *errorPosition, const IR::Type *destType, const IR::Type *srcType, std::string_view errorFormat={}, std::initializer_list< const IR::Node * > errorArgs={})
 Same as above, not allowing casts.
 
TypeVariableSubstitutionunifyBase (bool allowCasts, const IR::Node *errorPosition, const IR::Type *destType, const IR::Type *srcType, std::string_view errorFormat, std::initializer_list< const IR::Node * > errorArgs)
 
TypeVariableSubstitutionunifyCast (const IR::Node *errorPosition, const IR::Type *destType, const IR::Type *srcType, std::string_view errorFormat={}, std::initializer_list< const IR::Node * > errorArgs={})
 
const IR::NodeunsBinaryArith (const IR::Operation_Binary *op)
 
const IR::ActionListElement * validateActionInitializer (const IR::Expression *actionCall)
 
bool validateFields (const IR::Type *type, std::function< bool(const IR::Type *)> checker) const
 
- 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.
 

Additional Inherited Members

- Public Types inherited from P4::Visitor
typedef Visitor_Context Context
 
- Public Types inherited from P4::TypeInferenceBase
using PreorderResult = std::pair<const IR::Node *, bool>
 
- Static Public Member Functions inherited from P4::Visitor
static cstring demangle (const char *)
 
static bool warning_enabled (const Visitor *visitor, int warning_kind)
 
- Static Public Member Functions inherited from P4::TypeInferenceBase
static const IR::Type * specialize (const IR::IMayBeGenericType *type, const IR::Vector< IR::Type > *arguments, const Visitor::Context *ctxt)
 
- 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::Transform
bool forceClone = false
 
- Protected Attributes inherited from P4::Visitor
bool dontForwardChildrenBeforePreorder = false
 
bool joinFlows = false
 
bool visitDagOnce = true
 
- Protected Attributes inherited from P4::TypeInferenceBase
bool checkArrays = true
 
const IR::ActionList * currentActionList
 Action list of the current table.
 
bool errorOnNullDecls = false
 
bool readOnly = false
 
- Protected Attributes inherited from P4::ResolutionContext
bool anyOrder = false
 
- Static Protected Attributes inherited from P4::TypeInferenceBase
static constexpr bool forbidModules = true
 
static constexpr bool forbidPackages = true
 

Member Function Documentation

◆ clone()

TypeInference * BFN::TypeInference::clone ( ) const
overridevirtual

Reimplemented from P4::Visitor.

◆ setTypeType()

const IR::Type * BFN::TypeInference::setTypeType ( const IR::Type * type,
bool learn = true )
overrideprotectedvirtual

Reimplemented from P4::TypeInferenceBase.

◆ CollectSourceInfoLogging

class CollectSourceInfoLogging

Pass that collects source information.

This inspector serves to collect source information about definitions and uses of all P4 symbols in the program. It shall be applied when all important IR transformations have been done and P4::ReferenceMap is still available.

Inheritance diagram for CollectSourceInfoLogging:
[legend]

Public Member Functions

 CollectSourceInfoLogging (const P4::ReferenceMap &)
 
void addSymbol (const Symbol &)
 

Friends

class SourceInfoLogging
 

Constructor & Destructor Documentation

◆ CollectSourceInfoLogging()

CollectSourceInfoLogging::CollectSourceInfoLogging ( const P4::ReferenceMap & refMap)
explicit

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

◆ 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
 

◆ CopyBlockPragmas

class CopyBlockPragmas

Pass that copies block annotations to the block's tables.

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 CopyBlockPragmas:
[legend]

Public Member Functions

 CopyBlockPragmas (P4::ReferenceMap *refMap, P4::TypeMap *typeMap, P4::TypeChecking *typeChecking, std::set< cstring > pragmas)
 
 CopyBlockPragmas (P4::ReferenceMap *refMap, P4::TypeMap *typeMap, std::set< cstring > pragmas)
 

Function Documentation

◆ findContext()

template<class T >
const T * BFN::findContext ( const Visitor::Context * c)
inline

This function implements a policy suitable for the LocalCopyPropagation pass. The policy is: do not local copy propagate for assignment statement setting the output param of a register action. This function returns true if the localCopyPropagation should be enabled; It returns false if the localCopyPropagation should be disabled for the current statement.