static an Unary( cg_op op, an left, type_def *tipe ) /***************************************************/ { instruction *ins; an res; ins = MakeNary( (opcode_defs)op, GenIns( left ), NULL, NULL, TypeClass( tipe ), TypeClass( left->tipe ), 1 ); res = InsName( ins, tipe ); AddIns( ins ); BGDone( left ); return( res ); }
extern an PassProcParm( an rtn ) { /**************************************/ name *op; name *reg; op = AllocTemp( XX ); op->n.size = TypePtr->length + SizeDisplayReg(); reg = AllocRegName( DisplayReg() ); AddIns( MakeMove( GenIns( rtn ), TempOffset( op, 0, ClassPointer ), ClassPointer ) ); AddIns( MakeMove( reg, TempOffset( op, TypePtr->length, reg->n.name_class ), reg->n.name_class ) ); return( AddrName( op, TypeProcParm ) ); }
extern void BGParmInline( cg_sym_handle sym, type_def *tipe ) { /**************************************************************/ name *temp; name *parm_value; inline_parm *parm; parm = InlineStack->parms; InlineStack->parms = InlineStack->parms->next; // if( NotEquiv( parm->addr->tipe, tipe ) ) { // _Zoiks( ZOIKS_070 ); // } temp = SAllocUserTemp( sym, TypeClass( tipe ), tipe->length ); temp->v.usage |= USE_IN_ANOTHER_BLOCK; parm_value = GenIns( parm->addr ); BGDone( parm->addr ); AddIns( MakeMove( parm_value, temp, temp->n.name_class ) ); CGFree( parm ); }
static void AddCall( instruction *ins, cn call ) { /****************************************************/ name *proc_name; if( _IsTargetModel(FLOATING_DS) && (call->state->attr&ROUTINE_NEEDS_DS_LOADED) ) { AddIns( MakeMove( NearSegment(), AllocRegName( HW_DS ), U2 ) ); } if( call->name->tipe == TypeProcParm ) { proc_name = AllocTemp( ClassPointer ); /* what to do? proc_name->usage |= USE_REGISTER;*/ AddIns( MakeMove( ins->operands[CALL_OP_ADDR], proc_name, ClassPointer )); ins->operands[CALL_OP_ADDR] = proc_name; SetDisplay( GenIns( call->name ) ); AddIns( ins ); SaveDisplay( OP_POP ); } else { AddCallIns( ins, call ); } }
if( SelCompare( list->high, hi ) > 0 ) { break; } cases += list->high - list->low + 1; } return( cases ); } static void ScanBlock( tbl_control *table, an node, type_class_def class, label_handle other ) /************************************************************************************************/ { uint i; uint targets; name *value; value = GenIns( node ); MkSelOp( ScanCall( table, value, class ), class ); i = 0; targets = 0; for( ;; ) { if( table->cases[ i ] != other ) { ++targets; } if( ++i == table->size ) break; } if( other != NULL ) { ++targets; } GenBlock( SELECT, targets ); i = 0; for( ;; ) {
name = FlowOut( name, tipe ); } } return( name ); } an BGCompare( cg_op op, an left, an rite, label_handle entry, type_def *tipe ) /*********************************************************************************/ { an new; instruction *ins; name *newleft; name *newrite; LastCmpType = tipe; newleft = GenIns( left ); newrite = GenIns( rite ); BGDone( left ); BGDone( rite ); NamesCrossBlocks(); ins = MakeCondition( (opcode_defs)op, newleft, newrite, 0, 1, TypeClass( tipe ) ); AddIns( ins ); GenBlock( BLK_CONDITIONAL, 2 ); AddTarget( NULL, false ); AddTarget( NULL, false ); new = NewBoolNode(); new->u.b.e = entry; new->u.b.t = &CurrBlock->edge[0].destination.u.lbl; new->u.b.f = &CurrBlock->edge[1].destination.u.lbl; EnLink( AskForNewLabel(), true ); return( new );
static void Far16Parms( cn call ) { /*************************************/ instruction *ins; type_length parm_size; pn parm, next; instruction *call_ins; name *eax; name *ecx; name *esi; label_handle lbl; type_length offset; name *parmlist; call_state *state; rt_class rtindex; call_ins = call->ins; parm_size = 0; state = call->state; for( parm = call->parms; parm != NULL; parm = parm->next ) { parm_size += _RoundUp( parm->name->tipe->length, 2 ); } parmlist = SAllocTemp( XX, parm_size ); parmlist->v.usage |= NEEDS_MEMORY | USE_IN_ANOTHER_BLOCK | USE_ADDRESS; offset = 0; for( parm = call->parms; parm != NULL; parm = parm->next ) { parm->name->u.i.ins->result = STempOffset( parmlist, offset, TypeClass( parm->name->tipe ), parm->name->tipe->length ); offset += _RoundUp( parm->name->tipe->length, 2 ); } for( parm = call->parms; parm != NULL; parm = next ) { next = parm->next; parm->name->format = NF_ADDR; /* so instruction doesn't get freed! */ BGDone( parm->name ); CGFree( parm ); } eax = AllocRegName( HW_EAX ); ecx = AllocRegName( HW_ECX ); esi = AllocRegName( HW_ESI ); HW_TurnOn( state->parm.used, eax->r.reg ); HW_TurnOn( state->parm.used, ecx->r.reg ); HW_TurnOn( state->parm.used, esi->r.reg ); ins = MakeMove( AllocS32Const( parm_size ), ecx, WD ); AddIns( ins ); ins = MakeUnary( OP_LA, parmlist, esi, WD ); AddIns( ins ); if( ins->head.opcode == OP_CALL ) { ins = MakeUnary( OP_LA, call->name->u.n.name, eax, WD ); } else { ins = MakeMove( GenIns( call->name ), eax, WD ); call_ins->head.opcode = OP_CALL; } call_ins->num_operands = 2; AddIns( ins ); if( call_ins->type_class == XX ) { if( state->attr & ROUTINE_ALLOCS_RETURN ) { rtindex = RT_Far16Cdecl; } else { rtindex = RT_Far16Pascal; } } else { rtindex = RT_Far16Func; } lbl = RTLabel( rtindex ); call->name->u.n.name = AllocMemory( lbl, 0, CG_LBL, WD ); call_ins->flags.call_flags |= CALL_FAR16 | CALL_POPS_PARMS; call_ins->operands[CALL_OP_USED] = AllocRegName( state->parm.used ); call_ins->operands[CALL_OP_POPS] = AllocS32Const( 0 ); call_ins->zap = &call_ins->operands[CALL_OP_USED]->r; }