P4C
The P4 Compiler
Loading...
Searching...
No Matches
ActionData::Format::Use Struct Reference

Public Member Functions

safe_vector< const ALUPosition * > all_alu_positions () const
 
const RamSectionbuild_locked_in_sect () const
 
void clear ()
 
void determine_immediate_mask ()
 
void determine_mod_cond_maps ()
 
const ALUParameterfind_locked_in_all_actions_param_alloc (UniqueLocationKey &loc, const ALUPosition **alu_pos_p) const
 
const ALUParameterfind_param_alloc (UniqueLocationKey &loc, const ALUPosition **alu_pos_p) const
 
cstring get_format_name (const ALUPosition &alu_pos, bool bitmasked_set=false, le_bitrange *slot_bits=nullptr, le_bitrange *postpone_range=nullptr) const
 
cstring get_format_name (SlotType_t slot_type, Location_t loc, int byte_offset, le_bitrange *slot_bits=nullptr, le_bitrange *postpone_range=nullptr) const
 
bool if_action_has_action_data (cstring action_name) const
 
bool if_action_has_action_data_table (cstring action_name) const
 
int immediate_bits () const
 
template<typename T >
bool is_byte_offset (int byte_offset) const
 

Public Attributes

std::map< cstring, safe_vector< ALUPosition > > alu_positions
 
std::array< BusInputs, AD_LOCATIONS > bus_inputs
 
std::array< int, AD_LOCATIONS > bytes_per_loc = {{0, 0}}
 
bitvec full_words_bitmasked
 
bitvec immediate_mask
 
safe_vector< ALUPositionlocked_in_all_actions_alu_positions
 
BusInputs locked_in_all_actions_bus_inputs = {{bitvec(), bitvec(), bitvec()}}
 
std::map< cstring, ModCondMap > mod_cond_values
 

Friends

std::ostream & operator<< (std::ostream &out, const Use &use)
 

Member Function Documentation

◆ determine_immediate_mask()

void ActionData::Format::Use::determine_immediate_mask ( )

Calculate the mask of immediate bits which are to be packed on the table format. The immediate data is represented at bit-granularity.

◆ determine_mod_cond_maps()

void ActionData::Format::Use::determine_mod_cond_maps ( )

A map for coordinating conditional parameters to their associated position in the JSON The key is a the name of the condition, the value is two bitvecs, one in action_data_table, one in immediate, in which the bits are controlled by that condition

See also
asm_output::EmitAction::mod_cond_value

◆ find_locked_in_all_actions_param_alloc()

const ALUParameter * ActionData::Format::Use::find_locked_in_all_actions_param_alloc ( UniqueLocationKey & key,
const ALUPosition ** alu_pos_p ) const

Because the parameters are shared across all actions, the ALUOperations are stored across all actions. Each ALUOperation in all of these are also marked with the action_name as well, though in other lookups, the parameter can be looked up as a per action

◆ find_param_alloc()

const ALUParameter * ActionData::Format::Use::find_param_alloc ( UniqueLocationKey & key,
const ALUPosition ** alu_pos_p ) const

During the Instruction Adjustment phase of ActionAnalysis, in order to determine how to rename both constants and action data, as well as verify that the alignment is correct, an action parameter must be found within the action format.

This is done with a four part key:

  1. The action name
  2. The container (this should provide an ALUOperation, as only one ALUOperation is possible per container per action
  3. The phv_bits affected
  4. The parameter (technically a duplicate of 3, but can verify that both portions are the same).

This function returns the ALUParameter object, as well as the correspding ALUPosition object

◆ get_format_name()

cstring ActionData::Format::Use::get_format_name ( SlotType_t slot_type,
Location_t loc,
int byte_offset,
le_bitrange * slot_bits = nullptr,
le_bitrange * postpone_range = nullptr ) const

The purpose of this function is to have a standardized name of the location of parameters across multiple needs for it in the assembly output.

Specifically, in this example, parameters can be located with 3/4 coordinates:

1. SlotType_t slot_type - whether the alu op is a byte, half, or full word
2. Location_t loc - if the byte is in Action Data or Immediate
3. int byte_offset - the starting bit of that ALU operation in that location
4. optional bit_range to specify bit portions of the range.

Realistically, all of these are stored in the ALUPosition structure, though through asm_output, specifically during action data bus generation, the ALUPosition structure is not always available, so this function can be called.

The standardization is currently the following:

  1. If the location is in ACTION_DATA_TABLE, the name is $adf_(type)(offset), where type comes from the slot_type, and the offset is just the SlotType_t increment
  2. If the location is in IMMEDIATE, then the name has to coordinate with the table_format name, in this case "immediate". This is also followed by a lo..hi range, as the immediate has a max range while anything on the action data format is the full 8, 16, or 32 bits.

In addition, there are two parameters, for bit level granularity.

  1. slot_bits: for including a bit range starting from slot_bits lo to slot_bits hi
  2. postpone_range: if the range is going to be determined later, and is not part of the generated range

Member Data Documentation

◆ bus_inputs

std::array<BusInputs, AD_LOCATIONS> ActionData::Format::Use::bus_inputs
Initial value:
= {
{{{bitvec(), bitvec(), bitvec()}}, {{bitvec(), bitvec(), bitvec()}}}}
Definition bitvec.h:120

‍A bitvec per each SlotType / Location representing the use of each SlotType on input. Could be calculated directly from alu_positions

◆ full_words_bitmasked

bitvec ActionData::Format::Use::full_words_bitmasked

‍Which FULL words are to be used in a bitmasked-set, as those have to be contiguous on the action data bus words. Could be calculated directly from alu_positions

◆ immediate_mask

bitvec ActionData::Format::Use::immediate_mask

‍A contiguous bits of action data in match overhead. Could be calculated directly from alu_positions