P4C
The P4 Compiler
Loading...
Searching...
No Matches
P4 Namespace Reference

TODO: this is not really specific to BMV2, it should reside somewhere else. More...

Namespaces

namespace  BMV2
 TODO: this is not really specific to BMV2, it should reside somewhere else.
 
namespace  ControlPlaneAPI
 TODO(antonin): High level goals of the generator go here!!
 
namespace  Coverage
 
namespace  DPDK
 
namespace  EBPF
 
namespace  graphs
 
namespace  literals
 
namespace  NetHash
 A collection of hashing functions commonly used in network protocols.
 
namespace  P4Tools
 
namespace  P4V1
 
namespace  TC
 This file defines functions for the pass to generate the introspection file.
 
namespace  Test
 

Classes

class  AbstractInliner
 
class  AbstractParserDriver
 
class  AbstractSolver
 Provides a higher-level interface for an SMT solver. More...
 
class  ActionCall
 
class  ActionInvocation
 
class  ActionReplacement
 
class  ActionsInliner
 
class  ActionSynthesisPolicy
 
class  AddMissingIdAnnotations
 
class  AllDefinitions
 
class  AllocTrace
 
class  AnalyzeParser
 
class  AnnotationSelectionPolicy
 
class  AnyElement
 
class  ApplyMethod
 
class  ApplyOptionsPragmas
 
class  ApplyTypesToExpressions
 
class  ArrayLocation
 
struct  AutoCompileContext
 
class  backtrace_exception
 
class  Backtrack
 
class  BaseCompileContext
 
class  BaseLocation
 
class  basic_nullbuf
 
class  BinaryConstraint
 Base class for EqualityConstraint and CanBeImplicitlyCastConstraint. More...
 
class  BindTypeVariables
 
class  bitranges
 
class  bitvec
 
class  BuildResourceMap
 
class  BuiltInMethod
 
class  CallGraph
 
struct  CallInfo
 Describes information about a caller-callee pair. More...
 
class  CanBeImplicitlyCastConstraint
 The right type can be implicitly cast to the left type. More...
 
class  CastBooleanTableKeys
 
class  CheckConstants
 
class  CheckCoreMethods
 
class  CheckExternInvocationCommon
 Base class which can be used to prepare classes for checking constraints for invocations of externs (both methods and pure functions) in parsers and control blocks. More...
 
class  CheckHeaderTypes
 
class  CheckNamedArgs
 
class  CheckShadowing
 
class  CheckTableSize
 Checks some possible misuses of the table size property. More...
 
class  ChooseEnumRepresentation
 
class  ChooseErrorRepresentation
 
class  ClearTypeMap
 
class  CloneConstants
 
class  CloneExpressions
 
class  CloneVariableDeclarations
 
struct  ClosedRange
 
class  CollectUsedDeclarations
 Collects all used declarations into @used set. More...
 
struct  CompileContextStack
 
class  CompilerOptions
 
class  CompileTimeOperations
 
class  ComplexValues
 
class  ComputeDefUse
 Compute defuse info within P4Parser and P4Control blocks in the midend. More...
 
class  ComputeParserCG
 Builds a CallGraph of ParserState nodes. More...
 
class  ComputeWriteSet
 
class  ConstantFolding
 
class  ConstantFoldingPolicy
 
class  ConstantTypeSubstitution
 
class  ConstructorCall
 
class  ContainerConstructorCall
 
class  ContainsType
 
class  ControlFlowVisitor
 
class  ControlInstantiation
 
class  ConvertEnums
 
class  ConvertErrors
 
class  CopySrcInfo
 
class  CopyStructures
 
class  CreateBuiltins
 
class  CreateSpecializedTypes
 
class  CreateStructInitializers
 Converts some list expressions into struct initializers. More...
 
class  cstring
 
class  DeclarationLookup
 
class  DefaultArguments
 
class  DefaultP4CConfiguration
 
class  DefaultValues
 
class  Definitions
 List of definers for each base storage (at a specific program point). More...
 
class  Deprecated
 
struct  DiagnosticCountInfo
 
struct  DiagnosticCountInfoGuard
 
struct  DiagnosticCountInfoState
 
class  DirectMeterMap
 
class  DiscoverActionsInlining
 
class  DiscoverFunctionsInlining
 
class  DiscoverInlining
 Must be run after an evaluator; uses the blocks to discover caller/callee relationships. More...
 
class  DiscoverStructure
 
class  DoBindTypeVariables
 
class  DoCheckConstants
 
class  DoCheckCoreMethods
 Check types for arguments of core.p4 methods. More...
 
class  DoConstantFolding
 statically evaluates many constant expressions. More...
 
class  DoConvertEnums
 
class  DoConvertErrors
 
class  DoCopyStructures
 
class  DoDefaultArguments
 
class  DoDefaultValues
 
class  DoEliminateInvalidHeaders
 
class  DoEliminateSerEnums
 
class  DoEliminateSwitch
 
class  DoExpandEmit
 
class  DoExpandLookahead
 
class  DoFlattenHeaderUnion
 
class  DoFlattenHeaderUnionStack
 
class  DoGlobalCopyPropagation
 
class  DoLocalCopyPropagation
 
class  DoMoveActionsToTables
 
class  DontcareArgs
 
class  DoOrderArguments
 
class  DoRemoveActionParameters
 
class  DoRemoveAssertAssume
 
class  DoRemoveExits
 
class  DoRemoveLeftSlices
 
class  DoRemoveMiss
 
class  DoRemoveParserControlFlow
 Converts if statements in parsers into transitions. More...
 
class  DoRemoveReturns
 
class  DoRemoveSelectBooleans
 
class  DoReplaceNewtype
 
class  DoReplaceTuples
 
class  DoReplaceTypedef
 
class  DoResetHeaders
 Explicitly invalidate uninitialized header variables. More...
 
class  DoSetHeaders
 
class  DoSimplifyComplexCondition
 Pass that tries to simplify the conditions to a simple comparison of constants. More...
 
class  DoSimplifyControlFlow
 Replace complex control flow nodes with simpler ones where possible. More...
 
class  DoSimplifyDefUse
 
class  DoSimplifyExpressions
 Convert expressions so that each expression contains at most one side effect. More...
 
class  DoSimplifyKey
 
class  DoSimplifyNestedIf
 
class  DoSimplifySelectCases
 
class  DoSimplifySwitch
 Simplify select and switch statements that have constant arguments. More...
 
class  DoSingleArgumentSelect
 
class  DoStaticAssert
 
class  DoStrengthReduction
 
class  DoSynthesizeActions
 
class  DoTableHit
 
class  DoTableKeyNames
 
struct  DpdkProgramStructure
 Collect information related to P4 programs targeting dpdk. More...
 
class  Dump
 
class  DuplicateActions
 
class  DynamicVisitor
 
class  EbpfOptions
 
struct  Egress_Model
 
class  ElimCallExprInIfCond
 Pass that eliminates call expressions in if statement’s condition. More...
 
class  EliminateInvalidHeaders
 
class  EliminateNewtype
 
class  EliminateSerEnums
 
class  EliminateSubparserCalls
 
class  EliminateSwitch
 
class  EliminateTuples
 
class  EliminateTypedef
 
class  EntryPriorities
 Assigns priorities to table entries if they are not 'const'. More...
 
class  EnumInstance
 
class  EnumOn32Bits
 
class  EnumRepresentation
 
class  EqualityConstraint
 Requires two types to be equal. More...
 
class  ErrorCatalog
 
struct  ErrorMessage
 
class  ErrorReporter
 
class  ErrorType
 
class  Evaluator
 
class  EvaluatorPass
 
class  ExpandEmit
 
class  ExpandLookahead
 
class  Explain
 Creates a string that describes the values of current type variables. More...
 
class  ExpressionEvaluator
 
class  exprUses
 
class  ExternCall
 
class  ExternConstructorCall
 
class  ExternFunction
 
struct  ExternInstance
 
class  ExternInstantiation
 
class  ExternMethod
 
class  FillEnumMap
 
class  FindActionParameters
 
class  FindFunctionSpecializations
 
class  FindGlobalActionUses
 
class  FindHeaderTypesToReplace
 
class  FindParameters
 Finds parameters for actions that will be given unique names. More...
 
class  FindRedundantParsers
 
class  FindRepeatedActionUses
 
class  FindSpecializations
 
class  FindSymbols
 
class  FindTypesInLogMsgInvocationToReplace
 
class  FindTypeSpecializations
 
class  FindTypesToReplace
 
class  FindVariableValues
 
struct  flat_map
 
class  FlattenHeaders
 
class  FlattenHeaderUnion
 
class  FlattenInterfaceStructs
 
class  FlattenLogMsg
 
class  FrontEnd
 
class  FrontEndPolicy
 
class  FunctionCall
 
class  FunctionsInliner
 
struct  FunctionSpecialization
 Describes how a generic function is specialized. More...
 
struct  FunctionSpecializationMap
 
class  GeneralInliner
 Performs actual inlining work. More...
 
class  GlobalActionReplacements
 
class  GlobalCopyPropagation
 
struct  HalfOpenRange
 
class  HandleNoMatch
 
class  HandleValidityHeaderUnion
 
struct  has_dbprint
 
struct  has_dbprint< T, std::void_t< decltype(std::declval< T >().dbprint(std::declval< std::ostream & >()))> >
 
struct  has_ostream_operator
 
struct  has_ostream_operator< T, std::void_t< decltype(std::declval< std::ostream & >()<< std::declval< T >())> >
 
class  HasExits
 
class  hash_vector_base
 
class  hasSideEffects
 
class  HasTableApply
 Checks to see whether an IR node includes a table.apply() sub-expression. More...
 
struct  hdrFieldInfo
 
class  HeaderTypeMaxLengthCalculator
 
class  hex
 
class  hexvec
 
class  HierarchicalNames
 
class  HSIndexContretizer
 
class  HSIndexFinder
 
class  HSIndexSimplifier
 
class  HSIndexTransform
 This class substitutes index of a header stack in all occurences of found header stack. More...
 
class  hvec_map
 
class  hvec_set
 
class  ICastable
 
class  ICompileContext
 
class  IfInParser
 Detect whether the program contains an 'if' statement in a parser. More...
 
class  IHasBlock
 
class  IHasDbPrint
 
class  indent_t
 
class  IndexedLocation
 Interface for locations that support an index operation. More...
 
struct  Ingress_Model
 
struct  IngressInMetadataType_Model
 
class  Inline
 
class  InlineActions
 
class  InlineControlFlow
 
class  InlineDriver
 
class  InlineFunctions
 
class  InlineList
 
class  InlinePass
 Performs one round of inlining bottoms-up. More...
 
struct  InlineSummary
 Summarizes all inline operations to be performed. More...
 
class  InspectDpdkProgram
 
class  Inspector
 
class  InspectPortableProgram
 
class  InspectPsaProgram
 
class  InstanceBase
 
class  InstantiateDirectCalls
 
class  Instantiation
 Used to resolve a Declaration_Instance. More...
 
class  IOptionPragmaParser
 
class  IsLikeLeftValue
 
class  IsMask
 
class  IsNonConstantArrayIndex
 
class  IsValid
 
class  IterKeys
 
class  IterValues
 
class  JsonBoolean
 
class  JsonData
 
class  JSONGenerator
 
class  JSONLoader
 
class  JsonNull
 
class  JsonNumber
 
class  JsonObject
 
class  JsonString
 
class  JsonVector
 
class  KeyIsSimple
 
class  KeyNameGenerator
 
class  KeySideEffect
 
struct  loc_t
 
class  LocalCopyPropagation
 
class  LocalizeActions
 
class  LocalizeAllActions
 
struct  LocationPath
 
class  LocationSet
 
struct  LogAbbrev
 
class  LTBitMatrix
 
class  MapForKey
 
struct  MarshaledFrom
 
struct  match_t
 
class  MatchRegister
 
class  MethodInstance
 
class  MidEndLast
 
class  MinimalNameGenerator
 
class  MissingIdAssigner
 
class  Modifier
 
class  MoveActionsToTables
 
class  MoveConstructors
 
class  MoveDeclarations
 
class  MoveInitializers
 
class  MoveToElseAfterBranch
 
class  n4
 
class  NameGateways
 
class  NameGenerator
 
struct  NestedStructMap
 
class  NestedStructs
 
class  OnBacktrack
 
class  onullstream
 
class  OrderArguments
 
class  ordered_map
 
class  ordered_set
 
class  OrPolicy
 
class  P4CConfiguration
 
class  P4CContext
 
class  P4CContextWithOptions
 
class  P4COptionPragmaParser
 
class  P4CoreLibrary
 
class  P4Exception_Model
 
class  P4ParserDriver
 A ParserDriver that can parse P4-16 programs. More...
 
struct  P4RuntimeAPI
 
class  P4RuntimeSerializer
 Public APIs to generate P4Info message. Uses the singleton pattern. More...
 
class  P4WriteContext
 
class  PackageInstantiation
 
class  PacketIn
 
class  PacketOut
 
class  ParameterSubstitution
 
class  ParseAnnotationBodies
 Clears a type map after calling a ParseAnnotations instance. More...
 
class  ParseAnnotations
 
class  ParseDpdkArchitecture
 
class  ParsePortableArchitecture
 
class  ParsePsaArchitecture
 
struct  ParserErrorMessage
 
class  ParserInfo
 Information produced for a parser by the symbolic evaluator. More...
 
class  ParserInstantiation
 
class  ParserOptions
 
class  ParserRewriter
 
struct  ParserStateInfo
 Information produced for a parser state by the symbolic evaluator. More...
 
class  ParserStructure
 Information about a parser in the input program. More...
 
class  ParsersUnroll
 
class  PassIf
 
class  PassManager
 
class  PassRepeated
 
class  PassRepeatUntil
 
class  Pattern
 
class  PauseTrace
 
struct  PerInstanceSubstitutions
 
class  PortableProgramStructure
 
class  Predication
 
struct  primitive_info_t
 
class  ProcessDeparser
 
class  ProgramMap
 
class  ProgramPoint
 Indicates a statement in the program. More...
 
class  ProgramPoints
 
class  ProgramStructure
 
class  PsaProgramStructure
 
struct  PushContext
 
class  RangeIter
 
class  ReadOnlyTypeInference
 
class  ReadsWrites
 Computes the SetOfLocations read and written by an expression. More...
 
class  Reassociation
 
class  ReferenceMap
 Class used to encode maps from paths to declarations. More...
 
class  RemoveActionParameters
 
class  RemoveAliases
 
class  RemoveAllUnusedDeclarations
 Iterates RemoveUnusedDeclarations until convergence. More...
 
class  RemoveAllUnusedHUDDeclarations
 
class  RemoveAssertAssume
 
class  RemoveBreakContinue
 
class  RemoveComplexComparisons
 
class  RemoveComplexExpressions
 
class  RemoveComplexExpressionsPolicy
 
class  RemoveDontcareArgs
 
class  RemoveExits
 
class  RemoveGenericTypes
 Removes all structs or stacks that are generic. More...
 
class  RemoveHidden
 
class  RemoveLeftSlices
 
class  RemoveMiss
 
class  RemoveModifiedValues
 
class  RemoveNestedStructs
 
class  RemoveParserControlFlow
 
class  RemoveParserIfs
 
class  RemoveRedundantParsers
 
class  RemoveReturns
 
class  RemoveSelectBooleans
 
class  RemoveUnusedActionParameters
 
class  RemoveUnusedDeclarations
 Removes unused declarations. More...
 
class  RemoveUnusedHUDeclarations
 
class  RemoveUnusedPolicy
 
class  RemoveUselessCasts
 
class  RenameMap
 
class  RenameSymbols
 
class  ReplaceHeaders
 
class  ReplaceIndexRefs
 
class  ReplaceLogMsg
 
