TempleOSCDV4.12.ISO
This commit is contained in:
1 parent
93ca216483
commit
b84bbff6db
381 files changed
+18356
-18798
No files matched your search
+218
-219
@@ -34,8 +34,8 @@ Bool PrsAsmImm(CCmpCtrl *cc,CAsmArg *arg)
|
||||
|
||||
U0 PrsAsmArg(CCmpCtrl *cc,CAsmArg *arg,Bool rel)
|
||||
{
|
||||
CHashGeneric *temph,*temph1;
|
||||
CHashReg *tempr;
|
||||
CHashGeneric *tmph,*tmph1;
|
||||
CHashReg *tmpr;
|
||||
MemSet(arg,0,sizeof(CAsmArg));
|
||||
arg->seg =REG_NONE;
|
||||
arg->reg1=REG_NONE;
|
||||
@@ -43,11 +43,11 @@ U0 PrsAsmArg(CCmpCtrl *cc,CAsmArg *arg,Bool rel)
|
||||
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) {
|
||||
if (tmph=cc->hash_entry) {
|
||||
if (tmph->type&HTG_TYPE_MASK==HTT_REG) {
|
||||
tmpr=tmph;
|
||||
arg->reg1_type=tmpr->reg_type;
|
||||
switch (tmpr->reg_type) {
|
||||
start:
|
||||
case REGT_R8:
|
||||
arg->size=1;
|
||||
@@ -62,11 +62,11 @@ U0 PrsAsmArg(CCmpCtrl *cc,CAsmArg *arg,Bool rel)
|
||||
arg->size=8;
|
||||
break;
|
||||
end:
|
||||
arg->reg1=tempr->reg_num;
|
||||
arg->reg1=tmpr->reg_num;
|
||||
Lex(cc);
|
||||
return;
|
||||
case REGT_SEG:
|
||||
arg->seg=tempr->reg_num;
|
||||
arg->seg=tmpr->reg_num;
|
||||
if (Lex(cc)!=':') {
|
||||
arg->just_seg=TRUE;
|
||||
return;
|
||||
@@ -77,17 +77,17 @@ U0 PrsAsmArg(CCmpCtrl *cc,CAsmArg *arg,Bool rel)
|
||||
case REGT_MM:
|
||||
case REGT_XMM:
|
||||
arg->size=8;
|
||||
arg->reg1=tempr->reg_num;
|
||||
arg->reg1=tmpr->reg_num;
|
||||
Lex(cc);
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
if ((temph->type&HTG_TYPE_MASK==HTT_CLASS||
|
||||
temph->type&HTG_TYPE_MASK==HTT_INTERNAL_TYPE) &&
|
||||
(temph1=HashFind(cc->cur_str,cmp.asm_hash,HTT_ASM_KEYWORD)))
|
||||
temph=temph1;
|
||||
if (temph->type&HTG_TYPE_MASK==HTT_ASM_KEYWORD) {
|
||||
switch (temph->user_data0) {
|
||||
if ((tmph->type&HTG_TYPE_MASK==HTT_CLASS||
|
||||
tmph->type&HTG_TYPE_MASK==HTT_INTERNAL_TYPE) &&
|
||||
(tmph1=HashFind(cc->cur_str,cmp.asm_hash,HTT_ASM_KEYWORD)))
|
||||
tmph=tmph1;
|
||||
if (tmph->type&HTG_TYPE_MASK==HTT_ASM_KEYWORD) {
|
||||
switch (tmph->user_data0) {
|
||||
case AKW_I8:
|
||||
case AKW_U8:
|
||||
arg->size=1;
|
||||
@@ -129,19 +129,19 @@ pa_asm_direct_imm:
|
||||
Lex(cc); // skip [
|
||||
while (cc->token && cc->token!=']') {
|
||||
if (cc->token==TK_IDENT) {
|
||||
if (temph=cc->hash_entry) {
|
||||
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 (tmph=cc->hash_entry) {
|
||||
if (tmph->type&HTG_TYPE_MASK==HTT_REG &&
|
||||
REGT_R16<=tmph(CHashReg *)->reg_type<=REGT_R64) {
|
||||
tmpr=tmph;
|
||||
arg->reg2_type=tmpr->reg_type;
|
||||
if (arg->reg1==REG_NONE) {
|
||||
if (tempr->reg_num&7==REG_RSP) {
|
||||
if (tmpr->reg_num&7==REG_RSP) {
|
||||
arg->reg1=4;
|
||||
arg->reg2=tempr->reg_num;
|
||||
arg->reg2=tmpr->reg_num;
|
||||
} else
|
||||
arg->reg1=tempr->reg_num;
|
||||
arg->reg1=tmpr->reg_num;
|
||||
} else
|
||||
arg->reg2=tempr->reg_num;
|
||||
arg->reg2=tmpr->reg_num;
|
||||
Lex(cc);
|
||||
} else
|
||||
goto pa_asm_indirect_imm;
|
||||
@@ -269,7 +269,7 @@ Bool AsmStoreNum(CCmpCtrl *cc,CAsmNum2 *num2,I64 cnt,Bool U8_avail)
|
||||
{
|
||||
CAOTCtrl *aotc=cc->aotc;
|
||||
I64 i;
|
||||
CAOTAbsAddr *tempa;
|
||||
CAOTAbsAddr *tmpa;
|
||||
|
||||
if (!num2->imm_flag)
|
||||
num2->num.i-=num2->rel;
|
||||
@@ -284,19 +284,19 @@ Bool AsmStoreNum(CCmpCtrl *cc,CAsmNum2 *num2,I64 cnt,Bool U8_avail)
|
||||
LexExcept(cc,"Branch out of range at ");
|
||||
if (num2->imm_flag) {
|
||||
if (num2->num.abs_cnts.abs_addres&1) {
|
||||
tempa=CAlloc(sizeof(CAOTAbsAddr));
|
||||
tempa->next=aotc->abss;
|
||||
aotc->abss=tempa;
|
||||
tempa->ip=aotc->ip;
|
||||
tempa->type=AAT_ADD_U8;
|
||||
tmpa=CAlloc(sizeof(CAOTAbsAddr));
|
||||
tmpa->next=aotc->abss;
|
||||
aotc->abss=tmpa;
|
||||
tmpa->ip=aotc->ip;
|
||||
tmpa->type=AAT_ADD_U8;
|
||||
}
|
||||
} else {
|
||||
if (num2->num.abs_cnts.c_addres&1) {
|
||||
tempa=CAlloc(sizeof(CAOTAbsAddr));
|
||||
tempa->next=aotc->abss;
|
||||
aotc->abss=tempa;
|
||||
tempa->ip=aotc->ip;
|
||||
tempa->type=AAT_SUB_U8;
|
||||
tmpa=CAlloc(sizeof(CAOTAbsAddr));
|
||||
tmpa->next=aotc->abss;
|
||||
aotc->abss=tmpa;
|
||||
tmpa->ip=aotc->ip;
|
||||
tmpa->type=AAT_SUB_U8;
|
||||
}
|
||||
}
|
||||
AOTStoreCodeU8(cc,num2->num.i);
|
||||
@@ -311,19 +311,19 @@ Bool AsmStoreNum(CCmpCtrl *cc,CAsmNum2 *num2,I64 cnt,Bool U8_avail)
|
||||
LexExcept(cc,"Branch out of range at ");
|
||||
if (num2->imm_flag) {
|
||||
if (num2->num.abs_cnts.abs_addres&1) {
|
||||
tempa=CAlloc(sizeof(CAOTAbsAddr));
|
||||
tempa->next=aotc->abss;
|
||||
aotc->abss=tempa;
|
||||
tempa->ip=aotc->ip;
|
||||
tempa->type=AAT_ADD_U16;
|
||||
tmpa=CAlloc(sizeof(CAOTAbsAddr));
|
||||
tmpa->next=aotc->abss;
|
||||
aotc->abss=tmpa;
|
||||
tmpa->ip=aotc->ip;
|
||||
tmpa->type=AAT_ADD_U16;
|
||||
}
|
||||
} else {
|
||||
if (num2->num.abs_cnts.c_addres&1) {
|
||||
tempa=CAlloc(sizeof(CAOTAbsAddr));
|
||||
tempa->next=aotc->abss;
|
||||
aotc->abss=tempa;
|
||||
tempa->ip=aotc->ip;
|
||||
tempa->type=AAT_SUB_U16;
|
||||
tmpa=CAlloc(sizeof(CAOTAbsAddr));
|
||||
tmpa->next=aotc->abss;
|
||||
aotc->abss=tmpa;
|
||||
tmpa->ip=aotc->ip;
|
||||
tmpa->type=AAT_SUB_U16;
|
||||
}
|
||||
}
|
||||
AOTStoreCodeU8(cc,num2->num.i.u8[0]);
|
||||
@@ -338,19 +338,19 @@ Bool AsmStoreNum(CCmpCtrl *cc,CAsmNum2 *num2,I64 cnt,Bool U8_avail)
|
||||
LexExcept(cc,"Branch out of range at ");
|
||||
if (num2->imm_flag) {
|
||||
if (num2->num.abs_cnts.abs_addres&1) {
|
||||
tempa=CAlloc(sizeof(CAOTAbsAddr));
|
||||
tempa->next=aotc->abss;
|
||||
aotc->abss=tempa;
|
||||
tempa->ip=aotc->ip;
|
||||
tempa->type=AAT_ADD_U32;
|
||||
tmpa=CAlloc(sizeof(CAOTAbsAddr));
|
||||
tmpa->next=aotc->abss;
|
||||
aotc->abss=tmpa;
|
||||
tmpa->ip=aotc->ip;
|
||||
tmpa->type=AAT_ADD_U32;
|
||||
}
|
||||
} else {
|
||||
if (num2->num.abs_cnts.c_addres&1) {
|
||||
tempa=CAlloc(sizeof(CAOTAbsAddr));
|
||||
tempa->next=aotc->abss;
|
||||
aotc->abss=tempa;
|
||||
tempa->ip=aotc->ip;
|
||||
tempa->type=AAT_SUB_U32;
|
||||
tmpa=CAlloc(sizeof(CAOTAbsAddr));
|
||||
tmpa->next=aotc->abss;
|
||||
aotc->abss=tmpa;
|
||||
tmpa->ip=aotc->ip;
|
||||
tmpa->type=AAT_SUB_U32;
|
||||
}
|
||||
}
|
||||
AOTStoreCodeU32(cc,num2->num.i);
|
||||
@@ -362,19 +362,19 @@ Bool AsmStoreNum(CCmpCtrl *cc,CAsmNum2 *num2,I64 cnt,Bool U8_avail)
|
||||
U8_avail);
|
||||
if (num2->imm_flag) {
|
||||
if (num2->num.abs_cnts.abs_addres&1) {
|
||||
tempa=CAlloc(sizeof(CAOTAbsAddr));
|
||||
tempa->next=aotc->abss;
|
||||
aotc->abss=tempa;
|
||||
tempa->ip=aotc->ip;
|
||||
tempa->type=AAT_ADD_U64;
|
||||
tmpa=CAlloc(sizeof(CAOTAbsAddr));
|
||||
tmpa->next=aotc->abss;
|
||||
aotc->abss=tmpa;
|
||||
tmpa->ip=aotc->ip;
|
||||
tmpa->type=AAT_ADD_U64;
|
||||
}
|
||||
} else {
|
||||
if (num2->num.abs_cnts.c_addres&1) {
|
||||
tempa=CAlloc(sizeof(CAOTAbsAddr));
|
||||
tempa->next=aotc->abss;
|
||||
aotc->abss=tempa;
|
||||
tempa->ip=aotc->ip;
|
||||
tempa->type=AAT_SUB_U64;
|
||||
tmpa=CAlloc(sizeof(CAOTAbsAddr));
|
||||
tmpa->next=aotc->abss;
|
||||
aotc->abss=tmpa;
|
||||
tmpa->ip=aotc->ip;
|
||||
tmpa->type=AAT_SUB_U64;
|
||||
}
|
||||
}
|
||||
AOTStoreCodeU64(cc,num2->num.i);
|
||||
@@ -392,17 +392,16 @@ Bool AsmStoreNum(CCmpCtrl *cc,CAsmNum2 *num2,I64 cnt,Bool U8_avail)
|
||||
|
||||
U8 asm_seg_prefixes[6]={0x26,0x2E,0x36,0x3E,0x64,0x65};
|
||||
|
||||
Bool PrsAsmInst(CCmpCtrl *cc,CHashOpcode *tempo,I64 argcnt)
|
||||
Bool PrsAsmInst(CCmpCtrl *cc,CHashOpcode *tmpo,I64 argcnt)
|
||||
{
|
||||
CAOTCtrl *aotc=cc->aotc;
|
||||
I64 i,j,a1,a2,om,seg,arg1mask,arg2mask;
|
||||
CAsmArg *tempa1,*tempa2;
|
||||
CAsmArg *tmpa1,*tmpa2;
|
||||
Bool ModrM_complete,U8_avail=FALSE,found_second_possible=FALSE;
|
||||
CInst *tempi;
|
||||
|
||||
CInst *tmpins;
|
||||
CAsmIns cur,best;
|
||||
best.U8_cnt=255;
|
||||
|
||||
best.U8_cnt=255;
|
||||
if (argcnt>0)
|
||||
arg1mask=AsmMakeArgMask(cc,&aotc->arg1);
|
||||
else
|
||||
@@ -411,38 +410,38 @@ Bool PrsAsmInst(CCmpCtrl *cc,CHashOpcode *tempo,I64 argcnt)
|
||||
arg2mask=AsmMakeArgMask(cc,&aotc->arg2);
|
||||
else
|
||||
arg2mask=1;
|
||||
for (i=0;i<tempo->inst_entry_cnt;i++) {
|
||||
tempi=&tempo->ins[i];
|
||||
if (tempi->arg1==ARGT_REL8 || tempi->arg2==ARGT_REL8)
|
||||
for (i=0;i<tmpo->inst_entry_cnt;i++) {
|
||||
tmpins=&tmpo->ins[i];
|
||||
if (tmpins->arg1==ARGT_REL8 || tmpins->arg2==ARGT_REL8)
|
||||
U8_avail=TRUE;
|
||||
if (Bt(&arg1mask,tempi->arg1) && Bt(&arg2mask,tempi->arg2) &&
|
||||
(!(tempi->flags&IEF_NOT_IN_64_BIT) || aotc->seg_size!=64)) {
|
||||
if (Bt(&arg1mask,tmpins->arg1) && Bt(&arg2mask,tmpins->arg2) &&
|
||||
(!(tmpins->flags&IEF_NOT_IN_64_BIT) || aotc->seg_size!=64)) {
|
||||
MemSet(&cur,0,sizeof(CAsmIns));
|
||||
cur.tempi=tempi;
|
||||
cur.tmpins=tmpins;
|
||||
ModrM_complete=FALSE;
|
||||
cur.is_dft=ToBool(tempi->flags & IEF_DFT);
|
||||
cur.is_dft=ToBool(tmpins->flags & IEF_DFT);
|
||||
if (aotc->seg_size==64) {
|
||||
if (tempi->flags & IEF_48_REX)
|
||||
if (tmpins->flags & IEF_48_REX)
|
||||
cur.REX=0x48;
|
||||
else
|
||||
cur.REX=0x40;
|
||||
}
|
||||
cur.disp.imm_flag=TRUE;
|
||||
cur.imm.imm_flag=TRUE;
|
||||
om=tempi->opcode_modifier;
|
||||
a1=tempi->arg1;
|
||||
a2=tempi->arg2;
|
||||
tempa1=&aotc->arg1;
|
||||
tempa2=&aotc->arg2;
|
||||
cur.last_opcode_U8=tempi->opcode[tempi->opcode_cnt-1];
|
||||
om=tmpins->opcode_modifier;
|
||||
a1=tmpins->arg1;
|
||||
a2=tmpins->arg2;
|
||||
tmpa1=&aotc->arg1;
|
||||
tmpa2=&aotc->arg2;
|
||||
cur.last_opcode_U8=tmpins->opcode[tmpins->opcode_cnt-1];
|
||||
|
||||
if (tempi->slash_val<8) {
|
||||
cur.ModrM|=tempi->slash_val<<3;
|
||||
if (tmpins->slash_val<8) {
|
||||
cur.ModrM|=tmpins->slash_val<<3;
|
||||
cur.has_ModrM=TRUE;
|
||||
}
|
||||
|
||||
if (aotc->seg_size==16 && tempi->flags & IEF_OP_SIZE32 ||
|
||||
aotc->seg_size!=16 && tempi->flags & IEF_OP_SIZE16)
|
||||
if (aotc->seg_size==16 && tmpins->flags & IEF_OP_SIZE32 ||
|
||||
aotc->seg_size!=16 && tmpins->flags & IEF_OP_SIZE16)
|
||||
cur.has_operand_prefix=TRUE;
|
||||
|
||||
if (om==OM_IB) cur.imm.U8_cnt=1;
|
||||
@@ -468,16 +467,16 @@ Bool PrsAsmInst(CCmpCtrl *cc,CHashOpcode *tempo,I64 argcnt)
|
||||
cc->lex_include_stk->full_name,
|
||||
cc->lex_include_stk->line_num-1);
|
||||
}
|
||||
if (tempi->flags & IEF_PLUS_OPCODE) {
|
||||
if (tempi->slash_val==SV_R_REG) {
|
||||
cur.last_opcode_U8|=tempa1->reg1&7;
|
||||
if (tempa1->reg1&15>7)
|
||||
if (tmpins->flags & IEF_PLUS_OPCODE) {
|
||||
if (tmpins->slash_val==SV_R_REG) {
|
||||
cur.last_opcode_U8|=tmpa1->reg1&7;
|
||||
if (tmpa1->reg1&15>7)
|
||||
cur.REX|=1;
|
||||
if (tempa1->reg1>=20) //RBPu8,RSPu8,RSIu8,RDIu8?
|
||||
if (tmpa1->reg1>=20) //RBPu8,RSPu8,RSIu8,RDIu8?
|
||||
cur.has_REX=TRUE;
|
||||
} else {//SV_I_REG
|
||||
if (tempa1->reg1_type==REGT_FSTK)
|
||||
cur.last_opcode_U8+=tempa1->reg1;
|
||||
if (tmpa1->reg1_type==REGT_FSTK)
|
||||
cur.last_opcode_U8+=tmpa1->reg1;
|
||||
}
|
||||
}
|
||||
if (a1==ARGT_R64 || a1==ARGT_RM64 || a1==ARGT_M64)
|
||||
@@ -487,52 +486,52 @@ Bool PrsAsmInst(CCmpCtrl *cc,CHashOpcode *tempo,I64 argcnt)
|
||||
cur.has_addr_prefix=TRUE;
|
||||
|
||||
cur.has_ModrM=TRUE;
|
||||
if (tempa1->imm_or_off_present && tempa1->indirect &&
|
||||
tempa1->reg1==REG_NONE) {
|
||||
if (tmpa1->imm_or_off_present && tmpa1->indirect &&
|
||||
tmpa1->reg1==REG_NONE) {
|
||||
cur.ModrM=cur.ModrM+5;
|
||||
MemCpy(&cur.disp.num,&tempa1->num,sizeof(CAsmNum));
|
||||
MemCpy(&cur.disp.num,&tmpa1->num,sizeof(CAsmNum));
|
||||
cur.disp.U8_cnt=4;
|
||||
if (aotc->seg_size==64)
|
||||
cur.disp.imm_flag=FALSE;
|
||||
} else {
|
||||
if (tempa1->reg2==REG_NONE && tempa1->scale==1) {
|
||||
cur.ModrM|=tempa1->reg1&7;
|
||||
if (tempa1->reg1&15>7)
|
||||
if (tmpa1->reg2==REG_NONE && tmpa1->scale==1) {
|
||||
cur.ModrM|=tmpa1->reg1&7;
|
||||
if (tmpa1->reg1&15>7)
|
||||
cur.REX|=1;
|
||||
if (tempa1->reg1>=20) //RBPu8,RSPu8,RSIu8,RDIu8?
|
||||
if (tmpa1->reg1>=20) //RBPu8,RSPu8,RSIu8,RDIu8?
|
||||
cur.has_REX=TRUE;
|
||||
} else {
|
||||
cur.ModrM|=4;
|
||||
cur.has_SIB=TRUE;
|
||||
if (tempa1->scale==1)
|
||||
if (tmpa1->scale==1)
|
||||
cur.SIB=0;
|
||||
else if (tempa1->scale==2)
|
||||
else if (tmpa1->scale==2)
|
||||
cur.SIB=0x40;
|
||||
else if (tempa1->scale==4)
|
||||
else if (tmpa1->scale==4)
|
||||
cur.SIB=0x80;
|
||||
else if (tempa1->scale==8)
|
||||
else if (tmpa1->scale==8)
|
||||
cur.SIB=0xC0;
|
||||
if (tempa1->reg2==REG_NONE) {
|
||||
if (tmpa1->reg2==REG_NONE) {
|
||||
ModrM_complete=TRUE;
|
||||
cur.SIB|=(tempa1->reg1&7)<<3+REG_RBP;
|
||||
if (tempa1->reg1&15>7)
|
||||
cur.SIB|=(tmpa1->reg1&7)<<3+REG_RBP;
|
||||
if (tmpa1->reg1&15>7)
|
||||
cur.REX|=2;
|
||||
if (tempa1->reg1>=20) //RBPu8,RSPu8,RSIu8,RDIu8?
|
||||
if (tmpa1->reg1>=20) //RBPu8,RSPu8,RSIu8,RDIu8?
|
||||
cur.has_REX=TRUE;
|
||||
MemCpy(&cur.disp.num,&tempa1->num,sizeof(CAsmNum));
|
||||
MemCpy(&cur.disp.num,&tmpa1->num,sizeof(CAsmNum));
|
||||
cur.disp.U8_cnt=4;
|
||||
} else {
|
||||
cur.SIB|=(tempa1->reg1&7)<<3+tempa1->reg2&7;
|
||||
if (tempa1->reg1&15>7)
|
||||
cur.SIB|=(tmpa1->reg1&7)<<3+tmpa1->reg2&7;
|
||||
if (tmpa1->reg1&15>7)
|
||||
cur.REX|=2;
|
||||
if (tempa1->reg1>=20) //RBPu8,RSPu8,RSIu8,RDIu8?
|
||||
if (tmpa1->reg1>=20) //RBPu8,RSPu8,RSIu8,RDIu8?
|
||||
cur.has_REX=TRUE;
|
||||
if (tempa1->reg2&15>7)
|
||||
if (tmpa1->reg2&15>7)
|
||||
cur.REX|=1;
|
||||
if (tempa1->reg2>=20) //RBPu8,RSPu8,RSIu8,RDIu8?
|
||||
if (tmpa1->reg2>=20) //RBPu8,RSPu8,RSIu8,RDIu8?
|
||||
cur.has_REX=TRUE;
|
||||
if (tempa1->reg2&7==REG_RBP &&
|
||||
!tempa1->imm_or_off_present && tempa1->indirect) {
|
||||
if (tmpa1->reg2&7==REG_RBP &&
|
||||
!tmpa1->imm_or_off_present && tmpa1->indirect) {
|
||||
cur.ModrM|=0x40;
|
||||
cur.disp.U8_cnt=1;
|
||||
ModrM_complete=TRUE;
|
||||
@@ -540,8 +539,8 @@ Bool PrsAsmInst(CCmpCtrl *cc,CHashOpcode *tempo,I64 argcnt)
|
||||
}
|
||||
}
|
||||
if (!ModrM_complete) {
|
||||
if (tempa1->imm_or_off_present) {
|
||||
MemCpy(&cur.disp.num,&tempa1->num,sizeof(CAsmNum));
|
||||
if (tmpa1->imm_or_off_present) {
|
||||
MemCpy(&cur.disp.num,&tmpa1->num,sizeof(CAsmNum));
|
||||
if (!cur.disp.num.machine_code &&
|
||||
MIN_I8<=cur.disp.num.i<=MAX_I8) {
|
||||
cur.ModrM|=0x40;
|
||||
@@ -553,11 +552,11 @@ Bool PrsAsmInst(CCmpCtrl *cc,CHashOpcode *tempo,I64 argcnt)
|
||||
cur.ModrM|=0x80;
|
||||
cur.disp.U8_cnt=4;
|
||||
}
|
||||
} else if (!tempa1->indirect) {
|
||||
} else if (!tmpa1->indirect) {
|
||||
cur.has_addr_prefix=FALSE;
|
||||
cur.ModrM|=0xC0;
|
||||
} else {
|
||||
if (tempa1->reg1&7==REG_RBP) {
|
||||
if (tmpa1->reg1&7==REG_RBP) {
|
||||
cur.ModrM|=0x40;
|
||||
cur.disp.U8_cnt=1;
|
||||
}
|
||||
@@ -568,7 +567,7 @@ Bool PrsAsmInst(CCmpCtrl *cc,CHashOpcode *tempo,I64 argcnt)
|
||||
ARGT_UIMM8<=a1<=ARGT_UIMM64) {
|
||||
if (a1==ARGT_IMM64 || a2==ARGT_UIMM64)
|
||||
cur.REX|=8;
|
||||
MemCpy(&cur.imm.num,&tempa1->num,sizeof(CAsmNum));
|
||||
MemCpy(&cur.imm.num,&tmpa1->num,sizeof(CAsmNum));
|
||||
}
|
||||
} else if (argcnt==2) {
|
||||
if (best.U8_cnt!=255 && !found_second_possible && !best.is_dft) {
|
||||
@@ -578,26 +577,26 @@ Bool PrsAsmInst(CCmpCtrl *cc,CHashOpcode *tempo,I64 argcnt)
|
||||
cc->lex_include_stk->full_name,
|
||||
cc->lex_include_stk->line_num-1);
|
||||
}
|
||||
if (tempi->flags & IEF_PLUS_OPCODE) {
|
||||
if (tempi->slash_val==SV_R_REG) {
|
||||
if (tmpins->flags & IEF_PLUS_OPCODE) {
|
||||
if (tmpins->slash_val==SV_R_REG) {
|
||||
if (ARGT_AL<=a1<=ARGT_RAX) {
|
||||
cur.last_opcode_U8|=tempa2->reg1&7;
|
||||
if (tempa2->reg1&15>7)
|
||||
cur.last_opcode_U8|=tmpa2->reg1&7;
|
||||
if (tmpa2->reg1&15>7)
|
||||
cur.REX|=1;
|
||||
if (tempa2->reg1>=20) //RBPu8,RSPu8,RSIu8,RDIu8?
|
||||
if (tmpa2->reg1>=20) //RBPu8,RSPu8,RSIu8,RDIu8?
|
||||
cur.has_REX=TRUE;
|
||||
} else {
|
||||
cur.last_opcode_U8|=tempa1->reg1&7;
|
||||
if (tempa1->reg1&15>7)
|
||||
cur.last_opcode_U8|=tmpa1->reg1&7;
|
||||
if (tmpa1->reg1&15>7)
|
||||
cur.REX|=1;
|
||||
if (tempa1->reg1>=20) //RBPu8,RSPu8,RSIu8,RDIu8?
|
||||
if (tmpa1->reg1>=20) //RBPu8,RSPu8,RSIu8,RDIu8?
|
||||
cur.has_REX=TRUE;
|
||||
}
|
||||
} else {//SV_I_REG
|
||||
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 (tmpa1->reg1_type==REGT_FSTK)
|
||||
cur.last_opcode_U8|=tmpa1->reg1;
|
||||
if (tmpa2->reg1_type==REGT_FSTK)
|
||||
cur.last_opcode_U8|=tmpa2->reg1;
|
||||
}
|
||||
}
|
||||
if (a1==ARGT_RM64 || a2==ARGT_RM64 || a1==ARGT_M64 || a2==ARGT_M64 ||
|
||||
@@ -609,68 +608,68 @@ Bool PrsAsmInst(CCmpCtrl *cc,CHashOpcode *tempo,I64 argcnt)
|
||||
cur.has_addr_prefix=TRUE;
|
||||
cur.has_ModrM=TRUE;
|
||||
if (ARGT_RM8<=a2<=ARGT_RM64 || ARGT_M8<=a2<=ARGT_M64) {
|
||||
tempa1=&aotc->arg2;
|
||||
tempa2=&aotc->arg1;
|
||||
tmpa1=&aotc->arg2;
|
||||
tmpa2=&aotc->arg1;
|
||||
}
|
||||
if (tempi->slash_val==SV_R_REG) {
|
||||
if (tempa2->just_seg)
|
||||
cur.ModrM|=tempa2->seg<<3;
|
||||
if (tmpins->slash_val==SV_R_REG) {
|
||||
if (tmpa2->just_seg)
|
||||
cur.ModrM|=tmpa2->seg<<3;
|
||||
else {
|
||||
if (tempa2->reg1==REG_NONE) {
|
||||
cur.ModrM|=(tempa1->reg1&7)<<3;
|
||||
if (tempa1->reg1&15>7)
|
||||
if (tmpa2->reg1==REG_NONE) {
|
||||
cur.ModrM|=(tmpa1->reg1&7)<<3;
|
||||
if (tmpa1->reg1&15>7)
|
||||
cur.REX|=4;
|
||||
if (tempa1->reg1>=20) //RBPu8,RSPu8,RSIu8,RDIu8?
|
||||
if (tmpa1->reg1>=20) //RBPu8,RSPu8,RSIu8,RDIu8?
|
||||
cur.has_REX=TRUE;
|
||||
} else {
|
||||
cur.ModrM|=(tempa2->reg1&7)<<3;
|
||||
if (tempa2->reg1&15>7)
|
||||
cur.ModrM|=(tmpa2->reg1&7)<<3;
|
||||
if (tmpa2->reg1&15>7)
|
||||
cur.REX|=4;
|
||||
if (tempa2->reg1>=20) //RBPu8,RSPu8,RSIu8,RDIu8?
|
||||
if (tmpa2->reg1>=20) //RBPu8,RSPu8,RSIu8,RDIu8?
|
||||
cur.has_REX=TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (tempa1->reg2==REG_NONE && tempa1->scale==1) {
|
||||
if (tempa1->reg1!=REG_NONE) {
|
||||
cur.ModrM|=tempa1->reg1&7;
|
||||
if (tempa1->reg1&15>7)
|
||||
if (tmpa1->reg2==REG_NONE && tmpa1->scale==1) {
|
||||
if (tmpa1->reg1!=REG_NONE) {
|
||||
cur.ModrM|=tmpa1->reg1&7;
|
||||
if (tmpa1->reg1&15>7)
|
||||
cur.REX|=1;
|
||||
if (tempa1->reg1>=20) //RBPu8,RSPu8,RSIu8,RDIu8?
|
||||
if (tmpa1->reg1>=20) //RBPu8,RSPu8,RSIu8,RDIu8?
|
||||
cur.has_REX=TRUE;
|
||||
}
|
||||
} else {
|
||||
cur.ModrM|=4;
|
||||
cur.has_SIB=TRUE;
|
||||
if (tempa1->scale==1)
|
||||
if (tmpa1->scale==1)
|
||||
cur.SIB=0;
|
||||
else if (tempa1->scale==2)
|
||||
else if (tmpa1->scale==2)
|
||||
cur.SIB=0x40;
|
||||
else if (tempa1->scale==4)
|
||||
else if (tmpa1->scale==4)
|
||||
cur.SIB=0x80;
|
||||
else if (tempa1->scale==8)
|
||||
else if (tmpa1->scale==8)
|
||||
cur.SIB=0xC0;
|
||||
if (tempa1->reg2==REG_NONE) {
|
||||
if (tmpa1->reg2==REG_NONE) {
|
||||
ModrM_complete=TRUE;
|
||||
cur.SIB|=(tempa1->reg1&7)<<3+5;
|
||||
if (tempa1->reg1&15>7)
|
||||
cur.SIB|=(tmpa1->reg1&7)<<3+5;
|
||||
if (tmpa1->reg1&15>7)
|
||||
cur.REX|=2;
|
||||
if (tempa1->reg1>=20) //RBPu8,RSPu8,RSIu8,RDIu8?
|
||||
if (tmpa1->reg1>=20) //RBPu8,RSPu8,RSIu8,RDIu8?
|
||||
cur.has_REX=TRUE;
|
||||
MemCpy(&cur.disp.num,&tempa1->num,sizeof(CAsmNum));
|
||||
MemCpy(&cur.disp.num,&tmpa1->num,sizeof(CAsmNum));
|
||||
cur.disp.U8_cnt=4;
|
||||
} else {
|
||||
cur.SIB|=(tempa1->reg1&7)<<3+tempa1->reg2&7;
|
||||
if (tempa1->reg1&15>7)
|
||||
cur.SIB|=(tmpa1->reg1&7)<<3+tmpa1->reg2&7;
|
||||
if (tmpa1->reg1&15>7)
|
||||
cur.REX|=2;
|
||||
if (tempa1->reg1>=20) //RBPu8,RSPu8,RSIu8,RDIu8?
|
||||
if (tmpa1->reg1>=20) //RBPu8,RSPu8,RSIu8,RDIu8?
|
||||
cur.has_REX=TRUE;
|
||||
if (tempa1->reg2&15>7)
|
||||
if (tmpa1->reg2&15>7)
|
||||
cur.REX|=1;
|
||||
if (tempa1->reg2>=20) //RBPu8,RSPu8,RSIu8,RDIu8?
|
||||
if (tmpa1->reg2>=20) //RBPu8,RSPu8,RSIu8,RDIu8?
|
||||
cur.has_REX=TRUE;
|
||||
if (tempa1->reg2&7==REG_RBP &&
|
||||
!tempa1->imm_or_off_present && tempa1->indirect) {
|
||||
if (tmpa1->reg2&7==REG_RBP &&
|
||||
!tmpa1->imm_or_off_present && tmpa1->indirect) {
|
||||
cur.ModrM|=0x40;
|
||||
cur.disp.U8_cnt=1;
|
||||
ModrM_complete=TRUE;
|
||||
@@ -678,16 +677,16 @@ Bool PrsAsmInst(CCmpCtrl *cc,CHashOpcode *tempo,I64 argcnt)
|
||||
}
|
||||
}
|
||||
if (!ModrM_complete) {
|
||||
if (tempa1->imm_or_off_present &&
|
||||
tempa1->indirect && tempa1->reg1==REG_NONE) {
|
||||
if (tmpa1->imm_or_off_present &&
|
||||
tmpa1->indirect && tmpa1->reg1==REG_NONE) {
|
||||
cur.ModrM=cur.ModrM&0xF8+5;
|
||||
MemCpy(&cur.disp.num,&tempa1->num,sizeof(CAsmNum));
|
||||
MemCpy(&cur.disp.num,&tmpa1->num,sizeof(CAsmNum));
|
||||
cur.disp.U8_cnt=4;
|
||||
if (aotc->seg_size==64)
|
||||
cur.disp.imm_flag=FALSE;
|
||||
} else {
|
||||
if (tempa1->imm_or_off_present) {
|
||||
MemCpy(&cur.disp.num,&tempa1->num,sizeof(CAsmNum));
|
||||
if (tmpa1->imm_or_off_present) {
|
||||
MemCpy(&cur.disp.num,&tmpa1->num,sizeof(CAsmNum));
|
||||
if (!cur.disp.num.machine_code &&
|
||||
MIN_I8<=cur.disp.num.i<=MAX_I8) {
|
||||
cur.ModrM|=0x40;
|
||||
@@ -699,11 +698,11 @@ Bool PrsAsmInst(CCmpCtrl *cc,CHashOpcode *tempo,I64 argcnt)
|
||||
cur.ModrM|=0x80;
|
||||
cur.disp.U8_cnt=4;
|
||||
}
|
||||
} else if (!tempa1->indirect) {
|
||||
} else if (!tmpa1->indirect) {
|
||||
cur.has_addr_prefix=FALSE;
|
||||
cur.ModrM|=0xC0;
|
||||
} else {
|
||||
if (tempa1->reg1&7==REG_RBP) {
|
||||
if (tmpa1->reg1&7==REG_RBP) {
|
||||
cur.ModrM|=0x40;
|
||||
cur.disp.U8_cnt=1;
|
||||
}
|
||||
@@ -711,14 +710,14 @@ Bool PrsAsmInst(CCmpCtrl *cc,CHashOpcode *tempo,I64 argcnt)
|
||||
}
|
||||
}
|
||||
} else if (ARGT_MOFFS8<=a1<=ARGT_MOFFS64) {
|
||||
MemCpy(&cur.disp.num,&tempa1->num,sizeof(CAsmNum));
|
||||
MemCpy(&cur.disp.num,&tmpa1->num,sizeof(CAsmNum));
|
||||
if (aotc->seg_size==16)
|
||||
cur.disp.U8_cnt=2;
|
||||
else
|
||||
cur.disp.U8_cnt=4;
|
||||
cur.has_addr_prefix=FALSE;
|
||||
} else if (ARGT_MOFFS8<=a2<=ARGT_MOFFS64) {
|
||||
MemCpy(&cur.disp.num,&tempa2->num,sizeof(CAsmNum));
|
||||
MemCpy(&cur.disp.num,&tmpa2->num,sizeof(CAsmNum));
|
||||
if (aotc->seg_size==16)
|
||||
cur.disp.U8_cnt=2;
|
||||
else
|
||||
@@ -726,7 +725,7 @@ Bool PrsAsmInst(CCmpCtrl *cc,CHashOpcode *tempo,I64 argcnt)
|
||||
cur.has_addr_prefix=FALSE;
|
||||
} else if (ARGT_IMM8<=a1<=ARGT_IMM64 ||
|
||||
ARGT_UIMM8<=a1<=ARGT_UIMM64) {
|
||||
MemCpy(&cur.imm.num,&tempa1->num,sizeof(CAsmNum));
|
||||
MemCpy(&cur.imm.num,&tmpa1->num,sizeof(CAsmNum));
|
||||
if (a1==ARGT_IMM8 || a1==ARGT_UIMM8) cur.imm.U8_cnt=1;
|
||||
else if (a1==ARGT_IMM16 || a1==ARGT_UIMM16) cur.imm.U8_cnt=2;
|
||||
else if (a1==ARGT_IMM32 || a1==ARGT_UIMM32) cur.imm.U8_cnt=4;
|
||||
@@ -737,12 +736,12 @@ Bool PrsAsmInst(CCmpCtrl *cc,CHashOpcode *tempo,I64 argcnt)
|
||||
}
|
||||
if (ARGT_IMM8<=a2<=ARGT_IMM64 ||
|
||||
ARGT_UIMM8<=a2<=ARGT_UIMM64) {
|
||||
MemCpy(&cur.imm.num,&tempa2->num,sizeof(CAsmNum));
|
||||
MemCpy(&cur.imm.num,&tmpa2->num,sizeof(CAsmNum));
|
||||
if (a2==ARGT_IMM8 || a2==ARGT_UIMM8) cur.imm.U8_cnt=1;
|
||||
else if (a2==ARGT_IMM16 || a2==ARGT_UIMM16) cur.imm.U8_cnt=2;
|
||||
else if (a2==ARGT_IMM32 || a2==ARGT_UIMM32) {
|
||||
cur.imm.U8_cnt=4;
|
||||
if (tempi->flags&IEF_REX_ONLY_R8_R15 && a2==ARGT_UIMM32)
|
||||
if (tmpins->flags&IEF_REX_ONLY_R8_R15 && a2==ARGT_UIMM32)
|
||||
cur.REX&=~8;
|
||||
} else {
|
||||
cur.imm.U8_cnt=8;
|
||||
@@ -750,23 +749,23 @@ Bool PrsAsmInst(CCmpCtrl *cc,CHashOpcode *tempo,I64 argcnt)
|
||||
}
|
||||
}
|
||||
}
|
||||
cur.U8_cnt=tempi->opcode_cnt+cur.disp.U8_cnt+cur.imm.U8_cnt;
|
||||
cur.U8_cnt=tmpins->opcode_cnt+cur.disp.U8_cnt+cur.imm.U8_cnt;
|
||||
if (cur.has_ModrM) cur.U8_cnt++;
|
||||
if (cur.has_SIB) cur.U8_cnt++;
|
||||
if (aotc->seg_size==64 && cur.REX&0x40==0x40 &&
|
||||
(cur.REX!=0x40 || cur.has_REX) &&
|
||||
(cur.REX&7 || !(tempi->flags&IEF_REX_ONLY_R8_R15 ||
|
||||
tempi->flags&IEF_REX_XOR_LIKE && tempa1->reg1==tempa2->reg1 &&
|
||||
(cur.REX&7 || !(tmpins->flags&IEF_REX_ONLY_R8_R15 ||
|
||||
tmpins->flags&IEF_REX_XOR_LIKE && tmpa1->reg1==tmpa2->reg1 &&
|
||||
cur.ModrM&0xC0==0xC0)))
|
||||
cur.U8_cnt++;
|
||||
if (cur.U8_cnt<best.U8_cnt &&
|
||||
!(tempi->flags & IEF_DONT_SWITCH_MODES &&
|
||||
!(tmpins->flags & IEF_DONT_SWITCH_MODES &&
|
||||
(cur.has_addr_prefix || cur.has_operand_prefix)))
|
||||
MemCpy(&best,&cur,sizeof(CAsmIns));
|
||||
}
|
||||
}
|
||||
if (best.U8_cnt<255) {
|
||||
tempi=best.tempi;
|
||||
tmpins=best.tmpins;
|
||||
seg=REG_NONE;
|
||||
if (argcnt>1 && aotc->arg2.seg!=REG_NONE && !aotc->arg2.just_seg)
|
||||
seg=aotc->arg2.seg;
|
||||
@@ -780,12 +779,12 @@ Bool PrsAsmInst(CCmpCtrl *cc,CHashOpcode *tempo,I64 argcnt)
|
||||
AOTStoreCodeU8(cc,OC_ADDR_SIZE_PREFIX); //Operand size override
|
||||
if (aotc->seg_size==64 && best.REX&0x40==0x40 &&
|
||||
(best.REX!=0x40 || best.has_REX) &&
|
||||
(best.REX&7||!(tempi->flags&IEF_REX_ONLY_R8_R15 ||
|
||||
tempi->flags&IEF_REX_XOR_LIKE && tempa1->reg1==tempa2->reg1 &&
|
||||
(best.REX&7||!(tmpins->flags&IEF_REX_ONLY_R8_R15 ||
|
||||
tmpins->flags&IEF_REX_XOR_LIKE && tmpa1->reg1==tmpa2->reg1 &&
|
||||
best.ModrM&0xC0==0xC0)))
|
||||
AOTStoreCodeU8(cc,best.REX);
|
||||
for (j=0;j<tempi->opcode_cnt-1;j++)
|
||||
AOTStoreCodeU8(cc,tempi->opcode[j]);
|
||||
for (j=0;j<tmpins->opcode_cnt-1;j++)
|
||||
AOTStoreCodeU8(cc,tmpins->opcode[j]);
|
||||
AOTStoreCodeU8(cc,best.last_opcode_U8);
|
||||
|
||||
if (best.has_ModrM)
|
||||
@@ -804,7 +803,7 @@ Bool PrsAsmInst(CCmpCtrl *cc,CHashOpcode *tempo,I64 argcnt)
|
||||
if (!AsmStoreNum(cc,&best.imm,1,U8_avail))
|
||||
return FALSE;
|
||||
}
|
||||
if (tempi->flags&IEF_ENDING_ZERO) //ENTER inst
|
||||
if (tmpins->flags&IEF_ENDING_ZERO) //ENTER inst
|
||||
AOTStoreCodeU8(cc,0);
|
||||
return TRUE;
|
||||
}
|
||||
@@ -906,8 +905,8 @@ U0 PrsAsmBlk(CCmpCtrl *cc,I64 cmp_flags)
|
||||
CAOTCtrl *aotc=cc->aotc;
|
||||
I64 i,j,k,argcnt,
|
||||
old_flags=cc->flags & CCF_ASM_EXPRESSIONS;
|
||||
CHashOpcode *tempo;
|
||||
CHashExport *tempex;
|
||||
CHashOpcode *tmpo;
|
||||
CHashExport *tmpex;
|
||||
U8 *next_last_label;
|
||||
CCodeMisc *g_lb;
|
||||
|
||||
@@ -930,13 +929,13 @@ U0 PrsAsmBlk(CCmpCtrl *cc,I64 cmp_flags)
|
||||
if (cc->token!=TK_IDENT)
|
||||
LexExcept(cc,"Expecting identifier at ");
|
||||
else {
|
||||
tempex=NULL;
|
||||
tempex=CAlloc(sizeof(CHashExport));
|
||||
tempex->str=cc->cur_str;
|
||||
tmpex=NULL;
|
||||
tmpex=CAlloc(sizeof(CHashExport));
|
||||
tmpex->str=cc->cur_str;
|
||||
cc->cur_str=0;
|
||||
tempex->type=HTT_EXPORT_SYS_SYM|HTF_UNRESOLVED;
|
||||
HashAdd(tempex,cc->htc.glbl_hash_table);
|
||||
tempex->type|=HTF_IMPORT;
|
||||
tmpex->type=HTT_EXPORT_SYS_SYM|HTF_UNRESOLVED;
|
||||
HashAdd(tmpex,cc->htc.glbl_hash_table);
|
||||
tmpex->type|=HTF_IMPORT;
|
||||
if (Lex(cc)==',')
|
||||
Lex(cc); //skip ','
|
||||
}
|
||||
@@ -1006,29 +1005,29 @@ U0 PrsAsmBlk(CCmpCtrl *cc,I64 cmp_flags)
|
||||
LexExcept(cc,"Syntax error at ");
|
||||
}
|
||||
} else if (cc->hash_entry->type & HTT_OPCODE) {
|
||||
tempo=cc->hash_entry;
|
||||
tmpo=cc->hash_entry;
|
||||
Lex(cc); //skip opcode
|
||||
argcnt=0;
|
||||
if (tempo->ins[0].arg1) {
|
||||
if (tmpo->ins[0].arg1) {
|
||||
argcnt++;
|
||||
if (ARGT_REL8<=tempo->ins[0].arg1<=ARGT_REL32)
|
||||
if (ARGT_REL8<=tmpo->ins[0].arg1<=ARGT_REL32)
|
||||
PrsAsmArg(cc,&aotc->arg1,TRUE);
|
||||
else
|
||||
PrsAsmArg(cc,&aotc->arg1,FALSE);
|
||||
if (tempo->ins[0].arg2) {
|
||||
if (tmpo->ins[0].arg2) {
|
||||
argcnt++;
|
||||
if (cc->token!=',')
|
||||
LexExcept(cc,"Expecting ',' at ");
|
||||
else {
|
||||
Lex(cc); //skip ','
|
||||
if (ARGT_REL8<=tempo->ins[0].arg2<=ARGT_REL32)
|
||||
if (ARGT_REL8<=tmpo->ins[0].arg2<=ARGT_REL32)
|
||||
PrsAsmArg(cc,&aotc->arg2,TRUE);
|
||||
else
|
||||
PrsAsmArg(cc,&aotc->arg2,FALSE);
|
||||
}
|
||||
}
|
||||
}
|
||||
PrsAsmInst(cc,tempo,argcnt);
|
||||
PrsAsmInst(cc,tmpo,argcnt);
|
||||
} else if (cc->hash_entry->type & HTT_EXPORT_SYS_SYM) {
|
||||
if (Btr(&cc->hash_entry->type,HTf_UNRESOLVED)) {
|
||||
if (cc->hash_entry->type & HTF_LOCAL) {
|
||||
@@ -1063,25 +1062,25 @@ U0 PrsAsmBlk(CCmpCtrl *cc,I64 cmp_flags)
|
||||
} else
|
||||
LexExcept(cc,"Syntax error at ");
|
||||
} else if (cc->token==TK_IDENT) {
|
||||
tempex=CAlloc(sizeof(CHashExport));
|
||||
tempex->str=cc->cur_str;
|
||||
tmpex=CAlloc(sizeof(CHashExport));
|
||||
tmpex->str=cc->cur_str;
|
||||
cc->cur_str=0;
|
||||
tempex->type=HTT_EXPORT_SYS_SYM;
|
||||
tempex->val=aotc->ip;
|
||||
tmpex->type=HTT_EXPORT_SYS_SYM;
|
||||
tmpex->val=aotc->ip;
|
||||
Lex(cc); //Skip cur_str
|
||||
if (cc->token!=':' && cc->token!=TK_DBL_COLON)
|
||||
LexExcept(cc,"Expecting ':' at ");
|
||||
else {
|
||||
if (*tempex->str=='@' && tempex->str[1]=='@') {
|
||||
if (*tmpex->str=='@' && tmpex->str[1]=='@') {
|
||||
if (cc->token==TK_DBL_COLON)
|
||||
LexExcept(cc,"No local glbl exports at ");
|
||||
HashAdd(tempex,cc->htc.local_hash_table);
|
||||
HashAdd(tmpex,cc->htc.local_hash_table);
|
||||
} else
|
||||
HashAdd(tempex,cc->htc.glbl_hash_table);
|
||||
HashAdd(tmpex,cc->htc.glbl_hash_table);
|
||||
if (cc->htc.local_var_lst) {//AsmBlk in fun? Also add goto-like label.
|
||||
if (!(g_lb=COCGoToLabelFind(cc,tempex->str))) {
|
||||
if (!(g_lb=COCGoToLabelFind(cc,tmpex->str))) {
|
||||
g_lb=COCMiscNew(cc,CMT_ASM_LABEL);
|
||||
g_lb->str=StrNew(tempex->str);
|
||||
g_lb->str=StrNew(tmpex->str);
|
||||
} else if (g_lb->flags&CMF_DEFINED)
|
||||
LexExcept(cc,"Duplicate goto label at ");
|
||||
g_lb->type=CMT_ASM_LABEL;
|
||||
@@ -1091,11 +1090,11 @@ U0 PrsAsmBlk(CCmpCtrl *cc,I64 cmp_flags)
|
||||
ICAdd(cc,IC_LABEL,g_lb,0);
|
||||
}
|
||||
if (cc->token==TK_DBL_COLON) {
|
||||
tempex->type|=HTF_EXPORT;
|
||||
HashSrcFileSet(cc,tempex);
|
||||
tmpex->type|=HTF_EXPORT;
|
||||
HashSrcFileSet(cc,tmpex);
|
||||
|
||||
AOTLocalsResolve(cc);
|
||||
aotc->last_label=tempex->str;
|
||||
aotc->last_label=tmpex->str;
|
||||
}
|
||||
Lex(cc);
|
||||
}
|
||||
@@ -1104,8 +1103,8 @@ U0 PrsAsmBlk(CCmpCtrl *cc,I64 cmp_flags)
|
||||
else
|
||||
LexExcept(cc,"Syntax error at ");
|
||||
if (cmp_flags&CMPF_ONE_ASM_INS && (cc->token!=TK_IDENT ||
|
||||
!(tempo=cc->hash_entry) ||
|
||||
!(tempo->type&(HTT_OPCODE|HTT_ASM_KEYWORD))))
|
||||
!(tmpo=cc->hash_entry) ||
|
||||
!(tmpo->type&(HTT_OPCODE|HTT_ASM_KEYWORD))))
|
||||
break;
|
||||
}
|
||||
AOTLocalsResolve(cc);
|
||||
|
||||
+79
-79
@@ -1,45 +1,45 @@
|
||||
U0 AsmPrsInsFlags(CCmpCtrl *cc,CInst *tempi)
|
||||
U0 AsmPrsInsFlags(CCmpCtrl *cc,CInst *tmpins)
|
||||
{
|
||||
I64 i;
|
||||
while (TRUE) {
|
||||
switch (cc->token) {
|
||||
case TK_IDENT:
|
||||
if ((i=LstMatch(cc->cur_str,"NO\0CB\0CW\0CD\0CP\0IB\0IW\0ID\0"))>=0) {
|
||||
tempi->opcode_modifier=i;
|
||||
tmpins->opcode_modifier=i;
|
||||
break;
|
||||
} else
|
||||
return;
|
||||
case TK_I64:
|
||||
if (cc->cur_i64==16)
|
||||
tempi->flags|=IEF_OP_SIZE16;
|
||||
tmpins->flags|=IEF_OP_SIZE16;
|
||||
else if (cc->cur_i64==32)
|
||||
tempi->flags|=IEF_OP_SIZE32;
|
||||
tmpins->flags|=IEF_OP_SIZE32;
|
||||
else
|
||||
return;
|
||||
break;
|
||||
case '+':
|
||||
tempi->flags|=IEF_PLUS_OPCODE;
|
||||
tmpins->flags|=IEF_PLUS_OPCODE;
|
||||
case '/':
|
||||
if (Lex(cc)==TK_I64 && cc->cur_i64<8)
|
||||
tempi->slash_val=cc->cur_i64;
|
||||
tmpins->slash_val=cc->cur_i64;
|
||||
else if (cc->token==TK_IDENT) {
|
||||
if (!StrCmp(cc->cur_str,"R"))
|
||||
tempi->slash_val=SV_R_REG;
|
||||
tmpins->slash_val=SV_R_REG;
|
||||
else if (!StrCmp(cc->cur_str,"I"))
|
||||
tempi->slash_val=SV_I_REG;
|
||||
tmpins->slash_val=SV_I_REG;
|
||||
else
|
||||
return;
|
||||
} else
|
||||
return;
|
||||
break;
|
||||
case '!': tempi->flags|=IEF_DONT_SWITCH_MODES; break;
|
||||
case '&': tempi->flags|=IEF_DFT; break;
|
||||
case '%': tempi->flags|=IEF_NOT_IN_64_BIT; break;
|
||||
case '=': tempi->flags|=IEF_48_REX; break;
|
||||
case '`': tempi->flags|=IEF_REX_ONLY_R8_R15; break;
|
||||
case '^': tempi->flags|=IEF_REX_XOR_LIKE; break;
|
||||
case '*': tempi->flags|=IEF_STI_LIKE; break;
|
||||
case '$$': tempi->flags|=IEF_ENDING_ZERO; break;
|
||||
case '!': tmpins->flags|=IEF_DONT_SWITCH_MODES; break;
|
||||
case '&': tmpins->flags|=IEF_DFT; break;
|
||||
case '%': tmpins->flags|=IEF_NOT_IN_64_BIT; break;
|
||||
case '=': tmpins->flags|=IEF_48_REX; break;
|
||||
case '`': tmpins->flags|=IEF_REX_ONLY_R8_R15; break;
|
||||
case '^': tmpins->flags|=IEF_REX_XOR_LIKE; break;
|
||||
case '*': tmpins->flags|=IEF_STI_LIKE; break;
|
||||
case '$$': tmpins->flags|=IEF_ENDING_ZERO; break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
@@ -50,13 +50,13 @@ U0 AsmPrsInsFlags(CCmpCtrl *cc,CInst *tempi)
|
||||
U0 AsmHashLoad()
|
||||
{//See $LK,"::/Compiler/OpCodes.DD"$.
|
||||
I64 i,j,size,size_max;
|
||||
CInternalType *tempit;
|
||||
CInternalType *tmpit;
|
||||
CCmpCtrl *cc;
|
||||
CHashGeneric *temph;
|
||||
CHashReg *tempr;
|
||||
CHashOpcode *tempo,*tempo2,*tempo_max;
|
||||
CInst *tempi;
|
||||
CHashClass *tempc;
|
||||
CHashGeneric *tmph;
|
||||
CHashReg *tmpr;
|
||||
CHashOpcode *tmpo,*tmpo2,*tmpo_max;
|
||||
CInst *tmpins;
|
||||
CHashClass *tmpc;
|
||||
|
||||
cmp.size_arg_mask[0]=0x3FF0FFFFFE;
|
||||
cmp.size_arg_mask[1]=0x1110111112;
|
||||
@@ -66,7 +66,7 @@ U0 AsmHashLoad()
|
||||
|
||||
cmp.asm_hash=HashTableNew(1024);
|
||||
size_max=offset(CHashOpcode.ins)+sizeof(CInst)<<5;
|
||||
tempo_max=MAlloc(size_max);
|
||||
tmpo_max=MAlloc(size_max);
|
||||
|
||||
cc=CmpCtrlNew(FileRead("OpCodes.DD"),,"OpCodes.DD.Z");
|
||||
cc->htc.hash_table_lst=NULL;
|
||||
@@ -83,33 +83,33 @@ U0 AsmHashLoad()
|
||||
LexExcept(cc,"Expecting identifier at ");
|
||||
switch (i) {
|
||||
case REGT_R8...REGT_XMM:
|
||||
tempr=CAlloc(sizeof(CHashReg));
|
||||
tempr->str=cc->cur_str;
|
||||
tmpr=CAlloc(sizeof(CHashReg));
|
||||
tmpr->str=cc->cur_str;
|
||||
cc->cur_str=NULL;
|
||||
Lex(cc); //skip keyword name
|
||||
if (cc->token!=TK_I64)
|
||||
LexExcept(cc,"Expecting int at ");
|
||||
tempr->type=HTT_REG;
|
||||
tempr->reg_type=i;
|
||||
tempr->reg_num=cc->cur_i64;
|
||||
HashAdd(tempr,cmp.asm_hash);
|
||||
tmpr->type=HTT_REG;
|
||||
tmpr->reg_type=i;
|
||||
tmpr->reg_num=cc->cur_i64;
|
||||
HashAdd(tmpr,cmp.asm_hash);
|
||||
Lex(cc); //Skip INT
|
||||
break;
|
||||
case: //OPCODE
|
||||
if (cc->token!=TK_IDENT)
|
||||
LexExcept(cc,"Expecting opcode at ");
|
||||
MemSet(tempo_max,0,size_max);
|
||||
tempo_max->type=HTT_OPCODE;
|
||||
tempo_max->inst_entry_cnt=0;
|
||||
tempo_max->str=cc->cur_str;
|
||||
MemSet(tmpo_max,0,size_max);
|
||||
tmpo_max->type=HTT_OPCODE;
|
||||
tmpo_max->inst_entry_cnt=0;
|
||||
tmpo_max->str=cc->cur_str;
|
||||
cc->cur_str=0;
|
||||
Lex(cc); //Skip OPCODE
|
||||
while (cc->token && cc->token!=';' && cc->token!=':') {
|
||||
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!!
|
||||
tmpins=&tmpo_max->ins[tmpo_max->inst_entry_cnt];
|
||||
tmpins->ins_entry_num=tmpo_max->inst_entry_cnt++;
|
||||
tmpins->slash_val=SV_NONE; //Not zero!!
|
||||
while (cc->token==TK_I64) {
|
||||
tempi->opcode[tempi->opcode_cnt++]=cc->cur_i64;
|
||||
tmpins->opcode[tmpins->opcode_cnt++]=cc->cur_i64;
|
||||
Lex(cc);
|
||||
}
|
||||
if (cc->token==',')
|
||||
@@ -117,74 +117,74 @@ U0 AsmHashLoad()
|
||||
else if (cc->token!=';')
|
||||
LexExcept(cc,"Expecting ',' at ");
|
||||
|
||||
AsmPrsInsFlags(cc,tempi);
|
||||
AsmPrsInsFlags(cc,tmpins);
|
||||
|
||||
tempi->uasm_slash_val=tempi->slash_val;
|
||||
if (tempi->flags&IEF_STI_LIKE && tempi->slash_val!=SV_I_REG)
|
||||
tempi->uasm_slash_val=SV_STI_LIKE;
|
||||
tmpins->uasm_slash_val=tmpins->slash_val;
|
||||
if (tmpins->flags&IEF_STI_LIKE && tmpins->slash_val!=SV_I_REG)
|
||||
tmpins->uasm_slash_val=SV_STI_LIKE;
|
||||
|
||||
tempi->arg1=tempi->arg2=tempi->size1=tempi->size2=0;
|
||||
tmpins->arg1=tmpins->arg2=tmpins->size1=tmpins->size2=0;
|
||||
if (cc->token==TK_IDENT) {
|
||||
j=DefineMatch(cc->cur_str,"ST_ARG_TYPES");
|
||||
tempi->arg1=j;
|
||||
tmpins->arg1=j;
|
||||
if (Bt(&cmp.size_arg_mask[1],j))
|
||||
tempi->size1=8;
|
||||
tmpins->size1=8;
|
||||
else if (Bt(&cmp.size_arg_mask[2],j))
|
||||
tempi->size1=16;
|
||||
tmpins->size1=16;
|
||||
else if (Bt(&cmp.size_arg_mask[4],j))
|
||||
tempi->size1=32;
|
||||
tmpins->size1=32;
|
||||
else if (Bt(&cmp.size_arg_mask[8],j))
|
||||
tempi->size1=64;
|
||||
tmpins->size1=64;
|
||||
|
||||
if (Lex(cc)==TK_IDENT) {
|
||||
j=DefineMatch(cc->cur_str,"ST_ARG_TYPES");
|
||||
Lex(cc);
|
||||
tempi->arg2=j;
|
||||
tmpins->arg2=j;
|
||||
if (Bt(&cmp.size_arg_mask[1],j))
|
||||
tempi->size2=8;
|
||||
tmpins->size2=8;
|
||||
else if (Bt(&cmp.size_arg_mask[2],j))
|
||||
tempi->size2=16;
|
||||
tmpins->size2=16;
|
||||
else if (Bt(&cmp.size_arg_mask[4],j))
|
||||
tempi->size2=32;
|
||||
tmpins->size2=32;
|
||||
else if (Bt(&cmp.size_arg_mask[8],j))
|
||||
tempi->size2=64;
|
||||
tmpins->size2=64;
|
||||
}
|
||||
}
|
||||
}
|
||||
size=offset(CHashOpcode.ins)+sizeof(CInst)*tempo_max->inst_entry_cnt;
|
||||
tempo=MAlloc(size);
|
||||
MemCpy(tempo,tempo_max,size);
|
||||
tempo->use_cnt=0;
|
||||
if (HashFind(tempo->str,cmp.asm_hash,HTT_OPCODE))
|
||||
size=offset(CHashOpcode.ins)+sizeof(CInst)*tmpo_max->inst_entry_cnt;
|
||||
tmpo=MAlloc(size);
|
||||
MemCpy(tmpo,tmpo_max,size);
|
||||
tmpo->use_cnt=0;
|
||||
if (HashFind(tmpo->str,cmp.asm_hash,HTT_OPCODE))
|
||||
LexExcept(cc,"Duplicate OPCODE entry ");
|
||||
HashAdd(tempo,cmp.asm_hash);
|
||||
HashAdd(tmpo,cmp.asm_hash);
|
||||
//Parse aliases.
|
||||
if (cc->token==':') {
|
||||
while (Lex(cc)==TK_IDENT) {
|
||||
tempo2=MAllocIdent(tempo);
|
||||
tempo2->str=cc->cur_str;
|
||||
tmpo2=MAllocIdent(tmpo);
|
||||
tmpo2->str=cc->cur_str;
|
||||
cc->cur_str=0;
|
||||
tempo2->oc_flags|=OCF_ALIAS;
|
||||
if (HashFind(tempo2->str,cmp.asm_hash,HTT_OPCODE))
|
||||
tmpo2->oc_flags|=OCF_ALIAS;
|
||||
if (HashFind(tmpo2->str,cmp.asm_hash,HTT_OPCODE))
|
||||
LexExcept(cc,"Duplicate OPCODE ALIAS entry ");
|
||||
HashAdd(tempo2,cmp.asm_hash);
|
||||
HashAdd(tmpo2,cmp.asm_hash);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case: //KEYWORD
|
||||
case: //ASM_KEYWORD
|
||||
temph=CAlloc(sizeof(CHashGeneric));
|
||||
temph->str=cc->cur_str;
|
||||
tmph=CAlloc(sizeof(CHashGeneric));
|
||||
tmph->str=cc->cur_str;
|
||||
cc->cur_str=NULL;
|
||||
Lex(cc); //skip keyword name
|
||||
if (cc->token!=TK_I64)
|
||||
LexExcept(cc,"Expecting int at ");
|
||||
temph->user_data0=cc->cur_i64;
|
||||
tmph->user_data0=cc->cur_i64;
|
||||
if (i==10)
|
||||
temph->type=HTT_KEYWORD;
|
||||
tmph->type=HTT_KEYWORD;
|
||||
else
|
||||
temph->type=HTT_ASM_KEYWORD;
|
||||
HashAdd(temph,cmp.asm_hash);
|
||||
tmph->type=HTT_ASM_KEYWORD;
|
||||
HashAdd(tmph,cmp.asm_hash);
|
||||
Lex(cc); //Skip INT
|
||||
break;
|
||||
}
|
||||
@@ -192,18 +192,18 @@ U0 AsmHashLoad()
|
||||
LexExcept(cc,"Missing ';' at");
|
||||
Lex(cc); //Skip ';'
|
||||
}
|
||||
Free(tempo_max);
|
||||
Free(tmpo_max);
|
||||
CmpCtrlDel(cc);
|
||||
for (i=0;i<NUM_INTERNAL_TYPES;i++) {
|
||||
tempit=&internal_types_table[i];
|
||||
tempc=PrsClassNew;
|
||||
tempc->type=HTT_INTERNAL_TYPE;
|
||||
tempc->raw_type=tempit->type;
|
||||
Bts(&tempc->flags,Cf_INTERNAL_TYPE);
|
||||
tempc->size=tempit->size;
|
||||
tempc->str=AStrNew(tempit->name);
|
||||
HashAdd(tempc,cmp.asm_hash);
|
||||
cmp.internal_types[tempc->raw_type]=tempc;
|
||||
tmpit=&internal_types_table[i];
|
||||
tmpc=PrsClassNew;
|
||||
tmpc->type=HTT_INTERNAL_TYPE;
|
||||
tmpc->raw_type=tmpit->type;
|
||||
Bts(&tmpc->flags,Cf_INTERNAL_TYPE);
|
||||
tmpc->size=tmpit->size;
|
||||
tmpc->str=AStrNew(tmpit->name);
|
||||
HashAdd(tmpc,cmp.asm_hash);
|
||||
cmp.internal_types[tmpc->raw_type]=tmpc;
|
||||
}
|
||||
adam_task->hash_table->next=cmp.asm_hash;
|
||||
}
|
||||
+35
-35
@@ -2,19 +2,19 @@ U0 AOTStoreCodeU8(CCmpCtrl *cc,U8 b)
|
||||
{
|
||||
CAOTCtrl *aotc=cc->aotc;
|
||||
I64 i=aotc->ip>>AOT_BIN_BLK_BITS;
|
||||
CAOTBinBlk *tempbin=aotc->bin;
|
||||
CAOTBinBlk *tmpbin=aotc->bin;
|
||||
while (i--)
|
||||
if (!(tempbin=tempbin->next)) {
|
||||
if (!(tmpbin=tmpbin->next)) {
|
||||
i=aotc->ip>>AOT_BIN_BLK_BITS+1;
|
||||
tempbin=&aotc->bin;
|
||||
tmpbin=&aotc->bin;
|
||||
while (i--) {
|
||||
if (!tempbin->next)
|
||||
tempbin->next=CAlloc(sizeof(CAOTBinBlk));
|
||||
tempbin=tempbin->next;
|
||||
if (!tmpbin->next)
|
||||
tmpbin->next=CAlloc(sizeof(CAOTBinBlk));
|
||||
tmpbin=tmpbin->next;
|
||||
}
|
||||
break;
|
||||
}
|
||||
tempbin->body[aotc->ip++ & (AOT_BIN_BLK_SIZE-1)]=b;
|
||||
tmpbin->body[aotc->ip++ & (AOT_BIN_BLK_SIZE-1)]=b;
|
||||
if (aotc->lst) {
|
||||
if (aotc->lst_col>=24) {
|
||||
'\n';
|
||||
@@ -32,24 +32,24 @@ U0 AOTStoreCodeU32(CCmpCtrl *cc,U32 d)
|
||||
CAOTCtrl *aotc=cc->aotc;
|
||||
I64 i=aotc->ip>>AOT_BIN_BLK_BITS,j=(aotc->ip+sizeof(U32))>>AOT_BIN_BLK_BITS;
|
||||
U32 *_d;
|
||||
CAOTBinBlk *tempbin;
|
||||
CAOTBinBlk *tmpbin;
|
||||
if (i!=j)
|
||||
for (i=0;i<sizeof(U32);i++)
|
||||
AOTStoreCodeU8(cc,d.u8[i]);
|
||||
else {
|
||||
tempbin=aotc->bin;
|
||||
tmpbin=aotc->bin;
|
||||
while (i--)
|
||||
if (!(tempbin=tempbin->next)) {
|
||||
if (!(tmpbin=tmpbin->next)) {
|
||||
i=aotc->ip>>AOT_BIN_BLK_BITS+1;
|
||||
tempbin=&aotc->bin;
|
||||
tmpbin=&aotc->bin;
|
||||
while (i--) {
|
||||
if (!tempbin->next)
|
||||
tempbin->next=CAlloc(sizeof(CAOTBinBlk));
|
||||
tempbin=tempbin->next;
|
||||
if (!tmpbin->next)
|
||||
tmpbin->next=CAlloc(sizeof(CAOTBinBlk));
|
||||
tmpbin=tmpbin->next;
|
||||
}
|
||||
break;
|
||||
}
|
||||
_d=tempbin->body+ aotc->ip&(AOT_BIN_BLK_SIZE-1);
|
||||
_d=tmpbin->body+ aotc->ip&(AOT_BIN_BLK_SIZE-1);
|
||||
*_d=d;
|
||||
aotc->ip+=sizeof(U32);
|
||||
if (aotc->lst) {
|
||||
@@ -70,24 +70,24 @@ U0 AOTStoreCodeU64(CCmpCtrl *cc,U64 q)
|
||||
CAOTCtrl *aotc=cc->aotc;
|
||||
I64 i=aotc->ip>>AOT_BIN_BLK_BITS,j=(aotc->ip+sizeof(I64))>>AOT_BIN_BLK_BITS,
|
||||
*_q;
|
||||
CAOTBinBlk *tempbin;
|
||||
CAOTBinBlk *tmpbin;
|
||||
if (i!=j)
|
||||
for (i=0;i<sizeof(I64);i++)
|
||||
AOTStoreCodeU8(cc,q.u8[i]);
|
||||
else {
|
||||
tempbin=aotc->bin;
|
||||
tmpbin=aotc->bin;
|
||||
while (i--)
|
||||
if (!(tempbin=tempbin->next)) {
|
||||
if (!(tmpbin=tmpbin->next)) {
|
||||
i=aotc->ip>>AOT_BIN_BLK_BITS+1;
|
||||
tempbin=&aotc->bin;
|
||||
tmpbin=&aotc->bin;
|
||||
while (i--) {
|
||||
if (!tempbin->next)
|
||||
tempbin->next=CAlloc(sizeof(CAOTBinBlk));
|
||||
tempbin=tempbin->next;
|
||||
if (!tmpbin->next)
|
||||
tmpbin->next=CAlloc(sizeof(CAOTBinBlk));
|
||||
tmpbin=tmpbin->next;
|
||||
}
|
||||
break;
|
||||
}
|
||||
_q=tempbin->body+ aotc->ip&(AOT_BIN_BLK_SIZE-1);
|
||||
_q=tmpbin->body+ aotc->ip&(AOT_BIN_BLK_SIZE-1);
|
||||
*_q=q;
|
||||
aotc->ip+=sizeof(I64);
|
||||
if (aotc->lst) {
|
||||
@@ -106,19 +106,19 @@ U0 AOTStoreCodeU64(CCmpCtrl *cc,U64 q)
|
||||
U0 AOTStoreCodeU8At(CCmpCtrl *cc,I64 ip,...)
|
||||
{
|
||||
CAOTCtrl *aotc=cc->aotc;
|
||||
CAOTBinBlk *tempbin;
|
||||
CAOTBinBlk *tmpbin;
|
||||
I64 i,j;
|
||||
for (j=0;j<argc;j++) {
|
||||
i=ip>>AOT_BIN_BLK_BITS+1;
|
||||
tempbin=&aotc->bin;
|
||||
tmpbin=&aotc->bin;
|
||||
while (i--) {
|
||||
if (!tempbin->next) {
|
||||
tempbin->next=CAlloc(sizeof(CAOTBinBlk));
|
||||
tempbin->next->next=NULL;
|
||||
if (!tmpbin->next) {
|
||||
tmpbin->next=CAlloc(sizeof(CAOTBinBlk));
|
||||
tmpbin->next->next=NULL;
|
||||
}
|
||||
tempbin=tempbin->next;
|
||||
tmpbin=tmpbin->next;
|
||||
}
|
||||
tempbin->body[ip++ & (AOT_BIN_BLK_SIZE-1)]=argv[j];
|
||||
tmpbin->body[ip++ & (AOT_BIN_BLK_SIZE-1)]=argv[j];
|
||||
}
|
||||
if (ip>aotc->num_bin_U8s)
|
||||
aotc->num_bin_U8s=ip;
|
||||
@@ -147,11 +147,11 @@ I64 AsmLexExpression(CCmpCtrl *cc)
|
||||
U0 AsmLineLst(CCmpCtrl *cc)
|
||||
{
|
||||
CAOTCtrl *aotc=cc->aotc;
|
||||
CLexFile *tempf=cc->lex_include_stk;
|
||||
CDocEntry *doc_e=tempf->line_start,*doc_e2;
|
||||
if (aotc->lst && aotc->lst_last_lfn==tempf && doc_e) {
|
||||
CLexFile *tmpf=cc->lex_include_stk;
|
||||
CDocEntry *doc_e=tmpf->line_start,*doc_e2;
|
||||
if (aotc->lst && aotc->lst_last_lfn==tmpf && doc_e) {
|
||||
if (doc_e2=aotc->lst_last_line) {
|
||||
if (tempf->flags& LFSF_DOC) {
|
||||
if (tmpf->flags& LFSF_DOC) {
|
||||
while (doc_e2->y<doc_e->y) {
|
||||
"%h*c%08X ",24-aotc->lst_col,CH_SPACE,aotc->lst_last_ip;
|
||||
aotc->lst_col=0;
|
||||
@@ -169,7 +169,7 @@ U0 AsmLineLst(CCmpCtrl *cc)
|
||||
aotc->lst_last_line=doc_e;
|
||||
} else {
|
||||
aotc->lst_last_line=NULL;
|
||||
aotc->lst_last_lfn=tempf;
|
||||
aotc->lst_last_lfn=tmpf;
|
||||
}
|
||||
aotc->lst_last_ip=aotc->ip;
|
||||
}
|
||||
+133
-133
@@ -1,40 +1,40 @@
|
||||
U0 AsmResolve(CCmpCtrl *cc,CAsmUnresolvedRef *tempu,U8 *label,Bool undefined)
|
||||
U0 AsmResolve(CCmpCtrl *cc,CAsmUnresolvedRef *tmpu,U8 *label,Bool undefined)
|
||||
{
|
||||
CAOTImportExport *tempie;
|
||||
CAsmUndefHash *tempauh;
|
||||
I64 r=Call(tempu->machine_code);
|
||||
CAOTImportExport *tmpie;
|
||||
CAsmUndefHash *tmpauh;
|
||||
I64 r=Call(tmpu->machine_code);
|
||||
if (undefined) {
|
||||
tempauh=tempu->asm_undef_hash;
|
||||
while (tempauh) {
|
||||
if (tempauh->hash->type & HTF_UNRESOLVED) {
|
||||
tempie=CAlloc(sizeof(CAOTImportExport));
|
||||
tempie->next=tempauh->hash->ie_lst;
|
||||
tempauh->hash->ie_lst=tempie;
|
||||
tempie->ip=tempu->ip;
|
||||
tempie->aot=cc->aot;
|
||||
tempie->type=tempu->type;
|
||||
tmpauh=tmpu->asm_undef_hash;
|
||||
while (tmpauh) {
|
||||
if (tmpauh->hash->type & HTF_UNRESOLVED) {
|
||||
tmpie=CAlloc(sizeof(CAOTImportExport));
|
||||
tmpie->next=tmpauh->hash->ie_lst;
|
||||
tmpauh->hash->ie_lst=tmpie;
|
||||
tmpie->ip=tmpu->ip;
|
||||
tmpie->aot=cc->aot;
|
||||
tmpie->type=tmpu->type;
|
||||
}
|
||||
tempauh=tempauh->next; //Technically, more than one won't work.
|
||||
tmpauh=tmpauh->next; //Technically, more than one won't work.
|
||||
}
|
||||
} else if (!(tempu->type&IEF_IMM_NOT_REL)) {
|
||||
r-=tempu->rel_ip;
|
||||
if (tempu->type==IET_REL_I8 && !(MIN_I8<=r<=MAX_I8) ||
|
||||
tempu->type==IET_REL_I16 && !(MIN_I16<=r<=MAX_I16)) {
|
||||
} else if (!(tmpu->type&IEF_IMM_NOT_REL)) {
|
||||
r-=tmpu->rel_ip;
|
||||
if (tmpu->type==IET_REL_I8 && !(MIN_I8<=r<=MAX_I8) ||
|
||||
tmpu->type==IET_REL_I16 && !(MIN_I16<=r<=MAX_I16)) {
|
||||
PrintErr("Branch out of range at line:%04d %s\n",
|
||||
tempu->line_num,label);
|
||||
tmpu->line_num,label);
|
||||
LexExcept(cc);
|
||||
}
|
||||
if (tempu->U8_avail && tempu->type>IET_IMM_U8 && -124<=r<=123)
|
||||
if (tmpu->U8_avail && tmpu->type>IET_IMM_U8 && -124<=r<=123)
|
||||
PrintWarn("could use I8 displacement at line:%04d %s %s\n",
|
||||
tempu->line_num,cc->aotc->last_label,label);
|
||||
tmpu->line_num,cc->aotc->last_label,label);
|
||||
}
|
||||
AOTStoreCodeU8At(cc,tempu->ip,r.u8[0]);
|
||||
if (tempu->type>=IET_REL_I16) {
|
||||
AOTStoreCodeU8At(cc,tempu->ip+1,r.u8[1]);
|
||||
if (tempu->type>=IET_REL_I32) {
|
||||
AOTStoreCodeU8At(cc,tempu->ip+2,r.u8[2],r.u8[3]);
|
||||
if (tempu->type>=IET_REL_I64)
|
||||
AOTStoreCodeU8At(cc,tempu->ip+4,r.u8[4],r.u8[5],r.u8[6],r.u8[7]);
|
||||
AOTStoreCodeU8At(cc,tmpu->ip,r.u8[0]);
|
||||
if (tmpu->type>=IET_REL_I16) {
|
||||
AOTStoreCodeU8At(cc,tmpu->ip+1,r.u8[1]);
|
||||
if (tmpu->type>=IET_REL_I32) {
|
||||
AOTStoreCodeU8At(cc,tmpu->ip+2,r.u8[2],r.u8[3]);
|
||||
if (tmpu->type>=IET_REL_I64)
|
||||
AOTStoreCodeU8At(cc,tmpu->ip+4,r.u8[4],r.u8[5],r.u8[6],r.u8[7]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -42,30 +42,30 @@ U0 AsmResolve(CCmpCtrl *cc,CAsmUnresolvedRef *tempu,U8 *label,Bool undefined)
|
||||
U0 AOTLocalsResolve(CCmpCtrl *cc)
|
||||
{
|
||||
CAOTCtrl *aotc=cc->aotc;
|
||||
CAsmUnresolvedRef *tempu=aotc->local_unresolved,*tempu1;
|
||||
CAsmUndefHash *tempauh;
|
||||
CAsmUnresolvedRef *tmpu=aotc->local_unresolved,*tmpu1;
|
||||
CAsmUndefHash *tmpauh;
|
||||
Bool undefined;
|
||||
U8 *label=NULL;
|
||||
|
||||
while (tempu) {
|
||||
while (tmpu) {
|
||||
undefined=FALSE;
|
||||
tempu1=tempu->next;
|
||||
tempauh=tempu->asm_undef_hash;
|
||||
while (tempauh) {
|
||||
if (tempauh->hash->type & HTF_UNRESOLVED) {
|
||||
tmpu1=tmpu->next;
|
||||
tmpauh=tmpu->asm_undef_hash;
|
||||
while (tmpauh) {
|
||||
if (tmpauh->hash->type & HTF_UNRESOLVED) {
|
||||
PrintErr("Undefined sym at line:%04d %s %s\n",
|
||||
tempu->line_num,aotc->last_label,tempauh->hash->str);
|
||||
tmpu->line_num,aotc->last_label,tmpauh->hash->str);
|
||||
LexExcept(cc);
|
||||
}
|
||||
label=tempauh->hash->str;
|
||||
tempauh=tempauh->next;
|
||||
label=tmpauh->hash->str;
|
||||
tmpauh=tmpauh->next;
|
||||
}
|
||||
if (!undefined)
|
||||
AsmResolve(cc,tempu,label,FALSE);
|
||||
Free(tempu->machine_code);
|
||||
LinkedLstDel(tempu->asm_undef_hash);
|
||||
Free(tempu);
|
||||
tempu=tempu1;
|
||||
AsmResolve(cc,tmpu,label,FALSE);
|
||||
Free(tmpu->machine_code);
|
||||
LinkedLstDel(tmpu->asm_undef_hash);
|
||||
Free(tmpu);
|
||||
tmpu=tmpu1;
|
||||
}
|
||||
HashTableDel(cc->htc.local_hash_table);
|
||||
cc->htc.hash_table_lst=cc->htc.local_hash_table=HashTableNew(16);
|
||||
@@ -73,114 +73,114 @@ U0 AOTLocalsResolve(CCmpCtrl *cc)
|
||||
aotc->local_unresolved=NULL;
|
||||
}
|
||||
|
||||
U0 AOTGlblsResolve(CCmpCtrl *cc,CAOT *tempaot)
|
||||
U0 AOTGlblsResolve(CCmpCtrl *cc,CAOT *tmpaot)
|
||||
{
|
||||
CAOTCtrl *aotc=cc->aotc;
|
||||
CHashFun *tempf;
|
||||
CAsmUnresolvedRef *tempu=aotc->glbl_unresolved,*tempu1;
|
||||
CHashFun *tmpf;
|
||||
CAsmUnresolvedRef *tmpu=aotc->glbl_unresolved,*tmpu1;
|
||||
I64 i,j;
|
||||
CAOTImportExport *tempie,*tempie1;
|
||||
CAsmUndefHash *tempauh;
|
||||
CHashExport *tempex;
|
||||
CAOTImportExport *tmpie,*tmpie1;
|
||||
CAsmUndefHash *tmpauh;
|
||||
CHashExport *tmpex;
|
||||
U8 *label;
|
||||
Bool undefined;
|
||||
CExternUsage *tempeu,*tempeu8;
|
||||
CExternUsage *tmpeu,*tmpeu8;
|
||||
|
||||
while (tempu) {
|
||||
while (tmpu) {
|
||||
label=NULL;
|
||||
undefined=FALSE;
|
||||
tempu1=tempu->next;
|
||||
tempauh=tempu->asm_undef_hash;
|
||||
while (tempauh) {
|
||||
if (tempauh->hash->type & HTF_UNRESOLVED) {
|
||||
tempex=tempauh->hash;
|
||||
if (tempex->type & HTT_EXPORT_SYS_SYM&& tempex->type & HTF_UNRESOLVED &&
|
||||
!(tempex->type & HTF_IMPORT) &&
|
||||
(tempf=HashFind(tempex->str,cc->htc.hash_table_lst,HTT_FUN)) &&
|
||||
!Bt(&tempf->flags,Cf_EXTERN)) {
|
||||
tempex->val=tempf->exe_addr;
|
||||
tempex->type&=~HTF_UNRESOLVED;
|
||||
label=tempauh->hash->str;
|
||||
tmpu1=tmpu->next;
|
||||
tmpauh=tmpu->asm_undef_hash;
|
||||
while (tmpauh) {
|
||||
if (tmpauh->hash->type & HTF_UNRESOLVED) {
|
||||
tmpex=tmpauh->hash;
|
||||
if (tmpex->type & HTT_EXPORT_SYS_SYM&& tmpex->type & HTF_UNRESOLVED &&
|
||||
!(tmpex->type & HTF_IMPORT) &&
|
||||
(tmpf=HashFind(tmpex->str,cc->htc.hash_table_lst,HTT_FUN)) &&
|
||||
!Bt(&tmpf->flags,Cf_EXTERN)) {
|
||||
tmpex->val=tmpf->exe_addr;
|
||||
tmpex->type&=~HTF_UNRESOLVED;
|
||||
label=tmpauh->hash->str;
|
||||
} else {
|
||||
if (!(tempex->type & HTF_IMPORT)) {
|
||||
if (!(tmpex->type & HTF_IMPORT)) {
|
||||
if (cc->htc.local_var_lst) {
|
||||
tempex->type|=HTF_GOTO_LABEL;
|
||||
tempex->use_cnt++;
|
||||
tmpex->type|=HTF_GOTO_LABEL;
|
||||
tmpex->use_cnt++;
|
||||
} else {
|
||||
PrintErr("Undefined sym at line:%04d %s\n",
|
||||
tempu->line_num,tempex->str);
|
||||
tmpu->line_num,tmpex->str);
|
||||
LexExcept(cc);
|
||||
}
|
||||
} else if (undefined) {
|
||||
PrintErr("Two imports in same expression "
|
||||
"not allowed at line:%04d %s\n",
|
||||
tempu->line_num,tempex->str);
|
||||
tmpu->line_num,tmpex->str);
|
||||
LexExcept(cc);
|
||||
}
|
||||
undefined=TRUE;
|
||||
}
|
||||
} else
|
||||
label=tempauh->hash->str;
|
||||
tempauh=tempauh->next;
|
||||
label=tmpauh->hash->str;
|
||||
tmpauh=tmpauh->next;
|
||||
}
|
||||
AsmResolve(cc,tempu,label,undefined);
|
||||
Free(tempu->machine_code);
|
||||
LinkedLstDel(tempu->asm_undef_hash);
|
||||
Free(tempu);
|
||||
tempu=tempu1;
|
||||
AsmResolve(cc,tmpu,label,undefined);
|
||||
Free(tmpu->machine_code);
|
||||
LinkedLstDel(tmpu->asm_undef_hash);
|
||||
Free(tmpu);
|
||||
tmpu=tmpu1;
|
||||
}
|
||||
|
||||
for (i=0;i<=cc->htc.glbl_hash_table->mask;i++) {
|
||||
tempex=cc->htc.glbl_hash_table->body[i];
|
||||
while (tempex) {
|
||||
if (tempex->type & (HTF_IMPORT|HTF_GOTO_LABEL)) {
|
||||
if (tempex->use_cnt && (tempie=tempex->ie_lst)) {
|
||||
if (tempex->type&HTF_GOTO_LABEL)
|
||||
tempie->flags|=IEF_GOTO_LABEL;
|
||||
if (tempex->import_name)
|
||||
tempie->str=StrNew(tempex->import_name);
|
||||
tmpex=cc->htc.glbl_hash_table->body[i];
|
||||
while (tmpex) {
|
||||
if (tmpex->type & (HTF_IMPORT|HTF_GOTO_LABEL)) {
|
||||
if (tmpex->use_cnt && (tmpie=tmpex->ie_lst)) {
|
||||
if (tmpex->type&HTF_GOTO_LABEL)
|
||||
tmpie->flags|=IEF_GOTO_LABEL;
|
||||
if (tmpex->import_name)
|
||||
tmpie->str=StrNew(tmpex->import_name);
|
||||
else
|
||||
tempie->str=StrNew(tempex->str);
|
||||
tmpie->str=StrNew(tmpex->str);
|
||||
do {
|
||||
tempie1=tempie->next;
|
||||
QueIns(tempie,tempaot->last_ie);
|
||||
} while (tempie=tempie1);
|
||||
tempex->ie_lst=NULL;
|
||||
tmpie1=tmpie->next;
|
||||
QueIns(tmpie,tmpaot->last_ie);
|
||||
} while (tmpie=tmpie1);
|
||||
tmpex->ie_lst=NULL;
|
||||
}
|
||||
} else if (tempex->type & (HTF_EXPORT|HTF_RESOLVE)) {
|
||||
if (tempex->type & HTF_UNRESOLVED) {
|
||||
PrintErr("Undefined sym at %s\n",tempex->str);
|
||||
} else if (tmpex->type & (HTF_EXPORT|HTF_RESOLVE)) {
|
||||
if (tmpex->type & HTF_UNRESOLVED) {
|
||||
PrintErr("Undefined sym at %s\n",tmpex->str);
|
||||
LexExcept(cc);
|
||||
}
|
||||
if (tempex->type & HTF_RESOLVE) {
|
||||
tempf=tempex;
|
||||
tempeu=tempf->ext_lst;
|
||||
while (tempeu) {
|
||||
tempeu8=tempeu->next;
|
||||
j=tempf->exe_addr-(tempeu->ip+4);
|
||||
AOTStoreCodeU8At(cc,tempeu->ip,j.u8[0],j.u8[1],j.u8[2],j.u8[3]);
|
||||
Free(tempeu);
|
||||
tempeu=tempeu8;
|
||||
if (tmpex->type & HTF_RESOLVE) {
|
||||
tmpf=tmpex;
|
||||
tmpeu=tmpf->ext_lst;
|
||||
while (tmpeu) {
|
||||
tmpeu8=tmpeu->next;
|
||||
j=tmpf->exe_addr-(tmpeu->ip+4);
|
||||
AOTStoreCodeU8At(cc,tmpeu->ip,j.u8[0],j.u8[1],j.u8[2],j.u8[3]);
|
||||
Free(tmpeu);
|
||||
tmpeu=tmpeu8;
|
||||
}
|
||||
}
|
||||
if (tempex->type & HTF_EXPORT) {
|
||||
tempie=CAlloc(sizeof(CAOTImportExport));
|
||||
tempie->type=IET_REL32_EXPORT;
|
||||
if (tempex->type & HTT_FUN)
|
||||
tempie->ip=tempf->exe_addr;
|
||||
else if (tempex->type & HTT_GLBL_VAR)
|
||||
tempie->ip=tempex(CHashGlblVar *)->data_addr_ip;
|
||||
if (tmpex->type & HTF_EXPORT) {
|
||||
tmpie=CAlloc(sizeof(CAOTImportExport));
|
||||
tmpie->type=IET_REL32_EXPORT;
|
||||
if (tmpex->type & HTT_FUN)
|
||||
tmpie->ip=tmpf->exe_addr;
|
||||
else if (tmpex->type & HTT_GLBL_VAR)
|
||||
tmpie->ip=tmpex(CHashGlblVar *)->data_addr_ip;
|
||||
else
|
||||
tempie->ip=tempex->val;
|
||||
tempie->aot=cc->aot;
|
||||
if (tempex->type & HTF_IMM)
|
||||
tempie->type++;
|
||||
tempie->str=StrNew(tempex->str);
|
||||
tempie->src_link=StrNew(tempex->src_link);
|
||||
QueIns(tempie,tempaot->last_ie);
|
||||
tmpie->ip=tmpex->val;
|
||||
tmpie->aot=cc->aot;
|
||||
if (tmpex->type & HTF_IMM)
|
||||
tmpie->type++;
|
||||
tmpie->str=StrNew(tmpex->str);
|
||||
tmpie->src_link=StrNew(tmpex->src_link);
|
||||
QueIns(tmpie,tmpaot->last_ie);
|
||||
}
|
||||
}
|
||||
tempex=tempex->next;
|
||||
tmpex=tmpex->next;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -189,28 +189,28 @@ U0 AsmUnresolvedAdd(CCmpCtrl *cc,U8 *machine_code,I64 type,I64 ip,I64 rel_ip,
|
||||
CAsmUndefHash *local_asm_undef_hash,CAsmUndefHash *glbl_asm_undef_hash,
|
||||
I64 line_num,Bool U8_avail)
|
||||
{
|
||||
CAsmUnresolvedRef *tempu=MAlloc(sizeof(CAsmUnresolvedRef));
|
||||
tempu->machine_code=machine_code;
|
||||
tempu->type=type;
|
||||
tempu->ip=ip;
|
||||
tempu->rel_ip=rel_ip;
|
||||
tempu->aot=cc->aot;
|
||||
tempu->imm_flag=FALSE;
|
||||
tempu->line_num=line_num;
|
||||
tempu->U8_avail=U8_avail;
|
||||
tempu->str=NULL;
|
||||
CAsmUnresolvedRef *tmpu=MAlloc(sizeof(CAsmUnresolvedRef));
|
||||
tmpu->machine_code=machine_code;
|
||||
tmpu->type=type;
|
||||
tmpu->ip=ip;
|
||||
tmpu->rel_ip=rel_ip;
|
||||
tmpu->aot=cc->aot;
|
||||
tmpu->imm_flag=FALSE;
|
||||
tmpu->line_num=line_num;
|
||||
tmpu->U8_avail=U8_avail;
|
||||
tmpu->str=NULL;
|
||||
if (local_asm_undef_hash) {
|
||||
tempu->asm_undef_hash=local_asm_undef_hash;
|
||||
tempu->next=cc->aotc->local_unresolved;
|
||||
cc->aotc->local_unresolved=tempu;
|
||||
tmpu->asm_undef_hash=local_asm_undef_hash;
|
||||
tmpu->next=cc->aotc->local_unresolved;
|
||||
cc->aotc->local_unresolved=tmpu;
|
||||
} else {
|
||||
tempu->asm_undef_hash=glbl_asm_undef_hash;
|
||||
tempu->next=cc->aotc->glbl_unresolved;
|
||||
cc->aotc->glbl_unresolved=tempu;
|
||||
tmpu->asm_undef_hash=glbl_asm_undef_hash;
|
||||
tmpu->next=cc->aotc->glbl_unresolved;
|
||||
cc->aotc->glbl_unresolved=tmpu;
|
||||
if (glbl_asm_undef_hash->hash->type & HTF_IMPORT) {
|
||||
tempu->str=StrNew(glbl_asm_undef_hash->hash->str);
|
||||
tmpu->str=StrNew(glbl_asm_undef_hash->hash->str);
|
||||
if (glbl_asm_undef_hash->hash->type & HTF_IMM)
|
||||
tempu->imm_flag=TRUE;
|
||||
tmpu->imm_flag=TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
+296
-296
@@ -1,7 +1,7 @@
|
||||
U0 ICAddEct(CIntermediateCode *tempi,CICType t1,I64 r1,I64 d1,
|
||||
U0 ICAddEct(CIntermediateCode *tmpi,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,res_reg=REG_RAX;
|
||||
I64 i,tmp,res_reg=REG_RAX;
|
||||
Bool swap=FALSE;
|
||||
if (r3!=res_reg) {
|
||||
swap^=TRUE;
|
||||
@@ -12,48 +12,48 @@ U0 ICAddEct(CIntermediateCode *tempi,CICType t1,I64 r1,I64 d1,
|
||||
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))
|
||||
res_reg=r1;
|
||||
ICMov(tempi,MDF_REG+RT_I64,res_reg,0,t3,r3,d3,ip);
|
||||
ICMov(tmpi,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]);
|
||||
ICU16(tempi,i.u8[2]<<8+op);
|
||||
ICModr2(tempi,i,d2,ip+4);
|
||||
if (tmpi->ic_flags&ICF_LOCK)
|
||||
ICU8(tmpi,OC_LOCK_PREFIX);
|
||||
ICRex(tmpi,i.u8[1]);
|
||||
ICU16(tmpi,i.u8[2]<<8+op);
|
||||
ICModr2(tmpi,i,d2,ip+4);
|
||||
} else {
|
||||
if (t2&MDF_REG)
|
||||
temp=r2;
|
||||
tmp=r2;
|
||||
else
|
||||
temp=REG_RCX;
|
||||
tmp=REG_RCX;
|
||||
|
||||
if (t1&MDF_REG)
|
||||
res_reg=r1;
|
||||
|
||||
if (temp==res_reg)
|
||||
if (tmp==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,res_reg,0,t3,r3,d3,ip);
|
||||
if (r3==tmp && t3&MDG_REG_DISP_SIB)
|
||||
tmp=REG_RCX;
|
||||
ICMov(tmpi,MDF_REG+RT_I64,tmp,0,t2,r2,d2,ip);
|
||||
ICMov(tmpi,MDF_REG+RT_I64,res_reg,0,t3,r3,d3,ip);
|
||||
} else {
|
||||
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);
|
||||
ICMov(tmpi,MDF_REG+RT_I64,res_reg,0,t3,r3,d3,ip);
|
||||
ICMov(tmpi,MDF_REG+RT_I64,tmp,0,t2,r2,d2,ip);
|
||||
}
|
||||
i=0x48;
|
||||
if (res_reg>7)
|
||||
i+=4;
|
||||
if (temp>7)
|
||||
if (tmp>7)
|
||||
i++;
|
||||
if (tempi->ic_flags&ICF_LOCK)
|
||||
ICU8(tempi,OC_LOCK_PREFIX);
|
||||
ICU24(tempi,0xC00000+i+(temp&7)<<16+(res_reg&7)<<19+op<<8);
|
||||
if (tmpi->ic_flags&ICF_LOCK)
|
||||
ICU8(tmpi,OC_LOCK_PREFIX);
|
||||
ICU24(tmpi,0xC00000+i+(tmp&7)<<16+(res_reg&7)<<19+op<<8);
|
||||
}
|
||||
ICMov(tempi,t1,r1,d1,MDF_REG+RT_I64,res_reg,0,ip);
|
||||
ICMov(tmpi,t1,r1,d1,MDF_REG+RT_I64,res_reg,0,ip);
|
||||
}
|
||||
|
||||
U0 ICAddSubEctImm(CIntermediateCode *tempi,CICType t1,I64 r1,I64 d1,
|
||||
U0 ICAddSubEctImm(CIntermediateCode *tmpi,CICType t1,I64 r1,I64 d1,
|
||||
CICType t2,I64 r2,I64 d2,I64 d,I64 op,I64 ip)
|
||||
{
|
||||
I64 i,r;
|
||||
@@ -63,7 +63,7 @@ U0 ICAddSubEctImm(CIntermediateCode *tempi,CICType t1,I64 r1,I64 d1,
|
||||
}
|
||||
if (t1&MDF_REG) {
|
||||
if (!(t2&MDF_REG)) {
|
||||
ICMov(tempi,t1,r1,d1,t2,r2,d2,ip);
|
||||
ICMov(tmpi,t1,r1,d1,t2,r2,d2,ip);
|
||||
t2=t1;
|
||||
r2=r1;
|
||||
d2=d1;
|
||||
@@ -77,18 +77,18 @@ U0 ICAddSubEctImm(CIntermediateCode *tempi,CICType t1,I64 r1,I64 d1,
|
||||
(op.u8[0]==0x03||op.u8[0]==0x2B||op.u8[0]==0x33||op.u8[0]==0x0B))
|
||||
return;
|
||||
else if (d==1 && op.u8[0]==0x03) {
|
||||
ICU24(tempi,0xC0FF00+op.u8[1]<<19+i+(r1&7)<<16);
|
||||
ICU24(tmpi,0xC0FF00+op.u8[1]<<19+i+(r1&7)<<16);
|
||||
return;
|
||||
} else if (d==-1 && op.u8[0]==0x03) {
|
||||
ICU24(tempi,0xC8FF00+i+(r1&7)<<16);
|
||||
ICU24(tmpi,0xC8FF00+i+(r1&7)<<16);
|
||||
return;
|
||||
} else if (MIN_I8<=d<=MAX_I8) {
|
||||
ICU24(tempi,0xC08300+op.u8[1]<<19+i+(r1&7)<<16);
|
||||
ICU8(tempi,d);
|
||||
ICU24(tmpi,0xC08300+op.u8[1]<<19+i+(r1&7)<<16);
|
||||
ICU8(tmpi,d);
|
||||
return;
|
||||
} else if (MIN_I32<=d<=MAX_I32) {
|
||||
ICU24(tempi,0xC08100+op.u8[1]<<19+i+(r1&7)<<16);
|
||||
ICU32(tempi,d);
|
||||
ICU24(tmpi,0xC08100+op.u8[1]<<19+i+(r1&7)<<16);
|
||||
ICU32(tmpi,d);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -96,8 +96,8 @@ U0 ICAddSubEctImm(CIntermediateCode *tempi,CICType t1,I64 r1,I64 d1,
|
||||
!Bt(&cmp.non_ptr_vars_mask,r2)) {
|
||||
i=ICModr1(r1,MDF_DISP+RT_I64,r2,d);
|
||||
i.u8[1]|=0x48;
|
||||
ICU24(tempi,i.u8[2]<<16+0x8D00+i.u8[1]);
|
||||
ICModr2(tempi,i,d,ip+4);
|
||||
ICU24(tmpi,i.u8[2]<<16+0x8D00+i.u8[1]);
|
||||
ICModr2(tmpi,i,d,ip+4);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -107,7 +107,7 @@ U0 ICAddSubEctImm(CIntermediateCode *tempi,CICType t1,I64 r1,I64 d1,
|
||||
case MDf_SIB:
|
||||
case MDf_RIP_DISP32:
|
||||
if (t1!=t2 || r1!=r2 || d1!=d2) {
|
||||
ICMov(tempi,t1,r1,d1,t2,r2,d2,ip);
|
||||
ICMov(tmpi,t1,r1,d1,t2,r2,d2,ip);
|
||||
t2=t1;
|
||||
r2=r1;
|
||||
d2=d1;
|
||||
@@ -121,88 +121,88 @@ U0 ICAddSubEctImm(CIntermediateCode *tempi,CICType t1,I64 r1,I64 d1,
|
||||
|
||||
if (op.u8[0]==0x03 && (d==1 || d==-1)) { //Add
|
||||
i=ICModr1(r,t1,r1,d1);
|
||||
if (!(t1&MDF_REG) && tempi->ic_flags&ICF_LOCK)
|
||||
ICU8(tempi,OC_LOCK_PREFIX);
|
||||
if (!(t1&MDF_REG) && tmpi->ic_flags&ICF_LOCK)
|
||||
ICU8(tmpi,OC_LOCK_PREFIX);
|
||||
switch (t1.raw_type) {
|
||||
case RT_I8:
|
||||
case RT_U8:
|
||||
ICRex(tempi,i.u8[1]);
|
||||
ICU16(tempi,i.u8[2]<<8+0xFE);
|
||||
ICRex(tmpi,i.u8[1]);
|
||||
ICU16(tmpi,i.u8[2]<<8+0xFE);
|
||||
break;
|
||||
case RT_I16:
|
||||
case RT_U16:
|
||||
ICOpSizeRex(tempi,i.u8[1]);
|
||||
ICU16(tempi,i.u8[2]<<8+0xFF);
|
||||
ICOpSizeRex(tmpi,i.u8[1]);
|
||||
ICU16(tmpi,i.u8[2]<<8+0xFF);
|
||||
break;
|
||||
default:
|
||||
ICRex(tempi,i.u8[1]);
|
||||
ICU16(tempi,i.u8[2]<<8+0xFF);
|
||||
ICRex(tmpi,i.u8[1]);
|
||||
ICU16(tmpi,i.u8[2]<<8+0xFF);
|
||||
}
|
||||
ICModr2(tempi,i,d1,ip+4);
|
||||
ICModr2(tmpi,i,d1,ip+4);
|
||||
return;
|
||||
}
|
||||
if (MIN_I8<=d<=MAX_I8 || t1&(RTG_MASK-RTF_UNSIGNED)==RT_I8) {
|
||||
i=ICModr1(r,t1,r1,d1);
|
||||
if (tempi->ic_flags&ICF_LOCK)
|
||||
ICU8(tempi,OC_LOCK_PREFIX);
|
||||
if (tmpi->ic_flags&ICF_LOCK)
|
||||
ICU8(tmpi,OC_LOCK_PREFIX);
|
||||
switch (t1.raw_type) {
|
||||
case RT_I8:
|
||||
case RT_U8:
|
||||
ICRex(tempi,i.u8[1]);
|
||||
ICU16(tempi,i.u8[2]<<8+0x80);
|
||||
ICRex(tmpi,i.u8[1]);
|
||||
ICU16(tmpi,i.u8[2]<<8+0x80);
|
||||
break;
|
||||
case RT_I16:
|
||||
case RT_U16:
|
||||
ICOpSizeRex(tempi,i.u8[1]);
|
||||
ICU16(tempi,i.u8[2]<<8+0x83);
|
||||
ICOpSizeRex(tmpi,i.u8[1]);
|
||||
ICU16(tmpi,i.u8[2]<<8+0x83);
|
||||
break;
|
||||
default:
|
||||
ICRex(tempi,i.u8[1]);
|
||||
ICU16(tempi,i.u8[2]<<8+0x83);
|
||||
ICRex(tmpi,i.u8[1]);
|
||||
ICU16(tmpi,i.u8[2]<<8+0x83);
|
||||
}
|
||||
ICModr2(tempi,i,d1,ip+5);
|
||||
ICU8(tempi,d);
|
||||
ICModr2(tmpi,i,d1,ip+5);
|
||||
ICU8(tmpi,d);
|
||||
return;
|
||||
}
|
||||
if (MIN_I32<=d<=MAX_I32 || t1.raw_type<RT_I64) {
|
||||
i=ICModr1(r,t1,r1,d1);
|
||||
if (tempi->ic_flags&ICF_LOCK)
|
||||
ICU8(tempi,OC_LOCK_PREFIX);
|
||||
if (tmpi->ic_flags&ICF_LOCK)
|
||||
ICU8(tmpi,OC_LOCK_PREFIX);
|
||||
switch (t1.raw_type) {
|
||||
case RT_I16:
|
||||
case RT_U16:
|
||||
ICOpSizeRex(tempi,i.u8[1]);
|
||||
ICU16(tempi,i.u8[2]<<8+0x81);
|
||||
ICOpSizeRex(tmpi,i.u8[1]);
|
||||
ICU16(tmpi,i.u8[2]<<8+0x81);
|
||||
break;
|
||||
default:
|
||||
ICRex(tempi,i.u8[1]);
|
||||
ICU16(tempi,i.u8[2]<<8+0x81);
|
||||
ICRex(tmpi,i.u8[1]);
|
||||
ICU16(tmpi,i.u8[2]<<8+0x81);
|
||||
}
|
||||
if (i.u8[0]!=MODR_RIP_REL)
|
||||
ICModr2(tempi,i,d1,);
|
||||
ICModr2(tmpi,i,d1,);
|
||||
else {
|
||||
if (t1&(RTG_MASK-RTF_UNSIGNED)==RT_I16)
|
||||
ICU32(tempi,d1-(ip+tempi->ic_cnt+6));
|
||||
ICU32(tmpi,d1-(ip+tmpi->ic_cnt+6));
|
||||
else
|
||||
ICU32(tempi,d1-(ip+tempi->ic_cnt+8));
|
||||
tempi->ic_flags&=~ICF_CODE_FINAL;
|
||||
ICU32(tmpi,d1-(ip+tmpi->ic_cnt+8));
|
||||
tmpi->ic_flags&=~ICF_CODE_FINAL;
|
||||
}
|
||||
if (t1&(RTG_MASK-RTF_UNSIGNED)==RT_I16)
|
||||
ICU16(tempi,d);
|
||||
ICU16(tmpi,d);
|
||||
else
|
||||
ICU32(tempi,d);
|
||||
ICU32(tmpi,d);
|
||||
return;
|
||||
}
|
||||
break;
|
||||
case MDf_STK:
|
||||
ICAddSubEctImm(tempi,MDF_REG+RT_I64,REG_RAX,0,t2,r2,d2,d,op,ip);
|
||||
ICPushRegs(tempi,1<<REG_RAX);
|
||||
ICAddSubEctImm(tmpi,MDF_REG+RT_I64,REG_RAX,0,t2,r2,d2,d,op,ip);
|
||||
ICPushRegs(tmpi,1<<REG_RAX);
|
||||
return;
|
||||
}
|
||||
ICAddEct(tempi,t1,r1,d1,MDF_IMM+RT_I64,0,d,t2,r2,d2,op.u8[0],ip);
|
||||
ICAddEct(tmpi,t1,r1,d1,MDF_IMM+RT_I64,0,d,t2,r2,d2,op.u8[0],ip);
|
||||
}
|
||||
|
||||
U0 ICSub(CIntermediateCode *tempi,CICType t1,I64 r1,I64 d1,
|
||||
U0 ICSub(CIntermediateCode *tmpi,CICType t1,I64 r1,I64 d1,
|
||||
CICType t2,I64 r2,I64 d2,CICType t3,I64 r3,I64 d3,I64 ip)
|
||||
{
|
||||
I64 i=0x48,op=0x2B;
|
||||
@@ -215,97 +215,97 @@ U0 ICSub(CIntermediateCode *tempi,CICType t1,I64 r1,I64 d1,
|
||||
}
|
||||
if (t2.raw_type>=RT_I64 && r2.u8[0]!=REG_RAX &&
|
||||
(!(t2&MDF_SIB) || r2.u8[1]&15!=REG_RAX) && t2&MDG_REG_DISP_SIB_RIP) {
|
||||
ICMov(tempi,MDF_REG+RT_I64,REG_RAX,0,t3,r3,d3,ip);
|
||||
ICMov(tmpi,MDF_REG+RT_I64,REG_RAX,0,t3,r3,d3,ip);
|
||||
if (!swap) {
|
||||
op=0x03;
|
||||
ICU24(tempi,0xD8F748);
|
||||
ICU24(tmpi,0xD8F748);
|
||||
}
|
||||
i=ICModr1(REG_RAX,t2,r2,d2);
|
||||
if (tempi->ic_flags&ICF_LOCK)
|
||||
ICU8(tempi,OC_LOCK_PREFIX);
|
||||
ICRex(tempi,i.u8[1]);
|
||||
ICU16(tempi,i.u8[2]<<8+op);
|
||||
ICModr2(tempi,i,d2,ip+4);
|
||||
ICMov(tempi,t1,r1,d1,MDF_REG+RT_I64,REG_RAX,0,ip);
|
||||
if (tmpi->ic_flags&ICF_LOCK)
|
||||
ICU8(tmpi,OC_LOCK_PREFIX);
|
||||
ICRex(tmpi,i.u8[1]);
|
||||
ICU16(tmpi,i.u8[2]<<8+op);
|
||||
ICModr2(tmpi,i,d2,ip+4);
|
||||
ICMov(tmpi,t1,r1,d1,MDF_REG+RT_I64,REG_RAX,0,ip);
|
||||
} else {
|
||||
if (!(t3&MDF_REG) || t3.raw_type<RT_I64) {
|
||||
if (swap) {
|
||||
swap=FALSE;
|
||||
ICMov(tempi,MDF_REG+RT_I64,REG_RAX,0,t3,r3,d3,ip);
|
||||
ICMov(tempi,MDF_REG+RT_I64,REG_RCX,0,t2,r2,d2,ip);
|
||||
ICMov(tmpi,MDF_REG+RT_I64,REG_RAX,0,t3,r3,d3,ip);
|
||||
ICMov(tmpi,MDF_REG+RT_I64,REG_RCX,0,t2,r2,d2,ip);
|
||||
r2=REG_RAX;
|
||||
r3=REG_RCX;
|
||||
} else {
|
||||
ICMov(tempi,MDF_REG+RT_I64,REG_RAX,0,t3,r3,d3,ip);
|
||||
ICMov(tempi,MDF_REG+RT_I64,REG_RCX,0,t2,r2,d2,ip);
|
||||
ICMov(tmpi,MDF_REG+RT_I64,REG_RAX,0,t3,r3,d3,ip);
|
||||
ICMov(tmpi,MDF_REG+RT_I64,REG_RCX,0,t2,r2,d2,ip);
|
||||
r3=REG_RAX;
|
||||
r2=REG_RCX;
|
||||
}
|
||||
} else {
|
||||
ICMov(tempi,MDF_REG+RT_I64,REG_RCX,0,t2,r2,d2,ip);
|
||||
ICMov(tmpi,MDF_REG+RT_I64,REG_RCX,0,t2,r2,d2,ip);
|
||||
r2=REG_RCX;
|
||||
}
|
||||
if (swap) {
|
||||
op=0x03;
|
||||
ICU24(tempi,0xD9F748);
|
||||
ICU24(tmpi,0xD9F748);
|
||||
}
|
||||
if (r3>7)
|
||||
i++;
|
||||
if (r2>7)
|
||||
i+=4;
|
||||
if (tempi->ic_flags&ICF_LOCK)
|
||||
ICU8(tempi,OC_LOCK_PREFIX);
|
||||
ICU24(tempi,0xC00000+i+(r3&7)<<16+(r2&7)<<19+op<<8);
|
||||
ICMov(tempi,t1,r1,d1,MDF_REG+RT_I64,r2,0,ip);
|
||||
if (tmpi->ic_flags&ICF_LOCK)
|
||||
ICU8(tmpi,OC_LOCK_PREFIX);
|
||||
ICU24(tmpi,0xC00000+i+(r3&7)<<16+(r2&7)<<19+op<<8);
|
||||
ICMov(tmpi,t1,r1,d1,MDF_REG+RT_I64,r2,0,ip);
|
||||
}
|
||||
}
|
||||
|
||||
U0 ICMul(CIntermediateCode *tempi,I64 ip)
|
||||
U0 ICMul(CIntermediateCode *tmpi,I64 ip)
|
||||
{
|
||||
I64 i,r2,r=REG_RAX,j;
|
||||
CICArg *a1,*a2;
|
||||
Bool alt;
|
||||
if (tempi->a1.type&MDF_IMM) {
|
||||
a1=&tempi->a2;
|
||||
a2=&tempi->a1;
|
||||
if (tmpi->a1.type&MDF_IMM) {
|
||||
a1=&tmpi->a2;
|
||||
a2=&tmpi->a1;
|
||||
alt=TRUE;
|
||||
} else {
|
||||
a1=&tempi->a1;
|
||||
a2=&tempi->a2;
|
||||
a1=&tmpi->a1;
|
||||
a2=&tmpi->a2;
|
||||
alt=FALSE;
|
||||
}
|
||||
i=a2->disp;
|
||||
if (!(tempi->ic_class->raw_type&RTF_UNSIGNED) &&
|
||||
if (!(tmpi->ic_class->raw_type&RTF_UNSIGNED) &&
|
||||
a2->type&MDF_IMM && MIN_I32<=i<=MAX_I32) {
|
||||
if (tempi->r.type==MDF_REG+RT_I64) {
|
||||
ICMov(tempi,tempi->r.type,tempi->r.reg,tempi->r.disp,
|
||||
if (tmpi->r.type==MDF_REG+RT_I64) {
|
||||
ICMov(tmpi,tmpi->r.type,tmpi->r.reg,tmpi->r.disp,
|
||||
a1->type,a1->reg,a1->disp,ip);
|
||||
r=tempi->r.reg;
|
||||
r=tmpi->r.reg;
|
||||
} else
|
||||
ICMov(tempi,MDF_REG+RT_I64,REG_RAX,0,a1->type,a1->reg,a1->disp,ip);
|
||||
ICMov(tmpi,MDF_REG+RT_I64,REG_RAX,0,a1->type,a1->reg,a1->disp,ip);
|
||||
if (r>7)
|
||||
j=0xC0004D;
|
||||
else
|
||||
j=0xC00048;
|
||||
if (MIN_I8<=i<=MAX_I8)
|
||||
ICU32(tempi,i<<24+0x6B00+j+(r&7)<<16+(r&7)<<19);
|
||||
ICU32(tmpi,i<<24+0x6B00+j+(r&7)<<16+(r&7)<<19);
|
||||
else {
|
||||
ICU24(tempi,0x6900+j+(r&7)<<16+(r&7)<<19);
|
||||
ICU32(tempi,i);
|
||||
ICU24(tmpi,0x6900+j+(r&7)<<16+(r&7)<<19);
|
||||
ICU32(tmpi,i);
|
||||
}
|
||||
} else {
|
||||
if (tempi->ic_class->raw_type&RTF_UNSIGNED)
|
||||
if (tmpi->ic_class->raw_type&RTF_UNSIGNED)
|
||||
i=0xE0F748;
|
||||
else
|
||||
i=0xE8F748;
|
||||
if (alt) {
|
||||
ICMov(tempi,MDF_REG+RT_I64,REG_RCX,0,a1->type,a1->reg,a1->disp,ip);
|
||||
ICMov(tmpi,MDF_REG+RT_I64,REG_RCX,0,a1->type,a1->reg,a1->disp,ip);
|
||||
r2=REG_RCX;
|
||||
ICMov(tempi,MDF_REG+RT_I64,REG_RAX,0,a2->type,a2->reg,a2->disp,ip);
|
||||
ICMov(tmpi,MDF_REG+RT_I64,REG_RAX,0,a2->type,a2->reg,a2->disp,ip);
|
||||
} else {
|
||||
ICMov(tempi,MDF_REG+RT_I64,REG_RAX,0,a2->type,a2->reg,a2->disp,ip);
|
||||
ICMov(tmpi,MDF_REG+RT_I64,REG_RAX,0,a2->type,a2->reg,a2->disp,ip);
|
||||
if (!(a1->type&MDF_REG) || a1->type.raw_type<RT_I64) {
|
||||
ICMov(tempi,MDF_REG+RT_I64,REG_RCX,0,a1->type,a1->reg,a1->disp,ip);
|
||||
ICMov(tmpi,MDF_REG+RT_I64,REG_RCX,0,a1->type,a1->reg,a1->disp,ip);
|
||||
r2=REG_RCX;
|
||||
} else
|
||||
r2=a1->reg;
|
||||
@@ -314,196 +314,196 @@ U0 ICMul(CIntermediateCode *tempi,I64 ip)
|
||||
i++;
|
||||
r2&=7;
|
||||
}
|
||||
ICU24(tempi,i+r2<<16);
|
||||
ICU24(tmpi,i+r2<<16);
|
||||
}
|
||||
ICMov(tempi,tempi->r.type,tempi->r.reg,tempi->r.disp,MDF_REG+RT_I64,r,0,ip);
|
||||
ICMov(tmpi,tmpi->r.type,tmpi->r.reg,tmpi->r.disp,MDF_REG+RT_I64,r,0,ip);
|
||||
}
|
||||
|
||||
U0 ICMulEqu(CIntermediateCode *tempi,I64 ip)
|
||||
U0 ICMulEqu(CIntermediateCode *tmpi,I64 ip)
|
||||
{
|
||||
I64 i=tempi->a2.disp,r=REG_RAX,j;
|
||||
if (!(tempi->ic_class->raw_type&RTF_UNSIGNED) &&
|
||||
tempi->a2.type&MDF_IMM && MIN_I32<=i<=MAX_I32) {
|
||||
if (tempi->ic_flags & ICF_BY_VAL) {
|
||||
if (tempi->a1.type==MDF_REG+RT_I64)
|
||||
r=tempi->a1.reg;
|
||||
I64 i=tmpi->a2.disp,r=REG_RAX,j;
|
||||
if (!(tmpi->ic_class->raw_type&RTF_UNSIGNED) &&
|
||||
tmpi->a2.type&MDF_IMM && MIN_I32<=i<=MAX_I32) {
|
||||
if (tmpi->ic_flags & ICF_BY_VAL) {
|
||||
if (tmpi->a1.type==MDF_REG+RT_I64)
|
||||
r=tmpi->a1.reg;
|
||||
else
|
||||
ICMov(tempi,MDF_REG+RT_I64,REG_RAX,0,
|
||||
tempi->a1.type&MDG_MASK+tempi->a1_type_pointed_to,
|
||||
tempi->a1.reg,tempi->a1.disp,ip);
|
||||
ICMov(tmpi,MDF_REG+RT_I64,REG_RAX,0,
|
||||
tmpi->a1.type&MDG_MASK+tmpi->a1_type_pointed_to,
|
||||
tmpi->a1.reg,tmpi->a1.disp,ip);
|
||||
if (r>7)
|
||||
j=0xC0004D;
|
||||
else
|
||||
j=0xC00048;
|
||||
if (MIN_I8<=i<=MAX_I8)
|
||||
ICU32(tempi,i<<24+0x6B00+j+(r&7)<<16+(r&7)<<19);
|
||||
ICU32(tmpi,i<<24+0x6B00+j+(r&7)<<16+(r&7)<<19);
|
||||
else {
|
||||
ICU24(tempi,0x6900+j+(r&7)<<16+(r&7)<<19);
|
||||
ICU32(tempi,i);
|
||||
ICU24(tmpi,0x6900+j+(r&7)<<16+(r&7)<<19);
|
||||
ICU32(tmpi,i);
|
||||
}
|
||||
ICMov(tempi,tempi->a1.type&MDG_MASK+tempi->a1_type_pointed_to,
|
||||
tempi->a1.reg,tempi->a1.disp,MDF_REG+RT_I64,r,0,ip);
|
||||
ICMov(tmpi,tmpi->a1.type&MDG_MASK+tmpi->a1_type_pointed_to,
|
||||
tmpi->a1.reg,tmpi->a1.disp,MDF_REG+RT_I64,r,0,ip);
|
||||
} else {
|
||||
ICMov(tempi,MDF_REG+RT_I64,REG_RCX,0,
|
||||
tempi->a1.type,tempi->a1.reg,tempi->a1.disp,ip);
|
||||
ICMov(tempi,MDF_REG+RT_I64,REG_RBX,0,
|
||||
MDF_DISP+tempi->a1_type_pointed_to,REG_RCX,0,ip);
|
||||
ICMov(tmpi,MDF_REG+RT_I64,REG_RCX,0,
|
||||
tmpi->a1.type,tmpi->a1.reg,tmpi->a1.disp,ip);
|
||||
ICMov(tmpi,MDF_REG+RT_I64,REG_RBX,0,
|
||||
MDF_DISP+tmpi->a1_type_pointed_to,REG_RCX,0,ip);
|
||||
r=REG_RBX;
|
||||
if (MIN_I8<=i<=MAX_I8)
|
||||
ICU32(tempi,i<<24+0xDB6B48);
|
||||
ICU32(tmpi,i<<24+0xDB6B48);
|
||||
else {
|
||||
ICU24(tempi,0xDB6948);
|
||||
ICU32(tempi,i);
|
||||
ICU24(tmpi,0xDB6948);
|
||||
ICU32(tmpi,i);
|
||||
}
|
||||
ICMov(tempi,MDF_DISP+tempi->a1_type_pointed_to,REG_RCX,0,
|
||||
ICMov(tmpi,MDF_DISP+tmpi->a1_type_pointed_to,REG_RCX,0,
|
||||
MDF_REG+RT_I64,REG_RBX,0,ip);
|
||||
}
|
||||
} else {
|
||||
if (tempi->ic_class->raw_type&RTF_UNSIGNED)
|
||||
if (tmpi->ic_class->raw_type&RTF_UNSIGNED)
|
||||
i=0xE3F748;
|
||||
else
|
||||
i=0xEBF748;
|
||||
if (tempi->ic_flags & ICF_BY_VAL) {
|
||||
ICMov(tempi,MDF_REG+RT_I64,REG_RAX,0,
|
||||
tempi->a2.type,tempi->a2.reg,tempi->a2.disp,ip);
|
||||
ICMov(tempi,MDF_REG+RT_I64,REG_RBX,0,
|
||||
tempi->a1.type&MDG_MASK+tempi->a1_type_pointed_to,
|
||||
tempi->a1.reg,tempi->a1.disp,ip);
|
||||
ICU24(tempi,i);
|
||||
ICMov(tempi,tempi->a1.type&MDG_MASK+tempi->a1_type_pointed_to,
|
||||
tempi->a1.reg,tempi->a1.disp,MDF_REG+RT_I64,REG_RAX,0,ip);
|
||||
if (tmpi->ic_flags & ICF_BY_VAL) {
|
||||
ICMov(tmpi,MDF_REG+RT_I64,REG_RAX,0,
|
||||
tmpi->a2.type,tmpi->a2.reg,tmpi->a2.disp,ip);
|
||||
ICMov(tmpi,MDF_REG+RT_I64,REG_RBX,0,
|
||||
tmpi->a1.type&MDG_MASK+tmpi->a1_type_pointed_to,
|
||||
tmpi->a1.reg,tmpi->a1.disp,ip);
|
||||
ICU24(tmpi,i);
|
||||
ICMov(tmpi,tmpi->a1.type&MDG_MASK+tmpi->a1_type_pointed_to,
|
||||
tmpi->a1.reg,tmpi->a1.disp,MDF_REG+RT_I64,REG_RAX,0,ip);
|
||||
} else {
|
||||
ICMov(tempi,MDF_REG+RT_I64,REG_RAX,0,
|
||||
tempi->a2.type,tempi->a2.reg,tempi->a2.disp,ip);
|
||||
ICMov(tempi,MDF_REG+RT_I64,REG_RCX,0,
|
||||
tempi->a1.type,tempi->a1.reg,tempi->a1.disp,ip);
|
||||
ICMov(tempi,MDF_REG+RT_I64,REG_RBX,0,
|
||||
MDF_DISP+tempi->a1_type_pointed_to,REG_RCX,0,ip);
|
||||
ICU24(tempi,i);
|
||||
ICMov(tempi,MDF_DISP+tempi->a1_type_pointed_to,REG_RCX,0,
|
||||
ICMov(tmpi,MDF_REG+RT_I64,REG_RAX,0,
|
||||
tmpi->a2.type,tmpi->a2.reg,tmpi->a2.disp,ip);
|
||||
ICMov(tmpi,MDF_REG+RT_I64,REG_RCX,0,
|
||||
tmpi->a1.type,tmpi->a1.reg,tmpi->a1.disp,ip);
|
||||
ICMov(tmpi,MDF_REG+RT_I64,REG_RBX,0,
|
||||
MDF_DISP+tmpi->a1_type_pointed_to,REG_RCX,0,ip);
|
||||
ICU24(tmpi,i);
|
||||
ICMov(tmpi,MDF_DISP+tmpi->a1_type_pointed_to,REG_RCX,0,
|
||||
MDF_REG+RT_I64,REG_RAX,0,ip);
|
||||
}
|
||||
}
|
||||
if (tempi->r.type.mode)
|
||||
ICMov(tempi,tempi->r.type,tempi->r.reg,tempi->r.disp,MDF_REG+RT_I64,r,0,ip);
|
||||
if (tmpi->r.type.mode)
|
||||
ICMov(tmpi,tmpi->r.type,tmpi->r.reg,tmpi->r.disp,MDF_REG+RT_I64,r,0,ip);
|
||||
}
|
||||
|
||||
U0 ICDiv(CIntermediateCode *tempi,I64 ip)
|
||||
U0 ICDiv(CIntermediateCode *tmpi,I64 ip)
|
||||
{
|
||||
ICMov(tempi,MDF_REG+RT_I64,REG_RCX,0,
|
||||
tempi->a2.type,tempi->a2.reg,tempi->a2.disp,ip);
|
||||
ICMov(tempi,MDF_REG+RT_I64,REG_RAX,0,
|
||||
tempi->a1.type,tempi->a1.reg,tempi->a1.disp,ip);
|
||||
if (tempi->ic_class->raw_type&RTF_UNSIGNED) {
|
||||
ICZero(tempi,REG_RDX);
|
||||
ICU24(tempi,0xF1F748);
|
||||
ICMov(tmpi,MDF_REG+RT_I64,REG_RCX,0,
|
||||
tmpi->a2.type,tmpi->a2.reg,tmpi->a2.disp,ip);
|
||||
ICMov(tmpi,MDF_REG+RT_I64,REG_RAX,0,
|
||||
tmpi->a1.type,tmpi->a1.reg,tmpi->a1.disp,ip);
|
||||
if (tmpi->ic_class->raw_type&RTF_UNSIGNED) {
|
||||
ICZero(tmpi,REG_RDX);
|
||||
ICU24(tmpi,0xF1F748);
|
||||
} else {
|
||||
ICU16(tempi,0x9948);
|
||||
ICU24(tempi,0xF9F748);
|
||||
ICU16(tmpi,0x9948);
|
||||
ICU24(tmpi,0xF9F748);
|
||||
}
|
||||
ICMov(tempi,tempi->r.type,tempi->r.reg,tempi->r.disp,
|
||||
ICMov(tmpi,tmpi->r.type,tmpi->r.reg,tmpi->r.disp,
|
||||
MDF_REG+RT_I64,REG_RAX,0,ip);
|
||||
}
|
||||
|
||||
U0 ICDivEqu(CIntermediateCode *tempi,Bool is_mod,I64 ip)
|
||||
U0 ICDivEqu(CIntermediateCode *tmpi,Bool is_mod,I64 ip)
|
||||
{
|
||||
if (tempi->ic_flags & ICF_BY_VAL) {
|
||||
ICMov(tempi,MDF_REG+RT_I64,REG_RCX,0,
|
||||
tempi->a2.type,tempi->a2.reg,tempi->a2.disp,ip);
|
||||
ICMov(tempi,MDF_REG+RT_I64,REG_RAX,0,
|
||||
tempi->a1.type&MDG_MASK+tempi->a1_type_pointed_to,
|
||||
tempi->a1.reg,tempi->a1.disp,ip);
|
||||
if (tempi->ic_class->raw_type&RTF_UNSIGNED) {
|
||||
ICZero(tempi,REG_RDX);
|
||||
ICU24(tempi,0xF1F748);
|
||||
if (tmpi->ic_flags & ICF_BY_VAL) {
|
||||
ICMov(tmpi,MDF_REG+RT_I64,REG_RCX,0,
|
||||
tmpi->a2.type,tmpi->a2.reg,tmpi->a2.disp,ip);
|
||||
ICMov(tmpi,MDF_REG+RT_I64,REG_RAX,0,
|
||||
tmpi->a1.type&MDG_MASK+tmpi->a1_type_pointed_to,
|
||||
tmpi->a1.reg,tmpi->a1.disp,ip);
|
||||
if (tmpi->ic_class->raw_type&RTF_UNSIGNED) {
|
||||
ICZero(tmpi,REG_RDX);
|
||||
ICU24(tmpi,0xF1F748);
|
||||
} else {
|
||||
ICU16(tempi,0x9948);
|
||||
ICU24(tempi,0xF9F748);
|
||||
ICU16(tmpi,0x9948);
|
||||
ICU24(tmpi,0xF9F748);
|
||||
}
|
||||
if (is_mod)
|
||||
ICMov(tempi,tempi->a1.type&MDG_MASK+tempi->a1_type_pointed_to,
|
||||
tempi->a1.reg,tempi->a1.disp,MDF_REG+RT_I64,REG_RDX,0,ip);
|
||||
ICMov(tmpi,tmpi->a1.type&MDG_MASK+tmpi->a1_type_pointed_to,
|
||||
tmpi->a1.reg,tmpi->a1.disp,MDF_REG+RT_I64,REG_RDX,0,ip);
|
||||
else
|
||||
ICMov(tempi,tempi->a1.type&MDG_MASK+tempi->a1_type_pointed_to,
|
||||
tempi->a1.reg,tempi->a1.disp,MDF_REG+RT_I64,REG_RAX,0,ip);
|
||||
ICMov(tmpi,tmpi->a1.type&MDG_MASK+tmpi->a1_type_pointed_to,
|
||||
tmpi->a1.reg,tmpi->a1.disp,MDF_REG+RT_I64,REG_RAX,0,ip);
|
||||
} else {
|
||||
ICMov(tempi,MDF_REG+RT_I64,REG_RCX,0,
|
||||
tempi->a2.type,tempi->a2.reg,tempi->a2.disp,ip);
|
||||
ICMov(tempi,MDF_REG+RT_I64,REG_RBX,0,
|
||||
tempi->a1.type,tempi->a1.reg,tempi->a1.disp,ip);
|
||||
ICMov(tmpi,MDF_REG+RT_I64,REG_RCX,0,
|
||||
tmpi->a2.type,tmpi->a2.reg,tmpi->a2.disp,ip);
|
||||
ICMov(tmpi,MDF_REG+RT_I64,REG_RBX,0,
|
||||
tmpi->a1.type,tmpi->a1.reg,tmpi->a1.disp,ip);
|
||||
//dangerous might clobber RBX in Mov, but it doesn't
|
||||
ICMov(tempi,MDF_REG+RT_I64,REG_RAX,0,MDF_DISP+tempi->a1_type_pointed_to,
|
||||
ICMov(tmpi,MDF_REG+RT_I64,REG_RAX,0,MDF_DISP+tmpi->a1_type_pointed_to,
|
||||
REG_RBX,0,ip);
|
||||
if (tempi->ic_class->raw_type&RTF_UNSIGNED) {
|
||||
ICZero(tempi,REG_RDX);
|
||||
ICU24(tempi,0xF1F748);
|
||||
if (tmpi->ic_class->raw_type&RTF_UNSIGNED) {
|
||||
ICZero(tmpi,REG_RDX);
|
||||
ICU24(tmpi,0xF1F748);
|
||||
} else {
|
||||
ICU16(tempi,0x9948);
|
||||
ICU24(tempi,0xF9F748);
|
||||
ICU16(tmpi,0x9948);
|
||||
ICU24(tmpi,0xF9F748);
|
||||
}
|
||||
if (is_mod)
|
||||
ICMov(tempi,MDF_DISP+tempi->a1_type_pointed_to,REG_RBX,0,
|
||||
ICMov(tmpi,MDF_DISP+tmpi->a1_type_pointed_to,REG_RBX,0,
|
||||
MDF_REG+RT_I64,REG_RDX,0,ip);
|
||||
else
|
||||
ICMov(tempi,MDF_DISP+tempi->a1_type_pointed_to,REG_RBX,0,
|
||||
ICMov(tmpi,MDF_DISP+tmpi->a1_type_pointed_to,REG_RBX,0,
|
||||
MDF_REG+RT_I64,REG_RAX,0,ip);
|
||||
}
|
||||
if (tempi->r.type.mode) {
|
||||
if (tmpi->r.type.mode) {
|
||||
if (is_mod)
|
||||
ICMov(tempi,tempi->r.type,tempi->r.reg,tempi->r.disp,
|
||||
ICMov(tmpi,tmpi->r.type,tmpi->r.reg,tmpi->r.disp,
|
||||
MDF_REG+RT_I64,REG_RDX,0,ip);
|
||||
else
|
||||
ICMov(tempi,tempi->r.type,tempi->r.reg,tempi->r.disp,
|
||||
ICMov(tmpi,tmpi->r.type,tmpi->r.reg,tmpi->r.disp,
|
||||
MDF_REG+RT_I64,REG_RAX,0,ip);
|
||||
}
|
||||
}
|
||||
|
||||
U0 ICMod(CIntermediateCode *tempi,I64 ip)
|
||||
U0 ICMod(CIntermediateCode *tmpi,I64 ip)
|
||||
{
|
||||
ICMov(tempi,MDF_REG+RT_I64,REG_RCX,0,
|
||||
tempi->a2.type,tempi->a2.reg,tempi->a2.disp,ip);
|
||||
ICMov(tempi,MDF_REG+RT_I64,REG_RAX,0,
|
||||
tempi->a1.type,tempi->a1.reg,tempi->a1.disp,ip);
|
||||
if (tempi->ic_class->raw_type&RTF_UNSIGNED) {
|
||||
ICZero(tempi,REG_RDX);
|
||||
ICU24(tempi,0xF1F748);
|
||||
ICMov(tmpi,MDF_REG+RT_I64,REG_RCX,0,
|
||||
tmpi->a2.type,tmpi->a2.reg,tmpi->a2.disp,ip);
|
||||
ICMov(tmpi,MDF_REG+RT_I64,REG_RAX,0,
|
||||
tmpi->a1.type,tmpi->a1.reg,tmpi->a1.disp,ip);
|
||||
if (tmpi->ic_class->raw_type&RTF_UNSIGNED) {
|
||||
ICZero(tmpi,REG_RDX);
|
||||
ICU24(tmpi,0xF1F748);
|
||||
} else {
|
||||
ICU16(tempi,0x9948);
|
||||
ICU24(tempi,0xF9F748);
|
||||
ICU16(tmpi,0x9948);
|
||||
ICU24(tmpi,0xF9F748);
|
||||
}
|
||||
ICMov(tempi,tempi->r.type,tempi->r.reg,tempi->r.disp,
|
||||
ICMov(tmpi,tmpi->r.type,tmpi->r.reg,tmpi->r.disp,
|
||||
MDF_REG+RT_I64,REG_RDX,0,ip);
|
||||
}
|
||||
|
||||
U0 ICAddSubEctEqu(CIntermediateCode *tempi,U8 type_pointed_to,
|
||||
U0 ICAddSubEctEqu(CIntermediateCode *tmpi,U8 type_pointed_to,
|
||||
CICType t1,I64 r1,I64 d1,CICType t2,I64 r2,I64 d2,
|
||||
CICType t3,I64 r3,I64 d3,I64 op,I64 ip)
|
||||
{
|
||||
Bool done;
|
||||
I64 res_reg,temp,i;
|
||||
if (tempi->ic_flags & ICF_BY_VAL) {
|
||||
I64 res_reg,tmp,i;
|
||||
if (tmpi->ic_flags & ICF_BY_VAL) {
|
||||
if (t3&MDF_IMM) {
|
||||
ICAddSubEctImm(tempi,t2&MDG_MASK+type_pointed_to,r2,d2,t2&MDG_MASK+
|
||||
ICAddSubEctImm(tmpi,t2&MDG_MASK+type_pointed_to,r2,d2,t2&MDG_MASK+
|
||||
type_pointed_to,r2,d2,d3,op,ip);
|
||||
if (t1.mode)
|
||||
ICMov(tempi,t1,r1,d1,t2&MDG_MASK+type_pointed_to,r2,d2,ip);
|
||||
ICMov(tmpi,t1,r1,d1,t2&MDG_MASK+type_pointed_to,r2,d2,ip);
|
||||
return;
|
||||
} else {
|
||||
done=FALSE;
|
||||
if (type_pointed_to>=RT_I64) {
|
||||
if (!t1.mode && t2&MDG_REG_DISP_SIB_RIP) {
|
||||
if (t3&MDF_REG)
|
||||
temp=r3;
|
||||
tmp=r3;
|
||||
else {
|
||||
temp=REG_RCX;
|
||||
ICMov(tempi,MDF_REG+RT_I64,temp,0,t3,r3,d3,ip);
|
||||
tmp=REG_RCX;
|
||||
ICMov(tmpi,MDF_REG+RT_I64,tmp,0,t3,r3,d3,ip);
|
||||
}
|
||||
i=ICModr1(temp,t2&MDG_MASK+type_pointed_to,r2,d2);
|
||||
if (tempi->ic_flags&ICF_LOCK)
|
||||
ICU8(tempi,OC_LOCK_PREFIX);
|
||||
ICRex(tempi,i.u8[1]);
|
||||
ICU16(tempi,i.u8[2]<<8+op.u8[5]);
|
||||
ICModr2(tempi,i,d2,ip+4);
|
||||
i=ICModr1(tmp,t2&MDG_MASK+type_pointed_to,r2,d2);
|
||||
if (tmpi->ic_flags&ICF_LOCK)
|
||||
ICU8(tmpi,OC_LOCK_PREFIX);
|
||||
ICRex(tmpi,i.u8[1]);
|
||||
ICU16(tmpi,i.u8[2]<<8+op.u8[5]);
|
||||
ICModr2(tmpi,i,d2,ip+4);
|
||||
return;
|
||||
}
|
||||
if (t3.raw_type>=RT_I64 && t3&MDG_REG_DISP_SIB_RIP) {
|
||||
@@ -511,36 +511,36 @@ U0 ICAddSubEctEqu(CIntermediateCode *tempi,U8 type_pointed_to,
|
||||
res_reg=r2;
|
||||
else {
|
||||
res_reg=REG_RCX;
|
||||
ICMov(tempi,MDF_REG+RT_I64,REG_RCX,0,t2,r2,d2,ip);
|
||||
ICMov(tmpi,MDF_REG+RT_I64,REG_RCX,0,t2,r2,d2,ip);
|
||||
}
|
||||
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,
|
||||
if (tmpi->ic_flags&ICF_LOCK)
|
||||
ICU8(tmpi,OC_LOCK_PREFIX);
|
||||
ICRex(tmpi,i.u8[1]);
|
||||
ICU16(tmpi,i.u8[2]<<8+op.u8[0]);
|
||||
ICModr2(tmpi,i,d3,ip+4);
|
||||
ICMov(tmpi,t2&MDG_MASK+type_pointed_to,r2,d2,
|
||||
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);
|
||||
ICMov(tmpi,MDF_REG+RT_I64,REG_RAX,0,t3,r3,d3,ip);
|
||||
if (t2&MDF_REG && r2!=REG_RAX)
|
||||
res_reg=r2;
|
||||
else {
|
||||
res_reg=REG_RCX;
|
||||
ICMov(tempi,MDF_REG+RT_I64,REG_RCX,0,
|
||||
ICMov(tmpi,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 (tmpi->ic_flags&ICF_LOCK)
|
||||
ICU8(tmpi,OC_LOCK_PREFIX);
|
||||
if (res_reg>7)
|
||||
ICU8(tempi,0x4C);
|
||||
ICU8(tmpi,0x4C);
|
||||
else
|
||||
ICU8(tempi,0x48);
|
||||
ICU16(tempi,0xC000+op.u8[0]+(res_reg&7)<<11);
|
||||
ICMov(tempi,t2&MDG_MASK+type_pointed_to,r2,d2,
|
||||
ICU8(tmpi,0x48);
|
||||
ICU16(tmpi,0xC000+op.u8[0]+(res_reg&7)<<11);
|
||||
ICMov(tmpi,t2&MDG_MASK+type_pointed_to,r2,d2,
|
||||
MDF_REG+RT_I64,res_reg,0,ip);
|
||||
}
|
||||
}
|
||||
@@ -548,71 +548,71 @@ U0 ICAddSubEctEqu(CIntermediateCode *tempi,U8 type_pointed_to,
|
||||
done=FALSE;
|
||||
if (t3&MDF_IMM && op.u8[2]) {
|
||||
if (!d3.u32[1]) {
|
||||
if (tempi->ic_flags&ICF_RES_NOT_USED &&
|
||||
if (tmpi->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);
|
||||
ICSlashOp(tmpi,MDF_DISP+type_pointed_to,r2,0,0x838000+op.u8[4],ip);
|
||||
ICU8(tmpi,d3);
|
||||
done=TRUE;
|
||||
} else if (op.u8[2]==0x24) {//AND
|
||||
ICMov(tempi,MDF_REG+RT_I64,REG_RCX,0,t2,r2,d2,ip);
|
||||
ICMov(tempi,MDF_REG+RT_I64,REG_RAX,0,
|
||||
ICMov(tmpi,MDF_REG+RT_I64,REG_RCX,0,t2,r2,d2,ip);
|
||||
ICMov(tmpi,MDF_REG+RT_I64,REG_RAX,0,
|
||||
MDF_DISP+type_pointed_to,REG_RCX,0,ip);
|
||||
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,
|
||||
if (tmpi->ic_flags&ICF_LOCK)
|
||||
ICU8(tmpi,OC_LOCK_PREFIX);
|
||||
ICU16(tmpi,op.u8[3]<<8+0x40);
|
||||
ICU32(tmpi,d3);
|
||||
ICMov(tmpi,MDF_DISP+type_pointed_to,REG_RCX,0,
|
||||
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,
|
||||
ICMov(tmpi,MDF_REG+RT_I64,REG_RCX,0,t2,r2,d2,ip);
|
||||
ICMov(tmpi,MDF_REG+RT_I64,REG_RAX,0,
|
||||
MDF_DISP+type_pointed_to,REG_RCX,0,ip);
|
||||
res_reg=REG_RAX;
|
||||
if (tempi->ic_flags&ICF_LOCK)
|
||||
ICU8(tempi,OC_LOCK_PREFIX);
|
||||
if (tmpi->ic_flags&ICF_LOCK)
|
||||
ICU8(tmpi,OC_LOCK_PREFIX);
|
||||
if (d3.u16[1]) {
|
||||
ICU16(tempi,op.u8[3]<<8+0x40);
|
||||
ICU32(tempi,d3);
|
||||
ICU16(tmpi,op.u8[3]<<8+0x40);
|
||||
ICU32(tmpi,d3);
|
||||
} else if (d3.u8[1]) {
|
||||
ICU24(tempi,op.u8[3]<<16+0x4000+OC_OP_SIZE_PREFIX);
|
||||
ICU16(tempi,d3);
|
||||
ICU24(tmpi,op.u8[3]<<16+0x4000+OC_OP_SIZE_PREFIX);
|
||||
ICU16(tmpi,d3);
|
||||
} else {
|
||||
ICU16(tempi,op.u8[2]<<8+0x40);
|
||||
ICU8(tempi,d3);
|
||||
ICU16(tmpi,op.u8[2]<<8+0x40);
|
||||
ICU8(tmpi,d3);
|
||||
}
|
||||
ICMov(tempi,MDF_DISP+type_pointed_to,REG_RCX,0,
|
||||
ICMov(tmpi,MDF_DISP+type_pointed_to,REG_RCX,0,
|
||||
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);
|
||||
ICMov(tempi,MDF_REG+RT_I64,REG_RCX,0,t2,r2,d2,ip);
|
||||
ICMov(tempi,MDF_REG+RT_I64,REG_RBX,0,
|
||||
ICMov(tmpi,MDF_REG+RT_I64,REG_RAX,0,t3,r3,d3,ip);
|
||||
ICMov(tmpi,MDF_REG+RT_I64,REG_RCX,0,t2,r2,d2,ip);
|
||||
ICMov(tmpi,MDF_REG+RT_I64,REG_RBX,0,
|
||||
MDF_DISP+type_pointed_to,REG_RCX,0,ip);
|
||||
res_reg=REG_RBX;
|
||||
if (tempi->ic_flags&ICF_LOCK)
|
||||
ICU8(tempi,OC_LOCK_PREFIX);
|
||||
ICU8(tempi,0x48);
|
||||
ICU16(tempi,0xC000+op.u8[0]+(res_reg&7)<<11);
|
||||
ICMov(tempi,MDF_DISP+type_pointed_to,REG_RCX,0,
|
||||
if (tmpi->ic_flags&ICF_LOCK)
|
||||
ICU8(tmpi,OC_LOCK_PREFIX);
|
||||
ICU8(tmpi,0x48);
|
||||
ICU16(tmpi,0xC000+op.u8[0]+(res_reg&7)<<11);
|
||||
ICMov(tmpi,MDF_DISP+type_pointed_to,REG_RCX,0,
|
||||
MDF_REG+RT_I64,res_reg,0,ip);
|
||||
}
|
||||
}
|
||||
if (t1.mode)
|
||||
ICMov(tempi,t1,r1,d1,MDF_REG+RT_I64,res_reg,0,ip);
|
||||
ICMov(tmpi,t1,r1,d1,MDF_REG+RT_I64,res_reg,0,ip);
|
||||
}
|
||||
|
||||
U0 ICShift(CIntermediateCode *tempi,CICType t1,I64 r1,I64 d1,
|
||||
U0 ICShift(CIntermediateCode *tmpi,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,res_reg;
|
||||
if (tempi->ic_class->raw_type&RTF_UNSIGNED ||
|
||||
tempi->ic_flags & ICF_USE_UNSIGNED)
|
||||
if (tmpi->ic_class->raw_type&RTF_UNSIGNED ||
|
||||
tmpi->ic_flags & ICF_USE_UNSIGNED)
|
||||
is=us;
|
||||
if (t1&MDF_REG) {
|
||||
res_reg=r1;
|
||||
@@ -621,74 +621,74 @@ U0 ICShift(CIntermediateCode *tempi,CICType t1,I64 r1,I64 d1,
|
||||
} else
|
||||
res_reg=REG_RAX;
|
||||
if (t3&MDF_IMM) {
|
||||
ICMov(tempi,MDF_REG+RT_I64,res_reg,0,t2,r2,d2,ip);
|
||||
ICMov(tmpi,MDF_REG+RT_I64,res_reg,0,t2,r2,d2,ip);
|
||||
if (d3==1)
|
||||
ICU24(tempi,i+is.u16[2]<<8+(res_reg&7)<<16);
|
||||
ICU24(tmpi,i+is.u16[2]<<8+(res_reg&7)<<16);
|
||||
else {
|
||||
ICU24(tempi,i+is.u16[0]<<8+(res_reg&7)<<16);
|
||||
ICU8(tempi,d3);
|
||||
ICU24(tmpi,i+is.u16[0]<<8+(res_reg&7)<<16);
|
||||
ICU8(tmpi,d3);
|
||||
}
|
||||
} else {
|
||||
ICMov(tempi,MDF_REG+RT_I64,REG_RCX,0,t3,r3,d3,ip);
|
||||
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(tmpi,MDF_REG+RT_I64,REG_RCX,0,t3,r3,d3,ip);
|
||||
ICMov(tmpi,MDF_REG+RT_I64,res_reg,0,t2,r2,d2,ip);
|
||||
ICU24(tmpi,i+is.u16[1]<<8+(res_reg&7)<<16);
|
||||
}
|
||||
ICMov(tempi,t1,r1,d1,MDF_REG+RT_I64,res_reg,0,ip);
|
||||
ICMov(tmpi,t1,r1,d1,MDF_REG+RT_I64,res_reg,0,ip);
|
||||
}
|
||||
|
||||
U0 ICShiftEqu(CIntermediateCode *tempi,U8 type_pointed_to,
|
||||
U0 ICShiftEqu(CIntermediateCode *tmpi,U8 type_pointed_to,
|
||||
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 res_reg;
|
||||
if (tempi->ic_class->raw_type&RTF_UNSIGNED ||
|
||||
tempi->ic_flags & ICF_USE_UNSIGNED)
|
||||
if (tmpi->ic_class->raw_type&RTF_UNSIGNED ||
|
||||
tmpi->ic_flags & ICF_USE_UNSIGNED)
|
||||
is=us;
|
||||
if (tempi->ic_flags & ICF_BY_VAL) {
|
||||
if (tmpi->ic_flags & ICF_BY_VAL) {
|
||||
if (!(t3&MDF_IMM))
|
||||
ICMov(tempi,MDF_REG+RT_I64,REG_RCX,0,t3,r3,d3,ip);
|
||||
ICMov(tmpi,MDF_REG+RT_I64,REG_RCX,0,t3,r3,d3,ip);
|
||||
if (t2&MDF_REG)
|
||||
res_reg=r2;
|
||||
else {
|
||||
res_reg=REG_RAX;
|
||||
ICMov(tempi,MDF_REG+RT_I64,REG_RAX,0,
|
||||
ICMov(tmpi,MDF_REG+RT_I64,REG_RAX,0,
|
||||
t2&MDG_MASK+type_pointed_to,r2,d2,ip);
|
||||
}
|
||||
if (res_reg>7)
|
||||
ICU8(tempi,0x49);
|
||||
ICU8(tmpi,0x49);
|
||||
else
|
||||
ICU8(tempi,0x48);
|
||||
ICU8(tmpi,0x48);
|
||||
if (t3&MDF_IMM) {
|
||||
if (d3==1)
|
||||
ICU16(tempi,is.u16[2]+(res_reg&7)<<8);
|
||||
ICU16(tmpi,is.u16[2]+(res_reg&7)<<8);
|
||||
else {
|
||||
ICU16(tempi,is.u16[0]+(res_reg&7)<<8);
|
||||
ICU8(tempi,d3);
|
||||
ICU16(tmpi,is.u16[0]+(res_reg&7)<<8);
|
||||
ICU8(tmpi,d3);
|
||||
}
|
||||
} else
|
||||
ICU16(tempi,is.u16[1]+(res_reg&7)<<8);
|
||||
ICMov(tempi,t2&MDG_MASK+type_pointed_to,r2,d2,
|
||||
ICU16(tmpi,is.u16[1]+(res_reg&7)<<8);
|
||||
ICMov(tmpi,t2&MDG_MASK+type_pointed_to,r2,d2,
|
||||
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);
|
||||
ICMov(tmpi,MDF_REG+RT_I64,REG_RCX,0,t3,r3,d3,ip);
|
||||
ICMov(tmpi,MDF_REG+RT_I64,REG_RDX,0,t2,r2,d2,ip);
|
||||
ICMov(tmpi,MDF_REG+RT_I64,REG_RAX,0,MDF_DISP+type_pointed_to,REG_RDX,0,ip);
|
||||
res_reg=REG_RAX;
|
||||
ICU8(tempi,0x48);
|
||||
ICU8(tmpi,0x48);
|
||||
if (t3&MDF_IMM) {
|
||||
if (d3==1)
|
||||
ICU16(tempi,is.u16[2]+(res_reg&7)<<8);
|
||||
ICU16(tmpi,is.u16[2]+(res_reg&7)<<8);
|
||||
else {
|
||||
ICU16(tempi,is.u16[0]+(res_reg&7)<<8);
|
||||
ICU8(tempi,d3);
|
||||
ICU16(tmpi,is.u16[0]+(res_reg&7)<<8);
|
||||
ICU8(tmpi,d3);
|
||||
}
|
||||
} else
|
||||
ICU16(tempi,is.u16[1]+(res_reg&7)<<8);
|
||||
ICMov(tempi,
|
||||
ICU16(tmpi,is.u16[1]+(res_reg&7)<<8);
|
||||
ICMov(tmpi,
|
||||
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,res_reg,0,ip);
|
||||
ICMov(tmpi,t1,r1,d1,MDF_REG+RT_I64,res_reg,0,ip);
|
||||
}
|
||||
+339
-339
File diff suppressed because it is too large.
Load diff
+318
-318
@@ -1,4 +1,4 @@
|
||||
U0 ICAndBranch(CIntermediateCode *tempi,I64 ip,I64 is,U8 *buf,I64 ip2)
|
||||
U0 ICAndBranch(CIntermediateCode *tmpi,I64 ip,I64 is,U8 *buf,I64 ip2)
|
||||
{
|
||||
U64 i;
|
||||
I64 it,t1,r1,d1,r2;
|
||||
@@ -6,14 +6,14 @@ U0 ICAndBranch(CIntermediateCode *tempi,I64 ip,I64 is,U8 *buf,I64 ip2)
|
||||
CCodeMisc *lb;
|
||||
CICArg *a1,*a2;
|
||||
|
||||
if (tempi->a1.type&MDF_IMM) {
|
||||
if (tmpi->a1.type&MDF_IMM) {
|
||||
swap=TRUE;
|
||||
a1=&tempi->a2;
|
||||
a2=&tempi->a1;
|
||||
a1=&tmpi->a2;
|
||||
a2=&tmpi->a1;
|
||||
} else {
|
||||
swap=FALSE;
|
||||
a1=&tempi->a1;
|
||||
a2=&tempi->a2;
|
||||
a1=&tmpi->a1;
|
||||
a2=&tmpi->a2;
|
||||
}
|
||||
|
||||
if (a2->type&MDF_IMM && a2->disp>MAX_U32)
|
||||
@@ -28,14 +28,14 @@ U0 ICAndBranch(CIntermediateCode *tempi,I64 ip,I64 is,U8 *buf,I64 ip2)
|
||||
|
||||
i=a2->disp;
|
||||
if (a2->type&MDF_IMM && i<=MAX_U32) {
|
||||
ICMov(tempi,MDF_REG+RT_I64,REG_RAX,0,a1->type,a1->reg,a1->disp,ip2);
|
||||
ICMov(tmpi,MDF_REG+RT_I64,REG_RAX,0,a1->type,a1->reg,a1->disp,ip2);
|
||||
if (i<=MAX_U8)
|
||||
ICU16(tempi,i<<8+0xA8);
|
||||
ICU16(tmpi,i<<8+0xA8);
|
||||
else if (i<=MAX_U16)
|
||||
ICU32(tempi,i<<16+0xA900+OC_OP_SIZE_PREFIX);
|
||||
ICU32(tmpi,i<<16+0xA900+OC_OP_SIZE_PREFIX);
|
||||
else {
|
||||
ICU8(tempi,0xA9);
|
||||
ICU32(tempi,i);
|
||||
ICU8(tmpi,0xA9);
|
||||
ICU32(tmpi,i);
|
||||
}
|
||||
} else {
|
||||
t1=MDF_REG+it;
|
||||
@@ -55,13 +55,13 @@ U0 ICAndBranch(CIntermediateCode *tempi,I64 ip,I64 is,U8 *buf,I64 ip2)
|
||||
r2=REG_RDX;
|
||||
if (swap) {
|
||||
if (!(a1->type&MDF_REG) || r1!=a1->reg)
|
||||
ICMov(tempi,MDF_REG+RT_I64,r1,0,a1->type,a1->reg,a1->disp,ip2);
|
||||
ICMov(tmpi,MDF_REG+RT_I64,r1,0,a1->type,a1->reg,a1->disp,ip2);
|
||||
if (a2->type&MDG_REG_DISP_SIB_RIP) {
|
||||
t1=a2->type&MDG_MASK+it;
|
||||
r2=a2->reg;
|
||||
d1=a2->disp;
|
||||
} else
|
||||
ICMov(tempi,MDF_REG+RT_I64,r2,0,a2->type,a2->reg,a2->disp,ip2);
|
||||
ICMov(tmpi,MDF_REG+RT_I64,r2,0,a2->type,a2->reg,a2->disp,ip2);
|
||||
i=ICModr1(r1,t1,r2,d1);
|
||||
} else {
|
||||
if (a1->type&MDG_REG_DISP_SIB_RIP) {
|
||||
@@ -69,9 +69,9 @@ U0 ICAndBranch(CIntermediateCode *tempi,I64 ip,I64 is,U8 *buf,I64 ip2)
|
||||
r1=a1->reg;
|
||||
d1=a1->disp;
|
||||
} else
|
||||
ICMov(tempi,MDF_REG+RT_I64,r1,0,a1->type,a1->reg,a1->disp,ip2);
|
||||
ICMov(tmpi,MDF_REG+RT_I64,r1,0,a1->type,a1->reg,a1->disp,ip2);
|
||||
if (!(a2->type&MDF_REG) || r2!=a2->reg)
|
||||
ICMov(tempi,MDF_REG+RT_I64,r2,0,a2->type,a2->reg,a2->disp,ip2);
|
||||
ICMov(tmpi,MDF_REG+RT_I64,r2,0,a2->type,a2->reg,a2->disp,ip2);
|
||||
i=ICModr1(r2,t1,r1,d1);
|
||||
}
|
||||
} else {
|
||||
@@ -95,43 +95,43 @@ U0 ICAndBranch(CIntermediateCode *tempi,I64 ip,I64 is,U8 *buf,I64 ip2)
|
||||
r2=a2->reg;
|
||||
d1=a2->disp;
|
||||
} else
|
||||
ICMov(tempi,MDF_REG+RT_I64,r2,0,a2->type,a2->reg,a2->disp,ip2);
|
||||
ICMov(tmpi,MDF_REG+RT_I64,r2,0,a2->type,a2->reg,a2->disp,ip2);
|
||||
if (!(a1->type&MDF_REG) || r1!=a1->reg)
|
||||
ICMov(tempi,MDF_REG+RT_I64,r1,0,a1->type,a1->reg,a1->disp,ip2);
|
||||
ICMov(tmpi,MDF_REG+RT_I64,r1,0,a1->type,a1->reg,a1->disp,ip2);
|
||||
i=ICModr1(r1,t1,r2,d1);
|
||||
} else {
|
||||
if (!(a2->type&MDF_REG) || r2!=a2->reg)
|
||||
ICMov(tempi,MDF_REG+RT_I64,r2,0,a2->type,a2->reg,a2->disp,ip2);
|
||||
ICMov(tmpi,MDF_REG+RT_I64,r2,0,a2->type,a2->reg,a2->disp,ip2);
|
||||
if (a1->type&MDG_REG_DISP_SIB_RIP) {
|
||||
t1=a1->type&MDG_MASK+it;
|
||||
r1=a1->reg;
|
||||
d1=a1->disp;
|
||||
} else
|
||||
ICMov(tempi,MDF_REG+RT_I64,r1,0,a1->type,a1->reg,a1->disp,ip2);
|
||||
ICMov(tmpi,MDF_REG+RT_I64,r1,0,a1->type,a1->reg,a1->disp,ip2);
|
||||
i=ICModr1(r2,t1,r1,d1);
|
||||
}
|
||||
}
|
||||
switch (it) {
|
||||
case RT_I8:
|
||||
case RT_U8:
|
||||
ICRex(tempi,i.u8[1]);
|
||||
ICU16(tempi,i.u8[2]<<8+0x84);
|
||||
ICRex(tmpi,i.u8[1]);
|
||||
ICU16(tmpi,i.u8[2]<<8+0x84);
|
||||
break;
|
||||
case RT_U16:
|
||||
case RT_I16:
|
||||
ICOpSizeRex(tempi,i.u8[1]);
|
||||
ICU16(tempi,i.u8[2]<<8+0x85);
|
||||
ICOpSizeRex(tmpi,i.u8[1]);
|
||||
ICU16(tmpi,i.u8[2]<<8+0x85);
|
||||
break;
|
||||
default:
|
||||
ICRex(tempi,i.u8[1]);
|
||||
ICU16(tempi,i.u8[2]<<8+0x85);
|
||||
ICRex(tmpi,i.u8[1]);
|
||||
ICU16(tmpi,i.u8[2]<<8+0x85);
|
||||
}
|
||||
ICModr2(tempi,i,d1,ip2+4);
|
||||
ICModr2(tmpi,i,d1,ip2+4);
|
||||
}
|
||||
|
||||
ip+=tempi->ic_cnt;
|
||||
lb=OptLabelFwd(tempi->ic_data);
|
||||
short_jmp=ToBool(tempi->ic_flags&ICF_SHORT_JMP);
|
||||
ip+=tmpi->ic_cnt;
|
||||
lb=OptLabelFwd(tmpi->ic_data);
|
||||
short_jmp=ToBool(tmpi->ic_flags&ICF_SHORT_JMP);
|
||||
if (!buf && lb->addr!=INVALID_PTR) {
|
||||
i=lb->addr-(ip+2);
|
||||
if (lb->flags&CMF_POP_CMP)
|
||||
@@ -141,82 +141,82 @@ U0 ICAndBranch(CIntermediateCode *tempi,I64 ip,I64 is,U8 *buf,I64 ip2)
|
||||
}
|
||||
|
||||
if (short_jmp) {
|
||||
tempi->ic_flags|=ICF_SHORT_JMP;
|
||||
tmpi->ic_flags|=ICF_SHORT_JMP;
|
||||
i=lb->addr-(ip+2);
|
||||
if (lb->flags&CMF_POP_CMP)
|
||||
i+=8;
|
||||
ICU16(tempi,i<<8+is.u8[2]);
|
||||
ICU16(tmpi,i<<8+is.u8[2]);
|
||||
} else {
|
||||
tempi->ic_flags&=~ICF_SHORT_JMP;
|
||||
tmpi->ic_flags&=~ICF_SHORT_JMP;
|
||||
i=lb->addr-(ip+6);
|
||||
if (lb->flags&CMF_POP_CMP)
|
||||
i+=8;
|
||||
ICU16(tempi,is.u16[0]);
|
||||
ICU32(tempi,i);
|
||||
ICU16(tmpi,is.u16[0]);
|
||||
ICU32(tmpi,i);
|
||||
}
|
||||
}
|
||||
|
||||
U0 ICAssign(CIntermediateCode *tempi,I64 ip)
|
||||
U0 ICAssign(CIntermediateCode *tmpi,I64 ip)
|
||||
{
|
||||
CIntermediateCode *tempi1;
|
||||
if (tempi->ic_flags & ICF_BY_VAL) {
|
||||
ICMov(tempi,tempi->a1.type&MDG_MASK+tempi->a1_type_pointed_to,
|
||||
tempi->a1.reg,tempi->a1.disp,
|
||||
tempi->a2.type,tempi->a2.reg,tempi->a2.disp,ip);
|
||||
if (tempi->r.type.mode)
|
||||
ICMov(tempi,tempi->r.type&MDG_MASK+tempi->a1_type_pointed_to,
|
||||
tempi->r.reg,tempi->r.disp,
|
||||
tempi->a1.type&MDG_MASK+tempi->a1_type_pointed_to,
|
||||
tempi->a1.reg,tempi->a1.disp,ip);
|
||||
CIntermediateCode *tmpi1;
|
||||
if (tmpi->ic_flags & ICF_BY_VAL) {
|
||||
ICMov(tmpi,tmpi->a1.type&MDG_MASK+tmpi->a1_type_pointed_to,
|
||||
tmpi->a1.reg,tmpi->a1.disp,
|
||||
tmpi->a2.type,tmpi->a2.reg,tmpi->a2.disp,ip);
|
||||
if (tmpi->r.type.mode)
|
||||
ICMov(tmpi,tmpi->r.type&MDG_MASK+tmpi->a1_type_pointed_to,
|
||||
tmpi->r.reg,tmpi->r.disp,
|
||||
tmpi->a1.type&MDG_MASK+tmpi->a1_type_pointed_to,
|
||||
tmpi->a1.reg,tmpi->a1.disp,ip);
|
||||
} else {
|
||||
if (tempi->a1.type&MDF_REG) {
|
||||
if (!(tempi1=OptLag1(tempi)) || tempi1->ic_code!=IC_ADD_CONST ||
|
||||
tempi1->r.type!=MDF_REG+RT_I64 || tempi1->r.reg!=tempi->a1.reg ||
|
||||
tempi1->a1.type!=MDF_REG+RT_I64 || tempi1->a1.reg!=tempi->a1.reg ||
|
||||
(tempi->a2.type&MDF_REG || tempi->a2.type&MDF_DISP) &&
|
||||
tempi->a2.reg==tempi->a1.reg ||
|
||||
tempi->r.type.mode || tempi1->ic_flags&~ICG_NO_CVT_MASK) {
|
||||
ICMov(tempi,
|
||||
MDF_DISP+tempi->a1_type_pointed_to,tempi->a1.reg,tempi->a1.disp,
|
||||
tempi->a2.type,tempi->a2.reg,tempi->a2.disp,ip);
|
||||
if (tempi->r.type.mode)
|
||||
ICMov(tempi,tempi->r.type,tempi->r.reg,tempi->r.disp,
|
||||
tempi->a2.type,tempi->a2.reg,tempi->a2.disp,ip);
|
||||
if (tmpi->a1.type&MDF_REG) {
|
||||
if (!(tmpi1=OptLag1(tmpi)) || tmpi1->ic_code!=IC_ADD_CONST ||
|
||||
tmpi1->r.type!=MDF_REG+RT_I64 || tmpi1->r.reg!=tmpi->a1.reg ||
|
||||
tmpi1->a1.type!=MDF_REG+RT_I64 || tmpi1->a1.reg!=tmpi->a1.reg ||
|
||||
(tmpi->a2.type&MDF_REG || tmpi->a2.type&MDF_DISP) &&
|
||||
tmpi->a2.reg==tmpi->a1.reg ||
|
||||
tmpi->r.type.mode || tmpi1->ic_flags&~ICG_NO_CVT_MASK) {
|
||||
ICMov(tmpi,
|
||||
MDF_DISP+tmpi->a1_type_pointed_to,tmpi->a1.reg,tmpi->a1.disp,
|
||||
tmpi->a2.type,tmpi->a2.reg,tmpi->a2.disp,ip);
|
||||
if (tmpi->r.type.mode)
|
||||
ICMov(tmpi,tmpi->r.type,tmpi->r.reg,tmpi->r.disp,
|
||||
tmpi->a2.type,tmpi->a2.reg,tmpi->a2.disp,ip);
|
||||
} else {
|
||||
tempi->ic_flags=(tempi->ic_flags|tempi1->ic_flags)&
|
||||
tmpi->ic_flags=(tmpi->ic_flags|tmpi1->ic_flags)&
|
||||
~ICF_CODE_FINAL|ICF_DONT_RESTORE;
|
||||
tempi->a1.disp=tempi1->ic_data;
|
||||
OptSetNOP1(tempi1); //This better not be last pass!
|
||||
ICMov(tempi,MDF_DISP+tempi->a1_type_pointed_to,
|
||||
tempi->a1.reg,tempi->a1.disp,
|
||||
tempi->a2.type,tempi->a2.reg,tempi->a2.disp,ip);
|
||||
tmpi->a1.disp=tmpi1->ic_data;
|
||||
OptSetNOP1(tmpi1); //This better not be last pass!
|
||||
ICMov(tmpi,MDF_DISP+tmpi->a1_type_pointed_to,
|
||||
tmpi->a1.reg,tmpi->a1.disp,
|
||||
tmpi->a2.type,tmpi->a2.reg,tmpi->a2.disp,ip);
|
||||
}
|
||||
} else {
|
||||
ICMov(tempi,MDF_REG+RT_I64,REG_RCX,0,
|
||||
tempi->a1.type,tempi->a1.reg,tempi->a1.disp,ip);
|
||||
ICMov(tempi,MDF_DISP+tempi->a1_type_pointed_to,REG_RCX,0,
|
||||
tempi->a2.type,tempi->a2.reg,tempi->a2.disp,ip);
|
||||
if (tempi->r.type.mode)
|
||||
ICMov(tempi,tempi->r.type,tempi->r.reg,tempi->r.disp,
|
||||
tempi->a2.type,tempi->a2.reg,tempi->a2.disp,ip);
|
||||
ICMov(tmpi,MDF_REG+RT_I64,REG_RCX,0,
|
||||
tmpi->a1.type,tmpi->a1.reg,tmpi->a1.disp,ip);
|
||||
ICMov(tmpi,MDF_DISP+tmpi->a1_type_pointed_to,REG_RCX,0,
|
||||
tmpi->a2.type,tmpi->a2.reg,tmpi->a2.disp,ip);
|
||||
if (tmpi->r.type.mode)
|
||||
ICMov(tmpi,tmpi->r.type,tmpi->r.reg,tmpi->r.disp,
|
||||
tmpi->a2.type,tmpi->a2.reg,tmpi->a2.disp,ip);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
U0 ICBrBitOps(CIntermediateCode *tempi,I64 ip,
|
||||
U0 ICBrBitOps(CIntermediateCode *tmpi,I64 ip,
|
||||
I64 op,I64 op_imm,I64 is,U8 *buf,I64 ip2)
|
||||
{
|
||||
I64 i,t,r1,r2,d1,d2,t1,t2;
|
||||
CICArg *a1=&tempi->a1,*a2=&tempi->a2;
|
||||
CICArg *a1=&tmpi->a1,*a2=&tmpi->a2;
|
||||
Bool short_jmp;
|
||||
CCodeMisc *lb;
|
||||
|
||||
if (tempi->ic_flags & ICF_BY_VAL) {
|
||||
if (tempi->ic_flags&ICF_SWAP && !(a2->type&MDF_REG) &&
|
||||
if (tmpi->ic_flags & ICF_BY_VAL) {
|
||||
if (tmpi->ic_flags&ICF_SWAP && !(a2->type&MDF_REG) &&
|
||||
(!(a2->type&MDF_IMM) ||a2->disp>63)||
|
||||
!(tempi->ic_flags&ICF_SWAP) && a2->type&MDF_IMM &&
|
||||
!(tmpi->ic_flags&ICF_SWAP) && a2->type&MDF_IMM &&
|
||||
a2->disp<64 || a2->type&MDF_STK) {
|
||||
ICMov(tempi,MDF_REG+RT_I64,REG_RCX,0,a2->type,a2->reg,a2->disp,ip2);
|
||||
ICMov(tmpi,MDF_REG+RT_I64,REG_RCX,0,a2->type,a2->reg,a2->disp,ip2);
|
||||
t2=MDF_REG+RT_I64;
|
||||
r2=REG_RCX;
|
||||
d2=0;
|
||||
@@ -228,11 +228,11 @@ U0 ICBrBitOps(CIntermediateCode *tempi,I64 ip,
|
||||
r2=a2->reg;
|
||||
d2=a2->disp;
|
||||
}
|
||||
if (!(tempi->ic_flags&ICF_SWAP) && !(a1->type&MDF_REG) &&
|
||||
if (!(tmpi->ic_flags&ICF_SWAP) && !(a1->type&MDF_REG) &&
|
||||
(!(a1->type&MDF_IMM) || a1->disp>63) ||
|
||||
tempi->ic_flags&ICF_SWAP && a1->type&MDF_IMM &&
|
||||
tmpi->ic_flags&ICF_SWAP && a1->type&MDF_IMM &&
|
||||
a1->disp<64 || a1->type&MDF_STK) {
|
||||
ICMov(tempi,MDF_REG+RT_I64,REG_RDX,0,a1->type,a1->reg,a1->disp,ip2);
|
||||
ICMov(tmpi,MDF_REG+RT_I64,REG_RDX,0,a1->type,a1->reg,a1->disp,ip2);
|
||||
t1=MDF_REG+RT_I64;
|
||||
r1=REG_RDX;
|
||||
d1=0;
|
||||
@@ -251,23 +251,23 @@ U0 ICBrBitOps(CIntermediateCode *tempi,I64 ip,
|
||||
d2=0;
|
||||
if (a2->type&MDF_REG)
|
||||
r2=a2->reg;
|
||||
else if (!(tempi->ic_flags&ICF_SWAP) || !(a2->type&MDF_IMM) ||
|
||||
else if (!(tmpi->ic_flags&ICF_SWAP) || !(a2->type&MDF_IMM) ||
|
||||
a2->disp>63) {
|
||||
ICMov(tempi,MDF_REG+RT_I64,REG_RCX,0,a2->type,a2->reg,a2->disp,ip2);
|
||||
ICMov(tmpi,MDF_REG+RT_I64,REG_RCX,0,a2->type,a2->reg,a2->disp,ip2);
|
||||
r2=REG_RCX;
|
||||
} else
|
||||
r2=0;
|
||||
if (a1->type&MDF_REG)
|
||||
r1=a1->reg;
|
||||
else if (tempi->ic_flags&ICF_SWAP || !(a1->type&MDF_IMM) || a1->disp>63) {
|
||||
ICMov(tempi,MDF_REG+RT_I64,REG_RDX,0,a1->type,a1->reg,a1->disp,ip2);
|
||||
else if (tmpi->ic_flags&ICF_SWAP || !(a1->type&MDF_IMM) || a1->disp>63) {
|
||||
ICMov(tmpi,MDF_REG+RT_I64,REG_RDX,0,a1->type,a1->reg,a1->disp,ip2);
|
||||
r1=REG_RDX;
|
||||
} else
|
||||
r1=0;
|
||||
}
|
||||
if (tempi->ic_flags&ICF_LOCK && op!=0xA30F)
|
||||
ICU8(tempi,OC_LOCK_PREFIX);
|
||||
if (tempi->ic_flags&ICF_SWAP) {
|
||||
if (tmpi->ic_flags&ICF_LOCK && op!=0xA30F)
|
||||
ICU8(tmpi,OC_LOCK_PREFIX);
|
||||
if (tmpi->ic_flags&ICF_SWAP) {
|
||||
if (a2->type&MDF_IMM && a2->disp<32) {
|
||||
if (op==0xA30F && a2->disp<8) {
|
||||
t=t1&MDG_MASK+RT_U8;
|
||||
@@ -289,27 +289,27 @@ U0 ICBrBitOps(CIntermediateCode *tempi,I64 ip,
|
||||
t=t2;
|
||||
i=ICModr1(r1,t,r2,d2);
|
||||
}
|
||||
ICRex(tempi,i.u8[1]);
|
||||
ICRex(tmpi,i.u8[1]);
|
||||
if (op_imm==0xF6) {//TEST
|
||||
ICU16(tempi,i.u8[2]<<8+op_imm);
|
||||
ICModr2(tempi,i,a2->disp,ip2+5);
|
||||
ICU8(tempi,1<<a1->disp);
|
||||
ICU16(tmpi,i.u8[2]<<8+op_imm);
|
||||
ICModr2(tmpi,i,a2->disp,ip2+5);
|
||||
ICU8(tmpi,1<<a1->disp);
|
||||
if (is==0x72820F)
|
||||
is=0x75850F;
|
||||
else
|
||||
is=0x74840F;
|
||||
} else if (a1->type&MDF_IMM && a1->disp<64) {
|
||||
ICU24(tempi,i.u8[2]<<16+op_imm);
|
||||
ICModr2(tempi,i,a2->disp,ip2+5);
|
||||
ICU8(tempi,a1->disp);
|
||||
ICU24(tmpi,i.u8[2]<<16+op_imm);
|
||||
ICModr2(tmpi,i,a2->disp,ip2+5);
|
||||
ICU8(tmpi,a1->disp);
|
||||
} else {
|
||||
ICU24(tempi,i.u8[2]<<16+op);
|
||||
ICModr2(tempi,i,a2->disp,ip2+4);
|
||||
ICU24(tmpi,i.u8[2]<<16+op);
|
||||
ICModr2(tmpi,i,a2->disp,ip2+4);
|
||||
}
|
||||
|
||||
ip+=tempi->ic_cnt;
|
||||
lb=OptLabelFwd(tempi->ic_data);
|
||||
short_jmp=ToBool(tempi->ic_flags&ICF_SHORT_JMP);
|
||||
ip+=tmpi->ic_cnt;
|
||||
lb=OptLabelFwd(tmpi->ic_data);
|
||||
short_jmp=ToBool(tmpi->ic_flags&ICF_SHORT_JMP);
|
||||
if (!buf && lb->addr!=INVALID_PTR) {
|
||||
i=lb->addr-(ip+2);
|
||||
if (lb->flags&CMF_POP_CMP)
|
||||
@@ -319,180 +319,180 @@ U0 ICBrBitOps(CIntermediateCode *tempi,I64 ip,
|
||||
}
|
||||
|
||||
if (short_jmp) {
|
||||
tempi->ic_flags|=ICF_SHORT_JMP;
|
||||
tmpi->ic_flags|=ICF_SHORT_JMP;
|
||||
i=lb->addr-(ip+2);
|
||||
if (lb->flags&CMF_POP_CMP)
|
||||
i+=8;
|
||||
ICU16(tempi,i<<8+is.u8[2]);
|
||||
ICU16(tmpi,i<<8+is.u8[2]);
|
||||
} else {
|
||||
tempi->ic_flags&=~ICF_SHORT_JMP;
|
||||
tmpi->ic_flags&=~ICF_SHORT_JMP;
|
||||
i=lb->addr-(ip+6);
|
||||
if (lb->flags&CMF_POP_CMP)
|
||||
i+=8;
|
||||
ICU16(tempi,is.u16[0]);
|
||||
ICU32(tempi,i);
|
||||
ICU16(tmpi,is.u16[0]);
|
||||
ICU32(tmpi,i);
|
||||
}
|
||||
}
|
||||
|
||||
U0 ICQueInit(CIntermediateCode *tempi,I64 ip2)
|
||||
U0 ICQueInit(CIntermediateCode *tmpi,I64 ip2)
|
||||
{
|
||||
I64 r1;
|
||||
if (tempi->a1.type==MDF_REG+RT_I64)
|
||||
r1=tempi->a1.reg;
|
||||
if (tmpi->a1.type==MDF_REG+RT_I64)
|
||||
r1=tmpi->a1.reg;
|
||||
else {
|
||||
ICMov(tempi,MDF_REG+RT_I64,REG_RAX,0,
|
||||
tempi->a1.type,tempi->a1.reg,tempi->a1.disp,ip2);
|
||||
ICMov(tmpi,MDF_REG+RT_I64,REG_RAX,0,
|
||||
tmpi->a1.type,tmpi->a1.reg,tmpi->a1.disp,ip2);
|
||||
r1=REG_RAX;
|
||||
}
|
||||
ICMov(tempi,MDF_DISP+RT_I64,r1,0,MDF_REG+RT_I64,r1,0,ip2);
|
||||
ICMov(tempi,MDF_DISP+RT_I64,r1,sizeof(U8 *),MDF_REG+RT_I64,r1,0,ip2);
|
||||
ICMov(tmpi,MDF_DISP+RT_I64,r1,0,MDF_REG+RT_I64,r1,0,ip2);
|
||||
ICMov(tmpi,MDF_DISP+RT_I64,r1,sizeof(U8 *),MDF_REG+RT_I64,r1,0,ip2);
|
||||
}
|
||||
|
||||
U0 ICQueIns(CIntermediateCode *tempi,I64 ip2)
|
||||
U0 ICQueIns(CIntermediateCode *tmpi,I64 ip2)
|
||||
{
|
||||
I64 r1,r2;
|
||||
if (tempi->a2.type==MDF_REG+RT_I64 && tempi->a2.reg!=REG_RDX)
|
||||
r2=tempi->a2.reg;
|
||||
if (tmpi->a2.type==MDF_REG+RT_I64 && tmpi->a2.reg!=REG_RDX)
|
||||
r2=tmpi->a2.reg;
|
||||
else {
|
||||
ICMov(tempi,MDF_REG+RT_I64,REG_RAX,0,
|
||||
tempi->a2.type,tempi->a2.reg,tempi->a2.disp,ip2);
|
||||
ICMov(tmpi,MDF_REG+RT_I64,REG_RAX,0,
|
||||
tmpi->a2.type,tmpi->a2.reg,tmpi->a2.disp,ip2);
|
||||
r2=REG_RAX;
|
||||
}
|
||||
if (tempi->a1.type==MDF_REG+RT_I64)
|
||||
r1=tempi->a1.reg;
|
||||
if (tmpi->a1.type==MDF_REG+RT_I64)
|
||||
r1=tmpi->a1.reg;
|
||||
else {
|
||||
ICMov(tempi,MDF_REG+RT_I64,REG_RDX,0,
|
||||
tempi->a1.type,tempi->a1.reg,tempi->a1.disp,ip2);
|
||||
ICMov(tmpi,MDF_REG+RT_I64,REG_RDX,0,
|
||||
tmpi->a1.type,tmpi->a1.reg,tmpi->a1.disp,ip2);
|
||||
r1=REG_RDX;
|
||||
}
|
||||
ICMov(tempi,MDF_REG+RT_I64,REG_RBX,0,MDF_DISP+RT_I64,r1,0,ip2);
|
||||
ICMov(tempi,MDF_DISP+RT_I64,r1,0,MDF_REG+RT_I64,r2,0,ip2);
|
||||
ICMov(tempi,MDF_DISP+RT_I64,r2,0,MDF_REG+RT_I64,REG_RBX,0,ip2);
|
||||
ICMov(tempi,MDF_DISP+RT_I64,r2,sizeof(U8 *),MDF_REG+RT_I64,r1,0,ip2);
|
||||
ICMov(tempi,MDF_DISP+RT_I64,REG_RBX,sizeof(U8 *),MDF_REG+RT_I64,r2,0,ip2);
|
||||
ICMov(tmpi,MDF_REG+RT_I64,REG_RBX,0,MDF_DISP+RT_I64,r1,0,ip2);
|
||||
ICMov(tmpi,MDF_DISP+RT_I64,r1,0,MDF_REG+RT_I64,r2,0,ip2);
|
||||
ICMov(tmpi,MDF_DISP+RT_I64,r2,0,MDF_REG+RT_I64,REG_RBX,0,ip2);
|
||||
ICMov(tmpi,MDF_DISP+RT_I64,r2,sizeof(U8 *),MDF_REG+RT_I64,r1,0,ip2);
|
||||
ICMov(tmpi,MDF_DISP+RT_I64,REG_RBX,sizeof(U8 *),MDF_REG+RT_I64,r2,0,ip2);
|
||||
}
|
||||
|
||||
U0 ICQueInsRev(CIntermediateCode *tempi,I64 ip2)
|
||||
U0 ICQueInsRev(CIntermediateCode *tmpi,I64 ip2)
|
||||
{
|
||||
I64 r1,r2;
|
||||
if (tempi->a2.type==MDF_REG+RT_I64 && tempi->a2.reg!=REG_RDX)
|
||||
r2=tempi->a2.reg;
|
||||
if (tmpi->a2.type==MDF_REG+RT_I64 && tmpi->a2.reg!=REG_RDX)
|
||||
r2=tmpi->a2.reg;
|
||||
else {
|
||||
ICMov(tempi,MDF_REG+RT_I64,REG_RAX,0,
|
||||
tempi->a2.type,tempi->a2.reg,tempi->a2.disp,ip2);
|
||||
ICMov(tmpi,MDF_REG+RT_I64,REG_RAX,0,
|
||||
tmpi->a2.type,tmpi->a2.reg,tmpi->a2.disp,ip2);
|
||||
r2=REG_RAX;
|
||||
}
|
||||
if (tempi->a1.type==MDF_REG+RT_I64)
|
||||
r1=tempi->a1.reg;
|
||||
if (tmpi->a1.type==MDF_REG+RT_I64)
|
||||
r1=tmpi->a1.reg;
|
||||
else {
|
||||
ICMov(tempi,MDF_REG+RT_I64,REG_RDX,0,
|
||||
tempi->a1.type,tempi->a1.reg,tempi->a1.disp,ip2);
|
||||
ICMov(tmpi,MDF_REG+RT_I64,REG_RDX,0,
|
||||
tmpi->a1.type,tmpi->a1.reg,tmpi->a1.disp,ip2);
|
||||
r1=REG_RDX;
|
||||
}
|
||||
ICMov(tempi,MDF_REG+RT_I64,REG_RBX,0,MDF_DISP+RT_I64,r1,sizeof(U8 *),ip2);
|
||||
ICMov(tempi,MDF_DISP+RT_I64,REG_RBX,0,MDF_REG+RT_I64,r2,0,ip2);
|
||||
ICMov(tempi,MDF_DISP+RT_I64,r2,0,MDF_REG+RT_I64,r1,0,ip2);
|
||||
ICMov(tempi,MDF_DISP+RT_I64,r2,sizeof(U8 *),MDF_REG+RT_I64,REG_RBX,0,ip2);
|
||||
ICMov(tempi,MDF_DISP+RT_I64,r1,sizeof(U8 *),MDF_REG+RT_I64,r2,0,ip2);
|
||||
ICMov(tmpi,MDF_REG+RT_I64,REG_RBX,0,MDF_DISP+RT_I64,r1,sizeof(U8 *),ip2);
|
||||
ICMov(tmpi,MDF_DISP+RT_I64,REG_RBX,0,MDF_REG+RT_I64,r2,0,ip2);
|
||||
ICMov(tmpi,MDF_DISP+RT_I64,r2,0,MDF_REG+RT_I64,r1,0,ip2);
|
||||
ICMov(tmpi,MDF_DISP+RT_I64,r2,sizeof(U8 *),MDF_REG+RT_I64,REG_RBX,0,ip2);
|
||||
ICMov(tmpi,MDF_DISP+RT_I64,r1,sizeof(U8 *),MDF_REG+RT_I64,r2,0,ip2);
|
||||
}
|
||||
|
||||
U0 ICQueRem(CIntermediateCode *tempi,I64 ip2)
|
||||
U0 ICQueRem(CIntermediateCode *tmpi,I64 ip2)
|
||||
{
|
||||
I64 r1;
|
||||
if (tempi->a1.type==MDF_REG+RT_I64)
|
||||
r1=tempi->a1.reg;
|
||||
if (tmpi->a1.type==MDF_REG+RT_I64)
|
||||
r1=tmpi->a1.reg;
|
||||
else {
|
||||
ICMov(tempi,MDF_REG+RT_I64,REG_RAX,0,
|
||||
tempi->a1.type,tempi->a1.reg,tempi->a1.disp,ip2);
|
||||
ICMov(tmpi,MDF_REG+RT_I64,REG_RAX,0,
|
||||
tmpi->a1.type,tmpi->a1.reg,tmpi->a1.disp,ip2);
|
||||
r1=REG_RAX;
|
||||
}
|
||||
ICMov(tempi,MDF_REG+RT_I64,REG_RBX,0,MDF_DISP+RT_I64,r1,0,ip2);
|
||||
ICMov(tempi,MDF_REG+RT_I64,REG_RDX,0,MDF_DISP+RT_I64,r1,sizeof(U8 *),ip2);
|
||||
ICU24(tempi,0x1A8948);
|
||||
ICU32(tempi,sizeof(U8 *)<<24+0x538948);
|
||||
ICMov(tmpi,MDF_REG+RT_I64,REG_RBX,0,MDF_DISP+RT_I64,r1,0,ip2);
|
||||
ICMov(tmpi,MDF_REG+RT_I64,REG_RDX,0,MDF_DISP+RT_I64,r1,sizeof(U8 *),ip2);
|
||||
ICU24(tmpi,0x1A8948);
|
||||
ICU32(tmpi,sizeof(U8 *)<<24+0x538948);
|
||||
}
|
||||
|
||||
U0 ICMinMax(CIntermediateCode *tempi,I64 op,I64 ip2)
|
||||
U0 ICMinMax(CIntermediateCode *tmpi,I64 op,I64 ip2)
|
||||
{
|
||||
I64 r1,i1=0x48;
|
||||
if (tempi->a2.type==MDF_REG+RT_I64 && tempi->a2.reg!=REG_RAX) {
|
||||
r1=tempi->a2.reg;
|
||||
if (tmpi->a2.type==MDF_REG+RT_I64 && tmpi->a2.reg!=REG_RAX) {
|
||||
r1=tmpi->a2.reg;
|
||||
if (r1>7) {
|
||||
i1++;
|
||||
r1&=7;
|
||||
}
|
||||
ICMov(tempi,MDF_REG+RT_I64,REG_RAX,0,
|
||||
tempi->a1.type,tempi->a1.reg,tempi->a1.disp,ip2);
|
||||
ICMov(tmpi,MDF_REG+RT_I64,REG_RAX,0,
|
||||
tmpi->a1.type,tmpi->a1.reg,tmpi->a1.disp,ip2);
|
||||
} else {
|
||||
if (tempi->a1.reg==REG_RAX && tempi->a1.type&MDG_REG_DISP_SIB) {
|
||||
ICMov(tempi,MDF_REG+RT_I64,REG_RDX,0,
|
||||
tempi->a2.type,tempi->a2.reg,tempi->a2.disp,ip2);
|
||||
if (tmpi->a1.reg==REG_RAX && tmpi->a1.type&MDG_REG_DISP_SIB) {
|
||||
ICMov(tmpi,MDF_REG+RT_I64,REG_RDX,0,
|
||||
tmpi->a2.type,tmpi->a2.reg,tmpi->a2.disp,ip2);
|
||||
r1=REG_RDX;
|
||||
ICMov(tempi,MDF_REG+RT_I64,REG_RAX,0,
|
||||
tempi->a1.type,tempi->a1.reg,tempi->a1.disp,ip2);
|
||||
ICMov(tmpi,MDF_REG+RT_I64,REG_RAX,0,
|
||||
tmpi->a1.type,tmpi->a1.reg,tmpi->a1.disp,ip2);
|
||||
} else {
|
||||
ICMov(tempi,MDF_REG+RT_I64,REG_RAX,0,
|
||||
tempi->a2.type,tempi->a2.reg,tempi->a2.disp,ip2);
|
||||
if (tempi->a1.type==MDF_REG+RT_I64) {
|
||||
r1=tempi->a1.reg;
|
||||
ICMov(tmpi,MDF_REG+RT_I64,REG_RAX,0,
|
||||
tmpi->a2.type,tmpi->a2.reg,tmpi->a2.disp,ip2);
|
||||
if (tmpi->a1.type==MDF_REG+RT_I64) {
|
||||
r1=tmpi->a1.reg;
|
||||
if (r1>7) {
|
||||
i1++;
|
||||
r1&=7;
|
||||
}
|
||||
} else {
|
||||
r1=REG_RDX;
|
||||
ICMov(tempi,MDF_REG+RT_I64,REG_RDX,0,
|
||||
tempi->a1.type,tempi->a1.reg,tempi->a1.disp,ip2);
|
||||
ICMov(tmpi,MDF_REG+RT_I64,REG_RDX,0,
|
||||
tmpi->a1.type,tmpi->a1.reg,tmpi->a1.disp,ip2);
|
||||
}
|
||||
}
|
||||
}
|
||||
ICU24(tempi,0xC03B00+r1<<16+i1);
|
||||
ICU32(tempi,0xC0000F00+op<<16+r1<<24+i1);
|
||||
ICU24(tmpi,0xC03B00+r1<<16+i1);
|
||||
ICU32(tmpi,0xC0000F00+op<<16+r1<<24+i1);
|
||||
}
|
||||
|
||||
U0 ICSqr(CIntermediateCode *tempi,I64 op,I64 ip2)
|
||||
U0 ICSqr(CIntermediateCode *tmpi,I64 op,I64 ip2)
|
||||
{
|
||||
ICMov(tempi,MDF_REG+RT_I64,REG_RAX,0,
|
||||
tempi->a1.type,tempi->a1.reg,tempi->a1.disp,ip2);
|
||||
ICSlashOp(tempi,MDF_REG+RT_I64,REG_RAX,0,op,ip2);
|
||||
ICMov(tmpi,MDF_REG+RT_I64,REG_RAX,0,
|
||||
tmpi->a1.type,tmpi->a1.reg,tmpi->a1.disp,ip2);
|
||||
ICSlashOp(tmpi,MDF_REG+RT_I64,REG_RAX,0,op,ip2);
|
||||
}
|
||||
|
||||
U0 ICModU64(CIntermediateCode *tempi,I64 ip2)
|
||||
U0 ICModU64(CIntermediateCode *tmpi,I64 ip2)
|
||||
{
|
||||
CICType t1;
|
||||
I64 r1,d1;
|
||||
ICMov(tempi,MDF_REG+RT_I64,REG_RCX,0,
|
||||
tempi->a2.type,tempi->a2.reg,tempi->a2.disp,ip2);
|
||||
if (tempi->a1.reg!=REG_RAX && tempi->a1.reg!=REG_RDX &&
|
||||
tempi->a1.type&MDG_REG_DISP_SIB &&
|
||||
tempi->a1.type.raw_type>=RT_I64) {
|
||||
t1=tempi->a1.type;
|
||||
r1=tempi->a1.reg;
|
||||
d1=tempi->a1.disp;
|
||||
ICMov(tmpi,MDF_REG+RT_I64,REG_RCX,0,
|
||||
tmpi->a2.type,tmpi->a2.reg,tmpi->a2.disp,ip2);
|
||||
if (tmpi->a1.reg!=REG_RAX && tmpi->a1.reg!=REG_RDX &&
|
||||
tmpi->a1.type&MDG_REG_DISP_SIB &&
|
||||
tmpi->a1.type.raw_type>=RT_I64) {
|
||||
t1=tmpi->a1.type;
|
||||
r1=tmpi->a1.reg;
|
||||
d1=tmpi->a1.disp;
|
||||
} else {
|
||||
t1=MDF_REG+RT_I64;
|
||||
r1=REG_RBX;
|
||||
d1=0;
|
||||
ICMov(tempi,MDF_REG+RT_I64,REG_RBX,0,
|
||||
tempi->a1.type,tempi->a1.reg,tempi->a1.disp,ip2);
|
||||
ICMov(tmpi,MDF_REG+RT_I64,REG_RBX,0,
|
||||
tmpi->a1.type,tmpi->a1.reg,tmpi->a1.disp,ip2);
|
||||
}
|
||||
ICMov(tempi,MDF_REG+RT_I64,REG_RAX,0,MDF_DISP+RT_I64,REG_RCX,0,ip2);
|
||||
ICZero(tempi,REG_RDX);
|
||||
ICSlashOp(tempi,t1,r1,d1,SLASH_OP_DIV,ip2);
|
||||
ICMov(tempi,MDF_DISP+RT_I64,REG_RCX,0,MDF_REG+RT_I64,REG_RAX,0,ip2);
|
||||
ICMov(tempi,MDF_REG+RT_I64,REG_RAX,0,
|
||||
ICMov(tmpi,MDF_REG+RT_I64,REG_RAX,0,MDF_DISP+RT_I64,REG_RCX,0,ip2);
|
||||
ICZero(tmpi,REG_RDX);
|
||||
ICSlashOp(tmpi,t1,r1,d1,SLASH_OP_DIV,ip2);
|
||||
ICMov(tmpi,MDF_DISP+RT_I64,REG_RCX,0,MDF_REG+RT_I64,REG_RAX,0,ip2);
|
||||
ICMov(tmpi,MDF_REG+RT_I64,REG_RAX,0,
|
||||
MDF_REG+RT_I64,REG_RDX,0,ip2);
|
||||
}
|
||||
|
||||
U0 ICSwap(CIntermediateCode *tempi,I64 ip2)
|
||||
U0 ICSwap(CIntermediateCode *tmpi,I64 ip2)
|
||||
{
|
||||
I64 r1,r2;
|
||||
if (tempi->a1.type&MDF_REG)
|
||||
r1=tempi->a1.reg;
|
||||
if (tmpi->a1.type&MDF_REG)
|
||||
r1=tmpi->a1.reg;
|
||||
else
|
||||
r1=REG_RAX;
|
||||
if (tempi->a2.type&MDF_REG)
|
||||
r2=tempi->a2.reg;
|
||||
if (tmpi->a2.type&MDF_REG)
|
||||
r2=tmpi->a2.reg;
|
||||
else
|
||||
r2=REG_RAX;
|
||||
if (r1==r2) {
|
||||
@@ -501,166 +501,166 @@ U0 ICSwap(CIntermediateCode *tempi,I64 ip2)
|
||||
else
|
||||
r2=REG_RAX;
|
||||
}
|
||||
ICMov(tempi,MDF_REG+RT_I64,r2,0,
|
||||
tempi->a2.type,tempi->a2.reg,tempi->a2.disp,ip2);
|
||||
ICMov(tempi,MDF_REG+RT_I64,r1,0,
|
||||
tempi->a1.type,tempi->a1.reg,tempi->a1.disp,ip2);
|
||||
switch (tempi->ic_code) {
|
||||
ICMov(tmpi,MDF_REG+RT_I64,r2,0,
|
||||
tmpi->a2.type,tmpi->a2.reg,tmpi->a2.disp,ip2);
|
||||
ICMov(tmpi,MDF_REG+RT_I64,r1,0,
|
||||
tmpi->a1.type,tmpi->a1.reg,tmpi->a1.disp,ip2);
|
||||
switch (tmpi->ic_code) {
|
||||
case IC_SWAP_U8:
|
||||
ICMov(tempi,MDF_REG+RT_I64,REG_RCX,0,MDF_DISP+RT_U8,r1,0,ip2);
|
||||
ICMov(tempi,MDF_REG+RT_I64,REG_RDX,0,MDF_DISP+RT_U8,r2,0,ip2);
|
||||
ICMov(tempi,MDF_DISP+RT_U8,r2,0,MDF_REG+RT_I64,REG_RCX,0,ip2);
|
||||
ICMov(tempi,MDF_DISP+RT_U8,r1,0,MDF_REG+RT_I64,REG_RDX,0,ip2);
|
||||
ICMov(tmpi,MDF_REG+RT_I64,REG_RCX,0,MDF_DISP+RT_U8,r1,0,ip2);
|
||||
ICMov(tmpi,MDF_REG+RT_I64,REG_RDX,0,MDF_DISP+RT_U8,r2,0,ip2);
|
||||
ICMov(tmpi,MDF_DISP+RT_U8,r2,0,MDF_REG+RT_I64,REG_RCX,0,ip2);
|
||||
ICMov(tmpi,MDF_DISP+RT_U8,r1,0,MDF_REG+RT_I64,REG_RDX,0,ip2);
|
||||
break;
|
||||
case IC_SWAP_U16:
|
||||
ICMov(tempi,MDF_REG+RT_I64,REG_RCX,0,MDF_DISP+RT_U16,r1,0,ip2);
|
||||
ICMov(tempi,MDF_REG+RT_I64,REG_RDX,0,MDF_DISP+RT_U16,r2,0,ip2);
|
||||
ICMov(tempi,MDF_DISP+RT_U16,r2,0,MDF_REG+RT_I64,REG_RCX,0,ip2);
|
||||
ICMov(tempi,MDF_DISP+RT_U16,r1,0,MDF_REG+RT_I64,REG_RDX,0,ip2);
|
||||
ICMov(tmpi,MDF_REG+RT_I64,REG_RCX,0,MDF_DISP+RT_U16,r1,0,ip2);
|
||||
ICMov(tmpi,MDF_REG+RT_I64,REG_RDX,0,MDF_DISP+RT_U16,r2,0,ip2);
|
||||
ICMov(tmpi,MDF_DISP+RT_U16,r2,0,MDF_REG+RT_I64,REG_RCX,0,ip2);
|
||||
ICMov(tmpi,MDF_DISP+RT_U16,r1,0,MDF_REG+RT_I64,REG_RDX,0,ip2);
|
||||
break;
|
||||
case IC_SWAP_U32:
|
||||
ICMov(tempi,MDF_REG+RT_I64,REG_RCX,0,MDF_DISP+RT_U32,r1,0,ip2);
|
||||
ICMov(tempi,MDF_REG+RT_I64,REG_RDX,0,MDF_DISP+RT_U32,r2,0,ip2);
|
||||
ICMov(tempi,MDF_DISP+RT_U32,r2,0,MDF_REG+RT_I64,REG_RCX,0,ip2);
|
||||
ICMov(tempi,MDF_DISP+RT_U32,r1,0,MDF_REG+RT_I64,REG_RDX,0,ip2);
|
||||
ICMov(tmpi,MDF_REG+RT_I64,REG_RCX,0,MDF_DISP+RT_U32,r1,0,ip2);
|
||||
ICMov(tmpi,MDF_REG+RT_I64,REG_RDX,0,MDF_DISP+RT_U32,r2,0,ip2);
|
||||
ICMov(tmpi,MDF_DISP+RT_U32,r2,0,MDF_REG+RT_I64,REG_RCX,0,ip2);
|
||||
ICMov(tmpi,MDF_DISP+RT_U32,r1,0,MDF_REG+RT_I64,REG_RDX,0,ip2);
|
||||
break;
|
||||
case IC_SWAP_I64:
|
||||
ICMov(tempi,MDF_REG+RT_I64,REG_RCX,0,MDF_DISP+RT_U64,r1,0,ip2);
|
||||
ICMov(tempi,MDF_REG+RT_I64,REG_RDX,0,MDF_DISP+RT_U64,r2,0,ip2);
|
||||
ICMov(tempi,MDF_DISP+RT_U64,r2,0,MDF_REG+RT_I64,REG_RCX,0,ip2);
|
||||
ICMov(tempi,MDF_DISP+RT_U64,r1,0,MDF_REG+RT_I64,REG_RDX,0,ip2);
|
||||
ICMov(tmpi,MDF_REG+RT_I64,REG_RCX,0,MDF_DISP+RT_U64,r1,0,ip2);
|
||||
ICMov(tmpi,MDF_REG+RT_I64,REG_RDX,0,MDF_DISP+RT_U64,r2,0,ip2);
|
||||
ICMov(tmpi,MDF_DISP+RT_U64,r2,0,MDF_REG+RT_I64,REG_RCX,0,ip2);
|
||||
ICMov(tmpi,MDF_DISP+RT_U64,r1,0,MDF_REG+RT_I64,REG_RDX,0,ip2);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
U0 ICAndEqu(CIntermediateCode *tempi,I64 ip2)
|
||||
U0 ICAndEqu(CIntermediateCode *tmpi,I64 ip2)
|
||||
{
|
||||
I64 i,bit;
|
||||
if (tempi->a2.type&MDF_IMM && !(tempi->a1.type&MDF_STK) &&
|
||||
tempi->ic_flags&ICF_RES_NOT_USED) {
|
||||
i=~tempi->a2.disp;
|
||||
if (tmpi->a2.type&MDF_IMM && !(tmpi->a1.type&MDF_STK) &&
|
||||
tmpi->ic_flags&ICF_RES_NOT_USED) {
|
||||
i=~tmpi->a2.disp;
|
||||
bit=Bsf(i);
|
||||
if (0<=bit==Bsr(i)) {
|
||||
tempi->a2.disp=bit;
|
||||
tempi->a2.reg=0;
|
||||
tempi->a1.type=tempi->a1.type&MDG_MASK+RT_I64;
|
||||
ICBitOps(tempi,&tempi->a2,&tempi->a1,tempi,0xB30F,0x30BA0F,ip2);
|
||||
tmpi->a2.disp=bit;
|
||||
tmpi->a2.reg=0;
|
||||
tmpi->a1.type=tmpi->a1.type&MDG_MASK+RT_I64;
|
||||
ICBitOps(tmpi,&tmpi->a2,&tmpi->a1,tmpi,0xB30F,0x30BA0F,ip2);
|
||||
return;
|
||||
}
|
||||
}
|
||||
ICAddSubEctEqu(tempi,tempi->a1_type_pointed_to,
|
||||
tempi->r.type,tempi->r.reg,tempi->r.disp,
|
||||
tempi->a1.type,tempi->a1.reg,tempi->a1.disp,
|
||||
tempi->a2.type,tempi->a2.reg,tempi->a2.disp,0x210425240423,ip2);
|
||||
ICAddSubEctEqu(tmpi,tmpi->a1_type_pointed_to,
|
||||
tmpi->r.type,tmpi->r.reg,tmpi->r.disp,
|
||||
tmpi->a1.type,tmpi->a1.reg,tmpi->a1.disp,
|
||||
tmpi->a2.type,tmpi->a2.reg,tmpi->a2.disp,0x210425240423,ip2);
|
||||
}
|
||||
|
||||
U0 ICOrEqu(CIntermediateCode *tempi,I64 ip2)
|
||||
U0 ICOrEqu(CIntermediateCode *tmpi,I64 ip2)
|
||||
{
|
||||
I64 i,bit;
|
||||
if (tempi->a2.type&MDF_IMM && !(tempi->a1.type&MDF_STK) &&
|
||||
tempi->ic_flags&ICF_RES_NOT_USED) {
|
||||
i=tempi->a2.disp;
|
||||
if (tmpi->a2.type&MDF_IMM && !(tmpi->a1.type&MDF_STK) &&
|
||||
tmpi->ic_flags&ICF_RES_NOT_USED) {
|
||||
i=tmpi->a2.disp;
|
||||
bit=Bsf(i);
|
||||
if (0<=bit==Bsr(i) && i>MAX_I8) {
|
||||
tempi->a2.disp=bit;
|
||||
tempi->a2.reg=0;
|
||||
tempi->a1.type=tempi->a1.type&MDG_MASK+RT_I64;
|
||||
ICBitOps(tempi,&tempi->a2,&tempi->a1,tempi,0xAB0F,0x28BA0F,ip2);
|
||||
tmpi->a2.disp=bit;
|
||||
tmpi->a2.reg=0;
|
||||
tmpi->a1.type=tmpi->a1.type&MDG_MASK+RT_I64;
|
||||
ICBitOps(tmpi,&tmpi->a2,&tmpi->a1,tmpi,0xAB0F,0x28BA0F,ip2);
|
||||
return;
|
||||
}
|
||||
}
|
||||
ICAddSubEctEqu(tempi,tempi->a1_type_pointed_to,
|
||||
tempi->r.type,tempi->r.reg,tempi->r.disp,
|
||||
tempi->a1.type,tempi->a1.reg,tempi->a1.disp,
|
||||
tempi->a2.type,tempi->a2.reg,tempi->a2.disp,0x09010D0C010B,ip2);
|
||||
ICAddSubEctEqu(tmpi,tmpi->a1_type_pointed_to,
|
||||
tmpi->r.type,tmpi->r.reg,tmpi->r.disp,
|
||||
tmpi->a1.type,tmpi->a1.reg,tmpi->a1.disp,
|
||||
tmpi->a2.type,tmpi->a2.reg,tmpi->a2.disp,0x09010D0C010B,ip2);
|
||||
}
|
||||
|
||||
U0 ICXorEqu(CIntermediateCode *tempi,I64 ip2)
|
||||
U0 ICXorEqu(CIntermediateCode *tmpi,I64 ip2)
|
||||
{
|
||||
I64 i,bit;
|
||||
if (tempi->a2.type&MDF_IMM && !(tempi->a1.type&MDF_STK) &&
|
||||
tempi->ic_flags&ICF_RES_NOT_USED) {
|
||||
i=tempi->a2.disp;
|
||||
if (tmpi->a2.type&MDF_IMM && !(tmpi->a1.type&MDF_STK) &&
|
||||
tmpi->ic_flags&ICF_RES_NOT_USED) {
|
||||
i=tmpi->a2.disp;
|
||||
bit=Bsf(i);
|
||||
if (0<=bit==Bsr(i)) {
|
||||
tempi->a2.disp=bit;
|
||||
tempi->a2.reg=0;
|
||||
tempi->a1.type=tempi->a1.type&MDG_MASK+RT_I64;
|
||||
ICBitOps(tempi,&tempi->a2,&tempi->a1,tempi,0xBB0F,0x38BA0F,ip2);
|
||||
tmpi->a2.disp=bit;
|
||||
tmpi->a2.reg=0;
|
||||
tmpi->a1.type=tmpi->a1.type&MDG_MASK+RT_I64;
|
||||
ICBitOps(tmpi,&tmpi->a2,&tmpi->a1,tmpi,0xBB0F,0x38BA0F,ip2);
|
||||
return;
|
||||
}
|
||||
}
|
||||
ICAddSubEctEqu(tempi,tempi->a1_type_pointed_to,
|
||||
tempi->r.type,tempi->r.reg,tempi->r.disp,
|
||||
tempi->a1.type,tempi->a1.reg,tempi->a1.disp,
|
||||
tempi->a2.type,tempi->a2.reg,tempi->a2.disp,0x310635340633,ip2);
|
||||
ICAddSubEctEqu(tmpi,tmpi->a1_type_pointed_to,
|
||||
tmpi->r.type,tmpi->r.reg,tmpi->r.disp,
|
||||
tmpi->a1.type,tmpi->a1.reg,tmpi->a1.disp,
|
||||
tmpi->a2.type,tmpi->a2.reg,tmpi->a2.disp,0x310635340633,ip2);
|
||||
}
|
||||
|
||||
U0 ICSwitch(CIntermediateCode *tempi,I64 ip,
|
||||
U0 ICSwitch(CIntermediateCode *tmpi,I64 ip,
|
||||
Bool nobound,CCmpCtrl *cc,U8 *buf,I64 ip2)
|
||||
{
|
||||
I64 i,j,cnt,min,max,begin,r;
|
||||
CCodeMisc *lb;
|
||||
Bool short_jmp;
|
||||
CAOTAbsAddr *tempa;
|
||||
if (!(tempi->a1.type&MDF_REG) || tempi->a1.reg&7==REG_RSP)
|
||||
CAOTAbsAddr *tmpa;
|
||||
if (!(tmpi->a1.type&MDF_REG) || tmpi->a1.reg&7==REG_RSP)
|
||||
r=REG_RDX;
|
||||
else
|
||||
r=tempi->a1.reg;
|
||||
r=tmpi->a1.reg;
|
||||
if (nobound)
|
||||
ICMov(tempi,MDF_REG+RT_I64,r,0,
|
||||
tempi->a1.type,tempi->a1.reg,tempi->a1.disp,ip2);
|
||||
ICMov(tmpi,MDF_REG+RT_I64,r,0,
|
||||
tmpi->a1.type,tmpi->a1.reg,tmpi->a1.disp,ip2);
|
||||
else {
|
||||
if (tempi->a2.type&MDF_IMM) {
|
||||
j=tempi->a2.disp;
|
||||
ICMov(tempi,MDF_REG+RT_I64,r,0,
|
||||
tempi->a1.type,tempi->a1.reg,tempi->a1.disp,ip2);
|
||||
if (tmpi->a2.type&MDF_IMM) {
|
||||
j=tmpi->a2.disp;
|
||||
ICMov(tmpi,MDF_REG+RT_I64,r,0,
|
||||
tmpi->a1.type,tmpi->a1.reg,tmpi->a1.disp,ip2);
|
||||
if (MIN_I8<=j<=MAX_I8) {
|
||||
i=0xF88348+(r&7)<<16;
|
||||
if (r>7) i++;
|
||||
ICU24(tempi,i);
|
||||
ICU8(tempi,j);
|
||||
ICU24(tmpi,i);
|
||||
ICU8(tmpi,j);
|
||||
} else if (MIN_I32<=j<=MAX_I32) {
|
||||
i=0xF88148+(r&7)<<16;
|
||||
if (r>7) i++;
|
||||
ICU24(tempi,i);
|
||||
ICU32(tempi,j);
|
||||
ICU24(tmpi,i);
|
||||
ICU32(tmpi,j);
|
||||
} else {
|
||||
ICMov(tempi,MDF_REG+RT_I64,REG_RCX,0,
|
||||
tempi->a2.type,tempi->a2.reg,tempi->a2.disp,ip2);
|
||||
ICMov(tmpi,MDF_REG+RT_I64,REG_RCX,0,
|
||||
tmpi->a2.type,tmpi->a2.reg,tmpi->a2.disp,ip2);
|
||||
i=0xC13B48+(r&7)<<19;
|
||||
if (r>7) i+=4;
|
||||
ICU24(tempi,i);
|
||||
ICU24(tmpi,i);
|
||||
}
|
||||
} else {
|
||||
ICMov(tempi,MDF_REG+RT_I64,REG_RCX,0,
|
||||
tempi->a2.type,tempi->a2.reg,tempi->a2.disp,ip2);
|
||||
ICMov(tempi,MDF_REG+RT_I64,r,0,
|
||||
tempi->a1.type,tempi->a1.reg,tempi->a1.disp,ip2);
|
||||
ICMov(tmpi,MDF_REG+RT_I64,REG_RCX,0,
|
||||
tmpi->a2.type,tmpi->a2.reg,tmpi->a2.disp,ip2);
|
||||
ICMov(tmpi,MDF_REG+RT_I64,r,0,
|
||||
tmpi->a1.type,tmpi->a1.reg,tmpi->a1.disp,ip2);
|
||||
i=0xC13B48+(r&7)<<19;
|
||||
if (r>7) i+=4;
|
||||
ICU24(tempi,i);
|
||||
ICU24(tmpi,i);
|
||||
}
|
||||
|
||||
ip+=tempi->ic_cnt;
|
||||
lb=tempi->ic_data(CCodeMisc *)->dft;
|
||||
short_jmp=ToBool(tempi->ic_flags&ICF_SHORT_JMP);
|
||||
ip+=tmpi->ic_cnt;
|
||||
lb=tmpi->ic_data(CCodeMisc *)->dft;
|
||||
short_jmp=ToBool(tmpi->ic_flags&ICF_SHORT_JMP);
|
||||
if (!buf && lb->addr!=INVALID_PTR) {
|
||||
i=lb->addr-(ip+2);
|
||||
if (MIN_I8<=i<=MAX_I8)
|
||||
short_jmp=TRUE;
|
||||
}
|
||||
if (short_jmp) {
|
||||
tempi->ic_flags|=ICF_SHORT_JMP;
|
||||
ICU16(tempi,(lb->addr-(ip+2))<<8+0x73);
|
||||
tmpi->ic_flags|=ICF_SHORT_JMP;
|
||||
ICU16(tmpi,(lb->addr-(ip+2))<<8+0x73);
|
||||
} else {
|
||||
tempi->ic_flags&=~ICF_SHORT_JMP;
|
||||
ICU16(tempi,0x830F);
|
||||
ICU32(tempi,lb->addr-(ip+6));
|
||||
tmpi->ic_flags&=~ICF_SHORT_JMP;
|
||||
ICU16(tmpi,0x830F);
|
||||
ICU32(tmpi,lb->addr-(ip+6));
|
||||
}
|
||||
}
|
||||
|
||||
lb=tempi->ic_data;
|
||||
lb=tmpi->ic_data;
|
||||
begin=lb->begin->addr;
|
||||
if (!buf && begin!=INVALID_PTR) {
|
||||
min=MAX_I64;
|
||||
@@ -688,81 +688,81 @@ U0 ICSwitch(CIntermediateCode *tempi,I64 ip,
|
||||
|
||||
if (lb->flags&CMF_I8_JMP_TABLE) {
|
||||
if (r<8)
|
||||
ICU8(tempi,0x48);
|
||||
ICU8(tmpi,0x48);
|
||||
else
|
||||
ICU8(tempi,0x49);
|
||||
ICU24(tempi,0x98BE0F+(r&7)<<16);
|
||||
ICU8(tmpi,0x49);
|
||||
ICU24(tmpi,0x98BE0F+(r&7)<<16);
|
||||
cnt=1;
|
||||
} else if (lb->flags&CMF_U8_JMP_TABLE) {
|
||||
if (r<8)
|
||||
cnt=2;
|
||||
else {
|
||||
ICU8(tempi,0x49);
|
||||
ICU8(tmpi,0x49);
|
||||
cnt=1;
|
||||
}
|
||||
ICU24(tempi,0x98B60F+(r&7)<<16);
|
||||
ICU24(tmpi,0x98B60F+(r&7)<<16);
|
||||
} else if (lb->flags&CMF_I16_JMP_TABLE) {
|
||||
if (r<8)
|
||||
ICU8(tempi,0x48);
|
||||
ICU8(tmpi,0x48);
|
||||
else
|
||||
ICU8(tempi,0x4A);
|
||||
ICU32(tempi,0x451CBF0F+(r&7)<<27);
|
||||
ICU8(tmpi,0x4A);
|
||||
ICU32(tmpi,0x451CBF0F+(r&7)<<27);
|
||||
cnt=0;
|
||||
} else if (lb->flags&CMF_U16_JMP_TABLE) {
|
||||
if (r<8)
|
||||
cnt=1;
|
||||
else {
|
||||
ICU8(tempi,0x4A);
|
||||
ICU8(tmpi,0x4A);
|
||||
cnt=0;
|
||||
}
|
||||
ICU32(tempi,0x451CB70F+(r&7)<<27);
|
||||
ICU32(tmpi,0x451CB70F+(r&7)<<27);
|
||||
} else {
|
||||
if (r<8)
|
||||
cnt=2;
|
||||
else {
|
||||
ICU8(tempi,0x42);
|
||||
ICU8(tmpi,0x42);
|
||||
cnt=1;
|
||||
}
|
||||
ICU24(tempi,0x851C8B+(r&7)<<19);
|
||||
ICU24(tmpi,0x851C8B+(r&7)<<19);
|
||||
}
|
||||
if (buf && cc->flags&CCF_AOT_COMPILE) {
|
||||
tempa=CAlloc(sizeof(CAOTAbsAddr));
|
||||
tempa->next=cc->aotc->abss;
|
||||
tempa->type=AAT_ADD_U32;
|
||||
cc->aotc->abss=tempa;
|
||||
tempa->ip=ip2+tempi->ic_cnt;
|
||||
ICU32(tempi,lb->addr+cc->aotc->ip);
|
||||
tmpa=CAlloc(sizeof(CAOTAbsAddr));
|
||||
tmpa->next=cc->aotc->abss;
|
||||
tmpa->type=AAT_ADD_U32;
|
||||
cc->aotc->abss=tmpa;
|
||||
tmpa->ip=ip2+tmpi->ic_cnt;
|
||||
ICU32(tmpi,lb->addr+cc->aotc->ip);
|
||||
} else
|
||||
ICU32(tempi,lb->addr+buf);
|
||||
ICU32(tmpi,lb->addr+buf);
|
||||
|
||||
if (lb->flags&(CMF_I8_JMP_TABLE|CMF_U8_JMP_TABLE|
|
||||
CMF_I16_JMP_TABLE|CMF_U16_JMP_TABLE)) {
|
||||
ICU16(tempi,0xC381); //ADD EBX,0x12345678
|
||||
ICU16(tmpi,0xC381); //ADD EBX,0x12345678
|
||||
if (buf && cc->flags&CCF_AOT_COMPILE) {
|
||||
tempa=CAlloc(sizeof(CAOTAbsAddr));
|
||||
tempa->next=cc->aotc->abss;
|
||||
tempa->type=AAT_ADD_U32;
|
||||
cc->aotc->abss=tempa;
|
||||
tempa->ip=ip2+tempi->ic_cnt;
|
||||
ICU32(tempi,begin+cc->aotc->ip);
|
||||
tmpa=CAlloc(sizeof(CAOTAbsAddr));
|
||||
tmpa->next=cc->aotc->abss;
|
||||
tmpa->type=AAT_ADD_U32;
|
||||
cc->aotc->abss=tmpa;
|
||||
tmpa->ip=ip2+tmpi->ic_cnt;
|
||||
ICU32(tmpi,begin+cc->aotc->ip);
|
||||
} else
|
||||
ICU32(tempi,begin+buf);
|
||||
ICU32(tmpi,begin+buf);
|
||||
} else
|
||||
cnt+=6;
|
||||
ICU16(tempi,0xE3FF); //JMP EBX
|
||||
ICU16(tmpi,0xE3FF); //JMP EBX
|
||||
for (i=0;i<cnt;i++) //Code must always shrink, not expand
|
||||
ICU8(tempi,OC_NOP);
|
||||
tempi->ic_flags&=~ICF_CODE_FINAL;
|
||||
ICU8(tmpi,OC_NOP);
|
||||
tmpi->ic_flags&=~ICF_CODE_FINAL;
|
||||
}
|
||||
|
||||
U0 ICLocalVarInit(CIntermediateCode *tempi)
|
||||
U0 ICLocalVarInit(CIntermediateCode *tmpi)
|
||||
{
|
||||
ICU24(tempi,0xC48B48);
|
||||
ICU16(tempi,0x5748);
|
||||
ICU24(tempi,0xF88B48);
|
||||
ICU24(tempi,0xC1C748);
|
||||
ICU32(tempi,tempi->ic_data);
|
||||
ICU16(tempi,sys_var_init_val<<8+0xB0);
|
||||
ICU16(tempi,0xAAF3);
|
||||
ICU16(tempi,0x5F48);
|
||||
ICU24(tmpi,0xC48B48);
|
||||
ICU16(tmpi,0x5748);
|
||||
ICU24(tmpi,0xF88B48);
|
||||
ICU24(tmpi,0xC1C748);
|
||||
ICU32(tmpi,tmpi->ic_data);
|
||||
ICU16(tmpi,sys_var_init_val<<8+0xB0);
|
||||
ICU16(tmpi,0xAAF3);
|
||||
ICU16(tmpi,0x5F48);
|
||||
}
|
||||
+202
-202
@@ -3,7 +3,7 @@
|
||||
#define CN_MAIN 2
|
||||
#define CN_R 3
|
||||
|
||||
U0 CmpNoteFloatOp(CCmpCtrl *cc,CIntermediateCode *tempi,
|
||||
U0 CmpNoteFloatOp(CCmpCtrl *cc,CIntermediateCode *tmpi,
|
||||
Bool dont_pushable,Bool dont_popable,I64 pos)
|
||||
{
|
||||
Bool link=FALSE;
|
||||
@@ -11,34 +11,34 @@ U0 CmpNoteFloatOp(CCmpCtrl *cc,CIntermediateCode *tempi,
|
||||
cc->last_dont_popable && dont_pushable) {
|
||||
switch [pos] {
|
||||
case CN_A2:
|
||||
if (cc->last_float_op_ic!=tempi && cc->dont_push_float)
|
||||
if (cc->last_float_op_ic!=tmpi && cc->dont_push_float)
|
||||
link=TRUE;
|
||||
break;
|
||||
case CN_A1:
|
||||
if (cc->last_float_op_ic!=tempi && cc->dont_push_float)
|
||||
if (cc->last_float_op_ic!=tmpi && cc->dont_push_float)
|
||||
link=TRUE;
|
||||
break;
|
||||
case CN_MAIN:
|
||||
if (cc->last_float_op_ic!=tempi) {
|
||||
if (cc->last_float_op_ic!=tmpi) {
|
||||
if (cc->dont_push_float) {
|
||||
if (intermediate_code_table[tempi->ic_code].arg_cnt==IS_2_ARG &&
|
||||
if (intermediate_code_table[tmpi->ic_code].arg_cnt==IS_2_ARG &&
|
||||
cc->last_float_op_ic->r.reg!=REG_R8)
|
||||
tempi->ic_flags|=ICF_ALT_TEMPLATE;
|
||||
tmpi->ic_flags|=ICF_ALT_TEMPLATE;
|
||||
else
|
||||
tempi->ic_flags&=~ICF_ALT_TEMPLATE;
|
||||
tmpi->ic_flags&=~ICF_ALT_TEMPLATE;
|
||||
link=TRUE;
|
||||
}
|
||||
} else {
|
||||
if (intermediate_code_table[tempi->ic_code].arg_cnt==IS_2_ARG &&
|
||||
if (intermediate_code_table[tmpi->ic_code].arg_cnt==IS_2_ARG &&
|
||||
cc->last_float_op_pos!=CN_A1)
|
||||
tempi->ic_flags|=ICF_ALT_TEMPLATE;
|
||||
tmpi->ic_flags|=ICF_ALT_TEMPLATE;
|
||||
else
|
||||
tempi->ic_flags&=~ICF_ALT_TEMPLATE;
|
||||
tmpi->ic_flags&=~ICF_ALT_TEMPLATE;
|
||||
link=TRUE;
|
||||
}
|
||||
break;
|
||||
case CN_R:
|
||||
if (cc->last_float_op_ic==tempi && cc->last_float_op_pos==CN_MAIN)
|
||||
if (cc->last_float_op_ic==tmpi && cc->last_float_op_pos==CN_MAIN)
|
||||
link=TRUE;
|
||||
break;
|
||||
}
|
||||
@@ -46,11 +46,11 @@ U0 CmpNoteFloatOp(CCmpCtrl *cc,CIntermediateCode *tempi,
|
||||
if (!Bts(&cc->last_float_op_ic->ic_flags,
|
||||
ICf_DONT_POP_FLOAT0+cc->last_ic_float_op_num))
|
||||
cc->last_float_op_ic->ic_flags&=~ICF_CODE_FINAL;
|
||||
if (!Bts(&tempi->ic_flags,ICf_DONT_PUSH_FLOAT0+cc->cur_ic_float_op_num))
|
||||
tempi->ic_flags&=~ICF_CODE_FINAL;
|
||||
if (!Bts(&tmpi->ic_flags,ICf_DONT_PUSH_FLOAT0+cc->cur_ic_float_op_num))
|
||||
tmpi->ic_flags&=~ICF_CODE_FINAL;
|
||||
}
|
||||
}
|
||||
cc->last_float_op_ic=tempi;
|
||||
cc->last_float_op_ic=tmpi;
|
||||
cc->last_dont_pushable=dont_pushable;
|
||||
cc->last_dont_popable=dont_popable;
|
||||
cc->last_ic_float_op_num=cc->cur_ic_float_op_num++;
|
||||
@@ -59,33 +59,33 @@ U0 CmpNoteFloatOp(CCmpCtrl *cc,CIntermediateCode *tempi,
|
||||
throw('Compiler');
|
||||
}
|
||||
|
||||
U0 CmpSetFloatOpPushPop(CCmpCtrl *cc,CIntermediateCode *tempi,
|
||||
U0 CmpSetFloatOpPushPop(CCmpCtrl *cc,CIntermediateCode *tmpi,
|
||||
Bool *dont_push_float,Bool *dont_pop_float)
|
||||
{
|
||||
if (cc->pass==7) {
|
||||
*dont_push_float=FALSE;
|
||||
*dont_pop_float =FALSE;
|
||||
tempi->ic_flags&=~ICF_CODE_FINAL;
|
||||
tmpi->ic_flags&=~ICF_CODE_FINAL;
|
||||
} else {
|
||||
*dont_push_float=Bt(&tempi->ic_flags,
|
||||
*dont_push_float=Bt(&tmpi->ic_flags,
|
||||
ICf_DONT_PUSH_FLOAT0+cc->cur_ic_float_op_num);
|
||||
*dont_pop_float=Bt(&tempi->ic_flags,
|
||||
*dont_pop_float=Bt(&tmpi->ic_flags,
|
||||
ICf_DONT_POP_FLOAT0+cc->cur_ic_float_op_num);
|
||||
}
|
||||
}
|
||||
|
||||
U0 ICCopyTemplate(CCmpCtrl *cc,CIntermediateCode *tempi,I64 op,
|
||||
U0 ICCopyTemplate(CCmpCtrl *cc,CIntermediateCode *tmpi,I64 op,
|
||||
Bool off_the_record,Bool dont_pushable,Bool dont_popable,I64 pos)
|
||||
{
|
||||
Bool dont_push_float,dont_pop_float,alt;
|
||||
U8 *ptr;
|
||||
I64 i=0;
|
||||
if (!off_the_record) {
|
||||
if (tempi->ic_flags&ICF_ALT_TEMPLATE)
|
||||
if (tmpi->ic_flags&ICF_ALT_TEMPLATE)
|
||||
alt=TRUE;
|
||||
else
|
||||
alt=FALSE;
|
||||
CmpSetFloatOpPushPop(cc,tempi,&dont_push_float,&dont_pop_float);
|
||||
CmpSetFloatOpPushPop(cc,tmpi,&dont_push_float,&dont_pop_float);
|
||||
} else {
|
||||
dont_push_float=FALSE;
|
||||
dont_pop_float=FALSE;
|
||||
@@ -114,13 +114,13 @@ U0 ICCopyTemplate(CCmpCtrl *cc,CIntermediateCode *tempi,I64 op,
|
||||
}
|
||||
}
|
||||
}
|
||||
MemCpy(&tempi->ic_body[tempi->ic_cnt],ptr,i);
|
||||
MemCpy(&tmpi->ic_body[tmpi->ic_cnt],ptr,i);
|
||||
if (!off_the_record)
|
||||
CmpNoteFloatOp(cc,tempi,dont_pushable,dont_popable,pos);
|
||||
tempi->ic_cnt+=i;
|
||||
CmpNoteFloatOp(cc,tmpi,dont_pushable,dont_popable,pos);
|
||||
tmpi->ic_cnt+=i;
|
||||
}
|
||||
|
||||
U0 ICFCvt(CCmpCtrl *cc,CIntermediateCode *tempi,I64 r1,
|
||||
U0 ICFCvt(CCmpCtrl *cc,CIntermediateCode *tmpi,I64 r1,
|
||||
CICType t2,I64 r2,I64 d2,Bool to_int,I64 pos,I64 ip)
|
||||
{
|
||||
I64 rsp_size=0,op1,op2;
|
||||
@@ -134,39 +134,39 @@ U0 ICFCvt(CCmpCtrl *cc,CIntermediateCode *tempi,I64 r1,
|
||||
op2=SLASH_OP_FSTP;
|
||||
}
|
||||
|
||||
CmpSetFloatOpPushPop(cc,tempi,&dont_push_float,&dont_pop_float);
|
||||
CmpSetFloatOpPushPop(cc,tmpi,&dont_push_float,&dont_pop_float);
|
||||
if (!dont_push_float) {
|
||||
if (!(t2.raw_type>=RT_I64 && t2&MDG_DISP_SIB_RIP)) {
|
||||
ICPush(tempi,t2,r2,d2,ip);
|
||||
ICPush(tmpi,t2,r2,d2,ip);
|
||||
t2=MDF_SIB+RT_I64; r2=REG_RSP+REG_RSP<<8; d2=0;
|
||||
rsp_size=8;
|
||||
} else {
|
||||
if (!dont_pop_float) {
|
||||
rsp_size=8;
|
||||
ICAddRSP(tempi,-8);
|
||||
ICAddRSP(tmpi,-8);
|
||||
}
|
||||
}
|
||||
ICSlashOp(tempi,t2,r2,d2,op1,ip);
|
||||
ICSlashOp(tmpi,t2,r2,d2,op1,ip);
|
||||
} else {
|
||||
if (!dont_pop_float) {
|
||||
rsp_size=8;
|
||||
ICAddRSP(tempi,-8);
|
||||
ICAddRSP(tmpi,-8);
|
||||
}
|
||||
}
|
||||
if (to_int)
|
||||
CmpNoteFloatOp(cc,tempi,TRUE,FALSE,pos);
|
||||
CmpNoteFloatOp(cc,tmpi,TRUE,FALSE,pos);
|
||||
else
|
||||
CmpNoteFloatOp(cc,tempi,FALSE,TRUE,pos);
|
||||
CmpNoteFloatOp(cc,tmpi,FALSE,TRUE,pos);
|
||||
if (dont_pop_float) {
|
||||
if (rsp_size)
|
||||
ICAddRSP(tempi,rsp_size);
|
||||
ICAddRSP(tmpi,rsp_size);
|
||||
} else {
|
||||
ICSlashOp(tempi,MDF_SIB+RT_I64,REG_RSP+REG_RSP<<8,0,op2,ip);
|
||||
ICPop(tempi,MDF_REG+RT_I64,r1,0,ip);
|
||||
ICSlashOp(tmpi,MDF_SIB+RT_I64,REG_RSP+REG_RSP<<8,0,op2,ip);
|
||||
ICPop(tmpi,MDF_REG+RT_I64,r1,0,ip);
|
||||
}
|
||||
}
|
||||
|
||||
U0 ICFCvt2(CCmpCtrl *cc,CIntermediateCode *tempi,I64 r1,
|
||||
U0 ICFCvt2(CCmpCtrl *cc,CIntermediateCode *tmpi,I64 r1,
|
||||
CICType t2,I64 r2,I64 d2,Bool to_int,I64 ip)
|
||||
{
|
||||
I64 rsp_size=0,op1,op2;
|
||||
@@ -178,29 +178,29 @@ U0 ICFCvt2(CCmpCtrl *cc,CIntermediateCode *tempi,I64 r1,
|
||||
op2=SLASH_OP_FSTP;
|
||||
}
|
||||
if (!(t2.raw_type>=RT_I64 && t2&MDG_DISP_SIB_RIP)) {
|
||||
ICPush(tempi,t2,r2,d2,ip);
|
||||
ICPush(tmpi,t2,r2,d2,ip);
|
||||
t2=MDF_SIB+RT_I64; r2=REG_RSP+REG_RSP<<8; d2=0;
|
||||
rsp_size=8;
|
||||
} else {
|
||||
rsp_size=8;
|
||||
ICAddRSP(tempi,-8);
|
||||
ICAddRSP(tmpi,-8);
|
||||
}
|
||||
ICSlashOp(tempi,t2,r2,d2,op1,ip);
|
||||
ICSlashOp(tempi,MDF_SIB+RT_I64,REG_RSP+REG_RSP<<8,0,op2,ip);
|
||||
ICPop(tempi,MDF_REG+RT_I64,r1,0,ip);
|
||||
ICSlashOp(tmpi,t2,r2,d2,op1,ip);
|
||||
ICSlashOp(tmpi,MDF_SIB+RT_I64,REG_RSP+REG_RSP<<8,0,op2,ip);
|
||||
ICPop(tmpi,MDF_REG+RT_I64,r1,0,ip);
|
||||
cc->last_dont_pushable=cc->last_dont_popable=FALSE; //TODO: improve this
|
||||
}
|
||||
|
||||
U0 ICFUnaryMinus(CCmpCtrl *cc,CIntermediateCode *tempi,U8 *buf2,I64 ip)
|
||||
U0 ICFUnaryMinus(CCmpCtrl *cc,CIntermediateCode *tmpi,U8 *buf2,I64 ip)
|
||||
{
|
||||
CICArg *a1=&tempi->a1;
|
||||
CICArg *a1=&tmpi->a1;
|
||||
I64 rsp_size=0,builtin1=0,t1,r1,d1;
|
||||
Bool dont_push_float,dont_pop_float;
|
||||
|
||||
if (cc->flags&CCF_AOT_COMPILE)
|
||||
buf2=cc->aotc->ip;
|
||||
|
||||
CmpSetFloatOpPushPop(cc,tempi,&dont_push_float,&dont_pop_float);
|
||||
CmpSetFloatOpPushPop(cc,tmpi,&dont_push_float,&dont_pop_float);
|
||||
if (!dont_push_float) {
|
||||
if (a1->type.raw_type>=RT_I64 && a1->type&MDG_DISP_SIB_RIP) {
|
||||
t1=a1->type;
|
||||
@@ -214,148 +214,148 @@ U0 ICFUnaryMinus(CCmpCtrl *cc,CIntermediateCode *tempi,U8 *buf2,I64 ip)
|
||||
d1=COCFloatConstFind(cc,a1->disp(F64))+buf2;
|
||||
}
|
||||
} else {
|
||||
ICPush(tempi,a1->type,a1->reg,a1->disp,ip);
|
||||
ICPush(tmpi,a1->type,a1->reg,a1->disp,ip);
|
||||
t1=MDF_SIB+RT_I64; r1=REG_RSP+REG_RSP<<8; d1=0;
|
||||
rsp_size+=8;
|
||||
}
|
||||
}
|
||||
if (builtin1)
|
||||
ICU16(tempi,builtin1);
|
||||
ICU16(tmpi,builtin1);
|
||||
else
|
||||
ICSlashOp(tempi,t1,r1,d1,SLASH_OP_FLD,ip);
|
||||
ICSlashOp(tmpi,t1,r1,d1,SLASH_OP_FLD,ip);
|
||||
}
|
||||
if (!dont_pop_float && !rsp_size) {
|
||||
rsp_size=8;
|
||||
ICAddRSP(tempi,-8);
|
||||
ICAddRSP(tmpi,-8);
|
||||
}
|
||||
ICU16(tempi,0xE0D9); //FCHS
|
||||
CmpNoteFloatOp(cc,tempi,TRUE,TRUE,CN_MAIN);
|
||||
ICU16(tmpi,0xE0D9); //FCHS
|
||||
CmpNoteFloatOp(cc,tmpi,TRUE,TRUE,CN_MAIN);
|
||||
if (dont_pop_float) {
|
||||
if (rsp_size)
|
||||
ICAddRSP(tempi,rsp_size);
|
||||
ICAddRSP(tmpi,rsp_size);
|
||||
} else {
|
||||
ICSlashOp(tempi,MDF_SIB+RT_I64,REG_RSP+REG_RSP<<8,0,SLASH_OP_FSTP,ip);
|
||||
ICPop(tempi,tempi->r.type,tempi->r.reg,tempi->r.disp,ip);
|
||||
ICSlashOp(tmpi,MDF_SIB+RT_I64,REG_RSP+REG_RSP<<8,0,SLASH_OP_FSTP,ip);
|
||||
ICPop(tmpi,tmpi->r.type,tmpi->r.reg,tmpi->r.disp,ip);
|
||||
}
|
||||
}
|
||||
|
||||
U0 ICFMod(CCmpCtrl *cc,CIntermediateCode *tempi,I64 ip)
|
||||
U0 ICFMod(CCmpCtrl *cc,CIntermediateCode *tmpi,I64 ip)
|
||||
{//for MOD
|
||||
Bool dont_push_float,dont_pop_float;
|
||||
CmpSetFloatOpPushPop(cc,tempi,&dont_push_float,&dont_pop_float);
|
||||
CmpSetFloatOpPushPop(cc,tmpi,&dont_push_float,&dont_pop_float);
|
||||
if (dont_push_float) {
|
||||
if (tempi->ic_flags&ICF_ALT_TEMPLATE)
|
||||
ICMov(tempi,MDF_REG+RT_I64,REG_RAX,0,
|
||||
tempi->a1.type,tempi->a1.reg,tempi->a1.disp,ip);
|
||||
if (tmpi->ic_flags&ICF_ALT_TEMPLATE)
|
||||
ICMov(tmpi,MDF_REG+RT_I64,REG_RAX,0,
|
||||
tmpi->a1.type,tmpi->a1.reg,tmpi->a1.disp,ip);
|
||||
else
|
||||
ICMov(tempi,MDF_REG+RT_I64,REG_RAX,0,
|
||||
tempi->a2.type,tempi->a2.reg,tempi->a2.disp,ip);
|
||||
ICMov(tmpi,MDF_REG+RT_I64,REG_RAX,0,
|
||||
tmpi->a2.type,tmpi->a2.reg,tmpi->a2.disp,ip);
|
||||
} else {
|
||||
ICMov(tempi,MDF_REG+RT_I64,REG_RAX,0,
|
||||
tempi->a2.type,tempi->a2.reg,tempi->a2.disp,ip);
|
||||
ICMov(tempi,MDF_REG+RT_I64,REG_RDX,0,
|
||||
tempi->a1.type,tempi->a1.reg,tempi->a1.disp,ip);
|
||||
ICMov(tmpi,MDF_REG+RT_I64,REG_RAX,0,
|
||||
tmpi->a2.type,tmpi->a2.reg,tmpi->a2.disp,ip);
|
||||
ICMov(tmpi,MDF_REG+RT_I64,REG_RDX,0,
|
||||
tmpi->a1.type,tmpi->a1.reg,tmpi->a1.disp,ip);
|
||||
}
|
||||
//TODO: unpushable,unpop? Not sure
|
||||
ICCopyTemplate(cc,tempi,CMP_TEMPLATE_MOD,FALSE,FALSE,FALSE,CN_MAIN);
|
||||
ICCopyTemplate(cc,tmpi,CMP_TEMPLATE_MOD,FALSE,FALSE,FALSE,CN_MAIN);
|
||||
if (!dont_pop_float)
|
||||
ICMov(tempi,tempi->r.type,tempi->r.reg,tempi->r.disp,
|
||||
ICMov(tmpi,tmpi->r.type,tmpi->r.reg,tmpi->r.disp,
|
||||
MDF_REG+RT_I64,REG_RAX,0,ip);
|
||||
}
|
||||
|
||||
U0 ICFPow(CCmpCtrl *cc,CIntermediateCode *tempi,U8 *buf,I64 ip)
|
||||
U0 ICFPow(CCmpCtrl *cc,CIntermediateCode *tmpi,U8 *buf,I64 ip)
|
||||
{//for POW
|
||||
I64 i;
|
||||
CAOTImportExport *tempie;
|
||||
CHashExport *tempex=HashFind("SYS_POW",
|
||||
CAOTImportExport *tmpie;
|
||||
CHashExport *tmpex=HashFind("SYS_POW",
|
||||
cc->htc.hash_table_lst,HTT_EXPORT_SYS_SYM);
|
||||
|
||||
ICMov(tempi,MDF_REG+RT_I64,REG_RAX,0,
|
||||
tempi->a2.type,tempi->a2.reg,tempi->a2.disp,ip);
|
||||
ICMov(tempi,MDF_REG+RT_I64,REG_RDX,0,
|
||||
tempi->a1.type,tempi->a1.reg,tempi->a1.disp,ip);
|
||||
ICMov(tmpi,MDF_REG+RT_I64,REG_RAX,0,
|
||||
tmpi->a2.type,tmpi->a2.reg,tmpi->a2.disp,ip);
|
||||
ICMov(tmpi,MDF_REG+RT_I64,REG_RDX,0,
|
||||
tmpi->a1.type,tmpi->a1.reg,tmpi->a1.disp,ip);
|
||||
if (cc->flags&CCF_AOT_COMPILE) {
|
||||
if (!tempex) {
|
||||
tempex=CAlloc(sizeof(CHashExport));
|
||||
tempex->str=StrNew("SYS_POW");
|
||||
tempex->type=HTT_EXPORT_SYS_SYM|HTF_UNRESOLVED|HTF_IMPORT;
|
||||
HashAdd(tempex,cc->htc.glbl_hash_table);
|
||||
if (!tmpex) {
|
||||
tmpex=CAlloc(sizeof(CHashExport));
|
||||
tmpex->str=StrNew("SYS_POW");
|
||||
tmpex->type=HTT_EXPORT_SYS_SYM|HTF_UNRESOLVED|HTF_IMPORT;
|
||||
HashAdd(tmpex,cc->htc.glbl_hash_table);
|
||||
}
|
||||
if (tempex->type&HTF_IMPORT) {
|
||||
if (tmpex->type&HTF_IMPORT) {
|
||||
if (GetOption(OPTf_USE_IMM64)) {
|
||||
ICU16(tempi,0xBB48);
|
||||
ICU64(tempi,0);
|
||||
ICU16(tmpi,0xBB48);
|
||||
ICU64(tmpi,0);
|
||||
if (buf) {
|
||||
tempie=CAlloc(sizeof(CAOTImportExport));
|
||||
tempie->type=IET_IMM_I64;
|
||||
tempie->ip=ip+tempi->ic_cnt-8;
|
||||
tempie->next=tempex->ie_lst;
|
||||
tempex->ie_lst=tempie;
|
||||
tmpie=CAlloc(sizeof(CAOTImportExport));
|
||||
tmpie->type=IET_IMM_I64;
|
||||
tmpie->ip=ip+tmpi->ic_cnt-8;
|
||||
tmpie->next=tmpex->ie_lst;
|
||||
tmpex->ie_lst=tmpie;
|
||||
}
|
||||
ICU16(tempi,0xD3FF);
|
||||
ICU16(tmpi,0xD3FF);
|
||||
} else {
|
||||
ICU8(tempi,0xE8);
|
||||
ICU32(tempi,-(ip+tempi->ic_cnt+4));
|
||||
ICU8(tmpi,0xE8);
|
||||
ICU32(tmpi,-(ip+tmpi->ic_cnt+4));
|
||||
if (buf) {
|
||||
tempie=CAlloc(sizeof(CAOTImportExport));
|
||||
tempie->type=IET_REL_I32;
|
||||
tempie->ip=ip+tempi->ic_cnt-4;
|
||||
tempie->next=tempex->ie_lst;
|
||||
tempex->ie_lst=tempie;
|
||||
tmpie=CAlloc(sizeof(CAOTImportExport));
|
||||
tmpie->type=IET_REL_I32;
|
||||
tmpie->ip=ip+tmpi->ic_cnt-4;
|
||||
tmpie->next=tmpex->ie_lst;
|
||||
tmpex->ie_lst=tmpie;
|
||||
}
|
||||
}
|
||||
} else {//Kernel
|
||||
if (tempex->type&HTF_UNRESOLVED)
|
||||
if (tmpex->type&HTF_UNRESOLVED)
|
||||
throw('Compiler');
|
||||
else {
|
||||
i=tempex->val-(ip+tempi->ic_cnt+5);
|
||||
i=tmpex->val-(ip+tmpi->ic_cnt+5);
|
||||
if (!(MIN_I32<=i<=MAX_I32)) {
|
||||
throw('Compiler');
|
||||
// ICU16(tempi,0xBB48);
|
||||
// ICU64(tempi,tempex->val);
|
||||
// ICU16(tempi,0xD3FF);
|
||||
// ICU16(tmpi,0xBB48);
|
||||
// ICU64(tmpi,tmpex->val);
|
||||
// ICU16(tmpi,0xD3FF);
|
||||
} else {
|
||||
ICU8(tempi,0xE8);
|
||||
ICU32(tempi,i);
|
||||
ICU8(tmpi,0xE8);
|
||||
ICU32(tmpi,i);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
i=tempex->val-(ip+tempi->ic_cnt+5);
|
||||
i=tmpex->val-(ip+tmpi->ic_cnt+5);
|
||||
if (!(MIN_I32<=i<=MAX_I32)) {
|
||||
ICU16(tempi,0xBB48);
|
||||
ICU64(tempi,tempex->val);
|
||||
ICU16(tempi,0xD3FF);
|
||||
ICU16(tmpi,0xBB48);
|
||||
ICU64(tmpi,tmpex->val);
|
||||
ICU16(tmpi,0xD3FF);
|
||||
} else {
|
||||
ICU8(tempi,0xE8);
|
||||
ICU32(tempi,i);
|
||||
ICU8(tmpi,0xE8);
|
||||
ICU32(tmpi,i);
|
||||
}
|
||||
}
|
||||
tempi->ic_flags&=~ICF_CODE_FINAL;
|
||||
ICMov(tempi,tempi->r.type,tempi->r.reg,tempi->r.disp,
|
||||
tmpi->ic_flags&=~ICF_CODE_FINAL;
|
||||
ICMov(tmpi,tmpi->r.type,tmpi->r.reg,tmpi->r.disp,
|
||||
MDF_REG+RT_I64,REG_RAX,0,ip);
|
||||
}
|
||||
|
||||
U0 ICFOp(CCmpCtrl *cc,CIntermediateCode *tempi,I64 op,U8 *buf2,I64 ip)
|
||||
U0 ICFOp(CCmpCtrl *cc,CIntermediateCode *tmpi,I64 op,U8 *buf2,I64 ip)
|
||||
{//for ADD,SUB,DIV,MUL
|
||||
CICArg *a1,*a2;
|
||||
Bool dont_push_float,dont_pop_float,alt;
|
||||
I64 rsp_size=0,builtin1=0,builtin2=0,t1,r1,d1,t2,r2,d2;
|
||||
|
||||
if (tempi->ic_flags&ICF_ALT_TEMPLATE) {
|
||||
a1=&tempi->a2;
|
||||
a2=&tempi->a1;
|
||||
if (tmpi->ic_flags&ICF_ALT_TEMPLATE) {
|
||||
a1=&tmpi->a2;
|
||||
a2=&tmpi->a1;
|
||||
alt=TRUE;
|
||||
} else {
|
||||
a1=&tempi->a1;
|
||||
a2=&tempi->a2;
|
||||
a1=&tmpi->a1;
|
||||
a2=&tmpi->a2;
|
||||
alt=FALSE;
|
||||
}
|
||||
|
||||
if (cc->flags&CCF_AOT_COMPILE)
|
||||
buf2=cc->aotc->ip;
|
||||
|
||||
CmpSetFloatOpPushPop(cc,tempi,&dont_push_float,&dont_pop_float);
|
||||
CmpSetFloatOpPushPop(cc,tmpi,&dont_push_float,&dont_pop_float);
|
||||
if (dont_push_float) {
|
||||
if (a2->type.raw_type>=RT_I64 && a2->type&MDG_DISP_SIB_RIP) {
|
||||
t2=a2->type;
|
||||
@@ -369,7 +369,7 @@ U0 ICFOp(CCmpCtrl *cc,CIntermediateCode *tempi,I64 op,U8 *buf2,I64 ip)
|
||||
d2=COCFloatConstFind(cc,a2->disp(F64))+buf2;
|
||||
}
|
||||
} else {
|
||||
ICPush(tempi,a2->type,a2->reg,a2->disp,ip);
|
||||
ICPush(tmpi,a2->type,a2->reg,a2->disp,ip);
|
||||
t2=MDF_SIB+RT_I64; r2=REG_RSP+REG_RSP<<8; d2=0;
|
||||
rsp_size+=8;
|
||||
}
|
||||
@@ -389,7 +389,7 @@ U0 ICFOp(CCmpCtrl *cc,CIntermediateCode *tempi,I64 op,U8 *buf2,I64 ip)
|
||||
d1=COCFloatConstFind(cc,a1->disp(F64))+buf2;
|
||||
}
|
||||
} else {
|
||||
ICPush(tempi,a1->type,a1->reg,a1->disp,ip);
|
||||
ICPush(tmpi,a1->type,a1->reg,a1->disp,ip);
|
||||
t1=MDF_SIB+RT_I64; r1=REG_RSP+REG_RSP<<8; d1=0;
|
||||
rsp_size+=8;
|
||||
}
|
||||
@@ -406,7 +406,7 @@ U0 ICFOp(CCmpCtrl *cc,CIntermediateCode *tempi,I64 op,U8 *buf2,I64 ip)
|
||||
d2=COCFloatConstFind(cc,a2->disp(F64))+buf2;
|
||||
}
|
||||
} else {
|
||||
ICPush(tempi,a2->type,a2->reg,a2->disp,ip);
|
||||
ICPush(tmpi,a2->type,a2->reg,a2->disp,ip);
|
||||
t2=MDF_SIB+RT_I64; r2=REG_RSP+REG_RSP<<8; d2=0;
|
||||
rsp_size+=8;
|
||||
if (r1==REG_RSP+REG_RSP<<8)
|
||||
@@ -414,9 +414,9 @@ U0 ICFOp(CCmpCtrl *cc,CIntermediateCode *tempi,I64 op,U8 *buf2,I64 ip)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
ICMov(tempi,MDF_REG+RT_I64,REG_RDX,0,a1->type,a1->reg,a1->disp,ip);
|
||||
ICMov(tempi,MDF_REG+RT_I64,REG_RAX,0,a2->type,a2->reg,a2->disp,ip);
|
||||
ICU16(tempi,0x5052); //PUSH EDX PUSH EAX
|
||||
ICMov(tmpi,MDF_REG+RT_I64,REG_RDX,0,a1->type,a1->reg,a1->disp,ip);
|
||||
ICMov(tmpi,MDF_REG+RT_I64,REG_RAX,0,a2->type,a2->reg,a2->disp,ip);
|
||||
ICU16(tmpi,0x5052); //PUSH EDX PUSH EAX
|
||||
rsp_size=16;
|
||||
t1=MDF_SIB+RT_I64; r1=REG_RSP+REG_RSP<<8; d1=8;
|
||||
t2=MDF_SIB+RT_I64; r2=REG_RSP+REG_RSP<<8; d2=0;
|
||||
@@ -435,7 +435,7 @@ U0 ICFOp(CCmpCtrl *cc,CIntermediateCode *tempi,I64 op,U8 *buf2,I64 ip)
|
||||
d2=COCFloatConstFind(cc,a2->disp(F64))+buf2;
|
||||
}
|
||||
} else {
|
||||
ICPush(tempi,a2->type,a2->reg,a2->disp,ip);
|
||||
ICPush(tmpi,a2->type,a2->reg,a2->disp,ip);
|
||||
t2=MDF_SIB+RT_I64; r2=REG_RSP+REG_RSP<<8; d2=0;
|
||||
rsp_size+=8;
|
||||
}
|
||||
@@ -452,7 +452,7 @@ U0 ICFOp(CCmpCtrl *cc,CIntermediateCode *tempi,I64 op,U8 *buf2,I64 ip)
|
||||
d1=COCFloatConstFind(cc,a1->disp(F64))+buf2;
|
||||
}
|
||||
} else {
|
||||
ICPush(tempi,a1->type,a1->reg,a1->disp,ip);
|
||||
ICPush(tmpi,a1->type,a1->reg,a1->disp,ip);
|
||||
t1=MDF_SIB+RT_I64; r1=REG_RSP+REG_RSP<<8; d1=0;
|
||||
rsp_size+=8;
|
||||
if (r2==REG_RSP+REG_RSP<<8)
|
||||
@@ -460,9 +460,9 @@ U0 ICFOp(CCmpCtrl *cc,CIntermediateCode *tempi,I64 op,U8 *buf2,I64 ip)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
ICMov(tempi,MDF_REG+RT_I64,REG_RAX,0,a2->type,a2->reg,a2->disp,ip);
|
||||
ICMov(tempi,MDF_REG+RT_I64,REG_RDX,0,a1->type,a1->reg,a1->disp,ip);
|
||||
ICU16(tempi,0x5052); //PUSH EDX PUSH EAX
|
||||
ICMov(tmpi,MDF_REG+RT_I64,REG_RAX,0,a2->type,a2->reg,a2->disp,ip);
|
||||
ICMov(tmpi,MDF_REG+RT_I64,REG_RDX,0,a1->type,a1->reg,a1->disp,ip);
|
||||
ICU16(tmpi,0x5052); //PUSH EDX PUSH EAX
|
||||
rsp_size=16;
|
||||
t1=MDF_SIB+RT_I64; r1=REG_RSP+REG_RSP<<8; d1=8;
|
||||
t2=MDF_SIB+RT_I64; r2=REG_RSP+REG_RSP<<8; d2=0;
|
||||
@@ -471,7 +471,7 @@ U0 ICFOp(CCmpCtrl *cc,CIntermediateCode *tempi,I64 op,U8 *buf2,I64 ip)
|
||||
}
|
||||
if (!dont_pop_float && !rsp_size) {
|
||||
rsp_size=8;
|
||||
ICAddRSP(tempi,-8);
|
||||
ICAddRSP(tmpi,-8);
|
||||
}
|
||||
if (!dont_push_float) {
|
||||
if (builtin2 && !builtin1) {
|
||||
@@ -482,9 +482,9 @@ U0 ICFOp(CCmpCtrl *cc,CIntermediateCode *tempi,I64 op,U8 *buf2,I64 ip)
|
||||
SwapI64(&builtin1,&builtin2);
|
||||
}
|
||||
if (builtin1)
|
||||
ICU16(tempi,builtin1);
|
||||
ICU16(tmpi,builtin1);
|
||||
else
|
||||
ICSlashOp(tempi,t1,r1,d1,SLASH_OP_FLD,ip);
|
||||
ICSlashOp(tmpi,t1,r1,d1,SLASH_OP_FLD,ip);
|
||||
}
|
||||
if (alt)
|
||||
switch (op.u8[0]) {
|
||||
@@ -492,112 +492,112 @@ U0 ICFOp(CCmpCtrl *cc,CIntermediateCode *tempi,I64 op,U8 *buf2,I64 ip)
|
||||
case 6: op=SLASH_OP_FDIVR; break;
|
||||
}
|
||||
if (builtin2) {
|
||||
ICU16(tempi,builtin2);
|
||||
ICU16(tempi,op.u16[2]);
|
||||
ICU16(tmpi,builtin2);
|
||||
ICU16(tmpi,op.u16[2]);
|
||||
} else
|
||||
ICSlashOp(tempi,t2,r2,d2,op,ip);
|
||||
CmpNoteFloatOp(cc,tempi,TRUE,TRUE,CN_MAIN);
|
||||
ICSlashOp(tmpi,t2,r2,d2,op,ip);
|
||||
CmpNoteFloatOp(cc,tmpi,TRUE,TRUE,CN_MAIN);
|
||||
if (dont_pop_float) {
|
||||
if (rsp_size)
|
||||
ICAddRSP(tempi,rsp_size);
|
||||
ICAddRSP(tmpi,rsp_size);
|
||||
} else {
|
||||
if (rsp_size==8)
|
||||
ICSlashOp(tempi,MDF_SIB+RT_I64,REG_RSP+REG_RSP<<8,0,SLASH_OP_FSTP,ip);
|
||||
ICSlashOp(tmpi,MDF_SIB+RT_I64,REG_RSP+REG_RSP<<8,0,SLASH_OP_FSTP,ip);
|
||||
else if (rsp_size>8) {
|
||||
ICSlashOp(tempi,MDF_SIB+RT_I64,REG_RSP+REG_RSP<<8,rsp_size-8,
|
||||
ICSlashOp(tmpi,MDF_SIB+RT_I64,REG_RSP+REG_RSP<<8,rsp_size-8,
|
||||
SLASH_OP_FSTP,ip);
|
||||
ICAddRSP(tempi,rsp_size-8);
|
||||
ICAddRSP(tmpi,rsp_size-8);
|
||||
}
|
||||
ICPop(tempi,tempi->r.type,tempi->r.reg,tempi->r.disp,ip);
|
||||
ICPop(tmpi,tmpi->r.type,tmpi->r.reg,tmpi->r.disp,ip);
|
||||
}
|
||||
}
|
||||
|
||||
U0 ICFCmp(CCmpCtrl *cc,CIntermediateCode *tempi,I64 op,I64 ip)
|
||||
U0 ICFCmp(CCmpCtrl *cc,CIntermediateCode *tmpi,I64 op,I64 ip)
|
||||
{
|
||||
Bool dont_push_float,dont_pop_float;
|
||||
CmpSetFloatOpPushPop(cc,tempi,&dont_push_float,&dont_pop_float);
|
||||
CmpSetFloatOpPushPop(cc,tmpi,&dont_push_float,&dont_pop_float);
|
||||
if (dont_push_float) {
|
||||
if (tempi->ic_flags&ICF_ALT_TEMPLATE) {
|
||||
if (tempi->ic_flags&ICF_POP_CMP)
|
||||
ICPopRegs(tempi,1<<REG_RAX);
|
||||
if (tmpi->ic_flags&ICF_ALT_TEMPLATE) {
|
||||
if (tmpi->ic_flags&ICF_POP_CMP)
|
||||
ICPopRegs(tmpi,1<<REG_RAX);
|
||||
else
|
||||
ICMov(tempi,MDF_REG+RT_I64,REG_RAX,0,
|
||||
tempi->a1.type,tempi->a1.reg,tempi->a1.disp,ip);
|
||||
ICMov(tmpi,MDF_REG+RT_I64,REG_RAX,0,
|
||||
tmpi->a1.type,tmpi->a1.reg,tmpi->a1.disp,ip);
|
||||
} else
|
||||
ICMov(tempi,MDF_REG+RT_I64,REG_RAX,0,
|
||||
tempi->a2.type,tempi->a2.reg,tempi->a2.disp,ip);
|
||||
ICMov(tmpi,MDF_REG+RT_I64,REG_RAX,0,
|
||||
tmpi->a2.type,tmpi->a2.reg,tmpi->a2.disp,ip);
|
||||
} else {
|
||||
ICMov(tempi,MDF_REG+RT_I64,REG_RAX,0,
|
||||
tempi->a2.type,tempi->a2.reg,tempi->a2.disp,ip);
|
||||
if (tempi->ic_flags&ICF_POP_CMP)
|
||||
ICPopRegs(tempi,1<<REG_RDX);
|
||||
ICMov(tmpi,MDF_REG+RT_I64,REG_RAX,0,
|
||||
tmpi->a2.type,tmpi->a2.reg,tmpi->a2.disp,ip);
|
||||
if (tmpi->ic_flags&ICF_POP_CMP)
|
||||
ICPopRegs(tmpi,1<<REG_RDX);
|
||||
else
|
||||
ICMov(tempi,MDF_REG+RT_I64,REG_RDX,0,
|
||||
tempi->a1.type,tempi->a1.reg,tempi->a1.disp,ip);
|
||||
ICMov(tmpi,MDF_REG+RT_I64,REG_RDX,0,
|
||||
tmpi->a1.type,tmpi->a1.reg,tmpi->a1.disp,ip);
|
||||
}
|
||||
if (tempi->ic_flags&ICF_PUSH_CMP)
|
||||
ICPushRegs(tempi,1<<REG_RAX);
|
||||
ICCopyTemplate(cc,tempi,op,FALSE,TRUE,FALSE,CN_MAIN);
|
||||
ICMov(tempi,tempi->r.type,tempi->r.reg,tempi->r.disp,
|
||||
if (tmpi->ic_flags&ICF_PUSH_CMP)
|
||||
ICPushRegs(tmpi,1<<REG_RAX);
|
||||
ICCopyTemplate(cc,tmpi,op,FALSE,TRUE,FALSE,CN_MAIN);
|
||||
ICMov(tmpi,tmpi->r.type,tmpi->r.reg,tmpi->r.disp,
|
||||
MDF_REG+RT_I64,REG_RAX,0,ip);
|
||||
}
|
||||
|
||||
U0 ICFModEqu(CCmpCtrl *cc,CIntermediateCode *tempi,I64 ip)
|
||||
U0 ICFModEqu(CCmpCtrl *cc,CIntermediateCode *tmpi,I64 ip)
|
||||
{
|
||||
Bool dont_push_float,dont_pop_float;
|
||||
CmpSetFloatOpPushPop(cc,tempi,&dont_push_float,&dont_pop_float);
|
||||
if (tempi->ic_flags & ICF_BY_VAL) {
|
||||
CmpSetFloatOpPushPop(cc,tmpi,&dont_push_float,&dont_pop_float);
|
||||
if (tmpi->ic_flags & ICF_BY_VAL) {
|
||||
if (dont_push_float) {
|
||||
ICMov(tempi,MDF_REG+RT_I64,REG_RAX,0,
|
||||
tempi->a1.type&MDG_MASK+tempi->a1_type_pointed_to,
|
||||
tempi->a1.reg,tempi->a1.disp,ip);
|
||||
if (tempi->a1_type_pointed_to!=RT_F64)
|
||||
ICFCvt2(cc,tempi,REG_RAX,MDF_REG+RT_I64,REG_RAX,0,FALSE,ip);
|
||||
ICMov(tmpi,MDF_REG+RT_I64,REG_RAX,0,
|
||||
tmpi->a1.type&MDG_MASK+tmpi->a1_type_pointed_to,
|
||||
tmpi->a1.reg,tmpi->a1.disp,ip);
|
||||
if (tmpi->a1_type_pointed_to!=RT_F64)
|
||||
ICFCvt2(cc,tmpi,REG_RAX,MDF_REG+RT_I64,REG_RAX,0,FALSE,ip);
|
||||
} else {
|
||||
ICMov(tempi,MDF_REG+RT_I64,REG_RAX,0,
|
||||
tempi->a2.type,tempi->a2.reg,tempi->a2.disp,ip);
|
||||
ICMov(tempi,MDF_REG+RT_I64,REG_RDX,0,
|
||||
tempi->a1.type&MDG_MASK+tempi->a1_type_pointed_to,
|
||||
tempi->a1.reg,tempi->a1.disp,ip);
|
||||
if (tempi->a1_type_pointed_to!=RT_F64)
|
||||
ICFCvt2(cc,tempi,REG_RDX,MDF_REG+RT_I64,REG_RDX,0,FALSE,ip);
|
||||
ICMov(tmpi,MDF_REG+RT_I64,REG_RAX,0,
|
||||
tmpi->a2.type,tmpi->a2.reg,tmpi->a2.disp,ip);
|
||||
ICMov(tmpi,MDF_REG+RT_I64,REG_RDX,0,
|
||||
tmpi->a1.type&MDG_MASK+tmpi->a1_type_pointed_to,
|
||||
tmpi->a1.reg,tmpi->a1.disp,ip);
|
||||
if (tmpi->a1_type_pointed_to!=RT_F64)
|
||||
ICFCvt2(cc,tmpi,REG_RDX,MDF_REG+RT_I64,REG_RDX,0,FALSE,ip);
|
||||
}
|
||||
//TODO: unpushable,unpop? Not sure
|
||||
ICCopyTemplate(cc,tempi,CMP_TEMPLATE_MOD,FALSE,FALSE,FALSE,CN_MAIN);
|
||||
if (tempi->a1_type_pointed_to!=RT_F64)
|
||||
ICFCvt2(cc,tempi,REG_RAX,MDF_REG+RT_I64,REG_RAX,0,TRUE,ip);
|
||||
ICMov(tempi,tempi->a1.type&MDG_MASK+tempi->a1_type_pointed_to,
|
||||
tempi->a1.reg,tempi->a1.disp,MDF_REG+RT_I64,REG_RAX,0,ip);
|
||||
if (tempi->r.type.mode)
|
||||
ICMov(tempi,tempi->r.type,tempi->r.reg,tempi->r.disp,
|
||||
tempi->a1.type&MDG_MASK+tempi->a1_type_pointed_to,
|
||||
tempi->a1.reg,tempi->a1.disp,ip);
|
||||
ICCopyTemplate(cc,tmpi,CMP_TEMPLATE_MOD,FALSE,FALSE,FALSE,CN_MAIN);
|
||||
if (tmpi->a1_type_pointed_to!=RT_F64)
|
||||
ICFCvt2(cc,tmpi,REG_RAX,MDF_REG+RT_I64,REG_RAX,0,TRUE,ip);
|
||||
ICMov(tmpi,tmpi->a1.type&MDG_MASK+tmpi->a1_type_pointed_to,
|
||||
tmpi->a1.reg,tmpi->a1.disp,MDF_REG+RT_I64,REG_RAX,0,ip);
|
||||
if (tmpi->r.type.mode)
|
||||
ICMov(tmpi,tmpi->r.type,tmpi->r.reg,tmpi->r.disp,
|
||||
tmpi->a1.type&MDG_MASK+tmpi->a1_type_pointed_to,
|
||||
tmpi->a1.reg,tmpi->a1.disp,ip);
|
||||
} else {
|
||||
if (dont_push_float) {
|
||||
ICMov(tempi,MDF_REG+RT_I64,REG_RCX,0,tempi->a1.type,
|
||||
tempi->a1.reg,tempi->a1.disp,ip);
|
||||
ICMov(tempi,MDF_REG+RT_I64,REG_RAX,0,
|
||||
MDF_DISP+tempi->a1_type_pointed_to,REG_RCX,0,ip);
|
||||
if (tempi->a1_type_pointed_to!=RT_F64)
|
||||
ICFCvt2(cc,tempi,REG_RAX,MDF_REG+RT_I64,REG_RAX,0,FALSE,ip);
|
||||
ICMov(tmpi,MDF_REG+RT_I64,REG_RCX,0,tmpi->a1.type,
|
||||
tmpi->a1.reg,tmpi->a1.disp,ip);
|
||||
ICMov(tmpi,MDF_REG+RT_I64,REG_RAX,0,
|
||||
MDF_DISP+tmpi->a1_type_pointed_to,REG_RCX,0,ip);
|
||||
if (tmpi->a1_type_pointed_to!=RT_F64)
|
||||
ICFCvt2(cc,tmpi,REG_RAX,MDF_REG+RT_I64,REG_RAX,0,FALSE,ip);
|
||||
} else {
|
||||
ICMov(tempi,MDF_REG+RT_I64,REG_RAX,0,
|
||||
tempi->a2.type,tempi->a2.reg,tempi->a2.disp,ip);
|
||||
ICMov(tempi,MDF_REG+RT_I64,REG_RCX,0,tempi->a1.type,
|
||||
tempi->a1.reg,tempi->a1.disp,ip);
|
||||
ICMov(tempi,MDF_REG+RT_I64,REG_RDX,0,
|
||||
MDF_DISP+tempi->a1_type_pointed_to,REG_RCX,0,ip);
|
||||
if (tempi->a1_type_pointed_to!=RT_F64)
|
||||
ICFCvt2(cc,tempi,REG_RDX,MDF_REG+RT_I64,REG_RDX,0,FALSE,ip);
|
||||
ICMov(tmpi,MDF_REG+RT_I64,REG_RAX,0,
|
||||
tmpi->a2.type,tmpi->a2.reg,tmpi->a2.disp,ip);
|
||||
ICMov(tmpi,MDF_REG+RT_I64,REG_RCX,0,tmpi->a1.type,
|
||||
tmpi->a1.reg,tmpi->a1.disp,ip);
|
||||
ICMov(tmpi,MDF_REG+RT_I64,REG_RDX,0,
|
||||
MDF_DISP+tmpi->a1_type_pointed_to,REG_RCX,0,ip);
|
||||
if (tmpi->a1_type_pointed_to!=RT_F64)
|
||||
ICFCvt2(cc,tmpi,REG_RDX,MDF_REG+RT_I64,REG_RDX,0,FALSE,ip);
|
||||
}
|
||||
//TODO: unpushable,unpop? Not sure
|
||||
ICCopyTemplate(cc,tempi,CMP_TEMPLATE_MOD,FALSE,FALSE,FALSE,CN_MAIN);
|
||||
if (tempi->a1_type_pointed_to!=RT_F64)
|
||||
ICFCvt2(cc,tempi,REG_RAX,MDF_REG+RT_I64,REG_RAX,0,TRUE,ip);
|
||||
ICMov(tempi,MDF_DISP+tempi->a1_type_pointed_to,REG_RCX,0,
|
||||
ICCopyTemplate(cc,tmpi,CMP_TEMPLATE_MOD,FALSE,FALSE,FALSE,CN_MAIN);
|
||||
if (tmpi->a1_type_pointed_to!=RT_F64)
|
||||
ICFCvt2(cc,tmpi,REG_RAX,MDF_REG+RT_I64,REG_RAX,0,TRUE,ip);
|
||||
ICMov(tmpi,MDF_DISP+tmpi->a1_type_pointed_to,REG_RCX,0,
|
||||
MDF_REG+RT_I64,REG_RAX,0,ip);
|
||||
if (tempi->r.type.mode)
|
||||
ICMov(tempi,tempi->r.type,tempi->r.reg,tempi->r.disp,
|
||||
if (tmpi->r.type.mode)
|
||||
ICMov(tmpi,tmpi->r.type,tmpi->r.reg,tmpi->r.disp,
|
||||
MDF_REG+RT_I64,REG_RAX,0,ip);
|
||||
}
|
||||
}
|
||||
+229
-229
@@ -1,7 +1,7 @@
|
||||
U0 ICFOpEqu(CCmpCtrl *cc,CIntermediateCode *tempi,I64 op,U8 *buf2,I64 ip)
|
||||
U0 ICFOpEqu(CCmpCtrl *cc,CIntermediateCode *tmpi,I64 op,U8 *buf2,I64 ip)
|
||||
{//for ADD,SUB,DIV,MUL
|
||||
CICArg *a1=&tempi->a1,
|
||||
*a2=&tempi->a2;
|
||||
CICArg *a1=&tmpi->a1,
|
||||
*a2=&tmpi->a2;
|
||||
Bool dont_push_float,dont_pop_float,p1_mem;
|
||||
I64 rsp_size=0,builtin2=0,
|
||||
t1,r1,d1,t2,r2,d2;
|
||||
@@ -9,41 +9,41 @@ U0 ICFOpEqu(CCmpCtrl *cc,CIntermediateCode *tempi,I64 op,U8 *buf2,I64 ip)
|
||||
if (cc->flags&CCF_AOT_COMPILE)
|
||||
buf2=cc->aotc->ip;
|
||||
|
||||
CmpSetFloatOpPushPop(cc,tempi,&dont_push_float,&dont_pop_float);
|
||||
CmpSetFloatOpPushPop(cc,tmpi,&dont_push_float,&dont_pop_float);
|
||||
if (dont_pop_float)
|
||||
throw('Compiler');
|
||||
|
||||
if (tempi->ic_flags & ICF_BY_VAL) {
|
||||
if (tmpi->ic_flags & ICF_BY_VAL) {
|
||||
p1_mem=FALSE;
|
||||
if (dont_push_float) {
|
||||
if (tempi->a1_type_pointed_to!=RT_F64) {
|
||||
ICMov(tempi,MDF_REG+RT_I64,REG_RAX,0,
|
||||
a1->type&MDG_MASK+tempi->a1_type_pointed_to,a1->reg,a1->disp,ip);
|
||||
ICFCvt2(cc,tempi,REG_RAX,MDF_REG+RT_I64,REG_RAX,0,FALSE,ip);
|
||||
ICPush(tempi,MDF_REG+RT_I64,REG_RAX,0,ip);
|
||||
if (tmpi->a1_type_pointed_to!=RT_F64) {
|
||||
ICMov(tmpi,MDF_REG+RT_I64,REG_RAX,0,
|
||||
a1->type&MDG_MASK+tmpi->a1_type_pointed_to,a1->reg,a1->disp,ip);
|
||||
ICFCvt2(cc,tmpi,REG_RAX,MDF_REG+RT_I64,REG_RAX,0,FALSE,ip);
|
||||
ICPush(tmpi,MDF_REG+RT_I64,REG_RAX,0,ip);
|
||||
t1=MDF_SIB+RT_I64; r1=REG_RSP+REG_RSP<<8; d1=0;
|
||||
rsp_size+=8;
|
||||
} else {
|
||||
if (tempi->a1_type_pointed_to>=RT_I64 && a1->type&MDG_DISP_SIB_RIP) {
|
||||
t1=a1->type&MDG_MASK+tempi->a1_type_pointed_to;
|
||||
if (tmpi->a1_type_pointed_to>=RT_I64 && a1->type&MDG_DISP_SIB_RIP) {
|
||||
t1=a1->type&MDG_MASK+tmpi->a1_type_pointed_to;
|
||||
r1=a1->reg;
|
||||
d1=a1->disp;
|
||||
p1_mem=TRUE;
|
||||
} else {
|
||||
ICPush(tempi,a1->type&MDG_MASK+tempi->a1_type_pointed_to,
|
||||
ICPush(tmpi,a1->type&MDG_MASK+tmpi->a1_type_pointed_to,
|
||||
a1->reg,a1->disp,ip);
|
||||
t1=MDF_SIB+RT_I64; r1=REG_RSP+REG_RSP<<8; d1=0;
|
||||
rsp_size+=8;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (tempi->a1_type_pointed_to!=RT_F64 || a1->type&MDF_STK) {
|
||||
ICMov(tempi,MDF_REG+RT_I64,REG_RAX,0,a2->type,a2->reg,a2->disp,ip);
|
||||
ICMov(tempi,MDF_REG+RT_I64,REG_RDX,0,
|
||||
a1->type&MDG_MASK+tempi->a1_type_pointed_to,a1->reg,a1->disp,ip);
|
||||
if (tempi->a1_type_pointed_to!=RT_F64)
|
||||
ICFCvt2(cc,tempi,REG_RDX,MDF_REG+RT_I64,REG_RDX,0,FALSE,ip);
|
||||
ICU16(tempi,0x5052); //PUSH EDX PUSH EAX
|
||||
if (tmpi->a1_type_pointed_to!=RT_F64 || a1->type&MDF_STK) {
|
||||
ICMov(tmpi,MDF_REG+RT_I64,REG_RAX,0,a2->type,a2->reg,a2->disp,ip);
|
||||
ICMov(tmpi,MDF_REG+RT_I64,REG_RDX,0,
|
||||
a1->type&MDG_MASK+tmpi->a1_type_pointed_to,a1->reg,a1->disp,ip);
|
||||
if (tmpi->a1_type_pointed_to!=RT_F64)
|
||||
ICFCvt2(cc,tmpi,REG_RDX,MDF_REG+RT_I64,REG_RDX,0,FALSE,ip);
|
||||
ICU16(tmpi,0x5052); //PUSH EDX PUSH EAX
|
||||
rsp_size=16;
|
||||
t1=MDF_SIB+RT_I64; r1=REG_RSP+REG_RSP<<8; d1=8;
|
||||
t2=MDF_SIB+RT_I64; r2=REG_RSP+REG_RSP<<8; d2=0;
|
||||
@@ -60,18 +60,18 @@ U0 ICFOpEqu(CCmpCtrl *cc,CIntermediateCode *tempi,I64 op,U8 *buf2,I64 ip)
|
||||
d2=COCFloatConstFind(cc,a2->disp(F64))+buf2;
|
||||
}
|
||||
} else {
|
||||
ICPush(tempi,a2->type,a2->reg,a2->disp,ip);
|
||||
ICPush(tmpi,a2->type,a2->reg,a2->disp,ip);
|
||||
t2=MDF_SIB+RT_I64; r2=REG_RSP+REG_RSP<<8; d2=0;
|
||||
rsp_size+=8;
|
||||
}
|
||||
}
|
||||
if (tempi->a1_type_pointed_to>=RT_I64 && a1->type&MDG_DISP_SIB_RIP) {
|
||||
t1=a1->type&MDG_MASK+tempi->a1_type_pointed_to;
|
||||
if (tmpi->a1_type_pointed_to>=RT_I64 && a1->type&MDG_DISP_SIB_RIP) {
|
||||
t1=a1->type&MDG_MASK+tmpi->a1_type_pointed_to;
|
||||
r1=a1->reg;
|
||||
d1=a1->disp;
|
||||
p1_mem=TRUE;
|
||||
} else {
|
||||
ICPush(tempi,a1->type&MDG_MASK+tempi->a1_type_pointed_to,
|
||||
ICPush(tmpi,a1->type&MDG_MASK+tmpi->a1_type_pointed_to,
|
||||
a1->reg,a1->disp,ip);
|
||||
t1=MDF_SIB+RT_I64; r1=REG_RSP+REG_RSP<<8; d1=0;
|
||||
rsp_size+=8;
|
||||
@@ -80,71 +80,71 @@ U0 ICFOpEqu(CCmpCtrl *cc,CIntermediateCode *tempi,I64 op,U8 *buf2,I64 ip)
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!rsp_size && !(p1_mem && tempi->a1_type_pointed_to==RT_F64)) {
|
||||
if (!rsp_size && !(p1_mem && tmpi->a1_type_pointed_to==RT_F64)) {
|
||||
rsp_size=8;
|
||||
ICAddRSP(tempi,-8);
|
||||
ICAddRSP(tmpi,-8);
|
||||
}
|
||||
if (!dont_push_float) {
|
||||
if (builtin2)
|
||||
ICU16(tempi,builtin2);
|
||||
ICU16(tmpi,builtin2);
|
||||
else
|
||||
ICSlashOp(tempi,t2,r2,d2,SLASH_OP_FLD,ip);
|
||||
ICSlashOp(tmpi,t2,r2,d2,SLASH_OP_FLD,ip);
|
||||
}
|
||||
switch (op.u8[0]) {
|
||||
case 4: op=SLASH_OP_FSUBR; break;
|
||||
case 6: op=SLASH_OP_FDIVR; break;
|
||||
}
|
||||
ICSlashOp(tempi,t1,r1,d1,op,ip);
|
||||
CmpNoteFloatOp(cc,tempi,TRUE,FALSE,CN_MAIN);
|
||||
if (p1_mem && tempi->a1_type_pointed_to==RT_F64) {
|
||||
ICSlashOp(tempi,t1,r1,d1,SLASH_OP_FSTP,ip);
|
||||
ICSlashOp(tmpi,t1,r1,d1,op,ip);
|
||||
CmpNoteFloatOp(cc,tmpi,TRUE,FALSE,CN_MAIN);
|
||||
if (p1_mem && tmpi->a1_type_pointed_to==RT_F64) {
|
||||
ICSlashOp(tmpi,t1,r1,d1,SLASH_OP_FSTP,ip);
|
||||
if (rsp_size)
|
||||
ICAddRSP(tempi,rsp_size);
|
||||
ICAddRSP(tmpi,rsp_size);
|
||||
} else {
|
||||
if (rsp_size==8)
|
||||
ICSlashOp(tempi,MDF_SIB+RT_I64,REG_RSP+REG_RSP<<8,0,SLASH_OP_FSTP,ip);
|
||||
ICSlashOp(tmpi,MDF_SIB+RT_I64,REG_RSP+REG_RSP<<8,0,SLASH_OP_FSTP,ip);
|
||||
else if (rsp_size>8) {
|
||||
ICSlashOp(tempi,MDF_SIB+RT_I64,REG_RSP+REG_RSP<<8,rsp_size-8,
|
||||
ICSlashOp(tmpi,MDF_SIB+RT_I64,REG_RSP+REG_RSP<<8,rsp_size-8,
|
||||
SLASH_OP_FSTP,ip);
|
||||
ICAddRSP(tempi,rsp_size-8);
|
||||
ICAddRSP(tmpi,rsp_size-8);
|
||||
}
|
||||
if (tempi->a1_type_pointed_to!=RT_F64) {
|
||||
ICPop(tempi,MDF_REG+RT_I64,REG_RAX,0,ip);
|
||||
ICFCvt2(cc,tempi,REG_RAX,MDF_REG+RT_I64,REG_RAX,0,TRUE,ip);
|
||||
ICMov(tempi,a1->type&MDG_MASK+tempi->a1_type_pointed_to,a1->reg,
|
||||
if (tmpi->a1_type_pointed_to!=RT_F64) {
|
||||
ICPop(tmpi,MDF_REG+RT_I64,REG_RAX,0,ip);
|
||||
ICFCvt2(cc,tmpi,REG_RAX,MDF_REG+RT_I64,REG_RAX,0,TRUE,ip);
|
||||
ICMov(tmpi,a1->type&MDG_MASK+tmpi->a1_type_pointed_to,a1->reg,
|
||||
a1->disp,MDF_REG+RT_I64,REG_RAX,0,ip);
|
||||
} else
|
||||
ICPop(tempi,a1->type&MDG_MASK+tempi->a1_type_pointed_to,
|
||||
ICPop(tmpi,a1->type&MDG_MASK+tmpi->a1_type_pointed_to,
|
||||
a1->reg,a1->disp,ip);
|
||||
}
|
||||
if (tempi->r.type.mode)
|
||||
ICMov(tempi,tempi->r.type,tempi->r.reg,tempi->r.disp,
|
||||
a1->type&MDG_MASK+tempi->a1_type_pointed_to,a1->reg,a1->disp,ip);
|
||||
if (tmpi->r.type.mode)
|
||||
ICMov(tmpi,tmpi->r.type,tmpi->r.reg,tmpi->r.disp,
|
||||
a1->type&MDG_MASK+tmpi->a1_type_pointed_to,a1->reg,a1->disp,ip);
|
||||
} else {
|
||||
if (tempi->a1_type_pointed_to>=RT_I64)
|
||||
if (tmpi->a1_type_pointed_to>=RT_I64)
|
||||
p1_mem=TRUE;
|
||||
else
|
||||
p1_mem=FALSE;
|
||||
if (dont_push_float) {
|
||||
ICMov(tempi,MDF_REG+RT_I64,REG_RCX,0,a1->type,a1->reg,a1->disp,ip);
|
||||
if (tempi->a1_type_pointed_to!=RT_F64) {
|
||||
ICMov(tempi,MDF_REG+RT_I64,REG_RAX,0,
|
||||
MDF_DISP+tempi->a1_type_pointed_to,REG_RCX,0,ip);
|
||||
ICFCvt2(cc,tempi,REG_RAX,MDF_REG+RT_I64,REG_RAX,0,FALSE,ip);
|
||||
ICPush(tempi,MDF_REG+RT_I64,REG_RAX,0,ip);
|
||||
ICMov(tmpi,MDF_REG+RT_I64,REG_RCX,0,a1->type,a1->reg,a1->disp,ip);
|
||||
if (tmpi->a1_type_pointed_to!=RT_F64) {
|
||||
ICMov(tmpi,MDF_REG+RT_I64,REG_RAX,0,
|
||||
MDF_DISP+tmpi->a1_type_pointed_to,REG_RCX,0,ip);
|
||||
ICFCvt2(cc,tmpi,REG_RAX,MDF_REG+RT_I64,REG_RAX,0,FALSE,ip);
|
||||
ICPush(tmpi,MDF_REG+RT_I64,REG_RAX,0,ip);
|
||||
} else
|
||||
ICPush(tempi,MDF_DISP+tempi->a1_type_pointed_to,REG_RCX,0,ip);
|
||||
ICPush(tmpi,MDF_DISP+tmpi->a1_type_pointed_to,REG_RCX,0,ip);
|
||||
t1=MDF_SIB+RT_I64; r1=REG_RSP+REG_RSP<<8; d1=0;
|
||||
rsp_size+=8;
|
||||
} else {
|
||||
if (tempi->a1_type_pointed_to!=RT_F64 || a1->type&MDF_STK) {
|
||||
ICMov(tempi,MDF_REG+RT_I64,REG_RAX,0,a2->type,a2->reg,a2->disp,ip);
|
||||
ICMov(tempi,MDF_REG+RT_I64,REG_RCX,0,a1->type,a1->reg,a1->disp,ip);
|
||||
ICMov(tempi,MDF_REG+RT_I64,REG_RDX,0,
|
||||
MDF_DISP+tempi->a1_type_pointed_to,REG_RCX,0,ip);
|
||||
if (tempi->a1_type_pointed_to!=RT_F64)
|
||||
ICFCvt2(cc,tempi,REG_RDX,MDF_REG+RT_I64,REG_RDX,0,FALSE,ip);
|
||||
ICU16(tempi,0x5052); //PUSH EDX PUSH EAX
|
||||
if (tmpi->a1_type_pointed_to!=RT_F64 || a1->type&MDF_STK) {
|
||||
ICMov(tmpi,MDF_REG+RT_I64,REG_RAX,0,a2->type,a2->reg,a2->disp,ip);
|
||||
ICMov(tmpi,MDF_REG+RT_I64,REG_RCX,0,a1->type,a1->reg,a1->disp,ip);
|
||||
ICMov(tmpi,MDF_REG+RT_I64,REG_RDX,0,
|
||||
MDF_DISP+tmpi->a1_type_pointed_to,REG_RCX,0,ip);
|
||||
if (tmpi->a1_type_pointed_to!=RT_F64)
|
||||
ICFCvt2(cc,tmpi,REG_RDX,MDF_REG+RT_I64,REG_RDX,0,FALSE,ip);
|
||||
ICU16(tmpi,0x5052); //PUSH EDX PUSH EAX
|
||||
rsp_size=16;
|
||||
t1=MDF_SIB+RT_I64; r1=REG_RSP+REG_RSP<<8; d1=8;
|
||||
t2=MDF_SIB+RT_I64; r2=REG_RSP+REG_RSP<<8; d2=0;
|
||||
@@ -161,62 +161,62 @@ U0 ICFOpEqu(CCmpCtrl *cc,CIntermediateCode *tempi,I64 op,U8 *buf2,I64 ip)
|
||||
d2=COCFloatConstFind(cc,a2->disp(F64))+buf2;
|
||||
}
|
||||
} else {
|
||||
ICPush(tempi,a2->type,a2->reg,a2->disp,ip);
|
||||
ICPush(tmpi,a2->type,a2->reg,a2->disp,ip);
|
||||
t2=MDF_SIB+RT_I64; r2=REG_RSP+REG_RSP<<8; d2=0;
|
||||
rsp_size+=8;
|
||||
}
|
||||
}
|
||||
ICMov(tempi,MDF_REG+RT_I64,REG_RCX,0,a1->type,a1->reg,a1->disp,ip);
|
||||
ICPush(tempi,MDF_DISP+tempi->a1_type_pointed_to,REG_RCX,0,ip);
|
||||
ICMov(tmpi,MDF_REG+RT_I64,REG_RCX,0,a1->type,a1->reg,a1->disp,ip);
|
||||
ICPush(tmpi,MDF_DISP+tmpi->a1_type_pointed_to,REG_RCX,0,ip);
|
||||
t1=MDF_SIB+RT_I64; r1=REG_RSP+REG_RSP<<8; d1=0;
|
||||
rsp_size+=8;
|
||||
if (r2==REG_RSP+REG_RSP<<8)
|
||||
d2+=8;
|
||||
}
|
||||
}
|
||||
if (!rsp_size && !(p1_mem && tempi->a1_type_pointed_to==RT_F64)) {
|
||||
if (!rsp_size && !(p1_mem && tmpi->a1_type_pointed_to==RT_F64)) {
|
||||
rsp_size=8;
|
||||
ICAddRSP(tempi,-8);
|
||||
ICAddRSP(tmpi,-8);
|
||||
}
|
||||
if (!dont_push_float) {
|
||||
if (builtin2)
|
||||
ICU16(tempi,builtin2);
|
||||
ICU16(tmpi,builtin2);
|
||||
else
|
||||
ICSlashOp(tempi,t2,r2,d2,SLASH_OP_FLD,ip);
|
||||
ICSlashOp(tmpi,t2,r2,d2,SLASH_OP_FLD,ip);
|
||||
}
|
||||
|
||||
switch (op.u8[0]) {
|
||||
case 4: op=SLASH_OP_FSUBR; break;
|
||||
case 6: op=SLASH_OP_FDIVR; break;
|
||||
}
|
||||
ICSlashOp(tempi,t1,r1,d1,op,ip);
|
||||
CmpNoteFloatOp(cc,tempi,TRUE,FALSE,CN_MAIN);
|
||||
if (p1_mem && tempi->a1_type_pointed_to==RT_F64) {
|
||||
ICSlashOp(tempi,MDF_DISP+tempi->a1_type_pointed_to,
|
||||
ICSlashOp(tmpi,t1,r1,d1,op,ip);
|
||||
CmpNoteFloatOp(cc,tmpi,TRUE,FALSE,CN_MAIN);
|
||||
if (p1_mem && tmpi->a1_type_pointed_to==RT_F64) {
|
||||
ICSlashOp(tmpi,MDF_DISP+tmpi->a1_type_pointed_to,
|
||||
REG_RCX,0,SLASH_OP_FSTP,ip);
|
||||
if (rsp_size)
|
||||
ICAddRSP(tempi,rsp_size);
|
||||
ICAddRSP(tmpi,rsp_size);
|
||||
} else {
|
||||
if (rsp_size==8)
|
||||
ICSlashOp(tempi,MDF_SIB+RT_I64,REG_RSP+REG_RSP<<8,0,SLASH_OP_FSTP,ip);
|
||||
ICSlashOp(tmpi,MDF_SIB+RT_I64,REG_RSP+REG_RSP<<8,0,SLASH_OP_FSTP,ip);
|
||||
else if (rsp_size>8) {
|
||||
ICSlashOp(tempi,MDF_SIB+RT_I64,REG_RSP+REG_RSP<<8,rsp_size-8,
|
||||
ICSlashOp(tmpi,MDF_SIB+RT_I64,REG_RSP+REG_RSP<<8,rsp_size-8,
|
||||
SLASH_OP_FSTP,ip);
|
||||
ICAddRSP(tempi,rsp_size-8);
|
||||
ICAddRSP(tmpi,rsp_size-8);
|
||||
}
|
||||
ICPop(tempi,MDF_REG+RT_I64,REG_RAX,0,ip);
|
||||
if (tempi->a1_type_pointed_to!=RT_F64)
|
||||
ICFCvt2(cc,tempi,REG_RAX,MDF_REG+RT_I64,REG_RAX,0,TRUE,ip);
|
||||
ICMov(tempi,MDF_DISP+tempi->a1_type_pointed_to,REG_RCX,0,
|
||||
ICPop(tmpi,MDF_REG+RT_I64,REG_RAX,0,ip);
|
||||
if (tmpi->a1_type_pointed_to!=RT_F64)
|
||||
ICFCvt2(cc,tmpi,REG_RAX,MDF_REG+RT_I64,REG_RAX,0,TRUE,ip);
|
||||
ICMov(tmpi,MDF_DISP+tmpi->a1_type_pointed_to,REG_RCX,0,
|
||||
MDF_REG+RT_I64,REG_RAX,0,ip);
|
||||
}
|
||||
if (tempi->r.type.mode)
|
||||
ICMov(tempi,tempi->r.type,tempi->r.reg,tempi->r.disp,
|
||||
if (tmpi->r.type.mode)
|
||||
ICMov(tmpi,tmpi->r.type,tmpi->r.reg,tmpi->r.disp,
|
||||
MDF_REG+RT_I64,REG_RAX,0,ip);
|
||||
}
|
||||
}
|
||||
|
||||
U0 ICFCmpAndBranch(CCmpCtrl *cc,CIntermediateCode *tempi,I64 ip,
|
||||
U0 ICFCmpAndBranch(CCmpCtrl *cc,CIntermediateCode *tmpi,I64 ip,
|
||||
I64 us,I64 not_us,U8 *buf,I64 ip2)
|
||||
{
|
||||
CICArg *a1,*a2;
|
||||
@@ -225,13 +225,13 @@ U0 ICFCmpAndBranch(CCmpCtrl *cc,CIntermediateCode *tempi,I64 ip,
|
||||
CCodeMisc *lb;
|
||||
U8 *buf2;
|
||||
|
||||
if (tempi->ic_flags&ICF_ALT_TEMPLATE) {
|
||||
a1=&tempi->a2;
|
||||
a2=&tempi->a1;
|
||||
if (tmpi->ic_flags&ICF_ALT_TEMPLATE) {
|
||||
a1=&tmpi->a2;
|
||||
a2=&tmpi->a1;
|
||||
alt=TRUE;
|
||||
} else {
|
||||
a1=&tempi->a1;
|
||||
a2=&tempi->a2;
|
||||
a1=&tmpi->a1;
|
||||
a2=&tmpi->a2;
|
||||
alt=FALSE;
|
||||
}
|
||||
|
||||
@@ -240,9 +240,9 @@ U0 ICFCmpAndBranch(CCmpCtrl *cc,CIntermediateCode *tempi,I64 ip,
|
||||
else
|
||||
buf2=buf;
|
||||
|
||||
CmpSetFloatOpPushPop(cc,tempi,&dont_push_float,&dont_pop_float);
|
||||
CmpSetFloatOpPushPop(cc,tmpi,&dont_push_float,&dont_pop_float);
|
||||
if (dont_push_float) {
|
||||
if (tempi->ic_flags&ICF_POP_CMP && alt) {
|
||||
if (tmpi->ic_flags&ICF_POP_CMP && alt) {
|
||||
t2=MDF_SIB+RT_I64; r2=REG_RSP+REG_RSP<<8; d2=0;
|
||||
rsp_size+=8;
|
||||
} else {
|
||||
@@ -253,13 +253,13 @@ U0 ICFCmpAndBranch(CCmpCtrl *cc,CIntermediateCode *tempi,I64 ip,
|
||||
} else {
|
||||
if (a2->type&MDF_IMM) {
|
||||
if (!(builtin2=ICBuiltInFloatConst(a2->disp(F64))) ||
|
||||
tempi->ic_flags&ICF_PUSH_CMP) {
|
||||
tmpi->ic_flags&ICF_PUSH_CMP) {
|
||||
t2=MDF_RIP_DISP32+RT_I64;
|
||||
r2=REG_RIP;
|
||||
d2=COCFloatConstFind(cc,a2->disp(F64))+buf2;
|
||||
}
|
||||
} else {
|
||||
ICPush(tempi,a2->type,a2->reg,a2->disp,ip2);
|
||||
ICPush(tmpi,a2->type,a2->reg,a2->disp,ip2);
|
||||
t2=MDF_SIB+RT_I64; r2=REG_RSP+REG_RSP<<8; d2=0;
|
||||
rsp_size+=8;
|
||||
}
|
||||
@@ -268,7 +268,7 @@ U0 ICFCmpAndBranch(CCmpCtrl *cc,CIntermediateCode *tempi,I64 ip,
|
||||
} else {
|
||||
if (alt) {
|
||||
if (!(a2->type&MDF_STK)) {
|
||||
if (tempi->ic_flags&ICF_POP_CMP) {
|
||||
if (tmpi->ic_flags&ICF_POP_CMP) {
|
||||
t1=MDF_SIB+RT_I64; r1=REG_RSP+REG_RSP<<8; d1=0;
|
||||
rsp_size+=8;
|
||||
} else {
|
||||
@@ -284,7 +284,7 @@ U0 ICFCmpAndBranch(CCmpCtrl *cc,CIntermediateCode *tempi,I64 ip,
|
||||
d1=COCFloatConstFind(cc,a1->disp(F64))+buf2;
|
||||
}
|
||||
} else {
|
||||
ICPush(tempi,a1->type,a1->reg,a1->disp,ip2);
|
||||
ICPush(tmpi,a1->type,a1->reg,a1->disp,ip2);
|
||||
t1=MDF_SIB+RT_I64; r1=REG_RSP+REG_RSP<<8; d1=0;
|
||||
rsp_size+=8;
|
||||
}
|
||||
@@ -297,13 +297,13 @@ U0 ICFCmpAndBranch(CCmpCtrl *cc,CIntermediateCode *tempi,I64 ip,
|
||||
} else {
|
||||
if (a2->type&MDF_IMM) {
|
||||
if (!(builtin2=ICBuiltInFloatConst(a2->disp(F64))) ||
|
||||
tempi->ic_flags&ICF_PUSH_CMP) {
|
||||
tmpi->ic_flags&ICF_PUSH_CMP) {
|
||||
t2=MDF_RIP_DISP32+RT_I64;
|
||||
r2=REG_RIP;
|
||||
d2=COCFloatConstFind(cc,a2->disp(F64))+buf2;
|
||||
}
|
||||
} else {
|
||||
ICPush(tempi,a2->type,a2->reg,a2->disp,ip2);
|
||||
ICPush(tmpi,a2->type,a2->reg,a2->disp,ip2);
|
||||
t2=MDF_SIB+RT_I64; r2=REG_RSP+REG_RSP<<8; d2=0;
|
||||
rsp_size+=8;
|
||||
if (r1==REG_RSP+REG_RSP<<8)
|
||||
@@ -311,12 +311,12 @@ U0 ICFCmpAndBranch(CCmpCtrl *cc,CIntermediateCode *tempi,I64 ip,
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (tempi->ic_flags&ICF_POP_CMP)
|
||||
ICPopRegs(tempi,1<<REG_RDX);
|
||||
if (tmpi->ic_flags&ICF_POP_CMP)
|
||||
ICPopRegs(tmpi,1<<REG_RDX);
|
||||
else
|
||||
ICMov(tempi,MDF_REG+RT_I64,REG_RDX,0,a1->type,a1->reg,a1->disp,ip2);
|
||||
ICMov(tempi,MDF_REG+RT_I64,REG_RAX,0,a2->type,a2->reg,a2->disp,ip2);
|
||||
ICU16(tempi,0x5052); //PUSH EDX PUSH EAX
|
||||
ICMov(tmpi,MDF_REG+RT_I64,REG_RDX,0,a1->type,a1->reg,a1->disp,ip2);
|
||||
ICMov(tmpi,MDF_REG+RT_I64,REG_RAX,0,a2->type,a2->reg,a2->disp,ip2);
|
||||
ICU16(tmpi,0x5052); //PUSH EDX PUSH EAX
|
||||
rsp_size=16;
|
||||
t1=MDF_SIB+RT_I64; r1=REG_RSP+REG_RSP<<8; d1=8;
|
||||
t2=MDF_SIB+RT_I64; r2=REG_RSP+REG_RSP<<8; d2=0;
|
||||
@@ -330,18 +330,18 @@ U0 ICFCmpAndBranch(CCmpCtrl *cc,CIntermediateCode *tempi,I64 ip,
|
||||
} else {
|
||||
if (a2->type&MDF_IMM) {
|
||||
if (!(builtin2=ICBuiltInFloatConst(a2->disp(F64))) ||
|
||||
tempi->ic_flags&ICF_PUSH_CMP) {
|
||||
tmpi->ic_flags&ICF_PUSH_CMP) {
|
||||
t2=MDF_RIP_DISP32+RT_I64;
|
||||
r2=REG_RIP;
|
||||
d2=COCFloatConstFind(cc,a2->disp(F64))+buf2;
|
||||
}
|
||||
} else {
|
||||
ICPush(tempi,a2->type,a2->reg,a2->disp,ip2);
|
||||
ICPush(tmpi,a2->type,a2->reg,a2->disp,ip2);
|
||||
t2=MDF_SIB+RT_I64; r2=REG_RSP+REG_RSP<<8; d2=0;
|
||||
rsp_size+=8;
|
||||
}
|
||||
}
|
||||
if (tempi->ic_flags&ICF_POP_CMP) {
|
||||
if (tmpi->ic_flags&ICF_POP_CMP) {
|
||||
t1=MDF_SIB+RT_I64; r1=REG_RSP+REG_RSP<<8; d1=0;
|
||||
rsp_size+=8;
|
||||
if (r2==REG_RSP+REG_RSP<<8)
|
||||
@@ -359,7 +359,7 @@ U0 ICFCmpAndBranch(CCmpCtrl *cc,CIntermediateCode *tempi,I64 ip,
|
||||
d1=COCFloatConstFind(cc,a1->disp(F64))+buf2;
|
||||
}
|
||||
} else {
|
||||
ICPush(tempi,a1->type,a1->reg,a1->disp,ip2);
|
||||
ICPush(tmpi,a1->type,a1->reg,a1->disp,ip2);
|
||||
t1=MDF_SIB+RT_I64; r1=REG_RSP+REG_RSP<<8; d1=0;
|
||||
rsp_size+=8;
|
||||
if (r2==REG_RSP+REG_RSP<<8)
|
||||
@@ -368,12 +368,12 @@ U0 ICFCmpAndBranch(CCmpCtrl *cc,CIntermediateCode *tempi,I64 ip,
|
||||
}
|
||||
}
|
||||
} else {
|
||||
ICMov(tempi,MDF_REG+RT_I64,REG_RAX,0,a2->type,a2->reg,a2->disp,ip2);
|
||||
if (tempi->ic_flags&ICF_POP_CMP)
|
||||
ICPopRegs(tempi,1<<REG_RDX);
|
||||
ICMov(tmpi,MDF_REG+RT_I64,REG_RAX,0,a2->type,a2->reg,a2->disp,ip2);
|
||||
if (tmpi->ic_flags&ICF_POP_CMP)
|
||||
ICPopRegs(tmpi,1<<REG_RDX);
|
||||
else
|
||||
ICMov(tempi,MDF_REG+RT_I64,REG_RDX,0,a1->type,a1->reg,a1->disp,ip2);
|
||||
ICU16(tempi,0x5052); //PUSH EDX PUSH EAX
|
||||
ICMov(tmpi,MDF_REG+RT_I64,REG_RDX,0,a1->type,a1->reg,a1->disp,ip2);
|
||||
ICU16(tmpi,0x5052); //PUSH EDX PUSH EAX
|
||||
rsp_size=16;
|
||||
t1=MDF_SIB+RT_I64; r1=REG_RSP+REG_RSP<<8; d1=8;
|
||||
t2=MDF_SIB+RT_I64; r2=REG_RSP+REG_RSP<<8; d2=0;
|
||||
@@ -382,66 +382,66 @@ U0 ICFCmpAndBranch(CCmpCtrl *cc,CIntermediateCode *tempi,I64 ip,
|
||||
}
|
||||
if (!dont_push_float) {
|
||||
if (builtin1)
|
||||
ICU16(tempi,builtin1);
|
||||
ICU16(tmpi,builtin1);
|
||||
else
|
||||
ICSlashOp(tempi,t1,r1,d1,SLASH_OP_FLD,ip2);
|
||||
ICSlashOp(tmpi,t1,r1,d1,SLASH_OP_FLD,ip2);
|
||||
}
|
||||
if (!alt)
|
||||
us=not_us;
|
||||
if (builtin2)
|
||||
ICU16(tempi,builtin2);
|
||||
ICU16(tmpi,builtin2);
|
||||
else
|
||||
ICSlashOp(tempi,t2,r2,d2,SLASH_OP_FLD,ip2);
|
||||
if (tempi->ic_flags&ICF_PUSH_CMP) {
|
||||
ICSlashOp(tmpi,t2,r2,d2,SLASH_OP_FLD,ip2);
|
||||
if (tmpi->ic_flags&ICF_PUSH_CMP) {
|
||||
t2=MDF_SIB+RT_I64; r2=REG_RSP+REG_RSP<<8; d2=0;
|
||||
if (!rsp_size) {
|
||||
rsp_size=8;
|
||||
ICAddRSP(tempi,-8);
|
||||
ICAddRSP(tmpi,-8);
|
||||
} else if (rsp_size==16)
|
||||
d2=8;
|
||||
|
||||
if (alt) {
|
||||
ICU16(tempi,0xF1DF); //FCOMIP
|
||||
ICSlashOp(tempi,t2,r2,d2,SLASH_OP_FSTP,ip2);
|
||||
ICU16(tmpi,0xF1DF); //FCOMIP
|
||||
ICSlashOp(tmpi,t2,r2,d2,SLASH_OP_FSTP,ip2);
|
||||
} else {
|
||||
ICU16(tempi,0xF1DB); //FCOMI
|
||||
ICSlashOp(tempi,t2,r2,d2,SLASH_OP_FSTP,ip2);
|
||||
ICU32(tempi,0xF7D9C0DD); //FFREE,FINCSTP
|
||||
ICU16(tmpi,0xF1DB); //FCOMI
|
||||
ICSlashOp(tmpi,t2,r2,d2,SLASH_OP_FSTP,ip2);
|
||||
ICU32(tmpi,0xF7D9C0DD); //FFREE,FINCSTP
|
||||
}
|
||||
} else {
|
||||
ICU16(tempi,0xF1DF); //FCOMIP
|
||||
ICU32(tempi,0xF7D9C0DD); //FFREE,FINCSTP
|
||||
ICU16(tmpi,0xF1DF); //FCOMIP
|
||||
ICU32(tmpi,0xF7D9C0DD); //FFREE,FINCSTP
|
||||
}
|
||||
CmpNoteFloatOp(cc,tempi,TRUE,FALSE,CN_MAIN);
|
||||
CmpNoteFloatOp(cc,tmpi,TRUE,FALSE,CN_MAIN);
|
||||
|
||||
if (tempi->ic_flags&ICF_PUSH_CMP) {
|
||||
if (tmpi->ic_flags&ICF_PUSH_CMP) {
|
||||
if (r2.u8[0]==REG_RSP) {
|
||||
while (d2 && rsp_size) {
|
||||
ICU8(tempi,0x5B); //POP RBX (Dont change flags)
|
||||
ICU8(tmpi,0x5B); //POP RBX (Dont change flags)
|
||||
rsp_size-=8;
|
||||
d2-=8;
|
||||
}
|
||||
} else {
|
||||
while (rsp_size) {
|
||||
ICU8(tempi,0x5B); //POP RBX (Dont change flags)
|
||||
ICU8(tmpi,0x5B); //POP RBX (Dont change flags)
|
||||
rsp_size-=8;
|
||||
}
|
||||
ICPush(tempi,t2,r2,d2,ip2);
|
||||
ICPush(tmpi,t2,r2,d2,ip2);
|
||||
}
|
||||
} else {
|
||||
while (rsp_size) {
|
||||
ICU8(tempi,0x5B); //POP RBX (Dont change flags)
|
||||
ICU8(tmpi,0x5B); //POP RBX (Dont change flags)
|
||||
rsp_size-=8;
|
||||
}
|
||||
}
|
||||
|
||||
ip+=tempi->ic_cnt;
|
||||
lb=OptLabelFwd(tempi->ic_data);
|
||||
short_jmp=ToBool(tempi->ic_flags&ICF_SHORT_JMP);
|
||||
ip+=tmpi->ic_cnt;
|
||||
lb=OptLabelFwd(tmpi->ic_data);
|
||||
short_jmp=ToBool(tmpi->ic_flags&ICF_SHORT_JMP);
|
||||
if (!buf && lb->addr!=INVALID_PTR) {
|
||||
i=lb->addr-(ip+2);
|
||||
if (lb->flags&CMF_POP_CMP) {
|
||||
if(tempi->ic_flags&ICF_PUSH_CMP)
|
||||
if(tmpi->ic_flags&ICF_PUSH_CMP)
|
||||
i+=4;
|
||||
else
|
||||
i+=8;
|
||||
@@ -451,170 +451,170 @@ U0 ICFCmpAndBranch(CCmpCtrl *cc,CIntermediateCode *tempi,I64 ip,
|
||||
}
|
||||
|
||||
if (short_jmp) {
|
||||
tempi->ic_flags|=ICF_SHORT_JMP;
|
||||
tmpi->ic_flags|=ICF_SHORT_JMP;
|
||||
i=lb->addr-(ip+2);
|
||||
if (lb->flags&CMF_POP_CMP) {
|
||||
if(tempi->ic_flags&ICF_PUSH_CMP)
|
||||
if(tmpi->ic_flags&ICF_PUSH_CMP)
|
||||
i+=4;
|
||||
else
|
||||
i+=8;
|
||||
}
|
||||
ICU16(tempi,i<<8+us.u8[2]);
|
||||
ICU16(tmpi,i<<8+us.u8[2]);
|
||||
} else {
|
||||
tempi->ic_flags&=~ICF_SHORT_JMP;
|
||||
tmpi->ic_flags&=~ICF_SHORT_JMP;
|
||||
i=lb->addr-(ip+6);
|
||||
if (lb->flags&CMF_POP_CMP) {
|
||||
if(tempi->ic_flags&ICF_PUSH_CMP)
|
||||
if(tmpi->ic_flags&ICF_PUSH_CMP)
|
||||
i+=4;
|
||||
else
|
||||
i+=8;
|
||||
}
|
||||
ICU16(tempi,us.u16[0]);
|
||||
ICU32(tempi,i);
|
||||
ICU16(tmpi,us.u16[0]);
|
||||
ICU32(tmpi,i);
|
||||
}
|
||||
}
|
||||
|
||||
U0 ICFMul(CCmpCtrl *cc,CIntermediateCode *tempi,U8 *buf,I64 ip)
|
||||
U0 ICFMul(CCmpCtrl *cc,CIntermediateCode *tmpi,U8 *buf,I64 ip)
|
||||
{
|
||||
if (tempi->a1.type&MDF_IMM && tempi->a1.type&RTG_MASK==RT_F64 &&
|
||||
tempi->a1.disp(F64)==1.0) {
|
||||
CmpNoteFloatOp(cc,tempi,FALSE,FALSE,CN_MAIN);
|
||||
ICMov(tempi,tempi->r.type,tempi->r.reg,tempi->r.disp,
|
||||
tempi->a2.type,tempi->a2.reg,tempi->a2.disp,ip);
|
||||
} else if (tempi->a2.type&MDF_IMM &&
|
||||
tempi->a2.type&RTG_MASK==RT_F64&& tempi->a2.disp(F64)==1.0) {
|
||||
CmpNoteFloatOp(cc,tempi,FALSE,FALSE,CN_MAIN);
|
||||
ICMov(tempi,tempi->r.type,tempi->r.reg,tempi->r.disp,
|
||||
tempi->a1.type,tempi->a1.reg,tempi->a1.disp,ip);
|
||||
if (tmpi->a1.type&MDF_IMM && tmpi->a1.type&RTG_MASK==RT_F64 &&
|
||||
tmpi->a1.disp(F64)==1.0) {
|
||||
CmpNoteFloatOp(cc,tmpi,FALSE,FALSE,CN_MAIN);
|
||||
ICMov(tmpi,tmpi->r.type,tmpi->r.reg,tmpi->r.disp,
|
||||
tmpi->a2.type,tmpi->a2.reg,tmpi->a2.disp,ip);
|
||||
} else if (tmpi->a2.type&MDF_IMM &&
|
||||
tmpi->a2.type&RTG_MASK==RT_F64&& tmpi->a2.disp(F64)==1.0) {
|
||||
CmpNoteFloatOp(cc,tmpi,FALSE,FALSE,CN_MAIN);
|
||||
ICMov(tmpi,tmpi->r.type,tmpi->r.reg,tmpi->r.disp,
|
||||
tmpi->a1.type,tmpi->a1.reg,tmpi->a1.disp,ip);
|
||||
} else
|
||||
ICFOp(cc,tempi,SLASH_OP_FMUL,buf,ip);
|
||||
ICFOp(cc,tmpi,SLASH_OP_FMUL,buf,ip);
|
||||
}
|
||||
|
||||
U0 ICFDiv(CCmpCtrl *cc,CIntermediateCode *tempi,U8 *buf,I64 ip)
|
||||
U0 ICFDiv(CCmpCtrl *cc,CIntermediateCode *tmpi,U8 *buf,I64 ip)
|
||||
{
|
||||
if (tempi->a2.type&MDF_IMM && tempi->a2.type&RTG_MASK==RT_F64 &&
|
||||
tempi->a2.disp(F64)==1.0) {
|
||||
CmpNoteFloatOp(cc,tempi,FALSE,FALSE,CN_MAIN);
|
||||
ICMov(tempi,tempi->r.type,tempi->r.reg,tempi->r.disp,
|
||||
tempi->a1.type,tempi->a1.reg,tempi->a1.disp,ip);
|
||||
if (tmpi->a2.type&MDF_IMM && tmpi->a2.type&RTG_MASK==RT_F64 &&
|
||||
tmpi->a2.disp(F64)==1.0) {
|
||||
CmpNoteFloatOp(cc,tmpi,FALSE,FALSE,CN_MAIN);
|
||||
ICMov(tmpi,tmpi->r.type,tmpi->r.reg,tmpi->r.disp,
|
||||
tmpi->a1.type,tmpi->a1.reg,tmpi->a1.disp,ip);
|
||||
} else
|
||||
ICFOp(cc,tempi,SLASH_OP_FDIV,buf,ip);
|
||||
ICFOp(cc,tmpi,SLASH_OP_FDIV,buf,ip);
|
||||
}
|
||||
|
||||
U0 ICFAdd(CCmpCtrl *cc,CIntermediateCode *tempi,U8 *buf,I64 ip)
|
||||
U0 ICFAdd(CCmpCtrl *cc,CIntermediateCode *tmpi,U8 *buf,I64 ip)
|
||||
{
|
||||
Bool dont_push_float,dont_pop_float;
|
||||
CmpSetFloatOpPushPop(cc,tempi,&dont_push_float,&dont_pop_float);
|
||||
if (tempi->a1.type&MDF_IMM && !tempi->a1.disp) {
|
||||
CmpSetFloatOpPushPop(cc,tmpi,&dont_push_float,&dont_pop_float);
|
||||
if (tmpi->a1.type&MDF_IMM && !tmpi->a1.disp) {
|
||||
if (dont_push_float) {
|
||||
ICCopyTemplate(cc,tempi,CMP_TEMPLATE_FSTP,FALSE,TRUE,TRUE,CN_MAIN);
|
||||
ICMov(tempi,tempi->r.type,tempi->r.reg,tempi->r.disp,
|
||||
ICCopyTemplate(cc,tmpi,CMP_TEMPLATE_FSTP,FALSE,TRUE,TRUE,CN_MAIN);
|
||||
ICMov(tmpi,tmpi->r.type,tmpi->r.reg,tmpi->r.disp,
|
||||
MDF_REG+RT_I64,REG_RAX,0,ip);
|
||||
} else if (dont_pop_float) {
|
||||
ICMov(tempi,MDF_REG+RT_I64,REG_RAX,0,
|
||||
tempi->a2.type,tempi->a2.reg,tempi->a2.disp,ip);
|
||||
ICCopyTemplate(cc,tempi,CMP_TEMPLATE_FLD,FALSE,TRUE,TRUE,CN_MAIN);
|
||||
ICMov(tmpi,MDF_REG+RT_I64,REG_RAX,0,
|
||||
tmpi->a2.type,tmpi->a2.reg,tmpi->a2.disp,ip);
|
||||
ICCopyTemplate(cc,tmpi,CMP_TEMPLATE_FLD,FALSE,TRUE,TRUE,CN_MAIN);
|
||||
} else {
|
||||
CmpNoteFloatOp(cc,tempi,TRUE,TRUE,CN_MAIN);
|
||||
ICMov(tempi,tempi->r.type,tempi->r.reg,tempi->r.disp,
|
||||
tempi->a2.type,tempi->a2.reg,tempi->a2.disp,ip);
|
||||
CmpNoteFloatOp(cc,tmpi,TRUE,TRUE,CN_MAIN);
|
||||
ICMov(tmpi,tmpi->r.type,tmpi->r.reg,tmpi->r.disp,
|
||||
tmpi->a2.type,tmpi->a2.reg,tmpi->a2.disp,ip);
|
||||
}
|
||||
} else if (tempi->a2.type&MDF_IMM && !tempi->a2.disp) {
|
||||
} else if (tmpi->a2.type&MDF_IMM && !tmpi->a2.disp) {
|
||||
if (dont_push_float) {
|
||||
ICCopyTemplate(cc,tempi,CMP_TEMPLATE_FSTP,FALSE,TRUE,TRUE,CN_MAIN);
|
||||
ICMov(tempi,tempi->r.type,tempi->r.reg,tempi->r.disp,
|
||||
ICCopyTemplate(cc,tmpi,CMP_TEMPLATE_FSTP,FALSE,TRUE,TRUE,CN_MAIN);
|
||||
ICMov(tmpi,tmpi->r.type,tmpi->r.reg,tmpi->r.disp,
|
||||
MDF_REG+RT_I64,REG_RAX,0,ip);
|
||||
} else if (dont_pop_float) {
|
||||
ICMov(tempi,MDF_REG+RT_I64,REG_RAX,0,
|
||||
tempi->a1.type,tempi->a1.reg,tempi->a1.disp,ip);
|
||||
ICCopyTemplate(cc,tempi,CMP_TEMPLATE_FLD,FALSE,TRUE,TRUE,CN_MAIN);
|
||||
ICMov(tmpi,MDF_REG+RT_I64,REG_RAX,0,
|
||||
tmpi->a1.type,tmpi->a1.reg,tmpi->a1.disp,ip);
|
||||
ICCopyTemplate(cc,tmpi,CMP_TEMPLATE_FLD,FALSE,TRUE,TRUE,CN_MAIN);
|
||||
} else {
|
||||
ICMov(tempi,tempi->r.type,tempi->r.reg,tempi->r.disp,
|
||||
tempi->a1.type,tempi->a1.reg,tempi->a1.disp,ip);
|
||||
CmpNoteFloatOp(cc,tempi,TRUE,TRUE,CN_MAIN);
|
||||
ICMov(tmpi,tmpi->r.type,tmpi->r.reg,tmpi->r.disp,
|
||||
tmpi->a1.type,tmpi->a1.reg,tmpi->a1.disp,ip);
|
||||
CmpNoteFloatOp(cc,tmpi,TRUE,TRUE,CN_MAIN);
|
||||
}
|
||||
} else
|
||||
ICFOp(cc,tempi,SLASH_OP_FADD,buf,ip);
|
||||
ICFOp(cc,tmpi,SLASH_OP_FADD,buf,ip);
|
||||
}
|
||||
|
||||
U0 ICFSub(CCmpCtrl *cc,CIntermediateCode *tempi,U8 *buf,I64 ip)
|
||||
U0 ICFSub(CCmpCtrl *cc,CIntermediateCode *tmpi,U8 *buf,I64 ip)
|
||||
{
|
||||
Bool dont_push_float,dont_pop_float;
|
||||
if (tempi->a2.type&MDF_IMM && !tempi->a2.disp) {
|
||||
CmpSetFloatOpPushPop(cc,tempi,&dont_push_float,&dont_pop_float);
|
||||
if (tmpi->a2.type&MDF_IMM && !tmpi->a2.disp) {
|
||||
CmpSetFloatOpPushPop(cc,tmpi,&dont_push_float,&dont_pop_float);
|
||||
if (dont_push_float) {
|
||||
ICCopyTemplate(cc,tempi,CMP_TEMPLATE_FSTP,FALSE,TRUE,TRUE,CN_MAIN);
|
||||
ICMov(tempi,tempi->r.type,tempi->r.reg,tempi->r.disp,
|
||||
ICCopyTemplate(cc,tmpi,CMP_TEMPLATE_FSTP,FALSE,TRUE,TRUE,CN_MAIN);
|
||||
ICMov(tmpi,tmpi->r.type,tmpi->r.reg,tmpi->r.disp,
|
||||
MDF_REG+RT_I64,REG_RAX,0,ip);
|
||||
} else if (dont_pop_float) {
|
||||
ICMov(tempi,MDF_REG+RT_I64,REG_RAX,0,
|
||||
tempi->a1.type,tempi->a1.reg,tempi->a1.disp,ip);
|
||||
ICCopyTemplate(cc,tempi,CMP_TEMPLATE_FLD,FALSE,TRUE,TRUE,CN_MAIN);
|
||||
ICMov(tmpi,MDF_REG+RT_I64,REG_RAX,0,
|
||||
tmpi->a1.type,tmpi->a1.reg,tmpi->a1.disp,ip);
|
||||
ICCopyTemplate(cc,tmpi,CMP_TEMPLATE_FLD,FALSE,TRUE,TRUE,CN_MAIN);
|
||||
} else {
|
||||
ICMov(tempi,tempi->r.type,tempi->r.reg,tempi->r.disp,
|
||||
tempi->a1.type,tempi->a1.reg,tempi->a1.disp,ip);
|
||||
CmpNoteFloatOp(cc,tempi,TRUE,TRUE,CN_MAIN);
|
||||
ICMov(tmpi,tmpi->r.type,tmpi->r.reg,tmpi->r.disp,
|
||||
tmpi->a1.type,tmpi->a1.reg,tmpi->a1.disp,ip);
|
||||
CmpNoteFloatOp(cc,tmpi,TRUE,TRUE,CN_MAIN);
|
||||
}
|
||||
} else
|
||||
ICFOp(cc,tempi,SLASH_OP_FSUB,buf,ip);
|
||||
ICFOp(cc,tmpi,SLASH_OP_FSUB,buf,ip);
|
||||
}
|
||||
|
||||
U0 ICFPreIncDec(CCmpCtrl *cc,CIntermediateCode *tempi,I64 op,I64 ip)
|
||||
U0 ICFPreIncDec(CCmpCtrl *cc,CIntermediateCode *tmpi,I64 op,I64 ip)
|
||||
{
|
||||
if (tempi->ic_flags & ICF_BY_VAL) {
|
||||
ICMov(tempi,MDF_REG+RT_I64,REG_RAX,0,
|
||||
tempi->a1.type&MDG_MASK+RT_I64,tempi->a1.reg,tempi->a1.disp,ip);
|
||||
ICCopyTemplate(cc,tempi,op,FALSE,TRUE,TRUE,CN_MAIN);
|
||||
ICMov(tempi,tempi->a1.type,tempi->a1.reg,tempi->a1.disp,
|
||||
if (tmpi->ic_flags & ICF_BY_VAL) {
|
||||
ICMov(tmpi,MDF_REG+RT_I64,REG_RAX,0,
|
||||
tmpi->a1.type&MDG_MASK+RT_I64,tmpi->a1.reg,tmpi->a1.disp,ip);
|
||||
ICCopyTemplate(cc,tmpi,op,FALSE,TRUE,TRUE,CN_MAIN);
|
||||
ICMov(tmpi,tmpi->a1.type,tmpi->a1.reg,tmpi->a1.disp,
|
||||
MDF_REG+RT_I64,REG_RAX,0,ip);
|
||||
} else {
|
||||
ICMov(tempi,MDF_REG+RT_I64,REG_RCX,0,
|
||||
tempi->a1.type,tempi->a1.reg,tempi->a1.disp,ip);
|
||||
ICMov(tempi,MDF_REG+RT_I64,REG_RAX,0,MDF_DISP+RT_I64,REG_RCX,0,ip);
|
||||
ICCopyTemplate(cc,tempi,op,FALSE,TRUE,TRUE,CN_MAIN);
|
||||
ICMov(tempi,MDF_DISP+RT_I64,REG_RCX,0,MDF_REG+RT_I64,REG_RAX,0,ip);
|
||||
ICMov(tmpi,MDF_REG+RT_I64,REG_RCX,0,
|
||||
tmpi->a1.type,tmpi->a1.reg,tmpi->a1.disp,ip);
|
||||
ICMov(tmpi,MDF_REG+RT_I64,REG_RAX,0,MDF_DISP+RT_I64,REG_RCX,0,ip);
|
||||
ICCopyTemplate(cc,tmpi,op,FALSE,TRUE,TRUE,CN_MAIN);
|
||||
ICMov(tmpi,MDF_DISP+RT_I64,REG_RCX,0,MDF_REG+RT_I64,REG_RAX,0,ip);
|
||||
}
|
||||
if (tempi->r.type.mode)
|
||||
ICMov(tempi,tempi->r.type,tempi->r.reg,tempi->r.disp,
|
||||
if (tmpi->r.type.mode)
|
||||
ICMov(tmpi,tmpi->r.type,tmpi->r.reg,tmpi->r.disp,
|
||||
MDF_REG+RT_I64,REG_RAX,0,ip);
|
||||
}
|
||||
|
||||
U0 ICFPostIncDec(CCmpCtrl *cc,CIntermediateCode *tempi,I64 op,I64 ip)
|
||||
U0 ICFPostIncDec(CCmpCtrl *cc,CIntermediateCode *tmpi,I64 op,I64 ip)
|
||||
{
|
||||
if (tempi->ic_flags & ICF_BY_VAL) {
|
||||
ICMov(tempi,MDF_REG+RT_I64,REG_RAX,0,
|
||||
tempi->a1.type&MDG_MASK+RT_I64,tempi->a1.reg,tempi->a1.disp,ip);
|
||||
if (tempi->r.type.mode)
|
||||
ICMov(tempi,MDF_REG+RT_I64,REG_RDX,0,MDF_REG+RT_I64,REG_RAX,0,ip);
|
||||
ICCopyTemplate(cc,tempi,op,FALSE,TRUE,TRUE,CN_MAIN);
|
||||
ICMov(tempi,tempi->a1.type,tempi->a1.reg,tempi->a1.disp,
|
||||
if (tmpi->ic_flags & ICF_BY_VAL) {
|
||||
ICMov(tmpi,MDF_REG+RT_I64,REG_RAX,0,
|
||||
tmpi->a1.type&MDG_MASK+RT_I64,tmpi->a1.reg,tmpi->a1.disp,ip);
|
||||
if (tmpi->r.type.mode)
|
||||
ICMov(tmpi,MDF_REG+RT_I64,REG_RDX,0,MDF_REG+RT_I64,REG_RAX,0,ip);
|
||||
ICCopyTemplate(cc,tmpi,op,FALSE,TRUE,TRUE,CN_MAIN);
|
||||
ICMov(tmpi,tmpi->a1.type,tmpi->a1.reg,tmpi->a1.disp,
|
||||
MDF_REG+RT_I64,REG_RAX,0,ip);
|
||||
} else {
|
||||
ICMov(tempi,MDF_REG+RT_I64,REG_RCX,0,
|
||||
tempi->a1.type,tempi->a1.reg,tempi->a1.disp,ip);
|
||||
ICMov(tempi,MDF_REG+RT_I64,REG_RAX,0,MDF_DISP+RT_I64,REG_RCX,0,ip);
|
||||
if (tempi->r.type.mode)
|
||||
ICMov(tempi,MDF_REG+RT_I64,REG_RDX,0,MDF_REG+RT_I64,REG_RAX,0,ip);
|
||||
ICCopyTemplate(cc,tempi,op,FALSE,TRUE,TRUE,CN_MAIN);
|
||||
ICMov(tempi,MDF_DISP+RT_I64,REG_RCX,0,MDF_REG+RT_I64,REG_RAX,0,ip);
|
||||
ICMov(tmpi,MDF_REG+RT_I64,REG_RCX,0,
|
||||
tmpi->a1.type,tmpi->a1.reg,tmpi->a1.disp,ip);
|
||||
ICMov(tmpi,MDF_REG+RT_I64,REG_RAX,0,MDF_DISP+RT_I64,REG_RCX,0,ip);
|
||||
if (tmpi->r.type.mode)
|
||||
ICMov(tmpi,MDF_REG+RT_I64,REG_RDX,0,MDF_REG+RT_I64,REG_RAX,0,ip);
|
||||
ICCopyTemplate(cc,tmpi,op,FALSE,TRUE,TRUE,CN_MAIN);
|
||||
ICMov(tmpi,MDF_DISP+RT_I64,REG_RCX,0,MDF_REG+RT_I64,REG_RAX,0,ip);
|
||||
}
|
||||
if (tempi->r.type.mode)
|
||||
ICMov(tempi,tempi->r.type,tempi->r.reg,tempi->r.disp,
|
||||
if (tmpi->r.type.mode)
|
||||
ICMov(tmpi,tmpi->r.type,tmpi->r.reg,tmpi->r.disp,
|
||||
MDF_REG+RT_I64,REG_RDX,0,ip);
|
||||
}
|
||||
|
||||
U0 ICFTemplateFun(CCmpCtrl *cc,CIntermediateCode *tempi,I64 op,I64 ip)
|
||||
U0 ICFTemplateFun(CCmpCtrl *cc,CIntermediateCode *tmpi,I64 op,I64 ip)
|
||||
{
|
||||
Bool dont_push_float,dont_pop_float;
|
||||
|
||||
CmpSetFloatOpPushPop(cc,tempi,&dont_push_float,&dont_pop_float);
|
||||
CmpSetFloatOpPushPop(cc,tmpi,&dont_push_float,&dont_pop_float);
|
||||
if (!dont_push_float)
|
||||
ICMov(tempi,MDF_REG+RT_I64,REG_RAX,0,
|
||||
tempi->a1.type,tempi->a1.reg,tempi->a1.disp,ip);
|
||||
ICMov(tmpi,MDF_REG+RT_I64,REG_RAX,0,
|
||||
tmpi->a1.type,tmpi->a1.reg,tmpi->a1.disp,ip);
|
||||
|
||||
ICCopyTemplate(cc,tempi,op,FALSE,TRUE,TRUE,CN_MAIN);
|
||||
if (tempi->r.type.mode && !(tempi->ic_flags & ICF_R_TO_F64) &&
|
||||
!(tempi->ic_flags & ICF_R_TO_INT))
|
||||
ICMov(tempi,tempi->r.type,tempi->r.reg,tempi->r.disp,
|
||||
ICCopyTemplate(cc,tmpi,op,FALSE,TRUE,TRUE,CN_MAIN);
|
||||
if (tmpi->r.type.mode && !(tmpi->ic_flags & ICF_R_TO_F64) &&
|
||||
!(tmpi->ic_flags & ICF_R_TO_INT))
|
||||
ICMov(tmpi,tmpi->r.type,tmpi->r.reg,tmpi->r.disp,
|
||||
MDF_REG+RT_I64,REG_RAX,0,ip);
|
||||
}
|
||||
+209
-209
@@ -14,113 +14,113 @@ found it's way into a reg has been
|
||||
sign or zero extended to 64-bits.
|
||||
*/
|
||||
|
||||
U0 ICU8(CIntermediateCode *tempi,U8 b)
|
||||
U0 ICU8(CIntermediateCode *tmpi,U8 b)
|
||||
{
|
||||
tempi->ic_body[tempi->ic_cnt++]=b;
|
||||
tmpi->ic_body[tmpi->ic_cnt++]=b;
|
||||
}
|
||||
|
||||
U0 ICRex(CIntermediateCode *tempi,U8 b)
|
||||
U0 ICRex(CIntermediateCode *tmpi,U8 b)
|
||||
{
|
||||
if (b)
|
||||
tempi->ic_body[tempi->ic_cnt++]=b;
|
||||
tmpi->ic_body[tmpi->ic_cnt++]=b;
|
||||
}
|
||||
|
||||
U0 ICOpSizeRex(CIntermediateCode *tempi,U8 b)
|
||||
U0 ICOpSizeRex(CIntermediateCode *tmpi,U8 b)
|
||||
{
|
||||
tempi->ic_body[tempi->ic_cnt++]=OC_OP_SIZE_PREFIX;
|
||||
tmpi->ic_body[tmpi->ic_cnt++]=OC_OP_SIZE_PREFIX;
|
||||
if (b)
|
||||
tempi->ic_body[tempi->ic_cnt++]=b;
|
||||
tmpi->ic_body[tmpi->ic_cnt++]=b;
|
||||
}
|
||||
|
||||
U0 ICU16(CIntermediateCode *tempi,U16 w)
|
||||
U0 ICU16(CIntermediateCode *tmpi,U16 w)
|
||||
{
|
||||
*(&tempi->ic_body[tempi->ic_cnt])(U16)=w;
|
||||
tempi->ic_cnt+=2;
|
||||
*(&tmpi->ic_body[tmpi->ic_cnt])(U16)=w;
|
||||
tmpi->ic_cnt+=2;
|
||||
}
|
||||
|
||||
U0 ICU24(CIntermediateCode *tempi,U32 d)
|
||||
U0 ICU24(CIntermediateCode *tmpi,U32 d)
|
||||
{//Writes extra harmless overhanging byte.
|
||||
*(&tempi->ic_body[tempi->ic_cnt])(U32)=d;
|
||||
tempi->ic_cnt+=3;
|
||||
*(&tmpi->ic_body[tmpi->ic_cnt])(U32)=d;
|
||||
tmpi->ic_cnt+=3;
|
||||
}
|
||||
|
||||
U0 ICU32(CIntermediateCode *tempi,U32 d)
|
||||
U0 ICU32(CIntermediateCode *tmpi,U32 d)
|
||||
{
|
||||
*(&tempi->ic_body[tempi->ic_cnt])(U32)=d;
|
||||
tempi->ic_cnt+=4;
|
||||
*(&tmpi->ic_body[tmpi->ic_cnt])(U32)=d;
|
||||
tmpi->ic_cnt+=4;
|
||||
}
|
||||
|
||||
U0 ICU64(CIntermediateCode *tempi,U64 q)
|
||||
U0 ICU64(CIntermediateCode *tmpi,U64 q)
|
||||
{
|
||||
*(&tempi->ic_body[tempi->ic_cnt])(U64)=q;
|
||||
tempi->ic_cnt+=8;
|
||||
*(&tmpi->ic_body[tmpi->ic_cnt])(U64)=q;
|
||||
tmpi->ic_cnt+=8;
|
||||
}
|
||||
|
||||
U0 ICAddRSP(CIntermediateCode *tempi,I64 i,Bool optimize=TRUE)
|
||||
U0 ICAddRSP(CIntermediateCode *tmpi,I64 i,Bool optimize=TRUE)
|
||||
{
|
||||
I64 j,last_start;
|
||||
CIntermediateCode *tempil1;
|
||||
CIntermediateCode *tmpil1;
|
||||
if (optimize) {
|
||||
tempil1=tempi;
|
||||
if (tempi->ic_last_start<0 && !tempi->ic_cnt &&
|
||||
(tempil1=OptLag1(tempi)) && tempil1->ic_last_start<0)
|
||||
tempil1=NULL;
|
||||
if (tempil1) {
|
||||
j=tempil1->ic_cnt;
|
||||
if (tempil1->ic_last_start==j-4 && tempil1->ic_body[j-3]==0x83 &&
|
||||
tempil1->ic_body[j-4]==0x48) {
|
||||
if (tempil1->ic_body[j-2]==0xEC)
|
||||
j=-tempil1->ic_body[j-1](I8);
|
||||
else if (tempil1->ic_body[j-2]==0xC4)
|
||||
j=tempil1->ic_body[j-1](I8);
|
||||
tmpil1=tmpi;
|
||||
if (tmpi->ic_last_start<0 && !tmpi->ic_cnt &&
|
||||
(tmpil1=OptLag1(tmpi)) && tmpil1->ic_last_start<0)
|
||||
tmpil1=NULL;
|
||||
if (tmpil1) {
|
||||
j=tmpil1->ic_cnt;
|
||||
if (tmpil1->ic_last_start==j-4 && tmpil1->ic_body[j-3]==0x83 &&
|
||||
tmpil1->ic_body[j-4]==0x48) {
|
||||
if (tmpil1->ic_body[j-2]==0xEC)
|
||||
j=-tmpil1->ic_body[j-1](I8);
|
||||
else if (tmpil1->ic_body[j-2]==0xC4)
|
||||
j=tmpil1->ic_body[j-1](I8);
|
||||
else
|
||||
j=0;
|
||||
} else if (tempil1->ic_last_start==j-7 && tempil1->ic_body[j-6]==0x81 &&
|
||||
tempil1->ic_body[j-7]==0x48) {
|
||||
if (tempil1->ic_body[j-5]==0xEC)
|
||||
j=-tempil1->ic_body[j-4](I32);
|
||||
else if (tempil1->ic_body[j-5]==0xC4)
|
||||
j=tempil1->ic_body[j-4](I32);
|
||||
} else if (tmpil1->ic_last_start==j-7 && tmpil1->ic_body[j-6]==0x81 &&
|
||||
tmpil1->ic_body[j-7]==0x48) {
|
||||
if (tmpil1->ic_body[j-5]==0xEC)
|
||||
j=-tmpil1->ic_body[j-4](I32);
|
||||
else if (tmpil1->ic_body[j-5]==0xC4)
|
||||
j=tmpil1->ic_body[j-4](I32);
|
||||
else
|
||||
j=0;
|
||||
} else
|
||||
j=0;
|
||||
if (j) {
|
||||
if (tempi==tempil1) {
|
||||
tempi->ic_cnt=tempi->ic_last_start;
|
||||
if (tmpi==tmpil1) {
|
||||
tmpi->ic_cnt=tmpi->ic_last_start;
|
||||
i+=j;
|
||||
} 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;
|
||||
} else if (!(tmpi->ic_flags&ICF_PREV_DELETED)) {
|
||||
tmpil1->ic_flags|=ICF_DEL_PREV_INS;
|
||||
tmpi->ic_flags=tmpi->ic_flags&~ICF_CODE_FINAL|ICF_PREV_DELETED;
|
||||
i+=j;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
last_start=tempi->ic_cnt;
|
||||
last_start=tmpi->ic_cnt;
|
||||
if (i>0) {
|
||||
if (i<=MAX_I8)
|
||||
ICU32(tempi,0xC48348+i<<24);
|
||||
ICU32(tmpi,0xC48348+i<<24);
|
||||
else if (i<=MAX_I32) {
|
||||
ICU24(tempi,0xC48148);
|
||||
ICU32(tempi,i);
|
||||
ICU24(tmpi,0xC48148);
|
||||
ICU32(tmpi,i);
|
||||
} else
|
||||
throw('Compiler');
|
||||
} else if (i<0) {
|
||||
i=-i;
|
||||
if (i<=MAX_I8)
|
||||
ICU32(tempi,0xEC8348+i<<24);
|
||||
ICU32(tmpi,0xEC8348+i<<24);
|
||||
else if (i<=MAX_I32) {
|
||||
ICU24(tempi,0xEC8148);
|
||||
ICU32(tempi,i);
|
||||
ICU24(tmpi,0xEC8148);
|
||||
ICU32(tmpi,i);
|
||||
} else
|
||||
throw('Compiler');
|
||||
}
|
||||
if (optimize && tempi->ic_cnt>last_start)
|
||||
tempi->ic_last_start=last_start;
|
||||
if (optimize && tmpi->ic_cnt>last_start)
|
||||
tmpi->ic_last_start=last_start;
|
||||
}
|
||||
|
||||
extern U0 ICMov(CIntermediateCode *tempi,
|
||||
extern U0 ICMov(CIntermediateCode *tmpi,
|
||||
CICType t1,I64 r1,I64 d1,CICType t2,I64 r2,I64 d2,I64 ip);
|
||||
|
||||
#define MODR_REG 0
|
||||
@@ -210,7 +210,7 @@ I64 ICModr1(I64 r,CICType t2,I64 r2,I64 d2)
|
||||
return res;
|
||||
}
|
||||
|
||||
U0 ICModr2(CIntermediateCode *tempi,I64 i,I64 d,I64 ip=0)
|
||||
U0 ICModr2(CIntermediateCode *tmpi,I64 i,I64 d,I64 ip=0)
|
||||
{//t=0 means no SIB
|
||||
switch [i.u8[0]] {
|
||||
case MODR_REG:
|
||||
@@ -218,25 +218,25 @@ U0 ICModr2(CIntermediateCode *tempi,I64 i,I64 d,I64 ip=0)
|
||||
case MODR_INDIRECT_REG:
|
||||
break;
|
||||
case MODR_D8_INDIRECT_REG:
|
||||
ICU8(tempi,d);
|
||||
ICU8(tmpi,d);
|
||||
break;
|
||||
case MODR_D32_INDIRECT_REG:
|
||||
ICU32(tempi,d);
|
||||
ICU32(tmpi,d);
|
||||
break;
|
||||
case MODR_SIB_INDIRECT_REG:
|
||||
ICU8(tempi,i.u8[3]);
|
||||
ICU8(tmpi,i.u8[3]);
|
||||
break;
|
||||
case MODR_SIB_D8_INDIRECT_REG:
|
||||
ICU8(tempi,i.u8[3]);
|
||||
ICU8(tempi,d);
|
||||
ICU8(tmpi,i.u8[3]);
|
||||
ICU8(tmpi,d);
|
||||
break;
|
||||
case MODR_SIB_D32_INDIRECT_REG:
|
||||
ICU8(tempi,i.u8[3]);
|
||||
ICU32(tempi,d);
|
||||
ICU8(tmpi,i.u8[3]);
|
||||
ICU32(tmpi,d);
|
||||
break;
|
||||
case MODR_RIP_REL:
|
||||
ICU32(tempi,d-(ip+tempi->ic_cnt));
|
||||
tempi->ic_flags&=~ICF_CODE_FINAL;
|
||||
ICU32(tmpi,d-(ip+tmpi->ic_cnt));
|
||||
tmpi->ic_flags&=~ICF_CODE_FINAL;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -262,52 +262,52 @@ U0 ICModr2(CIntermediateCode *tempi,I64 i,I64 d,I64 ip=0)
|
||||
#define SLASH_OP_FISTTP 0x0000000001DDDD01
|
||||
#define SLASH_OP_FILD 0x0000000001DFDF05
|
||||
|
||||
U0 ICSlashOp(CIntermediateCode *tempi,CICType t1,I64 r1,I64 d1,I64 op,I64 ip)
|
||||
U0 ICSlashOp(CIntermediateCode *tmpi,CICType t1,I64 r1,I64 d1,I64 op,I64 ip)
|
||||
{
|
||||
I64 i;
|
||||
if (t1&MDF_REG && !op.u8[3])
|
||||
t1=t1&(MDG_MASK|RTF_UNSIGNED)+RT_I64; //Set to 64 bit,preserving unsigned
|
||||
i=ICModr1(op.u8[0],t1,r1,d1);
|
||||
|
||||
if (tempi->ic_flags&ICF_LOCK && op!=SLASH_OP_MOV && !(t1&MDF_REG))
|
||||
ICU8(tempi,OC_LOCK_PREFIX);
|
||||
if (tmpi->ic_flags&ICF_LOCK && op!=SLASH_OP_MOV && !(t1&MDF_REG))
|
||||
ICU8(tmpi,OC_LOCK_PREFIX);
|
||||
switch (t1.raw_type) {
|
||||
case RT_I8:
|
||||
case RT_U8:
|
||||
ICRex(tempi,i.u8[1]);
|
||||
ICU16(tempi,i.u8[2]<<8+op.u8[1]);
|
||||
ICRex(tmpi,i.u8[1]);
|
||||
ICU16(tmpi,i.u8[2]<<8+op.u8[1]);
|
||||
break;
|
||||
case RT_I16:
|
||||
case RT_U16:
|
||||
ICOpSizeRex(tempi,i.u8[1]);
|
||||
ICU16(tempi,i.u8[2]<<8+op.u8[2]);
|
||||
ICOpSizeRex(tmpi,i.u8[1]);
|
||||
ICU16(tmpi,i.u8[2]<<8+op.u8[2]);
|
||||
break;
|
||||
default:
|
||||
if (i.u8[1]!=0x48 || !op.u8[3])
|
||||
ICRex(tempi,i.u8[1]);
|
||||
ICU16(tempi,i.u8[2]<<8+op.u8[2]);
|
||||
ICRex(tmpi,i.u8[1]);
|
||||
ICU16(tmpi,i.u8[2]<<8+op.u8[2]);
|
||||
}
|
||||
ICModr2(tempi,i,d1,ip+4);
|
||||
ICModr2(tmpi,i,d1,ip+4);
|
||||
}
|
||||
|
||||
U0 ICPush(CIntermediateCode *tempi,CICType t1,I64 r1,I64 d1,I64 ip)
|
||||
U0 ICPush(CIntermediateCode *tmpi,CICType t1,I64 r1,I64 d1,I64 ip)
|
||||
{
|
||||
switch (Bsr(t1)) {
|
||||
case MDf_REG:
|
||||
if (r1>7)
|
||||
ICU16(tempi,0x5049+(r1&7)<<8);
|
||||
ICU16(tmpi,0x5049+(r1&7)<<8);
|
||||
else
|
||||
ICU8(tempi,0x50+r1);
|
||||
ICU8(tmpi,0x50+r1);
|
||||
return;
|
||||
case MDf_IMM:
|
||||
if (MIN_I8<=d1<=MAX_I8)
|
||||
ICU16(tempi,0x6A+d1<<8);
|
||||
ICU16(tmpi,0x6A+d1<<8);
|
||||
else if (MIN_I32<=d1<=MAX_I32) {
|
||||
ICU8(tempi,0x68);
|
||||
ICU32(tempi,d1);
|
||||
ICU8(tmpi,0x68);
|
||||
ICU32(tmpi,d1);
|
||||
} else {
|
||||
ICMov(tempi,MDF_REG+RT_I64,REG_RBX,0,t1,r1,d1,ip);
|
||||
ICU8(tempi,0x50+REG_RBX);
|
||||
ICMov(tmpi,MDF_REG+RT_I64,REG_RBX,0,t1,r1,d1,ip);
|
||||
ICU8(tmpi,0x50+REG_RBX);
|
||||
}
|
||||
return;
|
||||
case MDf_STK:
|
||||
@@ -319,86 +319,86 @@ U0 ICPush(CIntermediateCode *tempi,CICType t1,I64 r1,I64 d1,I64 ip)
|
||||
case RT_I64:
|
||||
case RT_U64:
|
||||
case RT_F64:
|
||||
ICSlashOp(tempi,t1,r1,d1,SLASH_OP_PUSH,ip);
|
||||
ICSlashOp(tmpi,t1,r1,d1,SLASH_OP_PUSH,ip);
|
||||
return;
|
||||
}
|
||||
break;
|
||||
}
|
||||
ICMov(tempi,MDF_REG+RT_I64,REG_RBX,0,t1,r1,d1,ip);
|
||||
ICU16(tempi,0x5048+REG_RBX<<8);
|
||||
ICMov(tmpi,MDF_REG+RT_I64,REG_RBX,0,t1,r1,d1,ip);
|
||||
ICU16(tmpi,0x5048+REG_RBX<<8);
|
||||
}
|
||||
|
||||
U0 ICPushRegs(CIntermediateCode *tempi,I64 mask)
|
||||
U0 ICPushRegs(CIntermediateCode *tmpi,I64 mask)
|
||||
{
|
||||
I64 i;
|
||||
for (i=0;i<NUM_REGS;i++) {
|
||||
if (Bt(&mask,i)) {
|
||||
if (i>7)
|
||||
ICU16(tempi,0x5049+(i&7)<<8);
|
||||
ICU16(tmpi,0x5049+(i&7)<<8);
|
||||
else
|
||||
ICU8(tempi,0x50+i);
|
||||
ICU8(tmpi,0x50+i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
U0 ICPop(CIntermediateCode *tempi,CICType t1,I64 r1,I64 d1,I64 ip)
|
||||
U0 ICPop(CIntermediateCode *tmpi,CICType t1,I64 r1,I64 d1,I64 ip)
|
||||
{
|
||||
switch (Bsr(t1)) {
|
||||
case MDf_REG:
|
||||
if (r1>7)
|
||||
ICU16(tempi,0x5849+(r1&7)<<8);
|
||||
ICU16(tmpi,0x5849+(r1&7)<<8);
|
||||
else
|
||||
ICU8(tempi,0x58+r1);
|
||||
ICU8(tmpi,0x58+r1);
|
||||
break;
|
||||
case MDf_DISP:
|
||||
case MDf_RIP_DISP32:
|
||||
case MDf_SIB:
|
||||
if (t1.raw_type<RT_I64) {
|
||||
ICU8(tempi,0x58+REG_RBX);
|
||||
ICMov(tempi,t1,r1,d1,MDF_REG+RT_I64,REG_RBX,0,ip);
|
||||
ICU8(tmpi,0x58+REG_RBX);
|
||||
ICMov(tmpi,t1,r1,d1,MDF_REG+RT_I64,REG_RBX,0,ip);
|
||||
} else
|
||||
ICSlashOp(tempi,t1,r1,d1,SLASH_OP_POP,ip);
|
||||
ICSlashOp(tmpi,t1,r1,d1,SLASH_OP_POP,ip);
|
||||
break;
|
||||
case MDf_STK:
|
||||
case MDf_IMM:
|
||||
ICU8(tempi,0x58+REG_RBX);
|
||||
ICMov(tempi,t1,r1,d1,MDF_REG+RT_I64,REG_RBX,0,ip);
|
||||
ICU8(tmpi,0x58+REG_RBX);
|
||||
ICMov(tmpi,t1,r1,d1,MDF_REG+RT_I64,REG_RBX,0,ip);
|
||||
break;
|
||||
default:
|
||||
ICAddRSP(tempi,8);
|
||||
ICAddRSP(tmpi,8);
|
||||
}
|
||||
}
|
||||
|
||||
U0 ICPopRegs(CIntermediateCode *tempi,I64 mask)
|
||||
U0 ICPopRegs(CIntermediateCode *tmpi,I64 mask)
|
||||
{
|
||||
I64 i;
|
||||
for (i=NUM_REGS-1;i>=0;i--) {
|
||||
if (Bt(&mask,i)) {
|
||||
if (i>7)
|
||||
ICU16(tempi,0x5849+(i&7)<<8);
|
||||
ICU16(tmpi,0x5849+(i&7)<<8);
|
||||
else
|
||||
ICU8(tempi,0x58+i);
|
||||
ICU8(tmpi,0x58+i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
U0 ICZero(CIntermediateCode *tempi,I64 r)
|
||||
U0 ICZero(CIntermediateCode *tmpi,I64 r)
|
||||
{
|
||||
if (r>7) {
|
||||
r&=7;
|
||||
ICU24(tempi,0xC0334D+r<<16+r<<19);
|
||||
ICU24(tmpi,0xC0334D+r<<16+r<<19);
|
||||
} else
|
||||
ICU16(tempi,0xC033+r<<8+r<<11);
|
||||
ICU16(tmpi,0xC033+r<<8+r<<11);
|
||||
}
|
||||
|
||||
U0 ICTest(CIntermediateCode *tempi,I64 r)
|
||||
U0 ICTest(CIntermediateCode *tmpi,I64 r)
|
||||
{
|
||||
I64 i=0xC08548; //TEST R,R
|
||||
if (r>7) {
|
||||
i+=5;
|
||||
r&=7;
|
||||
}
|
||||
ICU24(tempi,i+r<<16+r<<19);
|
||||
ICU24(tmpi,i+r<<16+r<<19);
|
||||
}
|
||||
|
||||
I64 ICBuiltInFloatConst(F64 d)
|
||||
@@ -423,57 +423,57 @@ I64 ICBuiltInFloatConst(F64 d)
|
||||
return 0;
|
||||
}
|
||||
|
||||
U0 ICMov(CIntermediateCode *tempi,
|
||||
U0 ICMov(CIntermediateCode *tmpi,
|
||||
CICType t1,I64 r1,I64 d1,CICType t2,I64 r2,I64 d2,I64 ip)
|
||||
{
|
||||
I64 i,cnt1,cnt2,b1_rex,b2_rex,b1,b2,b1_modr,b2_modr,
|
||||
b1_r1,b1_r2,b2_r1,b2_r2,last_start=tempi->ic_cnt;
|
||||
CIntermediateCode *tempil1;
|
||||
Bool old_lock=Btr(&tempi->ic_flags,ICf_LOCK);
|
||||
b1_r1,b1_r2,b2_r1,b2_r2,last_start=tmpi->ic_cnt;
|
||||
CIntermediateCode *tmpil1;
|
||||
Bool old_lock=Btr(&tmpi->ic_flags,ICf_LOCK);
|
||||
switch (Bsr(t1)) {
|
||||
case MDf_REG:
|
||||
if (t2&MDF_IMM) {
|
||||
if (!d2)
|
||||
ICZero(tempi,r1);
|
||||
ICZero(tmpi,r1);
|
||||
else if (0<=d2<=MAX_U8) {
|
||||
ICZero(tempi,r1);
|
||||
ICZero(tmpi,r1);
|
||||
if (r1>7)
|
||||
ICU24(tempi,d2<<16+(0xB0+r1&7)<<8+0x41);
|
||||
ICU24(tmpi,d2<<16+(0xB0+r1&7)<<8+0x41);
|
||||
else if (r1>3)
|
||||
ICU24(tempi,d2<<16+(0xB0+r1)<<8+0x40);
|
||||
ICU24(tmpi,d2<<16+(0xB0+r1)<<8+0x40);
|
||||
else
|
||||
ICU16(tempi,d2<<8+0xB0+r1);
|
||||
ICU16(tmpi,d2<<8+0xB0+r1);
|
||||
} else if (MIN_I8<=d2<0) {
|
||||
if (r1>7) {
|
||||
r1&=7;
|
||||
ICU24(tempi,d2<<16+(0xB0+r1)<<8+0x41);
|
||||
ICU32(tempi,0xC0BE0F4D+r1<<24+r1<<27);
|
||||
ICU24(tmpi,d2<<16+(0xB0+r1)<<8+0x41);
|
||||
ICU32(tmpi,0xC0BE0F4D+r1<<24+r1<<27);
|
||||
} else {
|
||||
if (r1>3)
|
||||
ICU24(tempi,d2<<16+(0xB0+r1)<<8+0x40);
|
||||
ICU24(tmpi,d2<<16+(0xB0+r1)<<8+0x40);
|
||||
else
|
||||
ICU16(tempi,d2<<8+0xB0+r1);
|
||||
ICU32(tempi,0xC0BE0F48+r1<<24+r1<<27);
|
||||
ICU16(tmpi,d2<<8+0xB0+r1);
|
||||
ICU32(tmpi,0xC0BE0F48+r1<<24+r1<<27);
|
||||
}
|
||||
} else if (0<=d2<=MAX_U32) {
|
||||
if (r1>7) {
|
||||
r1&=7;
|
||||
ICU16(tempi,(0xB8+r1)<<8+0x41);
|
||||
ICU32(tempi,d2);
|
||||
ICU16(tmpi,(0xB8+r1)<<8+0x41);
|
||||
ICU32(tmpi,d2);
|
||||
} else {
|
||||
ICU8(tempi,0xB8+r1);
|
||||
ICU32(tempi,d2);
|
||||
ICU8(tmpi,0xB8+r1);
|
||||
ICU32(tmpi,d2);
|
||||
}
|
||||
} else if (MIN_I32<=d2<0) {
|
||||
if (r1>7) {
|
||||
r1&=7;
|
||||
ICU16(tempi,(0xB8+r1)<<8+0x41);
|
||||
ICU32(tempi,d2);
|
||||
ICU24(tempi,0xC0634D+r1<<16+r1<<19);
|
||||
ICU16(tmpi,(0xB8+r1)<<8+0x41);
|
||||
ICU32(tmpi,d2);
|
||||
ICU24(tmpi,0xC0634D+r1<<16+r1<<19);
|
||||
} else {
|
||||
ICU8(tempi,0xB8+r1);
|
||||
ICU32(tempi,d2);
|
||||
ICU24(tempi,0xC06348+r1<<16+r1<<19);
|
||||
ICU8(tmpi,0xB8+r1);
|
||||
ICU32(tmpi,d2);
|
||||
ICU24(tmpi,0xC06348+r1<<16+r1<<19);
|
||||
}
|
||||
} else {
|
||||
i=0xB848;
|
||||
@@ -481,11 +481,11 @@ U0 ICMov(CIntermediateCode *tempi,
|
||||
i++;
|
||||
r1&=7;
|
||||
}
|
||||
ICU16(tempi,i+r1<<8);
|
||||
ICU64(tempi,d2);
|
||||
ICU16(tmpi,i+r1<<8);
|
||||
ICU64(tmpi,d2);
|
||||
}
|
||||
} else if (t2&MDF_STK)
|
||||
ICPop(tempi,t1,r1,d1,ip);
|
||||
ICPop(tmpi,t1,r1,d1,ip);
|
||||
else {
|
||||
if (r1==r2 && t2&MDF_REG)
|
||||
goto move_done;
|
||||
@@ -494,39 +494,39 @@ U0 ICMov(CIntermediateCode *tempi,
|
||||
i=ICModr1(r1,t2,r2,d2);
|
||||
if (t2.raw_type!=RT_U32)
|
||||
i|=0x4800;
|
||||
ICRex(tempi,i.u8[1]);
|
||||
ICRex(tmpi,i.u8[1]);
|
||||
switch (t2.raw_type) {
|
||||
case RT_I8:
|
||||
ICU24(tempi,i.u8[2]<<16+0xBE0F);
|
||||
ICU24(tmpi,i.u8[2]<<16+0xBE0F);
|
||||
break;
|
||||
case RT_I16:
|
||||
ICU24(tempi,i.u8[2]<<16+0xBF0F);
|
||||
ICU24(tmpi,i.u8[2]<<16+0xBF0F);
|
||||
break;
|
||||
case RT_I32:
|
||||
ICU16(tempi,i.u8[2]<<8+0x63);
|
||||
ICU16(tmpi,i.u8[2]<<8+0x63);
|
||||
break;
|
||||
|
||||
case RT_U8:
|
||||
ICU24(tempi,i.u8[2]<<16+0xB60F);
|
||||
ICU24(tmpi,i.u8[2]<<16+0xB60F);
|
||||
break;
|
||||
case RT_U16:
|
||||
ICU24(tempi,i.u8[2]<<16+0xB70F);
|
||||
ICU24(tmpi,i.u8[2]<<16+0xB70F);
|
||||
break;
|
||||
default:
|
||||
ICU16(tempi,i.u8[2]<<8+0x8B);
|
||||
ICU16(tmpi,i.u8[2]<<8+0x8B);
|
||||
}
|
||||
ICModr2(tempi,i,d2,ip+4);
|
||||
ICModr2(tmpi,i,d2,ip+4);
|
||||
}
|
||||
break;
|
||||
case MDf_STK:
|
||||
if (tempi->ic_flags&ICF_PUSH_CMP)
|
||||
ICPopRegs(tempi,1<<REG_RBX);
|
||||
if (tmpi->ic_flags&ICF_PUSH_CMP)
|
||||
ICPopRegs(tmpi,1<<REG_RBX);
|
||||
if (t1.raw_type<t2.raw_type)
|
||||
ICPush(tempi,t2&MDG_MASK+t1.raw_type,r2,d2,ip);
|
||||
ICPush(tmpi,t2&MDG_MASK+t1.raw_type,r2,d2,ip);
|
||||
else
|
||||
ICPush(tempi,t2,r2,d2,ip);
|
||||
if (tempi->ic_flags&ICF_PUSH_CMP)
|
||||
ICPushRegs(tempi,1<<REG_RBX);
|
||||
ICPush(tmpi,t2,r2,d2,ip);
|
||||
if (tmpi->ic_flags&ICF_PUSH_CMP)
|
||||
ICPushRegs(tmpi,1<<REG_RBX);
|
||||
break;
|
||||
case MDf_DISP:
|
||||
case MDf_RIP_DISP32:
|
||||
@@ -536,22 +536,22 @@ U0 ICMov(CIntermediateCode *tempi,
|
||||
switch (t1.raw_type) {
|
||||
case RT_I8:
|
||||
case RT_U8:
|
||||
ICRex(tempi,i.u8[1]);
|
||||
ICU16(tempi,i.u8[2]<<8+0xC6);
|
||||
ICRex(tmpi,i.u8[1]);
|
||||
ICU16(tmpi,i.u8[2]<<8+0xC6);
|
||||
break;
|
||||
case RT_U16:
|
||||
case RT_I16:
|
||||
ICOpSizeRex(tempi,i.u8[1]);
|
||||
ICU16(tempi,i.u8[2]<<8+0xC7);
|
||||
ICOpSizeRex(tmpi,i.u8[1]);
|
||||
ICU16(tmpi,i.u8[2]<<8+0xC7);
|
||||
break;
|
||||
default:
|
||||
ICRex(tempi,i.u8[1]);
|
||||
ICU16(tempi,i.u8[2]<<8+0xC7);
|
||||
ICRex(tmpi,i.u8[1]);
|
||||
ICU16(tmpi,i.u8[2]<<8+0xC7);
|
||||
}
|
||||
if (i.u8[0]!=MODR_RIP_REL)
|
||||
ICModr2(tempi,i,d1,);
|
||||
ICModr2(tmpi,i,d1,);
|
||||
else {
|
||||
i=d1-(ip+tempi->ic_cnt+4);
|
||||
i=d1-(ip+tmpi->ic_cnt+4);
|
||||
switch (t1.raw_type) {
|
||||
case RT_I8:
|
||||
case RT_U8:
|
||||
@@ -564,62 +564,62 @@ U0 ICMov(CIntermediateCode *tempi,
|
||||
default:
|
||||
i-=4;
|
||||
}
|
||||
ICU32(tempi,i);
|
||||
tempi->ic_flags&=~ICF_CODE_FINAL;
|
||||
ICU32(tmpi,i);
|
||||
tmpi->ic_flags&=~ICF_CODE_FINAL;
|
||||
}
|
||||
|
||||
switch (t1.raw_type) {
|
||||
case RT_I8:
|
||||
case RT_U8:
|
||||
ICU8(tempi,d2);
|
||||
ICU8(tmpi,d2);
|
||||
break;
|
||||
case RT_I16:
|
||||
case RT_U16:
|
||||
ICU16(tempi,d2);
|
||||
ICU16(tmpi,d2);
|
||||
break;
|
||||
default:
|
||||
ICU32(tempi,d2);
|
||||
ICU32(tmpi,d2);
|
||||
}
|
||||
} else {
|
||||
if (t2&MDF_REG)
|
||||
ICSlashOp(tempi,t1,r1,d1,r2+SLASH_OP_MOV,ip);
|
||||
ICSlashOp(tmpi,t1,r1,d1,r2+SLASH_OP_MOV,ip);
|
||||
else {
|
||||
ICMov(tempi,MDF_REG+RT_I64,REG_RBX,0,t2,r2,d2,ip);
|
||||
ICMov(tempi,t1,r1,d1,MDF_REG+RT_I64,REG_RBX,0,ip);
|
||||
ICMov(tmpi,MDF_REG+RT_I64,REG_RBX,0,t2,r2,d2,ip);
|
||||
ICMov(tmpi,t1,r1,d1,MDF_REG+RT_I64,REG_RBX,0,ip);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
move_done:
|
||||
if (!((t1|t2)&(MDF_STK|MDF_RIP_DISP32))) {
|
||||
tempil1=tempi;
|
||||
if (tempi->ic_last_start<0 && (tempil1=OptLag1(tempi)) &&
|
||||
tempil1->ic_last_start<0)
|
||||
tempil1=NULL;
|
||||
if (tempil1) {
|
||||
if (tempil1==tempi)
|
||||
cnt1=last_start-tempil1->ic_last_start;
|
||||
tmpil1=tmpi;
|
||||
if (tmpi->ic_last_start<0 && (tmpil1=OptLag1(tmpi)) &&
|
||||
tmpil1->ic_last_start<0)
|
||||
tmpil1=NULL;
|
||||
if (tmpil1) {
|
||||
if (tmpil1==tmpi)
|
||||
cnt1=last_start-tmpil1->ic_last_start;
|
||||
else {
|
||||
if (!(tempil1->ic_flags&ICF_CODE_FINAL))
|
||||
tempi->ic_flags&=~ICF_CODE_FINAL;
|
||||
if (!(tmpil1->ic_flags&ICF_CODE_FINAL))
|
||||
tmpi->ic_flags&=~ICF_CODE_FINAL;
|
||||
if (last_start)
|
||||
cnt1=0;
|
||||
else
|
||||
cnt1=tempil1->ic_cnt-tempil1->ic_last_start;
|
||||
cnt1=tmpil1->ic_cnt-tmpil1->ic_last_start;
|
||||
}
|
||||
cnt2=tempi->ic_cnt-last_start;
|
||||
cnt2=tmpi->ic_cnt-last_start;
|
||||
if (cnt1 && cnt1==cnt2) {
|
||||
b1_rex=tempil1->ic_body[tempil1->ic_last_start];
|
||||
b2_rex=tempi->ic_body[last_start];
|
||||
b1_rex=tmpil1->ic_body[tmpil1->ic_last_start];
|
||||
b2_rex=tmpi->ic_body[last_start];
|
||||
if (b1_rex&0x48==0x48 && b2_rex&0x48==0x48) {
|
||||
for (i=1;i<cnt1;i++)
|
||||
if ((b1=tempil1->ic_body[tempil1->ic_last_start+i])==
|
||||
(b2=tempi->ic_body[last_start+i])) {
|
||||
if ((b1=tmpil1->ic_body[tmpil1->ic_last_start+i])==
|
||||
(b2=tmpi->ic_body[last_start+i])) {
|
||||
if (i==1 && (b2==0x89 || b2==0x8B)) {
|
||||
b1_modr=tempil1->ic_body[tempil1->ic_last_start+2];
|
||||
b1_modr=tmpil1->ic_body[tmpil1->ic_last_start+2];
|
||||
b1_r1=b1_modr&7 +Bt(&b1_rex,0)<<3;
|
||||
b1_r2=b1_modr>>3&7+Bt(&b1_rex,2)<<3;
|
||||
b2_modr=tempi->ic_body[last_start+2];
|
||||
b2_modr=tmpi->ic_body[last_start+2];
|
||||
b2_r1=b2_modr&7 +Bt(&b2_rex,0)<<3;
|
||||
b2_r2=b2_modr>>3&7+Bt(&b2_rex,2)<<3;
|
||||
if (cnt1==3 && b2_modr&0xC0==0xC0) {
|
||||
@@ -638,10 +638,10 @@ move_done:
|
||||
else if (b2!=0x89 && b2!=0x8B)
|
||||
break;
|
||||
else {
|
||||
b1_modr=tempil1->ic_body[tempil1->ic_last_start+2];
|
||||
b1_modr=tmpil1->ic_body[tmpil1->ic_last_start+2];
|
||||
b1_r1=b1_modr&7 +Bt(&b1_rex,0)<<3;
|
||||
b1_r2=b1_modr>>3&7+Bt(&b1_rex,2)<<3;
|
||||
b2_modr=tempi->ic_body[last_start+2];
|
||||
b2_modr=tmpi->ic_body[last_start+2];
|
||||
b2_r1=b2_modr&7 +Bt(&b2_rex,0)<<3;
|
||||
b2_r2=b2_modr>>3&7+Bt(&b2_rex,2)<<3;
|
||||
if (cnt1==3 && b2_modr&0xC0==0xC0) {
|
||||
@@ -663,62 +663,62 @@ move_done:
|
||||
}
|
||||
if (i==cnt1) {
|
||||
move_redundant:
|
||||
tempi->ic_cnt=last_start;
|
||||
tmpi->ic_cnt=last_start;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (tempi->ic_cnt>last_start>tempi->ic_last_start)
|
||||
tempi->ic_last_start=last_start;
|
||||
BEqu(&tempi->ic_flags,ICf_LOCK,old_lock);
|
||||
if (tmpi->ic_cnt>last_start>tmpi->ic_last_start)
|
||||
tmpi->ic_last_start=last_start;
|
||||
BEqu(&tmpi->ic_flags,ICf_LOCK,old_lock);
|
||||
}
|
||||
|
||||
U0 ICLea(CIntermediateCode *tempi,CICType t1,I64 r1,I64 d1,
|
||||
U0 ICLea(CIntermediateCode *tmpi,CICType t1,I64 r1,I64 d1,
|
||||
CICType t2,I64 r2,I64 d2,CCmpCtrl *cc,U8 *buf,I64 ip)
|
||||
{
|
||||
I64 i;
|
||||
CAOTAbsAddr *tempa;
|
||||
CAOTAbsAddr *tmpa;
|
||||
switch (Bsr(t1)) {
|
||||
case MDf_REG:
|
||||
i=ICModr1(r1,t2,r2,d2);
|
||||
i.u8[1]|=0x48;
|
||||
ICU24(tempi,i.u8[2]<<16+0x8D00+i.u8[1]);
|
||||
ICModr2(tempi,i,d2,ip+4);
|
||||
ICU24(tmpi,i.u8[2]<<16+0x8D00+i.u8[1]);
|
||||
ICModr2(tmpi,i,d2,ip+4);
|
||||
break;
|
||||
case MDf_STK:
|
||||
if (t2&MDF_RIP_DISP32) {
|
||||
ICU8(tempi,0x68);
|
||||
ICU32(tempi,d2);
|
||||
ICU8(tmpi,0x68);
|
||||
ICU32(tmpi,d2);
|
||||
if (cc->flags&CCF_AOT_COMPILE && buf && !(cc->flags&CCF_NO_ABSS)) {
|
||||
tempa=CAlloc(sizeof(CAOTAbsAddr));
|
||||
tempa->next=cc->aotc->abss;
|
||||
tempa->type=AAT_ADD_U32;
|
||||
cc->aotc->abss=tempa;
|
||||
tempa->ip=ip+tempi->ic_cnt-4;
|
||||
tmpa=CAlloc(sizeof(CAOTAbsAddr));
|
||||
tmpa->next=cc->aotc->abss;
|
||||
tmpa->type=AAT_ADD_U32;
|
||||
cc->aotc->abss=tmpa;
|
||||
tmpa->ip=ip+tmpi->ic_cnt-4;
|
||||
}
|
||||
tempi->ic_flags&=~ICF_CODE_FINAL;
|
||||
tmpi->ic_flags&=~ICF_CODE_FINAL;
|
||||
break;
|
||||
} // Fall thru
|
||||
default:
|
||||
ICLea(tempi,MDF_REG+RT_I64,REG_RCX,0,t2,r2,d2,cc,buf,ip);
|
||||
ICMov(tempi,t1,r1,d1,MDF_REG+RT_I64,REG_RCX,0,ip);
|
||||
ICLea(tmpi,MDF_REG+RT_I64,REG_RCX,0,t2,r2,d2,cc,buf,ip);
|
||||
ICMov(tmpi,t1,r1,d1,MDF_REG+RT_I64,REG_RCX,0,ip);
|
||||
}
|
||||
}
|
||||
|
||||
U0 ICDeref(CIntermediateCode *tempi,I64 ip)
|
||||
U0 ICDeref(CIntermediateCode *tmpi,I64 ip)
|
||||
{
|
||||
CICType t;
|
||||
t=tempi->r.type.raw_type;
|
||||
if (t>tempi->a1_type_pointed_to)
|
||||
t=tempi->a1_type_pointed_to;
|
||||
if (tempi->a1.type&MDF_REG)
|
||||
ICMov(tempi,tempi->r.type,tempi->r.reg,tempi->r.disp,
|
||||
MDF_DISP+t,tempi->a1.reg,tempi->a1.disp,ip);
|
||||
t=tmpi->r.type.raw_type;
|
||||
if (t>tmpi->a1_type_pointed_to)
|
||||
t=tmpi->a1_type_pointed_to;
|
||||
if (tmpi->a1.type&MDF_REG)
|
||||
ICMov(tmpi,tmpi->r.type,tmpi->r.reg,tmpi->r.disp,
|
||||
MDF_DISP+t,tmpi->a1.reg,tmpi->a1.disp,ip);
|
||||
else {
|
||||
ICMov(tempi,MDF_REG+RT_I64,REG_RCX,0,
|
||||
tempi->a1.type,tempi->a1.reg,tempi->a1.disp,ip);
|
||||
ICMov(tempi,tempi->r.type,tempi->r.reg,tempi->r.disp,
|
||||
ICMov(tmpi,MDF_REG+RT_I64,REG_RCX,0,
|
||||
tmpi->a1.type,tmpi->a1.reg,tmpi->a1.disp,ip);
|
||||
ICMov(tmpi,tmpi->r.type,tmpi->r.reg,tmpi->r.disp,
|
||||
MDF_DISP+t,REG_RCX,0,ip);
|
||||
}
|
||||
}
|
||||
+36
-36
@@ -101,9 +101,9 @@ U0 UndefinedExtern()
|
||||
throw('UndefExt');
|
||||
}
|
||||
|
||||
U0 UnusedExternWarning(CCmpCtrl *cc,CHashClass *tempc)
|
||||
U0 UnusedExternWarning(CCmpCtrl *cc,CHashClass *tmpc)
|
||||
{
|
||||
PrintWarn("Unused extern '%s'\n",tempc->str);
|
||||
PrintWarn("Unused extern '%s'\n",tmpc->str);
|
||||
cc->warning_cnt++;
|
||||
}
|
||||
|
||||
@@ -181,73 +181,73 @@ U0 ICArgPut(CICArg *a,I64 type_pointed_to)
|
||||
'' CH_SPACE;
|
||||
}
|
||||
|
||||
U0 ICPut(CCmpCtrl *cc,CIntermediateCode *tempi)
|
||||
U0 ICPut(CCmpCtrl *cc,CIntermediateCode *tmpi)
|
||||
{
|
||||
I64 opcode=tempi->ic_code,i;
|
||||
I64 opcode=tmpi->ic_code,i;
|
||||
if (opcode>=IC_END_EXP && opcode!=IC_NOP2) {
|
||||
"%15ts %016X ",intermediate_code_table[opcode].name,tempi->ic_data;
|
||||
"%15ts %016X ",intermediate_code_table[opcode].name,tmpi->ic_data;
|
||||
if (cc->pass) {
|
||||
if (tempi->r.type.mode) {
|
||||
if (tmpi->r.type.mode) {
|
||||
"$$PURPLE$$R:$$FG$$";
|
||||
ICArgPut(&tempi->r,0);
|
||||
ICArgPut(&tmpi->r,0);
|
||||
}
|
||||
if (tempi->a1.type.mode) {
|
||||
if (tmpi->a1.type.mode) {
|
||||
"$$PURPLE$$A1:$$FG$$";
|
||||
if (intermediate_code_table[tempi->ic_code].type==IST_DEREF ||
|
||||
intermediate_code_table[tempi->ic_code].type==IST_ASSIGN)
|
||||
ICArgPut(&tempi->a1,tempi->a1_type_pointed_to);
|
||||
if (intermediate_code_table[tmpi->ic_code].type==IST_DEREF ||
|
||||
intermediate_code_table[tmpi->ic_code].type==IST_ASSIGN)
|
||||
ICArgPut(&tmpi->a1,tmpi->a1_type_pointed_to);
|
||||
else
|
||||
ICArgPut(&tempi->a1,0);
|
||||
ICArgPut(&tmpi->a1,0);
|
||||
}
|
||||
if (tempi->a2.type.mode) {
|
||||
if (tmpi->a2.type.mode) {
|
||||
"$$PURPLE$$A2:$$FG$$";
|
||||
ICArgPut(&tempi->a2,0);
|
||||
ICArgPut(&tmpi->a2,0);
|
||||
}
|
||||
"$$PURPLE$$:$$FG$$";
|
||||
}
|
||||
ICClassPut(tempi->ic_class);
|
||||
if (tempi->ic_flags & ICF_LOCK)
|
||||
ICClassPut(tmpi->ic_class);
|
||||
if (tmpi->ic_flags & ICF_LOCK)
|
||||
"$$BROWN$$lock$$FG$$ ";
|
||||
if (tempi->ic_flags & ICF_A2_TO_F64)
|
||||
if (tmpi->ic_flags & ICF_A2_TO_F64)
|
||||
"$$LTBLUE$$a2d$$FG$$ ";
|
||||
if (tempi->ic_flags & ICF_A2_TO_INT)
|
||||
if (tmpi->ic_flags & ICF_A2_TO_INT)
|
||||
"$$GREEN$$a2i$$FG$$ ";
|
||||
if (tempi->ic_flags & ICF_A1_TO_F64)
|
||||
if (tmpi->ic_flags & ICF_A1_TO_F64)
|
||||
"$$LTBLUE$$a1d$$FG$$ ";
|
||||
if (tempi->ic_flags & ICF_A1_TO_INT)
|
||||
if (tmpi->ic_flags & ICF_A1_TO_INT)
|
||||
"$$GREEN$$a1i$$FG$$ ";
|
||||
if (tempi->ic_flags & ICF_R_TO_F64)
|
||||
if (tmpi->ic_flags & ICF_R_TO_F64)
|
||||
"$$LTBLUE$$rd$$FG$$ ";
|
||||
if (tempi->ic_flags & ICF_R_TO_INT)
|
||||
if (tmpi->ic_flags & ICF_R_TO_INT)
|
||||
"$$GREEN$$ri$$FG$$ ";
|
||||
if (tempi->ic_flags & ICF_USE_F64)
|
||||
if (tmpi->ic_flags & ICF_USE_F64)
|
||||
"[F64] ";
|
||||
if (tempi->ic_flags & ICF_USE_UNSIGNED)
|
||||
if (tmpi->ic_flags & ICF_USE_UNSIGNED)
|
||||
"[unsigned] ";
|
||||
if (tempi->ic_flags & ICF_USE_INT)
|
||||
if (tmpi->ic_flags & ICF_USE_INT)
|
||||
"[int] ";
|
||||
if (tempi->ic_flags & ICF_RES_NOT_USED)
|
||||
if (tmpi->ic_flags & ICF_RES_NOT_USED)
|
||||
"NO_RES ";
|
||||
if (tempi->ic_flags & ICF_BY_VAL)
|
||||
if (tmpi->ic_flags & ICF_BY_VAL)
|
||||
"BY_VAL ";
|
||||
if (tempi->ic_flags & ICF_PUSH_RES)
|
||||
if (tmpi->ic_flags & ICF_PUSH_RES)
|
||||
"PUSH ";
|
||||
if (tempi->ic_flags & ICF_PUSH_CMP)
|
||||
if (tmpi->ic_flags & ICF_PUSH_CMP)
|
||||
"PUSH_CMP ";
|
||||
if (tempi->ic_flags & ICF_POP_CMP)
|
||||
if (tmpi->ic_flags & ICF_POP_CMP)
|
||||
"POP_CMP ";
|
||||
if (tempi->ic_flags & ICF_DEL_PREV_INS)
|
||||
if (tmpi->ic_flags & ICF_DEL_PREV_INS)
|
||||
"DEL_PREV ";
|
||||
if (tempi->ic_flags & ICF_PREV_DELETED)
|
||||
if (tmpi->ic_flags & ICF_PREV_DELETED)
|
||||
"PREV_DEL ";
|
||||
for (i=0;i<3;i++) {
|
||||
if (Bt(&tempi->ic_flags,ICf_DONT_PUSH_FLOAT0+i))
|
||||
if (Bt(&tmpi->ic_flags,ICf_DONT_PUSH_FLOAT0+i))
|
||||
"DONT_PUSH#%d ",i;
|
||||
if (Bt(&tempi->ic_flags,ICf_DONT_POP_FLOAT0+i))
|
||||
if (Bt(&tmpi->ic_flags,ICf_DONT_POP_FLOAT0+i))
|
||||
"DONT_POP#%d ",i;
|
||||
}
|
||||
if (tempi->ic_flags & ICF_ALT_TEMPLATE)
|
||||
"ALT_TEMP ";
|
||||
if (tmpi->ic_flags & ICF_ALT_TEMPLATE)
|
||||
"ALT_TMP ";
|
||||
'\n';
|
||||
}
|
||||
}
|
||||
+9
-9
@@ -8,7 +8,7 @@ import CDocEntry *DocPutLine(CDoc *doc,CDocEntry *doc_e);
|
||||
import I64 DocSize(CDoc *doc);
|
||||
import Bool DocWrite(CDoc *doc,Bool prompt=FALSE);
|
||||
extern U8 *CmdLinePmt();
|
||||
extern I64 HashEntrySize2(CHashSrcSym *temph);
|
||||
extern I64 HashEntrySize2(CHashSrcSym *tmph);
|
||||
extern Bool IsLexExpression2Bin(CCmpCtrl *cc,U8 **_machine_code);
|
||||
extern I64 Lex(CCmpCtrl *cc);
|
||||
extern I64 LexExpression(CCmpCtrl *cc);
|
||||
@@ -24,21 +24,21 @@ extern I64 OptPass789A(
|
||||
extern CHashClass *PrsClass(
|
||||
CCmpCtrl *cc,I64 keyword,I64 fsp_flags,Bool is_extern);
|
||||
extern CHashFun *PrsFunJoin(
|
||||
CCmpCtrl *cc,CHashClass *temp_return,U8 *name,I64 fsp_flags);
|
||||
CCmpCtrl *cc,CHashClass *tmp_return,U8 *name,I64 fsp_flags);
|
||||
extern I64 PrsKeyWord(CCmpCtrl *cc);
|
||||
extern Bool PrsStmt(CCmpCtrl *cc,I64 try_cnt=0,
|
||||
CCodeMisc *lb_break=NULL,I64 cmp_flags=CMPF_PRS_SEMICOLON);
|
||||
extern U0 PrsStreamBlk(CCmpCtrl *cc);
|
||||
extern CHashClass *PrsType(CCmpCtrl *cc,CHashClass **_tempc1,
|
||||
I64 *_mode,CMemberLst *tempm,U8 **_ident,CHashFun **_fun_ptr,
|
||||
CHashExport **_tempex,CArrayDim *tempad,I64 fsp_flags);
|
||||
extern CHashClass *PrsType(CCmpCtrl *cc,CHashClass **_tmpc1,
|
||||
I64 *_mode,CMemberLst *tmpm,U8 **_ident,CHashFun **_fun_ptr,
|
||||
CHashExport **_tmpex,CArrayDim *tmpad,I64 fsp_flags);
|
||||
extern I64 PrsUnaryModifier(CCmpCtrl *cc,CPrsStk *ps,
|
||||
CMemberLst **_local_var,CArrayDim **_tempad,I64 *unary_post_prec);
|
||||
CMemberLst **_local_var,CArrayDim **_tmpad,I64 *unary_post_prec);
|
||||
extern I64 PrsUnaryTerm(
|
||||
CCmpCtrl *cc,CPrsStk *ps,CMemberLst **_local_var,CArrayDim **_tempad,
|
||||
CCmpCtrl *cc,CPrsStk *ps,CMemberLst **_local_var,CArrayDim **_tmpad,
|
||||
I64 *max_prec,I64 *unary_pre_prec,I64 *paren_prec);
|
||||
extern U0 PrsVarInit2(CCmpCtrl *cc,U8 **_dst,CHashClass *tempc,
|
||||
CArrayDim *tempad,U8 *data_addr_ip,U8 **_base,Bool data_heap,I64 pass);
|
||||
extern U0 PrsVarInit2(CCmpCtrl *cc,U8 **_dst,CHashClass *tmpc,
|
||||
CArrayDim *tmpad,U8 *data_addr_ip,U8 **_base,Bool data_heap,I64 pass);
|
||||
_extern CMP_TEMPLATES U32 cmp_templates[1];
|
||||
_extern CMP_TEMPLATES_DONT_POP U32 cmp_templates_dont_pop[1];
|
||||
_extern CMP_TEMPLATES_DONT_PUSH2 U32 cmp_templates_dont_push2[1];
|
||||
|
||||
+61
-61
@@ -1,85 +1,85 @@
|
||||
I64 HashEntrySize(CHashSrcSym *temph)
|
||||
I64 HashEntrySize(CHashSrcSym *tmph)
|
||||
{//Logical size of a std system hash entry.
|
||||
CDbgInfo *dbg_info;
|
||||
CBinFile *bfh;
|
||||
switch (HashTypeNum(temph)) {
|
||||
switch (HashTypeNum(tmph)) {
|
||||
case HTt_DEFINE_STR:
|
||||
return MSize(temph(CHashDefineStr *)->data);
|
||||
return MSize(tmph(CHashDefineStr *)->data);
|
||||
case HTt_GLBL_VAR:
|
||||
case HTt_CLASS:
|
||||
case HTt_INTERNAL_TYPE:
|
||||
return temph(CHashClass *)->size;
|
||||
return tmph(CHashClass *)->size;
|
||||
case HTt_FUN:
|
||||
if (dbg_info=temph->dbg_info)
|
||||
if (dbg_info=tmph->dbg_info)
|
||||
return dbg_info->body[dbg_info->max_line+1-dbg_info->min_line]
|
||||
-dbg_info->body[0];
|
||||
else
|
||||
return -1;
|
||||
case HTt_FILE:
|
||||
return MSize(temph(CHashGeneric *)->user_data0);
|
||||
return MSize(tmph(CHashGeneric *)->user_data0);
|
||||
case HTt_MODULE:
|
||||
if (StrCmp(temph->str,KERNEL_MODULE_NAME))
|
||||
return MSize(temph(CHashGeneric *)->user_data0);
|
||||
if (StrCmp(tmph->str,KERNEL_MODULE_NAME))
|
||||
return MSize(tmph(CHashGeneric *)->user_data0);
|
||||
else {
|
||||
bfh=sys_boot_base-sizeof(CBinFile);
|
||||
return bfh->file_size;
|
||||
}
|
||||
case HTt_WORD:
|
||||
return StrLen(temph->str);
|
||||
return StrLen(tmph->str);
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
I64 HashEntrySize2(CHashSrcSym *temph)
|
||||
I64 HashEntrySize2(CHashSrcSym *tmph)
|
||||
{//Memory size of a std system hash entry.
|
||||
CDbgInfo *dbg_info;
|
||||
I64 res=MSize2(temph);
|
||||
if (!(temph->type&HTT_DICT_WORD))
|
||||
res+=MSize2(temph->str);
|
||||
if (temph->type & HTG_SRC_SYM) {
|
||||
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))
|
||||
res+=MSize2(temph->dbg_info);
|
||||
if (temph->type & HTT_CLASS)
|
||||
res+=MemberLstSize(temph);
|
||||
else if (temph->type & HTT_FUN) {
|
||||
res+=MemberLstSize(temph);
|
||||
if (dbg_info=temph->dbg_info)
|
||||
I64 res=MSize2(tmph);
|
||||
if (!(tmph->type&HTT_DICT_WORD))
|
||||
res+=MSize2(tmph->str);
|
||||
if (tmph->type & HTG_SRC_SYM) {
|
||||
res+=MSize2(tmph->src_link);
|
||||
res+=MSize2(tmph->idx);
|
||||
res+=MSize2(tmph->import_name);
|
||||
res+=LinkedLstSize(tmph->ie_lst);
|
||||
if (tmph->type & (HTT_FUN | HTT_EXPORT_SYS_SYM))
|
||||
res+=MSize2(tmph->dbg_info);
|
||||
if (tmph->type & HTT_CLASS)
|
||||
res+=MemberLstSize(tmph);
|
||||
else if (tmph->type & HTT_FUN) {
|
||||
res+=MemberLstSize(tmph);
|
||||
if (dbg_info=tmph->dbg_info)
|
||||
//This should be $LK,"MSize",A="MN:MSize"$() but it would crash on AOT .BIN.Z file funs.
|
||||
res+=dbg_info->body[dbg_info->max_line+1-dbg_info->min_line]
|
||||
-dbg_info->body[0];
|
||||
} else if (temph->type&HTT_DEFINE_STR)
|
||||
res+=MSize2(temph(CHashDefineStr *)->data);
|
||||
else if (temph->type & HTT_GLBL_VAR) {
|
||||
res+=LinkedLstSize(temph(CHashGlblVar *)->dim.next);
|
||||
if (!(temph(CHashGlblVar *)->flags&GVF_ALIAS))
|
||||
res+=MSize2(temph(CHashGlblVar *)->data_addr);
|
||||
if (temph(CHashGlblVar *)->fun_ptr)
|
||||
res+=HashEntrySize2(temph(CHashGlblVar *)->fun_ptr
|
||||
-temph(CHashGlblVar *)->fun_ptr->ptr_stars_cnt);
|
||||
} else if (tmph->type&HTT_DEFINE_STR)
|
||||
res+=MSize2(tmph(CHashDefineStr *)->data);
|
||||
else if (tmph->type & HTT_GLBL_VAR) {
|
||||
res+=LinkedLstSize(tmph(CHashGlblVar *)->dim.next);
|
||||
if (!(tmph(CHashGlblVar *)->flags&GVF_ALIAS))
|
||||
res+=MSize2(tmph(CHashGlblVar *)->data_addr);
|
||||
if (tmph(CHashGlblVar *)->fun_ptr)
|
||||
res+=HashEntrySize2(tmph(CHashGlblVar *)->fun_ptr
|
||||
-tmph(CHashGlblVar *)->fun_ptr->ptr_stars_cnt);
|
||||
}
|
||||
} else if (temph->type & HTT_FILE)
|
||||
res+=MSize2(temph(CHashGeneric *)->user_data0);
|
||||
else if (temph->type & HTT_MODULE &&
|
||||
StrCmp(temph->str,KERNEL_MODULE_NAME))
|
||||
res+=MSize2(temph(CHashGeneric *)->user_data0);
|
||||
} else if (tmph->type & HTT_FILE)
|
||||
res+=MSize2(tmph(CHashGeneric *)->user_data0);
|
||||
else if (tmph->type & HTT_MODULE &&
|
||||
StrCmp(tmph->str,KERNEL_MODULE_NAME))
|
||||
res+=MSize2(tmph(CHashGeneric *)->user_data0);
|
||||
return res;
|
||||
}
|
||||
|
||||
I64 HashTableSize2(CHashTable *table)
|
||||
{//Memory size of std system hash table and all entries.
|
||||
I64 i,res=0;
|
||||
CHashSrcSym *temph;
|
||||
CHashSrcSym *tmph;
|
||||
if (!table)
|
||||
return 0;
|
||||
for (i=0;i<=table->mask;i++) {
|
||||
temph=table->body[i];
|
||||
while (temph) {
|
||||
res+=HashEntrySize2(temph);
|
||||
temph=temph->next;
|
||||
tmph=table->body[i];
|
||||
while (tmph) {
|
||||
res+=HashEntrySize2(tmph);
|
||||
tmph=tmph->next;
|
||||
}
|
||||
}
|
||||
res+=MSize2(table->body);
|
||||
@@ -89,23 +89,23 @@ I64 HashTableSize2(CHashTable *table)
|
||||
|
||||
U0 MapFileWrite(CHashTable *h,U8 *map_name,U8 drv_let)
|
||||
{
|
||||
CHashSrcSym *temph;
|
||||
CHashSrcSym *tmph;
|
||||
I64 i,size;
|
||||
U8 *src_link;
|
||||
CDoc *doc;
|
||||
CDocBin *tempb;
|
||||
CDocBin *tmpb;
|
||||
CDbgInfo *dbg_info;
|
||||
|
||||
doc=DocNew(map_name);
|
||||
doc->flags|=DOCF_NO_CURSOR;
|
||||
for (i=0;i<=h->mask;i++) {
|
||||
temph=h->body[i];
|
||||
while (temph) {
|
||||
if (temph->src_link && !(temph->type & (HTF_IMPORT | HTF_PRIVATE))) {
|
||||
src_link=StrNew(temph->src_link);
|
||||
tmph=h->body[i];
|
||||
while (tmph) {
|
||||
if (tmph->src_link && !(tmph->type & (HTF_IMPORT | HTF_PRIVATE))) {
|
||||
src_link=StrNew(tmph->src_link);
|
||||
if (drv_let && StrLen(src_link)>=4)
|
||||
src_link[3]=drv_let;
|
||||
if (dbg_info=temph->dbg_info) {
|
||||
if (dbg_info=tmph->dbg_info) {
|
||||
size=offset(CDbgInfo.body)+
|
||||
sizeof(U32)*(dbg_info->max_line+2-dbg_info->min_line);
|
||||
if (size>MSize(dbg_info)) {
|
||||
@@ -113,26 +113,26 @@ U0 MapFileWrite(CHashTable *h,U8 *map_name,U8 drv_let)
|
||||
dbg_info=NULL;
|
||||
} else {
|
||||
if (dbg_info->min_line<=dbg_info->max_line) {
|
||||
tempb=CAlloc(sizeof(CDocBin));
|
||||
tempb->size=size;
|
||||
tempb->data=MAlloc(size);
|
||||
MemCpy(tempb->data,dbg_info,size);
|
||||
tempb->num=doc->cur_bin_num++;
|
||||
tempb->use_cnt=1;
|
||||
QueIns(tempb,doc->bin_head.last);
|
||||
tmpb=CAlloc(sizeof(CDocBin));
|
||||
tmpb->size=size;
|
||||
tmpb->data=MAlloc(size);
|
||||
MemCpy(tmpb->data,dbg_info,size);
|
||||
tmpb->num=doc->cur_bin_num++;
|
||||
tmpb->use_cnt=1;
|
||||
QueIns(tmpb,doc->bin_head.last);
|
||||
} else
|
||||
dbg_info=NULL;
|
||||
}
|
||||
}
|
||||
if (dbg_info)
|
||||
DocPrint(doc,"$$LK,\"%s\",A=\"%s\",BI=%d$$\n",
|
||||
temph->str,src_link,tempb->num);
|
||||
tmph->str,src_link,tmpb->num);
|
||||
else
|
||||
DocPrint(doc,"$$LK,\"%s\",A=\"%s\"$$\n",temph->str,src_link);
|
||||
DocPrint(doc,"$$LK,\"%s\",A=\"%s\"$$\n",tmph->str,src_link);
|
||||
|
||||
Free(src_link);
|
||||
}
|
||||
temph=temph->next;
|
||||
tmph=tmph->next;
|
||||
}
|
||||
}
|
||||
DocBinsValidate(doc);
|
||||
|
||||
+166
-166
@@ -1,7 +1,7 @@
|
||||
U8 *LexStmt2Bin(CCmpCtrl *cc,I64 *_type,I64 cmp_flags=0)
|
||||
{//Compile one cc stmt to bin code.
|
||||
I64 size,i,j,k,*res=INVALID_PTR;
|
||||
CCodeCtrl *tempcbh;
|
||||
CCodeCtrl *tmpcbh;
|
||||
if (_type) *_type=RT_I64;
|
||||
Btr(&cc->flags,CCf_PASS_TRACE_PRESENT);
|
||||
if (cc->aot_depth==2)
|
||||
@@ -26,8 +26,8 @@ U8 *LexStmt2Bin(CCmpCtrl *cc,I64 *_type,I64 cmp_flags=0)
|
||||
} else //TODO: too dangerous to del Misc?
|
||||
QueDel(&cc->coc.coc_head.next);
|
||||
if (cc->aot_depth==2) {
|
||||
tempcbh=COCPopNoFree(cc);
|
||||
COCAppend(cc,tempcbh);
|
||||
tmpcbh=COCPopNoFree(cc);
|
||||
COCAppend(cc,tmpcbh);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
@@ -37,8 +37,8 @@ CAOT *CmpJoin(CCmpCtrl *cc,I64 cmp_flags,U8 *map_name=NULL,U8 mapfile_drv_let=0)
|
||||
CAOTCtrl *aotc,*old_aot=cc->aotc;
|
||||
I64 i,j,l;
|
||||
U8 *buf;
|
||||
CAOTBinBlk *tempbin;
|
||||
CAOTImportExport *tempie;
|
||||
CAOTBinBlk *tmpbin;
|
||||
CAOTImportExport *tmpie;
|
||||
Bool okay=TRUE;
|
||||
CLexHashTableContext *htc=MAlloc(sizeof(CLexHashTableContext));
|
||||
CAOT *res=CAlloc(sizeof(CAOT)),*parent;
|
||||
@@ -83,10 +83,10 @@ CAOT *CmpJoin(CCmpCtrl *cc,I64 cmp_flags,U8 *map_name=NULL,U8 mapfile_drv_let=0)
|
||||
while (cc->token!=TK_EOF) {
|
||||
buf=LexStmt2Bin(cc,NULL,cmp_flags);
|
||||
if (buf!=INVALID_PTR) {
|
||||
tempie=CAlloc(sizeof(CAOTImportExport));
|
||||
tempie->type=IET_MAIN;
|
||||
tempie->ip=buf;
|
||||
QueIns(tempie,res->last_ie);
|
||||
tmpie=CAlloc(sizeof(CAOTImportExport));
|
||||
tmpie->type=IET_MAIN;
|
||||
tmpie->ip=buf;
|
||||
QueIns(tmpie,res->last_ie);
|
||||
}
|
||||
if (cmp_flags&CMPF_ASM_BLK)
|
||||
break;
|
||||
@@ -126,17 +126,17 @@ CAOT *CmpJoin(CCmpCtrl *cc,I64 cmp_flags,U8 *map_name=NULL,U8 mapfile_drv_let=0)
|
||||
res->buf=aotc->module_org;
|
||||
}
|
||||
res->aot_U8s=aotc->num_bin_U8s;
|
||||
tempbin=aotc->bin;
|
||||
tmpbin=aotc->bin;
|
||||
j=0;
|
||||
l=aotc->num_bin_U8s;
|
||||
while (tempbin) {
|
||||
while (tmpbin) {
|
||||
i=l;
|
||||
if (i>AOT_BIN_BLK_SIZE)
|
||||
i=AOT_BIN_BLK_SIZE;
|
||||
MemCpy(res->buf+j,tempbin->body,i);
|
||||
MemCpy(res->buf+j,tmpbin->body,i);
|
||||
j+=i;
|
||||
l-=i;
|
||||
tempbin=tempbin->next;
|
||||
tmpbin=tmpbin->next;
|
||||
}
|
||||
}
|
||||
LinkedLstDel(aotc->bin);
|
||||
@@ -171,20 +171,20 @@ CAOT *CmpBuf(U8 *buf,U8 *map_name=NULL,
|
||||
return res;
|
||||
}
|
||||
|
||||
U0 CmpFixUpJITAsm(CCmpCtrl *cc,CAOT *tempaot)
|
||||
U0 CmpFixUpJITAsm(CCmpCtrl *cc,CAOT *tmpaot)
|
||||
{
|
||||
I64 i,ip2=tempaot->buf+tempaot->ip,*str=NULL;
|
||||
I64 i,ip2=tmpaot->buf+tmpaot->ip,*str=NULL;
|
||||
U8 *ptr;
|
||||
CCodeMisc *g_lb;
|
||||
CAOTAbsAddr *tempa,*tempa1;
|
||||
CAOTImportExport *tempie,*tempie1;
|
||||
CHashExport *tempex;
|
||||
CAOTAbsAddr *tmpa,*tmpa1;
|
||||
CAOTImportExport *tmpie,*tmpie1;
|
||||
CHashExport *tmpex;
|
||||
|
||||
tempa=tempaot->abss;
|
||||
while (tempa) {
|
||||
tempa1=tempa->next;
|
||||
ptr=ip2+tempa->ip;
|
||||
switch [tempa->type] {
|
||||
tmpa=tmpaot->abss;
|
||||
while (tmpa) {
|
||||
tmpa1=tmpa->next;
|
||||
ptr=ip2+tmpa->ip;
|
||||
switch [tmpa->type] {
|
||||
case AAT_ADD_U8: *ptr(U8 *) +=ip2; break;
|
||||
case AAT_SUB_U8: *ptr(U8 *) -=ip2; break;
|
||||
case AAT_ADD_U16: *ptr(U16 *)+=ip2; break;
|
||||
@@ -194,63 +194,63 @@ U0 CmpFixUpJITAsm(CCmpCtrl *cc,CAOT *tempaot)
|
||||
case AAT_ADD_U64: *ptr(I64 *)+=ip2; break;
|
||||
case AAT_SUB_U64: *ptr(I64 *)-=ip2; break;
|
||||
}
|
||||
Free(tempa);
|
||||
tempa=tempa1;
|
||||
Free(tmpa);
|
||||
tmpa=tmpa1;
|
||||
}
|
||||
tempie=tempaot->next_ie;
|
||||
while (tempie!=&tempaot->next_ie) {
|
||||
tempie1=tempie->next;
|
||||
if (tempie->str) {
|
||||
tmpie=tmpaot->next_ie;
|
||||
while (tmpie!=&tmpaot->next_ie) {
|
||||
tmpie1=tmpie->next;
|
||||
if (tmpie->str) {
|
||||
Free(str);
|
||||
str=tempie->str;
|
||||
str=tmpie->str;
|
||||
}
|
||||
switch (tempie->type) {
|
||||
switch (tmpie->type) {
|
||||
case IET_REL32_EXPORT:
|
||||
case IET_IMM32_EXPORT:
|
||||
case IET_REL64_EXPORT:
|
||||
case IET_IMM64_EXPORT:
|
||||
tempex=CAlloc(sizeof(CHashExport));
|
||||
tempex->str=str;
|
||||
tmpex=CAlloc(sizeof(CHashExport));
|
||||
tmpex->str=str;
|
||||
str=NULL;
|
||||
tempex->type=HTT_EXPORT_SYS_SYM|HTF_IMM;
|
||||
if (tempie->type==IET_IMM32_EXPORT||tempie->type==IET_IMM64_EXPORT)
|
||||
tempex->val=tempie->ip;
|
||||
tmpex->type=HTT_EXPORT_SYS_SYM|HTF_IMM;
|
||||
if (tmpie->type==IET_IMM32_EXPORT||tmpie->type==IET_IMM64_EXPORT)
|
||||
tmpex->val=tmpie->ip;
|
||||
else
|
||||
tempex->val=tempie->ip+ip2;
|
||||
tempex->src_link=tempie->src_link;
|
||||
tempie->src_link=NULL;
|
||||
HashAdd(tempex,Fs->hash_table);
|
||||
SysSymImportsResolve(tempex->str);
|
||||
tmpex->val=tmpie->ip+ip2;
|
||||
tmpex->src_link=tmpie->src_link;
|
||||
tmpie->src_link=NULL;
|
||||
HashAdd(tmpex,Fs->hash_table);
|
||||
SysSymImportsResolve(tmpex->str);
|
||||
break;
|
||||
case IET_REL_I0...IET_IMM_I64:
|
||||
if (tempie->str) {
|
||||
if (tempie->flags&IEF_GOTO_LABEL) {
|
||||
if (tmpie->str) {
|
||||
if (tmpie->flags&IEF_GOTO_LABEL) {
|
||||
if(!(g_lb=COCGoToLabelFind(cc,str)))
|
||||
"Unresolved Reference:%s\n",str;
|
||||
else {
|
||||
g_lb->use_cnt++;
|
||||
g_lb=OptLabelFwd(g_lb);
|
||||
i=g_lb->addr+tempaot->buf;
|
||||
i=g_lb->addr+tmpaot->buf;
|
||||
}
|
||||
tempex=NULL;
|
||||
tmpex=NULL;
|
||||
} else {
|
||||
if (!(tempex=HashFind(str,Fs->hash_table,
|
||||
if (!(tmpex=HashFind(str,Fs->hash_table,
|
||||
HTG_ALL-HTT_IMPORT_SYS_SYM)))
|
||||
"Unresolved Reference:%s\n",str;
|
||||
else {
|
||||
if (tempex->type & HTT_FUN)
|
||||
i=tempex(CHashFun *)->exe_addr;
|
||||
else if (tempex->type & HTT_GLBL_VAR)
|
||||
i=tempex(CHashGlblVar *)->data_addr;
|
||||
if (tmpex->type & HTT_FUN)
|
||||
i=tmpex(CHashFun *)->exe_addr;
|
||||
else if (tmpex->type & HTT_GLBL_VAR)
|
||||
i=tmpex(CHashGlblVar *)->data_addr;
|
||||
else
|
||||
i=tempex->val;
|
||||
i=tmpex->val;
|
||||
}
|
||||
g_lb=NULL;
|
||||
}
|
||||
}
|
||||
if (tempex || g_lb) {
|
||||
ptr=tempie->ip+ip2;
|
||||
switch [tempie->type] {
|
||||
if (tmpex || g_lb) {
|
||||
ptr=tmpie->ip+ip2;
|
||||
switch [tmpie->type] {
|
||||
case IET_REL_I0:
|
||||
case IET_IMM_U0:
|
||||
break;
|
||||
@@ -288,32 +288,32 @@ U0 CmpFixUpJITAsm(CCmpCtrl *cc,CAOT *tempaot)
|
||||
}
|
||||
break;
|
||||
}
|
||||
Free(tempie->src_link);
|
||||
Free(tempie);
|
||||
tempie=tempie1;
|
||||
Free(tmpie->src_link);
|
||||
Free(tmpie);
|
||||
tmpie=tmpie1;
|
||||
}
|
||||
Free(str);
|
||||
if (!cc->aot_depth && Bt(&cc->opts,OPTf_TRACE))
|
||||
Un(ip2,tempaot->aot_U8s,64);
|
||||
QueRem(tempaot);
|
||||
Free(tempaot);
|
||||
Un(ip2,tmpaot->aot_U8s,64);
|
||||
QueRem(tmpaot);
|
||||
Free(tmpaot);
|
||||
}
|
||||
|
||||
U0 CmpFixUpAOTAsm(CCmpCtrl *cc,CAOT *tempaot)
|
||||
U0 CmpFixUpAOTAsm(CCmpCtrl *cc,CAOT *tmpaot)
|
||||
{
|
||||
CAOTCtrl *aotc=cc->aotc;
|
||||
I64 i,ip2=tempaot->ip+cc->aotc->ip;
|
||||
I64 i,ip2=tmpaot->ip+cc->aotc->ip;
|
||||
U8 *ptr;
|
||||
CCodeMisc *g_lb=NULL;
|
||||
CAOTAbsAddr *tempa,*tempa1;
|
||||
CAOTImportExport *tempie,*tempie1;
|
||||
CAOTAbsAddr *tmpa,*tmpa1;
|
||||
CAOTImportExport *tmpie,*tmpie1;
|
||||
|
||||
tempa=tempaot->abss;
|
||||
while (tempa) {
|
||||
tempa1=tempa->next;
|
||||
tempa->next=aotc->abss;
|
||||
ptr=tempaot->buf+tempaot->ip+tempa->ip;
|
||||
switch [tempa->type] {
|
||||
tmpa=tmpaot->abss;
|
||||
while (tmpa) {
|
||||
tmpa1=tmpa->next;
|
||||
tmpa->next=aotc->abss;
|
||||
ptr=tmpaot->buf+tmpaot->ip+tmpa->ip;
|
||||
switch [tmpa->type] {
|
||||
case AAT_ADD_U8: *ptr(U8 *)+=ip2; break;
|
||||
case AAT_SUB_U8: *ptr(U8 *)-=ip2; break;
|
||||
case AAT_ADD_U16: *ptr(U16 *)+=ip2; break;
|
||||
@@ -323,20 +323,20 @@ U0 CmpFixUpAOTAsm(CCmpCtrl *cc,CAOT *tempaot)
|
||||
case AAT_ADD_U64: *ptr(I64 *)+=ip2; break;
|
||||
case AAT_SUB_U64: *ptr(I64 *)-=ip2; break;
|
||||
}
|
||||
aotc->abss=tempa;
|
||||
tempa->ip+=ip2;
|
||||
tempa=tempa1;
|
||||
aotc->abss=tmpa;
|
||||
tmpa->ip+=ip2;
|
||||
tmpa=tmpa1;
|
||||
}
|
||||
|
||||
tempie=tempaot->next_ie;
|
||||
while (tempie!=&tempaot->next_ie) {
|
||||
tempie1=tempie->next;
|
||||
QueRem(tempie);
|
||||
if (IET_REL_I0<=tempie->type<=IET_IMM_I64) {
|
||||
if (tempie->str) {
|
||||
if (tempie->flags&IEF_GOTO_LABEL) {
|
||||
if(!(g_lb=COCGoToLabelFind(cc,tempie->str)))
|
||||
"Unresolved Reference:%s\n",tempie->str;
|
||||
tmpie=tmpaot->next_ie;
|
||||
while (tmpie!=&tmpaot->next_ie) {
|
||||
tmpie1=tmpie->next;
|
||||
QueRem(tmpie);
|
||||
if (IET_REL_I0<=tmpie->type<=IET_IMM_I64) {
|
||||
if (tmpie->str) {
|
||||
if (tmpie->flags&IEF_GOTO_LABEL) {
|
||||
if(!(g_lb=COCGoToLabelFind(cc,tmpie->str)))
|
||||
"Unresolved Reference:%s\n",tmpie->str;
|
||||
else {
|
||||
g_lb->use_cnt++;
|
||||
g_lb=OptLabelFwd(g_lb);
|
||||
@@ -347,10 +347,10 @@ U0 CmpFixUpAOTAsm(CCmpCtrl *cc,CAOT *tempaot)
|
||||
} else
|
||||
g_lb=NULL;
|
||||
|
||||
ptr=tempaot->buf+tempaot->ip+tempie->ip;
|
||||
ptr=tmpaot->buf+tmpaot->ip+tmpie->ip;
|
||||
if (g_lb) {
|
||||
i=g_lb->addr+tempaot->buf;
|
||||
switch [tempie->type] {
|
||||
i=g_lb->addr+tmpaot->buf;
|
||||
switch [tmpie->type] {
|
||||
case IET_REL_I0:
|
||||
case IET_IMM_U0:
|
||||
break;
|
||||
@@ -385,10 +385,10 @@ U0 CmpFixUpAOTAsm(CCmpCtrl *cc,CAOT *tempaot)
|
||||
*ptr(I64 *)=i;
|
||||
break;
|
||||
}
|
||||
Free(tempie->src_link);
|
||||
Free(tempie);
|
||||
Free(tmpie->src_link);
|
||||
Free(tmpie);
|
||||
} else {
|
||||
switch (tempie->type) {
|
||||
switch (tmpie->type) {
|
||||
start:
|
||||
case IET_REL32_EXPORT:
|
||||
case IET_IMM32_EXPORT:
|
||||
@@ -406,13 +406,13 @@ U0 CmpFixUpAOTAsm(CCmpCtrl *cc,CAOT *tempaot)
|
||||
case IET_REL_I32: *ptr(U32 *)-=ip2; break;
|
||||
case IET_REL_I64: *ptr(I64 *)-=ip2; break;
|
||||
end:
|
||||
tempie->ip+=ip2;
|
||||
tmpie->ip+=ip2;
|
||||
break;
|
||||
}
|
||||
tempie->aot=NULL;
|
||||
QueIns(tempie,tempaot->parent_aot->last_ie);
|
||||
tmpie->aot=NULL;
|
||||
QueIns(tmpie,tmpaot->parent_aot->last_ie);
|
||||
}
|
||||
tempie=tempie1;
|
||||
tmpie=tmpie1;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -420,115 +420,115 @@ I64 Cmp(U8 *filename,U8 *map_name=NULL,U8 *out_name=NULL,U8 mapfile_drv_let=0)
|
||||
{//AOT Compile HC or PRJ file a and output BIN file. Returns err_cnt.
|
||||
U8 *ptr,*fbuf=NULL,*fbuf2=NULL,*fbuf3=NULL,
|
||||
*patch_table=MAlloc(0x20000);
|
||||
CAOT *tempaot;
|
||||
CAOT *tmpaot;
|
||||
I64 i,cnt,size=0,error_cnt=0,warning_cnt=0,aot_U8s=0;
|
||||
CBinFile *bfh;
|
||||
CAOTImportExport *tempie,*tempie1;
|
||||
CAOTAbsAddr *tempa,*tempa1;
|
||||
CAOTHeapGlblRef *temphgr,*temphgr1;
|
||||
CAOTHeapGlbl *temphg,*temphg1;
|
||||
CAOTImportExport *tmpie,*tmpie1;
|
||||
CAOTAbsAddr *tmpa,*tmpa1;
|
||||
CAOTHeapGlblRef *tmphgr,*tmphgr1;
|
||||
CAOTHeapGlbl *tmphg,*tmphg1;
|
||||
|
||||
fbuf=DftExt(filename,"PRJ.Z");
|
||||
fbuf2=MStrPrint("#include \"%s\"",fbuf);
|
||||
if (map_name)
|
||||
fbuf3=DftExt(map_name,"MAP.Z");
|
||||
|
||||
if (tempaot=CmpBuf(fbuf2,fbuf3,&error_cnt,&warning_cnt,mapfile_drv_let)) {
|
||||
aot_U8s=tempaot->aot_U8s;
|
||||
if (tmpaot=CmpBuf(fbuf2,fbuf3,&error_cnt,&warning_cnt,mapfile_drv_let)) {
|
||||
aot_U8s=tmpaot->aot_U8s;
|
||||
ptr=patch_table;
|
||||
//See $LK,"Load",A="MN:Load"$()
|
||||
cnt=0;
|
||||
tempa=tempaot->abss;
|
||||
while (tempa) {
|
||||
if (!(tempa->type&IEF_IMM_NOT_REL))
|
||||
tmpa=tmpaot->abss;
|
||||
while (tmpa) {
|
||||
if (!(tmpa->type&IEF_IMM_NOT_REL))
|
||||
cnt++;
|
||||
tempa=tempa->next;
|
||||
tmpa=tmpa->next;
|
||||
}
|
||||
if (cnt) {
|
||||
*ptr++=IET_ABS_ADDR;
|
||||
*ptr(U32 *)++=cnt;
|
||||
*ptr++=0;
|
||||
tempa=tempaot->abss;
|
||||
while (tempa) {
|
||||
tempa1=tempa->next;
|
||||
if (!(tempa->type&IEF_IMM_NOT_REL))
|
||||
*ptr(U32 *)++ =tempa->ip;
|
||||
Free(tempa);
|
||||
tempa=tempa1;
|
||||
tmpa=tmpaot->abss;
|
||||
while (tmpa) {
|
||||
tmpa1=tmpa->next;
|
||||
if (!(tmpa->type&IEF_IMM_NOT_REL))
|
||||
*ptr(U32 *)++ =tmpa->ip;
|
||||
Free(tmpa);
|
||||
tmpa=tmpa1;
|
||||
}
|
||||
}
|
||||
temphg=tempaot->heap_glbls;
|
||||
while (temphg) {
|
||||
temphg1=temphg->next;
|
||||
tmphg=tmpaot->heap_glbls;
|
||||
while (tmphg) {
|
||||
tmphg1=tmphg->next;
|
||||
cnt=0;
|
||||
temphgr=temphg->references;
|
||||
while (temphgr) {
|
||||
tmphgr=tmphg->references;
|
||||
while (tmphgr) {
|
||||
cnt++;
|
||||
temphgr=temphgr->next;
|
||||
tmphgr=tmphgr->next;
|
||||
}
|
||||
if (cnt) {
|
||||
*ptr++=IET_DATA_HEAP;
|
||||
*ptr(U32 *)++=cnt;
|
||||
if (temphg->str) {
|
||||
i=StrLen(temphg->str);
|
||||
MemCpy(ptr,temphg->str,i+1);
|
||||
Free(temphg->str);
|
||||
if (tmphg->str) {
|
||||
i=StrLen(tmphg->str);
|
||||
MemCpy(ptr,tmphg->str,i+1);
|
||||
Free(tmphg->str);
|
||||
ptr+=i+1;
|
||||
} else
|
||||
*ptr++=0;
|
||||
*ptr(I64 *)++=temphg->size;
|
||||
temphgr=temphg->references;
|
||||
while (temphgr) {
|
||||
temphgr1=temphgr->next;
|
||||
*ptr(U32 *)++=temphgr->ip;
|
||||
Free(temphgr);
|
||||
temphgr=temphgr1;
|
||||
*ptr(I64 *)++=tmphg->size;
|
||||
tmphgr=tmphg->references;
|
||||
while (tmphgr) {
|
||||
tmphgr1=tmphgr->next;
|
||||
*ptr(U32 *)++=tmphgr->ip;
|
||||
Free(tmphgr);
|
||||
tmphgr=tmphgr1;
|
||||
}
|
||||
}
|
||||
Free(temphg);
|
||||
temphg=temphg1;
|
||||
Free(tmphg);
|
||||
tmphg=tmphg1;
|
||||
}
|
||||
|
||||
//Do exports first
|
||||
tempie=tempaot->next_ie;
|
||||
while (tempie!=&tempaot->next_ie) {
|
||||
tempie1=tempie->next;
|
||||
if (!tempie->type || IET_REL32_EXPORT<=tempie->type<=IET_IMM64_EXPORT) {
|
||||
QueRem(tempie);
|
||||
*ptr++=tempie->type;
|
||||
*ptr(U32 *)++=tempie->ip;
|
||||
if (tempie->str) {
|
||||
i=StrLen(tempie->str);
|
||||
MemCpy(ptr,tempie->str,i+1);
|
||||
Free(tempie->str);
|
||||
tmpie=tmpaot->next_ie;
|
||||
while (tmpie!=&tmpaot->next_ie) {
|
||||
tmpie1=tmpie->next;
|
||||
if (!tmpie->type || IET_REL32_EXPORT<=tmpie->type<=IET_IMM64_EXPORT) {
|
||||
QueRem(tmpie);
|
||||
*ptr++=tmpie->type;
|
||||
*ptr(U32 *)++=tmpie->ip;
|
||||
if (tmpie->str) {
|
||||
i=StrLen(tmpie->str);
|
||||
MemCpy(ptr,tmpie->str,i+1);
|
||||
Free(tmpie->str);
|
||||
ptr+=i+1;
|
||||
} else
|
||||
*ptr++=0;
|
||||
Free(tempie->src_link);
|
||||
Free(tempie);
|
||||
Free(tmpie->src_link);
|
||||
Free(tmpie);
|
||||
}
|
||||
tempie=tempie1;
|
||||
tmpie=tmpie1;
|
||||
}
|
||||
|
||||
//Do imports second
|
||||
tempie=tempaot->next_ie;
|
||||
while (tempie!=&tempaot->next_ie) {
|
||||
tempie1=tempie->next;
|
||||
QueRem(tempie);
|
||||
*ptr++=tempie->type;
|
||||
if (tempie->aot)
|
||||
tempie->ip+=tempie->aot->ip2;
|
||||
*ptr(U32 *)++=tempie->ip;
|
||||
if (tempie->str) {
|
||||
i=StrLen(tempie->str);
|
||||
MemCpy(ptr,tempie->str,i+1);
|
||||
Free(tempie->str);
|
||||
tmpie=tmpaot->next_ie;
|
||||
while (tmpie!=&tmpaot->next_ie) {
|
||||
tmpie1=tmpie->next;
|
||||
QueRem(tmpie);
|
||||
*ptr++=tmpie->type;
|
||||
if (tmpie->aot)
|
||||
tmpie->ip+=tmpie->aot->ip2;
|
||||
*ptr(U32 *)++=tmpie->ip;
|
||||
if (tmpie->str) {
|
||||
i=StrLen(tmpie->str);
|
||||
MemCpy(ptr,tmpie->str,i+1);
|
||||
Free(tmpie->str);
|
||||
ptr+=i+1;
|
||||
} else
|
||||
*ptr++=0;
|
||||
Free(tempie->src_link);
|
||||
Free(tempie);
|
||||
tempie=tempie1;
|
||||
Free(tmpie->src_link);
|
||||
Free(tmpie);
|
||||
tmpie=tmpie1;
|
||||
}
|
||||
|
||||
*ptr++=IET_END;
|
||||
@@ -541,11 +541,11 @@ I64 Cmp(U8 *filename,U8 *map_name=NULL,U8 *out_name=NULL,U8 mapfile_drv_let=0)
|
||||
#assert sizeof(CBinFile)-2<=MAX_I8
|
||||
bfh->reserved=0;
|
||||
bfh->bin_signature=BIN_SIGNATURE_VAL;
|
||||
bfh->module_org=tempaot->module_org;
|
||||
bfh->module_align_bits=tempaot->max_align_bits;
|
||||
bfh->module_org=tmpaot->module_org;
|
||||
bfh->module_align_bits=tmpaot->max_align_bits;
|
||||
bfh->patch_table_offset=sizeof(CBinFile)+aot_U8s;
|
||||
bfh->file_size=size;
|
||||
MemCpy(bfh(U8 *)+sizeof(CBinFile),tempaot->buf,aot_U8s);
|
||||
MemCpy(bfh(U8 *)+sizeof(CBinFile),tmpaot->buf,aot_U8s);
|
||||
MemCpy(bfh(U8 *)+sizeof(CBinFile)+aot_U8s,patch_table,
|
||||
size-aot_U8s-sizeof(CBinFile));
|
||||
Free(fbuf2);
|
||||
@@ -555,9 +555,9 @@ I64 Cmp(U8 *filename,U8 *map_name=NULL,U8 *out_name=NULL,U8 mapfile_drv_let=0)
|
||||
fbuf2=ChgExt(fbuf,"BIN.Z");
|
||||
FileWrite(fbuf2,bfh,size);
|
||||
Free(bfh);
|
||||
Free(tempaot->buf);
|
||||
QueDel(tempaot);
|
||||
Free(tempaot);
|
||||
Free(tmpaot->buf);
|
||||
QueDel(tmpaot);
|
||||
Free(tmpaot);
|
||||
}
|
||||
Free(patch_table);
|
||||
Free(fbuf);
|
||||
@@ -575,7 +575,7 @@ I64 ExePutS(U8 *buf,U8 *filename=NULL,
|
||||
Bool okay=TRUE;
|
||||
CCmpCtrl *cc;
|
||||
if (!filename)
|
||||
filename=blkdev.temp_filename;
|
||||
filename=blkdev.tmp_filename;
|
||||
cc=CmpCtrlNew(buf,ccf_flags|CCF_DONT_FREE_BUF,filename);
|
||||
if (Fs->last_cc!=&Fs->next_cc) {
|
||||
cc->opts=Fs->last_cc->opts;
|
||||
@@ -633,7 +633,7 @@ I64 ExePutS2(U8 *buf,U8 *filename=NULL,I64 ccf_flags=0)
|
||||
I64 res;
|
||||
CCmpCtrl *cc;
|
||||
if (!filename)
|
||||
filename=blkdev.temp_filename;
|
||||
filename=blkdev.tmp_filename;
|
||||
cc=CmpCtrlNew(buf,ccf_flags|CCF_DONT_FREE_BUF,filename);
|
||||
if (Fs->last_cc!=&Fs->next_cc)
|
||||
cc->opts=Fs->last_cc->opts;
|
||||
|
||||
+9
-6
@@ -69,11 +69,11 @@ U0 StreamPrint(U8 *fmt,...)
|
||||
{//Injects text into the compile stream. Used in #exe{} blocks.
|
||||
U8 *buf=StrPrintJoin(NULL,fmt,argc,argv),*st;
|
||||
CCmpCtrl *cc=Fs->last_cc;
|
||||
CStreamBlk *tempe=cc->last_stream_blk;
|
||||
if (tempe!=&cc->next_stream_blk) {
|
||||
st=MStrPrint("%s%s",tempe->body,buf);
|
||||
Free(tempe->body);
|
||||
tempe->body=st;
|
||||
CStreamBlk *tmpe=cc->last_stream_blk;
|
||||
if (tmpe!=&cc->next_stream_blk) {
|
||||
st=MStrPrint("%s%s",tmpe->body,buf);
|
||||
Free(tmpe->body);
|
||||
tmpe->body=st;
|
||||
} else
|
||||
PrintErr("No exe{} blk\n");
|
||||
Free(buf);
|
||||
@@ -140,9 +140,12 @@ U8 *CmdLinePmt()
|
||||
Free(st);
|
||||
}
|
||||
'>';
|
||||
if (IsDbg&&IsRaw)
|
||||
if (IsDbgMode&&IsRaw)
|
||||
RawDr;
|
||||
|
||||
LBts(&Fs->task_flags,TASKf_CMD_LINE_PMT);
|
||||
st=GetStr(,,GSF_SHIFT_ESC_EXIT);
|
||||
LBtr(&Fs->task_flags,TASKf_CMD_LINE_PMT);
|
||||
|
||||
i=StrLen(st);
|
||||
res=MAlloc(i+1+2);
|
||||
|
||||
Binary file not shown.
+75
-77
@@ -51,7 +51,7 @@ $LK,"LexPopNoRestore",A="FL:::/Compiler/LexLib.HC.Z,38",BI=40$
|
||||
$LK,"ExePrint",A="FL:::/Compiler/CMain.HC.Z,605",BI=41$
|
||||
$LK,"SLASH_OP_NEG",A="FL:::/Compiler/BackLib.HC.Z,247"$
|
||||
$LK,"PrsVarLst",A="FL:::/Compiler/PrsVar.HC.Z,416",BI=42$
|
||||
$LK,"PrsAsmDefine",A="FL:::/Compiler/Asm.HC.Z,814",BI=43$
|
||||
$LK,"PrsAsmDefine",A="FL:::/Compiler/Asm.HC.Z,813",BI=43$
|
||||
$LK,"PrsAddOp",A="FL:::/Compiler/PrsExp.HC.Z,15",BI=44$
|
||||
$LK,"LexWarn",A="FL:::/Compiler/CExcept.HC.Z,65",BI=45$
|
||||
$LK,"PE_POP_ALL1",A="FL:::/Compiler/PrsExp.HC.Z,12"$
|
||||
@@ -99,7 +99,7 @@ $LK,"CmpBuf",A="FL:::/Compiler/CMain.HC.Z,157",BI=75$
|
||||
$LK,"CMP_TEMPLATES_DONT_PUSH_POP",A="FL:::/Compiler/Templates.HC.Z,385"$
|
||||
$LK,"ICAddEct",A="FL:::/Compiler/BackA.HC.Z,1",BI=76$
|
||||
$LK,"ICToF64",A="FL:::/Compiler/BackB.HC.Z,283",BI=77$
|
||||
$LK,"PrsBinFile",A="FL:::/Compiler/Asm.HC.Z,888",BI=78$
|
||||
$LK,"PrsBinFile",A="FL:::/Compiler/Asm.HC.Z,887",BI=78$
|
||||
$LK,"HashTableSize2",A="FL:::/Compiler/CHash.HC.Z,72",BI=79$
|
||||
$LK,"HashEntrySize2",A="FL:::/Compiler/CHash.HC.Z,33",BI=80$
|
||||
$LK,"Ui",A="FL:::/Compiler/UAsm.HC.Z,238",BI=81$
|
||||
@@ -248,7 +248,7 @@ $LK,"CmpJoin",A="FL:::/Compiler/CMain.HC.Z,35",BI=194$
|
||||
$LK,"PrsPop2",A="FL:::/Compiler/PrsLib.HC.Z,16",BI=195$
|
||||
$LK,"CMP_TEMPLATES",A="FL:::/Compiler/Templates.HC.Z,4"$
|
||||
$LK,"MODR_D8_INDIRECT_REG",A="FL:::/Compiler/BackLib.HC.Z,128"$
|
||||
$LK,"PrsAsmBlk",A="FL:::/Compiler/Asm.HC.Z,904",BI=196$
|
||||
$LK,"PrsAsmBlk",A="FL:::/Compiler/Asm.HC.Z,903",BI=196$
|
||||
$LK,"PrsAsmArg",A="FL:::/Compiler/Asm.HC.Z,35",BI=197$
|
||||
$LK,"LexFirstRem",A="FL:::/Compiler/Lex.HC.Z,277",BI=198$
|
||||
$LK,"MemberClassBaseFind",A="FL:::/Compiler/LexLib.HC.Z,87",BI=199$
|
||||
@@ -340,91 +340,89 @@ $LK,"PrsDotDotDot",A="FL:::/Compiler/PrsVar.HC.Z,381",BI=266$
|
||||
$LK,"ICMulEqu",A="FL:::/Compiler/BackA.HC.Z,322",BI=267$
|
||||
$LK,"AsmPrsInsFlags",A="FL:::/Compiler/AsmInit.HC.Z,1",BI=268$
|
||||
$LK,"PrsNoWarn",A="FL:::/Compiler/PrsStmt.HC.Z,799",BI=269$
|
||||
| ||||