P4C
The P4 Compiler
Loading...
Searching...
No Matches
FieldSliceExtractInfo Class Reference

Holds information relating to a field slice's extract. More...

#include <field_slice_extract_info.h>

Public Member Functions

 FieldSliceExtractInfo (const ordered_map< const IR::BFN::ParserState *, unsigned > &state_bit_offsets, const std::map< unsigned, ordered_map< const IR::BFN::ParserState *, unsigned > > &stack_offset_state_bit_offsets, int min_packet_bit_offset, int max_packet_bit_offset, const PHV::Field *field)
 
 FieldSliceExtractInfo (const ordered_map< const IR::BFN::ParserState *, unsigned > &state_bit_offsets, const std::map< unsigned, ordered_map< const IR::BFN::ParserState *, unsigned > > &stack_offset_state_bit_offsets, int min_packet_bit_offset, int max_packet_bit_offset, const PHV::FieldSlice *slice)
 
const std::map< unsigned, StatePairSetbit_gaps (const CollectParserInfo &parserInfo, const FieldSliceExtractInfo *other) const
 
unsigned bit_in_byte_offset () const
 
const std::map< unsigned, StatePairSetbyte_gaps (const CollectParserInfo &parserInfo, const FieldSliceExtractInfo *other) const
 
int max_packet_bit_offset () const
 
int min_packet_bit_offset () const
 
std::vector< const FieldSliceExtractInfo * > * remove_conflicts (const CollectParserInfo &parserInfo, int preGapBits, const ClotCandidate *candidate, int postGapBits) const
 
const PHV::FieldSliceslice () const
 
unsigned state_bit_offset (const IR::BFN::ParserState *state) const
 
const ordered_map< const IR::BFN::ParserState *, unsigned > & state_bit_offsets () const
 
ordered_set< const IR::BFN::ParserState * > states () const
 
const FieldSliceExtractInfotrim (int lo_idx, int bits) const
 
const FieldSliceExtractInfotrim_head_to_byte () const
 Trims the start of the extract so that it is byte-aligned.
 
const FieldSliceExtractInfotrim_head_to_min_clot_pos () const
 Trims the start of the extract so that it does not extend past the minimum CLOT position.
 
const FieldSliceExtractInfotrim_tail_to_byte () const
 Trims the end of the extract so that it is byte-aligned.
 
const FieldSliceExtractInfotrim_tail_to_max_clot_pos () const
 Trims the end of the extract so that it does not extend past the maximum CLOT position.
 
void update (const IR::BFN::ParserState *state, unsigned stack_offset, unsigned state_bit_offset, int min_packet_bit_offset, int max_packet_bit_offset)
 

Friends

class GreedyClotAllocator
 
std::ostream & operator<< (std::ostream &out, const FieldSliceExtractInfo &field_slice_extract_info)
 
std::ostream & operator<< (std::ostream &out, const FieldSliceExtractInfo *field_slice_extract_info)
 
bool operator== (const FieldSliceExtractInfo &a, const FieldSliceExtractInfo &b)
 

Detailed Description

Holds information relating to a field slice's extract.

Member Function Documentation

◆ bit_gaps()

const std::map< unsigned, StatePairSet > FieldSliceExtractInfo::bit_gaps ( const CollectParserInfo & parserInfo,
const FieldSliceExtractInfo * other ) const

Produces a map wherein the keys are all possible gap sizes, in bits, between the end of this extract and the start of another extract when this extract occurs before the other extract in the input packet.

Each possible gap size is mapped to the set of parser states that realize that gap. Each set member is a pair, wherein the first component is the state containing this extract, and the second component is the state containing other.

◆ bit_in_byte_offset()

unsigned FieldSliceExtractInfo::bit_in_byte_offset ( ) const
inline
Returns
the field slice's bit-in-byte offset in the packet.

◆ byte_gaps()

const std::map< unsigned, StatePairSet > FieldSliceExtractInfo::byte_gaps ( const CollectParserInfo & parserInfo,
const FieldSliceExtractInfo * other ) const

Analogous to ClotCandidate::gaps. Produces a map wherein the keys are all possible gap sizes, in bits, between the end of this extract and the start of another extract when this extract occurs before the other extract in the input packet. An error occurs if any possible gap is not a multiple of 8 bits.

Each possible gap size is mapped to the set of parser states that realize that gap. Each set member is a pair, wherein the first component is the state containing this extract, and the second component is the state containing other.

◆ max_packet_bit_offset()

int FieldSliceExtractInfo::max_packet_bit_offset ( ) const
inline
Returns
the field slice's maximum offset, in bits, from the start of the packet to the start of the field slice.

◆ min_packet_bit_offset()

int FieldSliceExtractInfo::min_packet_bit_offset ( ) const
inline
Returns
the field slice's minimum offset, in bits, from the start of the packet to the start of the field slice.

◆ remove_conflicts()

std::vector< const FieldSliceExtractInfo * > * FieldSliceExtractInfo::remove_conflicts ( const CollectParserInfo & parserInfo,
int preGapBits,
const ClotCandidate * candidate,
int postGapBits ) const

Removes any bytes that conflict with the given candidate, returning the resulting list of FieldSliceExtractInfo instances, in the order in which they appear in the packet. More than one instance can result if conflicting bytes occur in the middle of the extract.

Parameters
parserInfoParser info.
preGapBitsThe size, in bits, of the inter-CLOT gap required before the given candidate.
candidateCLOT candidate.
postGapBitsThe size, in bits, of the inter-CLOT gap required after the given candidate.

◆ slice()

const PHV::FieldSlice * FieldSliceExtractInfo::slice ( ) const
inline
Returns
the field slice itself.

◆ state_bit_offset()

unsigned FieldSliceExtractInfo::state_bit_offset ( const IR::BFN::ParserState * state) const
inline
Returns
the bit offset of the field slice, relative to the given parser state.

◆ state_bit_offsets()

const ordered_map< const IR::BFN::ParserState *, unsigned > & FieldSliceExtractInfo::state_bit_offsets ( ) const
inline
Returns
the field slice's offset, in bits, from the start of each parser state in which the field is extracted.

◆ states()

ordered_set< const IR::BFN::ParserState * > FieldSliceExtractInfo::states ( ) const
Returns
the parser states in which the field slice is extracted.

◆ trim()

const FieldSliceExtractInfo * FieldSliceExtractInfo::trim ( int lo_idx,
int bits ) const

Trims the extract to a sub-slice.

Parameters
lo_idxThe start of the new slice, relative to the start of the old slice.
bitsThe number of bits.

Slices are trimmed relative to the least-significant bit (LSB) of the slice. A lo_idx value of 0 leaves the slice LSB unchanged, while a positive value discards lo_idx LSBs from the slice.

◆ update()

void FieldSliceExtractInfo::update ( const IR::BFN::ParserState * state,
unsigned stack_offset,
unsigned state_bit_offset,
int min_packet_offset,
int max_packet_offset )

Updates this object for this field being extracted in a newly discovered parser state.

Parameters
statethe new parser state
stack_offsetstack index offset
state_bit_offsetthe field's bit offset from the beginning of state
min_packet_bit_offsetthe minimum bit offset from the beginning of the packet of the field in the given state
max_packet_bit_offsetthe maximum bit offset from the beginning of the packet of the field in the given state

Copyright (C) 2024 Intel Corporation

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

SPDX-License-Identifier: Apache-2.0