Conversation
Add an MSVC-compatible <arm64_neon.h> resource header that forwards to Clang's generated <arm_neon.h>. This lets ARM64 Windows code using the MSVC header name lower NEON intrinsics through Clang builtins instead of leaving external neon_* calls such as neon_ld1m4_q32 Fix llvm#195683
|
@llvm/pr-subscribers-clang Author: GkvJwa ChangesAdd an MSVC-compatible <arm64_neon.h> resource header that forwards to Fix #195683 Full diff: https://github.com/llvm/llvm-project/pull/196014.diff 4 Files Affected:
diff --git a/clang/lib/Headers/CMakeLists.txt b/clang/lib/Headers/CMakeLists.txt
index d60ae2b5961e0..ce34f8b9410a7 100644
--- a/clang/lib/Headers/CMakeLists.txt
+++ b/clang/lib/Headers/CMakeLists.txt
@@ -55,6 +55,7 @@ set(arm_only_files
)
set(aarch64_only_files
+ arm64_neon.h
arm64intr.h
arm_neon_sve_bridge.h
)
diff --git a/clang/lib/Headers/arm64_neon.h b/clang/lib/Headers/arm64_neon.h
new file mode 100644
index 0000000000000..380e88d545621
--- /dev/null
+++ b/clang/lib/Headers/arm64_neon.h
@@ -0,0 +1,15 @@
+/*===---- arm64_neon.h - ARM64 NEON intrinsics -----------------------------===
+ *
+ * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+ * See https://llvm.org/LICENSE.txt for license information.
+ * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+ *
+ *===-----------------------------------------------------------------------===
+ */
+
+#ifndef __ARM64_NEON_H
+#define __ARM64_NEON_H
+
+#include <arm_neon.h>
+
+#endif /* __ARM64_NEON_H */
diff --git a/clang/lib/Headers/module.modulemap b/clang/lib/Headers/module.modulemap
index 3fcaa55f1110e..c8f96df1672c1 100644
--- a/clang/lib/Headers/module.modulemap
+++ b/clang/lib/Headers/module.modulemap
@@ -50,6 +50,12 @@ module _Builtin_intrinsics [system] [extern_c] {
header "arm64intr.h"
export *
+
+ explicit module neon {
+ requires neon
+ header "arm64_neon.h"
+ export *
+ }
}
explicit module intel {
diff --git a/clang/test/CodeGen/arm64-neon-header.c b/clang/test/CodeGen/arm64-neon-header.c
new file mode 100644
index 0000000000000..f0aea4093caad
--- /dev/null
+++ b/clang/test/CodeGen/arm64-neon-header.c
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -triple arm64-pc-windows-msvc -fms-compatibility \
+// RUN: -emit-llvm -o - %s | FileCheck %s
+
+#include <arm64_neon.h>
+
+// CHECK-LABEL: define{{.*}} @test_vld1q_s32_x4(
+// CHECK-NOT: neon_ld1m4_q32
+// CHECK: call { <4 x i32>, <4 x i32>, <4 x i32>, <4 x i32> } @llvm.aarch64.neon.ld1x4.v4i32.p0(ptr {{.*}})
+// CHECK-NOT: neon_ld1m4_q32
+// CHECK: ret
+int32x4x4_t test_vld1q_s32_x4(int32_t const *a) {
+ return vld1q_s32_x4(a);
+}
|
|
@llvm/pr-subscribers-backend-x86 Author: GkvJwa ChangesAdd an MSVC-compatible <arm64_neon.h> resource header that forwards to Fix #195683 Full diff: https://github.com/llvm/llvm-project/pull/196014.diff 4 Files Affected:
diff --git a/clang/lib/Headers/CMakeLists.txt b/clang/lib/Headers/CMakeLists.txt
index d60ae2b5961e0..ce34f8b9410a7 100644
--- a/clang/lib/Headers/CMakeLists.txt
+++ b/clang/lib/Headers/CMakeLists.txt
@@ -55,6 +55,7 @@ set(arm_only_files
)
set(aarch64_only_files
+ arm64_neon.h
arm64intr.h
arm_neon_sve_bridge.h
)
diff --git a/clang/lib/Headers/arm64_neon.h b/clang/lib/Headers/arm64_neon.h
new file mode 100644
index 0000000000000..380e88d545621
--- /dev/null
+++ b/clang/lib/Headers/arm64_neon.h
@@ -0,0 +1,15 @@
+/*===---- arm64_neon.h - ARM64 NEON intrinsics -----------------------------===
+ *
+ * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+ * See https://llvm.org/LICENSE.txt for license information.
+ * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+ *
+ *===-----------------------------------------------------------------------===
+ */
+
+#ifndef __ARM64_NEON_H
+#define __ARM64_NEON_H
+
+#include <arm_neon.h>
+
+#endif /* __ARM64_NEON_H */
diff --git a/clang/lib/Headers/module.modulemap b/clang/lib/Headers/module.modulemap
index 3fcaa55f1110e..c8f96df1672c1 100644
--- a/clang/lib/Headers/module.modulemap
+++ b/clang/lib/Headers/module.modulemap
@@ -50,6 +50,12 @@ module _Builtin_intrinsics [system] [extern_c] {
header "arm64intr.h"
export *
+
+ explicit module neon {
+ requires neon
+ header "arm64_neon.h"
+ export *
+ }
}
explicit module intel {
diff --git a/clang/test/CodeGen/arm64-neon-header.c b/clang/test/CodeGen/arm64-neon-header.c
new file mode 100644
index 0000000000000..f0aea4093caad
--- /dev/null
+++ b/clang/test/CodeGen/arm64-neon-header.c
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -triple arm64-pc-windows-msvc -fms-compatibility \
+// RUN: -emit-llvm -o - %s | FileCheck %s
+
+#include <arm64_neon.h>
+
+// CHECK-LABEL: define{{.*}} @test_vld1q_s32_x4(
+// CHECK-NOT: neon_ld1m4_q32
+// CHECK: call { <4 x i32>, <4 x i32>, <4 x i32>, <4 x i32> } @llvm.aarch64.neon.ld1x4.v4i32.p0(ptr {{.*}})
+// CHECK-NOT: neon_ld1m4_q32
+// CHECK: ret
+int32x4x4_t test_vld1q_s32_x4(int32_t const *a) {
+ return vld1q_s32_x4(a);
+}
|
| */ | ||
|
|
||
| #ifndef __ARM64_NEON_H | ||
| #define __ARM64_NEON_H |
There was a problem hiding this comment.
Please restrict this so we only do this forwarding on MSVC targets: #ifndef _MSC_VER #include_next "arm64_neon.h" or something like that. (There should be some examples in other headers.)
|
Adding some reviewers for the modulemap changes; I'm not really confident to review that. Otherwise LGTM |
2437a74 to
ae0a8aa
Compare
|
Merge it, if any problems with module, leave a comment and I will handle it |
|
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/51/builds/36917 Here is the relevant piece of the build log for the reference |
Add an MSVC-compatible <arm64_neon.h> resource header that forwards to
Clang's generated <arm_neon.h>. This lets ARM64 Windows code using the
MSVC header name lower NEON intrinsics through Clang builtins instead of
eaving external neon_* calls such as neon_ld1m4_q32
Fixes #195683