P4C
The P4 Compiler
|
#include <options.h>
Public Member Functions | |
int | process (const std::vector< const char * > &args) |
std::vector< const char * > * | process (int argc, char *const argv[]) override |
Hook for customizing options processing. | |
Public Member Functions inherited from P4::CompilerOptions | |
CompilerOptions (std::string_view defaultMessage="Compile a P4 program") | |
virtual bool | enable_intrinsic_metadata_fix () |
Public Member Functions inherited from P4::ParserOptions | |
ParserOptions (std::string_view defaultMessage="Parse a P4 program") | |
DebugHook | getDebugHook () const |
const char * | getIncludePath () const override |
Return target specific include path. | |
bool | isAnnotationDisabled (const IR::Annotation *a) const |
Check whether this particular annotation was disabled. | |
bool | isv1 () const |
True if we are compiling a P4 v1.0 or v1.1 program. | |
std::optional< ParserOptions::PreprocessorResult > | preprocess () const |
Returns the output of the preprocessor. | |
std::vector< const char * > * | process (int argc, char *const argv[]) override |
bool | searchForIncludePath (const char *&includePathOut, std::vector< cstring > relativePaths, const char *) |
void | setInputFile () |
Expect that the only remaining argument is the input file. | |
Public Member Functions inherited from P4::Util::Options | |
cstring | getBinaryName () |
cstring | getBuildDate () |
cstring | getCompileCommand () |
virtual void | usage () |
Public Attributes | |
std::vector< const char * > | compilerArgs |
Command-line arguments to be sent to the compiler. Populated by @process. | |
bool | disableInformationLogging = false |
Disable information logging. | |
std::optional< uint32_t > | seed = std::nullopt |
A seed for the PRNG. | |
Public Attributes inherited from P4::CompilerOptions | |
cstring | arch = nullptr |
bool | debugJson = false |
std::filesystem::path | dumpJsonFile |
bool | excludeBackendPasses = false |
bool | excludeFrontendPasses = false |
bool | excludeMidendPasses = false |
bool | listFrontendPasses = false |
bool | listMidendPasses = false |
bool | loopsUnrolling = false |
bool | ndebug = false |
int | optimizationLevel = 1 |
bool | optimizeDebug = false |
bool | optimizeSize = false |
cstring | p4RuntimeEntriesFile = nullptr |
cstring | p4RuntimeEntriesFiles = nullptr |
cstring | p4RuntimeFile = nullptr |
cstring | p4RuntimeFiles = nullptr |
P4::P4RuntimeFormat | p4RuntimeFormat = P4::P4RuntimeFormat::BINARY |
std::vector< cstring > | passesToExcludeBackend |
std::vector< cstring > | passesToExcludeFrontend |
std::vector< cstring > | passesToExcludeMidend |
std::filesystem::path | prettyPrintFile |
cstring | target = nullptr |
Public Attributes inherited from P4::ParserOptions | |
cstring | compilerVersion |
Compiler version. | |
bool | doNotCompile = false |
if true preprocess only | |
bool | doNotPreprocess = false |
if true skip preprocess | |
std::filesystem::path | dumpFolder = "." |
debugging dumps of programs written in this folder | |
cstring | exe_name |
Name of executable that is being run. | |
std::filesystem::path | file |
file to compile (- for stdin) | |
FrontendVersion | langVersion = FrontendVersion::P4_16 |
Which language to compile. | |
bool | noIncludes = false |
bool | optimizeParserInlining = false |
If false, optimization of callee parsers (subparsers) inlining is disabled. | |
cstring | preprocessor_options = cstring::empty |
options to pass to preprocessor | |
std::vector< cstring > | top4 |
substrings matched against pass names | |
Protected Member Functions | |
AbstractP4cToolOptions (AbstractP4cToolOptions &&)=default | |
AbstractP4cToolOptions (const AbstractP4cToolOptions &)=default | |
AbstractP4cToolOptions (std::string_view toolName, std::string_view message) | |
const std::string & | getToolName () const |
The name of the tool associated with these options. | |
AbstractP4cToolOptions & | operator= (const AbstractP4cToolOptions &)=default |
bool | validateOptions () const override |
Protected Member Functions inherited from P4::CompilerOptions | |
Protected Member Functions inherited from P4::ParserOptions | |
void | dumpPass (const char *manager, unsigned seq, const char *pass, const IR::Node *node) const |
virtual std::unique_ptr< ToP4 > | getToP4 (std::ostream *, bool, std::filesystem::path) const |
Protected Member Functions inherited from P4::Util::Options | |
Options (std::string_view message) | |
void | registerOption (const char *option, const char *argName, OptionProcessor processor, const char *description, OptionFlags flags=OptionFlags::Default) |
void | registerUsage (const char *msg) |
void | setOutStream (std::ostream *out) |
Additional Inherited Members | |
Public Types inherited from P4::ParserOptions | |
enum class | FrontendVersion { P4_14 , P4_16 } |
using | PreprocessorResult = std::unique_ptr<FILE, decltype(&closeFile)> |
Records the result of the preprocessor. | |
Public Types inherited from P4::Util::Options | |
enum | OptionFlags { Default = 0 , Hide = 1 << 0 , OptionalArgument = 1 << 1 } |
using | OptionProcessor = std::function<bool(const char *)> |
Static Public Member Functions inherited from P4::ParserOptions | |
static void | closeFile (FILE *file) |
Tries to close the input stream associated with the result. | |
Protected Attributes inherited from P4::Util::Options | |
std::vector< const char * > | additionalUsage |
const char * | binaryName |
cstring | buildDate |
bool | collectUnknownOptions = false |
cstring | compileCommand |
cstring | message |
std::vector< cstring > | optionOrder |
std::map< cstring, const Option * > | options |
std::ostream * | outStream = &std::cerr |
std::vector< const char * > | remainingOptions |
Encapsulates and processes command-line options for a compiler-based tool. Implementations should use the singleton pattern and define a static get() for obtaining the singleton instance.
int P4::P4Tools::AbstractP4cToolOptions::process | ( | const std::vector< const char * > & | args | ) |
Processes options.
|
overridevirtual |
Hook for customizing options processing.
Reimplemented from P4::Util::Options.
|
nodiscardoverrideprotectedvirtual |
Checks if parsed options make sense with respect to each-other.
Reimplemented from P4::CompilerOptions.
Reimplemented in P4::P4Tools::P4Testgen::TestgenOptions.