qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Cédric Le Goater" <clg@kaod.org>
To: qemu-ppc@nongnu.org, qemu-devel@nongnu.org
Cc: "Alex Bennée" <alex.bennee@linaro.org>,
	"Peter Maydell" <peter.maydell@linaro.org>,
	"Richard Henderson" <richard.henderson@linaro.org>,
	"Matheus Ferst" <matheus.ferst@eldorado.org.br>,
	"Cédric Le Goater" <clg@kaod.org>
Subject: [PULL 02/13] tests/tcg/ppc64le: use inline asm instead of __builtin_mtfsf
Date: Sat,  5 Mar 2022 11:59:59 +0100	[thread overview]
Message-ID: <20220305110010.1283654-3-clg@kaod.org> (raw)
In-Reply-To: <20220305110010.1283654-1-clg@kaod.org>

From: Matheus Ferst <matheus.ferst@eldorado.org.br>

LLVM/Clang does not support __builtin_mtfsf.

Acked-by: Alex Bennée <alex.bennee@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Matheus Ferst <matheus.ferst@eldorado.org.br>
Message-Id: <20220304165417.1981159-2-matheus.ferst@eldorado.org.br>
Signed-off-by: Cédric Le Goater <clg@kaod.org>
---
 tests/tcg/ppc64le/mtfsf.c | 19 +++++++++----------
 1 file changed, 9 insertions(+), 10 deletions(-)

diff --git a/tests/tcg/ppc64le/mtfsf.c b/tests/tcg/ppc64le/mtfsf.c
index b3d31f3637d9..bed5b1afa40e 100644
--- a/tests/tcg/ppc64le/mtfsf.c
+++ b/tests/tcg/ppc64le/mtfsf.c
@@ -1,8 +1,12 @@
 #include <stdlib.h>
+#include <stdint.h>
 #include <assert.h>
 #include <signal.h>
 #include <sys/prctl.h>
 
+#define MTFSF(FLM, FRB) asm volatile ("mtfsf %0, %1" :: "i" (FLM), "f" (FRB))
+#define MFFS(FRT) asm("mffs %0" : "=f" (FRT))
+
 #define FPSCR_VE     7  /* Floating-point invalid operation exception enable */
 #define FPSCR_VXSOFT 10 /* Floating-point invalid operation exception (soft) */
 #define FPSCR_FI     17 /* Floating-point fraction inexact                   */
@@ -21,10 +25,7 @@ void sigfpe_handler(int sig, siginfo_t *si, void *ucontext)
 
 int main(void)
 {
-    union {
-        double d;
-        long long ll;
-    } fpscr;
+    uint64_t fpscr;
 
     struct sigaction sa = {
         .sa_sigaction = sigfpe_handler,
@@ -40,10 +41,9 @@ int main(void)
     prctl(PR_SET_FPEXC, PR_FP_EXC_PRECISE);
 
     /* First test if the FI bit is being set correctly */
-    fpscr.ll = FP_FI;
-    __builtin_mtfsf(0b11111111, fpscr.d);
-    fpscr.d = __builtin_mffs();
-    assert((fpscr.ll & FP_FI) != 0);
+    MTFSF(0b11111111, FP_FI);
+    MFFS(fpscr);
+    assert((fpscr & FP_FI) != 0);
 
     /* Then test if the deferred exception is being called correctly */
     sigaction(SIGFPE, &sa, NULL);
@@ -54,8 +54,7 @@ int main(void)
      * But if a different exception is chosen si_code check should
      * change accordingly.
      */
-    fpscr.ll = FP_VE | FP_VXSOFT;
-    __builtin_mtfsf(0b11111111, fpscr.d);
+    MTFSF(0b11111111, FP_VE | FP_VXSOFT);
 
     return 1;
 }
-- 
2.34.1



  parent reply	other threads:[~2022-03-05 11:08 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-05 10:59 [PULL 00/13] ppc queue Cédric Le Goater
2022-03-05 10:59 ` [PULL 01/13] Use long endian options for ppc64 Cédric Le Goater
2022-03-05 10:59 ` Cédric Le Goater [this message]
2022-03-05 11:00 ` [PULL 03/13] target/ppc: change xs[n]madd[am]sp to use float64r32_muladd Cédric Le Goater
2022-03-05 11:00 ` [PULL 04/13] tests/tcg/ppc64le: drop __int128 usage in bcdsub Cédric Le Goater
2022-03-05 11:00 ` [PULL 05/13] tests/tcg/ppc64le: emit bcdsub with .long when needed Cédric Le Goater
2022-03-05 11:00 ` [PULL 06/13] tests/tcg/ppc64le: Use Altivec register names in clobber list Cédric Le Goater
2022-03-05 11:00 ` [PULL 07/13] target/ppc: Fix vmul[eo]* instructions marked 2.07 Cédric Le Goater
2022-03-05 11:00 ` [PULL 08/13] target/ppc: use ext32u and deposit in do_vx_vmulhw_i64 Cédric Le Goater
2022-03-05 11:00 ` [PULL 09/13] target/ppc: use extract/extract2 to create vrlqnm mask Cédric Le Goater
2022-03-05 11:00 ` [PULL 10/13] target/ppc: use andc in vrlqmi Cédric Le Goater
2022-03-05 11:00 ` [PULL 11/13] target/ppc: split XXGENPCV macros for readability Cédric Le Goater
2022-03-05 11:00 ` [PULL 12/13] target/ppc: Add missing helper_reset_fpstatus to VSX_MAX_MINC Cédric Le Goater
2022-03-05 11:00 ` [PULL 13/13] target/ppc: Add missing helper_reset_fpstatus to helper_XVCVSPBF16 Cédric Le Goater
2022-03-06 11:57 ` [PULL 00/13] ppc queue Peter Maydell

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220305110010.1283654-3-clg@kaod.org \
    --to=clg@kaod.org \
    --cc=alex.bennee@linaro.org \
    --cc=matheus.ferst@eldorado.org.br \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-ppc@nongnu.org \
    --cc=richard.henderson@linaro.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).