P4C
The P4 Compiler
Loading...
Searching...
No Matches
BFNContext Class Reference

A CompileContext for bf-p4c. More...

#include <bf-p4c-options.h>

Inheritance diagram for BFNContext:
[legend]

Public Member Functions

void clearBackendOptions ()
 Clear the backend options.
 
void discoverPipes (const IR::P4Program *, const IR::ToplevelBlock *)
 identify the pipelines in the program and setup the _pipes map
 
cstring getOutputDirectory (const cstring &suffix=cstring(), int pipe_id=-1)
 
cstring & getPipeName (int pipe_id)
 Return the pipeline name or empty if the program has not been parsed.
 
BFN_Optionsoptions () override
 
void setBackendOptions (BFN_Options *options)
 Record options created in the Backend.
 

Static Public Member Functions

static BFNContextget ()
 

names a pipe in the program.

Checks whether the given

bool isPipeName (const cstring &name)
 
BfErrorReportererrorReporter () override
 

Detailed Description

A CompileContext for bf-p4c.

Member Function Documentation

◆ get()

BFNContext & BFNContext::get ( )
static
Returns
the current compilation context, which must be of type BFNContext.

◆ getOutputDirectory()

cstring BFNContext::getOutputDirectory ( const cstring & suffix = cstring(),
int pipe_id = -1 )
Returns
a string that represents a path to an output directory: options.outputDir + pipename + suffix If pipe_id is not set (-1) return just options.outputDir. No other files except for the manifest should be stored in the root. If suffix is empty, return options.outputDir + pipename.

The structure of the output directory is: options.outputDir / manifest.json for each pipe / pipeName/context.json / pipeName/tofino[x].bin / pipeName/program.bfa / pipeName/program.res.json / pipeName/logs/ / pipeName/graphs/

If the directory does not exists, it is created. If the creation fails print an error message and return an empty string. FIXME: Make this return std::filesystem::path. There are quite a few invocations of this function.

◆ options()

BFN_Options & BFNContext::options ( )
override
Returns
the compiler options for this compilation context.