Revision 5ff9d6a4 tcg/tcg.c

b/tcg/tcg.c
401 401
        ts = &s->temps[s->nb_temps];
402 402
        ts->base_type = type;
403 403
        ts->type = TCG_TYPE_I32;
404
        ts->fixed_reg = 0;
404 405
        ts->val_type = TEMP_VAL_DEAD;
405 406
        ts->mem_allocated = 0;
406 407
        ts->name = NULL;
......
408 409
        ts->base_type = TCG_TYPE_I32;
409 410
        ts->type = TCG_TYPE_I32;
410 411
        ts->val_type = TEMP_VAL_DEAD;
412
        ts->fixed_reg = 0;
411 413
        ts->mem_allocated = 0;
412 414
        ts->name = NULL;
413 415
        s->nb_temps += 2;
......
418 420
        ts = &s->temps[s->nb_temps];
419 421
        ts->base_type = type;
420 422
        ts->type = type;
423
        ts->fixed_reg = 0;
421 424
        ts->val_type = TEMP_VAL_DEAD;
422 425
        ts->mem_allocated = 0;
423 426
        ts->name = NULL;
......
805 808
                assert(oarg < def->nb_oargs);
806 809
                assert(def->args_ct[oarg].ct & TCG_CT_REG);
807 810
                /* TCG_CT_ALIAS is for the output arguments. The input
808
                   argument is tagged with TCG_CT_IALIAS for
809
                   informative purposes. */
811
                   argument is tagged with TCG_CT_IALIAS. */
810 812
                def->args_ct[i] = def->args_ct[oarg];
811
                def->args_ct[oarg].ct = i | TCG_CT_ALIAS;
813
                def->args_ct[oarg].ct = TCG_CT_ALIAS;
814
                def->args_ct[oarg].alias_index = i;
812 815
                def->args_ct[i].ct |= TCG_CT_IALIAS;
816
                def->args_ct[i].alias_index = oarg;
813 817
            } else {
814 818
                for(;;) {
815 819
                    if (*ct_str == '\0')
......
935 939
            nb_args = args[-1];
936 940
            args -= nb_args;
937 941
            break;
942
        case INDEX_op_discard:
943
            args--;
944
            /* mark the temporary as dead */
945
            dead_temps[args[0]] = 1;
946
            break;
938 947
        case INDEX_op_macro_2:
939 948
            {
940 949
                int dead_args[2], macro_id;
......
1015 1024
                nb_oargs = def->nb_oargs;
1016 1025

  
1017 1026
                /* Test if the operation can be removed because all
1018
                   its outputs are dead. We may add a flag to
1019
                   explicitely tell if the op has side
1020
                   effects. Currently we assume that if nb_oargs == 0
1021
                   or OPF_BB_END is set, the operation has side
1022
                   effects and cannot be removed */
1023
                if (nb_oargs != 0 && !(def->flags & TCG_OPF_BB_END)) {
1027
                   its outputs are dead. We assume that nb_oargs == 0
1028
                   implies side effects */
1029
                if (!(def->flags & TCG_OPF_SIDE_EFFECTS) && nb_oargs != 0) {
1024 1030
                    for(i = 0; i < nb_oargs; i++) {
1025 1031
                        arg = args[i];
1026 1032
                        if (!dead_temps[arg])
......
1164 1170
    ts = &s->temps[temp];
1165 1171
    s->current_frame_offset = (s->current_frame_offset + sizeof(tcg_target_long) - 1) & ~(sizeof(tcg_target_long) - 1);
1166 1172
    if (s->current_frame_offset + sizeof(tcg_target_long) > s->frame_end)
1167
        abort();
1173
        tcg_abort();
1168 1174
    ts->mem_offset = s->current_frame_offset;
1169 1175
    ts->mem_reg = s->frame_reg;
1170 1176
    ts->mem_allocated = 1;
......
1350 1356
            }
1351 1357
        }
1352 1358
        assert(ts->val_type == TEMP_VAL_REG);
1353
        if ((arg_ct->ct & TCG_CT_IALIAS) &&
1354
            !IS_DEAD_IARG(i - nb_oargs)) {
1355
            /* if the input is aliased to an output and if it is
1356
               not dead after the instruction, we must allocate
1357
               a new register and move it */
1358
            goto allocate_in_reg;
1359
        if (arg_ct->ct & TCG_CT_IALIAS) {
1360
            if (ts->fixed_reg) {
1361
                /* if fixed register, we must allocate a new register
1362
                   if the alias is not the same register */
1363
                if (arg != args[arg_ct->alias_index])
1364
                    goto allocate_in_reg;
1365
            } else {
1366
                /* if the input is aliased to an output and if it is
1367
                   not dead after the instruction, we must allocate
1368
                   a new register and move it */
1369
                if (!IS_DEAD_IARG(i - nb_oargs)) 
1370
                    goto allocate_in_reg;
1371
            }
1359 1372
        }
1360 1373
        reg = ts->reg;
1361 1374
        if (tcg_regset_test_reg(arg_ct->u.regs, reg)) {
......
1404 1417
        arg_ct = &def->args_ct[i];
1405 1418
        ts = &s->temps[arg];
1406 1419
        if (arg_ct->ct & TCG_CT_ALIAS) {
1407
            reg = new_args[arg_ct->ct & ~TCG_CT_ALIAS];
1420
            reg = new_args[arg_ct->alias_index];
1408 1421
        } else {
1409 1422
            /* if fixed register, we try to use it */
1410 1423
            reg = ts->reg;
......
1694 1707
        case INDEX_op_nopn:
1695 1708
            args += args[0];
1696 1709
            goto next;
1710
        case INDEX_op_discard:
1711
            {
1712
                TCGTemp *ts;
1713
                ts = &s->temps[args[0]];
1714
                /* mark the temporary as dead */
1715
                if (ts->val_type != TEMP_VAL_CONST && !ts->fixed_reg) {
1716
                    if (ts->val_type == TEMP_VAL_REG)
1717
                        s->reg_to_temp[ts->reg] = -1;
1718
                    ts->val_type = TEMP_VAL_DEAD;
1719
                }
1720
            }
1721
            break;
1697 1722
        case INDEX_op_macro_goto:
1698 1723
            macro_op_index = op_index; /* only used for exceptions */
1699 1724
            op_index = args[0] - 1;

Also available in: Unified diff