diff options
Diffstat (limited to 'clang/lib/Driver/Tools.cpp')
| -rw-r--r-- | clang/lib/Driver/Tools.cpp | 31 |
1 files changed, 26 insertions, 5 deletions
diff --git a/clang/lib/Driver/Tools.cpp b/clang/lib/Driver/Tools.cpp index ceef90f171c..9d7dc70be70 100644 --- a/clang/lib/Driver/Tools.cpp +++ b/clang/lib/Driver/Tools.cpp @@ -1271,8 +1271,12 @@ static const char *getSystemZTargetCPU(const ArgList &Args) { static const char *getX86TargetCPU(const ArgList &Args, const llvm::Triple &Triple) { if (const Arg *A = Args.getLastArg(options::OPT_march_EQ)) { - if (StringRef(A->getValue()) != "native") + if (StringRef(A->getValue()) != "native") { + if (Triple.isOSDarwin() && Triple.getArchName() == "x86_64h") + return "core-avx2"; + return A->getValue(); + } // FIXME: Reject attempts to use -march=native unless the target matches // the host. @@ -1293,8 +1297,11 @@ static const char *getX86TargetCPU(const ArgList &Args, bool Is64Bit = Triple.getArch() == llvm::Triple::x86_64; // FIXME: Need target hooks. - if (Triple.isOSDarwin()) + if (Triple.isOSDarwin()) { + if (Triple.getArchName() == "x86_64h") + return "core-avx2"; return Is64Bit ? "core2" : "yonah"; + } // All x86 devices running Android have core2 as their common // denominator. This makes a better choice than pentium4. @@ -1380,8 +1387,22 @@ static std::string getCPUName(const ArgList &Args, const llvm::Triple &T) { } } -static void getX86TargetFeatures(const ArgList &Args, +static void getX86TargetFeatures(const llvm::Triple &Triple, + const ArgList &Args, std::vector<const char *> &Features) { + if (Triple.getArchName() == "x86_64h") { + // x86_64h implies quite a few of the more modern subtarget features + // for Haswell class CPUs, but not all of them. Opt-out of a few. + Features.push_back("-rdrnd"); + Features.push_back("-aes"); + Features.push_back("-pclmul"); + Features.push_back("-rtm"); + Features.push_back("-hle"); + Features.push_back("-fsgsbase"); + } + + // Now add any that the user explicitly requested on the command line, + // which may override the defaults. for (arg_iterator it = Args.filtered_begin(options::OPT_m_x86_Features_Group), ie = Args.filtered_end(); it != ie; ++it) { @@ -1508,7 +1529,7 @@ static void getTargetFeatures(const Driver &D, const llvm::Triple &Triple, break; case llvm::Triple::x86: case llvm::Triple::x86_64: - getX86TargetFeatures(Args, Features); + getX86TargetFeatures(Triple, Args, Features); break; } @@ -4518,7 +4539,7 @@ llvm::Triple::ArchType darwin::getArchTypeForDarwinArchName(StringRef Str) { .Cases("i386", "i486", "i486SX", "i586", "i686", llvm::Triple::x86) .Cases("pentium", "pentpro", "pentIIm3", "pentIIm5", "pentium4", llvm::Triple::x86) - .Case("x86_64", llvm::Triple::x86_64) + .Cases("x86_64", "x86_64h", llvm::Triple::x86_64) // This is derived from the driver driver. .Cases("arm", "armv4t", "armv5", "armv6", "armv6m", llvm::Triple::arm) .Cases("armv7", "armv7em", "armv7f", "armv7k", "armv7m", llvm::Triple::arm) |

