summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoseph Huber <huberjn@outlook.com>2024-05-03 14:01:09 -0500
committerGitHub <noreply@github.com>2024-05-03 14:01:09 -0500
commit70b79a9ccd03f93fc4c8464a91b6bef3aab322d3 (patch)
tree100a206eb9ef4379c6c1fcdf5d9d45d8664126d3
parent2f58b9aae2d6f1aeaecd98766ef31cebc0dcbb5b (diff)
[AMDGPU] Allow the `__builtin_flt_rounds` functions on AMDGPU (#90994)
Summary: Previous patches added support for the LLVM rounding intrinsic functions. This patch allows them to me emitted using the clang builtins when targeting AMDGPU.
-rw-r--r--clang/lib/Sema/SemaChecking.cpp16
-rw-r--r--clang/test/CodeGenOpenCL/builtins-amdgcn.cl12
2 files changed, 20 insertions, 8 deletions
diff --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp
index 6d0e93c2b834..3179d542b1f9 100644
--- a/clang/lib/Sema/SemaChecking.cpp
+++ b/clang/lib/Sema/SemaChecking.cpp
@@ -2533,18 +2533,18 @@ Sema::CheckBuiltinFunctionCall(FunctionDecl *FDecl, unsigned BuiltinID,
case Builtin::BI_bittestandset64:
case Builtin::BI_interlockedbittestandreset64:
case Builtin::BI_interlockedbittestandset64:
- if (CheckBuiltinTargetInSupported(*this, BuiltinID, TheCall,
- {llvm::Triple::x86_64, llvm::Triple::arm,
- llvm::Triple::thumb,
- llvm::Triple::aarch64}))
+ if (CheckBuiltinTargetInSupported(
+ *this, BuiltinID, TheCall,
+ {llvm::Triple::x86_64, llvm::Triple::arm, llvm::Triple::thumb,
+ llvm::Triple::aarch64, llvm::Triple::amdgcn}))
return ExprError();
break;
case Builtin::BI__builtin_set_flt_rounds:
- if (CheckBuiltinTargetInSupported(*this, BuiltinID, TheCall,
- {llvm::Triple::x86, llvm::Triple::x86_64,
- llvm::Triple::arm, llvm::Triple::thumb,
- llvm::Triple::aarch64}))
+ if (CheckBuiltinTargetInSupported(
+ *this, BuiltinID, TheCall,
+ {llvm::Triple::x86, llvm::Triple::x86_64, llvm::Triple::arm,
+ llvm::Triple::thumb, llvm::Triple::aarch64, llvm::Triple::amdgcn}))
return ExprError();
break;
diff --git a/clang/test/CodeGenOpenCL/builtins-amdgcn.cl b/clang/test/CodeGenOpenCL/builtins-amdgcn.cl
index bdca97c88786..338d6bc95655 100644
--- a/clang/test/CodeGenOpenCL/builtins-amdgcn.cl
+++ b/clang/test/CodeGenOpenCL/builtins-amdgcn.cl
@@ -839,6 +839,18 @@ unsigned test_wavefrontsize() {
return __builtin_amdgcn_wavefrontsize();
}
+// CHECK-LABEL test_flt_rounds(
+unsigned test_flt_rounds() {
+
+ // CHECK: call i32 @llvm.get.rounding()
+ unsigned mode = __builtin_flt_rounds();
+
+ // CHECK: call void @llvm.set.rounding(i32 %0)
+ __builtin_set_flt_rounds(mode);
+
+ return mode;
+}
+
// CHECK-LABEL test_get_fpenv(
unsigned long test_get_fpenv() {
// CHECK: call i64 @llvm.get.fpenv.i64()