TempleOSCDV4.06.ISO
This commit is contained in:
1 parent
6fe38d2d9d
commit
b632ab9a4f
261 files changed
+6282
-5801
No files matched your search
+54
-49
@@ -37,16 +37,16 @@ U0 PrsAsmArg(CCmpCtrl *cc,CAsmArg *arg,Bool rel)
|
||||
CHashGeneric *temph,*temph1;
|
||||
CHashReg *tempr;
|
||||
MemSet(arg,0,sizeof(CAsmArg));
|
||||
arg->seg=REG_NONE;
|
||||
arg->seg =REG_NONE;
|
||||
arg->reg1=REG_NONE;
|
||||
arg->reg2=REG_NONE;
|
||||
arg->fstk=REG_NONE;
|
||||
arg->scale=1;
|
||||
while (TRUE) {
|
||||
if (cc->token==TK_IDENT) {
|
||||
if (temph=cc->hash_entry) {
|
||||
if (temph->type&HTG_TYPE_MASK==HTT_REG) {
|
||||
tempr=temph;
|
||||
arg->reg1_type=tempr->reg_type;
|
||||
switch (tempr->reg_type) {
|
||||
sub_switch_start:
|
||||
case REGT_R8:
|
||||
@@ -74,8 +74,10 @@ U0 PrsAsmArg(CCmpCtrl *cc,CAsmArg *arg,Bool rel)
|
||||
Lex(cc); //skip ":"
|
||||
break;
|
||||
case REGT_FSTK:
|
||||
case REGT_MM:
|
||||
case REGT_XMM:
|
||||
arg->size=8;
|
||||
arg->fstk=tempr->reg_num;
|
||||
arg->reg1=tempr->reg_num;
|
||||
Lex(cc);
|
||||
return;
|
||||
}
|
||||
@@ -131,6 +133,7 @@ pa_asm_direct_imm:
|
||||
if (temph->type&HTG_TYPE_MASK==HTT_REG &&
|
||||
REGT_R16<=temph(CHashReg *)->reg_type<=REGT_R64) {
|
||||
tempr=temph;
|
||||
arg->reg2_type=tempr->reg_type;
|
||||
if (arg->reg1==REG_NONE) {
|
||||
if (tempr->reg_num&7==REG_RSP) {
|
||||
arg->reg1=4;
|
||||
@@ -146,12 +149,14 @@ pa_asm_direct_imm:
|
||||
goto pa_asm_indirect_imm;
|
||||
} else if (cc->token=='*') {
|
||||
Lex(cc);
|
||||
if (cc->token!=TK_INT)
|
||||
if (cc->token!=TK_I64)
|
||||
LexExcept(cc,"Expecting scale factor at ");
|
||||
arg->scale=cc->cur_i64;
|
||||
Lex(cc); //skip scale
|
||||
if (arg->reg2!=REG_NONE)
|
||||
if (arg->reg2!=REG_NONE) {
|
||||
SwapI64(&arg->reg1,&arg->reg2);
|
||||
SwapI64(&arg->reg1_type,&arg->reg2_type);
|
||||
}
|
||||
} else if (cc->token=='+') {
|
||||
Lex(cc); //skip '+'
|
||||
} else {
|
||||
@@ -172,92 +177,92 @@ pa_asm_indirect_imm:
|
||||
I64 AsmMakeArgMask(CCmpCtrl *cc,CAsmArg *arg)
|
||||
{
|
||||
CAOTCtrl *aotc=cc->aotc;
|
||||
I64 result;
|
||||
I64 res;
|
||||
if (arg->just_seg) {
|
||||
switch (arg->seg) {
|
||||
case 0: result=1<<ARGT_ES|1<<ARGT_SREG; break;
|
||||
case 1: result=1<<ARGT_CS|1<<ARGT_SREG; break;
|
||||
case 2: result=1<<ARGT_SS|1<<ARGT_SREG; break;
|
||||
case 3: result=1<<ARGT_DS|1<<ARGT_SREG; break;
|
||||
case 4: result=1<<ARGT_FS|1<<ARGT_SREG; break;
|
||||
case 5: result=1<<ARGT_GS|1<<ARGT_SREG; break;
|
||||
case 0: res=1<<ARGT_ES|1<<ARGT_SREG; break;
|
||||
case 1: res=1<<ARGT_CS|1<<ARGT_SREG; break;
|
||||
case 2: res=1<<ARGT_SS|1<<ARGT_SREG; break;
|
||||
case 3: res=1<<ARGT_DS|1<<ARGT_SREG; break;
|
||||
case 4: res=1<<ARGT_FS|1<<ARGT_SREG; break;
|
||||
case 5: res=1<<ARGT_GS|1<<ARGT_SREG; break;
|
||||
}
|
||||
goto mm_done;
|
||||
}
|
||||
if (arg->fstk!=REG_NONE) {
|
||||
if (arg->fstk)
|
||||
result=1<<ARGT_STI;
|
||||
if (arg->reg1_type==REGT_FSTK) {
|
||||
if (arg->reg1)
|
||||
res=1<<ARGT_STI;
|
||||
else
|
||||
result=1<<ARGT_ST0|1<<ARGT_STI;
|
||||
res=1<<ARGT_ST0|1<<ARGT_STI;
|
||||
goto mm_done;
|
||||
}
|
||||
result=cmp.size_arg_mask[arg->size];
|
||||
res=cmp.size_arg_mask[arg->size];
|
||||
if (aotc->seg_size==64)
|
||||
result&=0xFF0FFFFFFF;
|
||||
res&=0xFF0FFFFFFF;
|
||||
|
||||
if (arg->reg1!=REG_NONE && arg->imm_or_off_present && !arg->num.i &&
|
||||
!arg->num.glbl_asm_undef_hash && !arg->num.local_asm_undef_hash)
|
||||
arg->imm_or_off_present=FALSE; //Zero displacement
|
||||
|
||||
if (arg->reg2!=REG_NONE || arg->scale!=1) {
|
||||
result&=0x0000FF0000;
|
||||
res&=0x0000FF0000;
|
||||
goto mm_done;
|
||||
}
|
||||
|
||||
if (arg->indirect) {
|
||||
if (arg->imm_or_off_present)
|
||||
result&=0x00FFFF0000;
|
||||
res&=0x00FFFF0000;
|
||||
else
|
||||
result&=0x000FFF0000;
|
||||
res&=0x000FFF0000;
|
||||
} else {
|
||||
if (arg->imm_or_off_present)
|
||||
result&=0x000F000FFE;
|
||||
res&=0x000F000FFE;
|
||||
else
|
||||
result&=0x3F0FFFF000;
|
||||
res&=0x3F0FFFF000;
|
||||
}
|
||||
if (arg->seg!=REG_NONE)
|
||||
result&=0x00FFFF0000;
|
||||
res&=0x00FFFF0000;
|
||||
if (arg->reg1==REG_NONE) {
|
||||
if (arg->indirect)
|
||||
result&=0x00FFFF0000;
|
||||
res&=0x00FFFF0000;
|
||||
else if (arg->num.i<0) {
|
||||
if (arg->num.i>=MIN_I8)
|
||||
result&=0x8FE;
|
||||
res&=0x8FE;
|
||||
else if (arg->num.i>=MIN_I16)
|
||||
result&=0x8EE;
|
||||
res&=0x8EE;
|
||||
else if (arg->num.i>=MIN_I32)
|
||||
result&=0x8CE;
|
||||
res&=0x8CE;
|
||||
else
|
||||
result&=0x88E;
|
||||
res&=0x88E;
|
||||
} else {
|
||||
if (arg->num.i<=MAX_I8)
|
||||
result&=0xFFE;
|
||||
res&=0xFFE;
|
||||
else if (arg->num.i<=MAX_U8)
|
||||
result&=0xFEE;
|
||||
res&=0xFEE;
|
||||
else if (arg->num.i<=MAX_I16)
|
||||
result&=0xEEE;
|
||||
res&=0xEEE;
|
||||
else if (arg->num.i<=MAX_U16)
|
||||
result&=0xECE;
|
||||
res&=0xECE;
|
||||
else if (arg->num.i<=MAX_I32)
|
||||
result&=0xCCE;
|
||||
res&=0xCCE;
|
||||
else if (arg->num.i<=MAX_U32)
|
||||
result&=0xC8E;
|
||||
res&=0xC8E;
|
||||
else
|
||||
result&=0x88E;
|
||||
res&=0x88E;
|
||||
}
|
||||
} else {
|
||||
result&= 0x3F00FFF000;
|
||||
res&= 0x3F00FFF000;
|
||||
if (!arg->indirect) //M8-M64
|
||||
result&=0xFFFF0FFFFF;
|
||||
res&=0xFFFF0FFFFF;
|
||||
}
|
||||
switch (arg->reg1) {
|
||||
case REG_RAX: result&=~0x3000000000; break;
|
||||
case REG_RCX: result&=~0x2F00000000; break;
|
||||
case REG_RDX: result&=~0x1F00000000; break;
|
||||
default: result&=~0x3F00000000;
|
||||
case REG_RAX: res&=~0x3000000000; break;
|
||||
case REG_RCX: res&=~0x2F00000000; break;
|
||||
case REG_RDX: res&=~0x1F00000000; break;
|
||||
default: res&=~0x3F00000000;
|
||||
}
|
||||
mm_done:
|
||||
return result;
|
||||
return res;
|
||||
}
|
||||
|
||||
Bool AsmStoreNum(CCmpCtrl *cc,CAsmNum2 *num2,I64 cnt,Bool U8_avail)
|
||||
@@ -471,8 +476,8 @@ Bool PrsAsmInst(CCmpCtrl *cc,CHashOpcode *tempo,I64 argcnt)
|
||||
if (tempa1->reg1>=20) //RBPu8,RSPu8,RSIu8,RDIu8?
|
||||
cur.has_REX=TRUE;
|
||||
} else {//SV_I_REG
|
||||
if (tempa1->fstk!=REG_NONE)
|
||||
cur.last_opcode_U8+=tempa1->fstk;
|
||||
if (tempa1->reg1_type==REGT_FSTK)
|
||||
cur.last_opcode_U8+=tempa1->reg1;
|
||||
}
|
||||
}
|
||||
if (a1==ARGT_R64 || a1==ARGT_RM64 || a1==ARGT_M64)
|
||||
@@ -589,10 +594,10 @@ Bool PrsAsmInst(CCmpCtrl *cc,CHashOpcode *tempo,I64 argcnt)
|
||||
cur.has_REX=TRUE;
|
||||
}
|
||||
} else {//SV_I_REG
|
||||
if (tempa1->fstk!=REG_NONE)
|
||||
cur.last_opcode_U8|=tempa1->fstk;
|
||||
if (tempa2->fstk!=REG_NONE)
|
||||
cur.last_opcode_U8|=tempa2->fstk;
|
||||
if (tempa1->reg1_type==REGT_FSTK)
|
||||
cur.last_opcode_U8|=tempa1->reg1;
|
||||
if (tempa2->reg1_type==REGT_FSTK)
|
||||
cur.last_opcode_U8|=tempa2->reg1;
|
||||
}
|
||||
}
|
||||
if (a1==ARGT_RM64 || a2==ARGT_RM64 || a1==ARGT_M64 || a2==ARGT_M64 ||
|
||||
|
||||
@@ -9,7 +9,7 @@ U0 AsmPrsInsFlags(CCmpCtrl *cc,CInst *tempi)
|
||||
break;
|
||||
} else
|
||||
return;
|
||||
case TK_INT:
|
||||
case TK_I64:
|
||||
if (cc->cur_i64==16)
|
||||
tempi->flags|=IEF_OP_SIZE16;
|
||||
else if (cc->cur_i64==32)
|
||||
@@ -20,7 +20,7 @@ U0 AsmPrsInsFlags(CCmpCtrl *cc,CInst *tempi)
|
||||
case '+':
|
||||
tempi->flags|=IEF_PLUS_OPCODE;
|
||||
case '/':
|
||||
if (Lex(cc)==TK_INT && cc->cur_i64<8)
|
||||
if (Lex(cc)==TK_I64 && cc->cur_i64<8)
|
||||
tempi->slash_val=cc->cur_i64;
|
||||
else if (cc->token==TK_IDENT) {
|
||||
if (!StrCmp(cc->cur_str,"R"))
|
||||
@@ -74,9 +74,9 @@ U0 AsmHashLoad()
|
||||
while (cc->token) {
|
||||
if (cc->token!=TK_IDENT)
|
||||
LexExcept(cc,"Expecting identifier at ");
|
||||
i=LstMatch(cc->cur_str,"R8\0R16\0R32\0R64\0SEG\0FSTK\0"
|
||||
i=LstMatch(cc->cur_str,"NONE\0R8\0R16\0R32\0R64\0SEG\0FSTK\0"
|
||||
"MM\0XMM\0OPCODE\0KEYWORD\0ASM_KEYWORD\0");
|
||||
if (i<0)
|
||||
if (i<=0)
|
||||
LexExcept(cc,"Unknown Stmt");
|
||||
Lex(cc); //skip keyword
|
||||
if (cc->token!=TK_IDENT)
|
||||
@@ -87,7 +87,7 @@ U0 AsmHashLoad()
|
||||
tempr->str=cc->cur_str;
|
||||
cc->cur_str=NULL;
|
||||
Lex(cc); //skip keyword name
|
||||
if (cc->token!=TK_INT)
|
||||
if (cc->token!=TK_I64)
|
||||
LexExcept(cc,"Expecting int at ");
|
||||
tempr->type=HTT_REG;
|
||||
tempr->reg_type=i;
|
||||
@@ -108,7 +108,7 @@ U0 AsmHashLoad()
|
||||
tempi=&tempo_max->ins[tempo_max->inst_entry_cnt];
|
||||
tempi->ins_entry_num=tempo_max->inst_entry_cnt++;
|
||||
tempi->slash_val=SV_NONE; //Not zero!!
|
||||
while (cc->token==TK_INT) {
|
||||
while (cc->token==TK_I64) {
|
||||
tempi->opcode[tempi->opcode_cnt++]=cc->cur_i64;
|
||||
Lex(cc);
|
||||
}
|
||||
@@ -161,7 +161,7 @@ U0 AsmHashLoad()
|
||||
//Parse aliases.
|
||||
if (cc->token==':') {
|
||||
while (Lex(cc)==TK_IDENT) {
|
||||
tempo2=MAllocIdentical(tempo);
|
||||
tempo2=MAllocIdent(tempo);
|
||||
tempo2->str=cc->cur_str;
|
||||
cc->cur_str=0;
|
||||
tempo2->oc_flags|=OCF_ALIAS;
|
||||
@@ -177,10 +177,10 @@ U0 AsmHashLoad()
|
||||
temph->str=cc->cur_str;
|
||||
cc->cur_str=NULL;
|
||||
Lex(cc); //skip keyword name
|
||||
if (cc->token!=TK_INT)
|
||||
if (cc->token!=TK_I64)
|
||||
LexExcept(cc,"Expecting int at ");
|
||||
temph->user_data0=cc->cur_i64;
|
||||
if (i==9)
|
||||
if (i==10)
|
||||
temph->type=HTT_KEYWORD;
|
||||
else
|
||||
temph->type=HTT_ASM_KEYWORD;
|
||||
|
||||
+3
-3
@@ -127,7 +127,7 @@ U0 AOTStoreCodeU8At(CCmpCtrl *cc,I64 ip,...)
|
||||
I64 AsmLexExpression(CCmpCtrl *cc)
|
||||
{
|
||||
U8 *machine_code;
|
||||
I64 result=0;
|
||||
I64 res=0;
|
||||
cc->asm_undef_hash=NULL;
|
||||
cc->flags&=~(CCF_UNRESOLVED+CCF_LOCAL);
|
||||
cc->abs_cnts=0;
|
||||
@@ -138,10 +138,10 @@ I64 AsmLexExpression(CCmpCtrl *cc)
|
||||
LexExcept(cc,"Extern Not Allowed at ");
|
||||
if (cc->flags & CCF_UNRESOLVED)
|
||||
LexExcept(cc,"Undefined sym at ");
|
||||
result=Call(machine_code);
|
||||
res=Call(machine_code);
|
||||
Free(machine_code);
|
||||
}
|
||||
return result;
|
||||
return res;
|
||||
}
|
||||
|
||||
U0 AsmLineLst(CCmpCtrl *cc)
|
||||
|
||||
+59
-59
@@ -1,19 +1,19 @@
|
||||
U0 ICAddEct(CIntermediateCode *tempi,CICType t1,I64 r1,I64 d1,
|
||||
CICType t2,I64 r2,I64 d2,CICType t3,I64 r3,I64 d3,I64 op,I64 ip)
|
||||
{
|
||||
I64 i,temp,result_reg=REG_RAX;
|
||||
I64 i,temp,res_reg=REG_RAX;
|
||||
Bool swap=FALSE;
|
||||
if (r3!=result_reg) {
|
||||
if (r3!=res_reg) {
|
||||
swap^=TRUE;
|
||||
SwapI64(&t2,&t3);
|
||||
SwapI64(&r2,&r3);
|
||||
SwapI64(&d2,&d3);
|
||||
}
|
||||
if (t2.raw_type>=RT_I64 && r2!=result_reg && t2&MDG_REG_DISP_SIB_RIP) {
|
||||
if (t2.raw_type>=RT_I64 && r2!=res_reg && t2&MDG_REG_DISP_SIB_RIP) {
|
||||
if (t1&MDF_REG && !(r2==r1 && t2&MDG_REG_DISP_SIB))
|
||||
result_reg=r1;
|
||||
ICMov(tempi,MDF_REG+RT_I64,result_reg,0,t3,r3,d3,ip);
|
||||
i=ICModr1(result_reg,t2,r2,d2);
|
||||
res_reg=r1;
|
||||
ICMov(tempi,MDF_REG+RT_I64,res_reg,0,t3,r3,d3,ip);
|
||||
i=ICModr1(res_reg,t2,r2,d2);
|
||||
if (tempi->ic_flags&ICF_LOCK)
|
||||
ICU8(tempi,OC_LOCK_PREFIX);
|
||||
ICRex(tempi,i.u8[1]);
|
||||
@@ -26,31 +26,31 @@ U0 ICAddEct(CIntermediateCode *tempi,CICType t1,I64 r1,I64 d1,
|
||||
temp=REG_RCX;
|
||||
|
||||
if (t1&MDF_REG)
|
||||
result_reg=r1;
|
||||
res_reg=r1;
|
||||
|
||||
if (temp==result_reg)
|
||||
result_reg=REG_RDX;
|
||||
if (temp==res_reg)
|
||||
res_reg=REG_RDX;
|
||||
if (swap) {
|
||||
if (r3==temp && t3&MDG_REG_DISP_SIB)
|
||||
temp=REG_RCX;
|
||||
ICMov(tempi,MDF_REG+RT_I64,temp,0,t2,r2,d2,ip);
|
||||
ICMov(tempi,MDF_REG+RT_I64,result_reg,0,t3,r3,d3,ip);
|
||||
ICMov(tempi,MDF_REG+RT_I64,res_reg,0,t3,r3,d3,ip);
|
||||
} else {
|
||||
if (r2==result_reg && t2&MDG_REG_DISP_SIB)
|
||||
result_reg=REG_RDX;
|
||||
ICMov(tempi,MDF_REG+RT_I64,result_reg,0,t3,r3,d3,ip);
|
||||
if (r2==res_reg && t2&MDG_REG_DISP_SIB)
|
||||
res_reg=REG_RDX;
|
||||
ICMov(tempi,MDF_REG+RT_I64,res_reg,0,t3,r3,d3,ip);
|
||||
ICMov(tempi,MDF_REG+RT_I64,temp,0,t2,r2,d2,ip);
|
||||
}
|
||||
i=0x48;
|
||||
if (result_reg>7)
|
||||
if (res_reg>7)
|
||||
i+=4;
|
||||
if (temp>7)
|
||||
i++;
|
||||
if (tempi->ic_flags&ICF_LOCK)
|
||||
ICU8(tempi,OC_LOCK_PREFIX);
|
||||
ICU24(tempi,0xC00000+i+(temp&7)<<16+(result_reg&7)<<19+op<<8);
|
||||
ICU24(tempi,0xC00000+i+(temp&7)<<16+(res_reg&7)<<19+op<<8);
|
||||
}
|
||||
ICMov(tempi,t1,r1,d1,MDF_REG+RT_I64,result_reg,0,ip);
|
||||
ICMov(tempi,t1,r1,d1,MDF_REG+RT_I64,res_reg,0,ip);
|
||||
}
|
||||
|
||||
U0 ICAddSubEctImm(CIntermediateCode *tempi,CICType t1,I64 r1,I64 d1,
|
||||
@@ -480,7 +480,7 @@ U0 ICAddSubEctEqu(CIntermediateCode *tempi,U8 type_pointed_to,
|
||||
CICType t3,I64 r3,I64 d3,I64 op,I64 ip)
|
||||
{
|
||||
Bool done;
|
||||
I64 result_reg,temp,i;
|
||||
I64 res_reg,temp,i;
|
||||
if (tempi->ic_flags & ICF_BY_VAL) {
|
||||
if (t3&MDF_IMM) {
|
||||
ICAddSubEctImm(tempi,t2&MDG_MASK+type_pointed_to,r2,d2,t2&MDG_MASK+
|
||||
@@ -508,47 +508,47 @@ U0 ICAddSubEctEqu(CIntermediateCode *tempi,U8 type_pointed_to,
|
||||
}
|
||||
if (t3.raw_type>=RT_I64 && t3&MDG_REG_DISP_SIB_RIP) {
|
||||
if (t2&MDF_REG)
|
||||
result_reg=r2;
|
||||
res_reg=r2;
|
||||
else {
|
||||
result_reg=REG_RCX;
|
||||
res_reg=REG_RCX;
|
||||
ICMov(tempi,MDF_REG+RT_I64,REG_RCX,0,t2,r2,d2,ip);
|
||||
}
|
||||
i=ICModr1(result_reg,t3&MDG_MASK+type_pointed_to,r3,d3);
|
||||
i=ICModr1(res_reg,t3&MDG_MASK+type_pointed_to,r3,d3);
|
||||
if (tempi->ic_flags&ICF_LOCK)
|
||||
ICU8(tempi,OC_LOCK_PREFIX);
|
||||
ICRex(tempi,i.u8[1]);
|
||||
ICU16(tempi,i.u8[2]<<8+op.u8[0]);
|
||||
ICModr2(tempi,i,d3,ip+4);
|
||||
ICMov(tempi,t2&MDG_MASK+type_pointed_to,r2,d2,
|
||||
MDF_REG+RT_I64,result_reg,0,ip);
|
||||
MDF_REG+RT_I64,res_reg,0,ip);
|
||||
done=TRUE;
|
||||
}
|
||||
}
|
||||
if (!done) {
|
||||
ICMov(tempi,MDF_REG+RT_I64,REG_RAX,0,t3,r3,d3,ip);
|
||||
if (t2&MDF_REG && r2!=REG_RAX)
|
||||
result_reg=r2;
|
||||
res_reg=r2;
|
||||
else {
|
||||
result_reg=REG_RCX;
|
||||
res_reg=REG_RCX;
|
||||
ICMov(tempi,MDF_REG+RT_I64,REG_RCX,0,
|
||||
t2&MDG_MASK+type_pointed_to,r2,d2,ip);
|
||||
}
|
||||
if (tempi->ic_flags&ICF_LOCK)
|
||||
ICU8(tempi,OC_LOCK_PREFIX);
|
||||
if (result_reg>7)
|
||||
if (res_reg>7)
|
||||
ICU8(tempi,0x4C);
|
||||
else
|
||||
ICU8(tempi,0x48);
|
||||
ICU16(tempi,0xC000+op.u8[0]+(result_reg&7)<<11);
|
||||
ICU16(tempi,0xC000+op.u8[0]+(res_reg&7)<<11);
|
||||
ICMov(tempi,t2&MDG_MASK+type_pointed_to,r2,d2,
|
||||
MDF_REG+RT_I64,result_reg,0,ip);
|
||||
MDF_REG+RT_I64,res_reg,0,ip);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
done=FALSE;
|
||||
if (t3&MDF_IMM && op.u8[2]) {
|
||||
if (!d3.u32[1]) {
|
||||
if (tempi->ic_flags&ICF_NO_DEPEND_RESULT &&
|
||||
if (tempi->ic_flags&ICF_RES_NOT_USED &&
|
||||
t2&MDF_REG && d3(U64)<=MAX_I8) {
|
||||
ICSlashOp(tempi,MDF_DISP+type_pointed_to,r2,0,0x838000+op.u8[4],ip);
|
||||
ICU8(tempi,d3);
|
||||
@@ -557,19 +557,19 @@ U0 ICAddSubEctEqu(CIntermediateCode *tempi,U8 type_pointed_to,
|
||||
ICMov(tempi,MDF_REG+RT_I64,REG_RCX,0,t2,r2,d2,ip);
|
||||
ICMov(tempi,MDF_REG+RT_I64,REG_RAX,0,
|
||||
MDF_DISP+type_pointed_to,REG_RCX,0,ip);
|
||||
result_reg=REG_RAX;
|
||||
res_reg=REG_RAX;
|
||||
if (tempi->ic_flags&ICF_LOCK)
|
||||
ICU8(tempi,OC_LOCK_PREFIX);
|
||||
ICU16(tempi,op.u8[3]<<8+0x40);
|
||||
ICU32(tempi,d3);
|
||||
ICMov(tempi,MDF_DISP+type_pointed_to,REG_RCX,0,
|
||||
MDF_REG+RT_I64,result_reg,0,ip);
|
||||
MDF_REG+RT_I64,res_reg,0,ip);
|
||||
done=TRUE;
|
||||
} else if (type_pointed_to<RT_I64) {//OR/XOR
|
||||
ICMov(tempi,MDF_REG+RT_I64,REG_RCX,0,t2,r2,d2,ip);
|
||||
ICMov(tempi,MDF_REG+RT_I64,REG_RAX,0,
|
||||
MDF_DISP+type_pointed_to,REG_RCX,0,ip);
|
||||
result_reg=REG_RAX;
|
||||
res_reg=REG_RAX;
|
||||
if (tempi->ic_flags&ICF_LOCK)
|
||||
ICU8(tempi,OC_LOCK_PREFIX);
|
||||
if (d3.u16[1]) {
|
||||
@@ -583,7 +583,7 @@ U0 ICAddSubEctEqu(CIntermediateCode *tempi,U8 type_pointed_to,
|
||||
ICU8(tempi,d3);
|
||||
}
|
||||
ICMov(tempi,MDF_DISP+type_pointed_to,REG_RCX,0,
|
||||
MDF_REG+RT_I64,result_reg,0,ip);
|
||||
MDF_REG+RT_I64,res_reg,0,ip);
|
||||
done=TRUE;
|
||||
}
|
||||
}
|
||||
@@ -593,47 +593,47 @@ U0 ICAddSubEctEqu(CIntermediateCode *tempi,U8 type_pointed_to,
|
||||
ICMov(tempi,MDF_REG+RT_I64,REG_RCX,0,t2,r2,d2,ip);
|
||||
ICMov(tempi,MDF_REG+RT_I64,REG_RBX,0,
|
||||
MDF_DISP+type_pointed_to,REG_RCX,0,ip);
|
||||
result_reg=REG_RBX;
|
||||
res_reg=REG_RBX;
|
||||
if (tempi->ic_flags&ICF_LOCK)
|
||||
ICU8(tempi,OC_LOCK_PREFIX);
|
||||
ICU8(tempi,0x48);
|
||||
ICU16(tempi,0xC000+op.u8[0]+(result_reg&7)<<11);
|
||||
ICU16(tempi,0xC000+op.u8[0]+(res_reg&7)<<11);
|
||||
ICMov(tempi,MDF_DISP+type_pointed_to,REG_RCX,0,
|
||||
MDF_REG+RT_I64,result_reg,0,ip);
|
||||
MDF_REG+RT_I64,res_reg,0,ip);
|
||||
}
|
||||
}
|
||||
if (t1.mode)
|
||||
ICMov(tempi,t1,r1,d1,MDF_REG+RT_I64,result_reg,0,ip);
|
||||
ICMov(tempi,t1,r1,d1,MDF_REG+RT_I64,res_reg,0,ip);
|
||||
}
|
||||
|
||||
U0 ICShift(CIntermediateCode *tempi,CICType t1,I64 r1,I64 d1,
|
||||
CICType t2,I64 r2,I64 d2,CICType t3,I64 r3,I64 d3,
|
||||
I64 us,I64 is,I64 ip)
|
||||
{
|
||||
I64 i=0x48,result_reg;
|
||||
I64 i=0x48,res_reg;
|
||||
if (tempi->ic_class->raw_type&RTF_UNSIGNED ||
|
||||
tempi->ic_flags & ICF_USE_UNSIGNED)
|
||||
is=us;
|
||||
if (t1&MDF_REG) {
|
||||
result_reg=r1;
|
||||
if (result_reg>7)
|
||||
res_reg=r1;
|
||||
if (res_reg>7)
|
||||
i++;
|
||||
} else
|
||||
result_reg=REG_RAX;
|
||||
res_reg=REG_RAX;
|
||||
if (t3&MDF_IMM) {
|
||||
ICMov(tempi,MDF_REG+RT_I64,result_reg,0,t2,r2,d2,ip);
|
||||
ICMov(tempi,MDF_REG+RT_I64,res_reg,0,t2,r2,d2,ip);
|
||||
if (d3==1)
|
||||
ICU24(tempi,i+is.u16[2]<<8+(result_reg&7)<<16);
|
||||
ICU24(tempi,i+is.u16[2]<<8+(res_reg&7)<<16);
|
||||
else {
|
||||
ICU24(tempi,i+is.u16[0]<<8+(result_reg&7)<<16);
|
||||
ICU24(tempi,i+is.u16[0]<<8+(res_reg&7)<<16);
|
||||
ICU8(tempi,d3);
|
||||
}
|
||||
} else {
|
||||
ICMov(tempi,MDF_REG+RT_I64,REG_RCX,0,t3,r3,d3,ip);
|
||||
ICMov(tempi,MDF_REG+RT_I64,result_reg,0,t2,r2,d2,ip);
|
||||
ICU24(tempi,i+is.u16[1]<<8+(result_reg&7)<<16);
|
||||
ICMov(tempi,MDF_REG+RT_I64,res_reg,0,t2,r2,d2,ip);
|
||||
ICU24(tempi,i+is.u16[1]<<8+(res_reg&7)<<16);
|
||||
}
|
||||
ICMov(tempi,t1,r1,d1,MDF_REG+RT_I64,result_reg,0,ip);
|
||||
ICMov(tempi,t1,r1,d1,MDF_REG+RT_I64,res_reg,0,ip);
|
||||
}
|
||||
|
||||
U0 ICShiftEqu(CIntermediateCode *tempi,U8 type_pointed_to,
|
||||
@@ -641,7 +641,7 @@ U0 ICShiftEqu(CIntermediateCode *tempi,U8 type_pointed_to,
|
||||
CICType t2,I64 r2,I64 d2,
|
||||
CICType t3,I64 r3,I64 d3,I64 us,I64 is,I64 ip)
|
||||
{
|
||||
I64 result_reg;
|
||||
I64 res_reg;
|
||||
if (tempi->ic_class->raw_type&RTF_UNSIGNED ||
|
||||
tempi->ic_flags & ICF_USE_UNSIGNED)
|
||||
is=us;
|
||||
@@ -649,46 +649,46 @@ U0 ICShiftEqu(CIntermediateCode *tempi,U8 type_pointed_to,
|
||||
if (!(t3&MDF_IMM))
|
||||
ICMov(tempi,MDF_REG+RT_I64,REG_RCX,0,t3,r3,d3,ip);
|
||||
if (t2&MDF_REG)
|
||||
result_reg=r2;
|
||||
res_reg=r2;
|
||||
else {
|
||||
result_reg=REG_RAX;
|
||||
res_reg=REG_RAX;
|
||||
ICMov(tempi,MDF_REG+RT_I64,REG_RAX,0,
|
||||
t2&MDG_MASK+type_pointed_to,r2,d2,ip);
|
||||
}
|
||||
if (result_reg>7)
|
||||
if (res_reg>7)
|
||||
ICU8(tempi,0x49);
|
||||
else
|
||||
ICU8(tempi,0x48);
|
||||
if (t3&MDF_IMM) {
|
||||
if (d3==1)
|
||||
ICU16(tempi,is.u16[2]+(result_reg&7)<<8);
|
||||
ICU16(tempi,is.u16[2]+(res_reg&7)<<8);
|
||||
else {
|
||||
ICU16(tempi,is.u16[0]+(result_reg&7)<<8);
|
||||
ICU16(tempi,is.u16[0]+(res_reg&7)<<8);
|
||||
ICU8(tempi,d3);
|
||||
}
|
||||
} else
|
||||
ICU16(tempi,is.u16[1]+(result_reg&7)<<8);
|
||||
ICU16(tempi,is.u16[1]+(res_reg&7)<<8);
|
||||
ICMov(tempi,t2&MDG_MASK+type_pointed_to,r2,d2,
|
||||
MDF_REG+RT_I64,result_reg,0,ip);
|
||||
MDF_REG+RT_I64,res_reg,0,ip);
|
||||
} else {
|
||||
if (!(t3&MDF_IMM))
|
||||
ICMov(tempi,MDF_REG+RT_I64,REG_RCX,0,t3,r3,d3,ip);
|
||||
ICMov(tempi,MDF_REG+RT_I64,REG_RDX,0,t2,r2,d2,ip);
|
||||
ICMov(tempi,MDF_REG+RT_I64,REG_RAX,0,MDF_DISP+type_pointed_to,REG_RDX,0,ip);
|
||||
result_reg=REG_RAX;
|
||||
res_reg=REG_RAX;
|
||||
ICU8(tempi,0x48);
|
||||
if (t3&MDF_IMM) {
|
||||
if (d3==1)
|
||||
ICU16(tempi,is.u16[2]+(result_reg&7)<<8);
|
||||
ICU16(tempi,is.u16[2]+(res_reg&7)<<8);
|
||||
else {
|
||||
ICU16(tempi,is.u16[0]+(result_reg&7)<<8);
|
||||
ICU16(tempi,is.u16[0]+(res_reg&7)<<8);
|
||||
ICU8(tempi,d3);
|
||||
}
|
||||
} else
|
||||
ICU16(tempi,is.u16[1]+(result_reg&7)<<8);
|
||||
ICU16(tempi,is.u16[1]+(res_reg&7)<<8);
|
||||
ICMov(tempi,
|
||||
MDF_DISP+type_pointed_to,REG_RDX,0,MDF_REG+RT_I64,result_reg,0,ip);
|
||||
MDF_DISP+type_pointed_to,REG_RDX,0,MDF_REG+RT_I64,res_reg,0,ip);
|
||||
}
|
||||
if (t1.mode)
|
||||
ICMov(tempi,t1,r1,d1,MDF_REG+RT_I64,result_reg,0,ip);
|
||||
ICMov(tempi,t1,r1,d1,MDF_REG+RT_I64,res_reg,0,ip);
|
||||
}
|
||||
+22
-21
@@ -202,20 +202,20 @@ U0 ICCmp(CIntermediateCode *tempi,I64 us,I64 is,I64 ip)
|
||||
U0 ICBitOps(CIntermediateCode *tempi,CICArg *a1,CICArg *a2,
|
||||
CIntermediateCode *tempi2,I64 op,I64 op_imm,I64 ip)
|
||||
{//TODO:not fully utilizing Modr
|
||||
Bool no_depend=ToBool(tempi2->ic_flags&ICF_NO_DEPEND_RESULT);
|
||||
Bool res_not_used=ToBool(tempi2->ic_flags&ICF_RES_NOT_USED);
|
||||
I64 r1,t2,r2,d2,i=0x48;
|
||||
if (tempi->ic_flags & ICF_BY_VAL) {
|
||||
t2=a2->type&MDG_MASK+RT_I64; //TODO: check overflow
|
||||
r2=a2->reg;
|
||||
d2=a2->disp;
|
||||
if (!(t2&MDG_REG_DISP_SIB_RIP) || !(r2.u8[0]!=REG_RAX&&(!(t2&MDF_SIB) ||
|
||||
r2.u8[1]&15!=REG_RAX) || no_depend)) {
|
||||
r2.u8[1]&15!=REG_RAX) || res_not_used)) {
|
||||
ICMov(tempi,MDF_REG+RT_I64,REG_RCX,0,t2,r2,d2,ip);
|
||||
t2=MDF_REG+RT_I64;
|
||||
r2=REG_RCX;
|
||||
d2=0;
|
||||
}
|
||||
if (a1->type&MDF_REG && (a1->reg!=REG_RAX||no_depend))
|
||||
if (a1->type&MDF_REG && (a1->reg!=REG_RAX||res_not_used))
|
||||
r1=a1->reg;
|
||||
else if (!(a1->type&MDF_IMM) || a1->disp>63) {
|
||||
ICMov(tempi,MDF_REG+RT_I64,REG_RDX,0,a1->type,a1->reg,a1->disp,ip);
|
||||
@@ -225,13 +225,13 @@ U0 ICBitOps(CIntermediateCode *tempi,CICArg *a1,CICArg *a2,
|
||||
} else {
|
||||
t2=MDF_DISP+RT_I64;
|
||||
d2=0;
|
||||
if (a2->type&MDF_REG && (a2->reg!=REG_RAX||no_depend))
|
||||
if (a2->type&MDF_REG && (a2->reg!=REG_RAX||res_not_used))
|
||||
r2=a2->reg;
|
||||
else {
|
||||
ICMov(tempi,MDF_REG+RT_I64,REG_RCX,0,a2->type,a2->reg,a2->disp,ip);
|
||||
r2=REG_RCX;
|
||||
}
|
||||
if (a1->type&MDF_REG && (a1->reg!=REG_RAX||no_depend))
|
||||
if (a1->type&MDF_REG && (a1->reg!=REG_RAX||res_not_used))
|
||||
r1=a1->reg;
|
||||
else if (!(a1->type&MDF_IMM) || a1->disp>63) {
|
||||
ICMov(tempi,MDF_REG+RT_I64,REG_RDX,0,a1->type,a1->reg,a1->disp,ip);
|
||||
@@ -239,7 +239,7 @@ U0 ICBitOps(CIntermediateCode *tempi,CICArg *a1,CICArg *a2,
|
||||
} else
|
||||
r1=0;
|
||||
}
|
||||
if (!no_depend)
|
||||
if (!res_not_used)
|
||||
ICZero(tempi,REG_RAX);
|
||||
if (tempi->ic_flags&ICF_LOCK && op!=0xA30F)
|
||||
ICU8(tempi,OC_LOCK_PREFIX);
|
||||
@@ -255,8 +255,9 @@ U0 ICBitOps(CIntermediateCode *tempi,CICArg *a1,CICArg *a2,
|
||||
ICU24(tempi,i.u8[2]<<16+op);
|
||||
ICModr2(tempi,i,d2,ip+4);
|
||||
}
|
||||
if (!no_depend) {
|
||||
ICU32(tempi,0xD08348);
|
||||
if (!res_not_used) {
|
||||
ICU24(tempi,0xC0920F); //SETC AL
|
||||
progress3++;
|
||||
if (tempi->r.type.mode)
|
||||
ICMov(tempi,tempi->r.type,tempi->r.reg,tempi->r.disp,
|
||||
MDF_REG+RT_I64,REG_RAX,0,ip);
|
||||
@@ -465,10 +466,10 @@ U0 ICAssignPostIncDec(CIntermediateCode *tempi,I64 op,I64 ip)
|
||||
}
|
||||
}
|
||||
|
||||
U0 ICCmpAndBranch(CIntermediateCode *tempi,Bool has_result,I64 ip,
|
||||
U0 ICCmpAndBranch(CIntermediateCode *tempi,Bool has_res,I64 ip,
|
||||
I64 us,I64 is,I64 not_us,I64 not_is,U8 *buf,I64 ip2)
|
||||
{
|
||||
I64 r1,r2,i=0x48,j,result_reg;
|
||||
I64 r1,r2,i=0x48,j,res_reg;
|
||||
CICType t1,t2;
|
||||
Bool short_jmp,swap,done;
|
||||
CCodeMisc *lb;
|
||||
@@ -488,7 +489,7 @@ U0 ICCmpAndBranch(CIntermediateCode *tempi,Bool has_result,I64 ip,
|
||||
|
||||
j=a2->disp;
|
||||
if (a2->type&MDF_IMM && MIN_I32<=j<=MAX_I32) {
|
||||
if (!has_result && a1->type&MDG_REG_DISP_SIB_RIP)
|
||||
if (!has_res && a1->type&MDG_REG_DISP_SIB_RIP)
|
||||
ICAddSubEctImm(tempi,a1->type,a1->reg,a1->disp,
|
||||
a1->type,a1->reg,a1->disp,j,0x073B,ip2);
|
||||
else {
|
||||
@@ -525,12 +526,12 @@ U0 ICCmpAndBranch(CIntermediateCode *tempi,Bool has_result,I64 ip,
|
||||
}
|
||||
}
|
||||
}
|
||||
if (has_result) {
|
||||
if (has_res) {
|
||||
if (!swap) {
|
||||
ICMov(tempi,MDF_REG+RT_I64,REG_RCX,0,MDF_IMM+RT_I64,0,j,ip2);
|
||||
result_reg=REG_RCX;
|
||||
res_reg=REG_RCX;
|
||||
} else
|
||||
result_reg=r1;
|
||||
res_reg=r1;
|
||||
}
|
||||
} else {
|
||||
done=FALSE;
|
||||
@@ -538,7 +539,7 @@ U0 ICCmpAndBranch(CIntermediateCode *tempi,Bool has_result,I64 ip,
|
||||
r1=a1->reg;
|
||||
r2=a2->reg;
|
||||
t2=a2->type;
|
||||
if (t2.raw_type>=RT_I64 && !has_result && t2&MDG_DISP_SIB_RIP) {
|
||||
if (t2.raw_type>=RT_I64 && !has_res && t2&MDG_DISP_SIB_RIP) {
|
||||
if (!(t1&MDF_REG) || t1.raw_type<RT_I64) {
|
||||
ICMov(tempi,MDF_REG+RT_I64,REG_RAX,0,a1->type,a1->reg,a1->disp,ip2);
|
||||
r1=REG_RAX;
|
||||
@@ -562,8 +563,8 @@ U0 ICCmpAndBranch(CIntermediateCode *tempi,Bool has_result,I64 ip,
|
||||
ICRex(tempi,i.u8[1]);
|
||||
ICU16(tempi,i.u8[2]<<8+0x39);
|
||||
ICModr2(tempi,i,a1->disp,ip2+4);
|
||||
if (has_result)
|
||||
result_reg=r2;
|
||||
if (has_res)
|
||||
res_reg=r2;
|
||||
done=TRUE;
|
||||
}
|
||||
if (!done) {
|
||||
@@ -584,8 +585,8 @@ U0 ICCmpAndBranch(CIntermediateCode *tempi,Bool has_result,I64 ip,
|
||||
if (r1>7)
|
||||
i+=4;
|
||||
ICU24(tempi,0xC03B00+i+(r2&7)<<16+(r1&7)<<19);
|
||||
if (has_result)
|
||||
result_reg=r2;
|
||||
if (has_res)
|
||||
res_reg=r2;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -626,9 +627,9 @@ U0 ICCmpAndBranch(CIntermediateCode *tempi,Bool has_result,I64 ip,
|
||||
ICU16(tempi,is.u16[0]);
|
||||
ICU32(tempi,i);
|
||||
}
|
||||
if (has_result)
|
||||
if (has_res)
|
||||
ICMov(tempi,tempi->r.type,tempi->r.reg,tempi->r.disp,
|
||||
MDF_REG+RT_I64,result_reg,0,ip2);
|
||||
MDF_REG+RT_I64,res_reg,0,ip2);
|
||||
}
|
||||
|
||||
U0 ICTestAndBranch(CIntermediateCode *tempi,I64 ip,I64 is,U8 *buf,I64 ip2)
|
||||
|
||||
+3
-3
@@ -541,7 +541,7 @@ U0 ICAndEqu(CIntermediateCode *tempi,I64 ip2)
|
||||
{
|
||||
I64 i,bit;
|
||||
if (tempi->a2.type&MDF_IMM && !(tempi->a1.type&MDF_STK) &&
|
||||
tempi->ic_flags&ICF_NO_DEPEND_RESULT) {
|
||||
tempi->ic_flags&ICF_RES_NOT_USED) {
|
||||
i=~tempi->a2.disp;
|
||||
bit=Bsf(i);
|
||||
if (0<=bit==Bsr(i)) {
|
||||
@@ -562,7 +562,7 @@ U0 ICOrEqu(CIntermediateCode *tempi,I64 ip2)
|
||||
{
|
||||
I64 i,bit;
|
||||
if (tempi->a2.type&MDF_IMM && !(tempi->a1.type&MDF_STK) &&
|
||||
tempi->ic_flags&ICF_NO_DEPEND_RESULT) {
|
||||
tempi->ic_flags&ICF_RES_NOT_USED) {
|
||||
i=tempi->a2.disp;
|
||||
bit=Bsf(i);
|
||||
if (0<=bit==Bsr(i) && i>MAX_I8) {
|
||||
@@ -583,7 +583,7 @@ U0 ICXorEqu(CIntermediateCode *tempi,I64 ip2)
|
||||
{
|
||||
I64 i,bit;
|
||||
if (tempi->a2.type&MDF_IMM && !(tempi->a1.type&MDF_STK) &&
|
||||
tempi->ic_flags&ICF_NO_DEPEND_RESULT) {
|
||||
tempi->ic_flags&ICF_RES_NOT_USED) {
|
||||
i=tempi->a2.disp;
|
||||
bit=Bsf(i);
|
||||
if (0<=bit==Bsr(i)) {
|
||||
|
||||
+45
-45
@@ -4,7 +4,7 @@ RAX,RBX,RCX and RDX can be clobbered by
|
||||
each intermediate code's output code.
|
||||
However, intermediate codes must be
|
||||
coupled together based on the arg and
|
||||
result type specifications in the
|
||||
res type specifications in the
|
||||
$LK,"CICArg",A="MN:CICArg"$. RAX is the most common reg
|
||||
for coupling intermediate codes.
|
||||
|
||||
@@ -94,9 +94,9 @@ U0 ICAddRSP(CIntermediateCode *tempi,I64 i,Bool optimize=TRUE)
|
||||
if (tempi==tempil1) {
|
||||
tempi->ic_cnt=tempi->ic_last_cnt;
|
||||
i+=j;
|
||||
} else if (!(tempi->ic_flags&ICF_PREVIOUS_DELETED)) {
|
||||
tempil1->ic_flags|=ICF_DEL_PREVIOUS_INS;
|
||||
tempi->ic_flags=tempi->ic_flags&~ICF_CODE_FINAL|ICF_PREVIOUS_DELETED;
|
||||
} else if (!(tempi->ic_flags&ICF_PREV_DELETED)) {
|
||||
tempil1->ic_flags|=ICF_DEL_PREV_INS;
|
||||
tempi->ic_flags=tempi->ic_flags&~ICF_CODE_FINAL|ICF_PREV_DELETED;
|
||||
i+=j;
|
||||
}
|
||||
}
|
||||
@@ -137,81 +137,81 @@ extern U0 ICMov(CIntermediateCode *tempi,
|
||||
#define MODR_RIP_REL 7
|
||||
|
||||
I64 ICModr1(I64 r,CICType t2,I64 r2,I64 d2)
|
||||
{//result.u8[0] is type
|
||||
//result.u8[1] is REX
|
||||
//result.u8[2] is ModR
|
||||
//result.u8[3] is SIB
|
||||
I64 result=0;
|
||||
{//res.u8[0] is type
|
||||
//res.u8[1] is REX
|
||||
//res.u8[2] is ModR
|
||||
//res.u8[3] is SIB
|
||||
I64 res=0;
|
||||
if (t2.raw_type<RT_I64)
|
||||
result.u8[1]=0x40;
|
||||
res.u8[1]=0x40;
|
||||
else
|
||||
result.u8[1]=0x48;
|
||||
res.u8[1]=0x48;
|
||||
if (r>7) {
|
||||
result.u8[1]+=4;
|
||||
res.u8[1]+=4;
|
||||
r&=7;
|
||||
}
|
||||
switch (Bsr(t2)) {
|
||||
case MDf_REG:
|
||||
if (r2>7) {
|
||||
result.u8[1]++;
|
||||
res.u8[1]++;
|
||||
r2&=7;
|
||||
}
|
||||
result.u8[2]=0xC0+r<<3+r2;
|
||||
result.u8[0]=MODR_REG;
|
||||
if (result.u8[1]==0x40 && (t2.raw_type>=RT_I16 || r<4 && r2<4))
|
||||
result.u8[1]=0;
|
||||
res.u8[2]=0xC0+r<<3+r2;
|
||||
res.u8[0]=MODR_REG;
|
||||
if (res.u8[1]==0x40 && (t2.raw_type>=RT_I16 || r<4 && r2<4))
|
||||
res.u8[1]=0;
|
||||
break;
|
||||
case MDf_DISP:
|
||||
if (r2>7) {
|
||||
result.u8[1]++;
|
||||
res.u8[1]++;
|
||||
r2&=7;
|
||||
}
|
||||
if (!d2 && r2!=REG_RBP) {
|
||||
result.u8[2]=r<<3+r2;
|
||||
result.u8[0]=MODR_INDIRECT_REG;
|
||||
res.u8[2]=r<<3+r2;
|
||||
res.u8[0]=MODR_INDIRECT_REG;
|
||||
} else if (MIN_I8<=d2<=MAX_I8) {
|
||||
result.u8[2]=0x40+r<<3+r2;
|
||||
result.u8[0]=MODR_D8_INDIRECT_REG;
|
||||
res.u8[2]=0x40+r<<3+r2;
|
||||
res.u8[0]=MODR_D8_INDIRECT_REG;
|
||||
} else {
|
||||
result.u8[2]=0x80+r<<3+r2;
|
||||
result.u8[0]=MODR_D32_INDIRECT_REG;
|
||||
res.u8[2]=0x80+r<<3+r2;
|
||||
res.u8[0]=MODR_D32_INDIRECT_REG;
|
||||
}
|
||||
if (result.u8[1]==0x40 && (t2.raw_type>=RT_I16 || r<4))
|
||||
result.u8[1]=0;
|
||||
if (res.u8[1]==0x40 && (t2.raw_type>=RT_I16 || r<4))
|
||||
res.u8[1]=0;
|
||||
break;
|
||||
case MDf_SIB:
|
||||
if (7<r2.u8[0]<REG_NONE)
|
||||
result.u8[1]++;
|
||||
res.u8[1]++;
|
||||
if (r2.u8[1]&15>7)
|
||||
result.u8[1]+=2;
|
||||
res.u8[1]+=2;
|
||||
if (r2.u8[0]==REG_NONE) {
|
||||
result.u8[3]=5+(r2.u8[1]&7)<<3+r2.u8[1]&0xC0;
|
||||
result.u8[2]=4+r<<3;
|
||||
result.u8[0]=MODR_SIB_D32_INDIRECT_REG;
|
||||
res.u8[3]=5+(r2.u8[1]&7)<<3+r2.u8[1]&0xC0;
|
||||
res.u8[2]=4+r<<3;
|
||||
res.u8[0]=MODR_SIB_D32_INDIRECT_REG;
|
||||
} else {
|
||||
result.u8[3]=r2.u8[0]&7+(r2.u8[1]&7)<<3+r2.u8[1]&0xC0;
|
||||
res.u8[3]=r2.u8[0]&7+(r2.u8[1]&7)<<3+r2.u8[1]&0xC0;
|
||||
if (!d2 && r2.u8[0]&7!=REG_RBP) {
|
||||
result.u8[2]=4+r<<3;
|
||||
result.u8[0]=MODR_SIB_INDIRECT_REG;
|
||||
res.u8[2]=4+r<<3;
|
||||
res.u8[0]=MODR_SIB_INDIRECT_REG;
|
||||
} else if (MIN_I8<=d2<=MAX_I8) {
|
||||
result.u8[2]=0x44+r<<3;
|
||||
result.u8[0]=MODR_SIB_D8_INDIRECT_REG;
|
||||
res.u8[2]=0x44+r<<3;
|
||||
res.u8[0]=MODR_SIB_D8_INDIRECT_REG;
|
||||
} else {
|
||||
result.u8[2]=0x84+r<<3;
|
||||
result.u8[0]=MODR_SIB_D32_INDIRECT_REG;
|
||||
res.u8[2]=0x84+r<<3;
|
||||
res.u8[0]=MODR_SIB_D32_INDIRECT_REG;
|
||||
}
|
||||
}
|
||||
if (result.u8[1]==0x40 && (t2.raw_type>=RT_I16 || r<4))
|
||||
result.u8[1]=0;
|
||||
if (res.u8[1]==0x40 && (t2.raw_type>=RT_I16 || r<4))
|
||||
res.u8[1]=0;
|
||||
break;
|
||||
case MDf_RIP_DISP32:
|
||||
result.u8[2]=0x05+r<<3;
|
||||
result.u8[0]=MODR_RIP_REL;
|
||||
if (result.u8[1]==0x40 && (t2.raw_type>=RT_I16 || r<4))
|
||||
result.u8[1]=0;
|
||||
res.u8[2]=0x05+r<<3;
|
||||
res.u8[0]=MODR_RIP_REL;
|
||||
if (res.u8[1]==0x40 && (t2.raw_type>=RT_I16 || r<4))
|
||||
res.u8[1]=0;
|
||||
break;
|
||||
}
|
||||
return result;
|
||||
return res;
|
||||
}
|
||||
|
||||
U0 ICModr2(CIntermediateCode *tempi,I64 i,I64 d,I64 ip=0)
|
||||
|
||||
@@ -3,7 +3,7 @@ U0 LexPutToken(CCmpCtrl *cc)
|
||||
'"';
|
||||
if (cc->token==TK_IDENT || cc->token==TK_STR)
|
||||
"%s",cc->cur_str;
|
||||
else if (cc->token==TK_INT)
|
||||
else if (cc->token==TK_I64)
|
||||
"INT:%X",cc->cur_i64;
|
||||
else if (cc->token==TK_CHAR_CONST)
|
||||
"U8:%X",cc->cur_i64;
|
||||
@@ -219,21 +219,19 @@ U0 ICPut(CCmpCtrl *cc,CIntermediateCode *tempi)
|
||||
"[unsigned] ";
|
||||
if (tempi->ic_flags & ICF_USE_INT)
|
||||
"[int] ";
|
||||
if (tempi->ic_flags & ICF_NO_DEPEND_RESULT)
|
||||
"-DEP ";
|
||||
if (tempi->ic_flags & ICF_DEPEND_RESULT)
|
||||
"+DEP ";
|
||||
if (tempi->ic_flags & ICF_RES_NOT_USED)
|
||||
"NO_RES ";
|
||||
if (tempi->ic_flags & ICF_BY_VAL)
|
||||
"BY_VAL ";
|
||||
if (tempi->ic_flags & ICF_PUSH_RESULT)
|
||||
if (tempi->ic_flags & ICF_PUSH_RES)
|
||||
"PUSH ";
|
||||
if (tempi->ic_flags & ICF_PUSH_CMP)
|
||||
"PUSH_CMP ";
|
||||
if (tempi->ic_flags & ICF_POP_CMP)
|
||||
"POP_CMP ";
|
||||
if (tempi->ic_flags & ICF_DEL_PREVIOUS_INS)
|
||||
if (tempi->ic_flags & ICF_DEL_PREV_INS)
|
||||
"DEL_PREV ";
|
||||
if (tempi->ic_flags & ICF_PREVIOUS_DELETED)
|
||||
if (tempi->ic_flags & ICF_PREV_DELETED)
|
||||
"PREV_DEL ";
|
||||
for (i=0;i<3;i++) {
|
||||
if (Bt(&tempi->ic_flags,ICf_DONT_PUSH_FLOAT0+i))
|
||||
|
||||
+22
-22
@@ -33,58 +33,58 @@ I64 HashEntrySize(CHashSrcSym *temph)
|
||||
I64 HashEntrySize2(CHashSrcSym *temph)
|
||||
{//Memory size of a std system hash entry.
|
||||
CDbgInfo *dbg_info;
|
||||
I64 result=MSize2(temph);
|
||||
I64 res=MSize2(temph);
|
||||
if (!(temph->type&HTT_DICT_WORD))
|
||||
result+=MSize2(temph->str);
|
||||
res+=MSize2(temph->str);
|
||||
if (temph->type & HTG_SRC_SYM) {
|
||||
result+=MSize2(temph->src_link);
|
||||
result+=MSize2(temph->index);
|
||||
result+=MSize2(temph->import_name);
|
||||
result+=LinkedLstSize(temph->ie_lst);
|
||||
res+=MSize2(temph->src_link);
|
||||
res+=MSize2(temph->idx);
|
||||
res+=MSize2(temph->import_name);
|
||||
res+=LinkedLstSize(temph->ie_lst);
|
||||
if (temph->type & (HTT_FUN | HTT_EXPORT_SYS_SYM))
|
||||
result+=MSize2(temph->dbg_info);
|
||||
res+=MSize2(temph->dbg_info);
|
||||
if (temph->type & HTT_CLASS)
|
||||
result+=MemberLstSize(temph);
|
||||
res+=MemberLstSize(temph);
|
||||
else if (temph->type & HTT_FUN) {
|
||||
result+=MemberLstSize(temph);
|
||||
res+=MemberLstSize(temph);
|
||||
if (dbg_info=temph->dbg_info)
|
||||
//This should be $LK,"MSize",A="MN:MSize"$() but it would crash on AOT .BIN.Z file funs.
|
||||
result+=dbg_info->body[dbg_info->max_line+1-dbg_info->min_line]
|
||||
res+=dbg_info->body[dbg_info->max_line+1-dbg_info->min_line]
|
||||
-dbg_info->body[0];
|
||||
} else if (temph->type&HTT_DEFINE_STR)
|
||||
result+=MSize2(temph(CHashDefineStr *)->data);
|
||||
res+=MSize2(temph(CHashDefineStr *)->data);
|
||||
else if (temph->type & HTT_GLBL_VAR) {
|
||||
result+=LinkedLstSize(temph(CHashGlblVar *)->dim.next);
|
||||
res+=LinkedLstSize(temph(CHashGlblVar *)->dim.next);
|
||||
if (!(temph(CHashGlblVar *)->flags&GVF_ALIAS))
|
||||
result+=MSize2(temph(CHashGlblVar *)->data_addr);
|
||||
res+=MSize2(temph(CHashGlblVar *)->data_addr);
|
||||
if (temph(CHashGlblVar *)->fun_ptr)
|
||||
result+=HashEntrySize2(temph(CHashGlblVar *)->fun_ptr
|
||||
res+=HashEntrySize2(temph(CHashGlblVar *)->fun_ptr
|
||||
-temph(CHashGlblVar *)->fun_ptr->ptr_stars_cnt);
|
||||
}
|
||||
} else if (temph->type & HTT_FILE)
|
||||
result+=MSize2(temph(CHashGeneric *)->user_data0);
|
||||
res+=MSize2(temph(CHashGeneric *)->user_data0);
|
||||
else if (temph->type & HTT_MODULE &&
|
||||
StrCmp(temph->str,KERNEL_MODULE_NAME))
|
||||
result+=MSize2(temph(CHashGeneric *)->user_data0);
|
||||
return result;
|
||||
res+=MSize2(temph(CHashGeneric *)->user_data0);
|
||||
return res;
|
||||
}
|
||||
|
||||
I64 HashTableSize2(CHashTable *table)
|
||||
{//Memory size of std system hash table and all entries.
|
||||
I64 i,result=0;
|
||||
I64 i,res=0;
|
||||
CHashSrcSym *temph;
|
||||
if (!table)
|
||||
return 0;
|
||||
for (i=0;i<=table->mask;i++) {
|
||||
temph=table->body[i];
|
||||
while (temph) {
|
||||
result+=HashEntrySize2(temph);
|
||||
res+=HashEntrySize2(temph);
|
||||
temph=temph->next;
|
||||
}
|
||||
}
|
||||
result+=MSize2(table->body);
|
||||
result+=MSize2(table);
|
||||
return result;
|
||||
res+=MSize2(table->body);
|
||||
res+=MSize2(table);
|
||||
return res;
|
||||
}
|
||||
|
||||
U0 MapFileWrite(CHashTable *h,U8 *map_name,U8 drv_let)
|
||||
|
||||
+1
-1
@@ -225,7 +225,7 @@ U0 CmpLoadDefines()
|
||||
DefineLstLoad("ST_MM_REGS","MM0\0MM1\0MM2\0MM3\0MM4\0MM5\0MM6\0MM7\0");
|
||||
DefineLstLoad("ST_XMM_REGS",
|
||||
"XMM0\0XMM1\0XMM2\0XMM3\0XMM4\0XMM5\0XMM6\0XMM7\0");
|
||||
DefineLstLoad("ST_ARG_TYPES","NO\0REL8\0REL16\0REL32\0"
|
||||
DefineLstLoad("ST_ARG_TYPES","NONE\0REL8\0REL16\0REL32\0"
|
||||
"IMM8\0IMM16\0IMM32\0IMM64\0UIMM8\0UIMM16\0UIMM32\0UIMM64\0"
|
||||
"R8\0R16\0R32\0R64\0RM8\0RM16\0RM32\0RM64\0"
|
||||
"M8\0M16\0M32\0M64\0M1632\0M16N32\0M16N16\0M32N32\0"
|
||||
|
||||
+55
-55
@@ -1,6 +1,6 @@
|
||||
U8 *LexStmt2Bin(CCmpCtrl *cc,I64 *_type,I64 cmp_flags=0)
|
||||
{//Compile one cc stmt to bin code.
|
||||
I64 size,i,j,k,*result=INVALID_PTR;
|
||||
I64 size,i,j,k,*res=INVALID_PTR;
|
||||
CCodeCtrl *tempcbh;
|
||||
if (_type) *_type=RT_I64;
|
||||
Btr(&cc->flags,CCf_PASS_TRACE_PRESENT);
|
||||
@@ -9,17 +9,17 @@ U8 *LexStmt2Bin(CCmpCtrl *cc,I64 *_type,I64 cmp_flags=0)
|
||||
COCInit(cc);
|
||||
if (!PrsStmt(cc,,,cmp_flags)) {
|
||||
if (cc->coc.coc_root.next!=&cc->coc.coc_root) {
|
||||
cc->coc.coc_root.last->ic_flags&=~ICF_NO_DEPEND_RESULT;
|
||||
cc->coc.coc_root.last->ic_flags&=~ICF_RES_NOT_USED;
|
||||
ICAdd(cc,IC_RETURN_VAL2,0,0);
|
||||
ICAdd(cc,IC_RET,0,0);
|
||||
if (result=COCCompile(cc,&size,NULL,_type)) {
|
||||
if (res=COCCompile(cc,&size,NULL,_type)) {
|
||||
if (cc->flags&CCF_AOT_COMPILE) {
|
||||
j=cc->aotc->ip;
|
||||
k=(size+7)>>3;
|
||||
for (i=0;i<k;i++)
|
||||
AOTStoreCodeU64(cc,result[i]);
|
||||
Free(result);
|
||||
result=j;
|
||||
AOTStoreCodeU64(cc,res[i]);
|
||||
Free(res);
|
||||
res=j;
|
||||
}
|
||||
}
|
||||
} //TODO: else del misc?
|
||||
@@ -29,7 +29,7 @@ U8 *LexStmt2Bin(CCmpCtrl *cc,I64 *_type,I64 cmp_flags=0)
|
||||
tempcbh=COCPopNoFree(cc);
|
||||
COCAppend(cc,tempcbh);
|
||||
}
|
||||
return result;
|
||||
return res;
|
||||
}
|
||||
|
||||
CAOT *CmpJoin(CCmpCtrl *cc,I64 cmp_flags,U8 *map_name=NULL,U8 mapfile_drv_let=0)
|
||||
@@ -41,15 +41,15 @@ CAOT *CmpJoin(CCmpCtrl *cc,I64 cmp_flags,U8 *map_name=NULL,U8 mapfile_drv_let=0)
|
||||
CAOTImportExport *tempie;
|
||||
Bool okay=TRUE;
|
||||
CLexHashTableContext *htc=MAlloc(sizeof(CLexHashTableContext));
|
||||
CAOT *result=CAlloc(sizeof(CAOT)),*parent;
|
||||
CAOT *res=CAlloc(sizeof(CAOT)),*parent;
|
||||
if (parent=cc->aot) {
|
||||
result->parent_aot=parent;
|
||||
QueIns(result,parent->last);
|
||||
res->parent_aot=parent;
|
||||
QueIns(res,parent->last);
|
||||
} else
|
||||
QueInit(result);
|
||||
cc->aot=result;
|
||||
QueInit(res);
|
||||
cc->aot=res;
|
||||
|
||||
result->next_ie=result->last_ie=&result->next_ie;
|
||||
res->next_ie=res->last_ie=&res->next_ie;
|
||||
cc->aotc=aotc=CAlloc(sizeof(CAOTCtrl));
|
||||
cc->aot_depth++;
|
||||
|
||||
@@ -86,14 +86,14 @@ CAOT *CmpJoin(CCmpCtrl *cc,I64 cmp_flags,U8 *map_name=NULL,U8 mapfile_drv_let=0)
|
||||
tempie=CAlloc(sizeof(CAOTImportExport));
|
||||
tempie->type=IET_MAIN;
|
||||
tempie->ip=buf;
|
||||
QueIns(tempie,result->last_ie);
|
||||
QueIns(tempie,res->last_ie);
|
||||
}
|
||||
if (cmp_flags&CMPF_ASM_BLK)
|
||||
break;
|
||||
}
|
||||
} else
|
||||
PrsStmt(cc,,,cmp_flags);
|
||||
AOTGlblsResolve(cc,result);
|
||||
AOTGlblsResolve(cc,res);
|
||||
} catch {
|
||||
if (Fs->except_ch=='Compiler' && !(cmp_flags&CMPF_ASM_BLK)) {
|
||||
LexPutPos(cc);
|
||||
@@ -104,10 +104,10 @@ CAOT *CmpJoin(CCmpCtrl *cc,I64 cmp_flags,U8 *map_name=NULL,U8 mapfile_drv_let=0)
|
||||
if (!okay) {
|
||||
if (cc->error_cnt<1)
|
||||
cc->error_cnt=1;
|
||||
cc->aot=result->parent_aot;
|
||||
Free(result);
|
||||
cc->aot=res->parent_aot;
|
||||
Free(res);
|
||||
LinkedLstDel(aotc->bin);
|
||||
result=NULL;
|
||||
res=NULL;
|
||||
} else {
|
||||
if (map_name)
|
||||
MapFileWrite(cc->htc.glbl_hash_table,map_name,mapfile_drv_let);
|
||||
@@ -115,17 +115,17 @@ CAOT *CmpJoin(CCmpCtrl *cc,I64 cmp_flags,U8 *map_name=NULL,U8 mapfile_drv_let=0)
|
||||
HashTableDel(cc->htc.glbl_hash_table);
|
||||
|
||||
if (!aotc->num_bin_U8s)
|
||||
result->buf=NULL;
|
||||
res->buf=NULL;
|
||||
else {
|
||||
if (cc->flags&CCF_AOT_COMPILE)
|
||||
result->buf=MAlloc(aotc->num_bin_U8s);
|
||||
res->buf=MAlloc(aotc->num_bin_U8s);
|
||||
else {
|
||||
if (aotc->module_org==INVALID_PTR)
|
||||
result->buf=MAlloc(aotc->num_bin_U8s,Fs->code_heap);
|
||||
res->buf=MAlloc(aotc->num_bin_U8s,Fs->code_heap);
|
||||
else
|
||||
result->buf=aotc->module_org;
|
||||
res->buf=aotc->module_org;
|
||||
}
|
||||
result->aot_U8s=aotc->num_bin_U8s;
|
||||
res->aot_U8s=aotc->num_bin_U8s;
|
||||
tempbin=aotc->bin;
|
||||
j=0;
|
||||
l=aotc->num_bin_U8s;
|
||||
@@ -133,17 +133,17 @@ CAOT *CmpJoin(CCmpCtrl *cc,I64 cmp_flags,U8 *map_name=NULL,U8 mapfile_drv_let=0)
|
||||
i=l;
|
||||
if (i>AOT_BIN_BLK_SIZE)
|
||||
i=AOT_BIN_BLK_SIZE;
|
||||
MemCpy(result->buf+j,tempbin->body,i);
|
||||
MemCpy(res->buf+j,tempbin->body,i);
|
||||
j+=i;
|
||||
l-=i;
|
||||
tempbin=tempbin->next;
|
||||
}
|
||||
}
|
||||
LinkedLstDel(aotc->bin);
|
||||
result->abss=aotc->abss;
|
||||
result->heap_glbls=aotc->heap_glbls;
|
||||
result->max_align_bits=aotc->max_align_bits;
|
||||
result->module_org=aotc->module_org;
|
||||
res->abss=aotc->abss;
|
||||
res->heap_glbls=aotc->heap_glbls;
|
||||
res->max_align_bits=aotc->max_align_bits;
|
||||
res->module_org=aotc->module_org;
|
||||
}
|
||||
cc->aot=parent;
|
||||
MemCpy(&cc->htc,htc,sizeof(CLexHashTableContext));
|
||||
@@ -151,24 +151,24 @@ CAOT *CmpJoin(CCmpCtrl *cc,I64 cmp_flags,U8 *map_name=NULL,U8 mapfile_drv_let=0)
|
||||
Free(aotc);
|
||||
cc->aotc=old_aot;
|
||||
cc->aot_depth--;
|
||||
return result;
|
||||
return res;
|
||||
}
|
||||
|
||||
CAOT *CmpBuf(U8 *buf,U8 *map_name=NULL,
|
||||
I64 *error_cnt=NULL, I64 *warning_cnt=NULL,U8 mapfile_drv_let=0)
|
||||
{
|
||||
CCmpCtrl *cc;
|
||||
CAOT *result=NULL;
|
||||
CAOT *res=NULL;
|
||||
cc=CmpCtrlNew(buf,CCF_DONT_FREE_BUF);
|
||||
cc->flags|=CCF_AOT_COMPILE;
|
||||
QueIns(cc,Fs->last_lex);
|
||||
result=CmpJoin(cc,CMPF_LEX_FIRST,map_name,mapfile_drv_let);
|
||||
res=CmpJoin(cc,CMPF_LEX_FIRST,map_name,mapfile_drv_let);
|
||||
if (error_cnt) *error_cnt=cc->error_cnt;
|
||||
if (warning_cnt) *warning_cnt=cc->warning_cnt;
|
||||
QueRem(cc);
|
||||
if (result)
|
||||
if (res)
|
||||
CmpCtrlDel(cc);
|
||||
return result;
|
||||
return res;
|
||||
}
|
||||
|
||||
U0 CmpFixUpJITAsm(CCmpCtrl *cc,CAOT *tempaot)
|
||||
@@ -571,7 +571,7 @@ I64 Cmp(U8 *filename,U8 *map_name=NULL,U8 *out_name=NULL,U8 mapfile_drv_let=0)
|
||||
I64 ExePutS(U8 *buf,U8 *filename=NULL,
|
||||
Bool just_load=FALSE,CLexHashTableContext *htc=NULL)
|
||||
{//JIT Compile and execute text from a puts("").
|
||||
I64 result;
|
||||
I64 res;
|
||||
Bool okay=TRUE;
|
||||
CCmpCtrl *cc;
|
||||
if (!filename)
|
||||
@@ -590,43 +590,43 @@ I64 ExePutS(U8 *buf,U8 *filename=NULL,
|
||||
QueIns(cc,Fs->last_lex);
|
||||
try {
|
||||
Lex(cc);
|
||||
result=ExeCmdLine(cc);
|
||||
res=ExeCmdLine(cc);
|
||||
} catch {
|
||||
if (Fs->except_ch=='Compiler' || Fs->except_ch=='Break') {
|
||||
Fs->catch_except=TRUE;
|
||||
okay=FALSE;
|
||||
result=0;
|
||||
res=0;
|
||||
}
|
||||
}
|
||||
QueRem(cc);
|
||||
if (okay)
|
||||
CmpCtrlDel(cc); //TODO: can crash
|
||||
return result;
|
||||
return res;
|
||||
}
|
||||
|
||||
I64 ExePrint(U8 *fmt,...)
|
||||
{//JIT Compile and execute text from a printf().
|
||||
I64 result;
|
||||
I64 res;
|
||||
U8 *buf=StrPrintJoin(NULL,fmt,argc,argv);
|
||||
result=ExePutS(buf);
|
||||
res=ExePutS(buf);
|
||||
Free(buf);
|
||||
return result;
|
||||
return res;
|
||||
}
|
||||
|
||||
I64 ExeFile(U8 *name,Bool just_load=FALSE)
|
||||
{//JIT Compile and execute a file.
|
||||
I64 result;
|
||||
I64 res;
|
||||
U8 *name2=DftExt(name,"CPP.Z"),
|
||||
*st=MStrPrint("#include \"%s\";",name2);
|
||||
result=ExePutS(st,name,just_load);
|
||||
res=ExePutS(st,name,just_load);
|
||||
Free(st);
|
||||
Free(name2);
|
||||
return result;
|
||||
return res;
|
||||
}
|
||||
|
||||
I64 ExePutS2(U8 *buf,U8 *filename=NULL,Bool just_load=FALSE)
|
||||
{//throws exceptions
|
||||
I64 result;
|
||||
I64 res;
|
||||
CCmpCtrl *cc;
|
||||
if (!filename)
|
||||
filename=blkdev.temp_filename;
|
||||
@@ -637,35 +637,35 @@ I64 ExePutS2(U8 *buf,U8 *filename=NULL,Bool just_load=FALSE)
|
||||
cc->opts=Fs->last_lex->opts;
|
||||
QueIns(cc,Fs->last_lex);
|
||||
Lex(cc);
|
||||
result=ExeCmdLine(cc);
|
||||
res=ExeCmdLine(cc);
|
||||
QueRem(cc);
|
||||
CmpCtrlDel(cc);
|
||||
return result;
|
||||
return res;
|
||||
}
|
||||
|
||||
I64 ExePrint2(U8 *fmt,...)
|
||||
{//throws exceptions
|
||||
I64 result;
|
||||
I64 res;
|
||||
U8 *buf=StrPrintJoin(NULL,fmt,argc,argv);
|
||||
result=ExePutS2(buf);
|
||||
res=ExePutS2(buf);
|
||||
Free(buf);
|
||||
return result;
|
||||
return res;
|
||||
}
|
||||
|
||||
I64 ExeFile2(U8 *name,Bool just_load=FALSE)
|
||||
{//throws exceptions
|
||||
I64 result;
|
||||
I64 res;
|
||||
U8 *name2=DftExt(name,"CPP.Z"),*st=MStrPrint("#include \"%s\";",name2);
|
||||
result=ExePutS2(st,name,just_load);
|
||||
res=ExePutS2(st,name,just_load);
|
||||
Free(st);
|
||||
Free(name2);
|
||||
return result;
|
||||
return res;
|
||||
}
|
||||
|
||||
I64 StreamExePrint(U8 *fmt,...)
|
||||
{//Causes value from stream to be used in an #exe{} block.
|
||||
U8 *buf=StrPrintJoin(NULL,fmt,argc,argv);
|
||||
I64 result=0;
|
||||
I64 res=0;
|
||||
CLexHashTableContext *htc;
|
||||
CCmpCtrl *cc=Fs->last_lex;
|
||||
if (cc==&Fs->next_lex)
|
||||
@@ -674,10 +674,10 @@ I64 StreamExePrint(U8 *fmt,...)
|
||||
if (!(cc->flags&CCF_EXE_BLK))
|
||||
LexExcept(cc,"StreamExePrint only allowed in AOT compiled #exe{} mode.");
|
||||
if (htc=cc->htc.next)
|
||||
result=ExePutS(buf,,,htc);
|
||||
res=ExePutS(buf,,,htc);
|
||||
}
|
||||
Free(buf);
|
||||
return result;
|
||||
return res;
|
||||
}
|
||||
|
||||
U0 CInit()
|
||||
|
||||
+9
-9
@@ -88,7 +88,7 @@ CD3I32 *LexD3I32(CCmpCtrl *cc,CD3I32 *p)
|
||||
U8 *CmdLinePmt()
|
||||
{
|
||||
I64 i;
|
||||
U8 *result,*st;
|
||||
U8 *res,*st;
|
||||
if (Fs->new_answer) {
|
||||
if (Fs->answer_type==RT_F64)
|
||||
"%8.6fs ansf=%15.7g\n",Fs->answer_time,Fs->answer;
|
||||
@@ -106,17 +106,17 @@ U8 *CmdLinePmt()
|
||||
st=GetStr(,,GSF_SHIFT_ESC_EXIT);
|
||||
|
||||
i=StrLen(st);
|
||||
result=MAlloc(i+1+2);
|
||||
MemCpy(result,st,i+1);
|
||||
res=MAlloc(i+1+2);
|
||||
MemCpy(res,st,i+1);
|
||||
i--;
|
||||
while (i>=0 && Bt(chars_bmp_white_space,result[i]))
|
||||
while (i>=0 && Bt(chars_bmp_white_space,res[i]))
|
||||
i--;
|
||||
i++;
|
||||
if (i>0 && result[i-1]==';')
|
||||
result[i++]=';'; //The Lex goes one beyond
|
||||
result[i++]='\n';//#define goes to '\n'
|
||||
result[i]=0;
|
||||
if (i>0 && res[i-1]==';')
|
||||
res[i++]=';'; //The Lex goes one beyond
|
||||
res[i++]='\n';//#define goes to '\n'
|
||||
res[i]=0;
|
||||
|
||||
Free(st);
|
||||
return result;
|
||||
return res;
|
||||
}
|
||||
Binary file not shown.
+93
-131
@@ -1,5 +1,5 @@
|
||||
$LK,"LexPutPos",A="FL:::/Compiler/CExcept.CPP.Z,50",BI=1$
|
||||
$LK,"ICAssignPostIncDec",A="FL:::/Compiler/BackB.CPP.Z,429",BI=2$
|
||||
$LK,"ICAssignPostIncDec",A="FL:::/Compiler/BackB.CPP.Z,430",BI=2$
|
||||
$LK,"CmpSetFloatOpPushPop",A="FL:::/Compiler/BackFA.CPP.Z,62",BI=3$
|
||||
$LK,"ICFCvt2",A="FL:::/Compiler/BackFA.CPP.Z,169",BI=4$
|
||||
$LK,"CmpRawTypePointed",A="FL:::/Compiler/OptLib.CPP.Z,517",BI=5$
|
||||
@@ -17,7 +17,7 @@ $LK,"AsmLineLst",A="FL:::/Compiler/AsmLib.CPP.Z,147",BI=15$
|
||||
$LK,"ICOpSizeRex",A="FL:::/Compiler/BackLib.CPP.Z,28",BI=16$
|
||||
$LK,"CVI2",A="FL:::/Compiler/PrsVar.CPP.Z,117"$
|
||||
$LK,"ICU8",A="FL:::/Compiler/BackLib.CPP.Z,17",BI=17$
|
||||
$LK,"AsmStoreNum",A="FL:::/Compiler/Asm.CPP.Z,263",BI=18$
|
||||
$LK,"AsmStoreNum",A="FL:::/Compiler/Asm.CPP.Z,268",BI=18$
|
||||
$LK,"OptPass012",A="FL:::/Compiler/OptPass012.CPP.Z,23",BI=19$
|
||||
$LK,"MemberLstSize",A="FL:::/Compiler/LexLib.CPP.Z,191",BI=20$
|
||||
$LK,"ICQueIns",A="FL:::/Compiler/BackC.CPP.Z,355",BI=21$
|
||||
@@ -49,7 +49,7 @@ $LK,"LexPopNoRestore",A="FL:::/Compiler/LexLib.CPP.Z,38",BI=39$
|
||||
$LK,"ExePrint",A="FL:::/Compiler/CMain.CPP.Z,607",BI=40$
|
||||
$LK,"SLASH_OP_NEG",A="FL:::/Compiler/BackLib.CPP.Z,251"$
|
||||
$LK,"PrsVarLst",A="FL:::/Compiler/PrsVar.CPP.Z,416",BI=41$
|
||||
$LK,"PrsAsmDefine",A="FL:::/Compiler/Asm.CPP.Z,809",BI=42$
|
||||
$LK,"PrsAsmDefine",A="FL:::/Compiler/Asm.CPP.Z,814",BI=42$
|
||||
$LK,"PrsAddOp",A="FL:::/Compiler/PrsExp.CPP.Z,15",BI=43$
|
||||
$LK,"LexWarn",A="FL:::/Compiler/CExcept.CPP.Z,65",BI=44$
|
||||
$LK,"PE_POP_ALL1",A="FL:::/Compiler/PrsExp.CPP.Z,12"$
|
||||
@@ -96,8 +96,8 @@ $LK,"ICLea",A="FL:::/Compiler/BackLib.CPP.Z,613",BI=73$
|
||||
$LK,"CmpBuf",A="FL:::/Compiler/CMain.CPP.Z,157",BI=74$
|
||||
$LK,"CMP_TEMPLATES_DONT_PUSH_POP",A="FL:::/Compiler/Templates.CPP.Z,394"$
|
||||
$LK,"ICAddEct",A="FL:::/Compiler/BackA.CPP.Z,1",BI=75$
|
||||
$LK,"ICToF64",A="FL:::/Compiler/BackB.CPP.Z,283",BI=76$
|
||||
$LK,"PrsBinFile",A="FL:::/Compiler/Asm.CPP.Z,883",BI=77$
|
||||
$LK,"ICToF64",A="FL:::/Compiler/BackB.CPP.Z,284",BI=76$
|
||||
$LK,"PrsBinFile",A="FL:::/Compiler/Asm.CPP.Z,888",BI=77$
|
||||
$LK,"HashTableSize2",A="FL:::/Compiler/CHash.CPP.Z,72",BI=78$
|
||||
$LK,"HashEntrySize2",A="FL:::/Compiler/CHash.CPP.Z,33",BI=79$
|
||||
$LK,"Ui",A="FL:::/Compiler/UAsm.CPP.Z,238",BI=80$
|
||||
@@ -105,14 +105,14 @@ $LK,"ICSlashOp",A="FL:::/Compiler/BackLib.CPP.Z,269",BI=81$
|
||||
$LK,"OptBrZero",A="FL:::/Compiler/OptLib.CPP.Z,230",BI=82$
|
||||
$LK,"Un",A="FL:::/Compiler/UAsm.CPP.Z,660",BI=83$
|
||||
$LK,"PrsSizeOf",A="FL:::/Compiler/PrsExp.CPP.Z,298",BI=84$
|
||||
$LK,"ICToI64",A="FL:::/Compiler/BackB.CPP.Z,277",BI=85$
|
||||
$LK,"ICToI64",A="FL:::/Compiler/BackB.CPP.Z,278",BI=85$
|
||||
$LK,"ICMod",A="FL:::/Compiler/BackA.CPP.Z,461",BI=86$
|
||||
$LK,"OptSetNOP1",A="FL:::/Compiler/OptLib.CPP.Z,17",BI=87$
|
||||
$LK,"OptPass789A",A="FL:::/Compiler/OptPass789A.CPP.Z,1",BI=88$
|
||||
$LK,"OptSetNOP2",A="FL:::/Compiler/OptLib.CPP.Z,25",BI=89$
|
||||
$LK,"FBO1_F64",A="FL:::/Compiler/OptLib.CPP.Z,94"$
|
||||
$LK,"ICXorEqu",A="FL:::/Compiler/BackC.CPP.Z,582",BI=90$
|
||||
$LK,"ICToUpper",A="FL:::/Compiler/BackB.CPP.Z,266",BI=91$
|
||||
$LK,"ICToUpper",A="FL:::/Compiler/BackB.CPP.Z,267",BI=91$
|
||||
$LK,"AsmLexExpression",A="FL:::/Compiler/AsmLib.CPP.Z,127",BI=92$
|
||||
$LK,"ICMov",A="FL:::/Compiler/BackLib.CPP.Z,430",BI=93$
|
||||
$LK,"ICNot",A="FL:::/Compiler/BackB.CPP.Z,10",BI=94$
|
||||
@@ -151,7 +151,7 @@ $LK,"ICOrEqu",A="FL:::/Compiler/BackC.CPP.Z,561",BI=118$
|
||||
$LK,"ICModr1",A="FL:::/Compiler/BackLib.CPP.Z,139",BI=119$
|
||||
$LK,"ICModr2",A="FL:::/Compiler/BackLib.CPP.Z,217",BI=120$
|
||||
$LK,"SLASH_OP_FMUL",A="FL:::/Compiler/BackLib.CPP.Z,261"$
|
||||
$LK,"ICPreIncDec",A="FL:::/Compiler/BackB.CPP.Z,304",BI=121$
|
||||
$LK,"ICPreIncDec",A="FL:::/Compiler/BackB.CPP.Z,305",BI=121$
|
||||
$LK,"PrsUnaryTerm",A="FL:::/Compiler/PrsExp.CPP.Z,588",BI=122$
|
||||
$LK,"MemberLstDel",A="FL:::/Compiler/LexLib.CPP.Z,157",BI=123$
|
||||
$LK,"SLASH_OP_FSUB",A="FL:::/Compiler/BackLib.CPP.Z,259"$
|
||||
@@ -164,7 +164,7 @@ $LK,"PE_UNARY_TERM1",A="FL:::/Compiler/PrsExp.CPP.Z,1"$
|
||||
$LK,"ICFAdd",A="FL:::/Compiler/BackFB.CPP.Z,502",BI=127$
|
||||
$LK,"PE_UNARY_TERM2",A="FL:::/Compiler/PrsExp.CPP.Z,2"$
|
||||
$LK,"CmdLinePmt",A="FL:::/Compiler/CMisc.CPP.Z,88",BI=128$
|
||||
$LK,"AsmMakeArgMask",A="FL:::/Compiler/Asm.CPP.Z,172",BI=129$
|
||||
$LK,"AsmMakeArgMask",A="FL:::/Compiler/Asm.CPP.Z,177",BI=129$
|
||||
$LK,"COCHeaderPut",A="FL:::/Compiler/PrsLib.CPP.Z,229",BI=130$
|
||||
$LK,"PrsGlblInit",A="FL:::/Compiler/PrsVar.CPP.Z,206",BI=131$
|
||||
$LK,"ICAndEqu",A="FL:::/Compiler/BackC.CPP.Z,540",BI=132$
|
||||
@@ -212,7 +212,7 @@ $LK,"ICBitOps",A="FL:::/Compiler/BackB.CPP.Z,202",BI=168$
|
||||
$LK,"lex_zeros",A="FL:::/Compiler/Lex.CPP.Z,91"$
|
||||
$LK,"CSwitchCase",A="FL:::/Compiler/PrsStmt.CPP.Z,567"$
|
||||
$LK,"AsmResolve",A="FL:::/Compiler/AsmResolve.CPP.Z,1",BI=169$
|
||||
$LK,"PrsAsmInst",A="FL:::/Compiler/Asm.CPP.Z,390",BI=170$
|
||||
$LK,"PrsAsmInst",A="FL:::/Compiler/Asm.CPP.Z,395",BI=170$
|
||||
$LK,"COCCompile",A="FL:::/Compiler/PrsLib.CPP.Z,249",BI=171$
|
||||
$LK,"Cmp",A="FL:::/Compiler/CMain.CPP.Z,419",BI=172$
|
||||
$LK,"PrsPush2",A="FL:::/Compiler/PrsLib.CPP.Z,11",BI=173$
|
||||
@@ -220,12 +220,12 @@ $LK,"ICArgPut",A="FL:::/Compiler/CExcept.CPP.Z,141",BI=174$
|
||||
$LK,"UndefinedExtern",A="FL:::/Compiler/CExcept.CPP.Z,98",BI=175$
|
||||
$LK,"OptIC4",A="FL:::/Compiler/OptPass4.CPP.Z,1",BI=176$
|
||||
$LK,"OptIC6",A="FL:::/Compiler/OptPass6.CPP.Z,1",BI=177$
|
||||
$LK,"ICCmpAndBranch",A="FL:::/Compiler/BackB.CPP.Z,468",BI=178$
|
||||
$LK,"ICCmpAndBranch",A="FL:::/Compiler/BackB.CPP.Z,469",BI=178$
|
||||
$LK,"ICDivEqu",A="FL:::/Compiler/BackA.CPP.Z,408",BI=179$
|
||||
$LK,"PrsWhile",A="FL:::/Compiler/PrsStmt.CPP.Z,482",BI=180$
|
||||
$LK,"ICFCmpAndBranch",A="FL:::/Compiler/BackFB.CPP.Z,217",BI=181$
|
||||
$LK,"Lex",A="FL:::/Compiler/Lex.CPP.Z,443",BI=182$
|
||||
$LK,"ICTestAndBranch",A="FL:::/Compiler/BackB.CPP.Z,634",BI=183$
|
||||
$LK,"ICTestAndBranch",A="FL:::/Compiler/BackB.CPP.Z,635",BI=183$
|
||||
$LK,"uasm",A="FL:::/Compiler/Compiler.PRJ.Z,21"$
|
||||
$LK,"MODR_INDIRECT_REG",A="FL:::/Compiler/BackLib.CPP.Z,131"$
|
||||
$LK,"PE_MAYBE_MODIFIERS",A="FL:::/Compiler/PrsExp.CPP.Z,3"$
|
||||
@@ -242,14 +242,14 @@ $LK,"CmpJoin",A="FL:::/Compiler/CMain.CPP.Z,35",BI=190$
|
||||
$LK,"PrsPop2",A="FL:::/Compiler/PrsLib.CPP.Z,16",BI=191$
|
||||
$LK,"CMP_TEMPLATES",A="FL:::/Compiler/Templates.CPP.Z,4"$
|
||||
$LK,"MODR_D8_INDIRECT_REG",A="FL:::/Compiler/BackLib.CPP.Z,132"$
|
||||
$LK,"PrsAsmBlk",A="FL:::/Compiler/Asm.CPP.Z,899",BI=192$
|
||||
$LK,"PrsAsmBlk",A="FL:::/Compiler/Asm.CPP.Z,904",BI=192$
|
||||
$LK,"PrsAsmArg",A="FL:::/Compiler/Asm.CPP.Z,35",BI=193$
|
||||
$LK,"LexFirstRem",A="FL:::/Compiler/Lex.CPP.Z,277",BI=194$
|
||||
$LK,"MemberClassBaseFind",A="FL:::/Compiler/LexLib.CPP.Z,87",BI=195$
|
||||
$LK,"MemberFind",A="FL:::/Compiler/LexLib.CPP.Z,67",BI=196$
|
||||
$LK,"cmp",A="FL:::/Compiler/Compiler.PRJ.Z,16"$
|
||||
$LK,"OptLag",A="FL:::/Compiler/OptLib.CPP.Z,40",BI=197$
|
||||
$LK,"ICPostIncDec",A="FL:::/Compiler/BackB.CPP.Z,345",BI=198$
|
||||
$LK,"ICPostIncDec",A="FL:::/Compiler/BackB.CPP.Z,346",BI=198$
|
||||
$LK,"ICFPostIncDec",A="FL:::/Compiler/BackFB.CPP.Z,580",BI=199$
|
||||
$LK,"ICTest",A="FL:::/Compiler/BackLib.CPP.Z,398",BI=200$
|
||||
$LK,"ICModU64",A="FL:::/Compiler/BackC.CPP.Z,464",BI=201$
|
||||
@@ -286,7 +286,7 @@ $LK,"MODR_SIB_D8_INDIRECT_REG",A="FL:::/Compiler/BackLib.CPP.Z,135"$
|
||||
$LK,"cmp_type_flags_src_code",A="FL:::/Compiler/Lex.CPP.Z,328"$
|
||||
$LK,"PrsVarInit2",A="FL:::/Compiler/PrsVar.CPP.Z,123",BI=227$
|
||||
$LK,"PrsPop",A="FL:::/Compiler/PrsLib.CPP.Z,6",BI=228$
|
||||
$LK,"asm_seg_prefixes",A="FL:::/Compiler/Asm.CPP.Z,388"$
|
||||
$LK,"asm_seg_prefixes",A="FL:::/Compiler/Asm.CPP.Z,393"$
|
||||
$LK,"ICMinMax",A="FL:::/Compiler/BackC.CPP.Z,419",BI=229$
|
||||
$LK,"CmpLoadDefines",A="FL:::/Compiler/CInit.CPP.Z,205",BI=230$
|
||||
$LK,"PrsIf",A="FL:::/Compiler/PrsStmt.CPP.Z,455",BI=231$
|
||||
@@ -297,7 +297,7 @@ $LK,"CmpFixUpJITAsm",A="FL:::/Compiler/CMain.CPP.Z,174",BI=235$
|
||||
$LK,"COCPopNoFree",A="FL:::/Compiler/PrsLib.CPP.Z,114",BI=236$
|
||||
$LK,"ParenWarning",A="FL:::/Compiler/CExcept.CPP.Z,110",BI=237$
|
||||
$LK,"PrsFunCall",A="FL:::/Compiler/PrsExp.CPP.Z,378",BI=238$
|
||||
$LK,"ICDerefPostIncDec",A="FL:::/Compiler/BackB.CPP.Z,384",BI=239$
|
||||
$LK,"ICDerefPostIncDec",A="FL:::/Compiler/BackB.CPP.Z,385",BI=239$
|
||||
$LK,"Option",A="FL:::/Compiler/CMisc.CPP.Z,1",BI=240$
|
||||
$LK,"ExeFile2",A="FL:::/Compiler/CMain.CPP.Z,655",BI=241$
|
||||
$LK,"COptMemberVar",A="FL:::/Compiler/OptLib.CPP.Z,549"$
|
||||
@@ -309,7 +309,7 @@ $LK,"ICBrBitOps",A="FL:::/Compiler/BackC.CPP.Z,210",BI=244$
|
||||
$LK,"MODR_D32_INDIRECT_REG",A="FL:::/Compiler/BackLib.CPP.Z,133"$
|
||||
$LK,"LexGetChar",A="FL:::/Compiler/Lex.CPP.Z,107",BI=245$
|
||||
$LK,"LexSkipEol",A="FL:::/Compiler/Lex.CPP.Z,270",BI=246$
|
||||
$LK,"ICFlagBranch",A="FL:::/Compiler/BackB.CPP.Z,682",BI=247$
|
||||
$LK,"ICFlagBranch",A="FL:::/Compiler/BackB.CPP.Z,683",BI=247$
|
||||
$LK,"SLASH_OP_FSUBR",A="FL:::/Compiler/BackLib.CPP.Z,260"$
|
||||
$LK,"ICFPreIncDec",A="FL:::/Compiler/BackFB.CPP.Z,560",BI=248$
|
||||
$LK,"MODR_SIB_INDIRECT_REG",A="FL:::/Compiler/BackLib.CPP.Z,134"$
|
||||
@@ -321,7 +321,7 @@ $LK,"PrsFunNew",A="FL:::/Compiler/PrsLib.CPP.Z,62",BI=252$
|
||||
$LK,"StreamExePrint",A="FL:::/Compiler/CMain.CPP.Z,665",BI=253$
|
||||
$LK,"COCGoToLabelFind",A="FL:::/Compiler/PrsLib.CPP.Z,152",BI=254$
|
||||
$LK,"OptMVCompare",A="FL:::/Compiler/OptLib.CPP.Z,555",BI=255$
|
||||
$LK,"ICToBool",A="FL:::/Compiler/BackB.CPP.Z,289",BI=256$
|
||||
$LK,"ICToBool",A="FL:::/Compiler/BackB.CPP.Z,290",BI=256$
|
||||
$LK,"PrsFunJoin",A="FL:::/Compiler/PrsStmt.CPP.Z,68",BI=257$
|
||||
$LK,"PrsNoUnusedWarn",A="FL:::/Compiler/PrsStmt.CPP.Z,787",BI=258$
|
||||
$LK,"OptFixSizeOf",A="FL:::/Compiler/OptLib.CPP.Z,484",BI=259$
|
||||
@@ -334,127 +334,89 @@ $LK,"InstEntryFind",A="FL:::/Compiler/UAsm.CPP.Z,66",BI=262$
|
||||
$LK,"PrsDotDotDot",A="FL:::/Compiler/PrsVar.CPP.Z,381",BI=263$
|
||||
$LK,"ICMulEqu",A="FL:::/Compiler/BackA.CPP.Z,322",BI=264$
|
||||
$LK,"AsmPrsInsFlags",A="FL:::/Compiler/AsmInit.CPP.Z,1",BI=265$
|
||||
| ||||