[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 2/3] target/arm: Introduce store_cpu_field_constant() helper
From: |
Philippe Mathieu-Daudé |
Subject: |
[PATCH 2/3] target/arm: Introduce store_cpu_field_constant() helper |
Date: |
Sun, 3 Oct 2021 16:39:00 +0200 |
Similarly to the store_cpu_field() helper which takes a TCG
temporary, store its value to the CPUState, introduce the
store_cpu_field_constant() helper which store a constant to
CPUState (without using any TCG temporary).
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
target/arm/translate-a32.h | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/target/arm/translate-a32.h b/target/arm/translate-a32.h
index 88f15df60e8..b0abaac6f99 100644
--- a/target/arm/translate-a32.h
+++ b/target/arm/translate-a32.h
@@ -61,14 +61,19 @@ static inline TCGv_i32 load_cpu_offset(int offset)
#define load_cpu_field(name) load_cpu_offset(offsetof(CPUARMState, name))
-static inline void store_cpu_offset(TCGv_i32 var, int offset)
+static inline void store_cpu_offset(TCGv_i32 var, int offset, bool is_temp)
{
tcg_gen_st_i32(var, cpu_env, offset);
- tcg_temp_free_i32(var);
+ if (is_temp) {
+ tcg_temp_free_i32(var);
+ }
}
#define store_cpu_field(var, name) \
- store_cpu_offset(var, offsetof(CPUARMState, name))
+ store_cpu_offset(var, offsetof(CPUARMState, name), true)
+
+#define store_cpu_field_constant(val, name) \
+ store_cpu_offset(tcg_const_i32(val), offsetof(CPUARMState, name), false)
/* Create a new temporary and set it to the value of a CPU register. */
static inline TCGv_i32 load_reg(DisasContext *s, int reg)
--
2.31.1