mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-08 19:48:20 +02:00
Added Target CPU workspace override
This commit is contained in:
parent
91e856fc0b
commit
125d5c0c8c
14 changed files with 34 additions and 13 deletions
|
@ -127,7 +127,7 @@ namespace IDE.Compiler
|
||||||
|
|
||||||
[CallingConvention(.Stdcall), CLink]
|
[CallingConvention(.Stdcall), CLink]
|
||||||
static extern void BfCompiler_SetOptions(void* bfCompiler,
|
static extern void BfCompiler_SetOptions(void* bfCompiler,
|
||||||
void* hotProject, int32 hotIdx, char8* targetTriple, int32 toolsetType, int32 simdSetting, int32 allocStackCount, int32 maxWorkerThreads,
|
void* hotProject, int32 hotIdx, char8* targetTriple, char8* targetCPU, int32 toolsetType, int32 simdSetting, int32 allocStackCount, int32 maxWorkerThreads,
|
||||||
OptionFlags optionsFlags, char8* mallocName, char8* freeName);
|
OptionFlags optionsFlags, char8* mallocName, char8* freeName);
|
||||||
|
|
||||||
[CallingConvention(.Stdcall), CLink]
|
[CallingConvention(.Stdcall), CLink]
|
||||||
|
@ -302,12 +302,12 @@ namespace IDE.Compiler
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetOptions(BfProject hotProject, int32 hotIdx,
|
public void SetOptions(BfProject hotProject, int32 hotIdx,
|
||||||
String targetTriple, int32 toolsetType, int32 simdSetting, int32 allocStackCount, int32 maxWorkerThreads,
|
String targetTriple, String targetCPU, int32 toolsetType, int32 simdSetting, int32 allocStackCount, int32 maxWorkerThreads,
|
||||||
OptionFlags optionFlags, String mallocFuncName, String freeFuncName)
|
OptionFlags optionFlags, String mallocFuncName, String freeFuncName)
|
||||||
{
|
{
|
||||||
BfCompiler_SetOptions(mNativeBfCompiler,
|
BfCompiler_SetOptions(mNativeBfCompiler,
|
||||||
(hotProject != null) ? hotProject.mNativeBfProject : null, hotIdx,
|
(hotProject != null) ? hotProject.mNativeBfProject : null, hotIdx,
|
||||||
targetTriple, toolsetType, simdSetting, allocStackCount, maxWorkerThreads, optionFlags, mallocFuncName, freeFuncName);
|
targetTriple, targetCPU, toolsetType, simdSetting, allocStackCount, maxWorkerThreads, optionFlags, mallocFuncName, freeFuncName);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ForceRebuild()
|
public void ForceRebuild()
|
||||||
|
@ -699,8 +699,8 @@ namespace IDE.Compiler
|
||||||
//Debug.WriteLine("HandleOptions SetOptions:{0:X}", (int)optionFlags);
|
//Debug.WriteLine("HandleOptions SetOptions:{0:X}", (int)optionFlags);
|
||||||
|
|
||||||
SetOptions(hotBfProject, hotIdx,
|
SetOptions(hotBfProject, hotIdx,
|
||||||
targetTriple, (int32)options.mToolsetType, (int32)options.mBfSIMDSetting, (int32)options.mAllocStackTraceDepth, (int32)gApp.mSettings.mCompilerSettings.mWorkerThreads,
|
targetTriple, options.mTargetCPU, (int32)options.mToolsetType, (int32)options.mBfSIMDSetting, (int32)options.mAllocStackTraceDepth,
|
||||||
optionFlags, mallocLinkName, freeLinkName);
|
(int32)gApp.mSettings.mCompilerSettings.mWorkerThreads, optionFlags, mallocLinkName, freeLinkName);
|
||||||
|
|
||||||
if (!mIsResolveOnly)
|
if (!mIsResolveOnly)
|
||||||
{
|
{
|
||||||
|
|
|
@ -240,6 +240,8 @@ namespace IDE
|
||||||
[Reflect]
|
[Reflect]
|
||||||
public IntermediateType mIntermediateType;
|
public IntermediateType mIntermediateType;
|
||||||
[Reflect]
|
[Reflect]
|
||||||
|
public String mTargetCPU = new String() ~ delete _;
|
||||||
|
[Reflect]
|
||||||
public BuildOptions.SIMDSetting mBfSIMDSetting = .SSE2;
|
public BuildOptions.SIMDSetting mBfSIMDSetting = .SSE2;
|
||||||
[Reflect]
|
[Reflect]
|
||||||
public BuildOptions.BfOptimizationLevel mBfOptimizationLevel;
|
public BuildOptions.BfOptimizationLevel mBfOptimizationLevel;
|
||||||
|
@ -317,6 +319,7 @@ namespace IDE
|
||||||
|
|
||||||
mIncrementalBuild = prev.mIncrementalBuild;
|
mIncrementalBuild = prev.mIncrementalBuild;
|
||||||
mIntermediateType = prev.mIntermediateType;
|
mIntermediateType = prev.mIntermediateType;
|
||||||
|
mTargetCPU.Set(prev.mTargetCPU);
|
||||||
mBfSIMDSetting = prev.mBfSIMDSetting;
|
mBfSIMDSetting = prev.mBfSIMDSetting;
|
||||||
mBfOptimizationLevel = prev.mBfOptimizationLevel;
|
mBfOptimizationLevel = prev.mBfOptimizationLevel;
|
||||||
mCSIMDSetting = prev.mCSIMDSetting;
|
mCSIMDSetting = prev.mCSIMDSetting;
|
||||||
|
@ -738,6 +741,7 @@ namespace IDE
|
||||||
|
|
||||||
data.ConditionalAdd("Toolset", options.mToolsetType, ToolsetType.GetDefaultFor(platformType, isRelease));
|
data.ConditionalAdd("Toolset", options.mToolsetType, ToolsetType.GetDefaultFor(platformType, isRelease));
|
||||||
data.ConditionalAdd("BuildKind", options.mBuildKind, isTest ? .Test : .Normal);
|
data.ConditionalAdd("BuildKind", options.mBuildKind, isTest ? .Test : .Normal);
|
||||||
|
data.ConditionalAdd("TargetCPU", options.mTargetCPU);
|
||||||
data.ConditionalAdd("BfSIMDSetting", options.mBfSIMDSetting, .SSE2);
|
data.ConditionalAdd("BfSIMDSetting", options.mBfSIMDSetting, .SSE2);
|
||||||
if (platformType == .Windows)
|
if (platformType == .Windows)
|
||||||
data.ConditionalAdd("BfOptimizationLevel", options.mBfOptimizationLevel, isRelease ? .O2 : (platformName == "Win64") ? .OgPlus : .O0);
|
data.ConditionalAdd("BfOptimizationLevel", options.mBfOptimizationLevel, isRelease ? .O2 : (platformName == "Win64") ? .OgPlus : .O0);
|
||||||
|
@ -1041,6 +1045,7 @@ namespace IDE
|
||||||
|
|
||||||
options.mToolsetType = data.GetEnum<ToolsetType>("Toolset", ToolsetType.GetDefaultFor(platformType, isRelease));
|
options.mToolsetType = data.GetEnum<ToolsetType>("Toolset", ToolsetType.GetDefaultFor(platformType, isRelease));
|
||||||
options.mBuildKind = data.GetEnum<BuildKind>("BuildKind", isTest ? .Test : .Normal);
|
options.mBuildKind = data.GetEnum<BuildKind>("BuildKind", isTest ? .Test : .Normal);
|
||||||
|
data.GetString("TargetCPU", options.mTargetCPU);
|
||||||
options.mBfSIMDSetting = data.GetEnum<BuildOptions.SIMDSetting>("BfSIMDSetting", .SSE2);
|
options.mBfSIMDSetting = data.GetEnum<BuildOptions.SIMDSetting>("BfSIMDSetting", .SSE2);
|
||||||
if (platformType == .Windows)
|
if (platformType == .Windows)
|
||||||
options.mBfOptimizationLevel = data.GetEnum<BuildOptions.BfOptimizationLevel>("BfOptimizationLevel", isRelease ? .O2 : (platformName == "Win64") ? .OgPlus : .O0);
|
options.mBfOptimizationLevel = data.GetEnum<BuildOptions.BfOptimizationLevel>("BfOptimizationLevel", isRelease ? .O2 : (platformName == "Win64") ? .OgPlus : .O0);
|
||||||
|
|
|
@ -775,6 +775,7 @@ namespace IDE.ui
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
allocPropEntry.mOnUpdate();
|
allocPropEntry.mOnUpdate();
|
||||||
|
AddPropertiesItem(category, "Target CPU", "mTargetCPU");
|
||||||
AddPropertiesItem(category, "SIMD Instructions", "mBfSIMDSetting");
|
AddPropertiesItem(category, "SIMD Instructions", "mBfSIMDSetting");
|
||||||
AddPropertiesItem(category, "Optimization Level", "mBfOptimizationLevel",
|
AddPropertiesItem(category, "Optimization Level", "mBfOptimizationLevel",
|
||||||
scope String[] ( "O0", "O1", "O2", "O3", "Og", "Og+"));
|
scope String[] ( "O0", "O1", "O2", "O3", "Og", "Og+"));
|
||||||
|
|
|
@ -1117,7 +1117,9 @@ void BeIRCodeGen::HandleNextCmd()
|
||||||
case BfIRCmd_Module_SetTargetTriple:
|
case BfIRCmd_Module_SetTargetTriple:
|
||||||
{
|
{
|
||||||
CMD_PARAM(String, targetTriple);
|
CMD_PARAM(String, targetTriple);
|
||||||
mBeModule->mTargetTriple = targetTriple;
|
CMD_PARAM(String, targetCPU);
|
||||||
|
mBeModule->mTargetTriple = targetTriple;
|
||||||
|
mBeModule->mTargetCPU = targetCPU;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case BfIRCmd_Module_AddModuleFlag:
|
case BfIRCmd_Module_AddModuleFlag:
|
||||||
|
|
|
@ -16040,13 +16040,16 @@ BeMCOperand BeMCContext::AllocBinaryOp(BeMCInstKind instKind, const BeMCOperand&
|
||||||
}
|
}
|
||||||
|
|
||||||
void BeMCContext::Generate(BeFunction* function)
|
void BeMCContext::Generate(BeFunction* function)
|
||||||
{
|
{
|
||||||
BP_ZONE_F("BeMCContext::Generate %s", function->mName.c_str());
|
BP_ZONE_F("BeMCContext::Generate %s", function->mName.c_str());
|
||||||
|
|
||||||
mBeFunction = function;
|
mBeFunction = function;
|
||||||
mDbgFunction = mBeFunction->mDbgFunction;
|
mDbgFunction = mBeFunction->mDbgFunction;
|
||||||
mModule = function->mModule;
|
mModule = function->mModule;
|
||||||
|
|
||||||
|
if (!mModule->mTargetCPU.IsEmpty())
|
||||||
|
mModule->mBeIRCodeGen->Fail(StrFormat("Cannot set Target CPU '%s' for +Og optimization. Considering compiling under a different optimization setting.", mModule->mTargetCPU.c_str()));
|
||||||
|
|
||||||
//mDbgPreferredRegs[15] = X64Reg_RCX;
|
//mDbgPreferredRegs[15] = X64Reg_RCX;
|
||||||
//mDbgPreferredRegs[7] = X64Reg_RCX;
|
//mDbgPreferredRegs[7] = X64Reg_RCX;
|
||||||
/*mDbgPreferredRegs[14] = X64Reg_RAX;
|
/*mDbgPreferredRegs[14] = X64Reg_RAX;
|
||||||
|
|
|
@ -1769,6 +1769,9 @@ BeModule::BeModule(const StringImpl& moduleName, BeContext* context)
|
||||||
|
|
||||||
void BeModule::Hash(BeHashContext& hashCtx)
|
void BeModule::Hash(BeHashContext& hashCtx)
|
||||||
{
|
{
|
||||||
|
hashCtx.MixinStr(mTargetTriple);
|
||||||
|
hashCtx.MixinStr(mTargetCPU);
|
||||||
|
|
||||||
hashCtx.Mixin(mConfigConsts64.size());
|
hashCtx.Mixin(mConfigConsts64.size());
|
||||||
for (auto configConst : mConfigConsts64)
|
for (auto configConst : mConfigConsts64)
|
||||||
configConst->HashContent(hashCtx);
|
configConst->HashContent(hashCtx);
|
||||||
|
|
|
@ -2271,6 +2271,7 @@ public:
|
||||||
BeContext* mContext;
|
BeContext* mContext;
|
||||||
String mModuleName;
|
String mModuleName;
|
||||||
String mTargetTriple;
|
String mTargetTriple;
|
||||||
|
String mTargetCPU;
|
||||||
BeBlock* mActiveBlock;
|
BeBlock* mActiveBlock;
|
||||||
int mInsertPos;
|
int mInsertPos;
|
||||||
BeDbgLoc* mCurDbgLoc;
|
BeDbgLoc* mCurDbgLoc;
|
||||||
|
|
|
@ -9651,7 +9651,7 @@ static BfPlatformType GetPlatform(StringView str)
|
||||||
}
|
}
|
||||||
|
|
||||||
BF_EXPORT void BF_CALLTYPE BfCompiler_SetOptions(BfCompiler* bfCompiler, BfProject* hotProject, int hotIdx,
|
BF_EXPORT void BF_CALLTYPE BfCompiler_SetOptions(BfCompiler* bfCompiler, BfProject* hotProject, int hotIdx,
|
||||||
const char* targetTriple, int toolsetType, int simdSetting, int allocStackCount, int maxWorkerThreads,
|
const char* targetTriple, const char* targetCPU, int toolsetType, int simdSetting, int allocStackCount, int maxWorkerThreads,
|
||||||
BfCompilerOptionFlags optionFlags, char* mallocLinkName, char* freeLinkName)
|
BfCompilerOptionFlags optionFlags, char* mallocLinkName, char* freeLinkName)
|
||||||
{
|
{
|
||||||
BfLogSys(bfCompiler->mSystem, "BfCompiler_SetOptions\n");
|
BfLogSys(bfCompiler->mSystem, "BfCompiler_SetOptions\n");
|
||||||
|
@ -9664,6 +9664,7 @@ BF_EXPORT void BF_CALLTYPE BfCompiler_SetOptions(BfCompiler* bfCompiler, BfProje
|
||||||
options->mHotProject = hotProject;
|
options->mHotProject = hotProject;
|
||||||
options->mHotCompileIdx = hotIdx;
|
options->mHotCompileIdx = hotIdx;
|
||||||
options->mTargetTriple = targetTriple;
|
options->mTargetTriple = targetTriple;
|
||||||
|
options->mTargetCPU = targetCPU;
|
||||||
|
|
||||||
if (options->mTargetTriple.StartsWith("x86_64-"))
|
if (options->mTargetTriple.StartsWith("x86_64-"))
|
||||||
options->mMachineType = BfMachineType_x64;
|
options->mMachineType = BfMachineType_x64;
|
||||||
|
|
|
@ -96,6 +96,7 @@ public:
|
||||||
int32 mForceRebuildIdx;
|
int32 mForceRebuildIdx;
|
||||||
BfCompileOnDemandKind mCompileOnDemandKind;
|
BfCompileOnDemandKind mCompileOnDemandKind;
|
||||||
String mTargetTriple;
|
String mTargetTriple;
|
||||||
|
String mTargetCPU;
|
||||||
BfPlatformType mPlatformType;
|
BfPlatformType mPlatformType;
|
||||||
BfMachineType mMachineType;
|
BfMachineType mMachineType;
|
||||||
int mCLongSize;
|
int mCLongSize;
|
||||||
|
|
|
@ -2020,9 +2020,9 @@ void BfIRBuilder::WriteIR(const StringImpl& fileName)
|
||||||
NEW_CMD_INSERTED;
|
NEW_CMD_INSERTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
void BfIRBuilder::Module_SetTargetTriple(const StringImpl& targetTriple)
|
void BfIRBuilder::Module_SetTargetTriple(const StringImpl& targetTriple, const StringImpl& targetCPU)
|
||||||
{
|
{
|
||||||
WriteCmd(BfIRCmd_Module_SetTargetTriple, targetTriple);
|
WriteCmd(BfIRCmd_Module_SetTargetTriple, targetTriple, targetCPU);
|
||||||
NEW_CMD_INSERTED;
|
NEW_CMD_INSERTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1167,7 +1167,7 @@ public:
|
||||||
void RemoveIRCodeGen();
|
void RemoveIRCodeGen();
|
||||||
void WriteIR(const StringImpl& fileName);
|
void WriteIR(const StringImpl& fileName);
|
||||||
|
|
||||||
void Module_SetTargetTriple(const StringImpl& targetTriple);
|
void Module_SetTargetTriple(const StringImpl& targetTriple, const StringImpl& targetCPU);
|
||||||
void Module_AddModuleFlag(const StringImpl& flag, int val);
|
void Module_AddModuleFlag(const StringImpl& flag, int val);
|
||||||
|
|
||||||
BfIRType GetPrimitiveType(BfTypeCode typeCode);
|
BfIRType GetPrimitiveType(BfTypeCode typeCode);
|
||||||
|
|
|
@ -1645,7 +1645,7 @@ void BfIRCodeGen::InitTarget()
|
||||||
llvm::Triple theTriple = llvm::Triple(mLLVMModule->getTargetTriple());
|
llvm::Triple theTriple = llvm::Triple(mLLVMModule->getTargetTriple());
|
||||||
llvm::CodeGenOpt::Level optLvl = llvm::CodeGenOpt::None;
|
llvm::CodeGenOpt::Level optLvl = llvm::CodeGenOpt::None;
|
||||||
|
|
||||||
String cpuName = "";
|
String cpuName = mTargetCPU;
|
||||||
String arch = "";
|
String arch = "";
|
||||||
|
|
||||||
// Get the target specific parser.
|
// Get the target specific parser.
|
||||||
|
@ -1761,7 +1761,10 @@ void BfIRCodeGen::HandleNextCmd()
|
||||||
case BfIRCmd_Module_SetTargetTriple:
|
case BfIRCmd_Module_SetTargetTriple:
|
||||||
{
|
{
|
||||||
CMD_PARAM(String, targetTriple);
|
CMD_PARAM(String, targetTriple);
|
||||||
|
CMD_PARAM(String, targetCPU);
|
||||||
|
|
||||||
mTargetTriple.Set(targetTriple);
|
mTargetTriple.Set(targetTriple);
|
||||||
|
mTargetCPU = targetCPU;
|
||||||
if (targetTriple.IsEmpty())
|
if (targetTriple.IsEmpty())
|
||||||
mLLVMModule->setTargetTriple(llvm::sys::getDefaultTargetTriple());
|
mLLVMModule->setTargetTriple(llvm::sys::getDefaultTargetTriple());
|
||||||
else
|
else
|
||||||
|
|
|
@ -89,6 +89,7 @@ public:
|
||||||
|
|
||||||
BumpAllocator mAlloc;
|
BumpAllocator mAlloc;
|
||||||
BfTargetTriple mTargetTriple;
|
BfTargetTriple mTargetTriple;
|
||||||
|
String mTargetCPU;
|
||||||
String mModuleName;
|
String mModuleName;
|
||||||
llvm::LLVMContext* mLLVMContext;
|
llvm::LLVMContext* mLLVMContext;
|
||||||
llvm::Module* mLLVMModule;
|
llvm::Module* mLLVMModule;
|
||||||
|
|
|
@ -1012,7 +1012,7 @@ void BfModule::FinishInit()
|
||||||
|
|
||||||
mBfIRBuilder->Start(mModuleName, mCompiler->mSystem->mPtrSize, IsOptimized());
|
mBfIRBuilder->Start(mModuleName, mCompiler->mSystem->mPtrSize, IsOptimized());
|
||||||
|
|
||||||
mBfIRBuilder->Module_SetTargetTriple(mCompiler->mOptions.mTargetTriple);
|
mBfIRBuilder->Module_SetTargetTriple(mCompiler->mOptions.mTargetTriple, mCompiler->mOptions.mTargetCPU);
|
||||||
|
|
||||||
mBfIRBuilder->SetBackend(IsTargetingBeefBackend());
|
mBfIRBuilder->SetBackend(IsTargetingBeefBackend());
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue