Пример #1
0
void CgFrontGotoNear(           // EMIT GOTO IN NEAR SPACE (CS,GOTO)
    int opcode,                 // - opcode to determine type of label ref.
    unsigned condition,         // - condition for goto
    CGLABEL label )             // - label number
{
    label_reference( label, opcode );
    CgFrontCodeUint( IC_GOTO_NEAR, condition );
    dump_label( printf( "GotoNear -- %d\n", label ) );
}
Пример #2
0
void CgFrontSwitchCase(         // CASE STATEMENT IN SWITCH STATEMENT
    SCOPE scope_sw,             // - scope for switch jump
    boolean deadcode,           // - dead-code state
    TOKEN_LOCN *posn,           // - source-file position
    uint_32 value )             // - switch value
{
    CGFILE_GEN *gen;            // - generation data

    gen = getGenData();
    emitSourcePosn( gen, posn );
    CgFrontCodeUint( IC_SWITCH_CASE, value );
    LabelSwitchLabel( scope_sw, deadcode );
    cgfront_debug( "case" );
}
Пример #3
0
unsigned StaticInitFuncBeg(     // START INITIALIZATION OF STATIC IN FUNCTION
    void )
{
    CGLABEL init_label;         // - label #
    INIT_VAR *init_var;

    CgFrontStatInit();
    init_var = FunctionBodyGetInit( NULL );
    if( init_var->var == NULL ) {
        init_var->var = staticInitFuncVar();
    } else {
        init_var->mask <<= 1;
        if( init_var->mask >= 0x100 ) {
            ++init_var->var->sym_type->u.a.array_size;
            init_var->mask = 1;
        }
    }
    if( CompFlags.bm_switch_used ) {
        SYMBOL rtf;
        rtf = RunTimeCallSymbol( RTF_STATIC_INIT );
        CgFrontSymbol( rtf );
        CgSetType( GetBasicType( TYP_SINT ) );
        CgFrontCodePtr( IC_CALL_SETUP, rtf );
        CgSetType( GetBasicType( TYP_SINT ) );
        CgFrontCodeUint( IC_LEAF_CONST_INT, init_var->mask );
        CgFrontCode( IC_CALL_PARM );
        moduleInitVar( init_var->var, false );
        CgFrontCode( IC_CALL_PARM );
        CgFrontCode( IC_CALL_EXEC );
    } else {
        moduleInitVar( init_var->var, true );
        CgFrontCodeUint( IC_OPR_UNARY, CO_FETCH );
        CgFrontCodeUint( IC_LEAF_CONST_INT, init_var->mask );
        CgFrontCodeUint( IC_OPR_BINARY, CO_AND );
    }
    CgFrontCodeUint( IC_LEAF_CONST_INT, 0 );
    CgFrontCodeUint( IC_OPR_BINARY, CO_NE );
    init_label = CgFrontLabelCs();
    CgFrontGotoNear( IC_LABEL_CS, O_IF_TRUE, init_label );
    if( !CompFlags.bm_switch_used ) {
        moduleInitVar( init_var->var, true );
        CgFrontCodeUint( IC_LEAF_CONST_INT, init_var->mask );
        CgFrontCodeUint( IC_OPR_BINARY, CO_OR_EQUAL );
        CgFrontCode( IC_EXPR_DONE );
    }
    return( init_label );
}
Пример #4
0
static void moduleInitVar(      // GENERATE REFERENCE TO MODULE-INIT VAR.
    SYMBOL var,                 // - variable
    bool base_type )            // - base_type or pointer to it
{
    unsigned offset;            // - offset to be tested
    TYPE type;                  // - type for flags variable

    type = var->sym_type;
    offset = type->u.a.array_size - 1;
    if( offset != 0 ) {
        CgSetType( GetBasicType( TYP_UINT ) );
        CgFrontCodeUint( IC_LEAF_CONST_INT, offset );
        CgFrontSymbol( var );
        CgSetType( MakePointerTo( type->of ) );
        CgFrontCodeUint( IC_OPR_BINARY, CO_PLUS );
    } else {
        CgFrontSymbol( var );
    }
    if( base_type ) {
        CgSetType( type->of );
    } else {
        CgSetType( MakePointerTo( type->of ) );
    }
}
Пример #5
0
CGFILE_INS CgFrontFuncOpen(     // OPEN A FUNCTION (AND ITS FILE)
    SYMBOL func,                // - symbol for function
    TOKEN_LOCN *posn )          // - source position
{
    CGFILE_GEN *gen;            // - generation data
    DT_METHOD dtm;              // - destruction method for function
    CGFILE_INS reg;             // - position to zap for function registration

    codeCGFILE = CgioCreateFile( func );
    if( posn != NULL ) {
        codeCGFILE->defined = *posn;
    }
    gen = getGenData();
    if( posn != NULL ) {
        emitSourcePosn( gen, posn );
    }
    CgFrontCodePtr( IC_FUNCTION_OPEN, func );
    CgFrontCodePtr( IC_FUNCTION_ARGS, GetCurrScope() );
    dtm = CompInfo.dt_method_speced;
    if( ! SymIsDtor( func ) ) {
        switch( dtm ) {
          case DTM_DIRECT_SMALL :
            dtm = DTM_DIRECT;
            break;
          case DTM_TABLE_SMALL :
            dtm = DTM_TABLE;
            break;
        }
    }
    CompInfo.dt_method = dtm;
    CgFrontCodeUint( IC_FUNCTION_DTM, dtm );
    CgFrontCode( IC_NO_OP );    // - may be zapped to IC_FUNCTION_STAB
    reg = CgioLastWrite( codeCGFILE );
    gen->emit_line_no.src_file = NULL;
    if( posn != NULL ) {
        emitSourcePosn( gen, posn );
    }
    return reg;
}