P4C
The P4 Compiler
|
Namespaces | |
namespace | ControlPlaneState |
namespace | TraceEvents |
This file defines explicit types of trace events extended from the generic trace class. | |
Classes | |
class | AbstractExecutionState |
Represents state of execution after having reached a program point. More... | |
class | AbstractP4cTool |
class | AbstractP4cToolOptions |
class | AbstractRepCheckedNode |
class | ArchSpec |
Specifies a canonical representation of the target pipeline as documented in P4 code. More... | |
class | CompileContext |
A compilation context for P4Tools that provides a custom compiler configuration. More... | |
class | CompilerConfiguration |
class | CompilerResult |
class | CompilerTarget |
Encapsulates the details of invoking the P4 compiler for a target device and architecture. More... | |
class | ConvertStructExpr |
class | ConvertVarbits |
class | ExtendedCallGraph |
struct | FormatOptions |
Defines common formatting options. More... | |
class | HSIndexToMember |
The main class for finding non-concrete header stack indices. More... | |
class | MaskBuilder |
class | MidEnd |
class | Model |
class | NamespaceContext |
Represents a stack of namespaces. More... | |
class | P4Constants |
class | P4ProgramDCGCreator |
The main class for building control flow DCG. More... | |
class | ReachabilityEngine |
class | ReachabilityEngineState |
The main data for reachability engine. More... | |
class | SmithOptions |
class | SymbolicEnv |
class | Taint |
class | TaintPropagator |
class | Target |
class | TraceEvent |
An event in a trace of the execution of a P4 program. More... | |
class | Utils |
General utility functions that are not present in the compiler framework. More... | |
class | Z3Solver |
A Z3-based implementation of AbstractSolver. Encapsulates a z3::solver and a z3::context. More... | |
class | Z3SolverAccessor |
class | Z3Translator |
Translates P4 expressions into Z3. Any variables encountered are declared to a Z3 instance. More... | |
Typedefs | |
using | CompilerResultOrError = std::optional<std::reference_wrapper<const CompilerResult>> |
using | ConstraintsVector = std::vector<const IR::Expression *> |
using | DCGVertexType = const IR::Node * |
using | DCGVertexTypeSet = std::unordered_set<DCGVertexType> |
using | NodesCallGraph = ExtendedCallGraph<DCGVertexType> |
using | ReachabilityHashType = std::unordered_map<cstring, DCGVertexTypeSet> |
using | ReachabilityResult = std::pair<bool, const IR::Expression *> |
using | SymbolicMapType = P4::flat_map<IR::StateVariable, const IR::Expression *> |
Symbolic maps map a state variable to a IR::Expression. | |
using | Z3DeclaredVariablesMap = std::vector<ordered_map<unsigned, const IR::SymbolicVariable *>> |
Functions | |
std::vector< const IR::Type_Declaration * > | argumentsToTypeDeclarations (const IR::IGeneralNamespace *ns, const IR::Vector< IR::Argument > *inputArgs) |
std::vector< uint8_t > | convertBigIntToBytes (const big_int &dataInt, int targetWidthBits, bool padLeft) |
std::optional< std::string > | convertToIpv4String (const std::vector< uint8_t > &byteArray) |
std::optional< std::string > | convertToIpv6String (const std::vector< uint8_t > &byteArray) |
std::optional< std::string > | convertToMacString (const std::vector< uint8_t > &byteArray) |
void | enableInformationLogging () |
Enable the printing of basic run information. | |
void | enablePerformanceLogging () |
Enable printing of timing reports. | |
const IR::IDeclaration * | findProgramDecl (const IR::IGeneralNamespace *ns, const IR::Path *path) |
Looks up a declaration from a path. A BUG occurs if no declaration is found. | |
const IR::IDeclaration * | findProgramDecl (const IR::IGeneralNamespace *ns, const IR::PathExpression *pathExpr) |
Looks up a declaration from a path expression. A BUG occurs if no declaration is found. | |
std::string | formatBin (const big_int &value, int width, const FormatOptions &formatOptions=FormatOptions()) |
Format. | |
std::string | formatBinExpr (const IR::Expression *expr, const FormatOptions &formatOptions) |
std::string | formatBinOrHex (const big_int &value, const FormatOptions &formatOptions=FormatOptions()) |
Format. | |
std::string | formatBinOrHex (const big_int &value, int width, const FormatOptions &formatOptions) |
std::string | formatBinOrHexExpr (const IR::Expression *expr, const FormatOptions &formatOptions) |
std::string | formatHex (const big_int &value, int width, const FormatOptions &formatOptions=FormatOptions()) |
Format. | |
std::string | formatHexExpr (const IR::Expression *expr, const FormatOptions &formatOptions) |
std::string | formatOctal (const big_int &value, const FormatOptions &formatOptions=FormatOptions()) |
Format. | |
std::string | formatOctal (const big_int &value, int width, const FormatOptions &formatOptions) |
std::string | formatOctalExpr (const IR::Expression *expr, const FormatOptions &formatOptions) |
std::string | insertHexSeparators (const std::string &dataStr) |
Takes a hex-formatted string as input and inserts slashes as separators. | |
std::string | insertOctalSeparators (const std::string &dataStr) |
Takes an octal-formatted string as input and inserts slashes as separators. | |
std::string | insertSeparators (const std::string &dataStr, const std::string &separator, size_t stride, bool skipFirst) |
std::string | logHelper (boost::format &f) |
Helper function for @printFeature. | |
template<class T , class... Args> | |
std::string | logHelper (boost::format &f, T &&t, Args &&...args) |
Helper function for @printFeature. | |
std::ostream & | operator<< (std::ostream &os, const TraceEvent &event) |
template<typename... Arguments> | |
void | printDebug (const std::string &fmt, Arguments &&...args) |
template<typename... Arguments> | |
void | printFeature (const std::string &label, int level, const std::string &fmt, Arguments &&...args) |
template<typename... Arguments> | |
void | printInfo (const std::string &fmt, Arguments &&...args) |
void | printPerformanceReport (const std::optional< std::filesystem::path > &basePath) |
const IR::Type_Declaration * | resolveProgramType (const IR::IGeneralNamespace *ns, const IR::Type_Name *type) |
Resolves a Type_Name in the top-level namespace. | |
const char * | toString (const z3::expr &e) |
Converts a Z3 expression to a string. | |
const char * | toString (z3::model m) |
Converts a Z3 model to a string. | |
Variables internal to P4Tools. These variables do not exist in the P4 program itself, but are generated and added to the environment by the P4Tools tooling. These variables are also used for SMT solvers as symbolic variables.
struct P4::P4Tools::FormatOptions |
Defines common formatting options.
using P4::P4Tools::CompilerResultOrError = std::optional<std::reference_wrapper<const CompilerResult>> |
P4Tools compilers may return an error instead of a compiler result. This is a convenience definition for the return value.
using P4::P4Tools::ConstraintsVector = std::vector<const IR::Expression *> |
A list of constraints. These constraints may take the form of "x == 8w1","x != y", where "x" and "y" are symbolic variables. They are expressed in P4C IR form and may be consumed by SMT or similar solvers.
using P4::P4Tools::Z3DeclaredVariablesMap = std::vector<ordered_map<unsigned, const IR::SymbolicVariable *>> |
A stack of maps, which map Z3-internal expression IDs of declared Z3 variables to their corresponding P4 state variable. The maps are pushed and pop according to the solver push() and pop() operations.
std::vector< const IR::Type_Declaration * > P4::P4Tools::argumentsToTypeDeclarations | ( | const IR::IGeneralNamespace * | ns, |
const IR::Vector< IR::Argument > * | inputArgs ) |
Converts the list of arguments @inputArgs to a list of type declarations. Any names appearing in the arguments are resolved with @ns. This is mainly useful for inspecting package instances.
std::vector< uint8_t > P4::P4Tools::convertBigIntToBytes | ( | const big_int & | dataInt, |
int | targetWidthBits, | ||
bool | padLeft = false ) |
Converts a big integer input into a vector of bytes with the size targetWidthBits /8. If the integer value is smaller than the request bit size and
padLeft | is false, padding is added on the right-hand side of the vector (the "least-significant" side). Otherwise, padding is added on the left-hand side, (the "most-significant side") |
Chunk size is 8 bits, i.e., a byte.
std::optional< std::string > P4::P4Tools::convertToIpv4String | ( | const std::vector< uint8_t > & | byteArray | ) |
Convert a byte array into a IPv4 string of the form "x.x.x.x".
std::optional< std::string > P4::P4Tools::convertToIpv6String | ( | const std::vector< uint8_t > & | byteArray | ) |
Convert a byte array into a IPv4 string of the form "xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx".
Chunk size is 8 bits, i.e., a byte.
std::optional< std::string > P4::P4Tools::convertToMacString | ( | const std::vector< uint8_t > & | byteArray | ) |
Convert a byte array into a MAC string of the form "xx:xx:xx:xx:xx:xx".
std::string P4::P4Tools::formatBin | ( | const big_int & | value, |
int | width, | ||
const FormatOptions & | formatOptions = FormatOptions() ) |
Format.
std::string P4::P4Tools::formatBinExpr | ( | const IR::Expression * | expr, |
const FormatOptions & | formatOptions = FormatOptions() ) |
If the given
std::string P4::P4Tools::formatBinOrHex | ( | const big_int & | value, |
const FormatOptions & | formatOptions = FormatOptions() ) |
Format.
std::string P4::P4Tools::formatBinOrHexExpr | ( | const IR::Expression * | expr, |
const FormatOptions & | formatOptions = FormatOptions() ) |
If the given
std::string P4::P4Tools::formatHex | ( | const big_int & | value, |
int | width, | ||
const FormatOptions & | formatOptions = FormatOptions() ) |
Format.
std::string P4::P4Tools::formatHexExpr | ( | const IR::Expression * | expr, |
const FormatOptions & | formatOptions = FormatOptions() ) |
If the given
std::string P4::P4Tools::formatOctal | ( | const big_int & | value, |
const FormatOptions & | formatOptions = FormatOptions() ) |
Format.
std::string P4::P4Tools::formatOctalExpr | ( | const IR::Expression * | expr, |
const FormatOptions & | formatOptions = FormatOptions() ) |
If the given
std::string P4::P4Tools::insertSeparators | ( | const std::string & | dataStr, |
const std::string & | separator = "\\x", | ||
size_t | stride = 2, | ||
bool | skipFirst = false ) |
Insert separators into
dataStr | every |
stride. | If |
skipFirst | is true, this will not add a separator to the beginning of the string. This function always pads to the width of |
stride. |
void P4::P4Tools::printDebug | ( | const std::string & | fmt, |
Arguments &&... | args ) |
Convenience function for printing debug information. Easier to use then LOG(XX) since we only need one specific log-level across all files. Can be invoked with "-T tools_debug:4".
void P4::P4Tools::printFeature | ( | const std::string & | label, |
int | level, | ||
const std::string & | fmt, | ||
Arguments &&... | args ) |
A helper function that allows us to configure logging for a particular feature. This code is taken from
void P4::P4Tools::printInfo | ( | const std::string & | fmt, |
Arguments &&... | args ) |
Helper functions that prints strings associated with basic tool information. For example, the seed, status of test case generation, etc.
void P4::P4Tools::printPerformanceReport | ( | const std::optional< std::filesystem::path > & | basePath = std::nullopt | ) |
Print a performance report if performance logging is enabled. If a file is provided, it will be written to the file.