mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-10 20:42:21 +02:00
Added Android support, and generalized target triple support
Added PICLevel, RelocKind DarwinCommon/LinuxCommon/AndroidCommon merged into PosixCommon Mangling changed to avoid '@'
This commit is contained in:
parent
7a27ab75bf
commit
3883a3674d
39 changed files with 3457 additions and 5636 deletions
|
@ -1582,7 +1582,7 @@ void BfCompiler::CreateVData(BfVDataModule* bfModule)
|
|||
BfIRFunctionType mainFuncType;
|
||||
BfIRFunction mainFunc;
|
||||
if ((project->mTargetType == BfTargetType_BeefConsoleApplication) || (project->mTargetType == BfTargetType_BeefTest))
|
||||
{
|
||||
{
|
||||
SmallVector<BfIRType, 2> paramTypes;
|
||||
paramTypes.push_back(int32Type);
|
||||
paramTypes.push_back(nullPtrType);
|
||||
|
@ -1598,7 +1598,7 @@ void BfCompiler::CreateVData(BfVDataModule* bfModule)
|
|||
paramTypes.push_back(nullPtrType); // lpvReserved
|
||||
mainFuncType = bfModule->mBfIRBuilder->CreateFunctionType(int32Type, paramTypes, false);
|
||||
mainFunc = bfModule->mBfIRBuilder->CreateFunction(mainFuncType, BfIRLinkageType_External, "DllMain");
|
||||
if (mSystem->mPtrSize == 4)
|
||||
if (mOptions.mMachineType == BfMachineType_x86)
|
||||
bfModule->mBfIRBuilder->SetFuncCallingConv(mainFunc, BfIRCallingConv_StdCall);
|
||||
bfModule->SetupIRMethod(NULL, mainFunc, false);
|
||||
}
|
||||
|
@ -1611,7 +1611,7 @@ void BfCompiler::CreateVData(BfVDataModule* bfModule)
|
|||
paramTypes.push_back(int32Type); // nCmdShow
|
||||
mainFuncType = bfModule->mBfIRBuilder->CreateFunctionType(int32Type, paramTypes, false);
|
||||
mainFunc = bfModule->mBfIRBuilder->CreateFunction(mainFuncType, BfIRLinkageType_External, "WinMain");
|
||||
if (mSystem->mPtrSize == 4)
|
||||
if (mOptions.mMachineType == BfMachineType_x86)
|
||||
bfModule->mBfIRBuilder->SetFuncCallingConv(mainFunc, BfIRCallingConv_StdCall);
|
||||
bfModule->SetupIRMethod(NULL, mainFunc, false);
|
||||
}
|
||||
|
@ -1620,7 +1620,7 @@ void BfCompiler::CreateVData(BfVDataModule* bfModule)
|
|||
SmallVector<BfIRType, 2> paramTypes;
|
||||
paramTypes.push_back(int32Type);
|
||||
paramTypes.push_back(nullPtrType);
|
||||
mainFuncType = bfModule->mBfIRBuilder->CreateFunctionType(voidType, paramTypes, false);
|
||||
mainFuncType = bfModule->mBfIRBuilder->CreateFunctionType(int32Type, paramTypes, false);
|
||||
mainFunc = bfModule->mBfIRBuilder->CreateFunction(mainFuncType, BfIRLinkageType_External, "BeefMain");
|
||||
bfModule->SetupIRMethod(NULL, mainFunc, false);
|
||||
}
|
||||
|
@ -1711,7 +1711,8 @@ void BfCompiler::CreateVData(BfVDataModule* bfModule)
|
|||
}
|
||||
|
||||
BfIRValue retValue;
|
||||
if ((project->mTargetType == BfTargetType_BeefConsoleApplication) || (project->mTargetType == BfTargetType_BeefWindowsApplication))
|
||||
if ((project->mTargetType == BfTargetType_BeefConsoleApplication) || (project->mTargetType == BfTargetType_BeefWindowsApplication) ||
|
||||
(project->mTargetType == BfTargetType_BeefApplication_StaticLib) || (project->mTargetType == BfTargetType_BeefApplication_DynamicLib))
|
||||
{
|
||||
bool hadRet = false;
|
||||
|
||||
|
@ -1785,7 +1786,7 @@ void BfCompiler::CreateVData(BfVDataModule* bfModule)
|
|||
}
|
||||
BfIRFunctionType thunkFuncType = bfModule->mBfIRBuilder->CreateFunctionType(int32Type, paramTypes, false);
|
||||
|
||||
BfIRFunction thunkMainFunc = bfModule->mBfIRBuilder->CreateFunction(thunkFuncType, BfIRLinkageType_External, "BeefMain");
|
||||
BfIRFunction thunkMainFunc = bfModule->mBfIRBuilder->CreateFunction(thunkFuncType, BfIRLinkageType_External, "BeefStartProgram");
|
||||
bfModule->SetupIRMethod(NULL, thunkMainFunc, false);
|
||||
bfModule->mBfIRBuilder->SetActiveFunction(thunkMainFunc);
|
||||
|
||||
|
@ -5879,7 +5880,8 @@ bool BfCompiler::DoCompile(const StringImpl& outputDirectory)
|
|||
if ((bfProject->mTargetType != BfTargetType_BeefConsoleApplication) && (bfProject->mTargetType != BfTargetType_BeefWindowsApplication) &&
|
||||
(bfProject->mTargetType != BfTargetType_BeefDynLib) &&
|
||||
(bfProject->mTargetType != BfTargetType_C_ConsoleApplication) && (bfProject->mTargetType != BfTargetType_C_WindowsApplication) &&
|
||||
(bfProject->mTargetType != BfTargetType_BeefTest))
|
||||
(bfProject->mTargetType != BfTargetType_BeefTest) &&
|
||||
(bfProject->mTargetType != BfTargetType_BeefApplication_StaticLib) && (bfProject->mTargetType != BfTargetType_BeefApplication_DynamicLib))
|
||||
continue;
|
||||
|
||||
if (bfProject->mTargetType == BfTargetType_BeefTest)
|
||||
|
@ -8122,6 +8124,38 @@ BF_EXPORT const char* BF_CALLTYPE BfCompiler_HotResolve_Finish(BfCompiler* bfCom
|
|||
return outString.c_str();
|
||||
}
|
||||
|
||||
static BfPlatformType GetPlatform(StringView str)
|
||||
{
|
||||
while (!str.IsEmpty())
|
||||
{
|
||||
char c = str[str.mLength - 1];
|
||||
if (((c >= '0') && (c <= '9')) || (c == '.'))
|
||||
str.RemoveFromEnd(1);
|
||||
else
|
||||
break;
|
||||
}
|
||||
|
||||
bool hasLinux = false;
|
||||
|
||||
for (auto elem : str.Split('-'))
|
||||
{
|
||||
if (elem == "linux")
|
||||
hasLinux = true;
|
||||
else if (elem == "windows")
|
||||
return BfPlatformType_Windows;
|
||||
else if (elem == "macosx")
|
||||
return BfPlatformType_macOS;
|
||||
else if (elem == "ios")
|
||||
return BfPlatformType_iOS;
|
||||
else if ((elem == "android") || (elem == "androideabi"))
|
||||
return BfPlatformType_Android;
|
||||
}
|
||||
|
||||
if (hasLinux)
|
||||
return BfPlatformType_Linux;
|
||||
return BfPlatformType_Unknown;
|
||||
}
|
||||
|
||||
BF_EXPORT void BF_CALLTYPE BfCompiler_SetOptions(BfCompiler* bfCompiler, BfProject* hotProject, int hotIdx,
|
||||
const char* targetTriple, int toolsetType, int simdSetting, int allocStackCount, int maxWorkerThreads,
|
||||
BfCompilerOptionFlags optionFlags, char* mallocLinkName, char* freeLinkName)
|
||||
|
@ -8141,9 +8175,22 @@ BF_EXPORT void BF_CALLTYPE BfCompiler_SetOptions(BfCompiler* bfCompiler, BfProje
|
|||
options->mMachineType = BfMachineType_x64;
|
||||
else if (options->mTargetTriple.StartsWith("i686-"))
|
||||
options->mMachineType = BfMachineType_x86;
|
||||
else if ((options->mTargetTriple.StartsWith("arm64")) || (options->mTargetTriple.StartsWith("aarch64")))
|
||||
options->mMachineType = BfMachineType_AArch64;
|
||||
else if (options->mTargetTriple.StartsWith("armv"))
|
||||
options->mMachineType = BfMachineType_ARM;
|
||||
else
|
||||
options->mMachineType = BfMachineType_x64; // Default
|
||||
|
||||
options->mPlatformType = GetPlatform(options->mTargetTriple);
|
||||
|
||||
options->mCLongSize = 4;
|
||||
if ((options->mMachineType == BfMachineType_AArch64) || (options->mMachineType == BfMachineType_x64))
|
||||
{
|
||||
if ((options->mPlatformType == BfPlatformType_macOS) || (options->mPlatformType == BfPlatformType_iOS) || (options->mPlatformType == BfPlatformType_Android))
|
||||
options->mCLongSize = 8;
|
||||
}
|
||||
|
||||
bfCompiler->mCodeGen.SetMaxThreads(maxWorkerThreads);
|
||||
|
||||
if (!bfCompiler->mIsResolveOnly)
|
||||
|
@ -8169,15 +8216,15 @@ BF_EXPORT void BF_CALLTYPE BfCompiler_SetOptions(BfCompiler* bfCompiler, BfProje
|
|||
options->mOmitDebugHelpers = (optionFlags & BfCompilerOptionFlag_OmitDebugHelpers) != 0;
|
||||
|
||||
#ifdef _WINDOWS
|
||||
if (options->mToolsetType == BfToolsetType_GNU)
|
||||
{
|
||||
options->mErrorString = "Toolset 'GNU' is not available on this platform. Consider changing 'Workspace/General/Toolset'.";
|
||||
}
|
||||
// if (options->mToolsetType == BfToolsetType_GNU)
|
||||
// {
|
||||
// options->mErrorString = "Toolset 'GNU' is not available on this platform. Consider changing 'Workspace/General/Toolset'.";
|
||||
// }
|
||||
#else
|
||||
if (options->mToolsetType == BfToolsetType_Microsoft)
|
||||
{
|
||||
options->mErrorString = "Toolset 'Microsoft' is not available on this platform. Consider changing 'Workspace/General/Toolset'.";
|
||||
}
|
||||
// if (options->mToolsetType == BfToolsetType_Microsoft)
|
||||
// {
|
||||
// options->mErrorString = "Toolset 'Microsoft' is not available on this platform. Consider changing 'Workspace/General/Toolset'.";
|
||||
// }
|
||||
BF_ASSERT(!options->mEnableRealtimeLeakCheck);
|
||||
#endif
|
||||
options->mEmitObjectAccessCheck = (optionFlags & BfCompilerOptionFlag_EmitDebugInfo) != 0;
|
||||
|
|
|
@ -94,13 +94,15 @@ public:
|
|||
int32 mForceRebuildIdx;
|
||||
BfCompileOnDemandKind mCompileOnDemandKind;
|
||||
String mTargetTriple;
|
||||
BfPlatformType mPlatformType;
|
||||
BfMachineType mMachineType;
|
||||
int mCLongSize;
|
||||
BfToolsetType mToolsetType;
|
||||
BfSIMDSetting mSIMDSetting;
|
||||
int mMaxWorkerThreads;
|
||||
String mMallocLinkName;
|
||||
String mFreeLinkName;
|
||||
bool mIncrementalBuild;
|
||||
bool mIncrementalBuild;
|
||||
|
||||
bool mEmitDebugInfo;
|
||||
bool mEmitLineInfo;
|
||||
|
@ -140,7 +142,9 @@ public:
|
|||
mHotCompileIdx = 0;
|
||||
mForceRebuildIdx = 0;
|
||||
mCompileOnDemandKind = BfCompileOnDemandKind_AlwaysInclude;
|
||||
mPlatformType = BfPlatformType_Unknown;
|
||||
mMachineType = BfMachineType_x86;
|
||||
mCLongSize = 4;
|
||||
mToolsetType = BfToolsetType_Microsoft;
|
||||
mSIMDSetting = BfSIMDSetting_None;
|
||||
mHotProject = NULL;
|
||||
|
|
|
@ -1632,7 +1632,8 @@ void BfContext::UpdateRevisedTypes()
|
|||
BP_ZONE("BfContext::UpdateRevisedTypes");
|
||||
|
||||
int wantPtrSize;
|
||||
if (mCompiler->mOptions.mMachineType == BfMachineType_x86)
|
||||
if ((mCompiler->mOptions.mMachineType == BfMachineType_x86) |
|
||||
(mCompiler->mOptions.mMachineType == BfMachineType_ARM))
|
||||
wantPtrSize = 4;
|
||||
else
|
||||
wantPtrSize = 8;
|
||||
|
@ -1788,9 +1789,12 @@ void BfContext::UpdateRevisedTypes()
|
|||
|
||||
//
|
||||
{
|
||||
AutoCrit autoCrit(mSystem->mDataLock);
|
||||
|
||||
auto options = &mCompiler->mOptions;
|
||||
HashContext workspaceConfigHashCtx;
|
||||
|
||||
workspaceConfigHashCtx.MixinStr(options->mTargetTriple);
|
||||
workspaceConfigHashCtx.Mixin(options->mForceRebuildIdx);
|
||||
|
||||
workspaceConfigHashCtx.Mixin(options->mMachineType);
|
||||
|
@ -1813,6 +1817,8 @@ void BfContext::UpdateRevisedTypes()
|
|||
workspaceConfigHashCtx.Mixin(options->mEnableCustodian);
|
||||
workspaceConfigHashCtx.Mixin(options->mEnableSideStack);
|
||||
workspaceConfigHashCtx.Mixin(options->mHasVDataExtender);
|
||||
workspaceConfigHashCtx.Mixin(options->mDebugAlloc);
|
||||
workspaceConfigHashCtx.Mixin(options->mOmitDebugHelpers);
|
||||
|
||||
workspaceConfigHashCtx.Mixin(options->mUseDebugBackingParams);
|
||||
|
||||
|
@ -1821,6 +1827,7 @@ void BfContext::UpdateRevisedTypes()
|
|||
|
||||
workspaceConfigHashCtx.Mixin(options->mAllocStackCount);
|
||||
workspaceConfigHashCtx.Mixin(options->mExtraResolveChecks);
|
||||
workspaceConfigHashCtx.Mixin(options->mMaxSplatRegs);
|
||||
workspaceConfigHashCtx.MixinStr(options->mMallocLinkName);
|
||||
workspaceConfigHashCtx.MixinStr(options->mFreeLinkName);
|
||||
|
||||
|
@ -1842,6 +1849,11 @@ void BfContext::UpdateRevisedTypes()
|
|||
workspaceConfigHashCtx.Mixin(typeOptions.mAllocStackTraceDepth);
|
||||
}
|
||||
|
||||
// for (auto project : mSystem->mProjects)
|
||||
// {
|
||||
// workspaceConfigHashCtx.MixinStr(project->mName);
|
||||
// }
|
||||
|
||||
Val128 workspaceConfigHash = workspaceConfigHashCtx.Finish128();
|
||||
|
||||
mSystem->mWorkspaceConfigChanged = mSystem->mWorkspaceConfigHash != workspaceConfigHash;
|
||||
|
@ -1852,8 +1864,7 @@ void BfContext::UpdateRevisedTypes()
|
|||
mSystem->mMergedTypeOptions.Clear();
|
||||
mSystem->mWorkspaceConfigHash = workspaceConfigHash;
|
||||
}
|
||||
|
||||
AutoCrit autoCrit(mSystem->mDataLock);
|
||||
|
||||
for (auto project : mSystem->mProjects)
|
||||
{
|
||||
HashContext buildConfigHashCtx;
|
||||
|
@ -1861,11 +1872,14 @@ void BfContext::UpdateRevisedTypes()
|
|||
|
||||
if (!mCompiler->mIsResolveOnly)
|
||||
{
|
||||
auto& codeGenOptions = project->mCodeGenOptions;
|
||||
auto& codeGenOptions = project->mCodeGenOptions;
|
||||
|
||||
buildConfigHashCtx.Mixin(project->mAlwaysIncludeAll);
|
||||
buildConfigHashCtx.Mixin(project->mSingleModule);
|
||||
|
||||
bool isTestConfig = project->mTargetType == BfTargetType_BeefTest;
|
||||
buildConfigHashCtx.Mixin(isTestConfig);
|
||||
|
||||
|
||||
buildConfigHashCtx.Mixin(codeGenOptions.mOptLevel);
|
||||
buildConfigHashCtx.Mixin(codeGenOptions.mSizeLevel);
|
||||
buildConfigHashCtx.Mixin(codeGenOptions.mUseCFLAA);
|
||||
|
@ -1888,6 +1902,7 @@ void BfContext::UpdateRevisedTypes()
|
|||
buildConfigHashCtx.Mixin(codeGenOptions.mRunSLPAfterLoopVectorization);
|
||||
buildConfigHashCtx.Mixin(codeGenOptions.mUseGVNAfterVectorization);
|
||||
}
|
||||
buildConfigHashCtx.Mixin(project->mDisabled);
|
||||
buildConfigHashCtx.Mixin(project->mTargetType);
|
||||
|
||||
for (auto dep : project->mDependencies)
|
||||
|
@ -2226,6 +2241,12 @@ String BfContext::GenerateModuleName(BfTypeInstance* typeInst)
|
|||
name.RemoveToEnd(80);
|
||||
name += "__";
|
||||
}
|
||||
for (int i = 0; i < (int)name.length(); i++)
|
||||
{
|
||||
char c = name[i];
|
||||
if (c == '@')
|
||||
name[i] = '_';
|
||||
}
|
||||
|
||||
String tryName = name;
|
||||
for (int i = 2; true; i++)
|
||||
|
|
|
@ -2110,7 +2110,7 @@ void BfIRBuilder::CreateTypeDeclaration(BfType* type, bool forceDefine)
|
|||
String prefix = typeDef->mProject->mName + ".";
|
||||
StringT<128> mangledName;
|
||||
mangledName += prefix;
|
||||
BfMangler::Mangle(mangledName, mModule->mCompiler->GetMangleKind(), typeInstance);
|
||||
BfMangler::Mangle(mangledName, mModule->mCompiler->GetMangleKind(), typeInstance, typeInstance->mModule);
|
||||
BfIRType irStructType = CreateStructType(mangledName);
|
||||
if (type->IsObjectOrInterface())
|
||||
{
|
||||
|
@ -4748,7 +4748,7 @@ BfIRValue BfIRBuilder::DbgLifetimeEnd(BfIRMDNode varInfo)
|
|||
}
|
||||
|
||||
void BfIRBuilder::DbgCreateGlobalVariable(BfIRMDNode context, const StringImpl& name, const StringImpl& linkageName, BfIRMDNode file, int lineNumber, BfIRMDNode type, bool isLocalToUnit, BfIRValue val, BfIRMDNode decl)
|
||||
{
|
||||
{
|
||||
WriteCmd(BfIRCmd_DbgCreateGlobalVariable, context, name, linkageName, file, lineNumber, type, isLocalToUnit, val, decl);
|
||||
NEW_CMD_INSERTED;
|
||||
}
|
||||
|
|
|
@ -4009,9 +4009,44 @@ bool BfIRCodeGen::WriteObjectFile(const StringImpl& outFileName, const BfCodeGen
|
|||
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;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
std::unique_ptr<llvm::TargetMachine> target(
|
||||
theTarget->createTargetMachine(theTriple.getTriple(), cpuName.c_str(), featuresStr.c_str(),
|
||||
Options, relocModel, cmModel, optLvl));
|
||||
Options, relocModel, cmModel, optLvl));
|
||||
|
||||
std::error_code EC;
|
||||
llvm::sys::fs::OpenFlags OpenFlags = llvm::sys::fs::F_None;
|
||||
|
@ -4188,6 +4223,11 @@ void BfIRCodeGen::StaticInit()
|
|||
LLVMInitializeX86AsmParser();
|
||||
LLVMInitializeX86Disassembler();
|
||||
|
||||
LLVMInitializeARMTargetInfo();
|
||||
LLVMInitializeARMTarget();
|
||||
LLVMInitializeARMTargetMC();
|
||||
LLVMInitializeARMAsmPrinter();
|
||||
|
||||
LLVMInitializeAArch64TargetInfo();
|
||||
LLVMInitializeAArch64Target();
|
||||
LLVMInitializeAArch64TargetMC();
|
||||
|
|
|
@ -56,13 +56,10 @@ BfTypeCode BfGNUMangler::GetPrimTypeAt(MangleContext& mangleContext, StringImpl&
|
|||
case 't': return BfTypeCode_UInt16;
|
||||
case 'i': return BfTypeCode_Int32;
|
||||
case 'j': return BfTypeCode_UInt32;
|
||||
#if __SIZEOF_LONG__ == 8
|
||||
case 'l': return BfTypeCode_Int64;
|
||||
case 'm': return BfTypeCode_UInt64;
|
||||
#else
|
||||
case 'x': return BfTypeCode_Int64;
|
||||
case 'y': return BfTypeCode_UInt64;
|
||||
#endif
|
||||
case 'u':
|
||||
if (name[strIdx + 1] == '3')
|
||||
return BfTypeCode_IntPtr;
|
||||
|
@ -234,9 +231,9 @@ void BfGNUMangler::FindOrCreateNameSub(MangleContext& mangleContext, StringImpl&
|
|||
else
|
||||
name += "4";
|
||||
if (genericParamType->mGenericParamKind == BfGenericParamKind_Method)
|
||||
name += "@M";
|
||||
name += "`M";
|
||||
else
|
||||
name += "@T";
|
||||
name += "`T";
|
||||
itoa(genericParamType->mGenericParamIdx, str, 10);
|
||||
name += str;
|
||||
}
|
||||
|
@ -274,7 +271,7 @@ void BfGNUMangler::FindOrCreateNameSub(MangleContext& mangleContext, StringImpl&
|
|||
}
|
||||
|
||||
void BfGNUMangler::MangleTypeInst(MangleContext& mangleContext, StringImpl& name, BfTypeInstance* typeInst, BfTypeInstance* postfixTypeInstance, bool* isEndOpen)
|
||||
{
|
||||
{
|
||||
static int sCallCount = 0;
|
||||
sCallCount++;
|
||||
|
||||
|
@ -289,7 +286,7 @@ void BfGNUMangler::MangleTypeInst(MangleContext& mangleContext, StringImpl& name
|
|||
BfFieldDef* fieldDef = fieldInstance->GetFieldDef();
|
||||
String fieldName = fieldDef->mName;
|
||||
if ((fieldName[0] < '0') || (fieldName[0] > '9'))
|
||||
name += StrFormat("U%d@%s", fieldName.length() + 1, fieldName.c_str());
|
||||
name += StrFormat("U%d`%s", fieldName.length() + 1, fieldName.c_str());
|
||||
Mangle(mangleContext, name, fieldInstance->mResolvedType, postfixTypeInstance);
|
||||
}
|
||||
name += "E";
|
||||
|
@ -444,25 +441,25 @@ void BfGNUMangler::Mangle(MangleContext& mangleContext, StringImpl& name, BfType
|
|||
name += "i"; return;
|
||||
case BfTypeCode_UInt32:
|
||||
name += "j"; return;
|
||||
#if __SIZEOF_LONG__ == 8
|
||||
case BfTypeCode_Int64:
|
||||
name += "l"; return;
|
||||
if (mangleContext.mModule->mCompiler->mOptions.mCLongSize == 8)
|
||||
name += "l";
|
||||
else
|
||||
name += "x";
|
||||
return;
|
||||
case BfTypeCode_UInt64:
|
||||
name += "m"; return;
|
||||
#else
|
||||
case BfTypeCode_Int64:
|
||||
name += "x"; return;
|
||||
case BfTypeCode_UInt64:
|
||||
name += "y"; return;
|
||||
#endif
|
||||
if (mangleContext.mModule->mCompiler->mOptions.mCLongSize == 8)
|
||||
name += "m";
|
||||
else
|
||||
name += "y";
|
||||
return;
|
||||
case BfTypeCode_UIntPtr:
|
||||
if ((mangleContext.mCCompat) || (mangleContext.mInArgs))
|
||||
{
|
||||
#if __SIZEOF_LONG__ == 8
|
||||
name += (primType->mSize == 8) ? "m" : "j";
|
||||
#else
|
||||
name += (primType->mSize == 8) ? "y" : "j";
|
||||
#endif
|
||||
if (mangleContext.mModule->mCompiler->mOptions.mCLongSize == 8)
|
||||
name += (primType->mSize == 8) ? "m" : "j";
|
||||
else
|
||||
name += (primType->mSize == 8) ? "y" : "j";
|
||||
return;
|
||||
}
|
||||
name += "u4uint";
|
||||
|
@ -470,11 +467,10 @@ void BfGNUMangler::Mangle(MangleContext& mangleContext, StringImpl& name, BfType
|
|||
case BfTypeCode_IntPtr:
|
||||
if ((mangleContext.mCCompat) || (mangleContext.mInArgs))
|
||||
{
|
||||
#if __SIZEOF_LONG__ == 8
|
||||
name += (primType->mSize == 8) ? "l" : "i";
|
||||
#else
|
||||
name += (primType->mSize == 8) ? "x" : "i";
|
||||
#endif
|
||||
if (mangleContext.mModule->mCompiler->mOptions.mCLongSize == 8)
|
||||
name += (primType->mSize == 8) ? "l" : "i";
|
||||
else
|
||||
name += (primType->mSize == 8) ? "x" : "i";
|
||||
return;
|
||||
}
|
||||
name += "u3int";
|
||||
|
@ -635,7 +631,7 @@ void BfGNUMangler::Mangle(MangleContext& mangleContext, StringImpl& name, BfType
|
|||
}
|
||||
|
||||
name += strP;
|
||||
name += '@';
|
||||
name += '`';
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -834,7 +830,7 @@ String BfGNUMangler::Mangle(BfMethodInstance* methodInst)
|
|||
{
|
||||
if (methodInst->mMangleWithIdx)
|
||||
{
|
||||
methodName += StrFormat("@%d", methodInst->mMethodDef->mIdx);
|
||||
methodName += StrFormat("`%d", methodInst->mMethodDef->mIdx);
|
||||
mangledMethodIdx = true;
|
||||
}
|
||||
|
||||
|
@ -842,9 +838,9 @@ String BfGNUMangler::Mangle(BfMethodInstance* methodInst)
|
|||
}
|
||||
|
||||
if (methodDef->mCheckedKind == BfCheckedKind_Checked)
|
||||
name += "@CHK";
|
||||
name += "`CHK";
|
||||
else if (methodDef->mCheckedKind == BfCheckedKind_Unchecked)
|
||||
name += "@UCHK";
|
||||
name += "`UCHK";
|
||||
|
||||
if ((methodInst->mMethodDef->mDeclaringType->mPartialIdx != -1) && (!methodInst->mIsForeignMethodDef))
|
||||
{
|
||||
|
@ -877,14 +873,14 @@ String BfGNUMangler::Mangle(BfMethodInstance* methodInst)
|
|||
|
||||
if ((methodInst->mMangleWithIdx) && (!mangledMethodIdx))
|
||||
{
|
||||
methodName += StrFormat("@%d", methodInst->mMethodDef->mIdx);
|
||||
methodName += StrFormat("`%d", methodInst->mMethodDef->mIdx);
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
if ((prefixLen) && (methodInst->mMethodInstanceGroup->mOwner->mTypeDef->IsGlobalsContainer()) && (methodInst->mMethodDef->mMethodDeclaration == NULL))
|
||||
{
|
||||
methodName += '@';
|
||||
methodName += '`';
|
||||
methodName += methodInst->mMethodInstanceGroup->mOwner->mTypeDef->mProject->mName;
|
||||
}
|
||||
|
||||
|
|
|
@ -4319,12 +4319,12 @@ BfIRValue BfModule::CreateTypeData(BfType* type, Dictionary<int, int>& usedStrin
|
|||
{
|
||||
BfMangler::MangleStaticFieldName(typeDataName, mCompiler->GetMangleKind(), typeInstance, "sBfTypeData");
|
||||
if (typeInstance->mTypeDef->IsGlobalsContainer())
|
||||
typeDataName += "@" + typeInstance->mTypeDef->mProject->mName;
|
||||
typeDataName += "`G`" + typeInstance->mTypeDef->mProject->mName;
|
||||
}
|
||||
else
|
||||
{
|
||||
typeDataName += "sBfTypeData.";
|
||||
BfMangler::Mangle(typeDataName, mCompiler->GetMangleKind(), type);
|
||||
BfMangler::Mangle(typeDataName, mCompiler->GetMangleKind(), type, mContext->mScratchModule);
|
||||
}
|
||||
|
||||
int typeCode = BfTypeCode_None;
|
||||
|
@ -4460,7 +4460,7 @@ BfIRValue BfModule::CreateTypeData(BfType* type, Dictionary<int, int>& usedStrin
|
|||
|
||||
BfTypeDef* typeDef = typeInstance->mTypeDef;
|
||||
StringT<128> mangledName;
|
||||
BfMangler::Mangle(mangledName, mCompiler->GetMangleKind(), typeInstance);
|
||||
BfMangler::Mangle(mangledName, mCompiler->GetMangleKind(), typeInstance, typeInstance->mModule);
|
||||
|
||||
for (int methodIdx = 0; methodIdx < (int)typeDef->mMethods.size(); methodIdx++)
|
||||
{
|
||||
|
@ -13619,8 +13619,8 @@ void BfModule::CreateDllImportMethod()
|
|||
|
||||
BfIRCallingConv BfModule::GetCallingConvention(BfTypeInstance* typeInst, BfMethodDef* methodDef)
|
||||
{
|
||||
if (mSystem->mPtrSize == 8)
|
||||
return BfIRCallingConv_CDecl;
|
||||
if ((mCompiler->mOptions.mMachineType != BfMachineType_x86) || (mCompiler->mOptions.mPlatformType != BfPlatformType_Windows))
|
||||
return BfIRCallingConv_CDecl;
|
||||
if (methodDef->mCallingConvention == BfCallingConvention_Stdcall)
|
||||
return BfIRCallingConv_StdCall;
|
||||
if ((!methodDef->mIsStatic) && (!typeInst->IsValuelessType()) &&
|
||||
|
|
|
@ -3592,8 +3592,8 @@ BF_EXPORT void BF_CALLTYPE BfProject_SetDisabled(BfProject* bfProject, bool disa
|
|||
bfProject->mDisabled = disabled;
|
||||
}
|
||||
|
||||
BF_EXPORT void BF_CALLTYPE BfProject_SetOptions(BfProject* bfProject, int targetType, const char* startupObject, const char* preprocessorMacros,
|
||||
int optLevel, int ltoType, BfProjectFlags flags)
|
||||
BF_EXPORT void BF_CALLTYPE BfProject_SetOptions(BfProject* bfProject, int targetType, const char* startupObject, const char* preprocessorMacros,
|
||||
int optLevel, int ltoType, int relocType, int picLevel, BfProjectFlags flags)
|
||||
{
|
||||
bfProject->mTargetType = (BfTargetType)targetType;
|
||||
bfProject->mStartupObject = startupObject;
|
||||
|
@ -3601,6 +3601,8 @@ BF_EXPORT void BF_CALLTYPE BfProject_SetOptions(BfProject* bfProject, int target
|
|||
BfCodeGenOptions codeGenOptions;
|
||||
codeGenOptions.mOptLevel = (BfOptLevel)optLevel;
|
||||
codeGenOptions.mLTOType = (BfLTOType)ltoType;
|
||||
codeGenOptions.mRelocType = (BfRelocType)relocType;
|
||||
codeGenOptions.mPICLevel = (BfPICLevel)picLevel;
|
||||
codeGenOptions.mMergeFunctions = (flags & BfProjectFlags_MergeFunctions) != 0;
|
||||
codeGenOptions.mLoadCombine = (flags & BfProjectFlags_CombineLoads) != 0;
|
||||
codeGenOptions.mLoopVectorize = (flags & BfProjectFlags_VectorizeLoops) != 0;
|
||||
|
|
|
@ -204,11 +204,22 @@ enum BfCustomAttributeFlags
|
|||
BfCustomAttributeFlags_AlwaysIncludeTarget = 8
|
||||
};
|
||||
|
||||
enum BfPlatformType
|
||||
{
|
||||
BfPlatformType_Unknown,
|
||||
BfPlatformType_Windows,
|
||||
BfPlatformType_Linux,
|
||||
BfPlatformType_macOS,
|
||||
BfPlatformType_iOS,
|
||||
BfPlatformType_Android,
|
||||
};
|
||||
|
||||
enum BfMachineType
|
||||
{
|
||||
BfMachineType_Unknown,
|
||||
BfMachineType_x86,
|
||||
BfMachineType_x64,
|
||||
BfMachineType_ARM,
|
||||
BfMachineType_AArch64
|
||||
};
|
||||
|
||||
|
@ -265,6 +276,25 @@ enum BfCFLAAType
|
|||
BfCFLAAType_Both
|
||||
};
|
||||
|
||||
enum BfRelocType
|
||||
{
|
||||
BfRelocType_NotSet,
|
||||
BfRelocType_Static,
|
||||
BfRelocType_PIC,
|
||||
BfRelocType_DynamicNoPIC,
|
||||
BfRelocType_ROPI,
|
||||
BfRelocType_RWPI,
|
||||
BfRelocType_ROPI_RWPI
|
||||
};
|
||||
|
||||
enum BfPICLevel
|
||||
{
|
||||
BfPICLevel_NotSet,
|
||||
BfPICLevel_Not,
|
||||
BfPICLevel_Small,
|
||||
BfPICLevel_Big
|
||||
};
|
||||
|
||||
struct BfCodeGenOptions
|
||||
{
|
||||
bool mIsHotCompile;
|
||||
|
@ -277,6 +307,8 @@ struct BfCodeGenOptions
|
|||
int16 mVirtualMethodOfs;
|
||||
int16 mDynSlotOfs;
|
||||
|
||||
BfRelocType mRelocType;
|
||||
BfPICLevel mPICLevel;
|
||||
BfSIMDSetting mSIMDSetting;
|
||||
BfOptLevel mOptLevel;
|
||||
BfLTOType mLTOType;
|
||||
|
@ -327,7 +359,9 @@ struct BfCodeGenOptions
|
|||
mWriteLLVMIR = false;
|
||||
mVirtualMethodOfs = 0;
|
||||
mDynSlotOfs = 0;
|
||||
|
||||
|
||||
mRelocType = BfRelocType_NotSet;
|
||||
mPICLevel = BfPICLevel_NotSet;
|
||||
mSIMDSetting = BfSIMDSetting_None;
|
||||
mOptLevel = BfOptLevel_O0;
|
||||
mLTOType = BfLTOType_None;
|
||||
|
@ -378,6 +412,8 @@ struct BfCodeGenOptions
|
|||
hashCtx.Mixin(mVirtualMethodOfs);
|
||||
hashCtx.Mixin(mDynSlotOfs);
|
||||
|
||||
hashCtx.Mixin(mRelocType);
|
||||
hashCtx.Mixin(mPICLevel);
|
||||
hashCtx.Mixin(mSIMDSetting);
|
||||
hashCtx.Mixin(mOptLevel);
|
||||
hashCtx.Mixin(mLTOType);
|
||||
|
@ -950,7 +986,9 @@ enum BfTargetType
|
|||
BfTargetType_CustomBuild,
|
||||
BfTargetType_C_ConsoleApplication,
|
||||
BfTargetType_C_WindowsApplication,
|
||||
BfTargetType_BeefTest
|
||||
BfTargetType_BeefTest,
|
||||
BfTargetType_BeefApplication_StaticLib,
|
||||
BfTargetType_BeefApplication_DynamicLib
|
||||
};
|
||||
|
||||
enum BfProjectFlags
|
||||
|
|
|
@ -171,7 +171,7 @@
|
|||
<SubSystem>Windows</SubSystem>
|
||||
<GenerateDebugInformation>DebugFull</GenerateDebugInformation>
|
||||
<OutputFile>$(SolutionDir)\IDE\dist\$(TargetName).dll</OutputFile>
|
||||
<AdditionalDependencies>rpcrt4.lib;cabinet.lib;winmm.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;libcurl_a.lib;wininet.lib;LLVMMCDisassembler.lib;LLVMSupport.lib;LLVMMC.lib;LLVMObject.lib;LLVMCore.lib;LLVMBitReader.lib;LLVMAsmParser.lib;LLVMMCParser.lib;LLVMCodeGen.lib;LLVMTarget.lib;LLVMScalarOpts.lib;LLVMInstCombine.lib;LLVMSelectionDAG.lib;LLVMProfileData.lib;LLVMTransformUtils.lib;LLVMAnalysis.lib;LLVMAsmPrinter.lib;LLVMBitWriter.lib;LLVMVectorize.lib;LLVMipo.lib;LLVMInstrumentation.lib;LLVMDebugInfoDWARF.lib;LLVMDebugInfoPDB.lib;LLVMDebugInfoCodeView.lib;LLVMGlobalISel.lib;LLVMBinaryFormat.lib;LLVMLTO.lib;LLVMPasses.lib;LLVMLinker.lib;LLVMIRReader.lib;LLVMDemangle.lib;LLVMAggressiveInstCombine.lib;LLVMX86Info.lib;LLVMX86Utils.lib;LLVMX86AsmPrinter.lib;LLVMX86Desc.lib;LLVMX86CodeGen.lib;LLVMX86AsmParser.lib;LLVMX86Disassembler.lib;LLVMAArch64Info.lib;LLVMAArch64Utils.lib;LLVMAArch64AsmPrinter.lib;LLVMAArch64Desc.lib;LLVMAArch64CodeGen.lib;LLVMAArch64AsmParser.lib;LLVMAArch64Disassembler.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<AdditionalDependencies>rpcrt4.lib;cabinet.lib;winmm.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;libcurl_a.lib;wininet.lib;LLVMMCDisassembler.lib;LLVMSupport.lib;LLVMMC.lib;LLVMObject.lib;LLVMCore.lib;LLVMBitReader.lib;LLVMAsmParser.lib;LLVMMCParser.lib;LLVMCodeGen.lib;LLVMTarget.lib;LLVMScalarOpts.lib;LLVMInstCombine.lib;LLVMSelectionDAG.lib;LLVMProfileData.lib;LLVMTransformUtils.lib;LLVMAnalysis.lib;LLVMAsmPrinter.lib;LLVMBitWriter.lib;LLVMVectorize.lib;LLVMipo.lib;LLVMInstrumentation.lib;LLVMDebugInfoDWARF.lib;LLVMDebugInfoPDB.lib;LLVMDebugInfoCodeView.lib;LLVMGlobalISel.lib;LLVMBinaryFormat.lib;LLVMLTO.lib;LLVMPasses.lib;LLVMLinker.lib;LLVMIRReader.lib;LLVMDemangle.lib;LLVMAggressiveInstCombine.lib;LLVMX86Info.lib;LLVMX86Utils.lib;LLVMX86AsmPrinter.lib;LLVMX86Desc.lib;LLVMX86CodeGen.lib;LLVMX86AsmParser.lib;LLVMX86Disassembler.lib;LLVMAArch64Info.lib;LLVMAArch64Utils.lib;LLVMAArch64AsmPrinter.lib;LLVMAArch64Desc.lib;LLVMAArch64CodeGen.lib;LLVMAArch64AsmParser.lib;LLVMAArch64Disassembler.lib;LLVMARMInfo.lib;LLVMARMUtils.lib;LLVMARMAsmPrinter.lib;LLVMARMDesc.lib;LLVMARMCodeGen.lib;LLVMARMAsmParser.lib;LLVMARMDisassembler.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<AdditionalLibraryDirectories>..\extern\llvm_win64_8_0_1\Debug\lib; ..\extern\curl\builds\libcurl-vc15-x64-release-static-zlib-static-ipv6-sspi-winssl\lib;..\extern\curl\deps\lib;..\extern\jemalloc_win\x64\debug</AdditionalLibraryDirectories>
|
||||
<RandomizedBaseAddress>false</RandomizedBaseAddress>
|
||||
<ImportLibrary>$(SolutionDir)\IDE\dist\$(TargetName).lib</ImportLibrary>
|
||||
|
@ -230,7 +230,7 @@
|
|||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<OutputFile>$(SolutionDir)\IDE\dist\$(TargetName).dll</OutputFile>
|
||||
<AdditionalLibraryDirectories>..\extern\llvm_win64_8_0_1\Release\lib; ..\extern\curl\builds\libcurl-vc15-x64-release-static-zlib-static-ipv6-sspi-winssl\lib;..\extern\curl\deps\lib;..\extern\jemalloc_win\x64\release</AdditionalLibraryDirectories>
|
||||
<AdditionalDependencies>rpcrt4.lib;cabinet.lib;winmm.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;libcurl_a.lib;wininet.lib;LLVMMCDisassembler.lib;LLVMSupport.lib;LLVMMC.lib;LLVMObject.lib;LLVMCore.lib;LLVMBitReader.lib;LLVMAsmParser.lib;LLVMMCParser.lib;LLVMCodeGen.lib;LLVMTarget.lib;LLVMScalarOpts.lib;LLVMInstCombine.lib;LLVMSelectionDAG.lib;LLVMProfileData.lib;LLVMTransformUtils.lib;LLVMAnalysis.lib;LLVMAsmPrinter.lib;LLVMBitWriter.lib;LLVMVectorize.lib;LLVMipo.lib;LLVMInstrumentation.lib;LLVMDebugInfoDWARF.lib;LLVMDebugInfoPDB.lib;LLVMDebugInfoCodeView.lib;LLVMGlobalISel.lib;LLVMBinaryFormat.lib;LLVMLTO.lib;LLVMPasses.lib;LLVMLinker.lib;LLVMIRReader.lib;LLVMDemangle.lib;LLVMAggressiveInstCombine.lib;LLVMX86Info.lib;LLVMX86Utils.lib;LLVMX86AsmPrinter.lib;LLVMX86Desc.lib;LLVMX86CodeGen.lib;LLVMX86AsmParser.lib;LLVMX86Disassembler.lib;LLVMAArch64Info.lib;LLVMAArch64Utils.lib;LLVMAArch64AsmPrinter.lib;LLVMAArch64Desc.lib;LLVMAArch64CodeGen.lib;LLVMAArch64AsmParser.lib;LLVMAArch64Disassembler.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<AdditionalDependencies>rpcrt4.lib;cabinet.lib;winmm.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;libcurl_a.lib;wininet.lib;LLVMMCDisassembler.lib;LLVMSupport.lib;LLVMMC.lib;LLVMObject.lib;LLVMCore.lib;LLVMBitReader.lib;LLVMAsmParser.lib;LLVMMCParser.lib;LLVMCodeGen.lib;LLVMTarget.lib;LLVMScalarOpts.lib;LLVMInstCombine.lib;LLVMSelectionDAG.lib;LLVMProfileData.lib;LLVMTransformUtils.lib;LLVMAnalysis.lib;LLVMAsmPrinter.lib;LLVMBitWriter.lib;LLVMVectorize.lib;LLVMipo.lib;LLVMInstrumentation.lib;LLVMDebugInfoDWARF.lib;LLVMDebugInfoPDB.lib;LLVMDebugInfoCodeView.lib;LLVMGlobalISel.lib;LLVMBinaryFormat.lib;LLVMLTO.lib;LLVMPasses.lib;LLVMLinker.lib;LLVMIRReader.lib;LLVMDemangle.lib;LLVMAggressiveInstCombine.lib;LLVMX86Info.lib;LLVMX86Utils.lib;LLVMX86AsmPrinter.lib;LLVMX86Desc.lib;LLVMX86CodeGen.lib;LLVMX86AsmParser.lib;LLVMX86Disassembler.lib;LLVMAArch64Info.lib;LLVMAArch64Utils.lib;LLVMAArch64AsmPrinter.lib;LLVMAArch64Desc.lib;LLVMAArch64CodeGen.lib;LLVMAArch64AsmParser.lib;LLVMAArch64Disassembler.lib;LLVMARMInfo.lib;LLVMARMUtils.lib;LLVMARMAsmPrinter.lib;LLVMARMDesc.lib;LLVMARMCodeGen.lib;LLVMARMAsmParser.lib;LLVMARMDisassembler.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<RandomizedBaseAddress>false</RandomizedBaseAddress>
|
||||
<FullProgramDatabaseFile>true</FullProgramDatabaseFile>
|
||||
<ImportLibrary>$(SolutionDir)\IDE\dist\$(TargetName).lib</ImportLibrary>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue