mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-08 11:38:21 +02:00
Fixed datalayout initialization
This commit is contained in:
parent
a3848bbd78
commit
b3fe79522e
5 changed files with 142 additions and 128 deletions
|
@ -469,6 +469,7 @@ void BfCodeGenThread::RunLoop()
|
||||||
BP_ZONE_F("BfCodeGen::RunLoop.LLVM %s", request->mOutFileName.c_str());
|
BP_ZONE_F("BfCodeGen::RunLoop.LLVM %s", request->mOutFileName.c_str());
|
||||||
|
|
||||||
BfIRCodeGen* llvmIRCodeGen = new BfIRCodeGen();
|
BfIRCodeGen* llvmIRCodeGen = new BfIRCodeGen();
|
||||||
|
llvmIRCodeGen->SetCodeGenOptions(request->mOptions);
|
||||||
llvmIRCodeGen->SetConfigConst(BfIRConfigConst_VirtualMethodOfs, request->mOptions.mVirtualMethodOfs);
|
llvmIRCodeGen->SetConfigConst(BfIRConfigConst_VirtualMethodOfs, request->mOptions.mVirtualMethodOfs);
|
||||||
llvmIRCodeGen->SetConfigConst(BfIRConfigConst_DynSlotOfs, request->mOptions.mDynSlotOfs);
|
llvmIRCodeGen->SetConfigConst(BfIRConfigConst_DynSlotOfs, request->mOptions.mDynSlotOfs);
|
||||||
llvmIRCodeGen->ProcessBfIRData(request->mData);
|
llvmIRCodeGen->ProcessBfIRData(request->mData);
|
||||||
|
@ -501,7 +502,7 @@ void BfCodeGenThread::RunLoop()
|
||||||
outFileName = request->mOutFileName + ".s";
|
outFileName = request->mOutFileName + ".s";
|
||||||
else
|
else
|
||||||
outFileName = request->mOutFileName + BF_OBJ_EXT;
|
outFileName = request->mOutFileName + BF_OBJ_EXT;
|
||||||
if (!llvmIRCodeGen->WriteObjectFile(outFileName, request->mOptions))
|
if (!llvmIRCodeGen->WriteObjectFile(outFileName))
|
||||||
{
|
{
|
||||||
result.mType = BfCodeGenResult_Failed;
|
result.mType = BfCodeGenResult_Failed;
|
||||||
dirCache->FileFailed();
|
dirCache->FileFailed();
|
||||||
|
|
|
@ -11,6 +11,7 @@ namespace llvm
|
||||||
{
|
{
|
||||||
class Module;
|
class Module;
|
||||||
class LLVMContext;
|
class LLVMContext;
|
||||||
|
class TargetMachine;
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_BF_BEGIN
|
NS_BF_BEGIN
|
||||||
|
|
|
@ -26,24 +26,6 @@
|
||||||
|
|
||||||
#pragma warning(pop)
|
#pragma warning(pop)
|
||||||
|
|
||||||
namespace llvm
|
|
||||||
{
|
|
||||||
class Constant;
|
|
||||||
class Value;
|
|
||||||
class Type;
|
|
||||||
class BasicBlock;
|
|
||||||
class Function;
|
|
||||||
class FunctionType;
|
|
||||||
class MDNode;
|
|
||||||
class InlineAsm;
|
|
||||||
class DIType;
|
|
||||||
class DIBuilder;
|
|
||||||
class DICompileUnit;
|
|
||||||
class AttributeList;
|
|
||||||
class Module;
|
|
||||||
class LLVMContext;
|
|
||||||
};
|
|
||||||
|
|
||||||
NS_BF_BEGIN
|
NS_BF_BEGIN
|
||||||
|
|
||||||
class BfModule;
|
class BfModule;
|
||||||
|
@ -708,11 +690,6 @@ public:
|
||||||
mId = val.mId;
|
mId = val.mId;
|
||||||
}
|
}
|
||||||
|
|
||||||
BfIRMDNode(llvm::MDNode* mdNode)
|
|
||||||
{
|
|
||||||
mId = -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
operator bool() const
|
operator bool() const
|
||||||
{
|
{
|
||||||
return mId != -1;
|
return mId != -1;
|
||||||
|
|
|
@ -320,6 +320,7 @@ BfIRCodeGen::BfIRCodeGen()
|
||||||
{
|
{
|
||||||
mStream = NULL;
|
mStream = NULL;
|
||||||
mBfIRBuilder = NULL;
|
mBfIRBuilder = NULL;
|
||||||
|
mLLVMTargetMachine = NULL;
|
||||||
|
|
||||||
mNopInlineAsm = NULL;
|
mNopInlineAsm = NULL;
|
||||||
mAsmObjectCheckAsm = NULL;
|
mAsmObjectCheckAsm = NULL;
|
||||||
|
@ -356,6 +357,7 @@ BfIRCodeGen::~BfIRCodeGen()
|
||||||
delete mStream;
|
delete mStream;
|
||||||
delete mIRBuilder;
|
delete mIRBuilder;
|
||||||
delete mDIBuilder;
|
delete mDIBuilder;
|
||||||
|
delete mLLVMTargetMachine;
|
||||||
delete mLLVMModule;
|
delete mLLVMModule;
|
||||||
delete mLLVMContext;
|
delete mLLVMContext;
|
||||||
}
|
}
|
||||||
|
@ -1359,6 +1361,100 @@ void BfIRCodeGen::CreateMemSet(llvm::Value* addr, llvm::Value* val, llvm::Value*
|
||||||
mIRBuilder->CreateMemSet(addr, val, size, alignment, isVolatile);
|
mIRBuilder->CreateMemSet(addr, val, size, alignment, isVolatile);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void BfIRCodeGen::InitTarget()
|
||||||
|
{
|
||||||
|
llvm::SMDiagnostic Err;
|
||||||
|
llvm::Triple theTriple = llvm::Triple(mLLVMModule->getTargetTriple());
|
||||||
|
llvm::CodeGenOpt::Level optLvl = llvm::CodeGenOpt::None;
|
||||||
|
|
||||||
|
String cpuName = "";
|
||||||
|
String arch = "";
|
||||||
|
|
||||||
|
// Get the target specific parser.
|
||||||
|
std::string Error;
|
||||||
|
const llvm::Target *theTarget = llvm::TargetRegistry::lookupTarget(arch.c_str(), theTriple, Error);
|
||||||
|
if (!theTarget)
|
||||||
|
{
|
||||||
|
Fail(StrFormat("Failed to create LLVM Target: %s", Error.c_str()));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
llvm::TargetOptions Options = llvm::TargetOptions(); // InitTargetOptionsFromCodeGenFlags();
|
||||||
|
|
||||||
|
String featuresStr;
|
||||||
|
|
||||||
|
if (mCodeGenOptions.mOptLevel == BfOptLevel_O1)
|
||||||
|
{
|
||||||
|
//optLvl = CodeGenOpt::Less;
|
||||||
|
}
|
||||||
|
else if (mCodeGenOptions.mOptLevel == BfOptLevel_O2)
|
||||||
|
optLvl = llvm::CodeGenOpt::Default;
|
||||||
|
else if (mCodeGenOptions.mOptLevel == BfOptLevel_O3)
|
||||||
|
optLvl = llvm::CodeGenOpt::Aggressive;
|
||||||
|
|
||||||
|
if (mCodeGenOptions.mSIMDSetting == BfSIMDSetting_SSE)
|
||||||
|
featuresStr = "+sse";
|
||||||
|
else if (mCodeGenOptions.mSIMDSetting == BfSIMDSetting_SSE2)
|
||||||
|
featuresStr = "+sse2";
|
||||||
|
else if (mCodeGenOptions.mSIMDSetting == BfSIMDSetting_SSE3)
|
||||||
|
featuresStr = "+sse3";
|
||||||
|
else if (mCodeGenOptions.mSIMDSetting == BfSIMDSetting_SSE4)
|
||||||
|
featuresStr = "+sse4";
|
||||||
|
else if (mCodeGenOptions.mSIMDSetting == BfSIMDSetting_SSE41)
|
||||||
|
featuresStr = "+sse4.1";
|
||||||
|
else if (mCodeGenOptions.mSIMDSetting == BfSIMDSetting_AVX)
|
||||||
|
featuresStr = "+avx";
|
||||||
|
else if (mCodeGenOptions.mSIMDSetting == BfSIMDSetting_AVX2)
|
||||||
|
featuresStr = "+avx2";
|
||||||
|
|
||||||
|
llvm::Optional<llvm::Reloc::Model> relocModel;
|
||||||
|
llvm::CodeModel::Model cmModel = llvm::CodeModel::Small;
|
||||||
|
|
||||||
|
switch (mCodeGenOptions.mRelocType)
|
||||||
|
{
|
||||||
|
case BfRelocType_Static:
|
||||||
|
relocModel = llvm::Reloc::Model::DynamicNoPIC;
|
||||||
|
break;
|
||||||
|
case BfRelocType_PIC:
|
||||||
|
relocModel = llvm::Reloc::Model::PIC_;
|
||||||
|
break;
|
||||||
|
case BfRelocType_DynamicNoPIC:
|
||||||
|
relocModel = llvm::Reloc::Model::DynamicNoPIC;
|
||||||
|
break;
|
||||||
|
case BfRelocType_ROPI:
|
||||||
|
relocModel = llvm::Reloc::Model::ROPI;
|
||||||
|
break;
|
||||||
|
case BfRelocType_RWPI:
|
||||||
|
relocModel = llvm::Reloc::Model::RWPI;
|
||||||
|
break;
|
||||||
|
case BfRelocType_ROPI_RWPI:
|
||||||
|
relocModel = llvm::Reloc::Model::ROPI_RWPI;
|
||||||
|
break;
|
||||||
|
default: break;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (mCodeGenOptions.mPICLevel)
|
||||||
|
{
|
||||||
|
case BfPICLevel_Not:
|
||||||
|
mLLVMModule->setPICLevel(llvm::PICLevel::Level::NotPIC);
|
||||||
|
break;
|
||||||
|
case BfPICLevel_Small:
|
||||||
|
mLLVMModule->setPICLevel(llvm::PICLevel::Level::SmallPIC);
|
||||||
|
break;
|
||||||
|
case BfPICLevel_Big:
|
||||||
|
mLLVMModule->setPICLevel(llvm::PICLevel::Level::BigPIC);
|
||||||
|
break;
|
||||||
|
default: break;
|
||||||
|
}
|
||||||
|
|
||||||
|
mLLVMTargetMachine =
|
||||||
|
theTarget->createTargetMachine(theTriple.getTriple(), cpuName.c_str(), featuresStr.c_str(),
|
||||||
|
Options, relocModel, cmModel, optLvl);
|
||||||
|
|
||||||
|
mLLVMModule->setDataLayout(mLLVMTargetMachine->createDataLayout());
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
void BfIRCodeGen::HandleNextCmd()
|
void BfIRCodeGen::HandleNextCmd()
|
||||||
{
|
{
|
||||||
int curId = mCmdCount;
|
int curId = mCmdCount;
|
||||||
|
@ -1392,6 +1488,8 @@ void BfIRCodeGen::HandleNextCmd()
|
||||||
mLLVMModule->setTargetTriple(llvm::sys::getDefaultTargetTriple());
|
mLLVMModule->setTargetTriple(llvm::sys::getDefaultTargetTriple());
|
||||||
else
|
else
|
||||||
mLLVMModule->setTargetTriple(targetTriple.c_str());
|
mLLVMModule->setTargetTriple(targetTriple.c_str());
|
||||||
|
|
||||||
|
InitTarget();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case BfIRCmd_Module_AddModuleFlag:
|
case BfIRCmd_Module_AddModuleFlag:
|
||||||
|
@ -4219,6 +4317,11 @@ void BfIRCodeGen::HandleNextCmd()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void BfIRCodeGen::SetCodeGenOptions(BfCodeGenOptions codeGenOptions)
|
||||||
|
{
|
||||||
|
mCodeGenOptions = codeGenOptions;
|
||||||
|
}
|
||||||
|
|
||||||
void BfIRCodeGen::SetConfigConst(int idx, int value)
|
void BfIRCodeGen::SetConfigConst(int idx, int value)
|
||||||
{
|
{
|
||||||
auto constVal = llvm::ConstantInt::get(llvm::Type::getInt32Ty(*mLLVMContext), value);
|
auto constVal = llvm::ConstantInt::get(llvm::Type::getInt32Ty(*mLLVMContext), value);
|
||||||
|
@ -4819,7 +4922,7 @@ llvm::Expected<llvm::BitcodeModule> FindThinLTOModule(llvm::MemoryBufferRef MBRe
|
||||||
llvm::inconvertibleErrorCode());
|
llvm::inconvertibleErrorCode());
|
||||||
}
|
}
|
||||||
|
|
||||||
bool BfIRCodeGen::WriteObjectFile(const StringImpl& outFileName, const BfCodeGenOptions& codeGenOptions)
|
bool BfIRCodeGen::WriteObjectFile(const StringImpl& outFileName)
|
||||||
{
|
{
|
||||||
// {
|
// {
|
||||||
// PassManagerBuilderWrapper pmBuilder;
|
// PassManagerBuilderWrapper pmBuilder;
|
||||||
|
@ -4829,7 +4932,7 @@ bool BfIRCodeGen::WriteObjectFile(const StringImpl& outFileName, const BfCodeGen
|
||||||
|
|
||||||
mHasDebugLoc = false; // So fails don't show a line number
|
mHasDebugLoc = false; // So fails don't show a line number
|
||||||
|
|
||||||
bool enableLTO = codeGenOptions.mLTOType != BfLTOType_None;
|
bool enableLTO = mCodeGenOptions.mLTOType != BfLTOType_None;
|
||||||
|
|
||||||
if (enableLTO)
|
if (enableLTO)
|
||||||
{
|
{
|
||||||
|
@ -4840,97 +4943,6 @@ bool BfIRCodeGen::WriteObjectFile(const StringImpl& outFileName, const BfCodeGen
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
llvm::CodeGenOpt::Level optLvl = llvm::CodeGenOpt::None;
|
|
||||||
|
|
||||||
llvm::SMDiagnostic Err;
|
|
||||||
llvm::Triple theTriple;
|
|
||||||
|
|
||||||
theTriple = llvm::Triple(mLLVMModule->getTargetTriple());
|
|
||||||
|
|
||||||
String cpuName = "";
|
|
||||||
String arch = "";
|
|
||||||
|
|
||||||
// Get the target specific parser.
|
|
||||||
std::string Error;
|
|
||||||
const llvm::Target *theTarget = llvm::TargetRegistry::lookupTarget(arch.c_str(), theTriple, Error);
|
|
||||||
if (!theTarget)
|
|
||||||
{
|
|
||||||
Fail(StrFormat("Failed to create LLVM Target: %s", Error.c_str()));
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
llvm::TargetOptions Options = llvm::TargetOptions(); // InitTargetOptionsFromCodeGenFlags();
|
|
||||||
|
|
||||||
String featuresStr;
|
|
||||||
|
|
||||||
if (codeGenOptions.mOptLevel == BfOptLevel_O1)
|
|
||||||
{
|
|
||||||
//optLvl = CodeGenOpt::Less;
|
|
||||||
}
|
|
||||||
else if (codeGenOptions.mOptLevel == BfOptLevel_O2)
|
|
||||||
optLvl = llvm::CodeGenOpt::Default;
|
|
||||||
else if (codeGenOptions.mOptLevel == BfOptLevel_O3)
|
|
||||||
optLvl = llvm::CodeGenOpt::Aggressive;
|
|
||||||
|
|
||||||
if (codeGenOptions.mSIMDSetting == BfSIMDSetting_SSE)
|
|
||||||
featuresStr = "+sse";
|
|
||||||
else if (codeGenOptions.mSIMDSetting == BfSIMDSetting_SSE2)
|
|
||||||
featuresStr = "+sse2";
|
|
||||||
else if (codeGenOptions.mSIMDSetting == BfSIMDSetting_SSE3)
|
|
||||||
featuresStr = "+sse3";
|
|
||||||
else if (codeGenOptions.mSIMDSetting == BfSIMDSetting_SSE4)
|
|
||||||
featuresStr = "+sse4";
|
|
||||||
else if (codeGenOptions.mSIMDSetting == BfSIMDSetting_SSE41)
|
|
||||||
featuresStr = "+sse4.1";
|
|
||||||
else if (codeGenOptions.mSIMDSetting == BfSIMDSetting_AVX)
|
|
||||||
featuresStr = "+avx";
|
|
||||||
else if (codeGenOptions.mSIMDSetting == BfSIMDSetting_AVX2)
|
|
||||||
featuresStr = "+avx2";
|
|
||||||
|
|
||||||
llvm::Optional<llvm::Reloc::Model> relocModel;
|
|
||||||
llvm::CodeModel::Model cmModel = llvm::CodeModel::Small;
|
|
||||||
|
|
||||||
switch (codeGenOptions.mRelocType)
|
|
||||||
{
|
|
||||||
case BfRelocType_Static:
|
|
||||||
relocModel = llvm::Reloc::Model::DynamicNoPIC;
|
|
||||||
break;
|
|
||||||
case BfRelocType_PIC:
|
|
||||||
relocModel = llvm::Reloc::Model::PIC_;
|
|
||||||
break;
|
|
||||||
case BfRelocType_DynamicNoPIC:
|
|
||||||
relocModel = llvm::Reloc::Model::DynamicNoPIC;
|
|
||||||
break;
|
|
||||||
case BfRelocType_ROPI:
|
|
||||||
relocModel = llvm::Reloc::Model::ROPI;
|
|
||||||
break;
|
|
||||||
case BfRelocType_RWPI:
|
|
||||||
relocModel = llvm::Reloc::Model::RWPI;
|
|
||||||
break;
|
|
||||||
case BfRelocType_ROPI_RWPI:
|
|
||||||
relocModel = llvm::Reloc::Model::ROPI_RWPI;
|
|
||||||
break;
|
|
||||||
default: break;
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (codeGenOptions.mPICLevel)
|
|
||||||
{
|
|
||||||
case BfPICLevel_Not:
|
|
||||||
mLLVMModule->setPICLevel(llvm::PICLevel::Level::NotPIC);
|
|
||||||
break;
|
|
||||||
case BfPICLevel_Small:
|
|
||||||
mLLVMModule->setPICLevel(llvm::PICLevel::Level::SmallPIC);
|
|
||||||
break;
|
|
||||||
case BfPICLevel_Big:
|
|
||||||
mLLVMModule->setPICLevel(llvm::PICLevel::Level::BigPIC);
|
|
||||||
break;
|
|
||||||
default: break;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::unique_ptr<llvm::TargetMachine> target(
|
|
||||||
theTarget->createTargetMachine(theTriple.getTriple(), cpuName.c_str(), featuresStr.c_str(),
|
|
||||||
Options, relocModel, cmModel, optLvl));
|
|
||||||
|
|
||||||
std::error_code EC;
|
std::error_code EC;
|
||||||
llvm::sys::fs::OpenFlags OpenFlags = llvm::sys::fs::F_None;
|
llvm::sys::fs::OpenFlags OpenFlags = llvm::sys::fs::F_None;
|
||||||
|
|
||||||
|
@ -4941,20 +4953,20 @@ bool BfIRCodeGen::WriteObjectFile(const StringImpl& outFileName, const BfCodeGen
|
||||||
// Build up all of the passes that we want to do to the module.
|
// Build up all of the passes that we want to do to the module.
|
||||||
llvm::legacy::PassManager PM;
|
llvm::legacy::PassManager PM;
|
||||||
|
|
||||||
|
llvm::Triple theTriple = llvm::Triple(mLLVMModule->getTargetTriple());
|
||||||
// Add an appropriate TargetLibraryInfo pass for the module's triple.
|
// Add an appropriate TargetLibraryInfo pass for the module's triple.
|
||||||
llvm::TargetLibraryInfoImpl TLII(theTriple);
|
llvm::TargetLibraryInfoImpl TLII(theTriple);
|
||||||
|
|
||||||
PM.add(new llvm::TargetLibraryInfoWrapperPass(TLII));
|
PM.add(new llvm::TargetLibraryInfoWrapperPass(TLII));
|
||||||
|
|
||||||
// Add the target data from the target machine, if it exists, or the module.
|
// Add the target data from the target machine, if it exists, or the module.
|
||||||
mLLVMModule->setDataLayout(target->createDataLayout());
|
|
||||||
//PM.add(new DataLayoutPass());
|
//PM.add(new DataLayoutPass());
|
||||||
PopulateModulePassManager(PM, codeGenOptions);
|
PopulateModulePassManager(PM, mCodeGenOptions);
|
||||||
|
|
||||||
llvm::raw_fd_ostream* outStream = NULL;
|
llvm::raw_fd_ostream* outStream = NULL;
|
||||||
defer ( delete outStream; );
|
defer ( delete outStream; );
|
||||||
|
|
||||||
if ((enableLTO) || (codeGenOptions.mWriteBitcode))
|
if ((enableLTO) || (mCodeGenOptions.mWriteBitcode))
|
||||||
{
|
{
|
||||||
std::error_code ec;
|
std::error_code ec;
|
||||||
outStream = new llvm::raw_fd_ostream(outFileName.c_str(), ec, llvm::sys::fs::F_None);
|
outStream = new llvm::raw_fd_ostream(outFileName.c_str(), ec, llvm::sys::fs::F_None);
|
||||||
|
@ -4990,11 +5002,11 @@ bool BfIRCodeGen::WriteObjectFile(const StringImpl& outFileName, const BfCodeGen
|
||||||
//WriteBitcode
|
//WriteBitcode
|
||||||
bool noVerify = false; // Option
|
bool noVerify = false; // Option
|
||||||
|
|
||||||
if ((!enableLTO) && (!codeGenOptions.mWriteBitcode))
|
if ((!enableLTO) && (!mCodeGenOptions.mWriteBitcode))
|
||||||
{
|
{
|
||||||
// Ask the target to add backend passes as necessary.
|
// Ask the target to add backend passes as necessary.
|
||||||
if (target->addPassesToEmitFile(PM, out, NULL,
|
if (mLLVMTargetMachine->addPassesToEmitFile(PM, out, NULL,
|
||||||
(codeGenOptions.mAsmKind != BfAsmKind_None) ? llvm::TargetMachine::CGFT_AssemblyFile : llvm::TargetMachine::CGFT_ObjectFile,
|
(mCodeGenOptions.mAsmKind != BfAsmKind_None) ? llvm::TargetMachine::CGFT_AssemblyFile : llvm::TargetMachine::CGFT_ObjectFile,
|
||||||
//TargetMachine::CGFT_AssemblyFile,
|
//TargetMachine::CGFT_AssemblyFile,
|
||||||
noVerify /*, StartAfterID, StopAfterID*/))
|
noVerify /*, StartAfterID, StopAfterID*/))
|
||||||
{
|
{
|
||||||
|
@ -5007,7 +5019,7 @@ bool BfIRCodeGen::WriteObjectFile(const StringImpl& outFileName, const BfCodeGen
|
||||||
|
|
||||||
bool success = PM.run(*mLLVMModule);
|
bool success = PM.run(*mLLVMModule);
|
||||||
|
|
||||||
if ((codeGenOptions.mOptLevel > BfOptLevel_O0) && (codeGenOptions.mWriteLLVMIR))
|
if ((mCodeGenOptions.mOptLevel > BfOptLevel_O0) && (mCodeGenOptions.mWriteLLVMIR))
|
||||||
{
|
{
|
||||||
BP_ZONE("BfCodeGen::RunLoop.LLVM.IR");
|
BP_ZONE("BfCodeGen::RunLoop.LLVM.IR");
|
||||||
String fileName = outFileName;
|
String fileName = outFileName;
|
||||||
|
|
|
@ -4,6 +4,25 @@
|
||||||
#include "BfSystem.h"
|
#include "BfSystem.h"
|
||||||
#include "BfTargetTriple.h"
|
#include "BfTargetTriple.h"
|
||||||
|
|
||||||
|
namespace llvm
|
||||||
|
{
|
||||||
|
class Constant;
|
||||||
|
class Value;
|
||||||
|
class Type;
|
||||||
|
class BasicBlock;
|
||||||
|
class Function;
|
||||||
|
class FunctionType;
|
||||||
|
class MDNode;
|
||||||
|
class InlineAsm;
|
||||||
|
class DIType;
|
||||||
|
class DIBuilder;
|
||||||
|
class DICompileUnit;
|
||||||
|
class AttributeList;
|
||||||
|
class Module;
|
||||||
|
class LLVMContext;
|
||||||
|
class TargetMachine;
|
||||||
|
};
|
||||||
|
|
||||||
NS_BF_BEGIN
|
NS_BF_BEGIN
|
||||||
|
|
||||||
enum BfIRCodeGenEntryKind
|
enum BfIRCodeGenEntryKind
|
||||||
|
@ -72,10 +91,12 @@ public:
|
||||||
llvm::AttributeList* mAttrSet;
|
llvm::AttributeList* mAttrSet;
|
||||||
llvm::DIBuilder* mDIBuilder;
|
llvm::DIBuilder* mDIBuilder;
|
||||||
llvm::DICompileUnit* mDICompileUnit;
|
llvm::DICompileUnit* mDICompileUnit;
|
||||||
|
llvm::TargetMachine* mLLVMTargetMachine;
|
||||||
Array<llvm::DebugLoc> mSavedDebugLocs;
|
Array<llvm::DebugLoc> mSavedDebugLocs;
|
||||||
llvm::InlineAsm* mNopInlineAsm;
|
llvm::InlineAsm* mNopInlineAsm;
|
||||||
llvm::InlineAsm* mAsmObjectCheckAsm;
|
llvm::InlineAsm* mAsmObjectCheckAsm;
|
||||||
llvm::DebugLoc mDebugLoc;
|
llvm::DebugLoc mDebugLoc;
|
||||||
|
BfCodeGenOptions mCodeGenOptions;
|
||||||
bool mHasDebugLoc;
|
bool mHasDebugLoc;
|
||||||
bool mIsCodeView;
|
bool mIsCodeView;
|
||||||
int mConstValIdx;
|
int mConstValIdx;
|
||||||
|
@ -89,6 +110,7 @@ public:
|
||||||
Array<llvm::Constant*> mConfigConsts64;
|
Array<llvm::Constant*> mConfigConsts64;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
void InitTarget();
|
||||||
void FixValues(llvm::StructType* structType, llvm::SmallVector<llvm::Value*, 8>& values);
|
void FixValues(llvm::StructType* structType, llvm::SmallVector<llvm::Value*, 8>& values);
|
||||||
BfTypeCode GetTypeCode(llvm::Type* type, bool isSigned);
|
BfTypeCode GetTypeCode(llvm::Type* type, bool isSigned);
|
||||||
llvm::Type* GetLLVMType(BfTypeCode typeCode, bool& isSigned);
|
llvm::Type* GetLLVMType(BfTypeCode typeCode, bool& isSigned);
|
||||||
|
@ -145,6 +167,7 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
void HandleNextCmd() override;
|
void HandleNextCmd() override;
|
||||||
|
void SetCodeGenOptions(BfCodeGenOptions codeGenOptions);
|
||||||
void SetConfigConst(int idx, int value) override;
|
void SetConfigConst(int idx, int value) override;
|
||||||
|
|
||||||
llvm::Value* GetLLVMValue(int streamId);
|
llvm::Value* GetLLVMValue(int streamId);
|
||||||
|
@ -156,7 +179,7 @@ public:
|
||||||
|
|
||||||
///
|
///
|
||||||
|
|
||||||
bool WriteObjectFile(const StringImpl& outFileName, const BfCodeGenOptions& codeGenOptions);
|
bool WriteObjectFile(const StringImpl& outFileName);
|
||||||
bool WriteIR(const StringImpl& outFileName, StringImpl& error);
|
bool WriteIR(const StringImpl& outFileName, StringImpl& error);
|
||||||
|
|
||||||
static int GetIntrinsicId(const StringImpl& name);
|
static int GetIntrinsicId(const StringImpl& name);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue