[PATCH] D85874: [PowerPC] Add readflm/setflm intrinsics to Clang

Qiu Chaofan via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 12 22:58:36 PDT 2020


qiucf created this revision.
qiucf added reviewers: jsji, nemanjai, steven.zhang, ZhangKang, PowerPC.
Herald added subscribers: llvm-commits, cfe-commits, shchenz, kbarton.
Herald added projects: clang, LLVM.
qiucf requested review of this revision.
Herald added a subscriber: wuzish.

dbcfbffc <https://reviews.llvm.org/rGdbcfbffc7ae46cc7b84257787681676144a1bd5f> adds `ppc.readflm` and `ppc.setflm` intrinsics to read or write FPSCR register. This patch adds them to Clang.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D85874

Files:
  clang/include/clang/Basic/BuiltinsPPC.def
  clang/test/CodeGen/builtins-ppc.c
  llvm/include/llvm/IR/IntrinsicsPowerPC.td


Index: llvm/include/llvm/IR/IntrinsicsPowerPC.td
===================================================================
--- llvm/include/llvm/IR/IntrinsicsPowerPC.td
+++ llvm/include/llvm/IR/IntrinsicsPowerPC.td
@@ -48,9 +48,11 @@
   def int_ppc_eieio : Intrinsic<[],[],[]>;
 
   // Get content from current FPSCR register
-  def int_ppc_readflm : Intrinsic<[llvm_double_ty], [], [IntrNoMem]>;
+  def int_ppc_readflm : GCCBuiltin<"__builtin_readflm">,
+                        Intrinsic<[llvm_double_ty], [], [IntrNoMem]>;
   // Set FPSCR register, and return previous content
-  def int_ppc_setflm : Intrinsic<[llvm_double_ty], [llvm_double_ty], []>;
+  def int_ppc_setflm : GCCBuiltin<"__builtin_setflm">,
+                       Intrinsic<[llvm_double_ty], [llvm_double_ty], []>;
 
   // Intrinsics for [double]word extended forms of divide instructions
   def int_ppc_divwe : GCCBuiltin<"__builtin_divwe">,
Index: clang/test/CodeGen/builtins-ppc.c
===================================================================
--- clang/test/CodeGen/builtins-ppc.c
+++ clang/test/CodeGen/builtins-ppc.c
@@ -27,3 +27,12 @@
   // CHECK: call double @llvm.ppc.setrnd(i32 %2)
   res = __builtin_setrnd(x);
 }
+
+void test_builtin_ppc_flm() {
+  volatile double res;
+  // CHECK: call double @llvm.ppc.readflm()
+  res = __builtin_readflm();
+
+  // CHECK: call double @llvm.ppc.setflm(double %1)
+  res = __builtin_setflm(res);
+}
Index: clang/include/clang/Basic/BuiltinsPPC.def
===================================================================
--- clang/include/clang/Basic/BuiltinsPPC.def
+++ clang/include/clang/Basic/BuiltinsPPC.def
@@ -549,6 +549,12 @@
 // Set the floating point rounding mode
 BUILTIN(__builtin_setrnd, "di", "")
 
+// Get content from current FPSCR
+BUILTIN(__builtin_readflm, "d", "")
+
+// Set content of FPSCR, and return its content before update
+BUILTIN(__builtin_setflm, "dd", "")
+
 // Cache built-ins
 BUILTIN(__builtin_dcbf, "vvC*", "")
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D85874.285256.patch
Type: text/x-patch
Size: 1962 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200813/4d58921f/attachment.bin>


More information about the llvm-commits mailing list