P4C
The P4 Compiler
Loading...
Searching...
No Matches
PHV::FieldSlice Class Reference

#include <phv_fields.h>

Inheritance diagram for PHV::FieldSlice:
[legend]

Public Member Functions

 FieldSlice (const Field *field)
 Create a slice that holds the entirety of field.
 
 FieldSlice (const Field *field, le_bitrange range)
 
 FieldSlice (FieldSlice slice, le_bitrange range)
 Creates a subslice of the field of slice from range.lo to range.hi.
 
std::optional< FieldAlignmentalignment () const
 
le_bitrange byteAlignedRangeInBits () const
 
int container_bytes () const
 
const PHV::Fieldfield () const override
 
template<class FN >
void foreach_byte (const IR::MAU::Table *ctxt, const PHV::FieldUse *use, FN fn) const
 
template<class FN >
void foreach_byte (const PHV::AllocContext *ctxt, const PHV::FieldUse *use, FN fn) const
 
bitvec getStartBits (PHV::Size size) const
 
gress_t gress () const
 Whether the Field is ingress or egress.
 
bool is_tphv_candidate (const PhvUse &uses) const
 
bool is_unallocated () const
 
bool is_whole_field () const
 
FieldKind kind () const
 Kind of field of this slice.
 
 operator bool () const
 
bool operator< (const FieldSlice &other) const override
 
bool operator== (const FieldSlice &other) const override
 
const le_bitrangerange () const override
 
cstring shortString () const
 
int size () const override
 Total size of FieldSlice in bits.
 
nw_bitrange validContainerRange () const
 See documentation for Field::validContainerRange().
 
- Public Member Functions inherited from PHV::AbstractField
template<typename T >
const T & as () const
 
template<typename T >
bool is () const
 
template<typename T >
const T * to () const
 
- Public Member Functions inherited from LiftCompare< FieldSlice >
 OPERATOR (equal, Equal)
 
 OPERATOR (not_equal, NotEqual)
 
bool operator!= (const FieldSlice &other) const
 
- Public Member Functions inherited from LiftEqual< FieldSlice >
 OPERATOR (equal, Equal)
 
 OPERATOR (not_equal, NotEqual)
 
bool operator!= (const FieldSlice &other) const
 
virtual bool operator== (const FieldSlice &) const=0
 
- Public Member Functions inherited from LiftLess< FieldSlice >
 OPERATOR (equal, Equal)
 
 OPERATOR (greater, Greater)
 
 OPERATOR (greater_equal, GreaterEqual)
 
 OPERATOR (less, Less)
 
 OPERATOR (less_equal, LessEqual)
 
 OPERATOR (not_equal, NotEqual)
 
bool operator!= (const FieldSlice &other) const
 
virtual bool operator< (const FieldSlice &) const=0
 
bool operator<= (const FieldSlice &other) const
 
bool operator== (const FieldSlice &other) const
 
bool operator> (const FieldSlice &other) const
 
bool operator>= (const FieldSlice &other) const
 

Friends

size_t hash_value (const FieldSlice &fs)
 

Additional Inherited Members

- Static Public Member Functions inherited from PHV::AbstractField
static AbstractFieldcreate (const PhvInfo &, const IR::Expression *)
 

Detailed Description

Represents a slice (range of bits) of a PHV::Field. Constraints on the field that are related to position, like alignment, are tailored for each slice.

Member Function Documentation

◆ alignment()

std::optional< FieldAlignment > PHV::FieldSlice::alignment ( ) const
inline

The alignment requirement of this field slice. If std::nullopt, there is no particular alignment requirement.

◆ byteAlignedRangeInBits()

le_bitrange PHV::FieldSlice::byteAlignedRangeInBits ( ) const
inline

Returns a range of bits in the header that captures the byte aligned offset of this slice within its header. E.g. Suppose a field f is at offset 10 within its header type and its size is 12 bits. The byte aligned range for f[0:7] will be [8, 24].

◆ field()

const PHV::Field * PHV::FieldSlice::field ( ) const
inlineoverridevirtual
Returns
the field this is a slice of.

Implements PHV::AbstractField.

◆ getStartBits()

bitvec PHV::FieldSlice::getStartBits ( PHV::Size size) const
Returns
the bit positions (little Endian) at which the least significant bit of this field may be placed.

◆ is_tphv_candidate()

bool PHV::FieldSlice::is_tphv_candidate ( const PhvUse & uses) const
Returns
true if the slice can be allocated to a TPHV container.

◆ is_whole_field()

bool PHV::FieldSlice::is_whole_field ( ) const
inline
Returns
true if this field slice contains the entirety of its field.

◆ range()

const le_bitrange & PHV::FieldSlice::range ( ) const
inlineoverridevirtual
Returns
the bits of the field included in this field slice.

Implements PHV::AbstractField.

◆ size()

int PHV::FieldSlice::size ( ) const
inlineoverridevirtual

Total size of FieldSlice in bits.

Implements PHV::AbstractField.