@@ -211,6 +211,7 @@ enum operand_size {
211211 S8 ,
212212 S16 ,
213213 S32 ,
214+ S64 ,
214215};
215216
216217#if defined(__x86_64__ )
@@ -756,7 +757,7 @@ static inline void emit_alu64(struct jit_state *state, int op, int src, int dst)
756757#endif
757758}
758759
759- #if RV32_HAS (EXT_M )
760+ #if RV32_HAS (EXT_M ) || defined( __aarch64__ )
760761static inline void emit_alu64_imm8 (struct jit_state * state ,
761762 int op ,
762763 int src UNUSED ,
@@ -771,6 +772,9 @@ static inline void emit_alu64_imm8(struct jit_state *state,
771772 if (op == 0xc1 ) {
772773 emit_load_imm (state , R10 , imm );
773774 emit_dataproc_2source (state , true, DP2_LSRV , dst , dst , R10 );
775+ } else if (src == 0 ) {
776+ emit_load_imm (state , R10 , imm );
777+ emit_addsub_register (state , true, AS_ADD , dst , dst , R10 );
774778 }
775779#endif
776780}
@@ -914,6 +918,9 @@ static inline void emit_load(struct jit_state *state,
914918 case S32 :
915919 emit_loadstore_imm (state , LS_LDRW , dst , src , offset );
916920 break ;
921+ case S64 :
922+ emit_loadstore_imm (state , LS_LDRX , dst , src , offset );
923+ break ;
917924 default :
918925 assert (NULL );
919926 __UNREACHABLE ;
@@ -1104,6 +1111,9 @@ static inline void emit_store(struct jit_state *state,
11041111 case S32 :
11051112 emit_loadstore_imm (state , LS_STRW , src , dst , offset );
11061113 break ;
1114+ case S64 :
1115+ emit_loadstore_imm (state , LS_STRX , src , dst , offset );
1116+ break ;
11071117 default :
11081118 assert (NULL );
11091119 __UNREACHABLE ;
@@ -2026,10 +2036,28 @@ void parse_branch_history_table(struct jit_state *state,
20262036 }
20272037}
20282038
2039+ void emit_jit_inc_timer (struct jit_state * state )
2040+ {
2041+ #if defined(__x86_64__ )
2042+ /* Increment rv->timer. *rv pointer is stored in RDI register */
2043+ /* INC RDI, [rv + offsetof(riscv_t, timer)] */
2044+ emit_rex (state , 1 , 0 , 0 , 0 );
2045+ emit1 (state , 0xff );
2046+ emit1 (state , 0x87 );
2047+ emit4 (state , offsetof(riscv_t , timer ));
2048+ #elif defined(__aarch64__ )
2049+ emit_load (state , S64 , parameter_reg [0 ], temp_reg , offsetof(riscv_t , timer ));
2050+ emit_alu64_imm8 (state , 0 , 0 , temp_reg , 1 );
2051+ emit_store (state , S64 , temp_reg , parameter_reg [0 ],
2052+ offsetof(riscv_t , timer ));
2053+ #endif
2054+ }
2055+
20292056#define GEN (inst , code ) \
20302057 static void do_##inst(struct jit_state *state UNUSED, riscv_t *rv UNUSED, \
20312058 rv_insn_t *ir UNUSED) \
20322059 { \
2060+ emit_jit_inc_timer(state); \
20332061 code; \
20342062 }
20352063#include "rv32_jit.c"
0 commit comments