TempleOSTS_130707.ISO

This commit is contained in:
Terry A. Davis authored and minexew committed 2018-09-08 21:45:45 +02:00
1 parent 17b71f1a2d
commit 1343005a29
617 files changed
+14399 -25130

No files matched your search

+73 -106
View File
@@ -1,8 +1,7 @@
I64 CmpType(CHashClass *tempc)
{
if (tempc) {
while (tempc->fwd_class)
tempc=tempc->fwd_class;
tempc=OptClassFwd(tempc);
return tempc->sub_type;
}
return 0;
@@ -13,8 +12,7 @@ I64 CmpPType(CHashClass *tempc)
if (tempc) {
if (tempc->ptr_cnt)
tempc--;
while (tempc->fwd_class)
tempc=tempc->fwd_class;
tempc=OptClassFwd(tempc);
return tempc->sub_type;
}
return 0;
@@ -28,7 +26,7 @@ U0 CmpF1PushPop(CIntermediateCode *tempi,CIntermediateCode *tempi2)
U0 CmpF2PushPop(CIntermediateCode *tempi,CIntermediateCode *tempi1,CIntermediateCode *tempi2)
{
if ((tempi2->ic_opcode==IC_MOV || tempi2->ic_opcode==IC_F64) &&
if ((tempi2->ic_opcode==IC_MOV || tempi2->ic_opcode==IC_IMM_F64) &&
!(tempi2->ic_flags&ICF_R_TO_F64) &&
(Bt(fpop_bitmap,tempi1->ic_opcode) || tempi1->ic_flags&ICF_R_TO_F64))
Bts(&tempi->ic_flags,ICf_DONT_PUSH_FLOAT0);
@@ -50,11 +48,11 @@ I64 OptMVCompare(OptMemberVar *mv1,OptMemberVar *mv2)
U0 OptPass3(CLex *lx,CHashFun *fun_class,COptReg *register_offsets)
{
CHashClass *tempc,*tempc1,*tempc2,*tempc3;
CHashClass *tempc,*tempc1,*tempc2;
CCodeBlkMisc *lb;
CIntermediateCode *tempi,*tempi1,*tempi2,*tempi3,
*tempil1,*tempil2,
*temp_lag[4];
CIntermediateCode *tempi,*tempi1,*tempi2,
*tempil1,*tempil2,
*temp_lag[4];
I64 code,i,j,l,member_cnt,used_reg_mask=0;
CMemberLst *tempm;
CPrsStk *ps=OptStart(lx,temp_lag);
@@ -71,17 +69,15 @@ U0 OptPass3(CLex *lx,CHashFun *fun_class,COptReg *register_offsets)
member_cnt=0;
tempm=fun_class->member_lst;
while (tempm) {
tempc=tempm->member_class;
while (tempc->fwd_class)
tempc=tempc->fwd_class;
tempc=OptClassFwd(tempm->member_class);
if (0<=tempm->register<NUM_REGS) {
if (Bts(&used_reg_mask,tempm->register))
PrintFWarn("%S\n $$LK-A,\"FL:%s,%d\"$$ '%s' in '%s'\n","ST_REG_IN_USE",
lx->cur_lfn->name,lx->cur_lfn->line_num,tempm->str,fun_class->str);
lx->cur_lfn->name,lx->cur_lfn->line_num,tempm->str,fun_class->str);
register_offsets[tempm->register].offset=tempm->offset;
register_offsets[tempm->register].m=tempm;
} else if (tempc->sub_type!=IT_F64 && tempm->register!=CREG_NONE ||
tempm->register==CREG_ALLOC) {
tempm->register==CREG_ALLOC) {
if (tempm->register==CREG_ALLOC)
mv[member_cnt].score=MAX_I64/2; //big but not too big
mv[member_cnt].offset=tempm->offset;
@@ -89,7 +85,7 @@ U0 OptPass3(CLex *lx,CHashFun *fun_class,COptReg *register_offsets)
} else {
if (tempm->register==CREG_ALLOC)
PrintFWarn("%S\n $$LK-A,\"FL:%s,%d\"$$ '%s' in '%s'\n","ST_CANT_REG_VAR",
lx->cur_lfn->name,lx->cur_lfn->line_num,tempm->str,fun_class->str);
lx->cur_lfn->name,lx->cur_lfn->line_num,tempm->str,fun_class->str);
}
tempm=tempm->next;
}
@@ -100,7 +96,7 @@ U0 OptPass3(CLex *lx,CHashFun *fun_class,COptReg *register_offsets)
if (tempi->ic_opcode==IC_START)
tempi++;
while (code=tempi->ic_opcode) {
if (code!=IC_NOP) {
if (code!=IC_NOP1) {
OptNext(tempi,temp_lag);
tempil1=temp_lag[1];
tempil2=temp_lag[2];
@@ -109,17 +105,6 @@ U0 OptPass3(CLex *lx,CHashFun *fun_class,COptReg *register_offsets)
case 9:
ps->ptr-=tempi->ic_data>>3;
break;
case 3:
tempi3=PrsPop(ps);
if (tempi3->ic_flags&ICF_R_TO_F64)
tempc3=sys_internal_types[IT_F64];
else if (tempi3->ic_flags & ICF_R_TO_INT)
tempc3=sys_internal_types[IT_I64];
else
tempc3=tempi->t.p3c;
tempi->p3.type=TY_STK+CmpType(tempc3);
tempi->p3.ptype=CmpPType(tempc3);
tempi->ic_flags|=ICF_P3_WAS_STK;
case 2:
tempi2=PrsPop(ps);
if (tempi2->ic_flags&ICF_R_TO_F64)
@@ -153,20 +138,20 @@ U0 OptPass3(CLex *lx,CHashFun *fun_class,COptReg *register_offsets)
PrsPush(ps,tempi);
}
nobound_switch (code) {
case IC_F64:
case IC_IMM_F64:
tempi->ic_flags&=~ICF_R_TO_F64;
if (tempi->ic_flags&ICF_R_TO_INT) {
tempi->ic_data=ToI64(tempi->ic_data(F64));
tempi->ic_flags&=~ICF_R_TO_INT;
tempi->ic_opcode=IC_IMM;
tempi->ic_opcode=IC_IMM_U64;
}
break;
case IC_IMM:
case IC_IMM_U64:
tempi->ic_flags&=~ICF_R_TO_INT;
if (tempi->ic_flags&ICF_R_TO_F64) {
tempi->ic_data(F64)=ToF64(tempi->ic_data);
tempi->ic_flags&=~ICF_R_TO_F64;
tempi->ic_opcode=IC_F64;
tempi->ic_opcode=IC_IMM_F64;
}
break;
case IC_STR_CONST:
@@ -183,7 +168,7 @@ U0 OptPass3(CLex *lx,CHashFun *fun_class,COptReg *register_offsets)
break;
case IC_REG:
case IC_COM:
case IC_NATIVE_TYPECAST:
case IC_HOLYC_TYPECAST:
case IC_NOT:
case IC_UNARY_MINUS:
break;
@@ -191,29 +176,29 @@ U0 OptPass3(CLex *lx,CHashFun *fun_class,COptReg *register_offsets)
tempi->p1.ptype=tempi->r.type&IT_MASK;
if (tempi1->ic_opcode==IC_LEA) {
tempi->ic_flags|=tempi1->ic_flags;
tempi1->ic_opcode=IC_NOP;
tempi->p1.reg=tempi1->p1.reg;
tempi->p1.disp=tempi1->p1.disp;
tempi->p1.type=TY_DISP+tempi->r.type&IT_MASK;
tempi->p1.ptype=tempi->r.ptype;
tempi->ic_opcode=IC_MOV;
OptSetNOP1(tempi1);
if (tempi->p1.reg==CREG_RBP)
for (i=0;i<member_cnt;i++)
if (mv[i].offset==tempi->p1.disp) {
mv[i].lea_balance--;
mv[i].score+=1+tempi->ic_indent_level;
mv[i].score++;
break;
}
} else if (tempil1->ic_opcode==IC_ADD_CONST) {
} else if (tempil1->ic_opcode==IC_ADD_CONST) {
if (tempil2->ic_opcode==IC_REG) {
tempi->ic_flags|=tempil2->ic_flags|tempil1->ic_flags;
tempil2->ic_opcode=IC_NOP;
tempil1->ic_opcode=IC_NOP;
tempi->p1.reg=tempil2->p1.reg;
tempi->p1.disp=tempi->ic_data;
tempi->p1.type=TY_DISP+tempi->r.type&IT_MASK;
tempi->p1.ptype=tempi->r.ptype;
tempi->ic_opcode=IC_MOV;
OptSetNOP1(tempil2);
OptSetNOP1(tempil1);
}
}
break;
@@ -225,12 +210,12 @@ U0 OptPass3(CLex *lx,CHashFun *fun_class,COptReg *register_offsets)
case IC_DEREF_PP:
case IC_DEREF_MM:
if (tempi1->ic_opcode==IC_LEA &&
tempi1->p1.type&TY_MASK==TY_DISP &&
tempi1->p1.reg==CREG_RBP)
tempi1->p1.type&TY_MASK==TY_DISP &&
tempi1->p1.reg==CREG_RBP)
for (i=0;i<member_cnt;i++)
if (mv[i].offset==tempi1->p1.disp) {
mv[i].lea_balance--;
mv[i].score+=1+tempi->ic_indent_level;
mv[i].score++;
break;
}
tempi->p1.ptype=tempi->r.type&IT_MASK;
@@ -258,17 +243,16 @@ U0 OptPass3(CLex *lx,CHashFun *fun_class,COptReg *register_offsets)
}
if (OptFixupBinaryOp2(&tempi1,&tempi2)) {
tempi->ic_flags|=tempi1->ic_flags;
tempi1->ic_opcode=IC_NOP;
if (tempi->t.p1t!=tempi2)
tempi->t.p1c=tempi->t.p2c;
tempi->ic_data=tempi1->ic_data;
tempi->ic_opcode=IC_ADD_CONST;
tempi->p1.ptype=tempi->r.type&IT_MASK;
tempi->p2.type=TY_NULL;
OptSetNOP1(tempi1);
if (tempil2->ic_opcode==IC_REG &&
tempil2->p1.reg==CREG_RBP) {
tempil2->p1.reg==CREG_RBP) {
tempi->ic_flags|=tempil2->ic_flags;
tempil2->ic_opcode=IC_NOP;
tempi->ic_opcode=IC_LEA;
tempi->p1.reg=CREG_RBP;
tempi->p1.type=TY_DISP+tempi->p1.type&IT_MASK;
@@ -276,10 +260,11 @@ U0 OptPass3(CLex *lx,CHashFun *fun_class,COptReg *register_offsets)
for (i=0;i<member_cnt;i++)
if (mv[i].offset==tempi->ic_data) {
mv[i].lea_balance++;
mv[i].score+=1+tempi->ic_indent_level;
mv[i].score++;
break;
}
}
OptSetNOP1(tempil2);
}
}
break;
case IC_SUB:
@@ -287,12 +272,12 @@ U0 OptPass3(CLex *lx,CHashFun *fun_class,COptReg *register_offsets)
CmpF2PushPop(tempi,tempi1,tempi2);
break;
}
if (tempi2->ic_opcode==IC_IMM) {
if (tempi2->ic_opcode==IC_IMM_U64) {
tempi->ic_flags|=tempi2->ic_flags;
tempi2->ic_opcode=IC_NOP;
tempi->ic_data=tempi2->ic_data;
tempi->ic_opcode=IC_SUB_CONST;
tempi->p2.type=TY_NULL;
OptSetNOP1(tempi2);
}
break;
case IC_LESS:
@@ -307,7 +292,6 @@ U0 OptPass3(CLex *lx,CHashFun *fun_class,COptReg *register_offsets)
case IC_AND_AND:
case IC_OR_OR:
case IC_XOR_XOR:
case IC_COLON:
break;
case IC_MUL_EQUAL:
@@ -326,15 +310,15 @@ U0 OptPass3(CLex *lx,CHashFun *fun_class,COptReg *register_offsets)
case IC_OR_EQUAL:
case IC_XOR_EQUAL:
if (tempi1->ic_opcode==IC_LEA &&
tempi1->p1.type&TY_MASK==TY_DISP &&
tempi1->p1.reg==CREG_RBP)
tempi1->p1.type&TY_MASK==TY_DISP &&
tempi1->p1.reg==CREG_RBP)
for (i=0;i<member_cnt;i++)
if (mv[i].offset==tempi1->p1.disp) {
mv[i].lea_balance--;
mv[i].score+=1+tempi->ic_indent_level;
mv[i].score++;
break;
}
tempi->p1.ptype=tempi->r.type&IT_MASK;
tempi->p1.ptype=tempi->r.type&IT_MASK;
tempi->r.ptype=CmpPType(tempi->t.p1c);
break;
case IC_RETURN_VAL:
@@ -397,11 +381,9 @@ U0 OptPass3(CLex *lx,CHashFun *fun_class,COptReg *register_offsets)
case IC_BTS:
case IC_BTR:
case IC_BTC:
case IC_BEQU:
case IC_LBTS:
case IC_LBTR:
case IC_LBTC:
case IC_LBEQU:
case IC_BSF:
case IC_BSR:
case IC_PREEMPT:
@@ -411,8 +393,6 @@ U0 OptPass3(CLex *lx,CHashFun *fun_class,COptReg *register_offsets)
case IC_TO_F64:
case IC_TO_BOOL:
case IC_ABS_I64:
case IC_LIMIT_I64:
case IC_LIMIT_U64:
case IC_MIN_I64:
case IC_MAX_I64:
case IC_MIN_U64:
@@ -428,46 +408,36 @@ U0 OptPass3(CLex *lx,CHashFun *fun_class,COptReg *register_offsets)
case IC_QUE_INS:
case IC_QUE_INS_REV:
case IC_QUE_REM:
case IC_MEMCPY:
case IC_MEMSET:
case IC_MEMSET_U16:
case IC_MEMSET_U32:
case IC_MEMSET_U64:
case IC_INU32:
case IC_INU16:
case IC_INU8:
case IC_IN_U32:
case IC_IN_U16:
case IC_IN_U8:
case IC_STRLEN:
case IC_OUTU32:
case IC_OUTU16:
case IC_OUTU8:
case IC_OUT_U32:
case IC_OUT_U16:
case IC_OUT_U8:
case IC_ASM:
break;
case IC_NOBOUND_SWITCH:
case IC_SWITCH:
lb=tempi->ic_data;
lb=lb->dft;
while (lb->fwd)
lb=lb->fwd;
lb=OptLabelFwd(tempi->ic_data(CCodeBlkMisc *)->dft);
lb->flags|=CBMF_USED;
break;
case IC_BR_ZERO:
case IC_BR_NOT_ZERO:
if (tempi1->ic_opcode==IC_IMM ||
tempi1->ic_opcode==IC_F64) {
tempi1->ic_opcode=IC_NOP;
tempi->p1.type=TY_NULL;
tempi1->r.type=TY_NULL;
if (code==IC_BR_ZERO ^^ tempi1->ic_data)
if (tempi1->ic_opcode==IC_IMM_U64 || tempi1->ic_opcode==IC_IMM_F64) {
if (code==IC_BR_ZERO ^^ tempi1->ic_data) {
OptSetNOP1(tempi1);
tempi->p1.type=TY_NULL;
tempi->ic_opcode=IC_JMP;
else {
tempi->ic_opcode=IC_NOP;
tempi->ic_class=NULL;
} else {
OptSetNOP1(tempi1);
OptSetNOP1(tempi);
break;
}
}
goto here1;
case IC_BR_AND_ZERO:
if (tempi1->ic_opcode==IC_IMM) {
if (tempi1->ic_opcode==IC_IMM_U64) {
i=Bsr(tempi1->ic_data);
if (0<=i==Bsf(tempi1->ic_data)) {
tempi1->ic_data=i;
@@ -476,7 +446,7 @@ U0 OptPass3(CLex *lx,CHashFun *fun_class,COptReg *register_offsets)
goto here1;
}
}
if (tempi2->ic_opcode==IC_IMM) {
if (tempi2->ic_opcode==IC_IMM_U64) {
i=Bsr(tempi2->ic_data);
if (0<=i==Bsf(tempi2->ic_data)) {
tempi2->ic_data=i;
@@ -486,7 +456,7 @@ U0 OptPass3(CLex *lx,CHashFun *fun_class,COptReg *register_offsets)
}
goto here1;
case IC_BR_AND_NOT_ZERO:
if (tempi1->ic_opcode==IC_IMM) {
if (tempi1->ic_opcode==IC_IMM_U64) {
i=Bsr(tempi1->ic_data);
if (0<=i==Bsf(tempi1->ic_data)) {
tempi1->ic_data=i;
@@ -495,7 +465,7 @@ U0 OptPass3(CLex *lx,CHashFun *fun_class,COptReg *register_offsets)
goto here1;
}
}
if (tempi2->ic_opcode==IC_IMM) {
if (tempi2->ic_opcode==IC_IMM_U64) {
i=Bsr(tempi2->ic_data);
if (0<=i==Bsf(tempi2->ic_data)) {
tempi2->ic_data=i;
@@ -507,12 +477,12 @@ U0 OptPass3(CLex *lx,CHashFun *fun_class,COptReg *register_offsets)
case IC_BR_MM_ZERO:
case IC_BR_MM_NOT_ZERO:
if (tempi1->ic_opcode==IC_LEA &&
tempi1->p1.type&TY_MASK==TY_DISP &&
tempi1->p1.reg==CREG_RBP)
tempi1->p1.type&TY_MASK==TY_DISP &&
tempi1->p1.reg==CREG_RBP)
for (i=0;i<member_cnt;i++)
if (mv[i].offset==tempi1->p1.disp) {
mv[i].lea_balance--;
mv[i].score+=1+tempi->ic_indent_level;
mv[i].score++;
break;
}
tempi->p1.ptype=CmpType(tempc);
@@ -548,19 +518,18 @@ U0 OptPass3(CLex *lx,CHashFun *fun_class,COptReg *register_offsets)
case IC_BR_NOT_LBTC:
case IC_JMP:
here1:
lb=tempi->ic_data;
if (!(tempi->ic_flags&ICF_PUSH_CMP))
while (lb->fwd)
lb=lb->fwd;
if (tempi->ic_flags&ICF_PUSH_CMP)
lb=tempi->ic_data;
else
lb=OptLabelFwd(tempi->ic_data);
lb->flags|=CBMF_USED;
break;
case IC_LEAVE:
case IC_RET:
break;
case IC_ADDR:
case IC_NOP:
case IC_NOP1:
case IC_END:
case IC_QUESTION:
case IC_IRQ:
case IC_END_EXP:
case IC_CALL_END:
@@ -570,7 +539,7 @@ here1:
case IC_POP_REGS:
case IC_LABEL:
break;
case IC_NOP1:
case IC_NOP2:
ps->ptr+=tempi->ic_data;
break;
@@ -583,7 +552,7 @@ here1:
if (fun_class) {
fun_class->used_reg_mask=fun_class->used_reg_mask&~(CREG_VARS_MASK|CREG_NON_PTR_MASK)|used_reg_mask;
if (!Bt(&lx->opts,OPTf_NO_REG_VAR) &&
!(lx->flags & LF_NO_REG_OPT)) {
!(lx->flags & LF_NO_REG_OPT)) {
QSort(mv,member_cnt,sizeof(OptMemberVar),&OptMVCompare);
while (member_cnt && !mv[member_cnt-1].score)
member_cnt--;
@@ -595,7 +564,7 @@ here1:
} else {
if (mv[i].m->register==CREG_ALLOC)
PrintFWarn("%S\n $$LK-A,\"FL:%s,%d\"$$ '%s' in '%s'\n","ST_CANT_REG_VAR",
lx->cur_lfn->name,lx->cur_lfn->line_num,mv[i].m->str,fun_class->str);
lx->cur_lfn->name,lx->cur_lfn->line_num,mv[i].m->str,fun_class->str);
}
}
if (j>0) {
@@ -603,12 +572,10 @@ here1:
l=0;
for (i=0;i<j && l<num_non_ptr_vars;i++) {
tempm=mv[i].m;
tempc=tempm->member_class;
while (tempc->fwd_class)
tempc=tempc->fwd_class;
tempc=OptClassFwd(tempm->member_class);
if (!tempc->ptr_cnt && !tempm->dim.next) {
while (l<num_non_ptr_vars &&
Bts(&fun_class->used_reg_mask,to_non_ptr_vars_map[l]))
Bts(&fun_class->used_reg_mask,to_non_ptr_vars_map[l]))
l++;
if (l<num_non_ptr_vars) {
tempm->register=to_non_ptr_vars_map[l++];
@@ -616,8 +583,8 @@ here1:
register_offsets[tempm->register].m=tempm;
if (Bt(&lx->flags,Lf_OPT_TRACE_PRESENT))
"Fun:%s\nReg %Z Var \"%s\" %08X[RBP]\n",
fun_class->str,tempm->register,"ST_U64_REGS",
tempm->str,register_offsets[tempm->register].offset;
fun_class->str,tempm->register,"ST_U64_REGS",
tempm->str,register_offsets[tempm->register].offset;
mv[i].offset=0; //flag as reg var
}
}
@@ -626,11 +593,11 @@ here1:
l=0;
for (i=0;i<j && l<num_reg_vars;i++) {
tempm=mv[i].m;
//if not just flagged as reg var
//if not just flagged as reg var
if (mv[i].offset && (!mv[i].m->dim.next||
tempm->offset>0 && StrCmp(tempm->str,"argv"))) {
tempm->offset>0 && StrCmp(tempm->str,"argv"))) {
while (l<num_reg_vars &&
Bts(&fun_class->used_reg_mask,to_reg_vars_map[l]))
Bts(&fun_class->used_reg_mask,to_reg_vars_map[l]))
l++;
if (l<num_reg_vars) {
tempm->register=to_reg_vars_map[l++];
@@ -638,7 +605,7 @@ here1:
register_offsets[tempm->register].m=tempm;
if (Bt(&lx->flags,Lf_OPT_TRACE_PRESENT))
"Reg %Z Var \"%s\" %08X[RBP]\n",tempm->register,"ST_U64_REGS",
tempm->str,register_offsets[tempm->register].offset;
tempm->str,register_offsets[tempm->register].offset;
}
}
}