1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-06-10 12:32:20 +02:00

Added bitcode emission, additional logging

This commit is contained in:
Brian Fiete 2019-10-29 04:56:42 -07:00
parent 1e8c633a36
commit 43b69023f6
14 changed files with 74 additions and 31 deletions

View file

@ -8207,6 +8207,7 @@ BF_EXPORT void BF_CALLTYPE BfCompiler_SetOptions(BfCompiler* bfCompiler, BfProje
options->mIncrementalBuild = (optionFlags & BfCompilerOptionFlag_IncrementalBuild) != 0;
options->mWriteIR = (optionFlags & BfCompilerOptionFlag_WriteIR) != 0;
options->mGenerateObj = (optionFlags & BfCompilerOptionFlag_GenerateOBJ) != 0;
options->mGenerateBitcode = (optionFlags & BfCompilerOptionFlag_GenerateBitcode) != 0;
options->mNoFramePointerElim = (optionFlags & BfCompilerOptionFlag_NoFramePointerElim) != 0;
options->mInitLocalVariables = (optionFlags & BfCompilerOptionFlag_ClearLocalVars) != 0;
options->mRuntimeChecks = (optionFlags & BfCompilerOptionFlag_RuntimeChecks) != 0;
@ -8279,3 +8280,4 @@ BF_EXPORT void BF_CALLTYPE BfCompiler_ForceRebuild(BfCompiler* bfCompiler)
bfCompiler->mOptions.mForceRebuildIdx++;
}

View file

@ -98,8 +98,7 @@ public:
BfMachineType mMachineType;
int mCLongSize;
BfToolsetType mToolsetType;
BfSIMDSetting mSIMDSetting;
int mMaxWorkerThreads;
BfSIMDSetting mSIMDSetting;
String mMallocLinkName;
String mFreeLinkName;
bool mIncrementalBuild;
@ -127,6 +126,7 @@ public:
bool mWriteIR;
bool mGenerateObj;
bool mGenerateBitcode;
int mAllocStackCount;
bool mExtraResolveChecks;
@ -164,6 +164,7 @@ public:
mEnableRealtimeLeakCheck = false;
mWriteIR = false;
mGenerateObj = true;
mGenerateBitcode = false;
mEnableCustodian = false;
mEnableSideStack = false;
mHasVDataExtender = false;

View file

