[PATCH] D145765: Add __builtin_set_flt_rounds

Aaron Ballman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Mar 10 06:01:15 PST 2023


aaron.ballman added a comment.

Thank you for this! You should also add a release note and some documentation for the new builtin.



================
Comment at: clang/test/CodeGen/builtin_set_flt_rounds.c:1-4
+// RUN: %clang_cc1  -triple x86_64-gnu-linux %s -emit-llvm -o - | FileCheck %s
+// 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
----------------
Minor cleanup.


================
Comment at: clang/test/CodeGen/builtin_set_flt_rounds.c:5-7
+void test_builtin_set_flt_rounds() {
+  __builtin_set_flt_rounds(1);
+  // CHECK: call void @llvm.set.rounding(i32 1)
----------------
I think you should also add some Sema tests for correct and misuse of the builtin:
```
__builtin_set_flt_rounds(1); // OK

struct S { int a; } s;
__builtin_set_flt_rounds(s); // This should diagnose, right?

__builtin_set_flt_rounds(1.0f); // Should this implicitly convert or is this an error?
```
and that sema test can additionally test what happens when you call the builtin on an unsupported architecture.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D145765/new/

https://reviews.llvm.org/D145765



More information about the cfe-commits mailing list