ir.c
// Long double rvalues never live in registers, ensure all of them are on the stack
Long double rvalues never live in registers, ensure all of them are on the stack
Long double rvalues never live in registers ensure all of them are on the stack
void move_long_doubles_to_the_stack(Function *function) {
    make_vreg_count(function, 0);
    int *local_indexes = malloc(sizeof(int) * (function->vreg_count + 1));
    memset(local_indexes, 0, sizeof(int) * (function->vreg_count + 1));
    for (Tac *tac = function->ir; tac; tac = tac->next) {
        if (tac->dst  && tac->dst ->vreg && tac->dst ->type && tac->dst ->type->type == TYPE_LONG_DOUBLE && !tac->dst ->is_lvalue && !local_indexes[tac->dst ->vreg])
            local_indexes[tac->dst ->vreg] = new_local_index(function);
        if (tac->src1 && tac->src1->vreg && tac->src1->type && tac->src1->type->type == TYPE_LONG_DOUBLE && !tac->src1->is_lvalue && !local_indexes[tac->src1->vreg])
            local_indexes[tac->src1->vreg] = new_local_index(function);
        if (tac->src2 && tac->src2->vreg && tac->src2->type && tac->src2->type->type == TYPE_LONG_DOUBLE && !tac->src2->is_lvalue && !local_indexes[tac->src2->vreg])
            local_indexes[tac->src2->vreg] = new_local_index(function);
    }
    for (Tac *tac = function->ir; tac; tac = tac->next) {
        if (tac-> dst && tac-> dst->vreg && local_indexes[tac-> dst->vreg]) { tac-> dst->local_index = local_indexes[tac-> dst->vreg]; tac-> dst->vreg = 0; }
        if (tac->src1 && tac->src1->vreg && local_indexes[tac->src1->vreg]) { tac->src1->local_index = local_indexes[tac->src1->vreg]; tac->src1->vreg = 0; }
        if (tac->src2 && tac->src2->vreg && local_indexes[tac->src2->vreg]) { tac->src2->local_index = local_indexes[tac->src2->vreg]; tac->src2->vreg = 0; }
    }
}
void move_long_doubles_to_the_stack ( Function * function ) { make_vreg_count ( function , 0 ) ; int * local_indexes = malloc ( sizeof ( int ) * ( function -> vreg_count + 1 ) ) ; memset ( local_indexes , 0 , sizeof ( int ) * ( function -> vreg_count + 1 ) ) ; for ( Tac * tac = function -> ir ; tac ; tac = tac -> next ) { if ( tac -> dst && tac -> dst -> vreg && tac -> dst -> type && tac -> dst -> type -> type == TYPE_LONG_DOUBLE && ! tac -> dst -> is_lvalue && ! local_indexes [ tac -> dst -> vreg ] ) local_indexes [ tac -> dst -> vreg ] = new_local_index ( function ) ; if ( tac -> src1 && tac -> src1 -> vreg && tac -> src1 -> type && tac -> src1 -> type -> type == TYPE_LONG_DOUBLE && ! tac -> src1 -> is_lvalue && ! local_indexes [ tac -> src1 -> vreg ] ) local_indexes [ tac -> src1 -> vreg ] = new_local_index ( function ) ; if ( tac -> src2 && tac -> src2 -> vreg && tac -> src2 -> type && tac -> src2 -> type -> type == TYPE_LONG_DOUBLE && ! tac -> src2 -> is_lvalue && ! local_indexes [ tac -> src2 -> vreg ] ) local_indexes [ tac -> src2 -> vreg ] = new_local_index ( function ) ; } for ( Tac * tac = function -> ir ; tac ; tac = tac -> next ) { if ( tac -> dst && tac -> dst -> vreg && local_indexes [ tac -> dst -> vreg ] ) { tac -> dst -> local_index = local_indexes [ tac -> dst -> vreg ] ; tac -> dst -> vreg = 0 ; } if ( tac -> src1 && tac -> src1 -> vreg && local_indexes [ tac -> src1 -> vreg ] ) { tac -> src1 -> local_index = local_indexes [ tac -> src1 -> vreg ] ; tac -> src1 -> vreg = 0 ; } if ( tac -> src2 && tac -> src2 -> vreg && local_indexes [ tac -> src2 -> vreg ] ) { tac -> src2 -> local_index = local_indexes [ tac -> src2 -> vreg ] ; tac -> src2 -> vreg = 0 ; } } }
Long double rvalues never live in registers, ensure all of them are on the stack
Long double rvalues never live in registers ensure all of them are on the stack
// Long doubles in vregs are moved to the stack