[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 1/7] target/loongarch: Fix macros SET_FPU_* in cpu.h
From: |
Richard Henderson |
Subject: |
[PULL 1/7] target/loongarch: Fix macros SET_FPU_* in cpu.h |
Date: |
Fri, 5 Aug 2022 12:55:09 -0700 |
From: Qi Hu <huqi@loongson.cn>
The macros SET_FPU_* are used to set corresponding bits of fcsr.
Unfortunately it forgets to set the result and it causes fcsr's
"CAUSE" never being updated. This patch is to fix this bug.
Signed-off-by: Qi Hu <huqi@loongson.cn>
Reviewed-by: Song Gao <gaosong@loongson.cn>
Message-Id: <20220804132450.314329-1-huqi@loongson.cn>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
target/loongarch/cpu.h | 18 +++++++++++++++---
1 file changed, 15 insertions(+), 3 deletions(-)
diff --git a/target/loongarch/cpu.h b/target/loongarch/cpu.h
index a36349df83..dce999aaac 100644
--- a/target/loongarch/cpu.h
+++ b/target/loongarch/cpu.h
@@ -47,11 +47,23 @@ FIELD(FCSR0, FLAGS, 16, 5)
FIELD(FCSR0, CAUSE, 24, 5)
#define GET_FP_CAUSE(REG) FIELD_EX32(REG, FCSR0, CAUSE)
-#define SET_FP_CAUSE(REG, V) FIELD_DP32(REG, FCSR0, CAUSE, V)
+#define SET_FP_CAUSE(REG, V) \
+ do { \
+ (REG) = FIELD_DP32(REG, FCSR0, CAUSE, V); \
+ } while (0)
+
#define GET_FP_ENABLES(REG) FIELD_EX32(REG, FCSR0, ENABLES)
-#define SET_FP_ENABLES(REG, V) FIELD_DP32(REG, FCSR0, ENABLES, V)
+#define SET_FP_ENABLES(REG, V) \
+ do { \
+ (REG) = FIELD_DP32(REG, FCSR0, ENABLES, V); \
+ } while (0)
+
#define GET_FP_FLAGS(REG) FIELD_EX32(REG, FCSR0, FLAGS)
-#define SET_FP_FLAGS(REG, V) FIELD_DP32(REG, FCSR0, FLAGS, V)
+#define SET_FP_FLAGS(REG, V) \
+ do { \
+ (REG) = FIELD_DP32(REG, FCSR0, FLAGS, V); \
+ } while (0)
+
#define UPDATE_FP_FLAGS(REG, V) \
do { \
(REG) |= FIELD_DP32(0, FCSR0, FLAGS, V); \
--
2.34.1
- [PULL 0/7] loongarch patch queue, Richard Henderson, 2022/08/05
- [PULL 1/7] target/loongarch: Fix macros SET_FPU_* in cpu.h,
Richard Henderson <=
- [PULL 2/7] hw/loongarch: remove acpi-build.c unused variable 'aml_len', Richard Henderson, 2022/08/05
- [PULL 3/7] target/loongarch: Fix GDB get the wrong pc, Richard Henderson, 2022/08/05
- [PULL 5/7] target/loongarch: update loongarch-base64.xml, Richard Henderson, 2022/08/05
- [PULL 4/7] target/loongarch: add gdb_arch_name(), Richard Henderson, 2022/08/05
- [PULL 6/7] target/loongarch: Update loongarch-fpu.xml, Richard Henderson, 2022/08/05
- [PULL 7/7] target/loongarch: Update gdb_set_fpu() and gdb_get_fpu(), Richard Henderson, 2022/08/05
- Re: [PULL 0/7] loongarch patch queue, Richard Henderson, 2022/08/05