P4C
The P4 Compiler
|
#include <action_format.h>
Public Member Functions | |
SingleActionPositions (cstring an, safe_vector< RamSectionPosition > ai) | |
size_t | adt_bits_required () const |
safe_vector< RamSectionPosition > | best_inputs_to_move (int bits_to_move) |
size_t | bits_required () const |
std::array< bool, SECT_TYPES > | can_be_immed_msb (int bits_to_move) const |
std::array< int, SECT_TYPES > | min_bit_of_contiguous_sect () const |
std::array< int, SECT_TYPES > | minmax_bit_req () const |
void | move_other_sections_to_immed (int bits_to_move, SlotType_t minmax_sz, safe_vector< RamSectionPosition > &immed_vec) |
void | move_to_immed_from_adt (safe_vector< RamSectionPosition > &rv, size_t slot_sz, bool move_min_max_bit_req) |
std::array< int, SECT_TYPES > | sections_of_size () const |
size_t | total_slots_of_type (SlotType_t slot_type) const |
Public Attributes | |
cstring | action_name |
safe_vector< RamSectionPosition > | all_inputs |
Friends | |
std::ostream & | operator<< (std::ostream &out, const SingleActionPositions &sap) |
The allocation of all RamSections for a single action.
Please note the difference between slots/sections. The slots represent the action data xbar input slots, which come from the position of ALUOperation objects, while the section denote the RamSections, built up of many ALUOperation objects.
size_t ActionData::SingleActionPositions::adt_bits_required | ( | ) | const |
Due to the adt entries required to be at certain granularities, the bits_required might be less than the adt_bits_required
safe_vector< RamSectionPosition > ActionData::SingleActionPositions::best_inputs_to_move | ( | int | bits_to_move | ) |
As described in the comments above determine_bytes_per_loc, some actions must action data from an ActionData Tables to Immediate Data. The purpose of this function is to determine which sections to move.
The data can be moved in the sizes of the sections, i.e. on the granularity of bytes, half-words and full-words.
The other important this to note is that while action data requires the full entry size, immediate data has a bit-by-bit advantage. Immediate data can be packed right next to match data or other overhead data with no respect to the byte positions on the match RAM, due to the shift/mask/default behavior of match central.
Thus as part of the goal of moving action data, the goal is to require the minimum sized mask for immediate (at this point, the immediate mask has to be contiguous for the rest of the compiler)
The bits_to_move is the minimum number of bits (at a byte granularity) to move to immediate, as the entire slot has to be moved, which is either 8, 16, 32 or 64 bits in size. (64 bits obviously cannot be moved)
std::array< bool, SECT_TYPES > ActionData::SingleActionPositions::can_be_immed_msb | ( | int | bits_to_move | ) | const |
This determines, that given the number of bits that are required to be moved to immediate, that this particular slot size can be the final lsb.
Essentially the calculation is that if the total number of bits of slot_types, where slot_type_bits < bits_to_move, is also < bits_to_move, then any of those slot_types cannot fit
Best exemplified by an example. Say the bits_to_move is 16, and there is only one slot of BYTE size, then it would always be suboptimal to have the 8 bit slot to be the msb, as a 16 bit slot would by requirement have to be before the 8 bit slot in order to move at least 16 bits
std::array< int, SECT_TYPES > ActionData::SingleActionPositions::min_bit_of_contiguous_sect | ( | ) | const |
Used to determine which input should be placed last in the immediate bytes in order to determine which size should be the most significant action data in immediate.
std::array< int, SECT_TYPES > ActionData::SingleActionPositions::minmax_bit_req | ( | ) | const |
The goal of immediate data packing is to reduce the number of bits required to mask out of overhead. In order to do some of this calculation, the goal is to find the RamSection of particular packing sizes that have the smallest msb.
This function returns the minimum max bit in use of all RamSections of all possible sizes
void ActionData::SingleActionPositions::move_other_sections_to_immed | ( | int | bits_to_move, |
SlotType_t | minmax_sz, | ||
safe_vector< RamSectionPosition > & | immed_vec ) |
Now that the minmax value has be moved to immediate, this slot might have been less than the required number of bits necessary to move down to the next action data entry size. The purpose of this function is to determine which other sections to move to immediate as well.
std::array< int, SECT_TYPES > ActionData::SingleActionPositions::sections_of_size | ( | ) | const |
The sections_of_size are different than the slots of size in that the sections represent the RamSection while the the slots represent the inputs to the ActionDataBus, which come from the ALUOperation objects.
size_t ActionData::SingleActionPositions::total_slots_of_type | ( | SlotType_t | slot_type | ) | const |
Gathers the number of action data bus inputs of slot_type are in this particular action