forked from OSchip/llvm-project
[clang-cl] Add support for /arch:AVX512F and /arch:AVX512
For /arch:AVX512F: clang-cl and cl.exe both defines __AVX512F__ __AVX512CD__. clang-cl also defines __AVX512ER__ __AVX512PF__. 64-bit cl.exe also defines (according to /Bz) _NO_PREFETCHW. For /arch:AVX512: clang-cl and cl.exe both define __AVX512F__ __AVX512CD__ __AVX512BW__ __AVX512DQ__ __AVX512VL__. 64-bit cl.exe also defines _NO_PREFETCHW. So not 100% identical, but pretty close. Also refactor the existing AVX / AVX2 code to not repeat itself in both the 32-bit and 64-bit cases. https://reviews.llvm.org/D42538 llvm-svn: 323433
This commit is contained in:
parent
a0b2c78efc
commit
75ae75cd17
|
@ -43,19 +43,20 @@ const char *x86::getX86TargetCPU(const ArgList &Args,
|
||||||
if (const Arg *A = Args.getLastArgNoClaim(options::OPT__SLASH_arch)) {
|
if (const Arg *A = Args.getLastArgNoClaim(options::OPT__SLASH_arch)) {
|
||||||
// Mapping built by looking at lib/Basic's X86TargetInfo::initFeatureMap().
|
// Mapping built by looking at lib/Basic's X86TargetInfo::initFeatureMap().
|
||||||
StringRef Arch = A->getValue();
|
StringRef Arch = A->getValue();
|
||||||
const char *CPU;
|
const char *CPU = nullptr;
|
||||||
if (Triple.getArch() == llvm::Triple::x86) {
|
if (Triple.getArch() == llvm::Triple::x86) { // 32-bit-only /arch: flags.
|
||||||
CPU = llvm::StringSwitch<const char *>(Arch)
|
CPU = llvm::StringSwitch<const char *>(Arch)
|
||||||
.Case("IA32", "i386")
|
.Case("IA32", "i386")
|
||||||
.Case("SSE", "pentium3")
|
.Case("SSE", "pentium3")
|
||||||
.Case("SSE2", "pentium4")
|
.Case("SSE2", "pentium4")
|
||||||
.Case("AVX", "sandybridge")
|
|
||||||
.Case("AVX2", "haswell")
|
|
||||||
.Default(nullptr);
|
.Default(nullptr);
|
||||||
} else {
|
}
|
||||||
|
if (CPU == nullptr) { // 32-bit and 64-bit /arch: flags.
|
||||||
CPU = llvm::StringSwitch<const char *>(Arch)
|
CPU = llvm::StringSwitch<const char *>(Arch)
|
||||||
.Case("AVX", "sandybridge")
|
.Case("AVX", "sandybridge")
|
||||||
.Case("AVX2", "haswell")
|
.Case("AVX2", "haswell")
|
||||||
|
.Case("AVX512F", "knl")
|
||||||
|
.Case("AVX512", "skylake-avx512")
|
||||||
.Default(nullptr);
|
.Default(nullptr);
|
||||||
}
|
}
|
||||||
if (CPU) {
|
if (CPU) {
|
||||||
|
|
|
@ -68,6 +68,26 @@
|
||||||
// RUN: %clang_cl -m32 -arch:avx2 --target=i386-pc-windows -### -- 2>&1 %s | FileCheck -check-prefix=avx2 %s
|
// RUN: %clang_cl -m32 -arch:avx2 --target=i386-pc-windows -### -- 2>&1 %s | FileCheck -check-prefix=avx2 %s
|
||||||
// avx2: argument unused during compilation
|
// avx2: argument unused during compilation
|
||||||
|
|
||||||
|
// RUN: %clang_cl -m32 -arch:AVX512F --target=i386-pc-windows /c -Xclang -verify -DTEST_32_ARCH_AVX512F -- %s
|
||||||
|
#if defined(TEST_32_ARCH_AVX512F)
|
||||||
|
#if _M_IX86_FP != 2 || !__AVX__ || !__AVX2__ || !__AVX512F__ || __AVX512BW__
|
||||||
|
#error fail
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// RUN: %clang_cl -m32 -arch:avx512f --target=i386-pc-windows -### -- 2>&1 %s | FileCheck -check-prefix=avx512f %s
|
||||||
|
// avx512f: argument unused during compilation
|
||||||
|
|
||||||
|
// RUN: %clang_cl -m32 -arch:AVX512 --target=i386-pc-windows /c -Xclang -verify -DTEST_32_ARCH_AVX512 -- %s
|
||||||
|
#if defined(TEST_32_ARCH_AVX512)
|
||||||
|
#if _M_IX86_FP != 2 || !__AVX__ || !__AVX2__ || !__AVX512F__ || !__AVX512BW__
|
||||||
|
#error fail
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// RUN: %clang_cl -m32 -arch:avx512 --target=i386-pc-windows -### -- 2>&1 %s | FileCheck -check-prefix=avx512 %s
|
||||||
|
// avx512: argument unused during compilation
|
||||||
|
|
||||||
// RUN: %clang_cl -m64 -arch:AVX --target=x86_64-pc-windows /c -Xclang -verify -DTEST_64_ARCH_AVX -- %s
|
// RUN: %clang_cl -m64 -arch:AVX --target=x86_64-pc-windows /c -Xclang -verify -DTEST_64_ARCH_AVX -- %s
|
||||||
#if defined(TEST_64_ARCH_AVX)
|
#if defined(TEST_64_ARCH_AVX)
|
||||||
#if _M_IX86_FP || !__AVX__ || __AVX2__ || __AVX512F__ || __AVX512BW__
|
#if _M_IX86_FP || !__AVX__ || __AVX2__ || __AVX512F__ || __AVX512BW__
|
||||||
|
@ -88,5 +108,25 @@
|
||||||
// RUN: %clang_cl -m64 -arch:avx2 --target=x86_64-pc-windows -### -- 2>&1 %s | FileCheck -check-prefix=avx264 %s
|
// RUN: %clang_cl -m64 -arch:avx2 --target=x86_64-pc-windows -### -- 2>&1 %s | FileCheck -check-prefix=avx264 %s
|
||||||
// avx264: argument unused during compilation
|
// avx264: argument unused during compilation
|
||||||
|
|
||||||
|
// RUN: %clang_cl -m64 -arch:AVX512F --target=i386-pc-windows /c -Xclang -verify -DTEST_64_ARCH_AVX512F -- %s
|
||||||
|
#if defined(TEST_64_ARCH_AVX512F)
|
||||||
|
#if _M_IX86_FP || !__AVX__ || !__AVX2__ || !__AVX512F__ || __AVX512BW__
|
||||||
|
#error fail
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// RUN: %clang_cl -m64 -arch:avx512f --target=i386-pc-windows -### -- 2>&1 %s | FileCheck -check-prefix=avx512f64 %s
|
||||||
|
// avx512f64: argument unused during compilation
|
||||||
|
|
||||||
|
// RUN: %clang_cl -m64 -arch:AVX512 --target=i386-pc-windows /c -Xclang -verify -DTEST_64_ARCH_AVX512 -- %s
|
||||||
|
#if defined(TEST_64_ARCH_AVX512)
|
||||||
|
#if _M_IX86_FP || !__AVX__ || !__AVX2__ || !__AVX512F__ || !__AVX512BW__
|
||||||
|
#error fail
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// RUN: %clang_cl -m64 -arch:avx512 --target=i386-pc-windows -### -- 2>&1 %s | FileCheck -check-prefix=avx51264 %s
|
||||||
|
// avx51264: argument unused during compilation
|
||||||
|
|
||||||
void f() {
|
void f() {
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue