[PATCH] D42538: [clang-cl] Add support for /arch:AVX512F and /arch:AVX512
Nico Weber via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Jan 25 07:11:45 PST 2018
thakis created this revision.
thakis added a reviewer: hans.
thakis edited the summary of this revision.
Also refactor the existing AVX / AVX2 code to not repeat itself in both the 32-bit and 64-bit cases.
For /arch:AVX512F, we define `__AVX512F__` `__AVX512CD__` `__AVX512ER__` `__AVX512PF__`. cl.exe defines (according to /Bz) `__AVX512F__` and `__AVX512CD__`, and 64-bit cl also defines `_NO_PREFETCHW`.
For /arch:AVX512, we define `__AVX512F__`, `__AVX512CD__`, `__AVX512BW__`__AVX512DQ__`, `__AVX512VL__`. cl.exe defines `__AVX512F__`, `__AVX512CD__`, `__AVX512BW__`, `__AVX512DQ__`, `__AVX512VL__`, and on 64-bit also `_NO_PREFETCHW`.
So not 100% identical, but seems pretty close.
https://reviews.llvm.org/D42538
Files:
lib/Driver/ToolChains/Arch/X86.cpp
test/Driver/cl-x86-flags.c
Index: test/Driver/cl-x86-flags.c
===================================================================
--- test/Driver/cl-x86-flags.c
+++ test/Driver/cl-x86-flags.c
@@ -68,6 +68,26 @@
// RUN: %clang_cl -m32 -arch:avx2 --target=i386-pc-windows -### -- 2>&1 %s | FileCheck -check-prefix=avx2 %s
// 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
#if defined(TEST_64_ARCH_AVX)
#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
// 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() {
}
Index: lib/Driver/ToolChains/Arch/X86.cpp
===================================================================
--- lib/Driver/ToolChains/Arch/X86.cpp
+++ lib/Driver/ToolChains/Arch/X86.cpp
@@ -43,19 +43,20 @@
if (const Arg *A = Args.getLastArgNoClaim(options::OPT__SLASH_arch)) {
// Mapping built by looking at lib/Basic's X86TargetInfo::initFeatureMap().
StringRef Arch = A->getValue();
- const char *CPU;
- if (Triple.getArch() == llvm::Triple::x86) {
+ const char *CPU = nullptr;
+ if (Triple.getArch() == llvm::Triple::x86) { // 32-bit-only /arch: flags.
CPU = llvm::StringSwitch<const char *>(Arch)
.Case("IA32", "i386")
.Case("SSE", "pentium3")
.Case("SSE2", "pentium4")
- .Case("AVX", "sandybridge")
- .Case("AVX2", "haswell")
.Default(nullptr);
- } else {
+ }
+ if (CPU == nullptr) { // 32-bit and 64-bit /arch: flags.
CPU = llvm::StringSwitch<const char *>(Arch)
.Case("AVX", "sandybridge")
.Case("AVX2", "haswell")
+ .Case("AVX512F", "knl")
+ .Case("AVX512", "skylake-avx512")
.Default(nullptr);
}
if (CPU) {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D42538.131444.patch
Type: text/x-patch
Size: 3679 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180125/56bf570b/attachment.bin>
More information about the cfe-commits
mailing list