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

#include <action_format.h>

Inheritance diagram for ActionData::Constant:
[legend]

Public Member Functions

 Constant (bitvec v, size_t sz)
 
 Constant (int v, size_t sz)
 
cstring alias () const
 
void dbprint (std::ostream &out) const override
 
bool equiv_value (const Parameter *ad, bool check_cond=true) const override
 
bool from_p4_program () const override
 
const Parameterget_extended_param (uint32_t extension, const Parameter *ad) const override
 
bool is_next_bit_of_param (const Parameter *ad, bool same_alias) const override
 
cstring name () const override
 
bool only_one_overlap_solution () const override
 
const Parameteroverlap (const Parameter *ad, bool only_one_overlap_solution, le_bitrange *my_overlap, le_bitrange *ad_overlap) const override
 
void set_alias (cstring a)
 
int size () const override
 
const Parametersplit (int lo, int hi) const override
 
bitvec value () const
 
- Public Member Functions inherited from ActionData::Parameter
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
 
bool equiv_cond (const Parameter *p) const
 
template<typename T >
bool is () const
 
bool is_cond_type (ModConditionally_t type) const
 
virtual bool is_subset_of (const Parameter *param) const
 
virtual const Parametermerge (const Parameter *param) const
 
void set_cond (const Parameter *p)
 
void set_cond (ModConditionally_t ct, cstring n)
 
template<typename T >
const T * to () const
 
- Public Member Functions inherited from P4::IHasDbPrint
void print () const
 

Additional Inherited Members

- Protected Attributes inherited from ActionData::Parameter
cstring _cond_name
 
ModConditionally_t _cond_type = NONE
 

Detailed Description

This class represents a section of IR::MAU::ActionDataConstant, or an IR::Constant that cannot be created as the src1 operand of an ALU operation. The constant instead must come from Action Ram.

Similar to IR::Constant, the constant has a value and a bit size. Due to the size of the constant theoretically being infinite, a bitvec is used to store the value (though in theory, an mpz_class could have been used as well

Member Function Documentation

◆ dbprint()

void P4::IR::Constant::dbprint ( std::ostream & out) const
inlineoverridevirtual

Implements ActionData::Parameter.

◆ equiv_value()

bool ActionData::Constant::equiv_value ( const Parameter * ad,
bool check_cond = true ) const
overridevirtual

Implements ActionData::Parameter.

◆ from_p4_program()

bool ActionData::Constant::from_p4_program ( ) const
inlineoverridevirtual

Implements ActionData::Parameter.

◆ get_extended_param()

const Parameter * ActionData::Constant::get_extended_param ( uint32_t extension,
const Parameter * ad ) const
overridevirtual

Appending a constant to another constant on the MSB

Implements ActionData::Parameter.

◆ is_next_bit_of_param()

bool ActionData::Constant::is_next_bit_of_param ( const Parameter * ad,
bool same_alias ) const
overridevirtual

If the constant is coming from an argument, it has an alias. If the same alias is set to true, then only return true if the current constant has the same alias as the next constant

Implements ActionData::Parameter.

◆ name()

cstring ActionData::Constant::name ( ) const
inlineoverridevirtual

Implements ActionData::Parameter.

◆ only_one_overlap_solution()

bool ActionData::Constant::only_one_overlap_solution ( ) const
inlineoverridevirtual

Implements ActionData::Parameter.

◆ overlap()

const Parameter * ActionData::Constant::overlap ( const Parameter * ad,
bool only_one_overlap_solution,
le_bitrange * my_overlap,
le_bitrange * ad_overlap ) const
overridevirtual

Because Constants can potentially have multiple overlaps, this will only return an overlap under the following condition:

The constant that is smaller size than the other constant must be fully contained
within the other constant.

This could possibly be updated overtime to allow for more constant processing, i.e. overlaps at the edges of the constant

The parameter only_one_overlap_solution indicates that the overlap function will only return if overlap has one and only one solution (as this function is used by multiple Parameters). Constants do not have this property and will always return a no solution

Implements ActionData::Parameter.

◆ size()

int ActionData::Constant::size ( ) const
inlineoverridevirtual

Implements ActionData::Parameter.

◆ split()

const Parameter * ActionData::Constant::split ( int lo,
int hi ) const
overridevirtual

Implements ActionData::Parameter.