[llvm] r206095 - llc: Add support for -mcpu=native.

Jim Grosbach grosbach at apple.com
Fri Apr 11 18:34:31 PDT 2014


Author: grosbach
Date: Fri Apr 11 20:34:31 2014
New Revision: 206095

URL: http://llvm.org/viewvc/llvm-project?rev=206095&view=rev
Log:
llc: Add support for -mcpu=native.

When -mcpu=native is passed, autodetect the host CPU and pass that
as the CPU name to the TargetMachine factory method.

Modified:
    llvm/trunk/tools/llc/llc.cpp

Modified: llvm/trunk/tools/llc/llc.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llc/llc.cpp?rev=206095&r1=206094&r2=206095&view=diff
==============================================================================
--- llvm/trunk/tools/llc/llc.cpp (original)
+++ llvm/trunk/tools/llc/llc.cpp Fri Apr 11 20:34:31 2014
@@ -213,6 +213,12 @@ static int compileModule(char **argv, LL
   bool SkipModule = MCPU == "help" ||
                     (!MAttrs.empty() && MAttrs.front() == "help");
 
+  // If user asked for the 'native' CPU, autodetect here. If autodection fails,
+  // this will set the CPU to an empty string which tells the target to
+  // pick a basic default.
+  if (MCPU == "native")
+    MCPU = sys::getHostCPUName();
+
   // If user just wants to list available options, skip module loading
   if (!SkipModule) {
     M.reset(ParseIRFile(InputFilename, Err, Context));





More information about the llvm-commits mailing list