OpenASIP 2.2
|
#include <LLVMBackend.hh>
Public Member Functions | |
LLVMBackend (bool useInstalledVersion, TCEString tempDir) | |
virtual | ~LLVMBackend () |
void | setMachine (TTAMachine::Machine &target) |
TTAProgram::Program * | compile (const std::string &bytecodeFile, const std::string &emulationBytecodeFile, int optLevel, bool debug=false, InterPassData *ipData=NULL) |
TTAProgram::Program * | compile (llvm::Module &module, llvm::Module *emulationModule, llvm::TCETargetMachinePlugin &plugin, int optLevel, bool debug=false, InterPassData *ipData=NULL) |
TTAProgram::Program * | schedule (const std::string &bytecodeFile, const std::string &emulationBytecodeFile, int optLevel=2, bool debug=false, SchedulingPlan *plan=NULL) |
llvm::TCETargetMachinePlugin * | createPlugin () |
std::string | pluginFilename () |
Static Public Member Functions | |
static OperationDAGSelector::OperationSet | llvmRequiredOpset (bool includeFloatOps, bool isLittleEndian, bool bits64) |
Private Member Functions | |
unsigned | maxAllocaAlignment (const llvm::Module &mod) const |
Private Attributes | |
bool | useInstalledVersion_ |
Assume we are running an installed TCE version. | |
PluginTools | pluginTool_ |
Plugin tool for loading target machine plugin. | |
TCEString | cachePath_ |
Path to the cache where precompiled plugins are stored. | |
TCEString | tempDir_ |
Directory to store temporary files. | |
LLVMTCECmdLineOptions * | options_ |
InterPassData * | ipData_ |
TTAMachine::Machine * | mach_ |
TDGen * | pluginGen_ |
Static Private Attributes | |
static const std::string | TBLGEN_INCLUDES = "" |
static const std::string | PLUGIN_PREFIX = "tcecc-" |
static const std::string | PLUGIN_SUFFIX = ".so" |
static const TCEString | CXX0X_FLAG = "-std=c++0x" |
static const TCEString | CXX11_FLAG = "-std=c++11" |
static const TCEString | CXX14_FLAG = "-std=c++14" |
static const TCEString | CXX17_FLAG = "-std=c++17" |
LLVM compiler backend and compiler interface for TCE.
Definition at line 64 of file LLVMBackend.hh.
LLVMBackend::LLVMBackend | ( | bool | useInstalledVersion, |
TCEString | tempDir | ||
) |
Constructor.
useInstalledVersion | Should be true in case we are running an installed TCE (not from the source/build tree). |
tempDir | An existing directory where to store temporary files. The directory should be removed by the caller after use. |
Definition at line 325 of file LLVMBackend.cc.
References LLVMTCECmdLineOptions::backendCacheDir(), cachePath_, Application::cmdLineOptions(), Environment::llvmtceCachePath(), and options_.
|
virtual |
TTAProgram::Program * LLVMBackend::compile | ( | const std::string & | bytecodeFile, |
const std::string & | emulationBytecodeFile, | ||
int | optLevel, | ||
bool | debug = false , |
||
InterPassData * | ipData = NULL |
||
) |
Compiles bytecode for the given target machine.
bytecodeFile | Full path to the llvm bytecode file to compile. |
optLevel | Optimization level. |
debug | If true, enable LLVM debug printing. |
Definition at line 381 of file LLVMBackend.cc.
References __func__, assert, cachePath_, compile(), createPlugin(), DS, MachineValidatorResults::error(), MachineValidatorResults::errorCount(), MachineValidator::FU_PORT_MISSING, MachineValidator::GCU_AS_MISSING, MachineValidator::GCU_MISSING, mach_, options_, MachineValidator::PC_PORT_MISSING, pluginFilename(), MachineValidator::RA_PORT_MISSING, FileSystem::removeFileOrDirectory(), LLVMTCECmdLineOptions::saveBackendPlugin(), THROW_EXCEPTION, MachineValidator::USED_IO_NOT_BOUND, and MachineValidator::validate().
Referenced by compile(), and main().
TTAProgram::Program * LLVMBackend::compile | ( | llvm::Module & | module, |
llvm::Module * | emulationModule, | ||
llvm::TCETargetMachinePlugin & | plugin, | ||
int | optLevel, | ||
bool | debug = false , |
||
InterPassData * | ipData = NULL |
||
) |
Compiles given llvm program module for target machine using the given target machine plugin.
module | LLVM module to compile. |
plugin | Target architecture compiler plugin. |
optLevel | Optimization level. |
debug | If true, enable LLVM debug printing. |
This is quite straight copy how llc actually creates passes for target.
Definition at line 599 of file LLVMBackend.cc.
References abortWithError, addPass, assert, LLVMTCECmdLineOptions::assumeADFStackAlignment(), createTCEMCInstrInfo(), createTCEMCRegisterInfo(), createTCEMCSubtargetInfo(), llvm::LLVMTCEBuilder::deleteDeadProcedures(), Exception::errorMessageStack(), llvm::TCETargetMachinePlugin::fpDRegNum(), llvm::TCETargetMachinePlugin::getParamDRegNums(), llvm::TCETargetMachinePlugin::getVectorRVDRegNums(), PluginTools::importSymbol(), LLVMTCECmdLineOptions::initialStackPointerValue(), ipData_, TTAMachine::Machine::is64bit(), LLVMTCECmdLineOptions::isInitialStackPointerValueSet(), TTAMachine::Machine::isLittleEndian(), llvm::LLVMTCEBuilder::isProgramUsingRestrictedPointers(), LLVMTCECmdLineOptions::isWorkItemAAFileDefined(), LLVMInitializeTCETarget(), LLVMInitializeTCETargetInfo(), Application::logStream(), mach_, maxAllocaAlignment(), MachineInfo::maxMemoryAlignment(), options_, pluginTool_, llvm::TCETargetMachinePlugin::registerIndex(), llvm::LLVMTCEBuilder::result(), llvm::TCETargetMachinePlugin::rfName(), llvm::TCETargetMachinePlugin::rvDRegNum(), InterPassData::setDatum(), llvm::TCETargetMachine::setEmulationModule(), llvm::LLVMTCEBuilder::setInitialStackPointerValue(), llvm::LLVMTCEIRBuilder::setInnerLoopFinder(), llvm::TCETargetMachine::setStackAlignment(), llvm::TCETargetMachine::setTargetMachinePlugin(), llvm::TCETargetMachinePlugin::spDRegNum(), Application::verboseLevel(), and LLVMTCECmdLineOptions::workItemAAFile().
TCETargetMachinePlugin * LLVMBackend::createPlugin | ( | ) |
Creates TCETargetMachinePlugin for target architecture.
Definition at line 829 of file LLVMBackend.cc.
References __func__, PluginTools::addSearchPath(), assert, cachePath_, FileSystem::createDirectory(), CXX14_FLAG, CXX17_FLAG, FileSystem::DIRECTORY_SEPARATOR, DS, Exception::errorMessage(), FileSystem::fileExists(), FileSystem::fileIsDirectory(), FileSystem::fileIsReadable(), TDGen::generateBackend(), PluginTools::importSymbol(), Application::installationDir(), TTAMachine::Machine::is64bit(), TTAMachine::Machine::isLittleEndian(), Application::logStream(), mach_, options_, pluginFilename(), pluginGen_, pluginTool_, PluginTools::registerModule(), Exception::setCause(), TBLGEN_INCLUDES, tempDir_, useInstalledVersion_, LLVMTCECmdLineOptions::useOldBackendSources(), and Application::verboseLevel().
Referenced by compile().
|
static |
Returns minimum opset that is required by llvm.
Definition at line 151 of file LLVMBackend.cc.
Referenced by TDGen::writeInstrInfo().
|
private |
Ripped from LLVMTargetMachine.cpp
static void printAndVerify(PassManagerBase &PM, bool allowDoubleDefs = false, bool printMF = false) { if (printMF) { PM.add(createMachineFunctionPrinterPass(cerr)); } PM.add(createMachineVerifierPass(allowDoubleDefs)); } Finds the maximum alignment of an alloca in the module.
Used to align the stack for the program image.
Definition at line 531 of file LLVMBackend.cc.
Referenced by compile().
std::string LLVMBackend::pluginFilename | ( | ) |
Returns (hopefully) unique plugin filename for target architecture.
The filename includes also the TCE version string to avoid problems with incompatible backend plugins between TCE revisions. The filename is used for cached plugins.
Definition at line 1121 of file LLVMBackend.cc.
References assert, TDGen::generateBackend(), PLUGIN_SUFFIX, pluginGen_, Application::TCEVersionString(), and Conversion::toHexString().
Referenced by compile(), and createPlugin().
TTAProgram::Program * LLVMBackend::schedule | ( | const std::string & | bytecodeFile, |
const std::string & | emulationBytecodeFile, | ||
int | optLevel = 2 , |
||
bool | debug = false , |
||
SchedulingPlan * | plan = NULL |
||
) |
void LLVMBackend::setMachine | ( | TTAMachine::Machine & | target | ) |
Sets the target machine and creates a plugin generator for it.
target | The target machine |
Definition at line 365 of file LLVMBackend.cc.
References mach_, and pluginGen_.
Referenced by main().
|
private |
Path to the cache where precompiled plugins are stored.
Definition at line 102 of file LLVMBackend.hh.
Referenced by compile(), createPlugin(), and LLVMBackend().
|
staticprivate |
Definition at line 115 of file LLVMBackend.hh.
|
staticprivate |
Definition at line 116 of file LLVMBackend.hh.
|
staticprivate |
Definition at line 117 of file LLVMBackend.hh.
Referenced by createPlugin().
|
staticprivate |
Definition at line 118 of file LLVMBackend.hh.
Referenced by createPlugin().
|
private |
Definition at line 108 of file LLVMBackend.hh.
Referenced by compile().
|
private |
Definition at line 109 of file LLVMBackend.hh.
Referenced by compile(), compile(), createPlugin(), and setMachine().
|
private |
Definition at line 106 of file LLVMBackend.hh.
Referenced by compile(), compile(), createPlugin(), and LLVMBackend().
|
staticprivate |
Definition at line 113 of file LLVMBackend.hh.
|
staticprivate |
Definition at line 114 of file LLVMBackend.hh.
Referenced by pluginFilename().
|
private |
Definition at line 110 of file LLVMBackend.hh.
Referenced by createPlugin(), pluginFilename(), setMachine(), and ~LLVMBackend().
|
private |
Plugin tool for loading target machine plugin.
Definition at line 100 of file LLVMBackend.hh.
Referenced by compile(), and createPlugin().
|
staticprivate |
Definition at line 112 of file LLVMBackend.hh.
Referenced by createPlugin().
|
private |
Directory to store temporary files.
Definition at line 104 of file LLVMBackend.hh.
Referenced by createPlugin().
|
private |
Assume we are running an installed TCE version.
Definition at line 97 of file LLVMBackend.hh.
Referenced by createPlugin().