class  ReplacementMap
 
class  ReplaceSelectRange
 
class  ReplaceStructs
 
class  ReplaceTypeUses
 
class  ResetHeaders
 Invokes TypeChecking followed by DoResetHeaders. More...
 
class  ResolutionContext
 Visitor mixin for looking up names in enclosing scopes from the Visitor::Context. More...
 
class  ResolveReferences
 
class  RewriteAllParsers
 
class  safe_vector
 
class  SameExpression
 
class  SaturationElim
 Contains utility functions for eliminating saturating arithmetic. More...
 
class  ScalarValue
 
class  SerEnumInstance
 
class  SetHeaders
 
class  SetOfLocations
 
class  SideEffectOrdering
 
class  SideEffects
 Determines whether an expression may have method or constructor invocations. More...
 
class  SimpleCallInfo
 
class  SimpleEnumInstance
 An instance of a simple enum, e.g., X.A from enum X { A, B }. More...
 
class  SimpleInlineList
 
class  SimpleInlineWorkList
 
class  SimplifyBitwise
 
class  SimplifyComparisons
 
class  SimplifyComplexConditionPolicy
 
class  SimplifyControlFlow
 
class  SimplifyDefUse
 
class  SimplifyIfStatement
 Top level PassManager that governs simplification of if statements. More...
 
class  SimplifyKey
 
class  SimplifyNestedIf
 Top level PassManager that governs simplification of nested if statements in the deparser control block. More...
 
class  SimplifyParsers
 Remove unreachable parser states, and collapse simple chains of states. More...
 
class  SimplifySelectCases
 
class  SimplifySelectList
 
class  SimplifySwitch
 
class  SingleArgumentSelect
 
class  SkipControlPolicy
 
struct  SpecializationInfo
 Describes how a parser or control is specialized. More...
 
class  SpecializationMap
 Maintains a map from invocation to a SpecializationInfo object. More...
 
class  Specialize
 Specializes each Parser and Control with constant constructor arguments by substituting type arguments and constructor parameters. More...
 
class  SpecializeAll
 Specializes each Parser and Control by substituting type arguments and constructor parameters. More...
 
class  SpecializeFunctions
 Specializes each generic function by substituting type parameters. More...
 
class  SpecializeGenericFunctions
 
class  SpecializeGenericTypes
 Specializes each generic type by substituting type parameters. More...
 
class  SplitFlowVisit
 
class  SplitFlowVisit_base
 
class  SplitFlowVisitVector
 
class  StackVariable
 
class  StackVariableHash
 Class with hash function for StackVariable. More...
 
class  StaticAssert
 
class  StorageFactory
 
class  StorageLocation
 Abstraction for something that is has a left value (variable, parameter) More...
 
class  StorageMap
 Maps a declaration to its associated storage. More...
 
class  StrengthReduction
 
class  string_map
 
struct  StringRef
 
class  StructInitializers
 
class  StructLocation
 
struct  StructTypeReplacement
 
class  SubstituteParameters
 
class  SubstituteStructures
 
class  SwitchAddDefault
 
class  SymBitMatrix
 
class  SymbolicArray
 
class  SymbolicBool
 
class  SymbolicEnum
 
class  SymbolicError
 
class  SymbolicException
 
class  SymbolicExtern
 
class  SymbolicHeader
 
class  SymbolicHeaderUnion
 
class  SymbolicInteger
 
class  SymbolicPacketIn
 
class  SymbolicStaticError
 
class  SymbolicString
 
class  SymbolicStruct
 
class  SymbolicTuple
 
class  SymbolicValue
 
class  SymbolicValueFactory
 
class  SymbolicVarbit
 
class  SymbolicVoid
 
class  SymRenameMap
 
class  SynthesizeActions
 
class  TableApplySolver
 
class  TableHit
 
class  TableInsertions
 
class  TableKeyNames
 
class  TablesInActions
 
class  TablesInKeys
 
class  TagGlobalActions
 
class  TofinoModel
 
class  ToP4
 
class  Transform
 
class  TupleLocation
 
class  TypeCheck
 
class  TypeChecking
 
class  TypeConstraint
 
class  TypeConstraints
 
class  TypeInference
 
class  TypeInferenceBase
 
class  TypeMap
 
class  TypeOccursVisitor
 
struct  TypeSpecialization
 
struct  TypeSpecializationMap
 
class  TypeSubstitution
 
class  TypeSubstitutionVisitor
 
class  TypeUnification
 
class  TypeVariableSubstitution
 
class  TypeVariableSubstitutionVisitor
 
class  UniqueAndValidDest
 
class  UniqueAttachedId
 
class  UniqueId
 
class  UniqueNames
 
class  UniqueParameters
 
class  UnnestSelectList
 
struct  UnparsedConstant
 
class  UnrollLoops
 
class  UsedDeclSet
 
class  UselessCasts
 
class  ValidateMatchAnnotations
 
class  ValidateParsedProgram
 
class  ValidateStringAnnotations
 
class  ValidateTableProperties
 
class  ValidateValueSets
 
class  ValueMap
 
struct  VisitedKey
 The main class for parsers' states key for visited checking. More...
 
class  VisitFunctor
 
class  Visitor
 
struct  Visitor_Context
 
class  WithFieldsLocation
 Base class for location sets that contain fields. More...
 

Typedefs

using ActionCallInfo = SimpleCallInfo<IR::P4Action, IR::MethodCallStatement>
 
using ActionsInlineList = SimpleInlineList<IR::P4Action, ActionCallInfo, AInlineWorkList>
 
using AInlineWorkList = SimpleInlineWorkList<ActionCallInfo>
 
using big_int = boost::multiprecision::cpp_int
 
using Constraint = IR::Expression
 Represents a constraint that can be shipped to and asserted within a solver.
 
typedef std::function< void(const char *manager, unsigned seqNo, const char *pass, const IR::Node *node)> DebugHook
 
using EbpfContext = P4CContextWithOptions<EbpfOptions>
 
using FunctionCallInfo = SimpleCallInfo<IR::Node, IR::Statement>
 
using FunctionsInlineList = SimpleInlineList<IR::Node, FunctionCallInfo, FunctionsInlineWorkList>
 
using FunctionsInlineWorkList = SimpleInlineWorkList<FunctionCallInfo>
 
using GeneratedVariablesMap = std::map<cstring, const IR::PathExpression *>
 
typedef InlineDriver< ActionsInlineList, AInlineWorkListInlineActionsDriver
 
typedef InlineDriver< FunctionsInlineList, FunctionsInlineWorkListInlineFunctionsDriver
 
using le_bitinterval = HalfOpenRange<RangeUnit::Bit, Endian::Little>
 
using le_bitrange = ClosedRange<RangeUnit::Bit, Endian::Little>
 
using le_byteinterval = HalfOpenRange<RangeUnit::Byte, Endian::Little>
 
using le_byterange = ClosedRange<RangeUnit::Byte, Endian::Little>
 
using MessageType = ErrorMessage::MessageType
 
typedef onullstream< char > nullstream
 
using nw_bitinterval = HalfOpenRange<RangeUnit::Bit, Endian::Network>
 Convenience typedefs for half-open ranges in bits.
 
using nw_bitrange = ClosedRange<RangeUnit::Bit, Endian::Network>
 Convenience typedefs for closed ranges in bits.
 
using nw_byteinterval = HalfOpenRange<RangeUnit::Byte, Endian::Network>
 Convenience typedefs for half-open ranges in bytes.
 
using nw_byterange = ClosedRange<RangeUnit::Byte, Endian::Network>
 Convenience typedefs for closed ranges in bytes.
 
typedef CallGraph< const IR::ParserState * > ParserCallGraph
 
using ResourceMap = ordered_map<const IR::Node *, const IR::CompileTimeValue *>
 
typedef std::unordered_map< StackVariable, const IR::Expression *, StackVariableHashStackVariableIndexMap
 
typedef std::unordered_map< StackVariable, size_t, StackVariableHashStackVariableMap
 
typedef CallGraph< const IR::ParserState * > StateCallGraph
 
using SymbolicMapping
 This type maps symbolic variables to their value assigned by the solver.
 
using TypeLogMsgParams = std::pair<IR::IndexedVector<IR::NamedExpression>, std::string>
 

Enumerations

enum  block_t { PARSER , PIPELINE , DEPARSER }
 
enum class  DiagnosticAction { Ignore , Info , Warn , Error }
 An action to take when a diagnostic message is triggered. More...
 
enum class  Endian : uint8_t { Network = 0 , Little = 1 }
 An ordering for bits or bytes. More...
 
enum  InternalTableType { REGULAR_EXACT , LEARNER , WILDCARD }
 
enum class  P4RuntimeFormat { BINARY , JSON , TEXT , TEXT_PROTOBUF }
 P4Runtime serialization formats.
 
enum  psa_gress_t { INGRESS , EGRESS }
 
enum class  RangeUnit : uint8_t { Bit = 0 , Byte = 1 }
 Units in which a range can be specified.
 
enum class  ResolutionType { Any , Type , TypeVariable }
 Helper class to indicate types of nodes that may be returned during resolution.
 
enum class  StandardExceptions {
  NoError , PacketTooShort , NoMatch , StackOutOfBounds ,
  HeaderTooShort , ParserTimeout
}
 
enum class  TernaryBool { Yes , No , Maybe }
 
enum class  VisitStatus : unsigned { New , Revisit , Busy , Done }
 
enum  XDP2TC { XDP2TC_NONE , XDP2TC_META , XDP2TC_HEAD , XDP2TC_CPUMAP }
 

Functions

void add_comment (std::ostream &out, cstring str, std::string_view sep="")
 
void add_space (std::ostream &out, int size)
 
const char * addr2line (void *addr, const char *text)
 
void backtrace_fill_stacktrace (std::string &msg, void *const *backtrace, int size)
 
template<class Iter >
Iter begin (std::pair< Iter, Iter > pr)
 
template<class... Args>
std::string bug_helper (boost::format &f, std::string_view position, std::string_view tail, Args &&...args)
 
cstring cgMakeString (char c)
 
cstring cgMakeString (const IR::INode *node)
 
cstring cgMakeString (const IR::Node *node)
 
cstring cgMakeString (cstring s)
 
void checkParametersForMap (const IR::ParameterList *params, std::map< cstring, const IR::Expression * > *vars)
 
void compareValuesInMaps (std::map< cstring, const IR::Expression * > *oldValues, std::map< cstring, const IR::Expression * > *newValues)
 
template<class C , class T >
bool contains (C &c, const T &val)
 
template<class T , class C1 , class A1 , class U >
auto contains (const ordered_set< T, C1, A1 > &a, const U &b) -> decltype(b.begin(), true)
 
template<class T , class C1 , class A1 , class U >
auto contains (std::set< T, C1, A1 > &a, U &b) -> decltype(b.begin(), true)
 
template<class C , class Pred >
bool contains_if (C &c, Pred pred)
 
const IR::Expression * convert (const IR::Expression *expression, const IR::Type *type)
 
void dbprint (const IHasDbPrint *o)
 
void dbprint (const IR::Node &n)
 
void dbprint (const IR::Node *n)
 
void dbprint (const std::set< const IR::Expression * > s)
 
unsigned diagnosticCount ()
 
void dump (const big_int &i)
 
void dump (const big_int *i)
 
void dump (const ControlFlowVisitor::flow_join_info_t &info)
 
void dump (const ControlFlowVisitor::flow_join_info_t *info)
 
void dump (const ControlFlowVisitor::flow_join_points_t &fjp)
 
void dump (const ControlFlowVisitor::flow_join_points_t *fjp)
 
void dump (const hvec_set< const P4::ComputeDefUse::loc_t * > &p)
 
void dump (const IR::INode *n)
 
void dump (const IR::INode *n, unsigned maxdepth)
 
void dump (const IR::Node *n)
 
void dump (const IR::Node *n, unsigned maxdepth)
 
void dump (const match_t &m)
 
void dump (const match_t *m)
 
void dump (const P4::AllDefinitions *d)
 
void dump (const P4::ComputeDefUse &du)
 
void dump (const P4::ComputeDefUse *du)
 
void dump (const P4::ComputeDefUse::loc_t &p)
 
void dump (const P4::Definitions *d)
 
void dump (const P4::LocationSet *s)
 
void dump (const P4::ProgramPoint &p)
 
void dump (const P4::ProgramPoint *p)
 
void dump (const P4::ProgramPoints &p)
 
void dump (const P4::ProgramPoints *p)
 
void dump (const P4::StorageLocation *s)
 
void dump (const P4::StorageMap *s)
 
void dump (const SplitFlowVisit_base *split)
 
void dump (const Visitor::Context *ctxt)
 
void dump (P4::TypeVariableSubstitution &tvs)
 
void dump (P4::TypeVariableSubstitution *tvs)
 
void dump (std::ostream &out, const IR::Node *n)
 
void dump (std::ostream &out, const IR::Node *n, unsigned maxdepth)
 
void dump (std::ostream &out, const Visitor::Context *ctxt)
 
void dump (uintptr_t p)
 
void dump (uintptr_t p, unsigned maxdepth)
 
void dump_notype (const IR::INode *n)
 
void dump_notype (const IR::INode *n, unsigned maxdepth)
 
void dump_notype (const IR::Node *n)
 
void dump_notype (const IR::Node *n, unsigned maxdepth)
 
void dump_notype (uintptr_t p)
 
void dump_notype (uintptr_t p, unsigned maxdepth)
 
void dump_src (const IR::INode *n)
 
void dump_src (const IR::INode *n, unsigned maxdepth)
 
void dump_src (const IR::Node *n)
 
void dump_src (const IR::Node *n, unsigned maxdepth)
 
void dumpP4 (const IR::INode *node)
 
std::string dumpToString (const IR::Node *n)
 
template<class Iter >
Iter end (std::pair< Iter, Iter > pr)
 
template<class C , class Pred >
void erase_if (C &c, Pred pred)
 
template<typename... Args>
void error (const char *format, Args &&...args)
 Report an error with the given message.
 
template<class T , typename = std::enable_if_t<Util::has_SourceInfo_v<T> && !std::is_pointer_v<T>>, class... Args>
void error (const char *format, const T &node, Args &&...args)
 The const ref variant of the above.
 
template<class T , typename = std::enable_if_t<Util::has_SourceInfo_v<T>>, class... Args>
void error (const char *format, const T *node, Args &&...args)
 
template<typename... Args>
void error (const int kind, const char *format, Args &&...args)
 
template<class T , typename = std::enable_if_t<Util::has_SourceInfo_v<T> && !std::is_pointer_v<T>>, class... Args>
void error (const int kind, const char *format, const T &node, Args &&...args)
 The const ref variant of the above.
 
template<class T , typename = std::enable_if_t<Util::has_SourceInfo_v<T>>, class... Args>
void error (const int kind, const char *format, const T *node, Args &&...args)
 
template<class... Args>
ErrorMessage error_helper (boost::format &f, Args &&...args)
 
template<class... Args>
ErrorMessage error_helper (boost::format &f, const std::string &prefix, const Util::SourceInfo &info, const std::string &suffix, Args &&...args)
 
template<class... Args>
ErrorMessage error_helper (boost::format &f, ErrorMessage msg, Args &&...args)
 
unsigned errorCount ()
 
template<class T , typename = std::enable_if_t<Util::has_SourceInfo_v<T>>, class... Args>
void errorWithSuffix (const int kind, const char *format, const char *suffix, const T *node, Args &&...args)
 This is similar to the above method, but also has a suffix.
 
const char * exename (const char *argv0)
 
template<class C , class T >
C::iterator find (C &c, const T &val)
 
template<class Iter , class Fn >
Fn for_each (std::pair< Iter, Iter > range, Fn fn)
 
template<typename NodeType , typename Func >
void forAllMatching (const IR::Node *root, Func &&function)
 
template<class Cont >
std::ostream & format_container (std::ostream &out, const Cont &container, char lbrace, char rbrace)
 
P4RuntimeAPI generateP4Runtime (const IR::P4Program *program, cstring arch)
 
template<class K , class T , class V , class Comp , class Alloc >
get (const hvec_map< K, V, Comp, Alloc > &m, T key, V def=V())
 
template<class K , class T , class V , class Comp , class Alloc >
get (const hvec_map< K, V, Comp, Alloc > *m, T key, V def=V())
 
template<typename Map , typename Key >
Map::mapped_type get (const Map &m, const Key &key)
 
template<class Map , typename Key , typename Value >
Map::mapped_type get (const Map &m, const Key &key, Value &&def)
 
template<typename Map , typename Key >
Map::mapped_type get (const Map *m, const Key &key)
 
template<class Map , typename Key , typename Value >
Map::mapped_type get (const Map *m, const Key &key, Value &&def)
 
template<class Map , typename Key >
std::optional< typename Map::mapped_type > get_optional (const Map &m, const Key &key)
 
const IR::Expression * getConstant (const ScalarValue *constant)
 
DebugHook getDiagnosticCountInPassHook (BaseCompileContext &ctxt=BaseCompileContext::get())
 This creates a debug hook that prints information about the number of diagnostics of different levels (error, warning, info) printed by each of the pass after it ended. This is intended to help in debuggig and testing.
 
std::string getIndent (int l)
 
template<class K , class T , class V , class Comp , class Alloc >
const V * getref (const hvec_map< K, V, Comp, Alloc > &m, T key)
 
template<class K , class T , class V , class Comp , class Alloc >
const V * getref (const hvec_map< K, V, Comp, Alloc > *m, T key)
 
template<typename Map , typename Key >
const Map::mapped_type * getref (const Map &m, const Key &key)
 
template<typename Map , typename Key >
const Map::mapped_type * getref (const Map *m, const Key &key)
 
template<class K , class T , class V , class Comp , class Alloc >
V * getref (hvec_map< K, V, Comp, Alloc > &m, T key)
 
template<class K , class T , class V , class Comp , class Alloc >
V * getref (hvec_map< K, V, Comp, Alloc > *m, T key)
 
template<typename Map , typename Key >
Map::mapped_type * getref (Map &m, const Key &key)
 
template<typename Map , typename Key >
Map::mapped_type * getref (Map *m, const Key &key)
 
bool hasVarbitsOrUnions (const TypeMap *typeMap, const IR::Type *type)
 True if the type contains any varbit or header_union subtypes.
 
template<typename... Args>
void info (const int kind, const char *format, Args &&...args)
 
template<class T , typename = std::enable_if_t<Util::has_SourceInfo_v<T> && !std::is_pointer_v<T>>, class... Args>
void info (const int kind, const char *format, const T &node, Args &&...args)
 The const ref variant of the above.
 
template<class T , typename = std::enable_if_t<Util::has_SourceInfo_v<T>>, class... Args>
void info (const int kind, const char *format, const T *node, Args &&...args)
 Report info messages of type kind. Requires that the node argument have source info.
 
template<class T , class C1 , class A1 , class U >
auto intersects (const ordered_set< T, C1, A1 > &a, const U &b) -> decltype(b.begin(), true)
 
template<class T , class C1 , class A1 , class U >
auto intersects (std::set< T, C1, A1 > &a, U &b) -> decltype(b.begin(), true)
 
bool isAsync (const IR::Vector< IR::Method > methods, cstring callee, cstring caller)
 
bool isReachable (cstring stateName, const IR::IndexedVector< IR::ParserState > &states)
 
bool isSystemFile (cstring filename)
 Try to guess whether a file is a "system" file.
 
bool isTerminalState (IR::ID id)
 
template<class Map >
IterKeys< typename Map::const_iterator > Keys (const Map &m)
 
template<class Map >
IterKeys< typename Map::iterator > Keys (Map &m)
 
template<class PairIter >
IterKeys< PairIter > Keys (std::pair< PairIter, PairIter > range)
 
template<class C >
C::const_iterator max_element (const C &c)
 
template<class C , class Compare >
C::const_iterator max_element (const C &c, Compare comp)
 
template<class C >
C::const_iterator min_element (const C &c)
 
template<class C , class Compare >
C::const_iterator min_element (const C &c, Compare comp)
 
template<typename NodeType , typename RootType , typename Func >
const RootType * modifyAllMatching (const RootType *root, Func &&function)
 
bool names_overlap (cstring name1, cstring name2)
 Test to see if names denote overlapping locations.
 
std::ostream * openFile (const std::filesystem::path &name, bool nullOnError)
 
bool operator!= (const char *a, cstring b)
 
bool operator!= (const std::string &a, cstring b)
 
Pattern operator!= (int v, const Pattern &a)
 
template<class T >
auto operator!= (T a, const StringRef &b) -> decltype(b.operator!=(a))
 
Pattern operator% (int v, const Pattern &a)
 
bitvec operator& (bitvec &&a, const bitvec &b)
 
Pattern operator& (int v, const Pattern &a)
 
Pattern operator&& (int v, const Pattern &a)
 
template<class T , class C1 , class A1 , class U >
auto operator&= (ordered_set< T, C1, A1 > &a, const U &b) -> decltype(b.begin(), a)
 
template<class T , class C1 , class A1 , class U >
auto operator&= (std::set< T, C1, A1 > &a, U &b) -> decltype(b.begin(), a)
 
Pattern operator* (int v, const Pattern &a)
 
std::string operator+ (char a, cstring b)
 
std::string operator+ (const char *a, cstring b)
 
std::string operator+ (const char *s, const StringRef &a)
 
std::string operator+ (const std::string &s, const StringRef &a)
 
std::string operator+ (const StringRef &s, const char *a)
 
std::string operator+ (const StringRef &s, const std::string &a)
 
std::string operator+ (const StringRef &s, const StringRef &a)
 
std::string operator+ (const StringRef &s, cstring a)
 
std::string operator+ (cstring a, char b)
 
std::string operator+ (cstring a, const char *b)
 
std::string operator+ (cstring a, const std::string &b)
 
std::string operator+ (cstring a, cstring b)
 
std::string operator+ (cstring s, const StringRef &a)
 
Pattern operator+ (int v, const Pattern &a)
 
std::string operator+ (std::string a, cstring b)
 
std::string & operator+= (std::string &a, cstring b)
 
std::string & operator+= (std::string &s, const StringRef &a)
 
bitvec operator- (bitvec &&a, const bitvec &b)
 
template<RangeUnit Unit, Endian Order>
std::pair< HalfOpenRange< Unit, Order >, HalfOpenRange< Unit, Order > > operator- (ClosedRange< Unit, Order > left, ClosedRange< Unit, Order > right)
 
template<RangeUnit Unit, Endian Order>
std::pair< HalfOpenRange< Unit, Order >, HalfOpenRange< Unit, Order > > operator- (HalfOpenRange< Unit, Order > left, HalfOpenRange< Unit, Order > right)
 
Pattern operator- (int v, const Pattern &a)
 
template<class T , class C1 , class A1 , class U >
auto operator-= (ordered_set< T, C1, A1 > &a, const U &b) -> decltype(b.begin(), a)
 
template<class T , class C1 , class A1 , class U >
auto operator-= (std::set< T, C1, A1 > &a, U &b) -> decltype(b.begin(), a)
 
Pattern operator/ (int v, const Pattern &a)
 
bool operator< (const UnparsedConstant &a, const UnparsedConstant &b)
 
Pattern operator< (int v, const Pattern &a)
 
template<class T >
auto operator< (T a, const StringRef &b) -> decltype(b.operator>(a))
 
Pattern operator<< (int v, const Pattern &a)
 
JSONGeneratoroperator<< (P4::JSONGenerator &out, const MarshaledFrom &c)
 
std::ostream & operator<< (std::ostream &os, const bitvec &bv)
 
std::ostream & operator<< (std::ostream &os, const hex &h)
 
std::ostream & operator<< (std::ostream &os, const hexvec &h)
 
std::ostream & operator<< (std::ostream &os, const StringRef &a)
 
std::ostream & operator<< (std::ostream &os, indent_t i)
 
std::ostream & operator<< (std::ostream &os, n4 v)
 
std::ostream & operator<< (std::ostream &out, const AllocTrace &at)
 
std::ostream & operator<< (std::ostream &out, const Backtrack::trigger &trigger)
 
template<RangeUnit Unit, Endian Order>
std::ostream & operator<< (std::ostream &out, const ClosedRange< Unit, Order > &range)
 
std::ostream & operator<< (std::ostream &out, const ComputeDefUse::defuse_t &du)
 
std::ostream & operator<< (std::ostream &out, const ComputeDefUse::loc_t &loc)
 
std::ostream & operator<< (std::ostream &out, const ControlFlowVisitor::flow_join_info_t &info)
 
std::ostream & operator<< (std::ostream &out, const ControlFlowVisitor::flow_join_points_t &fjp)
 
std::ostream & operator<< (std::ostream &out, const Dump &d)
 
template<RangeUnit Unit, Endian Order>
std::ostream & operator<< (std::ostream &out, const HalfOpenRange< Unit, Order > &range)
 
std::ostream & operator<< (std::ostream &out, const hvec_set< const ComputeDefUse::loc_t * > &s)
 
std::ostream & operator<< (std::ostream &out, const IHasDbPrint &obj)
 
std::ostream & operator<< (std::ostream &out, const IHasDbPrint *obj)
 
std::ostream & operator<< (std::ostream &out, const IR::Vector< IR::Expression > &v)
 
std::ostream & operator<< (std::ostream &out, const IR::Vector< IR::Expression > *v)
 
std::ostream & operator<< (std::ostream &out, const LTBitMatrix &bm)
 
std::ostream & operator<< (std::ostream &out, const match_t &m)
 
std::ostream & operator<< (std::ostream &out, const MatchRegister &c)
 
template<typename T >
std::ostream & operator<< (std::ostream &out, const ordered_set< T > &set)
 
template<class T >
std::ostream & operator<< (std::ostream &out, const RangeIter< T > &r)
 
std::ostream & operator<< (std::ostream &out, const SplitFlowVisit_base &split)
 
std::ostream & operator<< (std::ostream &out, const std::pair< const IR::Node *, const hvec_set< const ComputeDefUse::loc_t * > > &p)
 
std::ostream & operator<< (std::ostream &out, const std::pair< const P4::IR::Expression *, cstring > &p)
 
template<class T >
std::ostream & operator<< (std::ostream &out, const std::set< T > &set)
 
template<class T >
std::ostream & operator<< (std::ostream &out, const std::vector< T > &vec)
 
std::ostream & operator<< (std::ostream &out, const UniqueAttachedId &uai)
 
std::ostream & operator<< (std::ostream &out, const UniqueAttachedId::type_t type)
 
std::ostream & operator<< (std::ostream &out, const UniqueId &ui)
 
std::ostream & operator<< (std::ostream &out, const UnparsedConstant &constant)
 
std::ostream & operator<< (std::ostream &out, cstring s)
 
std::ostream & operator<< (std::ostream &out, JsonData *json)
 
std::ostream & operator<< (std::ostream &out, P4::StandardExceptions e)
 
std::ostream & operator<< (std::ostream &s, const MarshaledFrom &m)
 
Pattern operator<= (int v, const Pattern &a)
 
template<class T >
auto operator<= (T a, const StringRef &b) -> decltype(b.operator>=(a))
 
bool operator== (const char *a, cstring b)
 
bool operator== (const std::string &a, cstring b)
 
Pattern operator== (int v, const Pattern &a)
 
template<class T >
auto operator== (T a, const StringRef &b) -> decltype(b.operator==(a))
 
Pattern operator> (int v, const Pattern &a)
 
template<class T >
auto operator> (T a, const StringRef &b) -> decltype(b.operator<(a))
 
Pattern operator>= (int v, const Pattern &a)
 
template<class T >
auto operator>= (T a, const StringRef &b) -> decltype(b.operator<=(a))
 
bool operator>> (const char *p, LTBitMatrix &bm)
 
bool operator>> (const char *p, match_t &m)
 
bool operator>> (const char *s, bitvec &bv)
 
bool operator>> (cstring s, UniqueAttachedId::type_t &type)
 
Pattern operator>> (int v, const Pattern &a)
 
std::istream & operator>> (std::istream &in, JsonData *&json)
 
std::istream & operator>> (std::istream &is, bitvec &bv)
 
bitvec operator^ (bitvec &&a, const bitvec &b)
 
Pattern operator^ (int v, const Pattern &a)
 
bitvec operator| (bitvec &&a, const bitvec &b)
 
Pattern operator| (int v, const Pattern &a)
 
template<class T , class C1 , class A1 , class U >
auto operator|= (ordered_set< T, C1, A1 > &a, const U &b) -> decltype(b.begin(), a)
 
template<class T , class C1 , class A1 , class U >
auto operator|= (std::set< T, C1, A1 > &a, U &b) -> decltype(b.begin(), a)
 
Pattern operator|| (int v, const Pattern &a)
 
const IR::Expression * optimizeExpression (const IR::Expression *node)
 
IR::Constant * parseConstant (const Util::SourceInfo &srcInfo, const UnparsedConstant &constant, long defaultValue)
 
int parseConstantChecked (const Util::SourceInfo &srcInfo, const UnparsedConstant &constant)
 
template<typename C = P4V1::Converter>
const IR::P4Program * parseP4File (const ParserOptions &options)
 
const IR::P4Program * parseP4String (const char *sourceFile, unsigned sourceLine, const std::string &input, CompilerOptions::FrontendVersion version)
 
const IR::P4Program * parseP4String (const std::string &input, CompilerOptions::FrontendVersion version)
 
template<class C , class Pred >
void remove_if (C &c, Pred pred)
 
void removeVarsContaining (std::map< cstring, const IR::Expression * > *vars, cstring name)
 
void serializeP4RuntimeIfRequired (const IR::P4Program *program, const CompilerOptions &options)
 
void setup_signals ()
 
template<typename K , typename V , typename C , typename Cont >
void swap (flat_map< K, V, C, Cont > &lhs, flat_map< K, V, C, Cont > &rhs)
 
template<RangeUnit Unit, Endian Order>
std::optional< ClosedRange< Unit, Order > > toClosedRange (HalfOpenRange< Unit, Order > halfOpenRange)
 
template<RangeUnit Unit, Endian Order>
HalfOpenRange< Unit, Order > toHalfOpenRange (ClosedRange< Unit, Order > closedRange)
 
std::string toP4 (const IR::INode *node)
 
std::ostream & toStream (std::ostream &out, RangeUnit unit, Endian order, int lo, int hi, bool closed)
 
cstring toString (const TernaryBool &c)
 
template<typename NodeType , typename Func >
const IR::NodetransformAllMatching (const IR::Node *root, Func &&function)
 
template<typename... Args>
void typeError (const char *format, Args &&...args)
 
UnparsedConstant unparsedConstant (const IR::AnnotationToken *token)
 
template<class Map >
IterValues< typename Map::const_iterator > Values (const Map &m)
 
template<class Map >
IterValues< typename Map::iterator > Values (Map &m)
 
template<class PairIter >
IterValues< PairIter > Values (std::pair< PairIter, PairIter > range)
 
template<class M >
MapForKey< M > ValuesForKey (M &m, typename M::key_type k)
 
template<typename... Args>
void warning (const char *format, Args &&...args)
 Report a warning with the given message.
 
template<typename... Args>
void warning (const int kind, const char *format, Args &&...args)
 
template<class T , typename = std::enable_if_t<Util::has_SourceInfo_v<T> && !std::is_pointer_v<T>>, class... Args>
void warning (const int kind, const char *format, const T &node, Args &&...args)
 The const ref variant of the above.
 
