P4C
The P4 Compiler
Loading...
Searching...
No Matches
P4::P4Tools::Target Class Reference

#include <target.h>

Inheritance diagram for P4::P4Tools::Target:
[legend]

Classes

struct  Spec
 Specifies a target device and architecture by their names in lower case. More...
 

Public Member Functions

virtual const IR::Expression * createTargetUninitialized (const IR::Type *type, bool forceTaint) const
 

Static Public Member Functions

static bool init (std::string deviceName, std::string archName)
 
static bool setArch (std::string archName)
 
static bool setDevice (std::string deviceName)
 

Public Attributes

Spec spec
 The device and architecture supported by this instance.
 
std::string toolName
 The name of the tool supported by this instance.
 

Protected Member Functions

 Target (std::string_view toolName, const std::string &deviceName, const std::string &archName)
 

Static Protected Member Functions

template<class TargetImpl >
static const TargetImpl & get (std::string_view toolName)
 

Detailed Description

Encapsulates the details of a target device and architecture for a single tool. Implementations are singletons and must provide a default constructor. Instances are automatically registered into a central registry. The active target is set by calling @init. The suite of instances for all supported tools for the active target can be obtained by calling @get.

Constructor & Destructor Documentation

◆ Target()

P4::P4Tools::Target::Target ( std::string_view toolName,
const std::string & deviceName,
const std::string & archName )
protected

Creates and registers a new Target instance for the given @toolName, @deviceName, and @archName.

Member Function Documentation

◆ createTargetUninitialized()

const IR::Expression * P4::P4Tools::Target::createTargetUninitialized ( const IR::Type * type,
bool forceTaint ) const
virtual
Returns
the default value for uninitialized variables for this particular target. This can be a taint variable or simply 0 (bits) or false (booleans). If
Parameters
forceTaintis active, this function always returns a taint variable. Can be overridden by sub-targets.

◆ get()

template<class TargetImpl >
static const TargetImpl & P4::P4Tools::Target::get ( std::string_view toolName)
inlinestaticprotected
Returns
the target instance for the given tool and active target, as selected by @init.

◆ init()

bool P4::P4Tools::Target::init ( std::string deviceName,
std::string archName )
static

Initializes the global target device and architecture to @deviceName and @archName.

Returns
true on success. If initialization fails, false is returned, and nothing is changed.

◆ setArch()

bool P4::P4Tools::Target::setArch ( std::string archName)
static

Initializes the global target architecture to @archName without changing the device. If no device was previously selected, then the first device registered for the architecture is chosen.

Returns
true on success. If initialization fails, false is returned, and nothing is changed.

◆ setDevice()

bool P4::P4Tools::Target::setDevice ( std::string deviceName)
static

Initializes the global target device to @deviceName without changing the architecture. If no architecture was previously selected, then the first architecture registered for the device is chosen.

Returns
true on success. If initialization fails, false is returned, and nothing is changed.