[clang] [clang] Add arm64_neon.h wrapper (PR #196014)
via cfe-commits
cfe-commits at lists.llvm.org
Wed May 6 00:09:09 PDT 2026
llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clang
Author: GkvJwa
<details>
<summary>Changes</summary>
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
Fix #<!-- -->195683
---
Full diff: https://github.com/llvm/llvm-project/pull/196014.diff
4 Files Affected:
- (modified) clang/lib/Headers/CMakeLists.txt (+1)
- (added) clang/lib/Headers/arm64_neon.h (+15)
- (modified) clang/lib/Headers/module.modulemap (+6)
- (added) clang/test/CodeGen/arm64-neon-header.c (+13)
``````````diff
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);
+}
``````````
</details>
https://github.com/llvm/llvm-project/pull/196014
More information about the cfe-commits
mailing list