Vuo 2.4.4
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Protected Member Functions | Static Protected Member Functions | Protected Attributes | Friends | List of all members
VuoCompilerModule Class Reference

Description

A node class or type defined in an LLVM module.

This class would be the compiler detail class for VuoModule, except that the inheritance doesn't work out.

Definition at line 23 of file VuoCompilerModule.hh.

Public Member Functions

virtual ~VuoCompilerModule (void)
 Destructor.
 
virtual set< string > getDependencies (void)
 Returns a list of this VuoCompilerModule's dependencies.
 
virtual string getDependencyName (void)
 Returns the name that would represent this VuoCompilerModule in another VuoCompilerModule's list of dependencies.
 
virtual string getDependencyPath (void)
 Returns the path that would represent this VuoCompilerModule in a dependency file.
 
virtual string getFileName (void)
 Returns the file name (with extension) that this module should have when saved to file.
 
VuoCompilerCompatibility getCompatibleTargets (void)
 Returns the set of targets (operating system versions) with which this module is compatible.
 
Module * getModule (void)
 Returns this VuoCompilerModule's LLVM module, which other LLVM modules can link to.
 
VuoModulegetPseudoBase (void)
 Returns the (pseudo) base for this (pseudo) compiler detail class.
 
bool isBuiltIn (void)
 Returns true if this module is one of the built-in modules distributed with Vuo.
 
void setBuiltIn (bool builtIn)
 Sets whether this module is one of the built-in modules distributed with Vuo.
 
string getModulePath (void)
 Returns the file from which the LLVM module was loaded, or an empty string if the module was contained in an archive or generated by the compiler.
 
void setSourcePath (const string &sourcePath)
 Stores the path of the source file for this module.
 
string getSourcePath (void)
 Returns the stored path of the source file for this module, if any.
 
void setSourceCode (const string &sourceCode)
 Stores the source code for this module.
 
string getSourceCode (void)
 Returns the stored source code for this module, if any.
 
shared_ptr< VuoMakeDependenciesgetMakeDependencies (void)
 Returns the stored dependency file contents for this module, if any.
 

Static Public Member Functions

static VuoCompilerModulenewModule (const string &moduleKey, Module *module, const string &modulePath, const VuoCompilerCompatibility &moduleCompatibility)
 Instantiates a VuoCompilerModule (or child class) corresponding to the type of VuoCompilerModule defined in the LLVM module.
 
static VuoCompilerCompatibility parseCompatibility (json_object *o, string key)
 Parses the target set value for key in the top level of the JSON object.
 
static void parseGenericTypes (json_object *moduleDetails, vector< string > &genericTypeNames, map< string, string > &defaultSpecializedForGenericTypeName, map< string, vector< string > > &compatibleSpecializedForGenericTypeName)
 Parses the "genericTypes" portion of a module's metadata.
 
static Function * declareFunctionInModule (Module *module, Function *function)
 Copies the function's header into the LLVM module, if it's not already there.
 
static string getFileNameForModuleKey (const string &moduleKey)
 Returns the file name (with extension) that a module with the given module key would have when saved to file.
 
static bool isModuleKeyMangledInFileName (const string &fileName)
 Returns true if a module with the given file name (with extension) would have a module key other than the file name minus extension.
 

Protected Member Functions

 VuoCompilerModule (VuoModule *base, Module *module)
 Creates a VuoCompilerModule associated with the given LLVM module, as a pseudo compiler detail class of the given VuoModule.
 
virtual void parse (void)
 Renames globals in the LLVM module that might conflict with other VuoCompilerModules, and parses those globals.
 
virtual void parseMetadata (void)
 Parses the metadata of this VuoCompilerModule (name, description, ...) from the LLVM module.
 
virtual set< string > globalsToRename (void)
 Returns a list of global variables and functions that may be defined in multiple modules, and thus need to be renamed.
 
string nameForGlobal (string genericGlobalVarOrFuncName)
 Returns the mangled name for a function or global variable.
 
void renameGlobalVarsAndFuncs (void)
 Renames the global variables and functions within the LLVM module so that they are unique to this VuoCompilerModule.
 

Static Protected Member Functions

static bool isSpecializedModule (Module *module, string moduleKey)
 Returns true if the moduleDetails global variable within the LLVM module contains a key indicating that it is intended to be a specialized module definition.
 
static string nameForGlobal (string nameBeforeCompilation, string moduleKey)
 Returns the mangled name for a function or global variable.
 
static bool hasOriginalOrMangledGlobal (string nameBeforeCompilation, Module *module, string moduleKey)
 Returns true if the module contains a function or global variable with name nameBeforeCompilation or with the corresponding mangled name.
 

Protected Attributes

struct json_object * moduleDetails
 This module's metadata, found in the argument to VuoModuleMetadata in the module definition.
 
set< string > dependencies
 The modules and libraries needed to compile a composition containing this module.
 
VuoCompilerCompatibility compatibleTargets
 The set of targets with which this module is compatible.
 
Module *VuoCompilerBitcodeParserparser
 < The LLVM module that defines this node class or type
 
string sourcePath
 The file containing the module's source code, if known.
 
string sourceCode
 The module's source code, if known.
 
shared_ptr< VuoMakeDependenciesmakeDependencies
 The source files needed to compile this module.
 
map< string, string > defaultSpecializedForGenericTypeName
 For generic modules: the types to use when creating an unspecialized instance.
 
map< string, vector< string > > compatibleSpecializedForGenericTypeName
 For generic modules: the types to which each generic type is allowed to be specialized.
 

Friends

class TestVuoCompilerModule
 
class TestModules
 

Constructor & Destructor Documentation

◆ VuoCompilerModule()

VuoCompilerModule::VuoCompilerModule ( VuoModule base,
Module *  module 
)
protected

Creates a VuoCompilerModule associated with the given LLVM module, as a pseudo compiler detail class of the given VuoModule.

Definition at line 23 of file VuoCompilerModule.cc.

◆ ~VuoCompilerModule()

VuoCompilerModule::~VuoCompilerModule ( void  )
virtual

Destructor.

Definition at line 45 of file VuoCompilerModule.cc.

Member Function Documentation

◆ declareFunctionInModule()

Function * VuoCompilerModule::declareFunctionInModule ( Module *  module,
Function *  functionSrc 
)
static

Copies the function's header into the LLVM module, if it's not already there.

Use this when an LLVM module needs to call a function defined in another LLVM module.

Definition at line 274 of file VuoCompilerModule.cc.

◆ getCompatibleTargets()

VuoCompilerCompatibility VuoCompilerModule::getCompatibleTargets ( void  )

Returns the set of targets (operating system versions) with which this module is compatible.

Only checks the compatibility of the module itself, not its dependencies.

Definition at line 358 of file VuoCompilerModule.cc.

◆ getDependencies()

set< string > VuoCompilerModule::getDependencies ( void  )
virtual

Returns a list of this VuoCompilerModule's dependencies.

Reimplemented in VuoCompilerSpecializedNodeClass.

Definition at line 291 of file VuoCompilerModule.cc.

◆ getDependencyName()

string VuoCompilerModule::getDependencyName ( void  )
virtual

Returns the name that would represent this VuoCompilerModule in another VuoCompilerModule's list of dependencies.

Reimplemented in VuoCompilerSpecializedNodeClass.

Definition at line 300 of file VuoCompilerModule.cc.

◆ getDependencyPath()

string VuoCompilerModule::getDependencyPath ( void  )
virtual

Returns the path that would represent this VuoCompilerModule in a dependency file.

See also
VuoMakeDependencies

Definition at line 310 of file VuoCompilerModule.cc.

◆ getFileName()

string VuoCompilerModule::getFileName ( void  )
virtual

Returns the file name (with extension) that this module should have when saved to file.

Reimplemented in VuoCompilerNodeClass, and VuoCompilerPublishedNodeClass.

Definition at line 322 of file VuoCompilerModule.cc.

◆ getFileNameForModuleKey()

string VuoCompilerModule::getFileNameForModuleKey ( const string &  moduleKey)
static

Returns the file name (with extension) that a module with the given module key would have when saved to file.

Definition at line 331 of file VuoCompilerModule.cc.

◆ getMakeDependencies()

shared_ptr< VuoMakeDependencies > VuoCompilerModule::getMakeDependencies ( void  )

Returns the stored dependency file contents for this module, if any.

Definition at line 439 of file VuoCompilerModule.cc.

◆ getModule()

Module * VuoCompilerModule::getModule ( void  )

Returns this VuoCompilerModule's LLVM module, which other LLVM modules can link to.

Definition at line 366 of file VuoCompilerModule.cc.

◆ getModulePath()

string VuoCompilerModule::getModulePath ( void  )

Returns the file from which the LLVM module was loaded, or an empty string if the module was contained in an archive or generated by the compiler.

Definition at line 399 of file VuoCompilerModule.cc.

◆ getPseudoBase()

VuoModule * VuoCompilerModule::getPseudoBase ( void  )

Returns the (pseudo) base for this (pseudo) compiler detail class.

Definition at line 374 of file VuoCompilerModule.cc.

◆ getSourceCode()

string VuoCompilerModule::getSourceCode ( void  )

Returns the stored source code for this module, if any.

Definition at line 431 of file VuoCompilerModule.cc.

◆ getSourcePath()

string VuoCompilerModule::getSourcePath ( void  )

Returns the stored path of the source file for this module, if any.

Definition at line 415 of file VuoCompilerModule.cc.

◆ globalsToRename()

set< string > VuoCompilerModule::globalsToRename ( void  )
protectedvirtual

Returns a list of global variables and functions that may be defined in multiple modules, and thus need to be renamed.

Definition at line 202 of file VuoCompilerModule.cc.

◆ hasOriginalOrMangledGlobal()

bool VuoCompilerModule::hasOriginalOrMangledGlobal ( string  nameBeforeCompilation,
Module *  module,
string  moduleKey 
)
staticprotected

Returns true if the module contains a function or global variable with name nameBeforeCompilation or with the corresponding mangled name.

Definition at line 229 of file VuoCompilerModule.cc.

◆ isBuiltIn()

bool VuoCompilerModule::isBuiltIn ( void  )

Returns true if this module is one of the built-in modules distributed with Vuo.

Definition at line 382 of file VuoCompilerModule.cc.

◆ isModuleKeyMangledInFileName()

bool VuoCompilerModule::isModuleKeyMangledInFileName ( const string &  fileName)
static

Returns true if a module with the given file name (with extension) would have a module key other than the file name minus extension.

Definition at line 343 of file VuoCompilerModule.cc.

◆ isSpecializedModule()

bool VuoCompilerModule::isSpecializedModule ( Module *  module,
string  moduleKey 
)
staticprotected

Returns true if the moduleDetails global variable within the LLVM module contains a key indicating that it is intended to be a specialized module definition.

Definition at line 106 of file VuoCompilerModule.cc.

◆ nameForGlobal() [1/2]

string VuoCompilerModule::nameForGlobal ( string  genericGlobalVarOrFuncName)
protected

Returns the mangled name for a function or global variable.

Definition at line 212 of file VuoCompilerModule.cc.

◆ nameForGlobal() [2/2]

string VuoCompilerModule::nameForGlobal ( string  nameBeforeCompilation,
string  moduleKey 
)
staticprotected

Returns the mangled name for a function or global variable.

Definition at line 220 of file VuoCompilerModule.cc.

◆ newModule()

VuoCompilerModule * VuoCompilerModule::newModule ( const string &  moduleKey,
Module *  module,
const string &  modulePath,
const VuoCompilerCompatibility moduleCompatibility 
)
static

Instantiates a VuoCompilerModule (or child class) corresponding to the type of VuoCompilerModule defined in the LLVM module.

If no type of VuoCompilerModule is defined, returns NULL.

moduleKey The node class name, type name, or library module key. module The LLVM module containing the module implementation. modulePath The path of the file from which this module was loaded (empty if none). moduleCompatibility Any restrictions to compatibility known just from loading the module (e.g. architecture), not including further restrictions that may be declared in the module's VuoModuleMetadata.

Definition at line 65 of file VuoCompilerModule.cc.

◆ parse()

void VuoCompilerModule::parse ( void  )
protectedvirtual

Renames globals in the LLVM module that might conflict with other VuoCompilerModules, and parses those globals.

Definition at line 124 of file VuoCompilerModule.cc.

