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

Added Target CPU workspace override

This commit is contained in:
Brian Fiete 2022-01-25 07:04:54 -05:00
parent 91e856fc0b
commit 125d5c0c8c
14 changed files with 34 additions and 13 deletions

View file

@ -9651,7 +9651,7 @@ static BfPlatformType GetPlatform(StringView str)
}
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)
{
BfLogSys(bfCompiler->mSystem, "BfCompiler_SetOptions\n");
@ -9664,6 +9664,7 @@ BF_EXPORT void BF_CALLTYPE BfCompiler_SetOptions(BfCompiler* bfCompiler, BfProje
options->mHotProject = hotProject;
options->mHotCompileIdx = hotIdx;
options->mTargetTriple = targetTriple;
options->mTargetCPU = targetCPU;
if (options->mTargetTriple.StartsWith("x86_64-"))
options->mMachineType = BfMachineType_x64;

View file

@ -96,6 +96,7 @@ public:
int32 mForceRebuildIdx;
BfCompileOnDemandKind mCompileOnDemandKind;
String mTargetTriple;
String mTargetCPU;
BfPlatformType mPlatformType;
BfMachineType mMachineType;
int mCLongSize;

View file

@ -2020,9 +2020,9 @@ void BfIRBuilder::WriteIR(const StringImpl& fileName)
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;
}

View file

@ -1167,7 +1167,7 @@ public:
void RemoveIRCodeGen();
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);
BfIRType GetPrimitiveType(BfTypeCode typeCode);

View file

@ -1645,7 +1645,7 @@ void BfIRCodeGen::InitTarget()
llvm::Triple theTriple = llvm::Triple(mLLVMModule->getTargetTriple());
llvm::CodeGenOpt::Level optLvl = llvm::CodeGenOpt::None;
String cpuName = "";
String cpuName = mTargetCPU;
String arch = "";
// Get the target specific parser.
@ -1761,7 +1761,10 @@ void BfIRCodeGen::HandleNextCmd()
case BfIRCmd_Module_SetTargetTriple:
{
CMD_PARAM(String, targetTriple);
CMD_PARAM(String, targetCPU);
mTargetTriple.Set(targetTriple);
mTargetCPU = targetCPU;
if (targetTriple.IsEmpty())
mLLVMModule->setTargetTriple(llvm::sys::getDefaultTargetTriple());
else

View file

@ -89,6 +89,7 @@ public:
BumpAllocator mAlloc;
BfTargetTriple mTargetTriple;
String mTargetCPU;
String mModuleName;
llvm::LLVMContext* mLLVMContext;
llvm::Module* mLLVMModule;

View file

@ -1012,7 +1012,7 @@ void BfModule::FinishInit()
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());