template<class T , typename = std::enable_if_t<Util::has_SourceInfo_v<T>>, class... Args>
void warning (const int kind, const char *format, const T *node, Args &&...args)
 Report warnings of type kind. Requires that the node argument have source info.
 

Variables

const unsigned action_handle_prefix = 0x00020000
 
const cstring bfrtSchemaVersion = cstring::literal("1.0.0")
 JSON schema versions.
 
const unsigned default_learner_table_size = 0x10000
 
const unsigned default_learner_table_timeout [dpdk_learner_max_configurable_timeout_values]
 Default timeout values for learner table to support common protocol states.
 
const char * DIAGNOSTIC_COUNT_IN_PASS_TAG = "diagnosticCountInPass"
 
auto & directMeterCounterSizeMap = DPDK::CollectDirectCounterMeter::directMeterCounterSizeMap
 
const unsigned dpdk_default_table_size = 65536
 Default values.
 
const unsigned dpdk_learner_max_configurable_timeout_values = 8
 Maximum number of configurable timeout values.
 
const int dpdk_max_operand_size = 64
 Maximum operand size for unary, binary and ternary operations.
 
template<class T >
constexpr bool has_dbprint_v = has_dbprint<T>::value
 
template<class T >
constexpr bool has_ostream_operator_v = has_ostream_operator<T>::value
 
const unsigned initial_group_id = 0xFFFFFFFF
 
const unsigned initial_member_id = 0
 Initial values for group_id and member_id for action selector and action profile tables.
 
auto & origNameMap = DPDK::ShortenTokenLength::origNameMap
 
const char outOfBoundsStateName [] = "stateOutOfBound"
 Name of out of bound state.
 
const char * p4_14includePath = CONFIG_PKGDATADIR "/p4_14include"
 
const char * p4includePath = CONFIG_PKGDATADIR "/p4include"
 
const std::set< cstringreservedWords
 
const unsigned table_handle_prefix = 0x00010000
 Unique handle for action and table.
 
const cstring tdiSchemaVersion = cstring::literal("0.1")
 

Detailed Description

TODO: this is not really specific to BMV2, it should reside somewhere else.

This file has common data structures used for inlining functions and actions. Inlining these is simpler than inlining controls and parsers

A cstring is a reference to a zero-terminated, immutable, interned string. The cstring object itself is not immutable; you can reassign it as required, and it provides a mutable interface that copies the underlying immutable string as needed.

Compared to std::string, these are the benefits that cstring provides:

  • Copying and assignment are cheap. Since cstring only deals with immutable strings, these operations only involve pointer assignment.
  • Comparing cstrings for equality is cheap; interning makes it possible to test for equality using a simple pointer comparison.
  • The immutability of the underlying strings means that it's always safe to change a cstring, even if there are other references to it elsewhere.
  • The API offers a number of handy helper methods that aren't available on std::string.

On the other hand, these are the disadvantages of using cstring:

  • Because cstring deals with immutable strings, any modification requires that the complete string be copied.
  • Interning has an initial cost: converting a const char*, a std::string, or a std::stringstream to a cstring requires copying it. Currently, this happens every time you perform the conversion, whether the string is already interned or not, unless the source is an std::string.
  • Interned strings can never be freed, so they'll stick around for the lifetime of the program.
  • The string interning cstring performs is currently not threadsafe, so you can't safely use cstrings off the main thread.

Given these tradeoffs, the general rule of thumb to follow is that you should try to convert strings to cstrings early and keep them in that form. That way, you benefit from cheaper copying, assignment, and equality testing in as many places as possible, and you avoid paying the cost of repeated conversion.

However, when you're building or mutating a string, you should use std::string. Convert to a cstring only when the string is in its final form. This ensures that you don't pay the time and space cost of interning every intermediate version of the string.

Note that cstring has implicit conversions to and from other string types. This is convenient, but in performance-sensitive code it's good to be aware that mixing the two types of strings can trigger a lot of implicit copies.

Shouldn't happen as cmake will not try to build this backend if the boost graph headers couldn't be found.

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

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 Helper functions and classes for making the creation of gtest easier and their running faster. See test-bf_getst_helper.cpp for example usage.


Class Documentation

◆ P4::PauseTrace

class P4::PauseTrace

◆ P4::primitive_info_t

struct P4::primitive_info_t
Class Members
unsigned max_operands
unsigned min_operands
unsigned out_operands
unsigned type_match_operands

◆ P4::TableInsertions

class P4::TableInsertions
Class Members
vector< const Declaration_Variable * > declarations
vector< const AssignmentStatement * > statements

◆ P4::UnparsedConstant

struct P4::UnparsedConstant

An unparsed numeric constant. We produce these as token values during lexing. The parser is responsible for actually interpreting the raw text as a numeric value and transforming it into an IR::Constant using parseConstant().

To illustrate how a numeric constant is represented using this struct, here is a breakdown of '16w0x12':

     ___
    /                                    ___
    |                                   /
    |   bitwidth (if @hasWidth)        |       16
    |                                   \___
    |
    |                                    ___
    |                                   /
    |   separator (if @hasWidth)       |       w
    |                                   \___

@text | | ___ | / | ignored prefix of length

| ___ | | ___ | / | numeric value in base @base | w | ___ ___

Simple numeric constants like '5' are specified by setting @hasWidth to false and providing a

Class Members
unsigned base An ignored prefix of the numeric constant (e.g. '0x').
bool hasWidth The base in which the constant is expressed.
unsigned skip Raw P4 text which was recognized as a numeric constant.
cstring text

Typedef Documentation

◆ DebugHook

typedef std::function< void(const char *, unsigned, const char *, const IR::Node *)> P4::DebugHook

A hook called by pass manager after a pass finishes.

Parameters
nodea result of the last pass, which can be the (transformed) node, or a nullptr.

◆ SymbolicMapping

Initial value:

This type maps symbolic variables to their value assigned by the solver.

Enumeration Type Documentation

◆ DiagnosticAction

enum class P4::DiagnosticAction
strong

An action to take when a diagnostic message is triggered.

Enumerator
Info 

Take no action and continue compilation.

Warn 

Print an info message and continue compilation.

Error 

Print a warning and continue compilation.

Print an error and signal that compilation should be aborted.

◆ Endian

enum class P4::Endian : uint8_t
strong

An ordering for bits or bytes.

Enumerator
Little 

Most significant bit/byte first.

◆ InternalTableType

DPDK target implementation treats tables with keys lying non-contiguous in underlying structure as wildcard even if all keys are exact match keys. Learner tables are special table with contiguous and exact match keys.

Function Documentation

◆ convert()

const IR::Expression * P4::convert ( const IR::Expression * expression,
const IR::Type * type )

Given an expression and a destination type, convert ListExpressions that occur within expression to StructExpression if the destination type matches.

◆ diagnosticCount()

unsigned P4::diagnosticCount ( )
inline
Returns
the number of diagnostics (either errors or warnings) encountered so far in the current compilation context.

◆ error() [1/3]

template<class T , typename = std::enable_if_t<Util::has_SourceInfo_v<T>>, class... Args>
void P4::error ( const char * format,
const T * node,
Args &&... args )

Convert errors that have a first argument as a node with source info to errors with kind This allows incremental migration toward minimizing the number of errors and warnings reported when passes are repeated, as typed errors are filtered.

◆ error() [2/3]

template<typename... Args>
void P4::error ( const int kind,
const char * format,
Args &&... args )

Report errors of type kind for messages that do not have a node. These will not be filtered

◆ error() [3/3]

template<class T , typename = std::enable_if_t<Util::has_SourceInfo_v<T>>, class... Args>
void P4::error ( const int kind,
const char * format,
const T * node,
Args &&... args )

Report errors of type kind. Requires that the node argument have source info. The message format is declared in the error catalog.

◆ errorCount()

unsigned P4::errorCount ( )
inline
Returns
the number of errors encountered so far in the current compilation context.

◆ exename()

const char * P4::exename ( const char * argv0 = nullptr)

Attempt to determine the executable name and return a static path to it. Will use argv0 if provided and nothing better can be found

◆ forAllMatching()

template<typename NodeType , typename Func >
void P4::forAllMatching ( const IR::Node * root,
Func && function )

Invoke an inspector @function for every node of type @NodeType in the subtree rooted at @root. The behavior is the same as a postorder Inspector.

◆ format_container()

template<class Cont >
std::ostream & P4::format_container ( std::ostream & out,
const Cont & container,
char lbrace,
char rbrace )

Serializes the container into the stream out, delimining it by bracketing it with lbrace and rbrace. This is mostly a helper for writing operator<< fur custom container classes.

◆ get()

template<typename Map , typename Key >
Map::mapped_type P4::get ( const Map & m,
const Key & key )

Given a map and a key, return the value corresponding to the key in the map, or a given default value if the key doesn't exist in the map.

◆ getDiagnosticCountInPassHook()

DebugHook P4::getDiagnosticCountInPassHook ( BaseCompileContext & ctxt = BaseCompileContext::get())

This creates a debug hook that prints information about the number of diagnostics of different levels (error, warning, info) printed by each of the pass after it ended. This is intended to help in debuggig and testing.

NOTE: You either need to use one DiagnosticCountInfo object (and its getPassManagerHook) for the entire compilation, create one pass and use its copies in all the pass managers in the compilation, or create each of the following hooks only after the previous compilations steps had already run. Otherwise, you can get spurious logs for a first pass of a pass manager running after some diagnostics were emitted.

It logs the messages if the log level for "diagnosticCountInPass" is at least 1. If the log level is at least 4, the logs also include the sequence number of the pass that printed the message in the pass manager.

Parameters
ctxtOptionally, you can provide a compilation context to take the diagnostic counts from. If not provied BaseCompileContext::get() is used.
Returns
A debug hook suitable for using in pass managers.

◆ getref()

template<typename Map , typename Key >
const Map::mapped_type * P4::getref ( const Map & m,
const Key & key )

Given a map and a key, return the pointer to value corresponding to the key in the map, or a nullptr if the key doesn't exist in the map.

◆ info()

template<typename... Args>
void P4::info ( const int kind,
const char * format,
Args &&... args )

Report info messages of type kind, for messages that do not have a node. These will not be filtered

◆ isTerminalState()

bool P4::isTerminalState ( IR::ID id)

Checks for terminal state.

◆ modifyAllMatching()

template<typename NodeType , typename RootType , typename Func >
const RootType * P4::modifyAllMatching ( const RootType * root,
Func && function )

Invoke a modifier @function for every node of type @NodeType in the subtree rooted at @root. The behavior is the same as a postorder Modifier.

Returns
the root of the new, modified version of the subtree.

◆ operator-() [1/2]

template<RangeUnit Unit, Endian Order>
std::pair< HalfOpenRange< Unit, Order >, HalfOpenRange< Unit, Order > > P4::operator- ( ClosedRange< Unit, Order > left,
ClosedRange< Unit, Order > right )
See also
HalfOpenRange subtraction.
Returns
a pair of half-open ranges (which may be empty).

◆ operator-() [2/2]

template<RangeUnit Unit, Endian Order>
std::pair< HalfOpenRange< Unit, Order >, HalfOpenRange< Unit, Order > > P4::operator- ( HalfOpenRange< Unit, Order > left,
HalfOpenRange< Unit, Order > right )

Implements range subtraction (similar to set subtraction), computing the upper and lower ranges that result from @left - @right. For example, @left - @right = { C.lower, C.upper }:

example (1) (2) (3) (4) @left -----— -— -— -— @right — -— -— -------— C.lower — -— (empty) (empty) C.upper – (empty) -— (empty)

XXX: This could produce a bit vector.

◆ optimizeExpression()

const IR::Expression * P4::optimizeExpression ( const IR::Expression * node)
inline

Applies expression optimizations to the input node. Currently, performs constant folding and strength reduction.

◆ parseConstant()

IR::Constant * P4::parseConstant ( const Util::SourceInfo & srcInfo,
const UnparsedConstant & constant,
long defaultValue )

Parses an UnparsedConstant @constant into an IR::Constant object, with location information taken from @srcInfo. If parsing fails, an IR::Constant containing the value @defaultValue is returned, and an error is reported.

Returns
an IR::Constant parsed from @constant. If parsing fails, returns either a default value.

◆ parseConstantChecked()

int P4::parseConstantChecked ( const Util::SourceInfo & srcInfo,
const UnparsedConstant & constant )

Parses a constant that should fit in an int value. Reports an error if it does not.

◆ parseP4File()

template<typename C = P4V1::Converter>
const IR::P4Program * P4::parseP4File ( const ParserOptions & options)

Parse P4 source from a file. The filename and language version are specified by @options. If the language version is not P4-16, then the program is converted to P4-16 before being returned.

Returns
a P4-16 IR tree representing the contents of the given file, or null on failure. If failure occurs, an error will also be reported.

◆ parseP4String()

const IR::P4Program * P4::parseP4String ( const char * sourceFile,
unsigned sourceLine,
const std::string & input,
CompilerOptions::FrontendVersion version )

Parse P4 source from the string @input, interpreting it as having language version

Version
. The source is not preprocessed before being parsed; the initial source location is derived from @sourceFile and @sourceLine. If the language version is not P4-16, then the program is converted to P4-16 before being returned.
Returns
a P4-16 IR tree representing the contents of the given string, or null on failure. If failure occurs, an error will also be reported.

◆ toClosedRange()

template<RangeUnit Unit, Endian Order>
std::optional< ClosedRange< Unit, Order > > P4::toClosedRange ( HalfOpenRange< Unit, Order > halfOpenRange)
Returns
a closed range denoting the same elements as the provided half-open range, or std::nullopt if the provided range is empty.

◆ toHalfOpenRange()

template<RangeUnit Unit, Endian Order>
HalfOpenRange< Unit, Order > P4::toHalfOpenRange ( ClosedRange< Unit, Order > closedRange)
Returns
a half-open range denoting the same elements as the provided closed range.

◆ transformAllMatching()

template<typename NodeType , typename Func >
const IR::Node * P4::transformAllMatching ( const IR::Node * root,
Func && function )

Invoke a transform @function for every node of type @NodeType in the subtree rooted at @root. The behavior is the same as a postorder Transform.

Returns
the root of the new, transformed version of the subtree.

◆ warning()

template<typename... Args>
void P4::warning ( const int kind,
const char * format,
Args &&... args )

Report warnings of type kind, for messages that do not have a node. These will not be filtered

Variable Documentation

◆ default_learner_table_timeout

const unsigned P4::default_learner_table_timeout[dpdk_learner_max_configurable_timeout_values]
Initial value:
= {
10, 30, 60, 120, 300, 43200, 120, 120}

Default timeout values for learner table to support common protocol states.

◆ p4includePath

const char * P4::p4includePath = CONFIG_PKGDATADIR "/p4include"

Standard include paths for .p4 header files. The values are determined by configure.

◆ reservedWords

const std::set< cstring > P4::reservedWords
Initial value:
= {
"abstract"_cs,
"action"_cs, "actions"_cs, "apply"_cs, "bool"_cs, "bit"_cs, "const"_cs,
"control"_cs, "default"_cs, "else"_cs, "enum"_cs, "error"_cs, "exit"_cs,
"extern"_cs, "false"_cs, "header"_cs, "header_union"_cs, "if"_cs, "in"_cs,
"inout"_cs, "int"_cs, "key"_cs, "match_kind"_cs, "out"_cs, "parser"_cs,
"package"_cs, "return"_cs, "select"_cs, "set"_cs, "state"_cs, "struct"_cs,
"switch"_cs, "table"_cs,
"this"_cs,
"transition"_cs, "true"_cs, "tuple"_cs, "typedef"_cs, "varbit"_cs, "verify"_cs,
"void"_cs, "_"_cs,
"NoAction"_cs
}