◆ parseCompatibility()

VuoCompilerCompatibility VuoCompilerModule::parseCompatibility ( json_object *  o,
string  key 
)
static

Parses the target set value for key in the top level of the JSON object.

If no such value is found, returns an unrestricted target set.

Definition at line 165 of file VuoCompilerModule.cc.

◆ parseGenericTypes()

void VuoCompilerModule::parseGenericTypes ( json_object *  moduleDetails,
vector< string > &  genericTypeNames,
map< string, string > &  defaultSpecializedForGenericTypeName,
map< string, vector< string > > &  compatibleSpecializedForGenericTypeName 
)
static

Parses the "genericTypes" portion of a module's metadata.

Definition at line 177 of file VuoCompilerModule.cc.

◆ parseMetadata()

void VuoCompilerModule::parseMetadata ( void  )
protectedvirtual

Parses the metadata of this VuoCompilerModule (name, description, ...) from the LLVM module.

See also
VuoModuleMetadata

Definition at line 136 of file VuoCompilerModule.cc.

◆ renameGlobalVarsAndFuncs()

void VuoCompilerModule::renameGlobalVarsAndFuncs ( void  )
protected

Renames the global variables and functions within the LLVM module so that they are unique to this VuoCompilerModule.

Definition at line 239 of file VuoCompilerModule.cc.

◆ setBuiltIn()

void VuoCompilerModule::setBuiltIn ( bool  builtIn)

Sets whether this module is one of the built-in modules distributed with Vuo.

Definition at line 390 of file VuoCompilerModule.cc.

◆ setSourceCode()

void VuoCompilerModule::setSourceCode ( const string &  sourceCode)

Stores the source code for this module.

Definition at line 423 of file VuoCompilerModule.cc.

◆ setSourcePath()

void VuoCompilerModule::setSourcePath ( const string &  sourcePath)

Stores the path of the source file for this module.

Definition at line 407 of file VuoCompilerModule.cc.

Friends And Related Symbol Documentation

◆ TestModules

friend class TestModules
friend

Definition at line 57 of file VuoCompilerModule.hh.

◆ TestVuoCompilerModule

friend class TestVuoCompilerModule
friend

Definition at line 56 of file VuoCompilerModule.hh.

Member Data Documentation

◆ compatibleSpecializedForGenericTypeName

map<string, vector<string> > VuoCompilerModule::compatibleSpecializedForGenericTypeName
protected

For generic modules: the types to which each generic type is allowed to be specialized.

Definition at line 54 of file VuoCompilerModule.hh.

◆ compatibleTargets

VuoCompilerCompatibility VuoCompilerModule::compatibleTargets
protected

The set of targets with which this module is compatible.

Definition at line 35 of file VuoCompilerModule.hh.

◆ defaultSpecializedForGenericTypeName

map<string, string> VuoCompilerModule::defaultSpecializedForGenericTypeName
protected

For generic modules: the types to use when creating an unspecialized instance.

Definition at line 53 of file VuoCompilerModule.hh.

◆ dependencies

set<string> VuoCompilerModule::dependencies
protected

The modules and libraries needed to compile a composition containing this module.

Definition at line 34 of file VuoCompilerModule.hh.

◆ makeDependencies

shared_ptr<VuoMakeDependencies> VuoCompilerModule::makeDependencies
protected

The source files needed to compile this module.

Definition at line 40 of file VuoCompilerModule.hh.

◆ moduleDetails

struct json_object* VuoCompilerModule::moduleDetails
protected

This module's metadata, found in the argument to VuoModuleMetadata in the module definition.

Definition at line 33 of file VuoCompilerModule.hh.

◆ parser

Module* VuoCompilerBitcodeParser* VuoCompilerModule::parser
protected

< The LLVM module that defines this node class or type

The parser of the LLVM module

Definition at line 37 of file VuoCompilerModule.hh.

◆ sourceCode

string VuoCompilerModule::sourceCode
protected

The module's source code, if known.

Definition at line 39 of file VuoCompilerModule.hh.

◆ sourcePath

string VuoCompilerModule::sourcePath
protected

The file containing the module's source code, if known.

Definition at line 38 of file VuoCompilerModule.hh.


The documentation for this class was generated from the following files: