![]() |
P4C
The P4 Compiler
|
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, StatePairSet > | bit_gaps (const CollectParserInfo &parserInfo, const FieldSliceExtractInfo *other) const |
unsigned | bit_in_byte_offset () const |
const std::map< unsigned, StatePairSet > | byte_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::FieldSlice * | slice () 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 FieldSliceExtractInfo * | trim (int lo_idx, int bits) const |
const FieldSliceExtractInfo * | trim_head_to_byte () const |
Trims the start of the extract so that it is byte-aligned. | |
const FieldSliceExtractInfo * | trim_head_to_min_clot_pos () const |
Trims the start of the extract so that it does not extend past the minimum CLOT position. | |
const FieldSliceExtractInfo * | trim_tail_to_byte () const |
Trims the end of the extract so that it is byte-aligned. | |
const FieldSliceExtractInfo * | trim_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) |
Holds information relating to a field slice's extract.
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
.
|
inline |
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
.
|
inline |
|
inline |
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.
parserInfo | Parser info. |
preGapBits | The size, in bits, of the inter-CLOT gap required before the given candidate . |
candidate | CLOT candidate. |
postGapBits | The size, in bits, of the inter-CLOT gap required after the given candidate . |
|
inline |
|
inline |
state
.
|
inline |
ordered_set< const IR::BFN::ParserState * > FieldSliceExtractInfo::states | ( | ) | const |
const FieldSliceExtractInfo * FieldSliceExtractInfo::trim | ( | int | lo_idx, |
int | bits ) const |
Trims the extract to a sub-slice.
lo_idx | The start of the new slice, relative to the start of the old slice. |
bits | The 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.
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.
state | the new parser state |
stack_offset | stack index offset |
state_bit_offset | the field's bit offset from the beginning of state |
min_packet_bit_offset | the minimum bit offset from the beginning of the packet of the field in the given state |
max_packet_bit_offset | the 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