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/+/33773
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Kokoro-Presubmit: kokoro <noreply+kokoro@google.com>
diff --git a/src/Reactor/LLVMReactor.cpp b/src/Reactor/LLVMReactor.cpp
index 8d08ca4..c2c7ae7 100644
--- a/src/Reactor/LLVMReactor.cpp
+++ b/src/Reactor/LLVMReactor.cpp
@@ -123,8 +123,9 @@
 	public:
 		static JITGlobals const * get();
 
+		std::string mcpu;
 		std::vector<std::string> mattrs;
-		const char* arch;
+		const char* march;
 		llvm::TargetOptions targetOptions;
 		llvm::DataLayout dataLayout = llvm::DataLayout("");
 
@@ -140,6 +141,9 @@
 
 	JITGlobals::JITGlobals()
 	{
+		// mcpu
+		mcpu = llvm::sys::getHostCPUName();
+
 		// mattrs
 		llvm::StringMap<bool> features;
 		bool ok = llvm::sys::getHostCPUFeatures(features);
@@ -177,21 +181,21 @@
 
 		// arch
 #if defined(__x86_64__)
-		arch = "x86-64";
+		march = "x86-64";
 #elif defined(__i386__)
-		arch = "x86";
+		march = "x86";
 #elif defined(__aarch64__)
-		arch = "arm64";
+		march = "arm64";
 #elif defined(__arm__)
-		arch = "arm";
+		march = "arm";
 #elif defined(__mips__)
 #if defined(__mips64)
-		arch = "mips64el";
+		march = "mips64el";
 #else
-		arch = "mipsel";
+		march = "mipsel";
 #endif
 #elif defined(__powerpc64__) && __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
-		arch = "ppc64le";
+		march = "ppc64le";
 #else
 		#error "unknown architecture"
 #endif
@@ -203,7 +207,8 @@
 		auto targetMachine = std::unique_ptr<llvm::TargetMachine>(
 			llvm::EngineBuilder()
 				.setOptLevel(llvm::CodeGenOpt::None)
-				.setMArch(arch)
+				.setMCPU(mcpu)
+				.setMArch(march)
 				.setMAttrs(mattrs)
 				.setTargetOptions(targetOptions)
 				.selectTarget());
@@ -248,7 +253,8 @@
 #else
 				.setOptLevel(toLLVM(optLevel))
 #endif // ENABLE_RR_DEBUG_INFO
-				.setMArch(JITGlobals::get()->arch)
+				.setMCPU(JITGlobals::get()->mcpu)
+				.setMArch(JITGlobals::get()->march)
 				.setMAttrs(JITGlobals::get()->mattrs)
 				.setTargetOptions(JITGlobals::get()->targetOptions)
 				.selectTarget()),