diff options
author | Reid Kleckner <reid@kleckner.net> | 2015-06-30 16:32:04 +0000 |
---|---|---|
committer | Reid Kleckner <reid@kleckner.net> | 2015-06-30 16:32:04 +0000 |
commit | 3123eff5ebea42904ffb9297e6f0a2eb403ea03d (patch) | |
tree | 13fccdf8f254853b326bc86619d0f081654827aa /clang/lib/Driver/Tools.cpp | |
parent | 0ca438c6b1b92863a3d765071890330da4dc05f8 (diff) | |
download | bcm5719-llvm-3123eff5ebea42904ffb9297e6f0a2eb403ea03d.tar.gz bcm5719-llvm-3123eff5ebea42904ffb9297e6f0a2eb403ea03d.zip |
[clang-cl] Use /arch: to set the base target CPU
The main effect of this change is that /arch:IA32 will use i386 as the
CPU, while clang-cl will continue to default to pentium4 (aka SSE2 plus
the usual other features).
/arch:AVX and /arch:AVX2 will also now enable the other features
available in sandybridge and haswell respectively, which is consistent
with MSDN.
llvm-svn: 241077
Diffstat (limited to 'clang/lib/Driver/Tools.cpp')
-rw-r--r-- | clang/lib/Driver/Tools.cpp | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/clang/lib/Driver/Tools.cpp b/clang/lib/Driver/Tools.cpp index d635d38dd03..bb56c659e89 100644 --- a/clang/lib/Driver/Tools.cpp +++ b/clang/lib/Driver/Tools.cpp @@ -1386,6 +1386,28 @@ static const char *getX86TargetCPU(const ArgList &Args, return Args.MakeArgString(CPU); } + if (const Arg *A = Args.getLastArg(options::OPT__SLASH_arch)) { + // Mapping built by referring to X86TargetInfo::getDefaultFeatures(). + StringRef Arch = A->getValue(); + const char *CPU; + if (Triple.getArch() == llvm::Triple::x86) { + CPU = llvm::StringSwitch<const char *>(Arch) + .Case("IA32", "i386") + .Case("SSE", "pentium3") + .Case("SSE2", "pentium4") + .Case("AVX", "sandybridge") + .Case("AVX2", "haswell") + .Default(nullptr); + } else { + CPU = llvm::StringSwitch<const char *>(Arch) + .Case("AVX", "sandybridge") + .Case("AVX2", "haswell") + .Default(nullptr); + } + if (CPU) + return CPU; + } + // Select the default CPU if none was given (or detection failed). if (Triple.getArch() != llvm::Triple::x86_64 && |