tests/tcg/ppc64le: use inline asm instead of __builtin_mtfsf
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>
This commit is contained in:
parent
ced5cfffee
commit
d21939ca8b
@ -1,8 +1,12 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include <stdint.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
#include <sys/prctl.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_VE 7 /* Floating-point invalid operation exception enable */
|
||||||
#define FPSCR_VXSOFT 10 /* Floating-point invalid operation exception (soft) */
|
#define FPSCR_VXSOFT 10 /* Floating-point invalid operation exception (soft) */
|
||||||
#define FPSCR_FI 17 /* Floating-point fraction inexact */
|
#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)
|
int main(void)
|
||||||
{
|
{
|
||||||
union {
|
uint64_t fpscr;
|
||||||
double d;
|
|
||||||
long long ll;
|
|
||||||
} fpscr;
|
|
||||||
|
|
||||||
struct sigaction sa = {
|
struct sigaction sa = {
|
||||||
.sa_sigaction = sigfpe_handler,
|
.sa_sigaction = sigfpe_handler,
|
||||||
@ -40,10 +41,9 @@ int main(void)
|
|||||||
prctl(PR_SET_FPEXC, PR_FP_EXC_PRECISE);
|
prctl(PR_SET_FPEXC, PR_FP_EXC_PRECISE);
|
||||||
|
|
||||||
/* First test if the FI bit is being set correctly */
|
/* First test if the FI bit is being set correctly */
|
||||||
fpscr.ll = FP_FI;
|
MTFSF(0b11111111, FP_FI);
|
||||||
__builtin_mtfsf(0b11111111, fpscr.d);
|
MFFS(fpscr);
|
||||||
fpscr.d = __builtin_mffs();
|
assert((fpscr & FP_FI) != 0);
|
||||||
assert((fpscr.ll & FP_FI) != 0);
|
|
||||||
|
|
||||||
/* Then test if the deferred exception is being called correctly */
|
/* Then test if the deferred exception is being called correctly */
|
||||||
sigaction(SIGFPE, &sa, NULL);
|
sigaction(SIGFPE, &sa, NULL);
|
||||||
@ -54,8 +54,7 @@ int main(void)
|
|||||||
* But if a different exception is chosen si_code check should
|
* But if a different exception is chosen si_code check should
|
||||||
* change accordingly.
|
* change accordingly.
|
||||||
*/
|
*/
|
||||||
fpscr.ll = FP_VE | FP_VXSOFT;
|
MTFSF(0b11111111, FP_VE | FP_VXSOFT);
|
||||||
__builtin_mtfsf(0b11111111, fpscr.d);
|
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user