@@ -597,6 +597,16 @@ static inline void tcg_out_smull32(TCGContext *s,
597
597
}
598
598
}
599
599
600
+ static inline void tcg_out_sdiv (TCGContext * s , int cond , int rd , int rn , int rm )
601
+ {
602
+ tcg_out32 (s , 0x0710f010 | (cond << 28 ) | (rd << 16 ) | rn | (rm << 8 ));
603
+ }
604
+
605
+ static inline void tcg_out_udiv (TCGContext * s , int cond , int rd , int rn , int rm )
606
+ {
607
+ tcg_out32 (s , 0x0730f010 | (cond << 28 ) | (rd << 16 ) | rn | (rm << 8 ));
608
+ }
609
+
600
610
static inline void tcg_out_ext8s (TCGContext * s , int cond ,
601
611
int rd , int rn )
602
612
{
@@ -1868,6 +1878,25 @@ static inline void tcg_out_op(TCGContext *s, TCGOpcode opc,
1868
1878
args [3 ], args [4 ], const_args [2 ]);
1869
1879
break ;
1870
1880
1881
+ case INDEX_op_div_i32 :
1882
+ tcg_out_sdiv (s , COND_AL , args [0 ], args [1 ], args [2 ]);
1883
+ break ;
1884
+ case INDEX_op_divu_i32 :
1885
+ tcg_out_udiv (s , COND_AL , args [0 ], args [1 ], args [2 ]);
1886
+ break ;
1887
+ case INDEX_op_rem_i32 :
1888
+ tcg_out_sdiv (s , COND_AL , TCG_REG_R8 , args [1 ], args [2 ]);
1889
+ tcg_out_mul32 (s , COND_AL , TCG_REG_R8 , TCG_REG_R8 , args [2 ]);
1890
+ tcg_out_dat_reg (s , COND_AL , ARITH_SUB , args [0 ], args [1 ], TCG_REG_R8 ,
1891
+ SHIFT_IMM_LSL (0 ));
1892
+ break ;
1893
+ case INDEX_op_remu_i32 :
1894
+ tcg_out_udiv (s , COND_AL , TCG_REG_R8 , args [1 ], args [2 ]);
1895
+ tcg_out_mul32 (s , COND_AL , TCG_REG_R8 , TCG_REG_R8 , args [2 ]);
1896
+ tcg_out_dat_reg (s , COND_AL , ARITH_SUB , args [0 ], args [1 ], TCG_REG_R8 ,
1897
+ SHIFT_IMM_LSL (0 ));
1898
+ break ;
1899
+
1871
1900
default :
1872
1901
tcg_abort ();
1873
1902
}
@@ -1954,6 +1983,13 @@ static const TCGTargetOpDef arm_op_defs[] = {
1954
1983
1955
1984
{ INDEX_op_deposit_i32 , { "r" , "0" , "rZ" } },
1956
1985
1986
+ #if TCG_TARGET_HAS_div_i32
1987
+ { INDEX_op_div_i32 , { "r" , "r" , "r" } },
1988
+ { INDEX_op_rem_i32 , { "r" , "r" , "r" } },
1989
+ { INDEX_op_divu_i32 , { "r" , "r" , "r" } },
1990
+ { INDEX_op_remu_i32 , { "r" , "r" , "r" } },
1991
+ #endif
1992
+
1957
1993
{ -1 },
1958
1994
};
1959
1995
0 commit comments