@@ -386,7 +386,9 @@ static inline void emit_jump_target_address(struct jit_state *state,
386386    emit4 (state , 0 );
387387}
388388#elif  defined(__aarch64__ )
389- static  inline  void  emit_load_imm (struct  jit_state  * state , int  dst , int64_t  imm );
389+ static  inline  void  emit_load_imm (struct  jit_state  * state ,
390+                                  int  dst ,
391+                                  uint32_t  imm );
390392
391393static  void  emit_a64 (struct  jit_state  * state , uint32_t  insn )
392394{
@@ -947,10 +949,7 @@ static inline void emit_load_imm(struct jit_state *state, int dst, uint32_t imm)
947949
948950    set_dirty (dst , true);
949951#elif  defined(__aarch64__ )
950-     if  ((int32_t ) imm  ==  imm )
951-         emit_movewide_imm (state , false, dst , imm );
952-     else 
953-         emit_movewide_imm (state , true, dst , imm );
952+     emit_movewide_imm (state , true, dst , imm );
954953#endif 
955954}
956955
@@ -978,24 +977,19 @@ static inline void emit_load_imm_sext(struct jit_state *state,
978977#endif 
979978}
980979
981- /* Store register src to [dst + offset]. 
982-  * 
983-  * If the offset is non-zero, it stores the host register back to the stack 
984-  * which mapped to the vm register file. Otherwise, it is a `write` pseudo 
985-  * instruction that writing the content of `src` into [dst]. 
986-  */ 
987- static  inline  void  emit_store (struct  jit_state  * state ,
988-                               enum  operand_size  size ,
989-                               int  src ,
990-                               int  dst ,
991-                               int32_t  offset )
980+ static  inline  bool  jit_store_x0 (struct  jit_state  * state ,
981+                                 enum  operand_size  size ,
982+                                 int  src ,
983+                                 int  dst ,
984+                                 int32_t  offset )
992985{
993986    for  (int  i  =  0 ; i  <  n_host_regs ; i ++ ) {
994987        if  (register_map [i ].reg_idx  !=  src )
995988            continue ;
996989        if  (register_map [i ].vm_reg_idx  !=  0 )
997990            continue ;
998991
992+ #if  defined(__x86_64__ )
999993        /* if src is x0, write 0x0 into destination */ 
1000994        if  (size  ==  S16 )
1001995            emit1 (state , 0x66 ); /* 16-bit override */ 
@@ -1019,9 +1013,43 @@ static inline void emit_store(struct jit_state *state,
10191013            assert (NULL );
10201014            __UNREACHABLE ;
10211015        }
1016+ #elif  defined(__aarch64__ )
1017+         switch  (size ) {
1018+         case  S8 :
1019+             emit_loadstore_imm (state , LS_STRB , RZ , dst , offset );
1020+             break ;
1021+         case  S16 :
1022+             emit_loadstore_imm (state , LS_STRH , RZ , dst , offset );
1023+             break ;
1024+         case  S32 :
1025+             emit_loadstore_imm (state , LS_STRW , RZ , dst , offset );
1026+             break ;
1027+         default :
1028+             assert (NULL );
1029+             __UNREACHABLE ;
1030+         }
1031+ #endif 
10221032        set_dirty (src , false);
1023-         return ;
1033+         return  true ;
10241034    }
1035+     return  false;
1036+ }
1037+ 
1038+ /* Store register src to [dst + offset]. 
1039+  * 
1040+  * If the offset is non-zero, it stores the host register back to the stack 
1041+  * which mapped to the vm register file. Otherwise, it is a `write` pseudo 
1042+  * instruction that writing the content of `src` into [dst]. 
1043+  */ 
1044+ static  inline  void  emit_store (struct  jit_state  * state ,
1045+                               enum  operand_size  size ,
1046+                               int  src ,
1047+                               int  dst ,
1048+                               int32_t  offset )
1049+ {
1050+     if  (jit_store_x0 (state , size , src , dst , offset ))
1051+         return ;
1052+ 
10251053#if  defined(__x86_64__ )
10261054    if  (size  ==  S16 )
10271055        emit1 (state , 0x66 ); /* 16-bit override */ 
@@ -1041,8 +1069,8 @@ static inline void emit_store(struct jit_state *state,
10411069        emit_loadstore_imm (state , LS_STRW , src , dst , offset );
10421070        break ;
10431071    default :
1072+         assert (NULL );
10441073        __UNREACHABLE ;
1045-         break ;
10461074    }
10471075#endif 
10481076
0 commit comments