Beispiel #1
0
static  fp_attr FPAttr( instruction *ins ) {
    /*******************************************/

    if( _OpIsCall( ins->head.opcode ) && ins->result != NULL ) {
        if( ins->result->n.class != N_REGISTER ) return( POPS_ALL );
        if( !HW_COvlap( ins->result->r.reg, HW_FLTS ) ) return( POPS_ALL );
        return( PUSHES+POPS_ALL );
    }
    if( ins->u.gen_table->generate == G_FCHOP ) return( NEEDS_ST0 );
    if( !_GenIs8087( ins->u.gen_table->generate ) ) {
        return( NEEDS_NOTHING );
    }
    switch( ins->u.gen_table->generate ) {
    case G_RRFBINP:
    case G_RNFBINP:
        return( NEEDS_ST0+POPS+SETS_ST1 );
    case G_MFLD:
    case G_FLDZ:
    case G_FLD1:
    case G_RFLD:
        return( PUSHES );
    case G_FRNDINT:
    case G_FCHS:
    case G_MFSTNP:
    case G_RFSTNP:
    case G_FTST:
    case G_FMATH:
    case G_RRFBIN:
    case G_RNFBIN:
    case G_MRFBIN:
    case G_MNFBIN:
        return( NEEDS_ST0 );
    case G_FCOMPP:
        return( NEEDS_ST0_ST1+POPS2 );
    case G_MFST:
    case G_MFSTRND:
    case G_RFST:
    case G_MCOMP:
    case G_RCOMP:
        return( NEEDS_ST0+POPS );
    case G_IFUNC:
        if( NumOperands( ins ) == 2 ) {
            return( NEEDS_ST0_ST1+POPS );
        } else {
            return( NEEDS_ST0 );
        }
    case G_FXCH:
        return( NEEDS_ST0+EXCHANGES );
    case G_FSINCOS:
    default:
        Zoiks( ZOIKS_075 );
        return( NEEDS_NOTHING );
    }
}
Beispiel #2
0
static  byte    Displacement( signed_32 val, hw_reg_set regs )
/************************************************************/
{
    if( val == 0 && !HW_COvlap( regs, HW_BP ) ) return( D0 );
    if( val <= 127 && val >= -128 ) {
        AddByte( val & 0xff );
        return( D8 );
    } else {
        Add32Displacement( val );
        return( D32 );
    }
}
Beispiel #3
0
static bool HasSegRegs( reg_tree *tree )
{
    hw_reg_set  *regs;

    regs = tree->regs;
    if( regs != NULL ) {
        for( ; !HW_CEqual( *regs, HW_EMPTY ); ++regs ) {
            if( HW_COvlap( *regs, HW_SEGS ) ) return( true );
        }
    }
    return( false );
}
Beispiel #4
0
extern  void    DumpInOut( instruction *ins ) {
/*********************************************/

    DumpLiteral( "     " );
    DumpGBit( &ins->head.live.out_of_block );
    DumpChar( ' ' );
    DumpLBit( &ins->head.live.within_block );
    if( !HW_CEqual( ins->head.live.regs, HW_EMPTY ) && !HW_COvlap( ins->head.live.regs, HW_UNUSED ) ) {
        DumpLiteral( "  " );
        DumpRegName( ins->head.live.regs );
    }
    DumpNL();
}
Beispiel #5
0
type_class_def  RegClass( hw_reg_set regs )
/*****************************************/
{
    hw_reg_set          test;

    if( HW_COvlap( regs, HW_FPR ) )
        return( FD );
    HW_CAsgn( test, HW_BREGS );
    if( HW_Subset( test, regs ) )
        return( U1 );
    HW_CAsgn( test, HW_WREGS );
    if( HW_Subset( test, regs ) )
        return( U2 );
    HW_CAsgn( test, HW_DREGS );
    if( HW_Subset( test, regs ) )
        return( U4 );
    return( U8 );
}
Beispiel #6
0
void    AddRegs( void )
/******************************
    Add some registers to the N_REGISTER list, so that we can do
    scoreboarding on them
*/
{
    hw_reg_set  lo_part;
    name        *reg_name;
    int         i;
    int         j;

    DS = AllocRegName( HW_DS );
    SS = AllocRegName( HW_SS );
    /*      89-01-03*/
    ES = AllocRegName( HW_ES );
    for( i = S_MAX; i-- > 0; ) {
        for( j = I_MAX; j-- > 0; ) {
            PtrRegs[i][j] = NULL;
        }
    }
    for( reg_name = Names[N_REGISTER]; reg_name != NULL; reg_name = reg_name->n.next_name ) {
        if( IsIndexReg( reg_name->r.reg, CP, false ) ) {
            if( HW_COvlap( reg_name->r.reg, HW_DS )
                    || HW_COvlap( reg_name->r.reg, HW_ES )
                    || HW_COvlap( reg_name->r.reg, HW_SS ) ) {
                lo_part = LowReg( reg_name->r.reg );
                if( HW_COvlap( lo_part, HW_BX ) ) {
                    PtrRegs[S_DS][I_BX] = NewRegName( HW_DS_BX );
                    PtrRegs[S_SS][I_BX] = NewRegName( HW_SS_BX );
                    PtrRegs[S_ES][I_BX] = NewRegName( HW_ES_BX );
                } else if( HW_COvlap( lo_part, HW_SI ) ) {
                    PtrRegs[S_DS][I_SI] = NewRegName( HW_DS_SI );
                    PtrRegs[S_SS][I_SI] = NewRegName( HW_SS_SI );
                    PtrRegs[S_ES][I_SI] = NewRegName( HW_ES_SI );
                } else if( HW_COvlap( lo_part, HW_DI ) ) {
                    PtrRegs[S_DS][I_DI] = NewRegName( HW_DS_DI );
                    PtrRegs[S_SS][I_DI] = NewRegName( HW_SS_DI );
                    PtrRegs[S_ES][I_DI] = NewRegName( HW_ES_DI );
                }
            }
        }
    }
    /*      89-01-03*/
}
Beispiel #7
0
extern  void    DumpRegName( hw_reg_set regname ) {
/*************************************************/

    bool        first;
    hw_reg_set  name;

    first = true;
    name = regname;
    if( !HW_COvlap( name, HW_UNUSED ) ) {
        while( !HW_CEqual( name, HW_EMPTY ) ) {
            if( first ) {
                first = false;
            } else {
                DumpChar( ':' );
            }
#if _TARGET & _TARG_370
            if( Check(&name,HW_G0) ) { DumpLiteral( "G0" ); continue; }
            if( Check(&name,HW_G1) ) { DumpLiteral( "G1" ); continue; }
            if( Check(&name,HW_G2) ) { DumpLiteral( "G2" ); continue; }
            if( Check(&name,HW_G3) ) { DumpLiteral( "G3" ); continue; }
            if( Check(&name,HW_G4) ) { DumpLiteral( "G4" ); continue; }
            if( Check(&name,HW_G5) ) { DumpLiteral( "G5" ); continue; }
            if( Check(&name,HW_G6) ) { DumpLiteral( "G6" ); continue; }
            if( Check(&name,HW_G7) ) { DumpLiteral( "G7" ); continue; }
            if( Check(&name,HW_G8) ) { DumpLiteral( "G8" ); continue; }
            if( Check(&name,HW_G9) ) { DumpLiteral( "G9" ); continue; }
            if( Check(&name,HW_G10)) { DumpLiteral( "G10" ); continue; }
            if( Check(&name,HW_G11)) { DumpLiteral( "G11" ); continue; }
            if( Check(&name,HW_G12)) { DumpLiteral( "G12" ); continue; }
            if( Check(&name,HW_G13)) { DumpLiteral( "G13" ); continue; }
            if( Check(&name,HW_G14)) { DumpLiteral( "G14" ); continue; }
            if( Check(&name,HW_G15)) { DumpLiteral( "G15" ); continue; }
            if( Check(&name,HW_E0) ) { DumpLiteral( "E0" ); continue; }
            if( Check(&name,HW_E4) ) { DumpLiteral( "E4" ); continue; }
            if( Check(&name,HW_D0) ) { DumpLiteral( "D0" ); continue; }
            if( Check(&name,HW_D2) ) { DumpLiteral( "D2" ); continue; }
            if( Check(&name,HW_D4) ) { DumpLiteral( "D4" ); continue; }
            if( Check(&name,HW_D6) ) { DumpLiteral( "D6" ); continue; }
            if( Check(&name,HW_Y0) ) { DumpLiteral( "Y0" ); continue; }
            if( Check(&name,HW_Y2) ) { DumpLiteral( "Y2" ); continue; }
            if( Check(&name,HW_Y4) ) { DumpLiteral( "Y4" ); continue; }
            if( Check(&name,HW_Y6) ) { DumpLiteral( "Y6" ); continue; }
#endif
#if _TARGET & (_TARG_PPC | _TARG_AXP | _TARG_MIPS)
            if( Check(&name,HW_R0) ) { DumpLiteral( "R0" ); continue; }
            if( Check(&name,HW_R1) ) { DumpLiteral( "R1" ); continue; }
            if( Check(&name,HW_R2) ) { DumpLiteral( "R2" ); continue; }
            if( Check(&name,HW_R3) ) { DumpLiteral( "R3" ); continue; }
            if( Check(&name,HW_R4) ) { DumpLiteral( "R4" ); continue; }
            if( Check(&name,HW_R5) ) { DumpLiteral( "R5" ); continue; }
            if( Check(&name,HW_R6) ) { DumpLiteral( "R6" ); continue; }
            if( Check(&name,HW_R7) ) { DumpLiteral( "R7" ); continue; }
            if( Check(&name,HW_R8) ) { DumpLiteral( "R8" ); continue; }
            if( Check(&name,HW_R9) ) { DumpLiteral( "R9" ); continue; }
            if( Check(&name,HW_R10) ) { DumpLiteral( "R10" ); continue; }
            if( Check(&name,HW_R11) ) { DumpLiteral( "R11" ); continue; }
            if( Check(&name,HW_R12) ) { DumpLiteral( "R12" ); continue; }
            if( Check(&name,HW_R13) ) { DumpLiteral( "R13" ); continue; }
            if( Check(&name,HW_R14) ) { DumpLiteral( "R14" ); continue; }
            if( Check(&name,HW_R15) ) { DumpLiteral( "R15" ); continue; }
            if( Check(&name,HW_R16) ) { DumpLiteral( "R16" ); continue; }
            if( Check(&name,HW_R17) ) { DumpLiteral( "R17" ); continue; }
            if( Check(&name,HW_R18) ) { DumpLiteral( "R18" ); continue; }
            if( Check(&name,HW_R19) ) { DumpLiteral( "R19" ); continue; }
            if( Check(&name,HW_R20) ) { DumpLiteral( "R20" ); continue; }
            if( Check(&name,HW_R21) ) { DumpLiteral( "R21" ); continue; }
            if( Check(&name,HW_R22) ) { DumpLiteral( "R22" ); continue; }
            if( Check(&name,HW_R23) ) { DumpLiteral( "R23" ); continue; }
            if( Check(&name,HW_R24) ) { DumpLiteral( "R24" ); continue; }
            if( Check(&name,HW_R25) ) { DumpLiteral( "R25" ); continue; }
            if( Check(&name,HW_R26) ) { DumpLiteral( "R26" ); continue; }
            if( Check(&name,HW_R27) ) { DumpLiteral( "R27" ); continue; }
            if( Check(&name,HW_R28) ) { DumpLiteral( "R28" ); continue; }
            if( Check(&name,HW_R29) ) { DumpLiteral( "R29" ); continue; }
            if( Check(&name,HW_R30) ) { DumpLiteral( "R30" ); continue; }
            if( Check(&name,HW_R31) ) { DumpLiteral( "R31" ); continue; }
    
            if( Check(&name,HW_D0) ) { DumpLiteral( "D0" ); continue; }
            if( Check(&name,HW_D1) ) { DumpLiteral( "D1" ); continue; }
            if( Check(&name,HW_D2) ) { DumpLiteral( "D2" ); continue; }
            if( Check(&name,HW_D3) ) { DumpLiteral( "D3" ); continue; }
            if( Check(&name,HW_D4) ) { DumpLiteral( "D4" ); continue; }
            if( Check(&name,HW_D5) ) { DumpLiteral( "D5" ); continue; }
            if( Check(&name,HW_D6) ) { DumpLiteral( "D6" ); continue; }
            if( Check(&name,HW_D7) ) { DumpLiteral( "D7" ); continue; }
            if( Check(&name,HW_D8) ) { DumpLiteral( "D8" ); continue; }
            if( Check(&name,HW_D9) ) { DumpLiteral( "D9" ); continue; }
            if( Check(&name,HW_D10) ) { DumpLiteral( "D10" ); continue; }
            if( Check(&name,HW_D11) ) { DumpLiteral( "D11" ); continue; }
            if( Check(&name,HW_D12) ) { DumpLiteral( "D12" ); continue; }
            if( Check(&name,HW_D13) ) { DumpLiteral( "D13" ); continue; }
            if( Check(&name,HW_D14) ) { DumpLiteral( "D14" ); continue; }
            if( Check(&name,HW_D15) ) { DumpLiteral( "D15" ); continue; }
            if( Check(&name,HW_D16) ) { DumpLiteral( "D16" ); continue; }
            if( Check(&name,HW_D17) ) { DumpLiteral( "D17" ); continue; }
            if( Check(&name,HW_D18) ) { DumpLiteral( "D18" ); continue; }
            if( Check(&name,HW_D19) ) { DumpLiteral( "D19" ); continue; }
            if( Check(&name,HW_D20) ) { DumpLiteral( "D20" ); continue; }
            if( Check(&name,HW_D21) ) { DumpLiteral( "D21" ); continue; }
            if( Check(&name,HW_D22) ) { DumpLiteral( "D22" ); continue; }
            if( Check(&name,HW_D23) ) { DumpLiteral( "D23" ); continue; }
            if( Check(&name,HW_D24) ) { DumpLiteral( "D24" ); continue; }
            if( Check(&name,HW_D25) ) { DumpLiteral( "D25" ); continue; }
            if( Check(&name,HW_D26) ) { DumpLiteral( "D26" ); continue; }
            if( Check(&name,HW_D27) ) { DumpLiteral( "D27" ); continue; }
            if( Check(&name,HW_D28) ) { DumpLiteral( "D28" ); continue; }
            if( Check(&name,HW_D29) ) { DumpLiteral( "D29" ); continue; }
            if( Check(&name,HW_D30) ) { DumpLiteral( "D30" ); continue; }
            if( Check(&name,HW_D31) ) { DumpLiteral( "D31" ); continue; }
    
            if( Check(&name,HW_W0) ) { DumpLiteral( "W0" ); continue; }
            if( Check(&name,HW_W1) ) { DumpLiteral( "W1" ); continue; }
            if( Check(&name,HW_W2) ) { DumpLiteral( "W2" ); continue; }
            if( Check(&name,HW_W3) ) { DumpLiteral( "W3" ); continue; }
            if( Check(&name,HW_W4) ) { DumpLiteral( "W4" ); continue; }
            if( Check(&name,HW_W5) ) { DumpLiteral( "W5" ); continue; }
            if( Check(&name,HW_W6) ) { DumpLiteral( "W6" ); continue; }
            if( Check(&name,HW_W7) ) { DumpLiteral( "W7" ); continue; }
            if( Check(&name,HW_W8) ) { DumpLiteral( "W8" ); continue; }
            if( Check(&name,HW_W9) ) { DumpLiteral( "W9" ); continue; }
            if( Check(&name,HW_W10) ) { DumpLiteral( "W10" ); continue; }
            if( Check(&name,HW_W11) ) { DumpLiteral( "W11" ); continue; }
            if( Check(&name,HW_W12) ) { DumpLiteral( "W12" ); continue; }
            if( Check(&name,HW_W13) ) { DumpLiteral( "W13" ); continue; }
            if( Check(&name,HW_W14) ) { DumpLiteral( "W14" ); continue; }
            if( Check(&name,HW_W15) ) { DumpLiteral( "W15" ); continue; }
            if( Check(&name,HW_W16) ) { DumpLiteral( "W16" ); continue; }
            if( Check(&name,HW_W17) ) { DumpLiteral( "W17" ); continue; }
            if( Check(&name,HW_W18) ) { DumpLiteral( "W18" ); continue; }
            if( Check(&name,HW_W19) ) { DumpLiteral( "W19" ); continue; }
            if( Check(&name,HW_W20) ) { DumpLiteral( "W20" ); continue; }
            if( Check(&name,HW_W21) ) { DumpLiteral( "W21" ); continue; }
            if( Check(&name,HW_W22) ) { DumpLiteral( "W22" ); continue; }
            if( Check(&name,HW_W23) ) { DumpLiteral( "W23" ); continue; }
            if( Check(&name,HW_W24) ) { DumpLiteral( "W24" ); continue; }
            if( Check(&name,HW_W25) ) { DumpLiteral( "W25" ); continue; }
            if( Check(&name,HW_W26) ) { DumpLiteral( "W26" ); continue; }
            if( Check(&name,HW_W27) ) { DumpLiteral( "W27" ); continue; }
            if( Check(&name,HW_W28) ) { DumpLiteral( "W28" ); continue; }
            if( Check(&name,HW_W29) ) { DumpLiteral( "W29" ); continue; }
            if( Check(&name,HW_W30) ) { DumpLiteral( "W30" ); continue; }
            if( Check(&name,HW_W31) ) { DumpLiteral( "W31" ); continue; }
    
            if( Check(&name,HW_B0) ) { DumpLiteral( "B0" ); continue; }
            if( Check(&name,HW_B1) ) { DumpLiteral( "B1" ); continue; }
            if( Check(&name,HW_B2) ) { DumpLiteral( "B2" ); continue; }
            if( Check(&name,HW_B3) ) { DumpLiteral( "B3" ); continue; }
            if( Check(&name,HW_B4) ) { DumpLiteral( "B4" ); continue; }
            if( Check(&name,HW_B5) ) { DumpLiteral( "B5" ); continue; }
            if( Check(&name,HW_B6) ) { DumpLiteral( "B6" ); continue; }
            if( Check(&name,HW_B7) ) { DumpLiteral( "B7" ); continue; }
            if( Check(&name,HW_B8) ) { DumpLiteral( "B8" ); continue; }
            if( Check(&name,HW_B9) ) { DumpLiteral( "B9" ); continue; }
            if( Check(&name,HW_B10) ) { DumpLiteral( "B10" ); continue; }
            if( Check(&name,HW_B11) ) { DumpLiteral( "B11" ); continue; }
            if( Check(&name,HW_B12) ) { DumpLiteral( "B12" ); continue; }
            if( Check(&name,HW_B13) ) { DumpLiteral( "B13" ); continue; }
            if( Check(&name,HW_B14) ) { DumpLiteral( "B14" ); continue; }
            if( Check(&name,HW_B15) ) { DumpLiteral( "B15" ); continue; }
            if( Check(&name,HW_B16) ) { DumpLiteral( "B16" ); continue; }
            if( Check(&name,HW_B17) ) { DumpLiteral( "B17" ); continue; }
            if( Check(&name,HW_B18) ) { DumpLiteral( "B18" ); continue; }
            if( Check(&name,HW_B19) ) { DumpLiteral( "B19" ); continue; }
            if( Check(&name,HW_B20) ) { DumpLiteral( "B20" ); continue; }
            if( Check(&name,HW_B21) ) { DumpLiteral( "B21" ); continue; }
            if( Check(&name,HW_B22) ) { DumpLiteral( "B22" ); continue; }
            if( Check(&name,HW_B23) ) { DumpLiteral( "B23" ); continue; }
            if( Check(&name,HW_B24) ) { DumpLiteral( "B24" ); continue; }
            if( Check(&name,HW_B25) ) { DumpLiteral( "B25" ); continue; }
            if( Check(&name,HW_B26) ) { DumpLiteral( "B26" ); continue; }
            if( Check(&name,HW_B27) ) { DumpLiteral( "B27" ); continue; }
            if( Check(&name,HW_B28) ) { DumpLiteral( "B28" ); continue; }
            if( Check(&name,HW_B29) ) { DumpLiteral( "B29" ); continue; }
            if( Check(&name,HW_B30) ) { DumpLiteral( "B30" ); continue; }
            if( Check(&name,HW_B31) ) { DumpLiteral( "B31" ); continue; }
    
            if( Check(&name,HW_F0) ) { DumpLiteral( "F0" ); continue; }
            if( Check(&name,HW_F1) ) { DumpLiteral( "F1" ); continue; }
            if( Check(&name,HW_F2) ) { DumpLiteral( "F2" ); continue; }
            if( Check(&name,HW_F3) ) { DumpLiteral( "F3" ); continue; }
            if( Check(&name,HW_F4) ) { DumpLiteral( "F4" ); continue; }
            if( Check(&name,HW_F5) ) { DumpLiteral( "F5" ); continue; }
            if( Check(&name,HW_F6) ) { DumpLiteral( "F6" ); continue; }
            if( Check(&name,HW_F7) ) { DumpLiteral( "F7" ); continue; }
            if( Check(&name,HW_F8) ) { DumpLiteral( "F8" ); continue; }
            if( Check(&name,HW_F9) ) { DumpLiteral( "F9" ); continue; }
            if( Check(&name,HW_F10) ) { DumpLiteral( "F10" ); continue; }
            if( Check(&name,HW_F11) ) { DumpLiteral( "F11" ); continue; }
            if( Check(&name,HW_F12) ) { DumpLiteral( "F12" ); continue; }
            if( Check(&name,HW_F13) ) { DumpLiteral( "F13" ); continue; }
            if( Check(&name,HW_F14) ) { DumpLiteral( "F14" ); continue; }
            if( Check(&name,HW_F15) ) { DumpLiteral( "F15" ); continue; }
            if( Check(&name,HW_F16) ) { DumpLiteral( "F16" ); continue; }
            if( Check(&name,HW_F17) ) { DumpLiteral( "F17" ); continue; }
            if( Check(&name,HW_F18) ) { DumpLiteral( "F18" ); continue; }
            if( Check(&name,HW_F19) ) { DumpLiteral( "F19" ); continue; }
            if( Check(&name,HW_F20) ) { DumpLiteral( "F20" ); continue; }
            if( Check(&name,HW_F21) ) { DumpLiteral( "F21" ); continue; }
            if( Check(&name,HW_F22) ) { DumpLiteral( "F22" ); continue; }
            if( Check(&name,HW_F23) ) { DumpLiteral( "F23" ); continue; }
            if( Check(&name,HW_F24) ) { DumpLiteral( "F24" ); continue; }
            if( Check(&name,HW_F25) ) { DumpLiteral( "F25" ); continue; }
            if( Check(&name,HW_F26) ) { DumpLiteral( "F26" ); continue; }
            if( Check(&name,HW_F27) ) { DumpLiteral( "F27" ); continue; }
            if( Check(&name,HW_F28) ) { DumpLiteral( "F28" ); continue; }
            if( Check(&name,HW_F29) ) { DumpLiteral( "F29" ); continue; }
            if( Check(&name,HW_F30) ) { DumpLiteral( "F30" ); continue; }
            if( Check(&name,HW_F31) ) { DumpLiteral( "F31" ); continue; }
#endif
#if 0
#if _TARGET & _TARG_PPC
            if( Check(&name,HW_CTR) ) { DumpLiteral( "CTR" ); continue; }
            if( Check(&name,HW_CR) ) { DumpLiteral( "CR" ); continue; }
            if( Check(&name,HW_MQ) ) { DumpLiteral( "MQ" ); continue; }
            if( Check(&name,HW_LR) ) { DumpLiteral( "LR" ); continue; }
#endif
#endif
#if _TARGET & ( _TARG_80386 | _TARG_IAPX86 )
            if( Check(&name,HW_EAX)) { DumpLiteral("EAX"); continue; }
            if( Check(&name,HW_AX) ) { DumpLiteral( "AX"); continue; }
            if( Check(&name,HW_AL) ) { DumpLiteral( "AL"); continue; }
            if( Check(&name,HW_AH) ) { DumpLiteral( "AH"); continue; }
            if( Check(&name,HW_EBX)) { DumpLiteral("EBX"); continue; }
            if( Check(&name,HW_BX) ) { DumpLiteral( "BX"); continue; }
            if( Check(&name,HW_BL) ) { DumpLiteral( "BL"); continue; }
            if( Check(&name,HW_BH) ) { DumpLiteral( "BH"); continue; }
            if( Check(&name,HW_ECX)) { DumpLiteral("ECX"); continue; }
            if( Check(&name,HW_CX) ) { DumpLiteral( "CX"); continue; }
            if( Check(&name,HW_CL) ) { DumpLiteral( "CL"); continue; }
            if( Check(&name,HW_CH) ) { DumpLiteral( "CH"); continue; }
            if( Check(&name,HW_EDX)) { DumpLiteral("EDX"); continue; }
            if( Check(&name,HW_DX) ) { DumpLiteral( "DX"); continue; }
            if( Check(&name,HW_DL) ) { DumpLiteral( "DL"); continue; }
            if( Check(&name,HW_DH) ) { DumpLiteral( "DH"); continue; }
            if( Check(&name,HW_EDI)) { DumpLiteral("EDI"); continue; }
            if( Check(&name,HW_DI) ) { DumpLiteral( "DI"); continue; }
            if( Check(&name,HW_ESI)) { DumpLiteral("ESI"); continue; }
            if( Check(&name,HW_SI) ) { DumpLiteral( "SI"); continue; }
            if( Check(&name,HW_BP))  { DumpLiteral("EBP"); continue; }
            if( Check(&name,HW_SP))  { DumpLiteral("ESP"); continue; }
            if( Check(&name,HW_GS) ) { DumpLiteral( "GS"); continue; }
            if( Check(&name,HW_FS) ) { DumpLiteral( "FS"); continue; }
            if( Check(&name,HW_ES) ) { DumpLiteral( "ES"); continue; }
            if( Check(&name,HW_DS) ) { DumpLiteral( "DS"); continue; }
            if( Check(&name,HW_CS) ) { DumpLiteral( "CS"); continue; }
            if( Check(&name,HW_SS) ) { DumpLiteral( "SS"); continue; }
            if( Check(&name,HW_ST0) ) { DumpLiteral( "ST(0)"); continue; }
            if( Check(&name,HW_ST1) ) { DumpLiteral( "ST(1)"); continue; }
            if( Check(&name,HW_ST2) ) { DumpLiteral( "ST(2)"); continue; }
            if( Check(&name,HW_ST3) ) { DumpLiteral( "ST(3)"); continue; }
            if( Check(&name,HW_ST4) ) { DumpLiteral( "ST(4)"); continue; }
            if( Check(&name,HW_ST5) ) { DumpLiteral( "ST(5)"); continue; }
            if( Check(&name,HW_ST6) ) { DumpLiteral( "ST(6)"); continue; }
            if( Check(&name,HW_ST7) ) { DumpLiteral( "ST(7)"); continue; }
#endif
            break;
        }
    }
}
Beispiel #8
0
an      BGCall( cn call, bool use_return, bool in_line )
/******************************************************/
{
    instruction         *call_ins;
    call_state          *state;
    name                *ret_ptr = NULL;
    name                *result;
    name                *temp;
    name                *reg_name;
    instruction         *ret_ins = NULL;
    hw_reg_set          return_reg;
    hw_reg_set          zap_reg;

    if( call->name->tipe == TypeProcParm ) {
        SaveDisplay( OP_PUSH );
    }

    state = call->state;
    result = BGNewTemp( call->tipe );
    call_ins = call->ins;

/*   If we have a return value that won't fit in a register*/
/*   pass a pointer to result as the first parm*/

    if( call_ins->type_class == XX ) {
        if( _RoutineIsFar16( state->attr ) ) {
            if( state->attr & ROUTINE_ALLOCS_RETURN ) {
                HW_CAsgn( state->return_reg, HW_EAX );
            } else {
                HW_CAsgn( state->return_reg, HW_EBX );
            }
        }
        if( ( state->attr & ROUTINE_ALLOCS_RETURN ) == 0 ) {
            if( HW_CEqual( state->return_reg, HW_EMPTY ) ) {
                ret_ptr = AllocTemp( WD );
            } else {
                ret_ptr = AllocRegName( state->return_reg );
            }
            ret_ins = MakeUnary( OP_LA, result, ret_ptr, WD );
            HW_TurnOn( state->parm.used, state->return_reg );
            call_ins->flags.call_flags |= CALL_RETURNS_STRUCT;
        }
    }
    if( _IsTargetModel(FLOATING_DS) && (state->attr&ROUTINE_NEEDS_DS_LOADED) ) {
        HW_CTurnOn( state->parm.used, HW_DS );
    }
    if( _RoutineIsFar16( state->attr ) ) {
#if _TARGET & _TARG_80386
        Far16Parms( call );
#endif
    } else {
        if( AssgnParms( call, in_line ) ) {
            if( state->attr & ROUTINE_REMOVES_PARMS ) {
                call_ins->flags.call_flags |= CALL_POPS_PARMS;
            }
        }
    }

    if( state->attr & (ROUTINE_MODIFIES_NO_MEMORY | ROUTINE_NEVER_RETURNS) ) {
        /* a routine that never returns can not write any memory as far
            as this routine is concerned */
        call_ins->flags.call_flags |= CALL_WRITES_NO_MEMORY;
    }
    if( state->attr & ROUTINE_READS_NO_MEMORY ) {
        call_ins->flags.call_flags |= CALL_READS_NO_MEMORY;
    }
    if( state->attr & ROUTINE_NEVER_RETURNS ) {
        call_ins->flags.call_flags |= CALL_ABORTS;
    }
    if( _RoutineIsInterrupt( state->attr ) ) {
        call_ins->flags.call_flags |= CALL_INTERRUPT | CALL_POPS_PARMS;
    }
    if( !use_return ) {
        call_ins->flags.call_flags |= CALL_IGNORES_RETURN;
    }
    if( call_ins->type_class == XX ) {
        reg_name = AllocRegName( state->return_reg );
        if( state->attr & ROUTINE_ALLOCS_RETURN ) {
            call_ins->result = reg_name;
            AddCall( call_ins, call );
            if( use_return ) {
                temp = AllocTemp( WD ); /* assume near pointer*/
                AddIns( MakeMove( reg_name, temp, WD ) );
                temp = SAllocIndex( temp, NULL, 0,
                                    result->n.type_class, call->tipe->length );
                AddIns( MakeMove( temp, result, result->n.type_class ) );
            }
        } else {
            call_ins->result = result;
            AddIns( ret_ins );
            if( HW_CEqual( state->return_reg, HW_EMPTY ) ) {
                AddIns( MakeUnary( OP_PUSH, ret_ptr, NULL, WD ) );
                state->parm.offset += TypeClassSize[WD];
                call_ins->operands[CALL_OP_POPS] =
                        AllocS32Const( call_ins->operands[CALL_OP_POPS]->c.lo.int_value + TypeClassSize[WD] );
                if( state->attr & ROUTINE_REMOVES_PARMS ) {
                    call_ins->flags.call_flags |= CALL_POPS_PARMS;
                }
            }
            AddCall( call_ins, call );
        }
    } else {
        return_reg = state->return_reg;
        zap_reg = call_ins->zap->reg;
        HW_CTurnOn( zap_reg, HW_FLTS );
        HW_OnlyOn( return_reg, zap_reg );
        call_ins->result = AllocRegName( return_reg );
        reg_name = AllocRegName( state->return_reg );
        AddCall( call_ins, call );
        if( use_return ) {
            ret_ins = MakeMove( reg_name, result, result->n.type_class );
            if( HW_COvlap( reg_name->r.reg, HW_FLTS ) ) {
                ret_ins->stk_entry = 1;
                ret_ins->stk_exit = 0;
            }
            AddIns( ret_ins );
        }
    }
    if( state->parm.offset != 0 && ( state->attr & ROUTINE_REMOVES_PARMS ) == 0 ) {
        reg_name = AllocRegName( HW_SP );
        AddIns( MakeBinary( OP_ADD, reg_name,
                AllocS32Const( state->parm.offset ), reg_name, WD ) );
    }
    return( MakeTempAddr( result ) );
}
Beispiel #9
0
void FlowSave( hw_reg_set *preg )
/*******************************/
{
    int                 score;
    int                 i, j;
    int                 best;
    int                 num_blocks;
    int                 num_regs;
    int                 curr_reg;
    hw_reg_set          *curr_push;
    reg_flow_info       *reg_info;
    block               *save;
    block               *restore;
    instruction         *ins;
    type_class_def      reg_type;

    HW_CAsgn( flowedRegs, HW_EMPTY );
    if( _IsntModel( FLOW_REG_SAVES ) ) return;
    if( !HaveDominatorInfo ) return;
    // we can't do this if we have push's which are 'live' at the end of a block
    // - this flag is set when we see a push being generated for a call in a different
    //   block
#if _TARGET & _TARG_INTEL
    if( CurrProc->targ.never_sp_frame ) return;
#endif
    num_regs = CountRegs( *preg );
    if( num_regs == 0 ) return;
    reg_info = CGAlloc( num_regs * sizeof( reg_flow_info ) );
    num_blocks = CountBlocks();
    InitBlockArray();
    curr_push = PushRegs;
    for( curr_reg = 0; curr_reg < num_regs; curr_reg++ ) {
        while( !HW_Ovlap( *curr_push, *preg ) ) curr_push++;
        HW_Asgn( reg_info[curr_reg].reg, *curr_push );
        reg_info[curr_reg].save = NULL;
        reg_info[curr_reg].restore = NULL;
    #if _TARGET & _TARG_INTEL
        if( HW_COvlap( *curr_push, HW_BP ) ) continue;  // don't mess with BP - it's magical
    #endif
        GetRegUsage( &reg_info[curr_reg] );
        best = 0;
        for( i = 0; i < num_blocks; i++ ) {
            for( j = 0; j < num_blocks; j++ ) {
                if( PairOk( blockArray[i], blockArray[j], &reg_info[0], curr_reg ) ) {
                    // we use the number of blocks dominated by the save block plus
                    // the number of blocks post-dominated by the restore block as a
                    // rough metric for determining how much we like a given (valid)
                    // pair of blocks - the more blocks dominated, the further 'in'
                    // we have pushed the save, which should be good
                    score =  CountDomBits( &blockArray[i]->dom.dominator );
                    score += CountDomBits( &blockArray[j]->dom.post_dominator );
                    if( score > best ) {
                        best = score;
                        reg_info[curr_reg].save    = blockArray[i];
                        reg_info[curr_reg].restore = blockArray[j];
                    }
                }
            }
        }
        // so now we know where we are going to save and restore the register
        // emit the instructions to do so, and remove reg from the set to push
        // in the normal prolog sequence
        save = reg_info[curr_reg].save;
        restore = reg_info[curr_reg].restore;
        if( ( save != NULL && save != HeadBlock ) && ( restore != NULL && !_IsBlkAttr( restore, BLK_RETURN ) ) ) {
            reg_type = WD;
        #if _TARGET & _TARG_INTEL
            if( IsSegReg( reg_info[curr_reg].reg ) ) {
                reg_type = U2;
            }
        #endif
            ins = MakeUnary( OP_PUSH, AllocRegName( reg_info[curr_reg].reg ), NULL, reg_type );
            ResetGenEntry( ins );
            PrefixIns( save->ins.hd.next, ins );
            ins = MakeUnary( OP_POP, NULL, AllocRegName( reg_info[curr_reg].reg ), reg_type );
            ins->num_operands = 0;
            ResetGenEntry( ins );
            SuffixIns( restore->ins.hd.prev, ins );
            HW_TurnOff( *preg, reg_info[curr_reg].reg );
            HW_TurnOn( flowedRegs, reg_info[curr_reg].reg );
            FixStackDepth( save, restore );
        }
        curr_push++;
    }
    CGFree( reg_info );
}
Beispiel #10
0
hw_reg_set      ParmRegConflicts( hw_reg_set regs )
/*************************************************/
{
    hw_reg_set          conflicts;

    conflicts = regs;
    if( HW_COvlap( regs, HW_R16 ) ) {
        HW_CTurnOn( conflicts, HW_F16 );
        HW_CTurnOn( conflicts, HW_R16 );
    }
    if( HW_COvlap( regs, HW_R17 ) ) {
        HW_CTurnOn( conflicts, HW_F17 );
        HW_CTurnOn( conflicts, HW_R17 );
    }
    if( HW_COvlap( regs, HW_R18 ) ) {
        HW_CTurnOn( conflicts, HW_F18 );
        HW_CTurnOn( conflicts, HW_R18 );
    }
    if( HW_COvlap( regs, HW_R19 ) ) {
        HW_CTurnOn( conflicts, HW_F19 );
        HW_CTurnOn( conflicts, HW_R19 );
    }
    if( HW_COvlap( regs, HW_R20 ) ) {
        HW_CTurnOn( conflicts, HW_F20 );
        HW_CTurnOn( conflicts, HW_R20 );
    }
    if( HW_COvlap( regs, HW_R21 ) ) {
        HW_CTurnOn( conflicts, HW_F21 );
        HW_CTurnOn( conflicts, HW_R21 );
    }
    if( HW_COvlap( regs, HW_F16 ) ) {
        HW_CTurnOn( conflicts, HW_R16 );
        HW_CTurnOn( conflicts, HW_F16 );
    }
    if( HW_COvlap( regs, HW_F17 ) ) {
        HW_CTurnOn( conflicts, HW_R17 );
        HW_CTurnOn( conflicts, HW_F17 );
    }
    if( HW_COvlap( regs, HW_F18 ) ) {
        HW_CTurnOn( conflicts, HW_R18 );
        HW_CTurnOn( conflicts, HW_F18 );
    }
    if( HW_COvlap( regs, HW_F19 ) ) {
        HW_CTurnOn( conflicts, HW_R19 );
        HW_CTurnOn( conflicts, HW_F19 );
    }
    if( HW_COvlap( regs, HW_F20 ) ) {
        HW_CTurnOn( conflicts, HW_R20 );
        HW_CTurnOn( conflicts, HW_F20 );
    }
    if( HW_COvlap( regs, HW_F21 ) ) {
        HW_CTurnOn( conflicts, HW_R21 );
        HW_CTurnOn( conflicts, HW_F21 );
    }
    return( conflicts );
}
Beispiel #11
0
extern  void    DumpOperand( name *operand ) {
/********************************************/

    char        buffer[20];
    hw_reg_set  reg;
    name        *base;

    if( operand->n.class == N_INDEXED ) {
        if( operand->i.base != NULL ) {
            if( !( operand->i.index_flags & X_FAKE_BASE ) ) {
                if( operand->i.index_flags & X_LOW_ADDR_BASE ) {
                    DumpLiteral( "l^" );
                }
                DumpOperand( operand->i.base );
                if( operand->i.constant > 0 ) {
                    DumpChar( '+' );
                }
            }
        }
        if( operand->i.constant != 0 ) {
            DumpLong( operand->i.constant );
        }
        DumpChar( '[' );
        if( operand->i.index_flags & X_BASE ) {
            reg = operand->i.index->r.reg;
#if _TARGET & ( _TARG_IAPX86 | _TARG_80386 )
            if( HW_COvlap( reg, HW_SEGS ) ) {

                hw_reg_set tmp;

                tmp = reg;
                HW_COnlyOn( tmp, HW_SEGS );
                DumpRegName( tmp );
                DumpChar( ':' );
                HW_CTurnOff( reg, HW_SEGS );
            }
#endif
            if( operand->i.index_flags & X_HIGH_BASE ) {
                DumpRegName( HighReg( reg ) );
                DumpChar( '+' );
                DumpRegName( LowReg( reg ) );
            } else {
                DumpRegName( LowReg( reg ) );
                DumpChar( '+' );
                DumpRegName( HighReg( reg ) );
            }
        } else {
            DumpOperand( operand->i.index );
        }
        if( operand->i.scale != 0 ) {
            DumpChar( '*' );
            DumpInt( 1 << operand->i.scale );
        }
        if( operand->i.index_flags & ( X_ALIGNED_1 | X_ALIGNED_2 | X_ALIGNED_4 | X_ALIGNED_8 ) ) {
            DumpChar( '$' );
            DumpInt( FlagsToAlignment( operand->i.index_flags ) );
        }
        DumpChar( ']' );
        base = operand->i.base;
        if( base != NULL ) {
            if( operand->i.index_flags & X_FAKE_BASE ) {
                DumpChar( '{' );
                if( base->n.class == N_MEMORY ) {
                    DumpXString( AskName(base->v.symbol, base->m.memory_type) );
                } else if( base->n.class == N_TEMP ) {
                    if( _FrontEndTmp( base ) ) {
                        DumpXString( FEName( base->v.symbol ) );
                    } else {
                        DumpOperand( base );
                    }
                }
                DumpChar( '}' );
            }
        }