P4C
The P4 Compiler
Loading...
Searching...
No Matches
ActionData::Parameter Class Referenceabstract

#include <action_format.h>

Inheritance diagram for ActionData::Parameter:
[legend]

Public Member Functions

virtual bool can_merge (const Parameter *param) const
 
bool can_overlap_ranges (le_bitrange my_range, le_bitrange ad_range, le_bitrange &overlap, le_bitrange *my_overlap, le_bitrange *ad_overlap) const
 
cstring cond_name () const
 
virtual void dbprint (std::ostream &out) const =0
 
bool equiv_cond (const Parameter *p) const
 
virtual bool equiv_value (const Parameter *, bool check_cond=true) const =0
 
virtual bool from_p4_program () const =0
 
virtual const Parameterget_extended_param (uint32_t extension, const Parameter *) const =0
 
template<typename T >
bool is () const
 
bool is_cond_type (ModConditionally_t type) const
 
virtual bool is_next_bit_of_param (const Parameter *, bool same_alias) const =0
 
virtual bool is_subset_of (const Parameter *param) const
 
virtual const Parametermerge (const Parameter *param) const
 
virtual cstring name () const =0
 
virtual bool only_one_overlap_solution () const =0
 
virtual const Parameteroverlap (const Parameter *ad, bool guaranteed_one_overlap, le_bitrange *my_overlap, le_bitrange *ad_overlap) const =0
 
void set_cond (const Parameter *p)
 
void set_cond (ModConditionally_t ct, cstring n)
 
virtual int size () const =0
 
virtual const Parametersplit (int lo, int hi) const =0
 
template<typename T >
const T * to () const
 
- Public Member Functions inherited from P4::IHasDbPrint
void print () const
 

Protected Attributes

cstring _cond_name
 
ModConditionally_t _cond_type = NONE
 

Detailed Description

The purpose of this class is the base abstract class for any parameter that can appear as any section of bits on the action data bus. This by itself does not coordinate to any particular location in the bus or relationship to PHV, but is just information that can be classified as ActionData

Member Function Documentation

◆ dbprint()

virtual void ActionData::Parameter::dbprint ( std::ostream & out) const
pure virtual

Implements P4::IHasDbPrint.

◆ get_extended_param()

virtual const Parameter * ActionData::Parameter::get_extended_param ( uint32_t extension,
const Parameter *  ) const
pure virtual

Implemented in ActionData::Constant.

◆ is_next_bit_of_param()

virtual bool ActionData::Parameter::is_next_bit_of_param ( const Parameter * ,
bool same_alias ) const
pure virtual

Implemented in ActionData::Constant.

◆ overlap()

virtual const Parameter * ActionData::Parameter::overlap ( const Parameter * ad,
bool guaranteed_one_overlap,
le_bitrange * my_overlap,
le_bitrange * ad_overlap ) const
pure virtual

Member Data Documentation

◆ _cond_type

ModConditionally_t ActionData::Parameter::_cond_type = NONE
protected

A modify_field_conditionally in p4-14, which is converted to a ternary operation in p4-16 is done in the following manner. The instruction is converted to a bitmasked-set, with the even action data bus location being the parameter, and the odd action data bus location being the conditional mask.

bitmasked-set, described in uArch 15.1.3.8 Bit maskable set can be thought of as the following: dest = (src1 & mask) | (src2 & ~mask)

where the mask is directly stored on the RAM line, and is used on the action data bus.

The mask is stored at the odd word, so in the case of a conditional set, the driver can update the mask as it would any other parameter. However, at the even word, it is not just src1 stored, but src1 & mask. The mask stored at the second word is used as the background. Thus, if the condition is true, src1 will equal the parameter, but if the condition is false, src1 will be 0.

This leads to the following issue. Say you had a P4 action:

action a1(bit<8> p1, bool cond) { hdr.f1 = p1; hdr.f2 = cond ? p1 : hdr.f2; }

While previously, the data space for parameter p1 could have been shared, because of the condition, these have to be completely separate spaces on the RAM line, as the p1 in the second instruction could sometimes be zero. The rule is the following:

Data is only equivalent when both the original parameter and the condition that is controlling that parameter are equivalent.