void FreeIns( instruction *ins ) { /******************************************** Free an instruction "ins" */ instruction *next; #if 0 /* Debugging code for integrity of conflict edges */ conflict_node *conf; for (conf = ConfList; conf != NULL; conf = conf->next_conflict) { if (conf->ins_range.first == ins || conf->ins_range.last == ins) { Zoiks(ZOIKS_050); } } #endif next = ins->head.next; if( next->head.opcode != OP_BLOCK && next->head.line_num == 0 ) { next->head.line_num = ins->head.line_num; } ins->head.prev->head.next = next; next->head.prev = ins->head.prev; FrlFreeSize( &InsFrl, (pointer *)ins, INS_SIZE ); }
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 ); } }
static void BuildPossible( reg_tree *tree ) /*********************************************/ { hw_reg_set *src; hw_reg_set *dst; if( tree != NULL ) { BuildPossible( tree->lo ); BuildPossible( tree->hi ); if( tree->idx != RL_NUMBER_OF_SETS ) { tree->regs = AllocRegSet(); dst = tree->regs; for( src = RegSets[tree->idx]; !HW_CEqual( *src, HW_EMPTY ); ++src ) { *dst++ = *src; } *dst = *src; #ifndef NDEBUG if ( dst - tree->regs >= REG_COUNT ) { /* '>=' 'coz no increment before 'break' */ Zoiks( ZOIKS_143 ); } #endif } } }
extern void DFObjLineInitDbgInfo( void ) { /*****************************************************/ /* called by objinit to init segments and dwarf writing library */ static const dw_funcs cli_funcs = { CLIReloc, CLIWrite, CLISeek, CLITell, CLIAlloc, CLIFree }; dw_init_info info; dw_cu_info cu; type_def *tipe_addr; info.language = DWLANG_C; info.compiler_options = DW_CM_DEBUGGER; info.abbrev_sym = 0; info.producer_name = SetDwarfProducer(); info.language = SetLang(); if( setjmp( info.exception_handler ) == 0 ) { info.funcs = cli_funcs; InitLineSegBck(); // start each seg with a ref label Client = DWInit( &info ); if( Client == NULL ) { Zoiks( ZOIKS_107 ); /* Bad */ } cu.source_filename = FEAuxInfo( NULL, SOURCE_NAME ); cu.directory = ""; cu.dbg_pch = NULL; cu.inc_list = NULL; cu.inc_list_len = 0; #if _TARGET & ( _TARG_IAPX86 | _TARG_80386 ) if( _IsTargetModel( FLAT_MODEL ) ) { cu.flags = true; cu.segment_size = 0; }else{ cu.flags = false; cu.segment_size = 2; } #else cu.flags = true; cu.segment_size = 0; #endif tipe_addr = TypeAddress( TY_NEAR_POINTER ); cu.offset_size = tipe_addr->length; switch( GetMemModel() ){ case 'h': cu.model = DW_MODEL_HUGE; break; case 'l': cu.model = DW_MODEL_LARGE; break; case 'f': cu.model = DW_MODEL_FLAT; break; case 's': cu.model = DW_MODEL_SMALL; break; default: cu.model = DW_MODEL_NONE; break; } DWInitDebugLine( Client, &cu ); } else { Zoiks( ZOIKS_107 ); /* Big Error */ } }
extern void DFObjInitDbgInfo( void ) { /*****************************************************/ /* called by objinit to init segments and dwarf writing library */ static const dw_funcs cli_funcs = { CLIReloc, CLIWrite, CLISeek, CLITell, CLIAlloc, CLIFree }; dw_init_info info; cg_sym_handle abbrev_sym; cg_sym_handle debug_pch; fe_attr attr; if( _IsntModel( DBG_LOCALS | DBG_TYPES ) ){ return; } info.compiler_options = DW_CM_DEBUGGER; info.abbrev_sym = 0; info.producer_name = SetDwarfProducer(); info.language = SetLang(); if( setjmp( info.exception_handler ) == 0 ) { info.funcs = cli_funcs; InitSegBck(); // start each seg with a ref label if( _IsModel( DBG_PREDEF ) ) { abbrev_sym = FEAuxInfo( NULL, DBG_PREDEF_SYM ); info.abbrev_sym = (dw_sym_handle)abbrev_sym; attr = FEAttr( abbrev_sym ); if( (attr & FE_IMPORT) ) { info.compiler_options |= DW_CM_ABBREV_PRE; }else{ back_handle bck; segment_id old; info.compiler_options |= DW_CM_ABBREV_GEN; bck = FEBack( abbrev_sym ); // dump out export label bck->seg = DwarfSegs[DW_DEBUG_ABBREV].seg; old = SetOP( DwarfSegs[DW_DEBUG_ABBREV].seg ); DataLabel( bck->lbl ); SetOP( old ); } } debug_pch = FEAuxInfo( NULL, DBG_PCH_SYM ); if( debug_pch != NULL ){ attr = FEAttr( debug_pch ); if( !(attr & FE_IMPORT) ) { back_handle bck; segment_id old; bck = FEBack( debug_pch ); bck->seg = DwarfSegs[DW_DEBUG_INFO].seg; old = SetOP( DwarfSegs[DW_DEBUG_INFO].seg ); DataLabel( bck->lbl ); SetOP( old ); debug_pch = NULL; } } Client = DWInit( &info ); if( Client == NULL ) { Zoiks( ZOIKS_107 ); /* Bad */ } DFBegCCU( AskCodeSeg(), (dw_sym_handle)debug_pch ); } else { Zoiks( ZOIKS_107 ); /* Big Error */ } }
static void CLIReloc( dw_sectnum sect, dw_relocs reloc_type, ... ){ /******************************************************/ static uint_32 const zero = 0; sect_info *curr; dw_sym_handle sym; dw_sym_handle bck; loc_range *low; loc_range *high; dw_sectnum section; va_list args; segment_id old; // long_offset off; va_start( args, reloc_type ); curr = &DwarfSegs[sect]; old = SetOP( curr->seg ); // off = AskBigLocation(); switch( reloc_type ) { case DW_W_LOW_PC: if( Pc_Low != NULL ){ DoLblReloc( Pc_Low, 0 ); }else{ Zoiks( ZOIKS_107 ); /* No Low PC */ } break; case DW_W_HIGH_PC: if( Pc_High != NULL ){ DoLblReloc( Pc_High, 0 ); }else{ Zoiks( ZOIKS_107 ); /* No High PC */ } break; case DW_W_STATIC: sym = va_arg( args, dw_sym_handle ); DoReloc( sym, 0 ); break; case DW_W_LABEL: bck = va_arg( args, dw_sym_handle ); DoLblReloc( (back_handle)bck, 0 ); break; case DW_W_SEGMENT: sym = va_arg( args, dw_sym_handle ); DoSegReloc( sym ); break; case DW_W_LABEL_SEG: bck = va_arg( args, dw_sym_handle ); DoSegLblReloc( (back_handle)bck ); break; case DW_W_LOC_RANGE: low = va_arg( args, loc_range* ); high = va_arg( args, loc_range* ); DoLblReloc( low->bck, low->disp ); DoLblReloc( high->bck, high->disp ); break; case DW_W_DEFAULT_FUNCTION: break; case DW_W_ARANGE_ADDR: DoLblReloc( ARange, 0 ); #if _TARGET & ( _TARG_IAPX86 | _TARG_80386 ) if( _IsntTargetModel( FLAT_MODEL ) ) { DoSegLblReloc( ARange ); } #endif break; case DW_W_UNIT_SIZE: UnitSize->segment = curr->seg; UnitSize->offset = AskBigLocation(); DataBytes( sizeof( zero ), &zero ); break; case DW_W_SECTION_POS: section = va_arg( args, uint ); DoSectOffset( section ); break; case DW_W_EXT_REF: { long_offset disp; sym = va_arg( args, dw_sym_handle ); disp = va_arg( args, dw_addr_offset ); DoReloc( sym, disp ); // DFFEPtrRef( (cg_sym_handle)sym, disp ); break; } default: abort(); break; } SetOP( old ); }