@@ -211,6 +211,7 @@ enum operand_size {
211
211
S8 ,
212
212
S16 ,
213
213
S32 ,
214
+ S64 ,
214
215
};
215
216
216
217
#if defined(__x86_64__ )
@@ -756,7 +757,7 @@ static inline void emit_alu64(struct jit_state *state, int op, int src, int dst)
756
757
#endif
757
758
}
758
759
759
- #if RV32_HAS (EXT_M )
760
+ #if RV32_HAS (EXT_M ) || defined( __aarch64__ )
760
761
static inline void emit_alu64_imm8 (struct jit_state * state ,
761
762
int op ,
762
763
int src UNUSED ,
@@ -771,6 +772,9 @@ static inline void emit_alu64_imm8(struct jit_state *state,
771
772
if (op == 0xc1 ) {
772
773
emit_load_imm (state , R10 , imm );
773
774
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 );
774
778
}
775
779
#endif
776
780
}
@@ -914,6 +918,9 @@ static inline void emit_load(struct jit_state *state,
914
918
case S32 :
915
919
emit_loadstore_imm (state , LS_LDRW , dst , src , offset );
916
920
break ;
921
+ case S64 :
922
+ emit_loadstore_imm (state , LS_LDRX , dst , src , offset );
923
+ break ;
917
924
default :
918
925
assert (NULL );
919
926
__UNREACHABLE ;
@@ -1104,6 +1111,9 @@ static inline void emit_store(struct jit_state *state,
1104
1111
case S32 :
1105
1112
emit_loadstore_imm (state , LS_STRW , src , dst , offset );
1106
1113
break ;
1114
+ case S64 :
1115
+ emit_loadstore_imm (state , LS_STRX , src , dst , offset );
1116
+ break ;
1107
1117
default :
1108
1118
assert (NULL );
1109
1119
__UNREACHABLE ;
@@ -2026,10 +2036,28 @@ void parse_branch_history_table(struct jit_state *state,
2026
2036
}
2027
2037
}
2028
2038
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
+
2029
2056
#define GEN (inst , code ) \
2030
2057
static void do_##inst(struct jit_state *state UNUSED, riscv_t *rv UNUSED, \
2031
2058
rv_insn_t *ir UNUSED) \
2032
2059
{ \
2060
+ emit_jit_inc_timer(state); \
2033
2061
code; \
2034
2062
}
2035
2063
#include "rv32_jit.c"
0 commit comments