static bool JustMoveLabel( common_info *max, ins_entry *ins ) /***************************************************************/ { oc_class cl; ins_entry *lbl; ins_entry *add; ins_entry *next; optbegin if( PrevClass( max->start_del ) != OC_LABEL ) optreturn( FALSE ); lbl = PrevIns( max->start_del ); if( _Attr( lbl ) & ATTR_SHORT ) optreturn( FALSE ); cl = PrevClass( lbl ); if( !_TransferClass( cl ) ) optreturn( FALSE ); DeleteQueue( lbl ); InsertQueue( lbl, PrevIns( max->start_com ) ); add = PrevIns( max->start_del ); for( ;; ) { next = NextIns( add ); DelInstr( next ); if( next == ins ) { break; } } Untangle( lbl ); optreturn( TRUE ); }
extern bool FindShort( ins_entry *ins, ins_entry *end ) /*********************************************************/ { for( ; ins != NULL && ins != end; ins = NextIns( ins ) ) { if( _Class( ins ) == OC_LABEL ) { if( _Attr( ins ) & ATTR_SHORT ) return( true ); _ClrStatus( _Label( ins ), SHORTREACH ); } } return( false ); }
extern void CallRet( ins_entry *instr ) /*****************************************/ { ins_entry *lbl; optbegin if( _Attr( instr ) & ATTR_POP ) optreturnvoid; lbl = _Label( instr )->ins; if( lbl == NULL ) optreturnvoid; if( NextClass( lbl ) != OC_RET ) optreturnvoid; _Savings( OPT_CALLTORET, _ObjLen( instr ) ); DelInstr( instr ); optend }
static void TransformJumps( ins_entry *ins, ins_entry *first ) /****************************************************************/ { ins_entry *add; ins_entry *next; ins_entry *lbl; oc_class cl; optbegin if( _Class( ins ) == OC_RET ) optreturnvoid; lbl = _Label( ins )->ins; if( lbl == NULL ) optreturnvoid; add = lbl; for( ;; ) { if( add == NULL ) optreturnvoid; cl = _Class( add ); if( _TransferClass( cl ) ) break; if( cl == OC_LABEL ) { if( _Attr( add ) & ATTR_SHORT ) optreturnvoid; _ClrStatus( _Label( add ), SHORTREACH ); } add = NextIns( add ); } if( add == first || add == ins ) optreturnvoid; if( FindShort( first, lbl ) ) optreturnvoid; for( ;; ) { next = PrevIns( add ); DeleteQueue( add ); InsertQueue( add, first ); if( add == lbl ) break; add = next; } DeleteQueue( first ); InsertQueue( first, next ); Untangle( NextIns( first ) ); optend }