P4C
The P4 Compiler
Loading...
Searching...
No Matches
ActionData::ALUOperation Class Reference

#include <action_format.h>

Public Member Functions

 ALUOperation (PHV::Container cont, ALUOPConstraint_t cons)
 
cstring action_name () const
 
void add_mask_param (ALUParameter &ap)
 
void add_param (ALUParameter &ap)
 
const ALUOperationadd_right_shift (int right_shift, int *rot_alias_idx) const
 
cstring alias () const
 
ALUOPConstraint_t constraint () const
 
PHV::Container container () const
 
bool contains_only_one_overlap_solution () const
 
const RamSectioncreate_meter_alu_RamSection () const
 
const RamSectioncreate_meter_color_RamSection () const
 
const RamSectioncreate_RamSection (bool shift_to_lsb) const
 
void dbprint_multiline () const
 
const ALUParameterfind_param_alloc (UniqueLocationKey &key) const
 
template<typename T >
bool has_param () const
 
int hw_right_shift () const
 
size_t index () const
 
bool is_constrained (ALUOPConstraint_t cons) const
 
bool is_right_shift_from_hw () const
 
cstring mask_alias () const
 
bitvec mask_bits () const
 
ParameterPositions parameter_positions () const
 
std::string parameter_positions_to_string () const
 
bitvec phv_bits () const
 
bitvec phv_bytes () const
 
bool right_shift_set () const
 
void set_action_name (cstring an)
 
void set_alias (cstring a)
 
void set_mask_alias (cstring ma)
 
size_t size () const
 
bitvec slot_bits () const
 
bitvec static_entry_of_arg (const Argument *arg, bitvec value) const
 
bitvec static_entry_of_constants () const
 
bool valid () const
 
cstring wrapped_constant () const
 

Friends

std::ostream & operator<< (std::ostream &out, const ALUOperation &op)
 
std::ostream & operator<< (std::ostream &out, const ALUOperation *op)
 

Detailed Description

This class is the representation of the src1 of a single ALU operation when the src1 comes from the Action Data Bus. Essentially a single PHV instruction could be represented as, (somewhat): PHV Container number(phv_bits) = function(ADB SLOT number(slot_bits))

This class represents the data contained within slot-hi to slot-lo. What is known at Action Format allocation are both which container the data is headed to and which bits of the container are used.

The purpose of the allocation is to both figure out the slot_bits ( which is just the PHV bits barrel_shifted right by a certain amount), as well as a potential RAM location to store this Action Data.

Member Function Documentation

◆ add_right_shift()

const ALUOperation * ActionData::ALUOperation::add_right_shift ( int right_shift,
int * rot_alias_idx ) const

In the case where a parameter is rotated around the slot_size, as is the case in a deposit-field instruction, an alias is necessary for this rotation to be printed out correctly in assembly (as this is converted to a deposit-field with a wrapped slice).

If the ALUOperation does not yet have an alias, then one is created. Potentially multiple can be created per action, requiring an index to be tracked

◆ create_meter_alu_RamSection()

const RamSection * ActionData::ALUOperation::create_meter_alu_RamSection ( ) const

Specifically for creating Meter ALU Ram Sections.

The Meter ALU output is always locked in position, as it is not programmable from the control plane where the bits are used. If the parameter is from Meter(lo..hi), the position on the home row action bus will be (lo..hi), as this is written directly from the ALU user.

Thus lo..hi must fit within a single adb slot, which is currently verified by action_analysis. For the ALUPosition object, the start byte is also already known as well as it comes from the lo / 8 of the action data bus.

◆ create_meter_color_RamSection()

const RamSection * ActionData::ALUOperation::create_meter_color_RamSection ( ) const

Meter Color is always output to bits 24..31 of immediate. There are multiple implications of this hardware limitation for this algorithm.

  1. For standard ALU operations, when a RAMSection is created, it is the size of the operation, or 2 x size of the ALU operation. However, because this is always in the upper section, this creates a 32 bit RamSection size that cannot be rotated.
  2. Because the parameter is locked into a position, the right shift (i.e. the rotation from the phv_bits), is locked in before allocation, vs. other operations which can rotate during the allocation

◆ create_RamSection()

const RamSection * ActionData::ALUOperation::create_RamSection ( bool shift_to_lsb) const

This function creates from a RamSection with it's isolated ALU information. This is the initial state from which the RamSections can be condensed and determined where they are in RAM.

◆ has_param()

template<typename T >
bool ActionData::ALUOperation::has_param ( ) const
inline

See also
comments on create_meter_color_RamSection

◆ phv_bytes()

bitvec ActionData::ALUOperation::phv_bytes ( ) const

compute a byte mask for bytes that are present in the phv_bits

◆ static_entry_of_arg()

bitvec ActionData::ALUOperation::static_entry_of_arg ( const Argument * arg,
bitvec value ) const

Given an Argument, and its corresponding static value, calculate the action data RAM value of this ALUOperation that correspond to that argument.

◆ static_entry_of_constants()

bitvec ActionData::ALUOperation::static_entry_of_constants ( ) const

Given an ALUOperation, return the action data RAM value of all of the constants saved on the RAM.