Author: Qiu Chaofan Date: 2020-08-21T15:12:19+08:00 New Revision: 91039784b3c9757c35e348d4e0700c90adb1a7e7
URL: https://github.com/llvm/llvm-project/commit/91039784b3c9757c35e348d4e0700c90adb1a7e7 DIFF: https://github.com/llvm/llvm-project/commit/91039784b3c9757c35e348d4e0700c90adb1a7e7.diff LOG: [PowerPC] Add readflm/setflm intrinsics to Clang Commit dbcfbffc adds ppc.readflm and ppc.setflm intrinsics to read or write FPSCR register. This patch adds them to Clang. Reviewed By: steven.zhang Differential Revision: https://reviews.llvm.org/D85874 Added: Modified: clang/include/clang/Basic/BuiltinsPPC.def clang/test/CodeGen/builtins-ppc.c llvm/include/llvm/IR/IntrinsicsPowerPC.td Removed: ################################################################################ diff --git a/clang/include/clang/Basic/BuiltinsPPC.def b/clang/include/clang/Basic/BuiltinsPPC.def index 73c607800415..566420d5dce9 100644 --- a/clang/include/clang/Basic/BuiltinsPPC.def +++ b/clang/include/clang/Basic/BuiltinsPPC.def @@ -556,6 +556,12 @@ BUILTIN(__builtin_pack_vector_int128, "V1LLLiULLiULLi", "") // 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*", "") diff --git a/clang/test/CodeGen/builtins-ppc.c b/clang/test/CodeGen/builtins-ppc.c index 1ff1b811c1a0..e30cdff3c8ce 100644 --- a/clang/test/CodeGen/builtins-ppc.c +++ b/clang/test/CodeGen/builtins-ppc.c @@ -27,3 +27,12 @@ void test_builtin_ppc_setrnd() { // 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); +} diff --git a/llvm/include/llvm/IR/IntrinsicsPowerPC.td b/llvm/include/llvm/IR/IntrinsicsPowerPC.td index ce4c98968a7b..b2e542994de9 100644 --- a/llvm/include/llvm/IR/IntrinsicsPowerPC.td +++ b/llvm/include/llvm/IR/IntrinsicsPowerPC.td @@ -48,9 +48,11 @@ let TargetPrefix = "ppc" in { // All intrinsics start with "llvm.ppc.". 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">, _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits