diff options
author | Amy Huang <akhuang@google.com> | 2024-07-08 12:59:02 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-07-08 12:59:02 -0700 |
commit | ae7ab043f2d8077ed00bb2d3239da4b96ad4b387 (patch) | |
tree | c608aca761dddc540b405de469e097720c3e3bcb /clang/test | |
parent | 393eff4e02e7ab3d234d246a8d6912c8e745e6f9 (diff) | |
download | llvm-ae7ab043f2d8077ed00bb2d3239da4b96ad4b387.zip llvm-ae7ab043f2d8077ed00bb2d3239da4b96ad4b387.tar.gz llvm-ae7ab043f2d8077ed00bb2d3239da4b96ad4b387.tar.bz2 |
Add __hlt intrinsic for Windows ARM. (#96578)
Add __hlt, which is a MSVC ARM64 intrinsic.
This intrinsic is just the HLT instruction. MSVC's version seems to
return something undefined; in this patch
it will just return zero.
MSVC intrinsics are defined here
https://learn.microsoft.com/en-us/cpp/intrinsics/arm64-intrinsics.
I used unsigned int as the return type, because that is what the MSVC
intrin.h header uses, even though
it conflicts with the documentation.
Diffstat (limited to 'clang/test')
-rw-r--r-- | clang/test/CodeGen/arm64-microsoft-intrinsics.c | 9 | ||||
-rw-r--r-- | clang/test/Sema/builtins-microsoft-arm64.c | 5 |
2 files changed, 14 insertions, 0 deletions
diff --git a/clang/test/CodeGen/arm64-microsoft-intrinsics.c b/clang/test/CodeGen/arm64-microsoft-intrinsics.c index a354ed9..7953618 100644 --- a/clang/test/CodeGen/arm64-microsoft-intrinsics.c +++ b/clang/test/CodeGen/arm64-microsoft-intrinsics.c @@ -127,6 +127,15 @@ void check__break() { // CHECK-MSVC: call void @llvm.aarch64.break(i32 0) // CHECK-LINUX: error: call to undeclared function '__break' +void check__hlt() { + __hlt(0); + __hlt(1, 2, 3, 4, 5); + int x = __hlt(0); +} + +// CHECK-MSVC: call void @llvm.aarch64.hlt(i32 0) +// CHECK-LINUX: error: call to undeclared function '__hlt' + unsigned __int64 check__getReg(void) { unsigned volatile __int64 reg; reg = __getReg(18); diff --git a/clang/test/Sema/builtins-microsoft-arm64.c b/clang/test/Sema/builtins-microsoft-arm64.c index 6d0dc09..322cf75 100644 --- a/clang/test/Sema/builtins-microsoft-arm64.c +++ b/clang/test/Sema/builtins-microsoft-arm64.c @@ -9,6 +9,11 @@ void check__break(int x) { __break(x); // expected-error {{argument to '__break' must be a constant integer}} } +void check__hlt() { + __hlt(-1); // expected-error-re {{argument value {{.*}} is outside the valid range}} + __hlt(65536); // expected-error-re {{argument value {{.*}} is outside the valid range}} +} + void check__getReg(void) { __getReg(-1); // expected-error-re {{argument value {{.*}} is outside the valid range}} __getReg(32); // expected-error-re {{argument value {{.*}} is outside the valid range}} |