Commit 49f8051e by Ben Clayton

LLVMReactor: Include the host mcpu in the target builder.

May unlock features that are not exposed by march. Change-Id: I4f10dfc93f75eab502824ec155daa9fbbb3d3d55 Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/33773Tested-by: 's avatarNicolas Capens <nicolascapens@google.com> Reviewed-by: 's avatarNicolas Capens <nicolascapens@google.com> Kokoro-Presubmit: kokoro <noreply+kokoro@google.com>
parent caa9cf75
...@@ -123,8 +123,9 @@ namespace ...@@ -123,8 +123,9 @@ namespace
public: public:
static JITGlobals const * get(); static JITGlobals const * get();
std::string mcpu;
std::vector<std::string> mattrs; std::vector<std::string> mattrs;
const char* arch; const char* march;
llvm::TargetOptions targetOptions; llvm::TargetOptions targetOptions;
llvm::DataLayout dataLayout = llvm::DataLayout(""); llvm::DataLayout dataLayout = llvm::DataLayout("");
...@@ -140,6 +141,9 @@ namespace ...@@ -140,6 +141,9 @@ namespace
JITGlobals::JITGlobals() JITGlobals::JITGlobals()
{ {
// mcpu
mcpu = llvm::sys::getHostCPUName();
// mattrs // mattrs
llvm::StringMap<bool> features; llvm::StringMap<bool> features;
bool ok = llvm::sys::getHostCPUFeatures(features); bool ok = llvm::sys::getHostCPUFeatures(features);
...@@ -177,21 +181,21 @@ namespace ...@@ -177,21 +181,21 @@ namespace
// arch // arch
#if defined(__x86_64__) #if defined(__x86_64__)
arch = "x86-64"; march = "x86-64";
#elif defined(__i386__) #elif defined(__i386__)
arch = "x86"; march = "x86";
#elif defined(__aarch64__) #elif defined(__aarch64__)
arch = "arm64"; march = "arm64";
#elif defined(__arm__) #elif defined(__arm__)
arch = "arm"; march = "arm";
#elif defined(__mips__) #elif defined(__mips__)
#if defined(__mips64) #if defined(__mips64)
arch = "mips64el"; march = "mips64el";
#else #else
arch = "mipsel"; march = "mipsel";
#endif #endif
#elif defined(__powerpc64__) && __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ #elif defined(__powerpc64__) && __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
arch = "ppc64le"; march = "ppc64le";
#else #else
#error "unknown architecture" #error "unknown architecture"
#endif #endif
...@@ -203,7 +207,8 @@ namespace ...@@ -203,7 +207,8 @@ namespace
auto targetMachine = std::unique_ptr<llvm::TargetMachine>( auto targetMachine = std::unique_ptr<llvm::TargetMachine>(
llvm::EngineBuilder() llvm::EngineBuilder()
.setOptLevel(llvm::CodeGenOpt::None) .setOptLevel(llvm::CodeGenOpt::None)
.setMArch(arch) .setMCPU(mcpu)
.setMArch(march)
.setMAttrs(mattrs) .setMAttrs(mattrs)
.setTargetOptions(targetOptions) .setTargetOptions(targetOptions)
.selectTarget()); .selectTarget());
...@@ -248,7 +253,8 @@ namespace ...@@ -248,7 +253,8 @@ namespace
#else #else
.setOptLevel(toLLVM(optLevel)) .setOptLevel(toLLVM(optLevel))
#endif // ENABLE_RR_DEBUG_INFO #endif // ENABLE_RR_DEBUG_INFO
.setMArch(JITGlobals::get()->arch) .setMCPU(JITGlobals::get()->mcpu)
.setMArch(JITGlobals::get()->march)
.setMAttrs(JITGlobals::get()->mattrs) .setMAttrs(JITGlobals::get()->mattrs)
.setTargetOptions(JITGlobals::get()->targetOptions) .setTargetOptions(JITGlobals::get()->targetOptions)
.selectTarget()), .selectTarget()),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment