P4C
The P4 Compiler
|
#include <action_analysis.h>
Classes | |
struct | ActionDataInfo |
struct | ActionParam |
struct | Alignment |
struct | ConstantInfo |
struct | ConstantPosition |
struct | ContainerAction |
struct | FieldAction |
struct | TotalAlignment |
Public Types | |
typedef std::map< PHV::Container, ContainerAction > | ContainerActionsMap |
typedef ordered_map< const IR::MAU::Instruction *, FieldAction > | FieldActionsMap |
enum | op_type_t { NONE = 0 , DST , SRC1 , SRC2 , SRC3 } |
Public Types inherited from P4::Visitor | |
typedef Visitor_Context | Context |
Public Member Functions | |
ActionAnalysis (const PhvInfo &p, bool pa, bool aa, const IR::MAU::Table *t, const ReductionOrInfo &ri, bool au=false, bool seq=true) | |
bool | error_found () const |
bool | get_action_data_misaligned () const |
bool | get_ad_alloc () const |
bool | get_allow_unalloc () const |
const ContainerActionsMap * | get_container_actions_map () const |
bool | get_error_verbose () const |
bool | get_phv_alloc () const |
bool | get_sequential () const |
const IR::MAU::Table * | get_table () const |
bool | get_verbose () const |
const IR::MAU::ActionArg * | isActionArg (const IR::Expression *expr, le_bitrange *bits_out=nullptr) |
const IR::Expression * | isActionParam (const IR::Expression *expr, le_bitrange *bits_out=nullptr, ActionParam::type_t *type=nullptr) |
bool | isReductionOr (ContainerAction &cont_action) const |
const IR::Expression * | isStrengthReducible (const IR::Expression *expr) |
bool | misaligned_actiondata () |
void | set_container_actions_map (ContainerActionsMap *cam) |
void | set_error_verbose () |
void | set_field_actions_map (FieldActionsMap *fam) |
void | set_verbose () |
bool | warning_found () const |
Public Member Functions inherited from P4::Inspector | |
const IR::Node * | apply_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 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 |
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 |
Static Public Attributes | |
static constexpr int | CONST_SRC_MAX = 3 |
static constexpr int | JBAY_CONST_SRC_MIN = 2 |
static constexpr int | LOADCONST_MAX = 21 |
static constexpr int | MAX_PHV_SOURCES = 2 |
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 Visitor * | called_by = nullptr |
cstring | internalName |
SplitFlowVisit_base *& | split_link |
SplitFlowVisit_base * | split_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 |
The purpose of this class is to look through the actions specified by the table and determine if they are Tofino compliant. The analysis can be run before and after phv allocation, as well as before and after action data formats are decided.
Tofino compliant is defined in the following way
The pass also constructs a field_actions/container_actions structure, depending on before or after PHV allocation. The container actions is especially useful, as it breaks the instruction into a container by container basis. The instructions after instruction selection are done on a field by field basis, and thus having a container view of the actions is necessary for having a correct view of the action data requirements, as well as reshaping the instructions from field by field to container by container
This pass can run before and after PHV allocation, and before and after table placement. The pass is also designed to run when action format allocation is done before PHV allocation, but a PHV allocation has been completed
const IR::Expression * ActionAnalysis::isActionParam | ( | const IR::Expression * | e, |
le_bitrange * | bits_out = nullptr, | ||
ActionParam::type_t * | type = nullptr ) |
Similar to phv.field, it returns the IR structure that corresponds to actiondata, If it is an MAU::ActionArg, HashDist, or AttachedOutput then the type is ACTIONDATA If it is an ActionDataConstant, then the type is CONSTANT
const IR::Expression * ActionAnalysis::isStrengthReducible | ( | const IR::Expression * | e | ) |
sizeInBytes() and sizeInBits() are converted to constant after flexible packing. The converted constant is constant-folded and strength-reduced (to eliminate subtract operation). Action analysis needs to be aware of the special treatment on 'sizeInBytes' and 'sizeInBits' function and not report an error when a slice is applied to the output of the functions.