P4C
The P4 Compiler
Loading...
Searching...
No Matches
ParserQuery Struct Reference

Collection of functions to check parser information. More...

#include <parser_query.h>

Public Member Functions

 ParserQuery (const CollectParserInfo &pi, const MapFieldToParserStates &fs)
 
ordered_set< const IR::BFN::ParserPrimitive * > find_inits (const ordered_set< const IR::BFN::ParserPrimitive * > &writes) const
 
ordered_set< const IR::BFN::ParserPrimitive * > find_inits (PHV::Container c) const
 
ordered_set< const IR::BFN::ParserPrimitive * > get_previous_writes (const IR::BFN::ParserPrimitive *p, const ordered_set< const IR::BFN::ParserPrimitive * > &writes) const
 
bool is_before (const ordered_set< const IR::BFN::ParserPrimitive * > &writes, const IR::BFN::Parser *parser, const IR::BFN::ParserPrimitive *p, const IR::BFN::ParserState *ps, const IR::BFN::ParserPrimitive *q, const IR::BFN::ParserState *qs=nullptr) const
 
bool is_single_write (const ordered_set< const IR::BFN::ParserPrimitive * > &writes) const
 
bool same_const_source (const IR::BFN::ParserPrimitive *pp, const IR::BFN::ParserPrimitive *qp) const
 Do two extracts use the same constant value?
 

Public Attributes

const MapFieldToParserStatesfield_to_states
 
const CollectParserInfoparser_info
 

Detailed Description

Collection of functions to check parser information.

These functions rely on data provided by other classes, hence the reason for encapsulating inside a struct

Member Function Documentation

◆ find_inits() [1/2]

ordered_set< const IR::BFN::ParserPrimitive * > ParserQuery::find_inits ( const ordered_set< const IR::BFN::ParserPrimitive * > & writes) const

Find the first writes, i.e. inits, given the set of writes. The set of writes belong to the same field. An init is a write that has no prior write in the parser IR.

◆ find_inits() [2/2]

ordered_set< const IR::BFN::ParserPrimitive * > ParserQuery::find_inits ( PHV::Container c) const

Find the first writes, i.e. inits, corresponding to the container c. An init is a write that has no prior write in the parser IR.

◆ get_previous_writes()

ordered_set< const IR::BFN::ParserPrimitive * > ParserQuery::get_previous_writes ( const IR::BFN::ParserPrimitive * p,
const ordered_set< const IR::BFN::ParserPrimitive * > & writes ) const

Find all prior writes for a given write

Parameters
pThe write for which to find prior writes
writesThe set of writes from which to identify prior writes
Returns
An ordered_set of all writes that occur prior to

◆ is_before()

bool ParserQuery::is_before ( const ordered_set< const IR::BFN::ParserPrimitive * > & writes,
const IR::BFN::Parser * parser,
const IR::BFN::ParserPrimitive * p,
const IR::BFN::ParserState * ps,
const IR::BFN::ParserPrimitive * q,
const IR::BFN::ParserState * qs = nullptr ) const

Check if the effect of p is before the effect of q in the parser. writes is the set of writes that belong to the same field and both p and q must be in this set. ps must be state of p or nullptr. qs must be state of q or nullptr.

◆ is_single_write()

bool ParserQuery::is_single_write ( const ordered_set< const IR::BFN::ParserPrimitive * > & writes) const

Are all writes in writes single-write (i.e., no path through the parse graph executes more than one write).

◆ same_const_source()

bool ParserQuery::same_const_source ( const IR::BFN::ParserPrimitive * pp,
const IR::BFN::ParserPrimitive * qp ) const

Do two extracts use the same constant value?

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