@ -3948,7 +3948,7 @@ bool BfIRCodeGen::WriteObjectFile(const StringImpl& outFileName, const BfCodeGen
mHasDebugLoc = false; // So fails don't show a line number
bool enableLTO = codeGenOptions.mLTOType != BfLTOType_None;
bool enableLTO = codeGenOptions.mLTOType != BfLTOType_None;
if (enableLTO)
{
@ -4070,8 +4070,8 @@ bool BfIRCodeGen::WriteObjectFile(const StringImpl& outFileName, const BfCodeGen
llvm::raw_fd_ostream* outStream = NULL;
defer ( delete outStream; );
if (enableLTO)
if ((enableLTO) || (codeGenOptions.mWriteBitcode))
{
std::error_code ec;
outStream = new llvm::raw_fd_ostream(outFileName.c_str(), ec, llvm::sys::fs::F_None);
@ -4079,10 +4079,12 @@ bool BfIRCodeGen::WriteObjectFile(const StringImpl& outFileName, const BfCodeGen
{
return false;
}
//PM.add()
PM.add(createWriteThinLTOBitcodePass(*outStream, NULL));
}
if (enableLTO)
PM.add(createWriteThinLTOBitcodePass(*outStream, NULL));
else
PM.add(createBitcodeWriterPass(*outStream, false, false, false));
}
//TargetPassConfig *PassConfig = target->createPassConfig(PM);
//PM.add(new BfPass());
@ -4105,7 +4107,7 @@ bool BfIRCodeGen::WriteObjectFile(const StringImpl& outFileName, const BfCodeGen
//WriteBitcode
bool noVerify = false; // Option
if (!enableLTO)
if ((!enableLTO) && (!codeGenOptions.mWriteBitcode))
{
// Ask the target to add backend passes as necessary.
if (target->addPassesToEmitFile(PM, out, NULL,

View file

@ -20478,6 +20478,7 @@ bool BfModule::Finish()
codeGenOptions.mSIMDSetting = moduleOptions.mSIMDSetting;
codeGenOptions.mWriteLLVMIR = mCompiler->mOptions.mWriteIR;
codeGenOptions.mWriteObj = mCompiler->mOptions.mGenerateObj;
codeGenOptions.mWriteBitcode = mCompiler->mOptions.mGenerateBitcode;
codeGenOptions.mVirtualMethodOfs = 1 + mCompiler->GetDynCastVDataCount() + mCompiler->mMaxInterfaceSlots;
codeGenOptions.mDynSlotOfs = mSystem->mPtrSize - mCompiler->GetDynCastVDataCount() * 4;
@ -20525,7 +20526,7 @@ bool BfModule::Finish()
{
moduleFileName.mFileName = irOutputPath;
}
else if ((!mCompiler->mOptions.mGenerateObj) && (!mCompiler->mOptions.mWriteIR))
else if ((!mCompiler->mOptions.mGenerateObj) && (!mCompiler->mOptions.mGenerateBitcode) && (!mCompiler->mOptions.mWriteIR))
{
BF_FATAL("Neither obj nor IR specified");
}

View file

@ -458,7 +458,7 @@ void BfParser::Init(uint64 cacheHash)
mParserData->mAstAllocManager = &gBfParserCache->mAstAllocManager;
mParserData->mSrc = mSrc;
mParserData->mSrcLength = mSrcLength;
if (cacheHash != 0)
{
BfLogSysM("Creating cached parserData %p for %p %s\n", mParserData, this, mFileName.c_str());

View file

@ -3290,7 +3290,7 @@ BF_EXPORT void BF_CALLTYPE BfSystem_DeleteParser(BfSystem* bfSystem, BfParser* b
{
for (auto typeDef : bfParser->mTypeDefs)
{
BfLogSys(bfSystem, "BfSystem_DeleteParser deleting typeDef %p\n", typeDef);
BfLogSys(bfSystem, "BfSystem_DeleteParser %p deleting typeDef %p\n", bfParser, typeDef);
typeDef->mDefState = BfTypeDef::DefState_Deleted;
}
}
@ -3815,3 +3815,9 @@ BF_EXPORT void BF_CALLTYPE BfSystem_FixTypes(BfSystem* bfSystem)
fixTypesHelper.mBfSystem = bfSystem;
fixTypesHelper.Fix();
}
BF_EXPORT void BF_CALLTYPE BfSystem_Log(BfSystem* bfSystem, char* str)
{
BfLogSys(bfSystem, str);
BfLogSys(bfSystem, "\n");
}

View file

@ -143,7 +143,7 @@ enum BfCompilerOptionFlags
BfCompilerOptionFlag_EmitLineInfo = 2,
BfCompilerOptionFlag_WriteIR = 4,
BfCompilerOptionFlag_GenerateOBJ = 8,
BfCompilerOptionFlag_NoFramePointerElim = 0x10,
BfCompilerOptionFlag_GenerateBitcode = 0x10,
BfCompilerOptionFlag_ClearLocalVars = 0x20,
BfCompilerOptionFlag_RuntimeChecks = 0x40,
BfCompilerOptionFlag_EmitDynamicCastCheck = 0x80,
@ -151,11 +151,12 @@ enum BfCompilerOptionFlags
BfCompilerOptionFlag_EmitObjectAccessCheck = 0x200,
BfCompilerOptionFlag_EnableCustodian = 0x400,
BfCompilerOptionFlag_EnableRealtimeLeakCheck = 0x800,
BfCompilerOptionFlag_EnableSideStack = 0x1000,
BfCompilerOptionFlag_EnableHotSwapping = 0x2000,
BfCompilerOptionFlag_IncrementalBuild = 0x4000,
BfCompilerOptionFlag_DebugAlloc = 0x8000,
BfCompilerOptionFlag_OmitDebugHelpers = 0x10000
BfCompilerOptionFlag_EnableSideStack = 0x1000,
BfCompilerOptionFlag_EnableHotSwapping = 0x2000,
BfCompilerOptionFlag_IncrementalBuild = 0x4000,
BfCompilerOptionFlag_DebugAlloc = 0x8000,
BfCompilerOptionFlag_OmitDebugHelpers = 0x10000,
BfCompilerOptionFlag_NoFramePointerElim = 0x20000,
};
enum BfTypeFlags
@ -300,6 +301,7 @@ struct BfCodeGenOptions
bool mIsHotCompile;
bool mWriteObj;
bool mWriteBitcode;
BfAsmKind mAsmKind;
bool mWriteToLib;
bool mWriteLLVMIR;
@ -354,6 +356,7 @@ struct BfCodeGenOptions
{
mIsHotCompile = false;
mWriteObj = true;
mWriteBitcode = false;
mAsmKind = BfAsmKind_None;
mWriteToLib = false;
mWriteLLVMIR = false;