P4C
The P4 Compiler
|
Allocates parser checksums. More...
Classes | |
struct | CollectParserChecksums |
class | ComputeDeadParserChecksums |
struct | DuplicateStates |
class | ElimDeadParserChecksums |
struct | InsertParserClotChecksums |
struct | ParserChecksumAllocator |
Allocates parser checksums.
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
struct CollectParserChecksums |
Copyright (C) 2024 Intel Corporation
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
SPDX-License-Identifier: Apache-2.0
Public Member Functions | |
CollectParserChecksums (const CollectParserInfo &parser_info) | |
void | end_apply () override |
IR::BFN::ChecksumMode | get_type (const IR::BFN::Parser *parser, cstring name) const |
profile_t | init_apply (const IR::Node *root) override |
bool | is_clot (const IR::BFN::Parser *parser, cstring decl) const |
bool | is_residual (const IR::BFN::Parser *parser, cstring decl) const |
bool | is_verification (const IR::BFN::Parser *parser, cstring decl) const |
bool | preorder (const IR::BFN::Parser *parser) override |
void | visit (const IR::BFN::Parser *parser, const IR::BFN::ParserState *state, const IR::BFN::ParserChecksumPrimitive *csum) |
Public Attributes | |
ordered_map< const IR::BFN::Parser *, ordered_map< cstring, std::vector< const IR::BFN::ParserChecksumPrimitive * > > > | decl_name_to_prims |
ordered_map< const IR::BFN::Parser *, ordered_map< cstring, ordered_set< const IR::BFN::ParserState * > > > | decl_name_to_states |
const CollectParserInfo & | parser_info |
ordered_map< const IR::BFN::Parser *, ordered_set< cstring > > | parser_to_clots |
ordered_map< const IR::BFN::Parser *, ordered_set< cstring > > | parser_to_decl_names |
ordered_map< const IR::BFN::Parser *, ordered_set< cstring > > | parser_to_residuals |
ordered_map< const IR::BFN::Parser *, ordered_set< cstring > > | parser_to_verifies |
ordered_map< const IR::BFN::ParserChecksumPrimitive *, const IR::BFN::ParserState * > | prim_to_state |
ordered_map< const IR::BFN::ParserState *, std::vector< const IR::BFN::ParserChecksumPrimitive * > > | state_to_prims |
class ComputeDeadParserChecksums |
Public Member Functions | |
ComputeDeadParserChecksums (const CollectParserInfo &parser_info, const CollectParserChecksums &checksum_info) | |
Public Attributes | |
ordered_set< const IR::BFN::ParserPrimitive * > | to_elim |
struct DuplicateStates |
Public Member Functions | |
DuplicateStates (AllocateParserChecksums &allocator, const CollectParserInfo &parser_info, const CollectParserChecksums &checksum_info) | |
bool | add_state_to_duplicate (const IR::BFN::ParserState *state, const ordered_set< const IR::BFN::ParserState * > &start_states, const IR::BFN::Parser *parser, ordered_set< const IR::BFN::ParserState * > &path) |
void | find_state_to_duplicate (const IR::BFN::Parser *parser, cstring decl) |
IR::BFN::ParserState * | get_new_state (const IR::BFN::ParserState *state, cstring decl) |
bool | has_ancestor (const IR::BFN::Parser *parser, const ordered_set< const IR::BFN::ParserState * > &calc_states, const IR::BFN::ParserState *dst) |
Is any state in "calc_states_" an ancestor of "dst"? | |
profile_t | init_apply (const IR::Node *root) override |
IR::BFN::ParserState * | make_path (const IR::BFN::ParserState *state, cstring decl, ordered_set< const IR::BFN::ParserState * > path) |
IR::Node * | preorder (IR::BFN::Transition *transition) override |
Public Attributes | |
AllocateParserChecksums & | allocator |
const CollectParserChecksums & | checksum_info |
ordered_map< cstring, ordered_map< cstring, ordered_set< const IR::BFN::ParserState * > > > | duplicate_path |
std::map< std::pair< const IR::BFN::ParserState *, cstring >, IR::BFN::ParserState * > | duplicate_states |
const CollectParserInfo & | parser_info |
class ElimDeadParserChecksums |
Public Member Functions | |
ElimDeadParserChecksums (const ordered_set< const IR::BFN::ParserPrimitive * > &to_elim) | |
bool | preorder (IR::BFN::ParserState *state) override |
struct InsertParserClotChecksums |
For CLOTs that contribute to checksum update at the deparser, we need to compute the CLOT's portion of checksum in the parser when we issue the CLOTs. So after CLOT allocation, we know which fields are allocated to CLOTs, and of those fields, which contribute to the checksum update. We then insert the checksum calculation primitives for these fields into the parser state where they are extracted.
Public Member Functions | |
InsertParserClotChecksums (const PhvInfo &phv, const CollectParserInfo &parser_info, const ClotInfo &clot) | |
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::Node * | apply_visitor (const IR::Node *, const char *=0) override |
bool | backtrack (trigger &trig) override |
PassManager * | clone () 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 ControlFlowVisitor * | controlFlowVisitor () |
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 Visitor & | flow_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 Context * | getChildContext () const |
int | getChildrenVisited () const |
const Context * | getContext () const |
int | getContextDepth () const |
const IR::Node * | getCurrentNode () const |
template<class T > | |
const T * | getCurrentNode () const |
const IR::Node * | getOriginal () 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 Visitor & | setCalledBy (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 Visitor * | called_by = nullptr |
cstring | internalName |
SplitFlowVisit_base *& | split_link |
SplitFlowVisit_base * | split_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< DebugHook > | debugHooks |
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 |
struct ParserChecksumAllocator |
Public Member Functions | |
ParserChecksumAllocator (AllocateParserChecksums &s, const CollectParserInfo &pi, const CollectParserChecksums &ci) | |
void | allocate (const IR::BFN::Parser *parser) |
const IR::Node * | apply_visitor (const IR::Node *n, const char *) override |
void | bind (const IR::BFN::Parser *parser, cstring csum, unsigned id) |
bool | can_share_hw_unit (const IR::BFN::Parser *parser, cstring declA, cstring declB) |
std::vector< ordered_set< cstring > > | compute_disjoint_sets (const IR::BFN::Parser *parser) |
void | compute_disjoint_sets (const IR::BFN::Parser *parser, const ordered_set< cstring > &decls, std::vector< ordered_set< cstring > > &disjoint_sets) |
bool | contains_clot_checksum (const IR::BFN::Parser *parser, const ordered_set< cstring > &decls) |
void | fail (gress_t gress) |
ordered_set< const IR::BFN::ParserState * > | get_end_states (const IR::BFN::Parser *parser, cstring decl) |
ordered_set< const IR::BFN::ParserState * > | get_start_states (const IR::BFN::Parser *parser, cstring decl) |
bool | is_clot (const IR::BFN::Parser *parser, cstring decl) |
bool | is_equiv (const IR::BFN::ParserState *state, cstring declA, cstring declB) |
bool | is_equiv_dest (const IR::BFN::ParserChecksumPrimitive *a, const IR::BFN::ParserChecksumPrimitive *b) |
bool | is_equiv_src (const IR::BFN::ParserChecksumPrimitive *a, const IR::BFN::ParserChecksumPrimitive *b) |
bool | is_residual (const IR::BFN::Parser *parser, cstring decl) |
bool | is_verification (const IR::BFN::Parser *parser, cstring decl) |
std::string | print_calc_states (const IR::BFN::Parser *parser, cstring declName) |
Public Member Functions inherited from P4::Visitor | |
virtual const IR::Node * | apply_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 Visitor * | clone () const |
virtual ControlFlowVisitor * | controlFlowVisitor () |
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 Visitor & | flow_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 Context * | getChildContext () const |
int | getChildrenVisited () const |
const Context * | getContext () const |
int | getContextDepth () const |
const IR::Node * | getCurrentNode () const |
template<class T > | |
const T * | getCurrentNode () const |
const IR::Node * | getOriginal () 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 Visitor & | setCalledBy (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 Attributes | |
const CollectParserChecksums & | checksum_info |
const CollectParserInfo & | parser_info |
AllocateParserChecksums & | self |
Public Attributes inherited from P4::Visitor | |
const Visitor * | called_by = nullptr |
cstring | internalName |
SplitFlowVisit_base *& | split_link |
SplitFlowVisit_base * | split_link_mem = nullptr |
Additional Inherited Members | |
Public Types inherited from P4::Visitor | |
typedef Visitor_Context | Context |
Static Public Member Functions inherited from P4::Visitor | |
static cstring | demangle (const char *) |
static bool | warning_enabled (const Visitor *visitor, int warning_kind) |
Protected Member Functions inherited from P4::Visitor | |
virtual void | init_join_flows (const IR::Node *) |
virtual bool | join_flows (const IR::Node *) |
virtual void | post_join_flows (const IR::Node *, const IR::Node *) |
void | visit_children (const IR::Node *, std::function< void()> fn) |
virtual void | visitAgain () const |
virtual void | visitOnce () const |
Protected Attributes inherited from P4::Visitor | |
bool | dontForwardChildrenBeforePreorder = false |
bool | joinFlows = false |
bool | visitDagOnce = true |
|
inline |
Returns the checksum calculation end states for declaration. A calculation may have multiple end states, e.g. IPv4 with variable length options where each option length is its own parser state. A state is an end state is no other state is its descendant.
|
inline |
Returns the checksum calculation start state for declaration. A calculation may have mutiple start states, e.g. branches that extract same header. A state is a start state is no other state is its ancestor.