From 1342c687f2b0429b3b185c9f11080300ca14529e Mon Sep 17 00:00:00 2001 From: YenHaoChen Date: Tue, 23 Jul 2024 08:42:05 +0800 Subject: refactor: set_fp_exceptions: Use a new macro raise_fp_exceptions(flags) and refine coding style for clearity --- riscv/decode_macros.h | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/riscv/decode_macros.h b/riscv/decode_macros.h index 675634a..8574f0d 100644 --- a/riscv/decode_macros.h +++ b/riscv/decode_macros.h @@ -211,10 +211,12 @@ static inline bool is_aligned(const unsigned val, const unsigned pos) } \ } while (0); -#define set_fp_exceptions ({ if (softfloat_exceptionFlags) { \ - STATE.fflags->write(STATE.fflags->read() | softfloat_exceptionFlags); \ - } \ - softfloat_exceptionFlags = 0; }) +#define raise_fp_exceptions(flags) do { if (flags) STATE.fflags->write(STATE.fflags->read() | (flags)); } while (0); +#define set_fp_exceptions \ + do { \ + raise_fp_exceptions(softfloat_exceptionFlags); \ + softfloat_exceptionFlags = 0; \ + } while (0); #define sext32(x) ((sreg_t)(int32_t)(x)) #define zext32(x) ((reg_t)(uint32_t)(x)) -- cgit v1.1 From e86e653ef35fcd6de8bb2ebe701dccdb9f30a6c7 Mon Sep 17 00:00:00 2001 From: YenHaoChen Date: Mon, 22 Jul 2024 17:50:54 +0800 Subject: fcvtmod.w.h: Not update fflags if no exception flag, e.g., exp == frac == 0 --- riscv/insns/fcvtmod_w_d.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/riscv/insns/fcvtmod_w_d.h b/riscv/insns/fcvtmod_w_d.h index e39400d..231f605 100644 --- a/riscv/insns/fcvtmod_w_d.h +++ b/riscv/insns/fcvtmod_w_d.h @@ -55,6 +55,5 @@ if (exp == 0) { } WRITE_RD(sext32(frac)); -STATE.fflags->write(STATE.fflags->read() | - (inexact ? softfloat_flag_inexact : 0) | +raise_fp_exceptions((inexact ? softfloat_flag_inexact : 0) | (invalid ? softfloat_flag_invalid : 0)); -- cgit v1.1