@@ -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,6 @@ 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 )
760760static  inline  void  emit_alu64_imm8 (struct  jit_state  * state ,
761761                                   int  op ,
762762                                   int  src  UNUSED ,
@@ -771,10 +771,12 @@ static inline void emit_alu64_imm8(struct jit_state *state,
771771    if  (op  ==  0xc1 ) {
772772        emit_load_imm (state , R10 , imm );
773773        emit_dataproc_2source (state , true, DP2_LSRV , dst , dst , R10 );
774+     } else  if  (src  ==  0 ) {
775+         emit_load_imm (state , temp_reg , 0x1 );
776+         emit_addsub_register (state , true, AS_ADD , dst , dst , temp_reg );
774777    }
775778#endif 
776779}
777- #endif 
778780
779781/* Register to register mov */ 
780782static  inline  void  emit_mov (struct  jit_state  * state , int  src , int  dst )
@@ -914,6 +916,9 @@ static inline void emit_load(struct jit_state *state,
914916    case  S32 :
915917        emit_loadstore_imm (state , LS_LDRW , dst , src , offset );
916918        break ;
919+     case  S64 :
920+         emit_loadstore_imm (state , LS_LDRX , dst , src , offset );
921+         break ;
917922    default :
918923        assert (NULL );
919924        __UNREACHABLE ;
@@ -1104,6 +1109,9 @@ static inline void emit_store(struct jit_state *state,
11041109    case  S32 :
11051110        emit_loadstore_imm (state , LS_STRW , src , dst , offset );
11061111        break ;
1112+     case  S64 :
1113+         emit_loadstore_imm (state , LS_STRX , src , dst , offset );
1114+         break ;
11071115    default :
11081116        assert (NULL );
11091117        __UNREACHABLE ;
@@ -2026,10 +2034,28 @@ void parse_branch_history_table(struct jit_state *state,
20262034    }
20272035}
20282036
2037+ void  emit_jit_update_timer (struct  jit_state  * state )
2038+ {
2039+ #if  defined(__x86_64__ )
2040+     /* Increment rv->timer. *rv pointer is stored in RDI register */ 
2041+     /* INC RDI, [rv + offsetof(riscv_t, timer)] */ 
2042+     emit_rex (state , 1 , 0 , 0 , 0 );
2043+     emit1 (state , 0xff );
2044+     emit1 (state , 0x87 );
2045+     emit4 (state , offsetof(riscv_t , timer ));
2046+ #elif  defined(__aarch64__ )
2047+     emit_load (state , S64 , parameter_reg [0 ], temp_reg , offsetof(riscv_t , timer ));
2048+     emit_alu64_imm8 (state , 0 , 0 , temp_reg , 1 );
2049+     emit_store (state , S64 , temp_reg , parameter_reg [0 ],
2050+                offsetof(riscv_t , timer ));
2051+ #endif 
2052+ }
2053+ 
20292054#define  GEN (inst , code )                                                       \
20302055    static void do_##inst(struct jit_state *state UNUSED, riscv_t *rv UNUSED, \
20312056                          rv_insn_t *ir UNUSED)                               \
20322057    {                                                                         \
2058+         emit_jit_update_timer(state);                                         \
20332059        code;                                                                 \
20342060    }
20352061#include  "rv32_jit.c" 
0 commit comments