P4C
The P4 Compiler
Loading...
Searching...
No Matches
SliceExtracts Struct Reference
Inheritance diagram for SliceExtracts:
[legend]

Public Member Functions

 SliceExtracts (const PhvInfo &phv, const ClotInfo &clot, const CollectParserInfo &parser_info, const MapFieldToParserStates &field_to_states)
 
template<class Extract >
const Extract * make_slice (const IR::BFN::Extract *extract, int le_low_idx, int width, int extract_base, std::optional< PHV::Container > cont=std::nullopt)
 
bool preorder (IR::BFN::ParserState *state) override
 
std::vector< const IR::BFN::Extract * > slice_extract (const IR::BFN::Extract *extract)
 

Public Attributes

const ClotInfoclot
 
const PhvInfophv
 
const ParserQuery pq
 
const IR::BFN::ParserState * state = nullptr
 

Detailed Description

Slices each extract into multiple extracts that each write into a single PHV container or CLOT. This prepares for the subsequent state-splitting pass, where we may need to allocate the sliced extracts into different states (this is the case when field straddles the input-buffer boundary).

Member Function Documentation

◆ make_slice()

template<class Extract >
const Extract * SliceExtracts::make_slice ( const IR::BFN::Extract * extract,
int le_low_idx,
int width,
int extract_base,
std::optional< PHV::Container > cont = std::nullopt )
inline

Rewrites an extract so that it extracts exactly the slice specified by le_low_idx and width, and marks the extract with the given extract type.

Parameters
extractextract to be rewritten.
le_low_idxthe little-endian index for the low end of the slice.
widththe width of the slice, in bits.
extract_baseThe low index of the extract destination ignoring slicing. For example, for extract inbuf bit[112..175] to ig_md.f[95:32], assume ig_md.f[95:64] and ig_md.f[63:32] are allocated to two 32-bit container. Two make_slice will be called. For the first make_slice, le_low_idx is 32, width is 32 and extract_base is 32. For the second make_slice, le_low_idx is 64, width is 32 and extract_base is 32.

◆ slice_extract()

std::vector< const IR::BFN::Extract * > SliceExtracts::slice_extract ( const IR::BFN::Extract * extract)
inline

Breaks up an Extract into a series of Extracts according to the extracted field's PHV and CLOT allocation.