Revision 1cd62ae9

b/tcg/ppc64/tcg-target.c
305 305
#define LWA    XO58(  2)
306 306
#define LWAX   XO31(341)
307 307

  
308
#define ADDIC  OPCD( 12)
308 309
#define ADDI   OPCD( 14)
309 310
#define ADDIS  OPCD( 15)
310 311
#define ORI    OPCD( 24)
......
332 333
#define CRANDC XO19(129)
333 334
#define CRNAND XO19(225)
334 335
#define CROR   XO19(449)
336
#define CRNOR  XO19( 33)
335 337

  
336 338
#define EXTSB  XO31(954)
337 339
#define EXTSH  XO31(922)
......
359 361
#define MTSPR  XO31(467)
360 362
#define SRAWI  XO31(824)
361 363
#define NEG    XO31(104)
364
#define MFCR   XO31( 19)
365
#define CNTLZW XO31( 26)
366
#define CNTLZD XO31( 58)
362 367

  
363 368
#define MULLD  XO31(233)
364 369
#define MULHD  XO31( 73)
......
1044 1049

  
1045 1050
}
1046 1051

  
1052
static void tcg_out_setcond (TCGContext *s, TCGType type, int cond, TCGArg arg0,
1053
                             TCGArg arg1, TCGArg arg2, int const_arg2)
1054
{
1055
    int crop, sh, arg;
1056

  
1057
    switch (cond) {
1058
    case TCG_COND_EQ:
1059
        if (const_arg2) {
1060
            if (!arg2) {
1061
                arg = arg1;
1062
            }
1063
            else {
1064
                arg = 0;
1065
                if ((uint16_t) arg2 == arg2) {
1066
                    tcg_out32 (s, XORI | RS (arg1) | RA (0) | arg2);
1067
                }
1068
                else {
1069
                    tcg_out_movi (s, type, 0, arg2);
1070
                    tcg_out32 (s, XOR | SAB (arg1, 0, 0));
1071
                }
1072
            }
1073
        }
1074
        else {
1075
            arg = 0;
1076
            tcg_out32 (s, XOR | SAB (arg1, 0, arg2));
1077
        }
1078

  
1079
        if (type == TCG_TYPE_I64) {
1080
            tcg_out32 (s, CNTLZD | RS (arg) | RA (0));
1081
            tcg_out_rld (s, RLDICL, arg0, 0, 58, 6);
1082
        }
1083
        else {
1084
            tcg_out32 (s, CNTLZW | RS (arg) | RA (0));
1085
            tcg_out32 (s, (RLWINM
1086
                           | RA (arg0)
1087
                           | RS (0)
1088
                           | SH (27)
1089
                           | MB (5)
1090
                           | ME (31)
1091
                           )
1092
                );
1093
        }
1094
        break;
1095

  
1096
    case TCG_COND_NE:
1097
        if (const_arg2) {
1098
            if (!arg2) {
1099
                arg = arg1;
1100
            }
1101
            else {
1102
                arg = 0;
1103
                if ((uint16_t) arg2 == arg2) {
1104
                    tcg_out32 (s, XORI | RS (arg1) | RA (0) | arg2);
1105
                }
1106
                else {
1107
                    tcg_out_movi (s, type, 0, arg2);
1108
                    tcg_out32 (s, XOR | SAB (arg1, 0, 0));
1109
                }
1110
            }
1111
        }
1112
        else {
1113
            arg = 0;
1114
            tcg_out32 (s, XOR | SAB (arg1, 0, arg2));
1115
        }
1116

  
1117
        if (arg == arg1 && arg1 == arg0) {
1118
            tcg_out32 (s, ADDIC | RT (0) | RA (arg) | 0xffff);
1119
            tcg_out32 (s, SUBFE | TAB (arg0, 0, arg));
1120
        }
1121
        else {
1122
            tcg_out32 (s, ADDIC | RT (arg0) | RA (arg) | 0xffff);
1123
            tcg_out32 (s, SUBFE | TAB (arg0, arg0, arg));
1124
        }
1125
        break;
1126

  
1127
    case TCG_COND_GT:
1128
    case TCG_COND_GTU:
1129
        sh = 30;
1130
        crop = 0;
1131
        goto crtest;
1132

  
1133
    case TCG_COND_LT:
1134
    case TCG_COND_LTU:
1135
        sh = 29;
1136
        crop = 0;
1137
        goto crtest;
1138

  
1139
    case TCG_COND_GE:
1140
    case TCG_COND_GEU:
1141
        sh = 31;
1142
        crop = CRNOR | BT (7, CR_EQ) | BA (7, CR_LT) | BB (7, CR_LT);
1143
        goto crtest;
1144

  
1145
    case TCG_COND_LE:
1146
    case TCG_COND_LEU:
1147
        sh = 31;
1148
        crop = CRNOR | BT (7, CR_EQ) | BA (7, CR_GT) | BB (7, CR_GT);
1149
    crtest:
1150
        tcg_out_cmp (s, cond, arg1, arg2, const_arg2, 7, type == TCG_TYPE_I64);
1151
        if (crop) tcg_out32 (s, crop);
1152
        tcg_out32 (s, MFCR | RT (0));
1153
        tcg_out32 (s, (RLWINM
1154
                       | RA (arg0)
1155
                       | RS (0)
1156
                       | SH (sh)
1157
                       | MB (31)
1158
                       | ME (31)
1159
                       )
1160
            );
1161
        break;
1162

  
1163
    default:
1164
        tcg_abort ();
1165
    }
1166
}
1167

  
1047 1168
static void tcg_out_bc (TCGContext *s, int bc, int label_index)
1048 1169
{
1049 1170
    TCGLabel *l = &s->labels[label_index];
......
1433 1554
        tcg_out32 (s, c | RS (args[1]) | RA (args[0]));
1434 1555
        break;
1435 1556

  
1557
    case INDEX_op_setcond_i32:
1558
        tcg_out_setcond (s, TCG_TYPE_I32, args[3], args[0], args[1], args[2],
1559
                         const_args[2]);
1560
        break;
1561
    case INDEX_op_setcond_i64:
1562
        tcg_out_setcond (s, TCG_TYPE_I64, args[3], args[0], args[1], args[2],
1563
                         const_args[2]);
1564
        break;
1565

  
1436 1566
    default:
1437 1567
        tcg_dump_ops (s, stderr);
1438 1568
        tcg_abort ();
......
1530 1660
    { INDEX_op_ext16s_i64, { "r", "r" } },
1531 1661
    { INDEX_op_ext32s_i64, { "r", "r" } },
1532 1662

  
1663
    { INDEX_op_setcond_i32, { "r", "r", "ri" } },
1664
    { INDEX_op_setcond_i64, { "r", "r", "ri" } },
1665

  
1533 1666
    { -1 },
1534 1667
};
1535 1668

  

Also available in: Unified diff