Revision 2bece2c8 tcg/tcg-op.h

b/tcg/tcg-op.h
353 353
    tcg_gen_op2i_i32(INDEX_op_movi_i32, ret, arg);
354 354
}
355 355

  
356
/* A version of dh_sizemask from def-helper.h that doesn't rely on
357
   preprocessor magic.  */
358
static inline int tcg_gen_sizemask(int n, int is_64bit, int is_signed)
359
{
360
    return (is_64bit << n*2) | (is_signed << (n*2 + 1));
361
}
362

  
356 363
/* helper calls */
357 364
static inline void tcg_gen_helperN(void *func, int flags, int sizemask,
358 365
                                   TCGArg ret, int nargs, TCGArg *args)
......
369 376
   and pure, hence the call to tcg_gen_callN() with TCG_CALL_CONST |
370 377
   TCG_CALL_PURE. This may need to be adjusted if these functions
371 378
   start to be used with other helpers. */
372
static inline void tcg_gen_helper32(void *func, TCGv_i32 ret,
379
static inline void tcg_gen_helper32(void *func, int sizemask, TCGv_i32 ret,
373 380
                                    TCGv_i32 a, TCGv_i32 b)
374 381
{
375 382
    TCGv_ptr fn;
......
377 384
    fn = tcg_const_ptr((tcg_target_long)func);
378 385
    args[0] = GET_TCGV_I32(a);
379 386
    args[1] = GET_TCGV_I32(b);
380
    tcg_gen_callN(&tcg_ctx, fn, TCG_CALL_CONST | TCG_CALL_PURE,
381
                  0, GET_TCGV_I32(ret), 2, args);
387
    tcg_gen_callN(&tcg_ctx, fn, TCG_CALL_CONST | TCG_CALL_PURE, sizemask,
388
                  GET_TCGV_I32(ret), 2, args);
382 389
    tcg_temp_free_ptr(fn);
383 390
}
384 391

  
385
static inline void tcg_gen_helper64(void *func, TCGv_i64 ret,
392
static inline void tcg_gen_helper64(void *func, int sizemask, TCGv_i64 ret,
386 393
                                    TCGv_i64 a, TCGv_i64 b)
387 394
{
388 395
    TCGv_ptr fn;
......
390 397
    fn = tcg_const_ptr((tcg_target_long)func);
391 398
    args[0] = GET_TCGV_I64(a);
392 399
    args[1] = GET_TCGV_I64(b);
393
    tcg_gen_callN(&tcg_ctx, fn, TCG_CALL_CONST | TCG_CALL_PURE,
394
                  7, GET_TCGV_I64(ret), 2, args);
400
    tcg_gen_callN(&tcg_ctx, fn, TCG_CALL_CONST | TCG_CALL_PURE, sizemask,
401
                  GET_TCGV_I64(ret), 2, args);
395 402
    tcg_temp_free_ptr(fn);
396 403
}
397 404

  
......
692 699
#else
693 700
static inline void tcg_gen_div_i32(TCGv_i32 ret, TCGv_i32 arg1, TCGv_i32 arg2)
694 701
{
695
    tcg_gen_helper32(tcg_helper_div_i32, ret, arg1, arg2);
702
    int sizemask = 0;
703
    /* Return value and both arguments are 32-bit and signed.  */
704
    sizemask |= tcg_gen_sizemask(0, 0, 1);
705
    sizemask |= tcg_gen_sizemask(1, 0, 1);
706
    sizemask |= tcg_gen_sizemask(2, 0, 1);
707

  
708
    tcg_gen_helper32(tcg_helper_div_i32, sizemask, ret, arg1, arg2);
696 709
}
697 710

  
698 711
static inline void tcg_gen_rem_i32(TCGv_i32 ret, TCGv_i32 arg1, TCGv_i32 arg2)
699 712
{
700
    tcg_gen_helper32(tcg_helper_rem_i32, ret, arg1, arg2);
713
    int sizemask = 0;
714
    /* Return value and both arguments are 32-bit and signed.  */
715
    sizemask |= tcg_gen_sizemask(0, 0, 1);
716
    sizemask |= tcg_gen_sizemask(1, 0, 1);
717
    sizemask |= tcg_gen_sizemask(2, 0, 1);
718

  
719
    tcg_gen_helper32(tcg_helper_rem_i32, sizemask, ret, arg1, arg2);
701 720
}
702 721

  
703 722
static inline void tcg_gen_divu_i32(TCGv_i32 ret, TCGv_i32 arg1, TCGv_i32 arg2)
704 723
{
705
    tcg_gen_helper32(tcg_helper_divu_i32, ret, arg1, arg2);
724
    int sizemask = 0;
725
    /* Return value and both arguments are 32-bit and unsigned.  */
726
    sizemask |= tcg_gen_sizemask(0, 0, 0);
727
    sizemask |= tcg_gen_sizemask(1, 0, 0);
728
    sizemask |= tcg_gen_sizemask(2, 0, 0);
729

  
730
    tcg_gen_helper32(tcg_helper_divu_i32, ret, arg1, arg2, 0);
706 731
}
707 732

  
708 733
static inline void tcg_gen_remu_i32(TCGv_i32 ret, TCGv_i32 arg1, TCGv_i32 arg2)
709 734
{
710
    tcg_gen_helper32(tcg_helper_remu_i32, ret, arg1, arg2);
735
    int sizemask = 0;
736
    /* Return value and both arguments are 32-bit and unsigned.  */
737
    sizemask |= tcg_gen_sizemask(0, 0, 0);
738
    sizemask |= tcg_gen_sizemask(1, 0, 0);
739
    sizemask |= tcg_gen_sizemask(2, 0, 0);
740

  
741
    tcg_gen_helper32(tcg_helper_remu_i32, ret, arg1, arg2, 0);
711 742
}
712 743
#endif
713 744

  
......
867 898
   specific code (x86) */
868 899
static inline void tcg_gen_shl_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2)
869 900
{
870
    tcg_gen_helper64(tcg_helper_shl_i64, ret, arg1, arg2);
901
    int sizemask = 0;
902
    /* Return value and both arguments are 64-bit and signed.  */
903
    sizemask |= tcg_gen_sizemask(0, 1, 1);
904
    sizemask |= tcg_gen_sizemask(1, 1, 1);
905
    sizemask |= tcg_gen_sizemask(2, 1, 1);
906

  
907
    tcg_gen_helper64(tcg_helper_shl_i64, sizemask, ret, arg1, arg2);
871 908
}
872 909

  
873 910
static inline void tcg_gen_shli_i64(TCGv_i64 ret, TCGv_i64 arg1, int64_t arg2)
......
877 914

  
878 915
static inline void tcg_gen_shr_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2)
879 916
{
880
    tcg_gen_helper64(tcg_helper_shr_i64, ret, arg1, arg2);
917
    int sizemask = 0;
918
    /* Return value and both arguments are 64-bit and signed.  */
919
    sizemask |= tcg_gen_sizemask(0, 1, 1);
920
    sizemask |= tcg_gen_sizemask(1, 1, 1);
921
    sizemask |= tcg_gen_sizemask(2, 1, 1);
922

  
923
    tcg_gen_helper64(tcg_helper_shr_i64, sizemask, ret, arg1, arg2);
881 924
}
882 925

  
883 926
static inline void tcg_gen_shri_i64(TCGv_i64 ret, TCGv_i64 arg1, int64_t arg2)
......
887 930

  
888 931
static inline void tcg_gen_sar_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2)
889 932
{
890
    tcg_gen_helper64(tcg_helper_sar_i64, ret, arg1, arg2);
933
    int sizemask = 0;
934
    /* Return value and both arguments are 64-bit and signed.  */
935
    sizemask |= tcg_gen_sizemask(0, 1, 1);
936
    sizemask |= tcg_gen_sizemask(1, 1, 1);
937
    sizemask |= tcg_gen_sizemask(2, 1, 1);
938

  
939
    tcg_gen_helper64(tcg_helper_sar_i64, sizemask, ret, arg1, arg2);
891 940
}
892 941

  
893 942
static inline void tcg_gen_sari_i64(TCGv_i64 ret, TCGv_i64 arg1, int64_t arg2)
......
935 984

  
936 985
static inline void tcg_gen_div_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2)
937 986
{
938
    tcg_gen_helper64(tcg_helper_div_i64, ret, arg1, arg2);
987
    int sizemask = 0;
988
    /* Return value and both arguments are 64-bit and signed.  */
989
    sizemask |= tcg_gen_sizemask(0, 1, 1);
990
    sizemask |= tcg_gen_sizemask(1, 1, 1);
991
    sizemask |= tcg_gen_sizemask(2, 1, 1);
992

  
993
    tcg_gen_helper64(tcg_helper_div_i64, sizemask, ret, arg1, arg2);
939 994
}
940 995

  
941 996
static inline void tcg_gen_rem_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2)
942 997
{
943
    tcg_gen_helper64(tcg_helper_rem_i64, ret, arg1, arg2);
998
    int sizemask = 0;
999
    /* Return value and both arguments are 64-bit and signed.  */
1000
    sizemask |= tcg_gen_sizemask(0, 1, 1);
1001
    sizemask |= tcg_gen_sizemask(1, 1, 1);
1002
    sizemask |= tcg_gen_sizemask(2, 1, 1);
1003

  
1004
    tcg_gen_helper64(tcg_helper_rem_i64, sizemask, ret, arg1, arg2);
944 1005
}
945 1006

  
946 1007
static inline void tcg_gen_divu_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2)
947 1008
{
948
    tcg_gen_helper64(tcg_helper_divu_i64, ret, arg1, arg2);
1009
    int sizemask = 0;
1010
    /* Return value and both arguments are 64-bit and unsigned.  */
1011
    sizemask |= tcg_gen_sizemask(0, 1, 0);
1012
    sizemask |= tcg_gen_sizemask(1, 1, 0);
1013
    sizemask |= tcg_gen_sizemask(2, 1, 0);
1014

  
1015
    tcg_gen_helper64(tcg_helper_divu_i64, sizemask, ret, arg1, arg2);
949 1016
}
950 1017

  
951 1018
static inline void tcg_gen_remu_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2)
952 1019
{
953
    tcg_gen_helper64(tcg_helper_remu_i64, ret, arg1, arg2);
1020
    int sizemask = 0;
1021
    /* Return value and both arguments are 64-bit and unsigned.  */
1022
    sizemask |= tcg_gen_sizemask(0, 1, 0);
1023
    sizemask |= tcg_gen_sizemask(1, 1, 0);
1024
    sizemask |= tcg_gen_sizemask(2, 1, 0);
1025

  
1026
    tcg_gen_helper64(tcg_helper_remu_i64, sizemask, ret, arg1, arg2);
954 1027
}
955 1028

  
956 1029
#else
......
1212 1285
#else
1213 1286
static inline void tcg_gen_div_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2)
1214 1287
{
1215
    tcg_gen_helper64(tcg_helper_div_i64, ret, arg1, arg2);
1288
    int sizemask = 0;
1289
    /* Return value and both arguments are 64-bit and signed.  */
1290
    sizemask |= tcg_gen_sizemask(0, 1, 1);
1291
    sizemask |= tcg_gen_sizemask(1, 1, 1);
1292
    sizemask |= tcg_gen_sizemask(2, 1, 1);
1293

  
1294
    tcg_gen_helper64(tcg_helper_div_i64, sizemask, ret, arg1, arg2);
1216 1295
}
1217 1296

  
1218 1297
static inline void tcg_gen_rem_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2)
1219 1298
{
1220
    tcg_gen_helper64(tcg_helper_rem_i64, ret, arg1, arg2);
1299
    int sizemask = 0;
1300
    /* Return value and both arguments are 64-bit and signed.  */
1301
    sizemask |= tcg_gen_sizemask(0, 1, 1);
1302
    sizemask |= tcg_gen_sizemask(1, 1, 1);
1303
    sizemask |= tcg_gen_sizemask(2, 1, 1);
1304

  
1305
    tcg_gen_helper64(tcg_helper_rem_i64, sizemask, ret, arg1, arg2);
1221 1306
}
1222 1307

  
1223 1308
static inline void tcg_gen_divu_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2)
1224 1309
{
1225
    tcg_gen_helper64(tcg_helper_divu_i64, ret, arg1, arg2);
1310
    int sizemask = 0;
1311
    /* Return value and both arguments are 64-bit and unsigned.  */
1312
    sizemask |= tcg_gen_sizemask(0, 1, 0);
1313
    sizemask |= tcg_gen_sizemask(1, 1, 0);
1314
    sizemask |= tcg_gen_sizemask(2, 1, 0);
1315

  
1316
    tcg_gen_helper64(tcg_helper_divu_i64, sizemask, ret, arg1, arg2);
1226 1317
}
1227 1318

  
1228 1319
static inline void tcg_gen_remu_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2)
1229 1320
{
1230
    tcg_gen_helper64(tcg_helper_remu_i64, ret, arg1, arg2);
1321
    int sizemask = 0;
1322
    /* Return value and both arguments are 64-bit and unsigned.  */
1323
    sizemask |= tcg_gen_sizemask(0, 1, 0);
1324
    sizemask |= tcg_gen_sizemask(1, 1, 0);
1325
    sizemask |= tcg_gen_sizemask(2, 1, 0);
1326

  
1327
    tcg_gen_helper64(tcg_helper_remu_i64, sizemask, ret, arg1, arg2);
1231 1328
}
1232 1329
#endif
1233 1330

  

Also available in: Unified diff