P4C
The P4 Compiler
|
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 |
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, AInlineWorkList > | InlineActionsDriver |
typedef InlineDriver< FunctionsInlineList, FunctionsInlineWorkList > | InlineFunctionsDriver |
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 *, StackVariableHash > | StackVariableIndexMap |
typedef std::unordered_map< StackVariable, size_t, StackVariableHash > | StackVariableMap |
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 > | |
V | 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 > | |
V | 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) |
JSONGenerator & | operator<< (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::Node * | transformAllMatching (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< cstring > | reservedWords |
const unsigned | table_handle_prefix = 0x00010000 |
Unique handle for action and table. | |
const cstring | tdiSchemaVersion = cstring::literal("0.1") |
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:
On the other hand, these are the disadvantages of using cstring:
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 P4::PauseTrace |
struct P4::primitive_info_t |
class P4::TableInsertions |
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 std::function< void(const char *, unsigned, const char *, const IR::Node *)> P4::DebugHook |
A hook called by pass manager after a pass finishes.
node | a result of the last pass, which can be the (transformed) node, or a nullptr. |
using P4::SymbolicMapping |
This type maps symbolic variables to their value assigned by the solver.
|
strong |
|
strong |
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.
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.
|
inline |
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.
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
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.
|
inline |
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
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.
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.
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.
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.
ctxt | Optionally, you can provide a compilation context to take the diagnostic counts from. If not provied BaseCompileContext::get() is used. |
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.
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
bool P4::isTerminalState | ( | IR::ID | id | ) |
Checks for terminal state.
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.
std::pair< HalfOpenRange< Unit, Order >, HalfOpenRange< Unit, Order > > P4::operator- | ( | ClosedRange< Unit, Order > | left, |
ClosedRange< Unit, Order > | right ) |
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.
|
inline |
Applies expression optimizations to the input node. Currently, performs constant folding and strength reduction.
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.
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.
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.
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
std::optional< ClosedRange< Unit, Order > > P4::toClosedRange | ( | HalfOpenRange< Unit, Order > | halfOpenRange | ) |
HalfOpenRange< Unit, Order > P4::toHalfOpenRange | ( | ClosedRange< Unit, Order > | closedRange | ) |
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.
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
const unsigned P4::default_learner_table_timeout[dpdk_learner_max_configurable_timeout_values] |
Default timeout values for learner table to support common protocol states.
const char * P4::p4includePath = CONFIG_PKGDATADIR "/p4include" |
Standard include paths for .p4 header files. The values are determined by configure
.
const std::set< cstring > P4::reservedWords |