summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJim Grosbach <grosbach@apple.com>2014-04-12 01:34:31 +0000
committerJim Grosbach <grosbach@apple.com>2014-04-12 01:34:31 +0000
commitd023e14a5e2af661d1bca44939f5b433fd00a238 (patch)
tree0fae9970d986c3b627a04098542f1ea571ac9dae
parent6bb00df864ea4e2f74f47c088b65baaff962cca5 (diff)
downloadllvm-d023e14a5e2af661d1bca44939f5b433fd00a238.tar.gz
llvm-d023e14a5e2af661d1bca44939f5b433fd00a238.tar.bz2
llvm-d023e14a5e2af661d1bca44939f5b433fd00a238.tar.xz
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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@206095 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--tools/llc/llc.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/tools/llc/llc.cpp b/tools/llc/llc.cpp
index 8fbdc49e5e..0c8d14d11d 100644
--- a/tools/llc/llc.cpp
+++ b/tools/llc/llc.cpp
@@ -213,6 +213,12 @@ static int compileModule(char **argv, LLVMContext &Context) {
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));