Ejemplo n.º 1
0
static  void            PreOptimize( void )
/*****************************************/
{
    bool        change;

    if( _IsntModel( NO_OPTIMIZATION ) ) {
//      CharsAndShortsToInts();
        MakeMovAddrConsts();
        PushPostOps();
        DeadTemps();
        InsDead();
        MakeFlowGraph();
        BlockTrim();
        CommonSex( _IsModel( LOOP_OPTIMIZATION ) );
        SetOnCondition();
        BlockTrim();
        AddANop();
        if( _IsModel( LOOP_OPTIMIZATION ) ) {
            change = FALSE;
            if( TransLoops( FALSE ) ) {
                change = TRUE;
            }
            if( LoopInvariant() ) {
                change = TRUE;
            }
            if( change ) {
                CommonSex(TRUE);
                InsDead();
                CommonInvariant();
            }
            if( IndVars() ) {
                CommonSex(FALSE);
                InsDead();
                change = TRUE;
            }
            BlockTrim();
            if( TransLoops( TRUE ) ) {
                BlockTrim();
                CommonSex( FALSE );
                change = TRUE;
            }
            if( change ) {
                ReConstFold();
            }
            LoopEnregister();
            if( change ) {
                BlockTrim();
            }
        }
        MulToShiftAdd();
        KillMovAddrConsts();
        FindReferences();
    } else {
        MakeFlowGraph();
        AddANop();
        FindReferences();
    }
}
Ejemplo n.º 2
0
extern  void    SplitVars( void )
/*******************************/
/* For each variable, find out if it can be split into two separate variables.*/
/* This often happens when programmers re-use variables rather than defining*/
/* a new one.*/
{
    name                *op;
    conflict_node       *conf;

    for( ;; ) {
        for( conf = ConfList; conf != NULL; conf = conf->next_conflict ) {
            op = conf->name;
            if( (op->v.usage & USE_IN_ANOTHER_BLOCK) == 0 )
                continue;
            if( op->n.class != N_TEMP )
                continue;
            if( _Is( conf, CST_CONF_VISITED ) )
                continue;
            _SetFalse( conf, CST_CONFLICT_ON_HOLD );
            if( _GBitEmpty( conf->id.out_of_block ) )
                continue;
            if( op->t.alias == op )
                Split1Var( conf );
            _GBitInit( conf->id.out_of_block, EMPTY );
            _SetTrue( conf, CST_CONFLICT_ON_HOLD | CST_CONF_VISITED );
        }
        if( !MoreConflicts() ) {
            break;
        }
    }
    CleanUp();
    FreeConflicts();
    InsDead();
    NullConflicts( EMPTY );
    FindReferences();
    MakeConflicts();
}