[clang] 7ceb19e - [PowerPC] Support set_flt_rounds builtin (#73750)

via cfe-commits cfe-commits at lists.llvm.org
Mon Nov 4 00:45:09 PST 2024


Author: Qiu Chaofan
Date: 2024-11-04T16:45:05+08:00
New Revision: 7ceb19e599fb42aeb103261425077dd10acbeae4

URL: https://github.com/llvm/llvm-project/commit/7ceb19e599fb42aeb103261425077dd10acbeae4
DIFF: https://github.com/llvm/llvm-project/commit/7ceb19e599fb42aeb103261425077dd10acbeae4.diff

LOG: [PowerPC] Support set_flt_rounds builtin (#73750)

Added: 
    

Modified: 
    clang/docs/LanguageExtensions.rst
    clang/lib/Sema/SemaChecking.cpp
    clang/test/CodeGen/builtin_set_flt_rounds.c

Removed: 
    


################################################################################
diff  --git a/clang/docs/LanguageExtensions.rst b/clang/docs/LanguageExtensions.rst
index 10232ff41da15a..f00422cd8b8045 100644
--- a/clang/docs/LanguageExtensions.rst
+++ b/clang/docs/LanguageExtensions.rst
@@ -3979,9 +3979,9 @@ standard:
 - ``4``  - to nearest, ties away from zero
 The effect of passing some other value to ``__builtin_flt_rounds`` is
 implementation-defined. ``__builtin_set_flt_rounds`` is currently only supported
-to work on x86, x86_64, Arm and AArch64 targets. These builtins read and modify
-the floating-point environment, which is not always allowed and may have unexpected
-behavior. Please see the section on `Accessing the floating point environment <https://clang.llvm.org/docs/UsersManual.html#accessing-the-floating-point-environment>`_ for more information.
+to work on x86, x86_64, powerpc, powerpc64, Arm and AArch64 targets. These builtins
+read and modify the floating-point environment, which is not always allowed and may
+have unexpected behavior. Please see the section on `Accessing the floating point environment <https://clang.llvm.org/docs/UsersManual.html#accessing-the-floating-point-environment>`_ for more information.
 
 String builtins
 ---------------

diff  --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp
index dae271c1ff5001..d78968179b1fdc 100644
--- a/clang/lib/Sema/SemaChecking.cpp
+++ b/clang/lib/Sema/SemaChecking.cpp
@@ -2212,7 +2212,9 @@ Sema::CheckBuiltinFunctionCall(FunctionDecl *FDecl, unsigned BuiltinID,
     if (CheckBuiltinTargetInSupported(
             *this, TheCall,
             {llvm::Triple::x86, llvm::Triple::x86_64, llvm::Triple::arm,
-             llvm::Triple::thumb, llvm::Triple::aarch64, llvm::Triple::amdgcn}))
+             llvm::Triple::thumb, llvm::Triple::aarch64, llvm::Triple::amdgcn,
+             llvm::Triple::ppc, llvm::Triple::ppc64, llvm::Triple::ppcle,
+             llvm::Triple::ppc64le}))
       return ExprError();
     break;
 

diff  --git a/clang/test/CodeGen/builtin_set_flt_rounds.c b/clang/test/CodeGen/builtin_set_flt_rounds.c
index fc483fcc232aa4..c5c8e905dbd4f8 100644
--- a/clang/test/CodeGen/builtin_set_flt_rounds.c
+++ b/clang/test/CodeGen/builtin_set_flt_rounds.c
@@ -2,6 +2,9 @@
 // RUN: %clang_cc1 -triple x86_64-windows-msvc %s -emit-llvm -o - | FileCheck %s
 // RUN: %clang_cc1 -triple aarch64-gnu-linux %s -emit-llvm -o - | FileCheck %s
 // RUN: %clang_cc1 -triple aarch64-windows-msvc %s -emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 -triple powerpc64le-unknown-linux-gnu %s -emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 -triple powerpc64-ibm-aix %s -emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 -triple powerpc-ibm-aix %s -emit-llvm -o - | FileCheck %s
 void test_builtin_set_flt_rounds() {
   __builtin_set_flt_rounds(1);
   // CHECK: call void @llvm.set.rounding(i32 1)


        


More information about the cfe-commits mailing list