mirror of
https://github.com/Zeal-Operating-System/ZealOS.git
synced 2025-06-07 08:14:48 +00:00
global cmp -> comp. Removed mmx registers from compiler
Working out argument flags and SSE register size support
This commit is contained in:
parent
6bd35c55f3
commit
ff561bb802
Binary file not shown.
@ -58,30 +58,29 @@ U0 ParseAsmArg(CCompCtrl *cc,CAsmArg *arg,Bool rel)
|
||||
{
|
||||
start:
|
||||
case REGT_R8:
|
||||
arg->size=1;
|
||||
arg->size = 1;
|
||||
break;
|
||||
case REGT_R16:
|
||||
arg->size=2;
|
||||
arg->size = 2;
|
||||
break;
|
||||
case REGT_R32:
|
||||
arg->size=4;
|
||||
arg->size = 4;
|
||||
break;
|
||||
case REGT_R64:
|
||||
case REGT_FSTACK:
|
||||
case REGT_MM:
|
||||
arg->size=8;
|
||||
arg->size = 8;
|
||||
break;
|
||||
case REGT_XMM:
|
||||
arg->size=16;
|
||||
arg->size = 16;
|
||||
end:
|
||||
arg->reg1=tmpr->reg_num;
|
||||
arg->reg1 = tmpr->reg_num;
|
||||
Lex(cc);
|
||||
return;
|
||||
case REGT_SEG:
|
||||
arg->seg = tmpr->reg_num;
|
||||
if (Lex(cc) != ':')
|
||||
{
|
||||
arg->just_seg=TRUE;
|
||||
arg->just_seg = TRUE;
|
||||
return;
|
||||
}
|
||||
else
|
||||
@ -91,9 +90,8 @@ U0 ParseAsmArg(CCompCtrl *cc,CAsmArg *arg,Bool rel)
|
||||
}
|
||||
else
|
||||
{
|
||||
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)))
|
||||
if ((tmph->type & HTG_TYPE_MASK == HTT_CLASS || tmph->type & HTG_TYPE_MASK == HTT_INTERNAL_TYPE) &&
|
||||
(tmph1 = HashFind(cc->cur_str, comp.asm_hash, HTT_ASM_KEYWORD)))
|
||||
tmph = tmph1;
|
||||
if (tmph->type & HTG_TYPE_MASK == HTT_ASM_KEYWORD)
|
||||
{
|
||||
@ -130,15 +128,16 @@ pa_asm_direct_imm:
|
||||
if (arg->size <= 1 && !rel && arg->num.abs_counts & 1)
|
||||
{
|
||||
if (cc->aotc->seg_size == 16)
|
||||
arg->size=2;
|
||||
arg->size = 2;
|
||||
else
|
||||
arg->size=4;
|
||||
arg->size = 4;
|
||||
}
|
||||
if (cc->token != '[')
|
||||
return;
|
||||
}
|
||||
}
|
||||
else if (cc->token=='[') {
|
||||
else if (cc->token == '[')
|
||||
{
|
||||
arg->indirect = TRUE;
|
||||
Lex(cc); // skip [
|
||||
while (cc->token && cc->token != ']')
|
||||
@ -191,81 +190,98 @@ pa_asm_indirect_imm:
|
||||
}
|
||||
}
|
||||
|
||||
I64 AsmMakeArgMask(CCompCtrl *cc,CAsmArg *arg)
|
||||
I64 AsmMakeArgMask(CCompCtrl *cc, CAsmArg *arg)
|
||||
{
|
||||
CAOTCtrl *aotc=cc->aotc;
|
||||
CAOTCtrl *aotc = cc->aotc;
|
||||
I64 res;
|
||||
if (arg->just_seg) {
|
||||
switch (arg->seg) {
|
||||
case 0: res=1<<ARGT_ES|1<<ARGT_SREG; break;
|
||||
case 1: res=1<<ARGT_CS|1<<ARGT_SREG; break;
|
||||
case 2: res=1<<ARGT_SS|1<<ARGT_SREG; break;
|
||||
case 3: res=1<<ARGT_DS|1<<ARGT_SREG; break;
|
||||
case 4: res=1<<ARGT_FS|1<<ARGT_SREG; break;
|
||||
case 5: res=1<<ARGT_GS|1<<ARGT_SREG; break;
|
||||
|
||||
if (arg->just_seg)
|
||||
{
|
||||
switch (arg->seg)
|
||||
{
|
||||
case: res = ARGT_ES|ARGT_SREG; break;
|
||||
case: res = ARGT_CS|ARGT_SREG; break;
|
||||
case: res = ARGT_SS|ARGT_SREG; break;
|
||||
case: res = ARGT_DS|ARGT_SREG; break;
|
||||
case: res = ARGT_FS|ARGT_SREG; break;
|
||||
case: res = ARGT_GS|ARGT_SREG; break;
|
||||
}
|
||||
goto mm_done;
|
||||
}
|
||||
if (arg->reg1_type==REGT_FSTACK) {
|
||||
|
||||
if (arg->reg1_type == REGT_FSTACK)
|
||||
{
|
||||
if (arg->reg1)
|
||||
res=1<<ARGT_STI;
|
||||
res = ARGT_STI;
|
||||
else
|
||||
res=1<<ARGT_ST0|1<<ARGT_STI;
|
||||
goto mm_done;
|
||||
}
|
||||
res=cmp.size_arg_mask[arg->size];
|
||||
if (aotc->seg_size==64)
|
||||
res&=0xFF0FFFFFFF;
|
||||
|
||||
if (arg->reg1!=REG_NONE && arg->imm_or_off_present && !arg->num.i &&
|
||||
!arg->num.glbl_asm_undef_hash && !arg->num.local_asm_undef_hash)
|
||||
arg->imm_or_off_present=FALSE; //Zero displacement
|
||||
|
||||
if (arg->reg2!=REG_NONE || arg->scale!=1) {
|
||||
res&=0x0000FF0000;
|
||||
res = ARGT_ST0 | ARGT_STI;
|
||||
goto mm_done;
|
||||
}
|
||||
|
||||
if (arg->indirect) {
|
||||
if (arg->imm_or_off_present)
|
||||
res&=0x00FFFF0000;
|
||||
else
|
||||
res&=0x000FFF0000;
|
||||
} else {
|
||||
if (arg->imm_or_off_present)
|
||||
res&=0x000F000FFE;
|
||||
else
|
||||
res&=0x3F0FFFF000;
|
||||
res = comp.size_arg_mask[arg->size];
|
||||
|
||||
if (aotc->seg_size == 64)
|
||||
res &= 0xFF0FFFFFFF;
|
||||
|
||||
if (arg->reg1 != REG_NONE && arg->imm_or_off_present && !arg->num.i &&
|
||||
!arg->num.glbl_asm_undef_hash && !arg->num.local_asm_undef_hash)
|
||||
arg->imm_or_off_present = FALSE; //Zero displacement
|
||||
|
||||
if (arg->reg2 != REG_NONE || arg->scale != 1)
|
||||
{
|
||||
res &= 0x0000FF0000;
|
||||
goto mm_done;
|
||||
}
|
||||
if (arg->seg!=REG_NONE)
|
||||
|
||||
if (arg->indirect)
|
||||
{
|
||||
if (arg->imm_or_off_present)
|
||||
res &= 0x00FFFF0000;
|
||||
else
|
||||
res &= 0x000FFF0000;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (arg->imm_or_off_present)
|
||||
res &= 0x000F000FFE;
|
||||
else
|
||||
res &= 0x3F0FFFF000;
|
||||
}
|
||||
|
||||
if (arg->seg != REG_NONE)
|
||||
res&=0x00FFFF0000;
|
||||
if (arg->reg1==REG_NONE) {
|
||||
|
||||
if (arg->reg1 == REG_NONE)
|
||||
{
|
||||
if (arg->indirect)
|
||||
res&=0x00FFFF0000;
|
||||
else if (arg->num.i<0) {
|
||||
if (arg->num.i>=I8_MIN)
|
||||
res&=0x8FE;
|
||||
else if (arg->num.i>=I16_MIN)
|
||||
res&=0x8EE;
|
||||
else if (arg->num.i>=I32_MIN)
|
||||
res&=0x8CE;
|
||||
res &= 0x00FFFF0000;
|
||||
else if (arg->num.i < 0)
|
||||
{
|
||||
if (arg->num.i >= I8_MIN)
|
||||
res &= 0x8FE;
|
||||
else if (arg->num.i >= I16_MIN)
|
||||
res &= 0x8EE;
|
||||
else if (arg->num.i >= I32_MIN)
|
||||
res &= 0x8CE;
|
||||
else
|
||||
res&=0x88E;
|
||||
} else {
|
||||
if (arg->num.i<=I8_MAX)
|
||||
res&=0xFFE;
|
||||
else if (arg->num.i<=U8_MAX)
|
||||
res&=0xFEE;
|
||||
else if (arg->num.i<=I16_MAX)
|
||||
res&=0xEEE;
|
||||
else if (arg->num.i<=U16_MAX)
|
||||
res&=0xECE;
|
||||
else if (arg->num.i<=I32_MAX)
|
||||
res&=0xCCE;
|
||||
else if (arg->num.i<=U32_MAX)
|
||||
res&=0xC8E;
|
||||
res &= 0x88E;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (arg->num.i <= I8_MAX)
|
||||
res &= 0xFFE;
|
||||
else if (arg->num.i <= U8_MAX)
|
||||
res &= 0xFEE;
|
||||
else if (arg->num.i <= I16_MAX)
|
||||
res &= 0xEEE;
|
||||
else if (arg->num.i <= U16_MAX)
|
||||
res &= 0xECE;
|
||||
else if (arg->num.i <= I32_MAX)
|
||||
res &= 0xCCE;
|
||||
else if (arg->num.i <= U32_MAX)
|
||||
res &= 0xC8E;
|
||||
else
|
||||
res&=0x88E;
|
||||
res &= 0x88E;
|
||||
}
|
||||
} else {
|
||||
res&= 0x3F00FFF000;
|
||||
@ -429,7 +445,7 @@ Bool ParseAsmInst(CCompCtrl *cc,CHashOpcode *tmpo,I64 argcount)
|
||||
arg2mask=1;
|
||||
for (i=0;i<tmpo->inst_entry_count;i++) {
|
||||
tmpins=&tmpo->ins[i];
|
||||
if (tmpins->arg1==ARGT_REL8 || tmpins->arg2==ARGT_REL8)
|
||||
if (tmpins->arg1==ARGt_REL8 || tmpins->arg2==ARGt_REL8)
|
||||
U8_avail=TRUE;
|
||||
if (Bt(&arg1mask,tmpins->arg1) && Bt(&arg2mask,tmpins->arg2) &&
|
||||
(!(tmpins->flags&IEF_NOT_IN_64_BIT) || aotc->seg_size!=64)) {
|
||||
@ -496,9 +512,9 @@ Bool ParseAsmInst(CCompCtrl *cc,CHashOpcode *tmpo,I64 argcount)
|
||||
cur.last_opcode_U8+=tmpa1->reg1;
|
||||
}
|
||||
}
|
||||
if (arg1==ARGT_R64 || arg1==ARGT_RM64 || arg1==ARGT_M64)
|
||||
if (arg1==ARGt_R64 || arg1==ARGt_RM64 || arg1==ARGt_M64)
|
||||
cur.REX|=8;
|
||||
if (ARGT_RM8<=arg1<=ARGT_RM64 || ARGT_M8<=arg1<=ARGT_M64) {
|
||||
if (ARGt_RM8<=arg1<=ARGt_RM64 || ARGt_M8<=arg1<=ARGt_M64) {
|
||||
if (aotc->seg_size==16)
|
||||
cur.has_addr_prefix=TRUE;
|
||||
|
||||
@ -580,9 +596,9 @@ Bool ParseAsmInst(CCompCtrl *cc,CHashOpcode *tmpo,I64 argcount)
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (ARGT_REL8<=arg1<=ARGT_REL32 || ARGT_IMM8<=arg1<=ARGT_IMM64 ||
|
||||
ARGT_UIMM8<=arg1<=ARGT_UIMM64) {
|
||||
if (arg1==ARGT_IMM64 || arg2==ARGT_UIMM64)
|
||||
} else if (ARGt_REL8<=arg1<=ARGt_REL32 || ARGt_IMM8<=arg1<=ARGt_IMM64 ||
|
||||
ARGt_UIMM8<=arg1<=ARGt_UIMM64) {
|
||||
if (arg1==ARGt_IMM64 || arg2==ARGt_UIMM64)
|
||||
cur.REX|=8;
|
||||
MemCopy(&cur.imm.num,&tmpa1->num,sizeof(CAsmNum));
|
||||
}
|
||||
@ -596,7 +612,7 @@ Bool ParseAsmInst(CCompCtrl *cc,CHashOpcode *tmpo,I64 argcount)
|
||||
}
|
||||
if (tmpins->flags & IEF_PLUS_OPCODE) {
|
||||
if (tmpins->slash_val==SV_R_REG) {
|
||||
if (ARGT_AL<=arg1<=ARGT_RAX) {
|
||||
if (ARGt_AL<=arg1<=ARGt_RAX) {
|
||||
cur.last_opcode_U8|=tmpa2->reg1&7;
|
||||
if (tmpa2->reg1&15>7)
|
||||
cur.REX|=1;
|
||||
@ -616,16 +632,16 @@ Bool ParseAsmInst(CCompCtrl *cc,CHashOpcode *tmpo,I64 argcount)
|
||||
cur.last_opcode_U8|=tmpa2->reg1;
|
||||
}
|
||||
}
|
||||
if (arg1==ARGT_RM64 || arg2==ARGT_RM64 ||
|
||||
arg1==ARGT_M64 || arg2==ARGT_M64 ||
|
||||
arg1==ARGT_R64 || arg2==ARGT_R64)
|
||||
if (arg1==ARGt_RM64 || arg2==ARGt_RM64 ||
|
||||
arg1==ARGt_M64 || arg2==ARGt_M64 ||
|
||||
arg1==ARGt_R64 || arg2==ARGt_R64)
|
||||
cur.REX|=8;
|
||||
if (ARGT_RM8<=arg1<=ARGT_RM64 || ARGT_RM8<=arg2<=ARGT_RM64 ||
|
||||
ARGT_M8<=arg1<=ARGT_M64 || ARGT_M8<=arg2<=ARGT_M64) {
|
||||
if (ARGt_RM8<=arg1<=ARGt_RM64 || ARGt_RM8<=arg2<=ARGt_RM64 ||
|
||||
ARGt_M8<=arg1<=ARGt_M64 || ARGt_M8<=arg2<=ARGt_M64) {
|
||||
if (aotc->seg_size==16)
|
||||
cur.has_addr_prefix=TRUE;
|
||||
cur.has_ModrM=TRUE;
|
||||
if (ARGT_RM8<=arg2<=ARGT_RM64 || ARGT_M8<=arg2<=ARGT_M64) {
|
||||
if (ARGt_RM8<=arg2<=ARGt_RM64 || ARGt_M8<=arg2<=ARGt_M64) {
|
||||
tmpa1=&aotc->arg2;
|
||||
tmpa2=&aotc->arg1;
|
||||
}
|
||||
@ -727,39 +743,39 @@ Bool ParseAsmInst(CCompCtrl *cc,CHashOpcode *tmpo,I64 argcount)
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (ARGT_MOFFS8<=arg1<=ARGT_MOFFS64) {
|
||||
} else if (ARGt_MOFFS8<=arg1<=ARGt_MOFFS64) {
|
||||
MemCopy(&cur.disp.num,&tmpa1->num,sizeof(CAsmNum));
|
||||
if (aotc->seg_size==16)
|
||||
cur.disp.U8_count=2;
|
||||
else
|
||||
cur.disp.U8_count=4;
|
||||
cur.has_addr_prefix=FALSE;
|
||||
} else if (ARGT_MOFFS8<=arg2<=ARGT_MOFFS64) {
|
||||
} else if (ARGt_MOFFS8<=arg2<=ARGt_MOFFS64) {
|
||||
MemCopy(&cur.disp.num,&tmpa2->num,sizeof(CAsmNum));
|
||||
if (aotc->seg_size==16)
|
||||
cur.disp.U8_count=2;
|
||||
else
|
||||
cur.disp.U8_count=4;
|
||||
cur.has_addr_prefix=FALSE;
|
||||
} else if (ARGT_IMM8<=arg1<=ARGT_IMM64 ||
|
||||
ARGT_UIMM8<=arg1<=ARGT_UIMM64) {
|
||||
} else if (ARGt_IMM8<=arg1<=ARGt_IMM64 ||
|
||||
ARGt_UIMM8<=arg1<=ARGt_UIMM64) {
|
||||
MemCopy(&cur.imm.num,&tmpa1->num,sizeof(CAsmNum));
|
||||
if (arg1==ARGT_IMM8 || arg1==ARGT_UIMM8) cur.imm.U8_count=1;
|
||||
else if (arg1==ARGT_IMM16 || arg1==ARGT_UIMM16) cur.imm.U8_count=2;
|
||||
else if (arg1==ARGT_IMM32 || arg1==ARGT_UIMM32) cur.imm.U8_count=4;
|
||||
if (arg1==ARGt_IMM8 || arg1==ARGt_UIMM8) cur.imm.U8_count=1;
|
||||
else if (arg1==ARGt_IMM16 || arg1==ARGt_UIMM16) cur.imm.U8_count=2;
|
||||
else if (arg1==ARGt_IMM32 || arg1==ARGt_UIMM32) cur.imm.U8_count=4;
|
||||
else {
|
||||
cur.imm.U8_count=8;
|
||||
cur.REX|=8;
|
||||
}
|
||||
}
|
||||
if (ARGT_IMM8<=arg2<=ARGT_IMM64 ||
|
||||
ARGT_UIMM8<=arg2<=ARGT_UIMM64) {
|
||||
if (ARGt_IMM8<=arg2<=ARGt_IMM64 ||
|
||||
ARGt_UIMM8<=arg2<=ARGt_UIMM64) {
|
||||
MemCopy(&cur.imm.num,&tmpa2->num,sizeof(CAsmNum));
|
||||
if (arg2==ARGT_IMM8 || arg2==ARGT_UIMM8) cur.imm.U8_count=1;
|
||||
else if (arg2==ARGT_IMM16 || arg2==ARGT_UIMM16) cur.imm.U8_count=2;
|
||||
else if (arg2==ARGT_IMM32 || arg2==ARGT_UIMM32) {
|
||||
if (arg2==ARGt_IMM8 || arg2==ARGt_UIMM8) cur.imm.U8_count=1;
|
||||
else if (arg2==ARGt_IMM16 || arg2==ARGt_UIMM16) cur.imm.U8_count=2;
|
||||
else if (arg2==ARGt_IMM32 || arg2==ARGt_UIMM32) {
|
||||
cur.imm.U8_count=4;
|
||||
if (tmpins->flags&IEF_REX_ONLY_R8_R15 && arg2==ARGT_UIMM32)
|
||||
if (tmpins->flags&IEF_REX_ONLY_R8_R15 && arg2==ARGt_UIMM32)
|
||||
cur.REX&=~8;
|
||||
} else {
|
||||
cur.imm.U8_count=8;
|
||||
@ -1028,7 +1044,7 @@ U0 ParseAsmBlk(CCompCtrl *cc,I64 comp_flags)
|
||||
argcount=0;
|
||||
if (tmpo->ins[0].arg1) {
|
||||
argcount++;
|
||||
if (ARGT_REL8<=tmpo->ins[0].arg1<=ARGT_REL32)
|
||||
if (ARGt_REL8<=tmpo->ins[0].arg1<=ARGt_REL32)
|
||||
ParseAsmArg(cc,&aotc->arg1,TRUE);
|
||||
else
|
||||
ParseAsmArg(cc,&aotc->arg1,FALSE);
|
||||
@ -1038,7 +1054,7 @@ U0 ParseAsmBlk(CCompCtrl *cc,I64 comp_flags)
|
||||
LexExcept(cc,"Expecting ',' at ");
|
||||
else {
|
||||
Lex(cc); //skip ','
|
||||
if (ARGT_REL8<=tmpo->ins[0].arg2<=ARGT_REL32)
|
||||
if (ARGt_REL8<=tmpo->ins[0].arg2<=ARGt_REL32)
|
||||
ParseAsmArg(cc,&aotc->arg2,TRUE);
|
||||
else
|
||||
ParseAsmArg(cc,&aotc->arg2,FALSE);
|
||||
|
@ -1,45 +1,56 @@
|
||||
U0 AsmParseInsFlags(CCompCtrl *cc,CInst *tmpins)
|
||||
U0 AsmParseInsFlags(CCompCtrl *cc, CInst *tmpins)
|
||||
{
|
||||
I64 i;
|
||||
while (TRUE) {
|
||||
switch (cc->token) {
|
||||
|
||||
while (TRUE)
|
||||
{
|
||||
switch (cc->token)
|
||||
{
|
||||
case TK_IDENT:
|
||||
if ((i=ListMatch(cc->cur_str,"NO\0CB\0CW\0CD\0CP\0IB\0IW\0ID\0"))>=0) {
|
||||
tmpins->opcode_modifier=i;
|
||||
if ((i = ListMatch(cc->cur_str, "NO\0CB\0CW\0CD\0CP\0IB\0IW\0ID\0")) >= 0)
|
||||
{
|
||||
tmpins->opcode_modifier = i;
|
||||
break;
|
||||
} else
|
||||
}
|
||||
else
|
||||
return;
|
||||
case TK_I64:
|
||||
if (cc->cur_i64==16)
|
||||
tmpins->flags|=IEF_OP_SIZE16;
|
||||
if (cc->cur_i64 == 16)
|
||||
tmpins->flags |= IEF_OP_SIZE16;
|
||||
else if (cc->cur_i64==32)
|
||||
tmpins->flags|=IEF_OP_SIZE32;
|
||||
tmpins->flags |= IEF_OP_SIZE32;
|
||||
else
|
||||
return;
|
||||
break;
|
||||
case '+':
|
||||
tmpins->flags|=IEF_PLUS_OPCODE;
|
||||
tmpins->flags |= IEF_PLUS_OPCODE;
|
||||
case '/':
|
||||
if (Lex(cc)==TK_I64 && cc->cur_i64<8)
|
||||
tmpins->slash_val=cc->cur_i64;
|
||||
else if (cc->token==TK_IDENT) {
|
||||
if (!StrCompare(cc->cur_str,"R"))
|
||||
tmpins->slash_val=SV_R_REG;
|
||||
else if (!StrCompare(cc->cur_str,"I"))
|
||||
tmpins->slash_val=SV_I_REG;
|
||||
if (Lex(cc) == TK_I64)
|
||||
{
|
||||
if (cc->cur_i64 < 8)
|
||||
tmpins->slash_val = cc->cur_i64;
|
||||
else
|
||||
return;
|
||||
LexExcept(cc, "Invalid slash val at ");
|
||||
}
|
||||
else if (cc->token == TK_IDENT)
|
||||
{
|
||||
if (!StrCompare(cc->cur_str, "R"))
|
||||
tmpins->slash_val = SV_R_REG;
|
||||
else if (!StrCompare(cc->cur_str, "I"))
|
||||
tmpins->slash_val =SV_I_REG;
|
||||
else
|
||||
LexExcept(cc, "Invalid slash val at ");
|
||||
} else
|
||||
return;
|
||||
LexExcept(cc, "Invalid slash val at ");
|
||||
break;
|
||||
case '!': tmpins->flags|=IEF_DONT_SWITCH_MODES; break;
|
||||
case '&': tmpins->flags|=IEF_DEFAULT; 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;
|
||||
case '!': tmpins->flags |= IEF_DONT_SWITCH_MODES; break;
|
||||
case '&': tmpins->flags |= IEF_DEFAULT; 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;
|
||||
}
|
||||
@ -58,151 +69,170 @@ U0 AsmHashLoad()
|
||||
CInst *tmpins;
|
||||
CHashClass *tmpc;
|
||||
|
||||
cmp.size_arg_mask[0] = 0x3FF0FFFFFE;
|
||||
cmp.size_arg_mask[1] = 0x1110111112;
|
||||
cmp.size_arg_mask[2] = 0x2220222224;
|
||||
cmp.size_arg_mask[4] = 0x0440444448;
|
||||
cmp.size_arg_mask[8] = 0x0880888880;
|
||||
comp.size_arg_mask[0] = 0x3FF0FFFFFE;
|
||||
comp.size_arg_mask[1] = 0x1110111112;
|
||||
comp.size_arg_mask[2] = 0x2220222224;
|
||||
comp.size_arg_mask[4] = 0x0440444448;
|
||||
comp.size_arg_mask[8] = ARGG_SIZE_8;//0x20000880888880;
|
||||
comp.size_arg_mask[16] = ARGG_SIZE_16;
|
||||
|
||||
cmp.asm_hash = HashTableNew(1024);
|
||||
comp.asm_hash = HashTableNew(1024);
|
||||
size_max = offset(CHashOpcode.ins) + sizeof(CInst) << 5;
|
||||
tmpo_max = MAlloc(size_max);
|
||||
|
||||
cc=CompCtrlNew(FileRead("OpCodes.DD"),,"OpCodes.DD");
|
||||
cc = CompCtrlNew(FileRead("OpCodes.DD"),,"OpCodes.DD");
|
||||
cc->htc.hash_table_list=NULL;
|
||||
Lex(cc);
|
||||
while (cc->token) {
|
||||
if (cc->token!=TK_IDENT)
|
||||
LexExcept(cc,"Expecting identifier at ");
|
||||
i=ListMatch(cc->cur_str, "NONE\0R8\0R16\0R32\0R64\0SEG\0FSTACK\0MM\0XMM\0OPCODE\0KEYWORD\0ASM_KEYWORD\0");
|
||||
if (i<=0)
|
||||
while (cc->token)
|
||||
{
|
||||
if (cc->token != TK_IDENT)
|
||||
LexExcept(cc, "Expecting identifier at ");
|
||||
i = ListMatch(cc->cur_str, "NONE\0R8\0R16\0R32\0R64\0SEG\0FSTACK\0XMM\0OPCODE\0KEYWORD\0ASM_KEYWORD\0");
|
||||
if (i <= 0)
|
||||
LexExcept(cc,"Unknown Statement");
|
||||
Lex(cc); //skip keyword
|
||||
if (cc->token!=TK_IDENT)
|
||||
LexExcept(cc,"Expecting identifier at ");
|
||||
switch (i) {
|
||||
case REGT_R8...REGT_XMM:
|
||||
tmpr=CAlloc(sizeof(CHashReg));
|
||||
tmpr->str=cc->cur_str;
|
||||
cc->cur_str=NULL;
|
||||
if (cc->token != TK_IDENT)
|
||||
LexExcept(cc, "Expecting identifier at ");
|
||||
switch (i)
|
||||
{
|
||||
case REGT_R8 ... REGT_XMM:
|
||||
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 ");
|
||||
tmpr->type = HTT_REG;
|
||||
tmpr->reg_type = i;
|
||||
tmpr->reg_num = cc->cur_i64;
|
||||
HashAdd(tmpr, cmp.asm_hash);
|
||||
HashAdd(tmpr, comp.asm_hash);
|
||||
Lex(cc); //Skip INT
|
||||
break;
|
||||
|
||||
case: //OPCODE
|
||||
if (cc->token!=TK_IDENT)
|
||||
LexExcept(cc,"Expecting opcode at ");
|
||||
MemSet(tmpo_max,0,size_max);
|
||||
tmpo_max->type=HTT_OPCODE;
|
||||
tmpo_max->inst_entry_count=0;
|
||||
tmpo_max->str=cc->cur_str;
|
||||
if (cc->token != TK_IDENT)
|
||||
LexExcept(cc, "Expecting opcode at ");
|
||||
MemSet(tmpo_max, 0, size_max);
|
||||
tmpo_max->type = HTT_OPCODE;
|
||||
tmpo_max->inst_entry_count = 0;
|
||||
tmpo_max->str = cc->cur_str;
|
||||
cc->cur_str=0;
|
||||
Lex(cc); //Skip OPCODE
|
||||
while (cc->token && cc->token!=';' && cc->token!=':') {
|
||||
tmpins=&tmpo_max->ins[tmpo_max->inst_entry_count];
|
||||
tmpins->ins_entry_num=tmpo_max->inst_entry_count++;
|
||||
tmpins->slash_val=SV_NONE; //Not zero!!
|
||||
while (cc->token==TK_I64) {
|
||||
tmpins->opcode[tmpins->opcode_count++]=cc->cur_i64;
|
||||
|
||||
while (cc->token && cc->token != ';' && cc->token != ':')
|
||||
{
|
||||
tmpins = &tmpo_max->ins[tmpo_max->inst_entry_count];
|
||||
tmpins->ins_entry_num = tmpo_max->inst_entry_count++;
|
||||
tmpins->slash_val = SV_NONE; //Not zero!!
|
||||
|
||||
while (cc->token == TK_I64)
|
||||
{
|
||||
tmpins->opcode[tmpins->opcode_count++] = cc->cur_i64;
|
||||
Lex(cc);
|
||||
}
|
||||
if (cc->token==',')
|
||||
|
||||
if (cc->token == ',')
|
||||
Lex(cc);
|
||||
else if (cc->token!=';')
|
||||
LexExcept(cc,"Expecting ',' at ");
|
||||
else if (cc->token != ';')
|
||||
LexExcept(cc, "Expecting ',' at ");
|
||||
|
||||
AsmParseInsFlags(cc,tmpins);
|
||||
|
||||
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;
|
||||
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;
|
||||
|
||||
tmpins->arg1=tmpins->arg2=tmpins->size1=tmpins->size2=0;
|
||||
if (cc->token==TK_IDENT) {
|
||||
j=DefineMatch(cc->cur_str,"ST_ARG_TYPES");
|
||||
tmpins->arg1=j;
|
||||
if (Bt(&cmp.size_arg_mask[1],j))
|
||||
tmpins->size1=8;
|
||||
else if (Bt(&cmp.size_arg_mask[2],j))
|
||||
tmpins->size1=16;
|
||||
else if (Bt(&cmp.size_arg_mask[4],j))
|
||||
tmpins->size1=32;
|
||||
else if (Bt(&cmp.size_arg_mask[8],j))
|
||||
tmpins->size1=64;
|
||||
tmpins->arg1 = tmpins->arg2 = tmpins->size1 = tmpins->size2 = 0;
|
||||
if (cc->token == TK_IDENT)
|
||||
{
|
||||
j = DefineMatch(cc->cur_str, "ST_ARG_TYPES");
|
||||
tmpins->arg1 = j;
|
||||
if (Bt(&comp.size_arg_mask[1], j))
|
||||
tmpins->size1 = 8;
|
||||
else if (Bt(&comp.size_arg_mask[2], j))
|
||||
tmpins->size1 = 16;
|
||||
else if (Bt(&comp.size_arg_mask[4], j))
|
||||
tmpins->size1 = 32;
|
||||
else if (Bt(&comp.size_arg_mask[8], j))
|
||||
tmpins->size1 = 64;
|
||||
else if (Bt(&comp.size_arg_mask[16], j))
|
||||
tmpins->size1 = 128;
|
||||
|
||||
if (Lex(cc)==TK_IDENT) {
|
||||
j=DefineMatch(cc->cur_str,"ST_ARG_TYPES");
|
||||
if (Lex(cc) == TK_IDENT)
|
||||
{
|
||||
j = DefineMatch(cc->cur_str, "ST_ARG_TYPES");
|
||||
Lex(cc);
|
||||
tmpins->arg2=j;
|
||||
if (Bt(&cmp.size_arg_mask[1],j))
|
||||
tmpins->size2=8;
|
||||
else if (Bt(&cmp.size_arg_mask[2],j))
|
||||
tmpins->size2=16;
|
||||
else if (Bt(&cmp.size_arg_mask[4],j))
|
||||
tmpins->size2=32;
|
||||
else if (Bt(&cmp.size_arg_mask[8],j))
|
||||
tmpins->size2=64;
|
||||
tmpins->arg2 = j;
|
||||
if (Bt(&comp.size_arg_mask[1], j))
|
||||
tmpins->size2 = 8;
|
||||
else if (Bt(&comp.size_arg_mask[2], j))
|
||||
tmpins->size2 = 16;
|
||||
else if (Bt(&comp.size_arg_mask[4], j))
|
||||
tmpins->size2 = 32;
|
||||
else if (Bt(&comp.size_arg_mask[8], j))
|
||||
tmpins->size2 = 64;
|
||||
else if(Bt(&comp.size_arg_mask[16], j))
|
||||
tmpins->size2 = 128;
|
||||
}
|
||||
}
|
||||
}
|
||||
size=offset(CHashOpcode.ins)+sizeof(CInst)*tmpo_max->inst_entry_count;
|
||||
tmpo=MAlloc(size);
|
||||
MemCopy(tmpo,tmpo_max,size);
|
||||
tmpo->use_count=0;
|
||||
if (HashFind(tmpo->str,cmp.asm_hash,HTT_OPCODE))
|
||||
size = offset(CHashOpcode.ins) + sizeof(CInst) * tmpo_max->inst_entry_count;
|
||||
tmpo = MAlloc(size);
|
||||
MemCopy(tmpo, tmpo_max, size);
|
||||
tmpo->use_count = 0;
|
||||
if (HashFind(tmpo->str, comp.asm_hash, HTT_OPCODE))
|
||||
LexExcept(cc,"Duplicate OPCODE entry ");
|
||||
HashAdd(tmpo,cmp.asm_hash);
|
||||
HashAdd(tmpo, comp.asm_hash);
|
||||
//Parse aliases.
|
||||
if (cc->token==':') {
|
||||
while (Lex(cc)==TK_IDENT) {
|
||||
tmpo2=MAllocIdent(tmpo);
|
||||
tmpo2->str=cc->cur_str;
|
||||
cc->cur_str=0;
|
||||
tmpo2->oc_flags|=OCF_ALIAS;
|
||||
if (HashFind(tmpo2->str,cmp.asm_hash,HTT_OPCODE))
|
||||
LexExcept(cc,"Duplicate OPCODE ALIAS entry ");
|
||||
HashAdd(tmpo2,cmp.asm_hash);
|
||||
if (cc->token == ':')
|
||||
{
|
||||
while (Lex(cc) == TK_IDENT)
|
||||
{
|
||||
tmpo2 = MAllocIdent(tmpo);
|
||||
tmpo2->str = cc->cur_str;
|
||||
cc->cur_str = NULL;
|
||||
tmpo2->oc_flags |= OCF_ALIAS;
|
||||
if (HashFind(tmpo2->str, comp.asm_hash, HTT_OPCODE))
|
||||
LexExcept(cc, "Duplicate OPCODE ALIAS entry ");
|
||||
HashAdd(tmpo2, comp.asm_hash);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case: //KEYWORD
|
||||
case: //ASM_KEYWORD
|
||||
tmph=CAlloc(sizeof(CHashGeneric));
|
||||
tmph->str=cc->cur_str;
|
||||
cc->cur_str=NULL;
|
||||
tmph = CAlloc(sizeof(CHashGeneric));
|
||||
tmph->str = cc->cur_str;
|
||||
cc->cur_str = NULL;
|
||||
Lex(cc); //skip keyword name
|
||||
if (cc->token!=TK_I64)
|
||||
if (cc->token != TK_I64)
|
||||
LexExcept(cc,"Expecting int at ");
|
||||
tmph->user_data0=cc->cur_i64;
|
||||
if (i==10)
|
||||
tmph->type=HTT_KEYWORD;
|
||||
tmph->user_data0 = cc->cur_i64;
|
||||
if (i == 9) //what a stupid way of doing things.
|
||||
tmph->type = HTT_KEYWORD;
|
||||
else
|
||||
tmph->type=HTT_ASM_KEYWORD;
|
||||
HashAdd(tmph,cmp.asm_hash);
|
||||
tmph->type = HTT_ASM_KEYWORD;
|
||||
HashAdd(tmph, comp.asm_hash);
|
||||
Lex(cc); //Skip INT
|
||||
break;
|
||||
}
|
||||
if (cc->token!=';')
|
||||
LexExcept(cc,"Missing ';' at");
|
||||
if (cc->token != ';')
|
||||
LexExcept(cc, "Missing ';' at ");
|
||||
Lex(cc); //Skip ';'
|
||||
}
|
||||
Free(tmpo_max);
|
||||
CompCtrlDel(cc);
|
||||
for (i=0;i<INTERNAL_TYPES_NUM;i++) {
|
||||
tmpit=&internal_types_table[i];
|
||||
tmpc=ParseClassNew;
|
||||
tmpc->type=HTT_INTERNAL_TYPE;
|
||||
tmpc->raw_type=tmpit->type;
|
||||
Bts(&tmpc->flags,Cf_INTERNAL_TYPE);
|
||||
tmpc->size=tmpit->size;
|
||||
tmpc->str=ZStrNew(tmpit->name);
|
||||
HashAdd(tmpc,cmp.asm_hash);
|
||||
cmp.internal_types[tmpc->raw_type]=tmpc;
|
||||
for (i = 0; i < INTERNAL_TYPES_NUM; i++)
|
||||
{
|
||||
tmpit = &internal_types_table[i];
|
||||
tmpc = ParseClassNew;
|
||||
tmpc->type = HTT_INTERNAL_TYPE;
|
||||
tmpc->raw_type = tmpit->type;
|
||||
Bts(&tmpc->flags, Cf_INTERNAL_TYPE);
|
||||
tmpc->size = tmpit->size;
|
||||
tmpc->str = ZStrNew(tmpit->name);
|
||||
HashAdd(tmpc, comp.asm_hash);
|
||||
comp.internal_types[tmpc->raw_type] = tmpc;
|
||||
}
|
||||
zenith_task->hash_table->next=cmp.asm_hash;
|
||||
zenith_task->hash_table->next=comp.asm_hash;
|
||||
}
|
||||
|
@ -93,7 +93,7 @@ U0 ICAddSubEctImm(CIntermediateCode *tmpi,CICType t1,I64 r1,I64 d1,
|
||||
}
|
||||
}
|
||||
if (op.u8[0]==0x03 && I32_MIN<=d<=I32_MAX &&
|
||||
!Bt(&cmp.non_ptr_vars_mask,r2)) {
|
||||
!Bt(&comp.non_ptr_vars_mask,r2)) {
|
||||
i=ICModr1(r1,MDF_DISP+RT_I64,r2,d);
|
||||
i.u8[1]|=0x48;
|
||||
ICU24(tmpi,i.u8[2]<<16+0x8D00+i.u8[1]);
|
||||
|
@ -353,15 +353,6 @@ U0 CompLoadDefines()
|
||||
"R14\0"
|
||||
"R15\0");
|
||||
|
||||
DefineListLoad("ST_MM_REGS",
|
||||
"MM0\0"
|
||||
"MM1\0"
|
||||
"MM2\0"
|
||||
"MM3\0"
|
||||
"MM4\0"
|
||||
"MM5\0"
|
||||
"MM6\0"
|
||||
"MM7\0");
|
||||
DefineListLoad("ST_XMM_REGS",
|
||||
"XMM0\0"
|
||||
"XMM1\0"
|
||||
@ -432,10 +423,9 @@ U0 CompLoadDefines()
|
||||
"MM32\0"
|
||||
"MM64\0"
|
||||
"XMM\0"
|
||||
"XMM32\0"
|
||||
"XMM0\0"
|
||||
"XMM64\0"
|
||||
"XMM128\0"
|
||||
"XMM0\0");
|
||||
"XMM128\0");
|
||||
|
||||
DefineListLoad("ST_SEG_REGS",
|
||||
"ES\0"
|
||||
@ -461,21 +451,21 @@ U0 CompFillTables()
|
||||
I64 i;
|
||||
U32 *d;
|
||||
|
||||
cmp.to_reg_vars_map=CAlloc(REG_REGS_NUM*sizeof(U8));
|
||||
cmp.num_reg_vars=0;
|
||||
cmp.reg_vars_mask=REGG_LOCAL_VARS;
|
||||
comp.to_reg_vars_map=CAlloc(REG_REGS_NUM*sizeof(U8));
|
||||
comp.num_reg_vars=0;
|
||||
comp.reg_vars_mask=REGG_LOCAL_VARS;
|
||||
for (i=0;i<REG_REGS_NUM;i++)
|
||||
if (Bt(&cmp.reg_vars_mask,i))
|
||||
cmp.to_reg_vars_map[cmp.num_reg_vars++]=i;
|
||||
if (Bt(&comp.reg_vars_mask,i))
|
||||
comp.to_reg_vars_map[comp.num_reg_vars++]=i;
|
||||
|
||||
cmp.non_ptr_vars_map=CAlloc(REG_REGS_NUM*sizeof(U8));
|
||||
cmp.num_non_ptr_vars=0;
|
||||
cmp.non_ptr_vars_mask=REGG_LOCAL_NON_PTR_VARS;
|
||||
comp.non_ptr_vars_map=CAlloc(REG_REGS_NUM*sizeof(U8));
|
||||
comp.num_non_ptr_vars=0;
|
||||
comp.non_ptr_vars_mask=REGG_LOCAL_NON_PTR_VARS;
|
||||
for (i=0;i<REG_REGS_NUM;i++)
|
||||
if (Bt(&cmp.non_ptr_vars_mask,i))
|
||||
cmp.non_ptr_vars_map[cmp.num_non_ptr_vars++]=i;
|
||||
if (Bt(&comp.non_ptr_vars_mask,i))
|
||||
comp.non_ptr_vars_map[comp.num_non_ptr_vars++]=i;
|
||||
|
||||
cmp.dual_U16_tokens1=d=CAlloc(sizeof(U32)*TK_TKS_NUM);
|
||||
comp.dual_U16_tokens1=d=CAlloc(sizeof(U32)*TK_TKS_NUM);
|
||||
d['!']=TK_NOT_EQU<<16+'=';
|
||||
d['&']=TK_AND_AND<<16+'&';
|
||||
d['*']=TK_MUL_EQU<<16+'=';
|
||||
@ -490,7 +480,7 @@ U0 CompFillTables()
|
||||
d['|']=TK_OR_OR<<16+'|';
|
||||
d['%']=TK_MOD_EQU<<16+'=';
|
||||
|
||||
cmp.dual_U16_tokens2=d=CAlloc(sizeof(U32)*TK_TKS_NUM);
|
||||
comp.dual_U16_tokens2=d=CAlloc(sizeof(U32)*TK_TKS_NUM);
|
||||
d['&']=TK_AND_EQU<<16+'=';
|
||||
d['+']=TK_ADD_EQU<<16+'=';
|
||||
d['-']=TK_MINUS_MINUS<<16+'-';
|
||||
@ -500,11 +490,11 @@ U0 CompFillTables()
|
||||
d['^']=TK_XOR_XOR<<16+'^';
|
||||
d['|']=TK_OR_EQU<<16+'=';
|
||||
|
||||
cmp.dual_U16_tokens3=d=CAlloc(sizeof(U32)*TK_TKS_NUM);
|
||||
comp.dual_U16_tokens3=d=CAlloc(sizeof(U32)*TK_TKS_NUM);
|
||||
d['-']=TK_SUB_EQU<<16+'=';
|
||||
d['/']=TK_DIV_EQU<<16+'=';
|
||||
|
||||
cmp.binary_ops=d=CAlloc(sizeof(U32)*TK_TKS_NUM);
|
||||
comp.binary_ops=d=CAlloc(sizeof(U32)*TK_TKS_NUM);
|
||||
d['`'] =(PREC_EXP+ASSOCF_RIGHT)<<16+IC_POWER;
|
||||
d[TK_SHL]=(PREC_EXP+ASSOCF_LEFT)<<16+IC_SHL;
|
||||
d[TK_SHR]=(PREC_EXP+ASSOCF_LEFT)<<16+IC_SHR;
|
||||
|
@ -65,7 +65,7 @@ CAOT *CompJoin(CCompCtrl *cc,I64 comp_flags,U8 *map_name=NULL,U8 mapfile_drive_l
|
||||
if (cc->flags&CCF_AOT_COMPILE) {
|
||||
cc->htc.define_hash_table=cc->htc.glbl_hash_table;
|
||||
if (cc->aot_depth<=1)
|
||||
cc->htc.glbl_hash_table->next=cmp.asm_hash;
|
||||
cc->htc.glbl_hash_table->next=comp.asm_hash;
|
||||
else
|
||||
cc->htc.glbl_hash_table->next=htc->glbl_hash_table;
|
||||
} else
|
||||
@ -692,9 +692,9 @@ U0 CInit()
|
||||
{
|
||||
CompLoadDefines;
|
||||
CompFillTables;
|
||||
QueueInit(&cmp.ic_nop);
|
||||
cmp.ic_nop.ic_class=cmp.internal_types[RT_I64];
|
||||
cmp.ic_nop.ic_code=IC_NOP1;
|
||||
QueueInit(&comp.ic_nop);
|
||||
comp.ic_nop.ic_class=comp.internal_types[RT_I64];
|
||||
comp.ic_nop.ic_code=IC_NOP1;
|
||||
AsmHashLoad;
|
||||
UAsmHashLoad;
|
||||
}
|
||||
|
@ -13,7 +13,7 @@
|
||||
#exe {Option(OPTf_KEEP_PRIVATE,OFF);};
|
||||
#include "Templates"
|
||||
#include "CExterns"
|
||||
CCompGlobals cmp;
|
||||
CCompGlobals comp;
|
||||
#include "CInit"
|
||||
#include "CExcept"
|
||||
#include "LexLib"
|
||||
|
@ -237,81 +237,81 @@ class CIntermediateStruct
|
||||
#define IC_POPCNT 0xB9
|
||||
#define IC_ICS_NUM 0xBA
|
||||
|
||||
#define KW_INCLUDE 0
|
||||
#define KW_DEFINE 1
|
||||
#define KW_UNION 2
|
||||
#define KW_CATCH 3
|
||||
#define KW_CLASS 4
|
||||
#define KW_TRY 5
|
||||
#define KW_IF 6
|
||||
#define KW_ELSE 7
|
||||
#define KW_FOR 8
|
||||
#define KW_WHILE 9
|
||||
#define KW_EXTERN 10
|
||||
#define KW__EXTERN 11
|
||||
#define KW_RETURN 12
|
||||
#define KW_SIZEOF 13
|
||||
#define KW__INTERN 14
|
||||
#define KW_DO 15
|
||||
#define KW_ASM 16
|
||||
#define KW_GOTO 17
|
||||
#define KW_EXE 18
|
||||
#define KW_BREAK 19
|
||||
#define KW_SWITCH 20
|
||||
#define KW_START 21
|
||||
#define KW_END 22
|
||||
#define KW_CASE 23
|
||||
#define KW_DEFAULT 24
|
||||
#define KW_PUBLIC 25
|
||||
#define KW_OFFSET 26
|
||||
#define KW_IMPORT 27
|
||||
#define KW__IMPORT 28
|
||||
#define KW_IFDEF 29
|
||||
#define KW_IFNDEF 30
|
||||
#define KW_IFAOT 31
|
||||
#define KW_IFJIT 32
|
||||
#define KW_ENDIF 33
|
||||
#define KW_ASSERT 34
|
||||
#define KW_REG 35
|
||||
#define KW_NOREG 36
|
||||
#define KW_LASTCLASS 37
|
||||
#define KW_NO_WARN 38
|
||||
#define KW_INCLUDE 0
|
||||
#define KW_DEFINE 1
|
||||
#define KW_UNION 2
|
||||
#define KW_CATCH 3
|
||||
#define KW_CLASS 4
|
||||
#define KW_TRY 5
|
||||
#define KW_IF 6
|
||||
#define KW_ELSE 7
|
||||
#define KW_FOR 8
|
||||
#define KW_WHILE 9
|
||||
#define KW_EXTERN 10
|
||||
#define KW__EXTERN 11
|
||||
#define KW_RETURN 12
|
||||
#define KW_SIZEOF 13
|
||||
#define KW__INTERN 14
|
||||
#define KW_DO 15
|
||||
#define KW_ASM 16
|
||||
#define KW_GOTO 17
|
||||
#define KW_EXE 18
|
||||
#define KW_BREAK 19
|
||||
#define KW_SWITCH 20
|
||||
#define KW_START 21
|
||||
#define KW_END 22
|
||||
#define KW_CASE 23
|
||||
#define KW_DEFAULT 24
|
||||
#define KW_PUBLIC 25
|
||||
#define KW_OFFSET 26
|
||||
#define KW_IMPORT 27
|
||||
#define KW__IMPORT 28
|
||||
#define KW_IFDEF 29
|
||||
#define KW_IFNDEF 30
|
||||
#define KW_IFAOT 31
|
||||
#define KW_IFJIT 32
|
||||
#define KW_ENDIF 33
|
||||
#define KW_ASSERT 34
|
||||
#define KW_REG 35
|
||||
#define KW_NOREG 36
|
||||
#define KW_LASTCLASS 37
|
||||
#define KW_NO_WARN 38
|
||||
#define KW_HELP_INDEX 39
|
||||
#define KW_HELP_FILE 40
|
||||
#define KW_STATIC 41
|
||||
#define KW_LOCK 42
|
||||
#define KW_DEFINED 43
|
||||
#define KW_INTERRUPT 44
|
||||
#define KW_HELP_FILE 40
|
||||
#define KW_STATIC 41
|
||||
#define KW_LOCK 42
|
||||
#define KW_DEFINED 43
|
||||
#define KW_INTERRUPT 44
|
||||
#define KW_HASERRCODE 45
|
||||
#define KW_ARGPOP 46
|
||||
#define KW_NOARGPOP 47
|
||||
#define KW_ARGPOP 46
|
||||
#define KW_NOARGPOP 47
|
||||
|
||||
#define AKW_ALIGN 64
|
||||
#define AKW_ORG 65
|
||||
#define AKW_I0 66
|
||||
#define AKW_I8 67
|
||||
#define AKW_I16 68
|
||||
#define AKW_I32 69
|
||||
#define AKW_I64 70
|
||||
#define AKW_U0 71
|
||||
#define AKW_U8 72
|
||||
#define AKW_U16 73
|
||||
#define AKW_U32 74
|
||||
#define AKW_U64 75
|
||||
#define AKW_F64 76
|
||||
#define AKW_DU8 77
|
||||
#define AKW_DU16 78
|
||||
#define AKW_DU32 79
|
||||
#define AKW_DU64 80
|
||||
#define AKW_DUP 81
|
||||
#define AKW_USE16 82
|
||||
#define AKW_USE32 83
|
||||
#define AKW_USE64 84
|
||||
#define AKW_IMPORT 85
|
||||
#define AKW_LIST 86
|
||||
#define AKW_NOLIST 87
|
||||
#define AKW_BINFILE 88
|
||||
#define KW_KWS_NUM 89
|
||||
#define AKW_ALIGN 64
|
||||
#define AKW_ORG 65
|
||||
#define AKW_I0 66
|
||||
#define AKW_I8 67
|
||||
#define AKW_I16 68
|
||||
#define AKW_I32 69
|
||||
#define AKW_I64 70
|
||||
#define AKW_U0 71
|
||||
#define AKW_U8 72
|
||||
#define AKW_U16 73
|
||||
#define AKW_U32 74
|
||||
#define AKW_U64 75
|
||||
#define AKW_F64 76
|
||||
#define AKW_DU8 77
|
||||
#define AKW_DU16 78
|
||||
#define AKW_DU32 79
|
||||
#define AKW_DU64 80
|
||||
#define AKW_DUP 81
|
||||
#define AKW_USE16 82
|
||||
#define AKW_USE32 83
|
||||
#define AKW_USE64 84
|
||||
#define AKW_IMPORT 85
|
||||
#define AKW_LIST 86
|
||||
#define AKW_NOLIST 87
|
||||
#define AKW_BINFILE 88
|
||||
#define KW_KWS_NUM 89
|
||||
|
||||
#define CMP_TEMPLATE_INC 0x00
|
||||
#define CMP_TEMPLATE_DEC 0x01
|
||||
|
@ -10,7 +10,7 @@ public extern I64 ExePutS2(U8 *buf,U8 *filename=NULL,I64 ccf_flags=0);
|
||||
public _extern _LAST_FUN I64 LastFun(I64 argc,I64 *argv);
|
||||
public extern I64 RunFile(U8 *name,I64 ccf_flags=0,...);
|
||||
public extern I64 RunFile2(U8 *name,I64 ccf_flags=0,...);
|
||||
public extern CCompGlobals cmp;
|
||||
public extern CCompGlobals comp;
|
||||
|
||||
#help_index "Compiler/Directive"
|
||||
#help_file "::/Doc/Directives"
|
||||
|
@ -147,7 +147,7 @@ lgc_start2:
|
||||
tmpf->line_start=doc_e->next;
|
||||
tmpf->line_num=doc_e->y+2;//+1 because NEW_LINE is on prev line
|
||||
//+1 because doc y starts at zero
|
||||
cmp.compiled_lines++;
|
||||
comp.compiled_lines++;
|
||||
cc->last_U16='\n';
|
||||
goto lgc_done;
|
||||
case DOCT_TAB:
|
||||
@ -245,7 +245,7 @@ lgc_start2:
|
||||
tmpf=cc->lex_include_stack;
|
||||
if (!(tmpf->flags & LFSF_DOC)) {
|
||||
tmpf->line_num++;
|
||||
cmp.compiled_lines++;
|
||||
comp.compiled_lines++;
|
||||
tmpf->line_start=src;
|
||||
}
|
||||
break;
|
||||
@ -1093,7 +1093,7 @@ lex_dot_dot:
|
||||
case ']'...'^':
|
||||
case '{'...'~':
|
||||
case '`':
|
||||
if (!(i=cmp.dual_U16_tokens1[ch])) {
|
||||
if (!(i=comp.dual_U16_tokens1[ch])) {
|
||||
if (ch=='$$') {
|
||||
ch=LexGetChar(cc);
|
||||
if (ch=='$$') {
|
||||
@ -1148,7 +1148,7 @@ lex_check_comment:
|
||||
goto lex_end;
|
||||
}
|
||||
}
|
||||
if (i=cmp.dual_U16_tokens2[ch]) {
|
||||
if (i=comp.dual_U16_tokens2[ch]) {
|
||||
if (i.u16[0]==j) {
|
||||
i>>=16;
|
||||
if (!i) {// "//"
|
||||
@ -1173,7 +1173,7 @@ lex_check_comment:
|
||||
goto lex_end;
|
||||
}
|
||||
}
|
||||
if (i=cmp.dual_U16_tokens3[ch]) {
|
||||
if (i=comp.dual_U16_tokens3[ch]) {
|
||||
if (i.u16[0]==j) {
|
||||
cc->token=i.u16[1];
|
||||
goto lex_end;
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* See $LK,"AsmHashLoad",A="MN:AsmHashLoad"$().
|
||||
$HL$/* See $LK,"AsmHashLoad",A="MN:AsmHashLoad"$().
|
||||
|
||||
'!'= IEF_DONT_SWITCH_MODES
|
||||
'&'= IEF_DEFAULT
|
||||
@ -119,15 +119,6 @@ FSTACK ST5 5;
|
||||
FSTACK ST6 6;
|
||||
FSTACK ST7 7;
|
||||
|
||||
MM MM0 0;
|
||||
MM MM1 1;
|
||||
MM MM2 2;
|
||||
MM MM3 3;
|
||||
MM MM4 4;
|
||||
MM MM5 5;
|
||||
MM MM6 6;
|
||||
MM MM7 7;
|
||||
|
||||
XMM XMM0 0;
|
||||
XMM XMM1 1;
|
||||
XMM XMM2 2;
|
||||
@ -1308,4 +1299,9 @@ OPCODE MOV_RAX_CR3 0x0F 0x20 0xD8, 32=;
|
||||
OPCODE MOV_CR4_RAX 0x0F 0x22 0xE0, 32=;
|
||||
OPCODE MOV_RAX_CR4 0x0F 0x20 0xE0, 32=;
|
||||
|
||||
OPCODE MULPD 0x66 0x0F 0x59,/R XMM XMM;
|
||||
OPCODE MOVD
|
||||
0x66 0x0F 0x6E,/R 32 XMM RM32
|
||||
0x66 0x0F 0x7E,/R 32 RM32 XMM;
|
||||
OPCODE MOVQ
|
||||
0x66 0x48 0x0F 0x6E,/R XMM RM64
|
||||
0x66 0x48 0x0F 0x7E,/R RM64 XMM;
|
||||
|
@ -101,17 +101,17 @@ Bool OptFixupBinaryOp1(CIntermediateCode *tmpi,
|
||||
CHashClass *tmpc=tmpi->ic_class,*tmpc1,*tmpc2;
|
||||
|
||||
if (tmpi1->ic_flags&ICF_RES_TO_INT)
|
||||
tmpc1=cmp.internal_types[RT_I64];
|
||||
tmpc1=comp.internal_types[RT_I64];
|
||||
else if (tmpi1->ic_flags&ICF_RES_TO_F64)
|
||||
tmpc1=cmp.internal_types[RT_F64];
|
||||
tmpc1=comp.internal_types[RT_F64];
|
||||
else {
|
||||
tmpc1=OptClassFwd(tmpi1->ic_class);
|
||||
}
|
||||
|
||||
if (tmpi2->ic_flags&ICF_RES_TO_INT)
|
||||
tmpc2=cmp.internal_types[RT_I64];
|
||||
tmpc2=comp.internal_types[RT_I64];
|
||||
else if (tmpi2->ic_flags&ICF_RES_TO_F64)
|
||||
tmpc2=cmp.internal_types[RT_F64];
|
||||
tmpc2=comp.internal_types[RT_F64];
|
||||
else {
|
||||
tmpc2=OptClassFwd(tmpi2->ic_class);
|
||||
}
|
||||
@ -124,7 +124,7 @@ Bool OptFixupBinaryOp1(CIntermediateCode *tmpi,
|
||||
if (tmpc->raw_type==RT_F64) {
|
||||
if (tmpi1->ic_code==IC_IMM_I64) {
|
||||
tmpi1->ic_data(F64)=tmpi1->ic_data;
|
||||
tmpi1->ic_class=cmp.internal_types[RT_F64];
|
||||
tmpi1->ic_class=comp.internal_types[RT_F64];
|
||||
tmpi1->ic_code=IC_IMM_F64;
|
||||
tmpi1->ic_flags&=~ICF_RES_TO_F64;
|
||||
} else
|
||||
@ -132,7 +132,7 @@ Bool OptFixupBinaryOp1(CIntermediateCode *tmpi,
|
||||
tmpi1->ic_flags|=ICF_RES_TO_F64;
|
||||
if (tmpi2->ic_code==IC_IMM_I64) {
|
||||
tmpi2->ic_data(F64)=tmpi2->ic_data;
|
||||
tmpi2->ic_class=cmp.internal_types[RT_F64];
|
||||
tmpi2->ic_class=comp.internal_types[RT_F64];
|
||||
tmpi2->ic_code=IC_IMM_F64;
|
||||
tmpi2->ic_flags&=~ICF_RES_TO_F64;
|
||||
} else
|
||||
@ -142,16 +142,16 @@ Bool OptFixupBinaryOp1(CIntermediateCode *tmpi,
|
||||
tmpii->ic_code!=IC_PUSH_CMP && tmpii->ic_code!=IC_AND_AND) {
|
||||
//We are looking for float comparisons to zero to convert to int.
|
||||
if (tmpi1->ic_code==IC_IMM_F64 && !tmpi1->ic_data &&
|
||||
tmpi2->ic_code==IC_DEREF && tmpc2==cmp.internal_types[RT_F64]) {
|
||||
tmpi2->ic_code==IC_DEREF && tmpc2==comp.internal_types[RT_F64]) {
|
||||
tmpi1->ic_code==IC_IMM_I64;
|
||||
goto fb_here1;
|
||||
} else if (tmpi2->ic_code==IC_IMM_F64 && !tmpi2->ic_data &&
|
||||
tmpi1->ic_code==IC_DEREF && tmpc1==cmp.internal_types[RT_F64]) {
|
||||
tmpi1->ic_code==IC_DEREF && tmpc1==comp.internal_types[RT_F64]) {
|
||||
tmpi2->ic_code==IC_IMM_I64;
|
||||
fb_here1:
|
||||
tmpi1->ic_flags&=~ICF_RES_TO_F64;
|
||||
tmpi->ic_class=tmpi1->ic_class=tmpi2->ic_class=
|
||||
cmp.internal_types[RT_I64];
|
||||
comp.internal_types[RT_I64];
|
||||
*is_unsigned=FALSE;
|
||||
return FBO1_NOT_CONST;
|
||||
}
|
||||
@ -203,7 +203,7 @@ Bool OptFixupUnaryOp(CIntermediateCode *tmpi, CIntermediateCode *tmpi1,
|
||||
if (tmpc->raw_type==RT_F64) {
|
||||
if (tmpi1->ic_code==IC_IMM_I64) {
|
||||
tmpi1->ic_data(F64)=tmpi1->ic_data;
|
||||
tmpi1->ic_class=cmp.internal_types[RT_F64];
|
||||
tmpi1->ic_class=comp.internal_types[RT_F64];
|
||||
tmpi1->ic_code=IC_IMM_F64;
|
||||
tmpi1->ic_flags&=~ICF_RES_TO_F64;
|
||||
} else
|
||||
|
@ -72,7 +72,7 @@ args.
|
||||
tmpi->ic_data=ToI64(tmpi->ic_data(F64));
|
||||
tmpi->ic_flags&=~ICF_RES_TO_INT;
|
||||
tmpi->ic_code=IC_IMM_I64;
|
||||
tmpi->ic_class=cmp.internal_types[RT_I64];
|
||||
tmpi->ic_class=comp.internal_types[RT_I64];
|
||||
}
|
||||
break;
|
||||
case IC_IMM_I64:
|
||||
@ -81,7 +81,7 @@ args.
|
||||
tmpi->ic_data(F64)=ToF64(tmpi->ic_data);
|
||||
tmpi->ic_flags&=~ICF_RES_TO_F64;
|
||||
tmpi->ic_code=IC_IMM_F64;
|
||||
tmpi->ic_class=cmp.internal_types[RT_F64];
|
||||
tmpi->ic_class=comp.internal_types[RT_F64];
|
||||
}
|
||||
break;
|
||||
case IC_HOLYC_TYPECAST:
|
||||
@ -98,9 +98,9 @@ args.
|
||||
if (tmpi->ic_data) {//was paren
|
||||
if (!tmpi_push->ic_class->ptr_stars_count) {
|
||||
if (tmpi_push->ic_class->raw_type==RT_F64)
|
||||
tmpi_push->ic_class2=cmp.internal_types[RT_F64];
|
||||
tmpi_push->ic_class2=comp.internal_types[RT_F64];
|
||||
else
|
||||
tmpi_push->ic_class2=cmp.internal_types[RT_I64];
|
||||
tmpi_push->ic_class2=comp.internal_types[RT_I64];
|
||||
}
|
||||
} else {
|
||||
tmpi1->ic_class=tmpi->ic_class;
|
||||
@ -157,7 +157,7 @@ args.
|
||||
tmpi->ic_flags|=tmpi1->ic_flags;
|
||||
OptSetNOP1(tmpi1);
|
||||
}
|
||||
tmpi_push->ic_class2=cmp.internal_types[RT_I64];
|
||||
tmpi_push->ic_class2=comp.internal_types[RT_I64];
|
||||
break;
|
||||
start:
|
||||
case IC_NOT:
|
||||
@ -188,7 +188,7 @@ args.
|
||||
}
|
||||
}
|
||||
if (tmpc1->type&HTT_INTERNAL_TYPE && tmpc1->raw_type&RTF_UNSIGNED)
|
||||
tmpi->ic_class=cmp.internal_types[tmpc1->raw_type-1];
|
||||
tmpi->ic_class=comp.internal_types[tmpc1->raw_type-1];
|
||||
break;
|
||||
case IC_SHL_CONST:
|
||||
if (i=OptFixupUnaryOp(tmpi,tmpi1,&is_unsigned)) {
|
||||
@ -267,9 +267,9 @@ args.
|
||||
end:
|
||||
if (!tmpi_push->ic_class->ptr_stars_count) {
|
||||
if (tmpi_push->ic_class->raw_type==RT_F64)
|
||||
tmpi_push->ic_class2=cmp.internal_types[RT_F64];
|
||||
tmpi_push->ic_class2=comp.internal_types[RT_F64];
|
||||
else
|
||||
tmpi_push->ic_class2=cmp.internal_types[RT_I64];
|
||||
tmpi_push->ic_class2=comp.internal_types[RT_I64];
|
||||
}
|
||||
break;
|
||||
case IC_DEREF:
|
||||
@ -297,12 +297,12 @@ args.
|
||||
LexWarn(cc,"Dereference U0 ");
|
||||
break;
|
||||
case IC_POWER:
|
||||
tmpc=tmpi->ic_class=cmp.internal_types[RT_F64];
|
||||
tmpc=tmpi->ic_class=comp.internal_types[RT_F64];
|
||||
if (tmpc1->raw_type!=RT_F64)
|
||||
tmpi1->ic_flags|=ICF_RES_TO_F64;
|
||||
if (tmpc2->raw_type!=RT_F64)
|
||||
tmpi2->ic_flags|=ICF_RES_TO_F64;
|
||||
tmpi_push->ic_class2=cmp.internal_types[RT_F64];
|
||||
tmpi_push->ic_class2=comp.internal_types[RT_F64];
|
||||
break;
|
||||
start:
|
||||
case IC_MUL:
|
||||
@ -695,30 +695,30 @@ args.
|
||||
tmpi->ic_data=tmpi1->ic_data&&tmpi2->ic_data;
|
||||
tmpi->ic_code=IC_IMM_I64;
|
||||
}
|
||||
tmpi->ic_class=cmp.internal_types[RT_I64];
|
||||
tmpi->ic_class=comp.internal_types[RT_I64];
|
||||
break;
|
||||
case IC_OR_OR:
|
||||
if (OptFixupBinaryOp1(tmpi,tmpi1,tmpi2,&is_unsigned)) {
|
||||
tmpi->ic_data=tmpi1->ic_data||tmpi2->ic_data;
|
||||
tmpi->ic_code=IC_IMM_I64;
|
||||
}
|
||||
tmpi->ic_class=cmp.internal_types[RT_I64];
|
||||
tmpi->ic_class=comp.internal_types[RT_I64];
|
||||
break;
|
||||
case IC_XOR_XOR:
|
||||
if (OptFixupBinaryOp1(tmpi,tmpi1,tmpi2,&is_unsigned)) {
|
||||
tmpi->ic_data=tmpi1->ic_data^^tmpi2->ic_data;
|
||||
tmpi->ic_code=IC_IMM_I64;
|
||||
}
|
||||
tmpi->ic_class=cmp.internal_types[RT_I64];
|
||||
tmpi->ic_class=comp.internal_types[RT_I64];
|
||||
break;
|
||||
end:
|
||||
if (!tmpi_push->ic_class->ptr_stars_count) {
|
||||
if (tmpi_push->ic_class->raw_type==RT_F64)
|
||||
tmpi_push->ic_class2=cmp.internal_types[RT_F64];
|
||||
tmpi_push->ic_class2=comp.internal_types[RT_F64];
|
||||
else if (is_unsigned)
|
||||
tmpi_push->ic_class2=cmp.internal_types[RT_U64];
|
||||
tmpi_push->ic_class2=comp.internal_types[RT_U64];
|
||||
else
|
||||
tmpi_push->ic_class2=cmp.internal_types[RT_I64];
|
||||
tmpi_push->ic_class2=comp.internal_types[RT_I64];
|
||||
}
|
||||
break;
|
||||
start:
|
||||
@ -810,16 +810,16 @@ args.
|
||||
tmpi->ic_flags&=~ICF_RES_TO_INT;
|
||||
if (!tmpi_push->ic_class->ptr_stars_count) {
|
||||
if (tmpi_push->ic_class->raw_type==RT_F64)
|
||||
tmpi_push->ic_class2=cmp.internal_types[RT_F64];
|
||||
tmpi_push->ic_class2=comp.internal_types[RT_F64];
|
||||
else if (is_unsigned)
|
||||
tmpi_push->ic_class2=cmp.internal_types[RT_U64];
|
||||
tmpi_push->ic_class2=comp.internal_types[RT_U64];
|
||||
else
|
||||
tmpi_push->ic_class2=cmp.internal_types[RT_I64];
|
||||
tmpi_push->ic_class2=comp.internal_types[RT_I64];
|
||||
}
|
||||
if (tmpi_push->ic_flags & ICF_PUSH_CMP)
|
||||
tmpi->ic_class=tmpi->ic_class2;
|
||||
else
|
||||
tmpi->ic_class=cmp.internal_types[RT_I64];
|
||||
tmpi->ic_class=comp.internal_types[RT_I64];
|
||||
break;
|
||||
start:
|
||||
if (cc->pass==2 && (!tmpc->size||!tmpc2->size))
|
||||
@ -963,8 +963,8 @@ args.
|
||||
|
||||
tmpi->ic_code=IC_IMM_I64;
|
||||
tmpi->ic_data=ToI64(tmpi1->ic_data(F64));
|
||||
tmpi->ic_class=cmp.internal_types[RT_I64];
|
||||
tmpi->ic_class2=cmp.internal_types[RT_I64];
|
||||
tmpi->ic_class=comp.internal_types[RT_I64];
|
||||
tmpi->ic_class2=comp.internal_types[RT_I64];
|
||||
OptSetNOP1(tmpi1);
|
||||
} else if (tmpi1->ic_code==IC_IMM_I64) {
|
||||
tmpi2=tmpi1->last;
|
||||
@ -981,8 +981,8 @@ args.
|
||||
|
||||
tmpi->ic_code=IC_IMM_I64;
|
||||
tmpi->ic_data=tmpi1->ic_data;
|
||||
tmpi->ic_class=cmp.internal_types[RT_I64];
|
||||
tmpi->ic_class2=cmp.internal_types[RT_I64];
|
||||
tmpi->ic_class=comp.internal_types[RT_I64];
|
||||
tmpi->ic_class2=comp.internal_types[RT_I64];
|
||||
OptSetNOP1(tmpi1);
|
||||
}
|
||||
if (tmpi1->ic_flags&ICF_RES_TO_F64) {
|
||||
@ -1006,8 +1006,8 @@ args.
|
||||
~(ICF_RES_TO_F64|ICF_PUSH_RES)|tmpi2->ic_flags;
|
||||
OptSetNOP1(tmpi2);
|
||||
|
||||
tmpi1->ic_class=cmp.internal_types[RT_I64];
|
||||
tmpi1->ic_class2=cmp.internal_types[RT_I64];
|
||||
tmpi1->ic_class=comp.internal_types[RT_I64];
|
||||
tmpi1->ic_class2=comp.internal_types[RT_I64];
|
||||
tmpi_push=tmpi1;
|
||||
OptSetNOP1(tmpi);
|
||||
}
|
||||
@ -1028,8 +1028,8 @@ args.
|
||||
|
||||
tmpi->ic_code=IC_IMM_F64;
|
||||
tmpi->ic_data(F64)=ToF64(tmpi1->ic_data);
|
||||
tmpi->ic_class=cmp.internal_types[RT_F64];
|
||||
tmpi->ic_class2=cmp.internal_types[RT_F64];
|
||||
tmpi->ic_class=comp.internal_types[RT_F64];
|
||||
tmpi->ic_class2=comp.internal_types[RT_F64];
|
||||
OptSetNOP1(tmpi1);
|
||||
} else if (tmpi1->ic_code==IC_IMM_F64) {
|
||||
tmpi2=tmpi1->last;
|
||||
@ -1046,8 +1046,8 @@ args.
|
||||
|
||||
tmpi->ic_code=IC_IMM_F64;
|
||||
tmpi->ic_data=tmpi1->ic_data;
|
||||
tmpi->ic_class=cmp.internal_types[RT_F64];
|
||||
tmpi->ic_class2=cmp.internal_types[RT_F64];
|
||||
tmpi->ic_class=comp.internal_types[RT_F64];
|
||||
tmpi->ic_class2=comp.internal_types[RT_F64];
|
||||
OptSetNOP1(tmpi1);
|
||||
}
|
||||
if (tmpi1->ic_flags&ICF_RES_TO_INT) {
|
||||
@ -1071,8 +1071,8 @@ args.
|
||||
~(ICF_RES_TO_INT|ICF_PUSH_RES)|tmpi2->ic_flags;
|
||||
OptSetNOP1(tmpi2);
|
||||
|
||||
tmpi1->ic_class=cmp.internal_types[RT_F64];
|
||||
tmpi1->ic_class2=cmp.internal_types[RT_F64];
|
||||
tmpi1->ic_class=comp.internal_types[RT_F64];
|
||||
tmpi1->ic_class2=comp.internal_types[RT_F64];
|
||||
tmpi_push=tmpi1;
|
||||
OptSetNOP1(tmpi);
|
||||
}
|
||||
@ -1093,8 +1093,8 @@ args.
|
||||
|
||||
tmpi->ic_code=IC_IMM_I64;
|
||||
tmpi->ic_data=ToBool(tmpi1->ic_data);
|
||||
tmpi->ic_class=cmp.internal_types[RT_I64];
|
||||
tmpi->ic_class2=cmp.internal_types[RT_I64];
|
||||
tmpi->ic_class=comp.internal_types[RT_I64];
|
||||
tmpi->ic_class2=comp.internal_types[RT_I64];
|
||||
OptSetNOP1(tmpi1);
|
||||
}
|
||||
break;
|
||||
|
@ -57,9 +57,9 @@ U0 OptPass3(CCompCtrl *cc,COptReg *reg_offsets)
|
||||
else {
|
||||
if (tmpil1=OptLag(tmpi)) {
|
||||
if (!(tmpil2=OptLag(tmpil1)))
|
||||
tmpil2=&cmp.ic_nop;
|
||||
tmpil2=&comp.ic_nop;
|
||||
} else
|
||||
tmpil1=tmpil2=&cmp.ic_nop;
|
||||
tmpil1=tmpil2=&comp.ic_nop;
|
||||
tmpc=tmpi->ic_class;
|
||||
switch [intermediate_code_table[code].arg_count] {
|
||||
case IS_V_ARG:
|
||||
@ -68,9 +68,9 @@ U0 OptPass3(CCompCtrl *cc,COptReg *reg_offsets)
|
||||
case IS_2_ARG:
|
||||
tmpi2=ParsePop(ps);
|
||||
if (tmpi2->ic_flags&ICF_RES_TO_F64)
|
||||
tmpc2=cmp.internal_types[RT_F64];
|
||||
tmpc2=comp.internal_types[RT_F64];
|
||||
else if (tmpi2->ic_flags & ICF_RES_TO_INT)
|
||||
tmpc2=cmp.internal_types[RT_I64];
|
||||
tmpc2=comp.internal_types[RT_I64];
|
||||
else
|
||||
tmpc2=tmpi->t.arg2_class;
|
||||
tmpi->arg2.type=MDF_STACK+CompRawType(tmpc2);
|
||||
@ -78,9 +78,9 @@ U0 OptPass3(CCompCtrl *cc,COptReg *reg_offsets)
|
||||
case IS_1_ARG:
|
||||
tmpi1=ParsePop(ps);
|
||||
if (tmpi1->ic_flags&ICF_RES_TO_F64)
|
||||
tmpc1=cmp.internal_types[RT_F64];
|
||||
tmpc1=comp.internal_types[RT_F64];
|
||||
else if (tmpi1->ic_flags & ICF_RES_TO_INT)
|
||||
tmpc1=cmp.internal_types[RT_I64];
|
||||
tmpc1=comp.internal_types[RT_I64];
|
||||
else
|
||||
tmpc1=tmpi->t.arg1_class;
|
||||
tmpi->arg1.type=MDF_STACK+CompRawType(tmpc1);
|
||||
@ -555,17 +555,17 @@ R12 and R13 as non-pointer register variables, such as index variables i,j,k.
|
||||
if (j>0) {
|
||||
if (Bt(&cc->flags,CCf_PASS_TRACE_PRESENT))
|
||||
"Fun:%s\n",cc->htc.fun->str;
|
||||
if (j>cmp.num_reg_vars) {
|
||||
if (j>comp.num_reg_vars) {
|
||||
l=0;
|
||||
for (i=0;i<j && l<cmp.num_non_ptr_vars;i++) {
|
||||
for (i=0;i<j && l<comp.num_non_ptr_vars;i++) {
|
||||
tmpm=mv[i].m;
|
||||
tmpc=OptClassFwd(tmpm->member_class);
|
||||
if (!tmpc->ptr_stars_count && !tmpm->dim.next) {
|
||||
while (l<cmp.num_non_ptr_vars &&
|
||||
Bts(&cc->htc.fun->used_reg_mask,cmp.non_ptr_vars_map[l]))
|
||||
while (l<comp.num_non_ptr_vars &&
|
||||
Bts(&cc->htc.fun->used_reg_mask,comp.non_ptr_vars_map[l]))
|
||||
l++;
|
||||
if (l<cmp.num_non_ptr_vars) {
|
||||
tmpm->reg=cmp.non_ptr_vars_map[l++];
|
||||
if (l<comp.num_non_ptr_vars) {
|
||||
tmpm->reg=comp.non_ptr_vars_map[l++];
|
||||
reg_offsets[tmpm->reg].offset=mv[i].offset_start;
|
||||
reg_offsets[tmpm->reg].m=tmpm;
|
||||
if (Bt(&cc->flags,CCf_PASS_TRACE_PRESENT))
|
||||
@ -585,16 +585,16 @@ R12 and R13 as non-pointer register variables, such as index variables i,j,k.
|
||||
}
|
||||
}
|
||||
l=0;
|
||||
for (i=0;i<j && l<cmp.num_reg_vars;i++) {
|
||||
for (i=0;i<j && l<comp.num_reg_vars;i++) {
|
||||
tmpm=mv[i].m;
|
||||
//if not just flagged as reg var
|
||||
if (mv[i].offset_start && (!mv[i].m->dim.next||
|
||||
tmpm->offset>0 && StrCompare(tmpm->str,"argv"))) {
|
||||
while (l<cmp.num_reg_vars &&
|
||||
Bts(&cc->htc.fun->used_reg_mask,cmp.to_reg_vars_map[l]))
|
||||
while (l<comp.num_reg_vars &&
|
||||
Bts(&cc->htc.fun->used_reg_mask,comp.to_reg_vars_map[l]))
|
||||
l++;
|
||||
if (l<cmp.num_reg_vars) {
|
||||
tmpm->reg=cmp.to_reg_vars_map[l++];
|
||||
if (l<comp.num_reg_vars) {
|
||||
tmpm->reg=comp.to_reg_vars_map[l++];
|
||||
reg_offsets[tmpm->reg].offset=mv[i].offset_start;
|
||||
reg_offsets[tmpm->reg].m=tmpm;
|
||||
if (Bt(&cc->flags,CCf_PASS_TRACE_PRESENT))
|
||||
|
@ -15,7 +15,7 @@ Bool OptIC4(CIntermediateCode *tmpi)
|
||||
tmpil2->arg1.type&MDF_REG) {
|
||||
i=tmpil1->ic_data;
|
||||
if (I32_MIN<=i<=I32_MAX &&
|
||||
!Bt(&cmp.non_ptr_vars_mask,tmpil2->arg1.reg)) {
|
||||
!Bt(&comp.non_ptr_vars_mask,tmpil2->arg1.reg)) {
|
||||
tmpil1->ic_flags|=tmpil2->ic_flags&ICG_NO_CONVERT_MASK;
|
||||
tmpil1->ic_code=IC_LEA;
|
||||
tmpil1->arg1.type=MDF_DISP+tmpil1->arg1.type.raw_type;
|
||||
@ -97,7 +97,7 @@ Bool OptIC4(CIntermediateCode *tmpi)
|
||||
tmpil1->arg1.type&MDF_STACK) {
|
||||
i=tmpil2->ic_data;
|
||||
if (I32_MIN<=i<=I32_MAX &&
|
||||
!Bt(&cmp.non_ptr_vars_mask,tmpil2->arg1.reg)) {
|
||||
!Bt(&comp.non_ptr_vars_mask,tmpil2->arg1.reg)) {
|
||||
tmpil1->ic_flags|=tmpil2->ic_flags;
|
||||
tmpil1->ic_code=IC_MOV;
|
||||
tmpil1->arg1.type=MDF_DISP+tmpil1->arg1_type_pointed_to;
|
||||
@ -157,15 +157,15 @@ U0 OptPass4(CCompCtrl *cc,COptReg *reg_offsets,I64 *_type)
|
||||
tmpi=OptFree(tmpi);
|
||||
} else {
|
||||
tmpc=tmpi->ic_class;
|
||||
tmpi1=tmpi2=&cmp.ic_nop;
|
||||
tmpi1=tmpi2=&comp.ic_nop;
|
||||
if (tmpil1=OptLag2(tmpi)) {
|
||||
if (tmpil2=OptLag2(tmpil1)) {
|
||||
if (!(tmpil3=OptLag2(tmpil2)))
|
||||
tmpil3=&cmp.ic_nop;
|
||||
tmpil3=&comp.ic_nop;
|
||||
} else
|
||||
tmpil2=tmpil3=&cmp.ic_nop;
|
||||
tmpil2=tmpil3=&comp.ic_nop;
|
||||
} else
|
||||
tmpil1=tmpil2=tmpil3=&cmp.ic_nop;
|
||||
tmpil1=tmpil2=tmpil3=&comp.ic_nop;
|
||||
switch [intermediate_code_table[code].arg_count] {
|
||||
case IS_V_ARG:
|
||||
ps->ptr-=tmpi->ic_data>>3;
|
||||
@ -428,7 +428,7 @@ p4_sib:
|
||||
break;
|
||||
}
|
||||
}
|
||||
tmpi->ic_class=cmp.internal_types[RT_I64];
|
||||
tmpi->ic_class=comp.internal_types[RT_I64];
|
||||
} else if (_type)
|
||||
*_type=tmpi->ic_class->raw_type;
|
||||
break;
|
||||
|
@ -6,7 +6,7 @@ Bool OptIC6(CIntermediateCode *tmpi)
|
||||
if (tmpil1->ic_code==IC_ADD_CONST && tmpi->ic_code==IC_DEREF &&
|
||||
tmpi->ic_flags&ICF_ARG1_WAS_STACK && tmpi->arg1.type&MDF_REG &&
|
||||
tmpil1->res.type&MDF_REG && I32_MIN<=tmpil1->ic_data<=I32_MAX &&
|
||||
!Bt(&cmp.non_ptr_vars_mask,tmpil1->arg1.reg)) {
|
||||
!Bt(&comp.non_ptr_vars_mask,tmpil1->arg1.reg)) {
|
||||
if (tmpil1->arg1.type&MDF_REG) {
|
||||
tmpi->ic_flags=tmpi->ic_flags&~ICF_ARG1_WAS_STACK | tmpil1->ic_flags;
|
||||
tmpi->ic_code=IC_MOV;
|
||||
@ -107,7 +107,7 @@ U0 OptPass6(CCompCtrl *cc)
|
||||
#assert REGG_STACK_TMP==1<<9
|
||||
tmpi=cc->coc.coc_head.next;
|
||||
old_tmpil2=NULL;
|
||||
tmpil1=tmpil2=&cmp.ic_nop;
|
||||
tmpil1=tmpil2=&comp.ic_nop;
|
||||
while (tmpi->ic_code) {
|
||||
if (tmpi->ic_code>IC_NOP2) {
|
||||
if (tmpil1->ic_code>IC_NOP2)
|
||||
|
@ -20,43 +20,43 @@ CIntermediateCode *ParseAddOp(CCompCtrl *cc,I64 stack_op,CHashClass *tmpc)
|
||||
case IC_ADD:
|
||||
if (tmpc->ptr_stars_count && !tmpi->ic_class->ptr_stars_count &&
|
||||
tmpi->ic_class->raw_type!=RT_F64) {
|
||||
ICAdd(cc,IC_SIZEOF,1,cmp.internal_types[RT_I64]);
|
||||
ICAdd(cc,IC_MUL,0,cmp.internal_types[RT_I64]);
|
||||
ICAdd(cc,IC_SIZEOF,1,comp.internal_types[RT_I64]);
|
||||
ICAdd(cc,IC_MUL,0,comp.internal_types[RT_I64]);
|
||||
}
|
||||
break;
|
||||
case IC_SUB:
|
||||
if (tmpc->ptr_stars_count && tmpi->ic_class->raw_type!=RT_F64) {
|
||||
if (!tmpi->ic_class->ptr_stars_count) {
|
||||
ICAdd(cc,IC_SIZEOF,1,cmp.internal_types[RT_I64]);
|
||||
ICAdd(cc,IC_MUL,0,cmp.internal_types[RT_I64]);
|
||||
ICAdd(cc,IC_SIZEOF,1,comp.internal_types[RT_I64]);
|
||||
ICAdd(cc,IC_MUL,0,comp.internal_types[RT_I64]);
|
||||
} else
|
||||
div_sizeof=TRUE;
|
||||
}
|
||||
break;
|
||||
case IC_AND_AND:
|
||||
case IC_OR_OR:
|
||||
ICAdd(cc,IC_NOP1,0,cmp.internal_types[RT_I64]);
|
||||
ICAdd(cc,IC_NOP1,0,comp.internal_types[RT_I64]);
|
||||
break;
|
||||
case IC_ADD_EQU:
|
||||
case IC_SUB_EQU:
|
||||
if (tmpc->ptr_stars_count) {
|
||||
ICAdd(cc,IC_SIZEOF,1,cmp.internal_types[RT_I64]);
|
||||
ICAdd(cc,IC_MUL,0,cmp.internal_types[RT_I64]);
|
||||
ICAdd(cc,IC_SIZEOF,1,comp.internal_types[RT_I64]);
|
||||
ICAdd(cc,IC_MUL,0,comp.internal_types[RT_I64]);
|
||||
}
|
||||
break;
|
||||
}
|
||||
tmpi=ICAdd(cc,stack_op,0,tmpc);
|
||||
if (stack_op.u8[3]&ECF_HAS_PUSH_CMP) {
|
||||
tmpi->ic_flags|=ICF_POP_CMP;
|
||||
ICAdd(cc,IC_NOP1,0,cmp.internal_types[RT_I64]);
|
||||
ICAdd(cc,IC_AND_AND,0,cmp.internal_types[RT_I64],ICF_POP_CMP);
|
||||
ICAdd(cc,IC_NOP1,0,comp.internal_types[RT_I64]);
|
||||
ICAdd(cc,IC_AND_AND,0,comp.internal_types[RT_I64],ICF_POP_CMP);
|
||||
}
|
||||
if (div_sizeof) {
|
||||
tmpc--;
|
||||
if (tmpc->size!=1) {
|
||||
ICAdd(cc,IC_IMM_I64,tmpc->size,cmp.internal_types[RT_I64]);
|
||||
ICAdd(cc,IC_DIV,0,cmp.internal_types[RT_I64]);
|
||||
tmpc=cmp.internal_types[RT_I64];
|
||||
ICAdd(cc,IC_IMM_I64,tmpc->size,comp.internal_types[RT_I64]);
|
||||
ICAdd(cc,IC_DIV,0,comp.internal_types[RT_I64]);
|
||||
tmpc=comp.internal_types[RT_I64];
|
||||
}
|
||||
}
|
||||
return tmpi;
|
||||
@ -126,7 +126,7 @@ pe_check_binary_ops1:
|
||||
} else if (paren_prec<=PREC_UNARY_PRE+ASSOC_MASK)
|
||||
ParenWarning(cc);
|
||||
}
|
||||
cur_op=cmp.binary_ops[cc->token];
|
||||
cur_op=comp.binary_ops[cc->token];
|
||||
|
||||
case PE_CHECK_BINARY_OPS2:
|
||||
pe_check_binary_ops2:
|
||||
@ -175,13 +175,13 @@ pe_do_binary_op:
|
||||
tmpi=cc->coc.coc_head.last;
|
||||
if (!tmpi->ic_class->ptr_stars_count &&
|
||||
tmpi->ic_class->raw_type!=RT_F64) {
|
||||
ICAdd(cc,IC_SIZEOF,1,cmp.internal_types[RT_I64]);
|
||||
ICAdd(cc,IC_MUL,0,cmp.internal_types[RT_I64]);
|
||||
ICAdd(cc,IC_SIZEOF,1,comp.internal_types[RT_I64]);
|
||||
ICAdd(cc,IC_MUL,0,comp.internal_types[RT_I64]);
|
||||
}
|
||||
break;
|
||||
case IC_AND_AND:
|
||||
case IC_OR_OR:
|
||||
ICAdd(cc,IC_NOP1,0,cmp.internal_types[RT_I64]);
|
||||
ICAdd(cc,IC_NOP1,0,comp.internal_types[RT_I64]);
|
||||
break;
|
||||
}
|
||||
if (cc->flags & CCF_FUN_EXP) {
|
||||
@ -225,11 +225,11 @@ pe_pop_higher:
|
||||
if (intermediate_code_table[cur_op.u16[0]].type==IST_CMP &&
|
||||
intermediate_code_table[stack_op.u16[0]].type==IST_CMP) {
|
||||
tmpi->ic_flags|=ICF_PUSH_CMP;
|
||||
ICAdd(cc,IC_NOP1,0,cmp.internal_types[RT_I64]);
|
||||
ICAdd(cc,IC_NOP1,0,comp.internal_types[RT_I64]);
|
||||
ICAdd(cc,IC_PUSH_CMP,0,tmpc);
|
||||
cur_op.u8[3]|=ECF_HAS_PUSH_CMP;
|
||||
} else if (cur_op.u16[0]==IC_AND_AND || cur_op.u16[0]==IC_OR_OR)
|
||||
ICAdd(cc,IC_NOP1,0,cmp.internal_types[RT_I64]);
|
||||
ICAdd(cc,IC_NOP1,0,comp.internal_types[RT_I64]);
|
||||
goto pe_pop_higher;
|
||||
|
||||
case PE_PUSH_LOWER:
|
||||
@ -293,7 +293,7 @@ Bool ParseExpression(CCompCtrl *cc,I64 *_max_prec,Bool end_exp,CParseStack *_ps=
|
||||
if (end_exp)
|
||||
ICAdd(cc,IC_END_EXP,0,0,ICF_RES_NOT_USED);
|
||||
if (cc->coc.coc_head.last->ic_class==
|
||||
cmp.internal_types[RT_U0])
|
||||
comp.internal_types[RT_U0])
|
||||
LexWarn(cc,"U0 Expression ");
|
||||
}
|
||||
cc->flags|=old_flags&(CCF_PREINC|CCF_PREDEC);
|
||||
@ -347,7 +347,7 @@ pu_sizeof_member:
|
||||
while (Lex(cc)=='*');
|
||||
i=sizeof(U8 *);
|
||||
}
|
||||
ICAdd(cc,IC_IMM_I64,i,cmp.internal_types[RT_I64]);
|
||||
ICAdd(cc,IC_IMM_I64,i,comp.internal_types[RT_I64]);
|
||||
}
|
||||
|
||||
U0 ParseOffsetOf(CCompCtrl *cc)
|
||||
@ -377,7 +377,7 @@ U0 ParseOffsetOf(CCompCtrl *cc)
|
||||
i+=tmpm->offset;
|
||||
tmpc=tmpm->member_class;
|
||||
} while (Lex(cc)=='.');
|
||||
ICAdd(cc,IC_IMM_I64,i,cmp.internal_types[RT_I64]);
|
||||
ICAdd(cc,IC_IMM_I64,i,comp.internal_types[RT_I64]);
|
||||
}
|
||||
|
||||
I64 ParseFunCall(CCompCtrl *cc,CParseStack *ps,Bool indirect,CHashFun *tmpf)
|
||||
@ -419,10 +419,10 @@ I64 ParseFunCall(CCompCtrl *cc,CParseStack *ps,Bool indirect,CHashFun *tmpf)
|
||||
|
||||
if (indirect) {
|
||||
if (!(cc->flags & (CCF_RAX | CCF_ARRAY)))
|
||||
ICAdd(cc,IC_DEREF,0,cmp.internal_types[RT_PTR]);
|
||||
cc->coc.coc_head.last->ic_class=cmp.internal_types[RT_PTR];
|
||||
ICAdd(cc,IC_SET_RAX,0,cmp.internal_types[RT_PTR]);
|
||||
ICAdd(cc,IC_NOP2,1,cmp.internal_types[RT_PTR]); //balance the books
|
||||
ICAdd(cc,IC_DEREF,0,comp.internal_types[RT_PTR]);
|
||||
cc->coc.coc_head.last->ic_class=comp.internal_types[RT_PTR];
|
||||
ICAdd(cc,IC_SET_RAX,0,comp.internal_types[RT_PTR]);
|
||||
ICAdd(cc,IC_NOP2,1,comp.internal_types[RT_PTR]); //balance the books
|
||||
}
|
||||
COCPush(cc);
|
||||
tmpcbh=cc->coc.coc_next;
|
||||
@ -460,7 +460,7 @@ I64 ParseFunCall(CCompCtrl *cc,CParseStack *ps,Bool indirect,CHashFun *tmpf)
|
||||
if (tmpm->flags & (MLF_STR_DEFAULT_AVAILABLE|MLF_LASTCLASS) &&
|
||||
cc->flags&CCF_AOT_COMPILE) {
|
||||
cm=COCMiscNew(cc,CMT_STR_CONST);
|
||||
ICAdd(cc,IC_STR_CONST,cm,cmp.internal_types[RT_U8]+1);
|
||||
ICAdd(cc,IC_STR_CONST,cm,comp.internal_types[RT_U8]+1);
|
||||
cm->st_len=StrLen(default_val)+1;
|
||||
cm->str=StrNew(default_val);
|
||||
cc->flags|=CCF_HAS_MISC_DATA;
|
||||
@ -637,17 +637,17 @@ I64 ParseUnaryTerm(CCompCtrl *cc,CParseStack *ps,CMemberList **_local_var,
|
||||
}
|
||||
cc->abs_counts.externs++;
|
||||
ICAdd(cc,IC_IMM_I64,
|
||||
&tmpf->exe_addr,cmp.internal_types[RT_PTR]);
|
||||
ICAdd(cc,IC_DEREF,0,cmp.internal_types[RT_PTR]);
|
||||
&tmpf->exe_addr,comp.internal_types[RT_PTR]);
|
||||
ICAdd(cc,IC_DEREF,0,comp.internal_types[RT_PTR]);
|
||||
} else {
|
||||
if (cc->flags&CCF_AOT_COMPILE) {
|
||||
ICAdd(cc,IC_ABS_ADDR,
|
||||
tmpf->exe_addr,cmp.internal_types[RT_PTR]);
|
||||
tmpf->exe_addr,comp.internal_types[RT_PTR]);
|
||||
if (cc->flags&CCF_ASM_EXPRESSIONS)
|
||||
cc->abs_counts.abs_addres++;
|
||||
} else
|
||||
ICAdd(cc,IC_IMM_I64,
|
||||
tmpf->exe_addr,cmp.internal_types[RT_PTR]);
|
||||
tmpf->exe_addr,comp.internal_types[RT_PTR]);
|
||||
}
|
||||
cc->abs_counts.c_addres++;
|
||||
Lex(cc);
|
||||
@ -659,7 +659,7 @@ I64 ParseUnaryTerm(CCompCtrl *cc,CParseStack *ps,CMemberList **_local_var,
|
||||
!(cc->flags&CCF_AOT_COMPILE) && tmpex->type&HTF_IMM) {
|
||||
cc->abs_counts.c_addres++;
|
||||
ICAdd(cc,IC_IMM_I64,
|
||||
tmpex->val,cmp.internal_types[RT_PTR]);
|
||||
tmpex->val,comp.internal_types[RT_PTR]);
|
||||
Lex(cc);
|
||||
return PE_MAYBE_MODIFIERS;
|
||||
} else
|
||||
@ -680,24 +680,24 @@ I64 ParseUnaryTerm(CCompCtrl *cc,CParseStack *ps,CMemberList **_local_var,
|
||||
case TK_CHAR_CONST:
|
||||
case TK_INS_BIN_SIZE:
|
||||
if (cc->cur_i64<0)
|
||||
ICAdd(cc,IC_IMM_I64,cc->cur_i64,cmp.internal_types[RT_U64]);
|
||||
ICAdd(cc,IC_IMM_I64,cc->cur_i64,comp.internal_types[RT_U64]);
|
||||
else
|
||||
ICAdd(cc,IC_IMM_I64,cc->cur_i64,cmp.internal_types[RT_I64]);
|
||||
ICAdd(cc,IC_IMM_I64,cc->cur_i64,comp.internal_types[RT_I64]);
|
||||
Lex(cc);
|
||||
break;
|
||||
case TK_F64:
|
||||
ICAdd(cc,IC_IMM_F64,cc->cur_f64(I64),cmp.internal_types[RT_F64]);
|
||||
ICAdd(cc,IC_IMM_F64,cc->cur_f64(I64),comp.internal_types[RT_F64]);
|
||||
Lex(cc);
|
||||
break;
|
||||
case TK_STR:
|
||||
cm=COCMiscNew(cc,CMT_STR_CONST);
|
||||
ICAdd(cc,IC_STR_CONST,cm,cmp.internal_types[RT_U8]+1);
|
||||
ICAdd(cc,IC_STR_CONST,cm,comp.internal_types[RT_U8]+1);
|
||||
cm->str=LexExtStr(cc,&cm->st_len);
|
||||
cc->flags|=CCF_HAS_MISC_DATA;
|
||||
break;
|
||||
case TK_INS_BIN:
|
||||
cm=COCMiscNew(cc,CMT_STR_CONST);
|
||||
ICAdd(cc,IC_STR_CONST,cm,cmp.internal_types[RT_U8]+1);
|
||||
ICAdd(cc,IC_STR_CONST,cm,comp.internal_types[RT_U8]+1);
|
||||
cm->str=cc->cur_str;
|
||||
cm->st_len=cc->cur_str_len;
|
||||
cc->cur_str=NULL;
|
||||
@ -708,15 +708,15 @@ I64 ParseUnaryTerm(CCompCtrl *cc,CParseStack *ps,CMemberList **_local_var,
|
||||
if (cc->flags & CCF_ASM_EXPRESSIONS) {
|
||||
cc->abs_counts.abs_addres++;
|
||||
if (cc->flags&CCF_AOT_COMPILE)
|
||||
ICAdd(cc,IC_ABS_ADDR,cc->aotc->rip,cmp.internal_types[RT_PTR]);
|
||||
ICAdd(cc,IC_ABS_ADDR,cc->aotc->rip,comp.internal_types[RT_PTR]);
|
||||
else
|
||||
ICAdd(cc,IC_IMM_I64,cc->aotc->rip,cmp.internal_types[RT_PTR]);
|
||||
ICAdd(cc,IC_IMM_I64,cc->aotc->rip,comp.internal_types[RT_PTR]);
|
||||
} else {
|
||||
if (cc->flags&CCF_CLASS_DOL_OFFSET)
|
||||
ICAdd(cc,IC_IMM_I64,cc->class_dol_offset,
|
||||
cmp.internal_types[RT_I64]);
|
||||
comp.internal_types[RT_I64]);
|
||||
else
|
||||
ICAdd(cc,IC_RIP,0,cmp.internal_types[RT_PTR]);
|
||||
ICAdd(cc,IC_RIP,0,comp.internal_types[RT_PTR]);
|
||||
}
|
||||
Lex(cc);
|
||||
break;
|
||||
@ -787,7 +787,7 @@ I64 ParseUnaryTerm(CCompCtrl *cc,CParseStack *ps,CMemberList **_local_var,
|
||||
ps->ptr--;
|
||||
if (i.u16[0]!=IC_ADDR)
|
||||
LexExcept(cc,"Expecting '&' at ");
|
||||
ICAdd(cc,IC_IMM_I64,tmpm->offset,cmp.internal_types[RT_PTR]);
|
||||
ICAdd(cc,IC_IMM_I64,tmpm->offset,comp.internal_types[RT_PTR]);
|
||||
*_local_var=tmpm;
|
||||
Lex(cc);
|
||||
return PE_MAYBE_MODIFIERS;
|
||||
@ -846,15 +846,15 @@ pu_export_sys_sym:
|
||||
else
|
||||
cc->flags|=CCF_UNRESOLVED;
|
||||
ICAdd(cc,IC_IMM_I64,
|
||||
&tmpex->val,cmp.internal_types[RT_PTR],ICF_NO_RIP);
|
||||
ICAdd(cc,IC_DEREF,0,cmp.internal_types[RT_PTR]);
|
||||
&tmpex->val,comp.internal_types[RT_PTR],ICF_NO_RIP);
|
||||
ICAdd(cc,IC_DEREF,0,comp.internal_types[RT_PTR]);
|
||||
} else {
|
||||
if (cc->flags&CCF_AOT_COMPILE && !(tmpex->type & HTF_IMM))
|
||||
ICAdd(cc,IC_ABS_ADDR,tmpex->val,cmp.internal_types[RT_PTR]);
|
||||
ICAdd(cc,IC_ABS_ADDR,tmpex->val,comp.internal_types[RT_PTR]);
|
||||
else {
|
||||
if (tmpex->type&HTF_IMM)
|
||||
cc->abs_counts.c_addres++;
|
||||
ICAdd(cc,IC_IMM_I64,tmpex->val,cmp.internal_types[RT_PTR]);
|
||||
ICAdd(cc,IC_IMM_I64,tmpex->val,comp.internal_types[RT_PTR]);
|
||||
}
|
||||
}
|
||||
Lex(cc);
|
||||
@ -941,9 +941,9 @@ pu_export_sys_sym:
|
||||
j++;
|
||||
if (cc->token==TK_IDENT &&
|
||||
(cc->hash_entry || cc->local_var_entry))
|
||||
ICAdd(cc,IC_IMM_I64,TRUE,cmp.internal_types[RT_I64]);
|
||||
ICAdd(cc,IC_IMM_I64,TRUE,comp.internal_types[RT_I64]);
|
||||
else
|
||||
ICAdd(cc,IC_IMM_I64,FALSE,cmp.internal_types[RT_I64]);
|
||||
ICAdd(cc,IC_IMM_I64,FALSE,comp.internal_types[RT_I64]);
|
||||
Lex(cc);
|
||||
while (j--) {
|
||||
if (cc->token!=')')
|
||||
|
@ -602,9 +602,9 @@ U0 ParseSwitch(CCompCtrl *cc,I64 try_count)
|
||||
mc_jt->begin->use_count++;
|
||||
if (!ParseExpression(cc,NULL,FALSE))
|
||||
throw('Compiler');
|
||||
tmpi_sub=ICAdd(cc,IC_IMM_I64,0,cmp.internal_types[RT_I64]);
|
||||
ICAdd(cc,IC_SUB,0,cmp.internal_types[RT_I64]);
|
||||
tmpi_cmp=ICAdd(cc,IC_IMM_I64,0,cmp.internal_types[RT_I64]);
|
||||
tmpi_sub=ICAdd(cc,IC_IMM_I64,0,comp.internal_types[RT_I64]);
|
||||
ICAdd(cc,IC_SUB,0,comp.internal_types[RT_I64]);
|
||||
tmpi_cmp=ICAdd(cc,IC_IMM_I64,0,comp.internal_types[RT_I64]);
|
||||
if (nobound) {
|
||||
ICAdd(cc,IC_NOBOUND_SWITCH,mc_jt,0);
|
||||
if (cc->token!=']')
|
||||
@ -842,7 +842,7 @@ U0 ParseStreamBlk(CCompCtrl *cc)
|
||||
U0 ParseTryBlk(CCompCtrl *cc,I64 try_count)
|
||||
{
|
||||
CCodeMisc *lb_catch,*lb_done,*lb_untry;
|
||||
CHashClass *tmpc=cmp.internal_types[RT_PTR];
|
||||
CHashClass *tmpc=comp.internal_types[RT_PTR];
|
||||
CHashFun *tmp_try=HashFind("SysTry",cc->htc.hash_table_list,HTT_FUN),
|
||||
*tmp_untry=HashFind("SysUntry",cc->htc.hash_table_list,HTT_FUN);
|
||||
|
||||
@ -1097,14 +1097,14 @@ sm_import:
|
||||
cc->abs_counts.externs++;
|
||||
if (cc->flags&CCF_AOT_COMPILE)
|
||||
ICAdd(cc,IC_CALL_IMPORT,
|
||||
tmp_untry,cmp.internal_types[RT_PTR]);
|
||||
tmp_untry,comp.internal_types[RT_PTR]);
|
||||
else
|
||||
ICAdd(cc,IC_CALL_INDIRECT2,
|
||||
&tmp_untry->exe_addr,
|
||||
cmp.internal_types[RT_PTR]);
|
||||
comp.internal_types[RT_PTR]);
|
||||
} else
|
||||
ICAdd(cc,IC_CALL,tmp_untry->exe_addr,
|
||||
cmp.internal_types[RT_PTR]);
|
||||
comp.internal_types[RT_PTR]);
|
||||
}
|
||||
}
|
||||
if (Lex(cc)!=';') {
|
||||
|
@ -353,7 +353,7 @@ CHashClass *ParseType(CCompCtrl *cc,CHashClass **_tmpc1,
|
||||
if (Lex(cc)!='(')
|
||||
LexExcept(cc,"Expecting '(' at ");
|
||||
fun_ptr=ParseFunJoin(cc,tmpc1,NULL,fsp_flags)+ptr_stars_count;
|
||||
tmpc1=cmp.internal_types[RT_PTR]+ptr_stars_count;
|
||||
tmpc1=comp.internal_types[RT_PTR]+ptr_stars_count;
|
||||
}
|
||||
ParseArrayDims(cc,mode,tmpad);
|
||||
|
||||
@ -380,7 +380,7 @@ U0 ParseDotDotDot(CCompCtrl *cc,CHashFun *tmpf,I64 _reg)
|
||||
Lex(cc);
|
||||
tmpm=MemberListNew(_reg);
|
||||
tmpm->flags=MLF_DOT_DOT_DOT;
|
||||
tmpm->member_class=cmp.internal_types[RT_I64];
|
||||
tmpm->member_class=comp.internal_types[RT_I64];
|
||||
tmpm->str=StrNew("argc");
|
||||
tmpm->offset=tmpf->size;
|
||||
tmpm->size=8;
|
||||
@ -389,7 +389,7 @@ U0 ParseDotDotDot(CCompCtrl *cc,CHashFun *tmpf,I64 _reg)
|
||||
|
||||
tmpm=MemberListNew(_reg);
|
||||
tmpm->flags=MLF_DOT_DOT_DOT;
|
||||
tmpm->member_class=cmp.internal_types[RT_I64];
|
||||
tmpm->member_class=comp.internal_types[RT_I64];
|
||||
tmpm->str=StrNew("argv");
|
||||
tmpm->dim.total_count=127; //arbitrary
|
||||
tmpm->dim.next=tmpad=MAlloc(sizeof(CArrayDim));
|
||||
|
@ -36,8 +36,8 @@ I64 InstEntriesCompare(CInst *tmpins1,CInst *tmpins2)
|
||||
if (res=tmpins1->flags&IEF_48_REX - tmpins2->flags&IEF_48_REX)
|
||||
return res;
|
||||
|
||||
i1=tmpins1->arg2==ARGT_IMM64 || tmpins1->arg2==ARGT_UIMM64;
|
||||
i2=tmpins2->arg2==ARGT_IMM64 || tmpins2->arg2==ARGT_UIMM64;
|
||||
i1=tmpins1->arg2==ARGt_IMM64 || tmpins1->arg2==ARGt_UIMM64;
|
||||
i2=tmpins2->arg2==ARGt_IMM64 || tmpins2->arg2==ARGt_UIMM64;
|
||||
return i1-i2;
|
||||
}
|
||||
}
|
||||
@ -115,7 +115,7 @@ CInst *InstEntryFind(U8 *rip,I64 opsize,I64 seg_size)
|
||||
goto ief_compare_done;
|
||||
}
|
||||
}
|
||||
if (opsize==64||arg1==ARGT_M64||arg2==ARGT_M64) {
|
||||
if (opsize==64||arg1==ARGt_M64||arg2==ARGt_M64) {
|
||||
if (!Bt(&uasm.ins64_arg_mask,arg1)&&
|
||||
!Bt(&uasm.ins64_arg_mask,arg2)&&
|
||||
!(tmpins->flags&IEF_48_REX))
|
||||
@ -152,17 +152,17 @@ CInst *InstEntryFind(U8 *rip,I64 opsize,I64 seg_size)
|
||||
goto ief_compare_done;
|
||||
}
|
||||
}
|
||||
if (opsize==64 || arg1==ARGT_M64 || arg2==ARGT_M64) {
|
||||
if (opsize==64 || arg1==ARGt_M64 || arg2==ARGt_M64) {
|
||||
if (!Bt(&uasm.ins64_arg_mask,arg1) &&
|
||||
!Bt(&uasm.ins64_arg_mask,arg2) &&
|
||||
!(tmpins->flags&IEF_48_REX)&& !(arg2==ARGT_NONE &&
|
||||
(ARGT_UIMM8<=arg1<=ARGT_UIMM64 ||
|
||||
ARGT_IMM8<=arg1<=ARGT_IMM64)))
|
||||
!(tmpins->flags&IEF_48_REX)&& !(arg2==ARGt_NONE &&
|
||||
(ARGt_UIMM8<=arg1<=ARGt_UIMM64 ||
|
||||
ARGt_IMM8<=arg1<=ARGt_IMM64)))
|
||||
m=1;
|
||||
else if (tmpins->arg2==ARGT_IMM64 || tmpins->arg2==ARGT_UIMM64) {
|
||||
if (arg2!=ARGT_IMM64&&arg2!=ARGT_UIMM64)
|
||||
else if (tmpins->arg2==ARGt_IMM64 || tmpins->arg2==ARGt_UIMM64) {
|
||||
if (arg2!=ARGt_IMM64&&arg2!=ARGt_UIMM64)
|
||||
m=1;
|
||||
} else if (arg2==ARGT_IMM64||arg2==ARGT_UIMM64)
|
||||
} else if (arg2==ARGt_IMM64||arg2==ARGt_UIMM64)
|
||||
m=-1;
|
||||
} else {
|
||||
if (Bt(&uasm.ins64_arg_mask,arg1) ||
|
||||
@ -198,14 +198,14 @@ U0 UAsmHashLoad()
|
||||
CInst *tmpins;
|
||||
I64 i,j1,j2,k;
|
||||
|
||||
uasm.ins64_arg_mask=0x0880888880+1<<ARGT_ST0+1<<ARGT_STI;
|
||||
uasm.signed_arg_mask=1<<ARGT_REL8+1<<ARGT_REL16+1<<ARGT_REL32+
|
||||
1<<ARGT_IMM8+1<<ARGT_IMM16+1<<ARGT_IMM32+1<<ARGT_IMM64;
|
||||
uasm.mem_arg_mask=1<<ARGT_M8+1<<ARGT_M16+1<<ARGT_M32+1<<ARGT_M64;
|
||||
uasm.ins64_arg_mask=0x0880888880+1<<ARGt_ST0+1<<ARGt_STI;
|
||||
uasm.signed_arg_mask=1<<ARGt_REL8+1<<ARGt_REL16+1<<ARGt_REL32+
|
||||
1<<ARGt_IMM8+1<<ARGt_IMM16+1<<ARGt_IMM32+1<<ARGt_IMM64;
|
||||
uasm.mem_arg_mask=1<<ARGt_M8+1<<ARGt_M16+1<<ARGt_M32+1<<ARGt_M64;
|
||||
|
||||
uasm.table_16_32_entries=uasm.table_64_entries=0;
|
||||
for (i=0;i<=cmp.asm_hash->mask;i++) {
|
||||
tmph=cmp.asm_hash->body[i];
|
||||
for (i=0;i<=comp.asm_hash->mask;i++) {
|
||||
tmph=comp.asm_hash->body[i];
|
||||
while (tmph) {
|
||||
if (tmph->type==HTT_OPCODE && !(tmph->oc_flags&OCF_ALIAS)) {
|
||||
tmpins=&tmph->ins;
|
||||
@ -223,8 +223,8 @@ U0 UAsmHashLoad()
|
||||
j1=j2=0;
|
||||
uasm.table_16_32=MAlloc(uasm.table_16_32_entries*sizeof(U8 *));
|
||||
uasm.table_64 =MAlloc(uasm.table_64_entries *sizeof(U8 *));
|
||||
for (i=0;i<=cmp.asm_hash->mask;i++) {
|
||||
tmph=cmp.asm_hash->body[i];
|
||||
for (i=0;i<=comp.asm_hash->mask;i++) {
|
||||
tmph=comp.asm_hash->body[i];
|
||||
while (tmph) {
|
||||
if (tmph->type==HTT_OPCODE && !(tmph->oc_flags&OCF_ALIAS)) {
|
||||
tmpins=&tmph->ins;
|
||||
@ -369,7 +369,7 @@ U0 Ui(U8 *buf,U8 **_rip,I64 seg_size=64,I64 *_jmp_dst=NULL,Bool just_ins=FALSE)
|
||||
rip--;
|
||||
RM1=*rip++ - tmpins->opcode[tmpins->opcode_count-1]+REX_b;
|
||||
ptr=NULL;
|
||||
if (ARGT_R8<=arg1<=ARGT_R64) {
|
||||
if (ARGt_R8<=arg1<=ARGt_R64) {
|
||||
if (arg1_size==8) {
|
||||
if (REX!=-1)
|
||||
ptr="ST_U8_REX_REGS";
|
||||
@ -400,9 +400,9 @@ U0 Ui(U8 *buf,U8 **_rip,I64 seg_size=64,I64 *_jmp_dst=NULL,Bool just_ins=FALSE)
|
||||
}
|
||||
}
|
||||
|
||||
if (ARGT_RM8<=arg1<=ARGT_RM64 || ARGT_M8<=arg1<=ARGT_M64 ||
|
||||
ARGT_RM8<=arg2<=ARGT_RM64 || ARGT_M8<=arg2<=ARGT_M64) {
|
||||
if (ARGT_RM8<=arg2<=ARGT_RM64 || ARGT_M8<=arg2<=ARGT_M64) {
|
||||
if (ARGt_RM8<=arg1<=ARGt_RM64 || ARGt_M8<=arg1<=ARGt_M64 ||
|
||||
ARGt_RM8<=arg2<=ARGt_RM64 || ARGt_M8<=arg2<=ARGt_M64) {
|
||||
if (ARGt_RM8<=arg2<=ARGt_RM64 || ARGt_M8<=arg2<=ARGt_M64) {
|
||||
reloced_arg1=arg2;
|
||||
reloced_arg2=arg1;
|
||||
reloced_arg1_size=arg2_size;
|
||||
@ -436,11 +436,11 @@ U0 Ui(U8 *buf,U8 **_rip,I64 seg_size=64,I64 *_jmp_dst=NULL,Bool just_ins=FALSE)
|
||||
RM2=-1;
|
||||
else {
|
||||
ptr=NULL;
|
||||
if (reloced_arg2==ARGT_SREG) {
|
||||
if (reloced_arg2==ARGt_SREG) {
|
||||
if (RM2<=5)
|
||||
ptr="ST_SEG_REGS";
|
||||
} else if (!(ARGT_IMM8<=reloced_arg2<=ARGT_IMM64) &&
|
||||
!(ARGT_UIMM8<=reloced_arg2<=ARGT_UIMM64)) {
|
||||
} else if (!(ARGt_IMM8<=reloced_arg2<=ARGt_IMM64) &&
|
||||
!(ARGt_UIMM8<=reloced_arg2<=ARGt_UIMM64)) {
|
||||
if (reloced_arg2_size==8) {
|
||||
if (REX!=-1)
|
||||
ptr="ST_U8_REX_REGS";
|
||||
@ -460,13 +460,13 @@ U0 Ui(U8 *buf,U8 **_rip,I64 seg_size=64,I64 *_jmp_dst=NULL,Bool just_ins=FALSE)
|
||||
disp=*rip(I32 *)++;
|
||||
if (seg_size==64) {
|
||||
disp+=rip;
|
||||
if (reloced_arg2==ARGT_IMM8 || reloced_arg2==ARGT_UIMM8)
|
||||
if (reloced_arg2==ARGt_IMM8 || reloced_arg2==ARGt_UIMM8)
|
||||
disp++;
|
||||
else if (reloced_arg2==ARGT_IMM16 || reloced_arg2==ARGT_UIMM16)
|
||||
else if (reloced_arg2==ARGt_IMM16 || reloced_arg2==ARGt_UIMM16)
|
||||
disp+=2;
|
||||
else if (reloced_arg2==ARGT_IMM32 || reloced_arg2==ARGT_UIMM32)
|
||||
else if (reloced_arg2==ARGt_IMM32 || reloced_arg2==ARGt_UIMM32)
|
||||
disp+=4;
|
||||
else if (reloced_arg2==ARGT_IMM64 || reloced_arg2==ARGT_UIMM64)
|
||||
else if (reloced_arg2==ARGt_IMM64 || reloced_arg2==ARGt_UIMM64)
|
||||
disp+=8;
|
||||
}
|
||||
CatPrint(reloced_arg1_st,"[%X]",disp);
|
||||
@ -526,33 +526,33 @@ U0 Ui(U8 *buf,U8 **_rip,I64 seg_size=64,I64 *_jmp_dst=NULL,Bool just_ins=FALSE)
|
||||
}
|
||||
|
||||
switch (arg1) {
|
||||
case ARGT_IMM8:
|
||||
case ARGT_UIMM8:
|
||||
case ARGt_IMM8:
|
||||
case ARGt_UIMM8:
|
||||
imm=*rip(U8 *)++;
|
||||
CatPrint(arg1_st,"%02X",imm);
|
||||
if (tmpins->opcode[0]==0xCD && (ptr=DefineSub(imm,"ST_INT_NAMES")))
|
||||
CatPrint(arg1_st,"%s",ptr);
|
||||
break;
|
||||
case ARGT_IMM16:
|
||||
case ARGT_UIMM16:
|
||||
case ARGt_IMM16:
|
||||
case ARGt_UIMM16:
|
||||
CatPrint(arg1_st,"%04X",*rip(U16 *)++);
|
||||
break;
|
||||
case ARGT_IMM32:
|
||||
case ARGT_UIMM32:
|
||||
case ARGt_IMM32:
|
||||
case ARGt_UIMM32:
|
||||
CatPrint(arg1_st,"%08X",*rip(U32 *)++);
|
||||
break;
|
||||
case ARGT_IMM64:
|
||||
case ARGT_UIMM64:
|
||||
case ARGt_IMM64:
|
||||
case ARGt_UIMM64:
|
||||
CatPrint(arg1_st,"%016X",*rip(I64 *)++);
|
||||
break;
|
||||
start:
|
||||
case ARGT_REL8:
|
||||
case ARGt_REL8:
|
||||
disp=*rip(I8 *)++;
|
||||
break;
|
||||
case ARGT_REL16:
|
||||
case ARGt_REL16:
|
||||
disp=*rip(I16 *)++;
|
||||
break;
|
||||
case ARGT_REL32:
|
||||
case ARGt_REL32:
|
||||
disp=*rip(I32 *)++;
|
||||
break;
|
||||
end:
|
||||
@ -565,7 +565,7 @@ U0 Ui(U8 *buf,U8 **_rip,I64 seg_size=64,I64 *_jmp_dst=NULL,Bool just_ins=FALSE)
|
||||
CatPrint(arg1_st,"%P ",disp);
|
||||
if (_jmp_dst) *_jmp_dst=disp;
|
||||
break;
|
||||
case ARGT_MOFFS8...ARGT_MOFFS64:
|
||||
case ARGt_MOFFS8...ARGt_MOFFS64:
|
||||
CatPrint(arg1_st,seg_overrides);
|
||||
if (arg1_size==8)
|
||||
disp=*rip(U8 *)++;
|
||||
@ -575,12 +575,12 @@ U0 Ui(U8 *buf,U8 **_rip,I64 seg_size=64,I64 *_jmp_dst=NULL,Bool just_ins=FALSE)
|
||||
disp=*rip(U32 *)++;
|
||||
CatPrint(arg1_st,"[%X]",disp);
|
||||
break;
|
||||
case ARGT_AL ... ARGT_DX:
|
||||
case ARGT_SS ... ARGT_ST0:
|
||||
CatPrint(arg1_st,"%z",arg1-ARGT_AL,
|
||||
case ARGt_AL ... ARGt_DX:
|
||||
case ARGt_SS ... ARGt_ST0:
|
||||
CatPrint(arg1_st,"%z",arg1-ARGt_AL,
|
||||
"AL\0AX\0EAX\0RAX\0CL\0DX\0\0\0SS\0DS\0ES\0FS\0GS\0CS\0ST0\0");
|
||||
break;
|
||||
case ARGT_STI:
|
||||
case ARGt_STI:
|
||||
rip--;
|
||||
CatPrint(arg1_st,"%Z",*rip++ - tmpins->opcode[tmpins->opcode_count-1],
|
||||
"ST_FSTACK_REGS");
|
||||
@ -588,23 +588,23 @@ U0 Ui(U8 *buf,U8 **_rip,I64 seg_size=64,I64 *_jmp_dst=NULL,Bool just_ins=FALSE)
|
||||
}
|
||||
|
||||
switch (arg2) {
|
||||
case ARGT_IMM8:
|
||||
case ARGT_UIMM8:
|
||||
case ARGt_IMM8:
|
||||
case ARGt_UIMM8:
|
||||
CatPrint(arg2_st,"%02X",*rip(U8 *)++);
|
||||
break;
|
||||
case ARGT_IMM16:
|
||||
case ARGT_UIMM16:
|
||||
case ARGt_IMM16:
|
||||
case ARGt_UIMM16:
|
||||
CatPrint(arg2_st,"%04X",*rip(U16 *)++);
|
||||
break;
|
||||
case ARGT_IMM32:
|
||||
case ARGT_UIMM32:
|
||||
case ARGt_IMM32:
|
||||
case ARGt_UIMM32:
|
||||
CatPrint(arg2_st,"%08X",*rip(U32 *)++);
|
||||
break;
|
||||
case ARGT_IMM64:
|
||||
case ARGT_UIMM64:
|
||||
case ARGt_IMM64:
|
||||
case ARGt_UIMM64:
|
||||
CatPrint(arg2_st,"%016X",*rip(I64 *)++);
|
||||
break;
|
||||
case ARGT_MOFFS8...ARGT_MOFFS64:
|
||||
case ARGt_MOFFS8...ARGt_MOFFS64:
|
||||
CatPrint(arg2_st,seg_overrides);
|
||||
if (arg2_size==8)
|
||||
disp=*rip(U8 *)++;
|
||||
@ -614,12 +614,12 @@ U0 Ui(U8 *buf,U8 **_rip,I64 seg_size=64,I64 *_jmp_dst=NULL,Bool just_ins=FALSE)
|
||||
disp=*rip(U32 *)++;
|
||||
CatPrint(arg2_st,"[%X]",disp);
|
||||
break;
|
||||
case ARGT_AL ... ARGT_DX:
|
||||
case ARGT_SS ... ARGT_ST0:
|
||||
CatPrint(arg2_st,"%z",arg2-ARGT_AL,
|
||||
case ARGt_AL ... ARGt_DX:
|
||||
case ARGt_SS ... ARGt_ST0:
|
||||
CatPrint(arg2_st,"%z",arg2-ARGt_AL,
|
||||
"AL\0AX\0EAX\0RAX\0CL\0DX\0\0\0SS\0DS\0ES\0FS\0GS\0CS\0ST0\0");
|
||||
break;
|
||||
case ARGT_STI:
|
||||
case ARGt_STI:
|
||||
rip--;
|
||||
CatPrint(arg2_st,"%Z",*rip++ -tmpins->opcode[tmpins->opcode_count-1],
|
||||
"ST_FSTACK_REGS");
|
||||
|
@ -4,7 +4,7 @@ $ID,2$The mini compiler is like the main compiler, except the main compiler's le
|
||||
|
||||
The main compiler generates $LK,"Intermediate Code",A="FF:::/Compiler/CompilerA.HH,IC_END"$ at the parser stage.See $LK,"ParseExpression",A="MN:ParseExpression"$(), $LK,"ParseStatement",A="MN:ParseStatement"$().
|
||||
|
||||
The main compiler optimizes See $LK,"Intermediate Code Attributes",A="MN:intermediate_code_table"$, $LK,"Combining Consts",A="FF:::/Compiler/OptPass012.CC,case IC_MUL"$, $LK,"Choosing Reg Vars",A="FF:::/Compiler/OptPass3.CC,cmp.num_reg_vars"$.Use $LK,"PassTrace",A="MN:PassTrace"$() to see the optimization stages.
|
||||
The main compiler optimizes See $LK,"Intermediate Code Attributes",A="MN:intermediate_code_table"$, $LK,"Combining Consts",A="FF:::/Compiler/OptPass012.CC,case IC_MUL"$, $LK,"Choosing Reg Vars",A="FF:::/Compiler/OptPass3.CC,comp.num_reg_vars"$.Use $LK,"PassTrace",A="MN:PassTrace"$() to see the optimization stages.
|
||||
|
||||
The main compiler makes machine code in the back end.See $LK,"IC Struct",A="MN:CIntermediateCode"$, $LK,"COCCompile",A="MN:COCCompile"$ and $LK,"OptPass789A",A="FF:::/Compiler/OptPass789A.CC,IC_MUL"$(),$LK,"BackEnd",A="FF:::/Compiler/BackA.CC,ICMul"$.Set $LK,"Trace",A="MN:Trace"$(ON) to see the output of the backend.
|
||||
$ID,-2$
|
||||
|
@ -314,7 +314,7 @@ $IV,1$----01/14/17 19:16:51----$IV,0$
|
||||
|
||||
$IV,1$----01/14/17 09:43:12----$IV,0$
|
||||
* Improved $LK,"::/Demo/AcctExample/TOS/TOSHolySpirit.HC"$.
|
||||
* Added cmp $LK,"U0 Expression",A="FF:::/Compiler/PrsExp.HC,U0 Expression"$ warn.
|
||||
* Added comp $LK,"U0 Expression",A="FF:::/Compiler/PrsExp.HC,U0 Expression"$ warn.
|
||||
* Improved syntax highlighting.
|
||||
|
||||
$IV,1$----01/11/17 03:33:33----$IV,0$
|
||||
|
@ -191,7 +191,7 @@ $FG$$ID,-2$
|
||||
|
||||
* There is no question-colon operator.
|
||||
|
||||
* ZenithOS $LK,"operator precedence",A="FF:::/Compiler/CInit.CC,cmp.binary_ops"$
|
||||
* ZenithOS $LK,"operator precedence",A="FF:::/Compiler/CInit.CC,comp.binary_ops"$
|
||||
$FG,2$`$FG$,$FG,2$>>$FG$,$FG,2$<<$FG$
|
||||
$FG,2$*$FG$,$FG,2$/$FG$,$FG,2$%$FG$
|
||||
$FG,2$&$FG$
|
||||
|
@ -198,13 +198,31 @@ U0 SysDefinesLoad()
|
||||
DefineListLoad("ST_COLORS","BLACK\0BLUE\0GREEN\0CYAN\0"
|
||||
"RED\0PURPLE\0BROWN\0LTGRAY\0DKGRAY\0LTBLUE\0LTGREEN\0"
|
||||
"LTCYAN\0LTRED\0LTPURPLE\0YELLOW\0WHITE\0");
|
||||
DefineListLoad("ST_INT_NAMES","Divide Error\0SingleStep\0NMI\0Breakpoint\0"
|
||||
"Overflow\0BOUND Range Exceeded\0Invalid Opcode\0No Math Coprocessor\0"
|
||||
"Double Fault\0Coprocessor Segment Fault\0Invalid TASK\0"
|
||||
"Segment Not Present\0Stack Segment Fault\0General Protection\0"
|
||||
"Page Fault\0\0Math Fault\0Alignment Check\0Machine Check\0"
|
||||
"SIMD Exception\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
|
||||
"\0\0\0\0\0\0\0\0\0\0\0MP Crash\0Wake\0Debug\0");
|
||||
DefineListLoad("ST_INT_NAMES",
|
||||
"Divide Error\0"
|
||||
"SingleStep\0"
|
||||
"NMI\0"
|
||||
"Breakpoint\0"
|
||||
"Overflow\0"
|
||||
"BOUND Range Exceeded\0"
|
||||
"Invalid Opcode\0"
|
||||
"No Math Coprocessor\0"
|
||||
"Double Fault\0"
|
||||
"Coprocessor Segment Fault\0"
|
||||
"Invalid TASK\0"
|
||||
"Segment Not Present\0"
|
||||
"Stack Segment Fault\0"
|
||||
"General Protection\0"
|
||||
"Page Fault\0"
|
||||
"\0"
|
||||
"Math Fault\0"
|
||||
"Alignment Check\0"
|
||||
"Machine Check\0"
|
||||
"SIMD Exception\0"
|
||||
"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
|
||||
"MP Crash\0"
|
||||
"Wake\0"
|
||||
"Debug\0");
|
||||
}
|
||||
|
||||
U8 *Color2Str(U8 *buf,CColorROPU32 c)
|
||||
|
@ -868,8 +868,7 @@ public class CHashGeneric:CHash
|
||||
#define REGT_R64 4
|
||||
#define REGT_SEG 5
|
||||
#define REGT_FSTACK 6
|
||||
#define REGT_MM 7
|
||||
#define REGT_XMM 8
|
||||
#define REGT_XMM 7
|
||||
|
||||
public class CHashReg:CHash
|
||||
{
|
||||
@ -2010,74 +2009,133 @@ class CAsmUnresolvedRef
|
||||
#define OM_IW 6
|
||||
#define OM_ID 7
|
||||
|
||||
#define ARGT_NONE 0
|
||||
#define ARGT_REL8 1
|
||||
#define ARGT_REL16 2
|
||||
#define ARGT_REL32 3
|
||||
#define ARGt_NONE 0
|
||||
#define ARGt_REL8 1
|
||||
#define ARGt_REL16 2
|
||||
#define ARGt_REL32 3
|
||||
#define ARGT_NONE (1<<ARGt_NONE)
|
||||
#define ARGT_REL8 (1<<ARGt_REL8)
|
||||
#define ARGT_REL16 (1<<ARGt_REL16)
|
||||
#define ARGT_REL32 (1<<ARGt_REL32)
|
||||
|
||||
#define ARGT_IMM8 4
|
||||
#define ARGT_IMM16 5
|
||||
#define ARGT_IMM32 6
|
||||
#define ARGT_IMM64 7
|
||||
#define ARGt_IMM8 4
|
||||
#define ARGt_IMM16 5
|
||||
#define ARGt_IMM32 6
|
||||
#define ARGt_IMM64 7
|
||||
#define ARGT_IMM8 (1<<ARGt_IMM8)
|
||||
#define ARGT_IMM16 (1<<ARGt_IMM16)
|
||||
#define ARGT_IMM32 (1<<ARGt_IMM32)
|
||||
#define ARGT_IMM64 (1<<ARGt_IMM64)
|
||||
|
||||
#define ARGT_UIMM8 8
|
||||
#define ARGT_UIMM16 9
|
||||
#define ARGT_UIMM32 10
|
||||
#define ARGT_UIMM64 11
|
||||
#define ARGt_UIMM8 8
|
||||
#define ARGt_UIMM16 9
|
||||
#define ARGt_UIMM32 10
|
||||
#define ARGt_UIMM64 11
|
||||
#define ARGT_UIMM8 (1<<ARGt_UIMM8)
|
||||
#define ARGT_UIMM16 (1<<ARGt_UIMM16)
|
||||
#define ARGT_UIMM32 (1<<ARGt_UIMM32)
|
||||
#define ARGT_UIMM64 (1<<ARGt_UIMM64)
|
||||
|
||||
#define ARGT_R8 12
|
||||
#define ARGT_R16 13
|
||||
#define ARGT_R32 14
|
||||
#define ARGT_R64 15
|
||||
#define ARGt_R8 12
|
||||
#define ARGt_R16 13
|
||||
#define ARGt_R32 14
|
||||
#define ARGt_R64 15
|
||||
#define ARGT_R8 (1<<ARGt_R8)
|
||||
#define ARGT_R16 (1<<ARGt_R16)
|
||||
#define ARGT_R32 (1<<ARGt_R32)
|
||||
#define ARGT_R64 (1<<ARGt_R64)
|
||||
|
||||
#define ARGT_RM8 16
|
||||
#define ARGT_RM16 17
|
||||
#define ARGT_RM32 18
|
||||
#define ARGT_RM64 19
|
||||
#define ARGt_RM8 16
|
||||
#define ARGt_RM16 17
|
||||
#define ARGt_RM32 18
|
||||
#define ARGt_RM64 19
|
||||
#define ARGT_RM8 (1<<ARGt_RM8)
|
||||
#define ARGT_RM16 (1<<ARGt_RM16)
|
||||
#define ARGT_RM32 (1<<ARGt_RM32)
|
||||
#define ARGT_RM64 (1<<ARGt_RM64)
|
||||
|
||||
#define ARGT_M8 20
|
||||
#define ARGT_M16 21
|
||||
#define ARGT_M32 22
|
||||
#define ARGT_M64 23
|
||||
#define ARGt_M8 20
|
||||
#define ARGt_M16 21
|
||||
#define ARGt_M32 22
|
||||
#define ARGt_M64 23
|
||||
#define ARGT_M8 (1<<ARGt_M8)
|
||||
#define ARGT_M16 (1<<ARGt_M16)
|
||||
#define ARGT_M32 (1<<ARGt_M32)
|
||||
#define ARGT_M64 (1<<ARGt_M64)
|
||||
|
||||
#define ARGT_M1632 24 // Not implemented
|
||||
#define ARGT_M16N32 25 // Not implemented
|
||||
#define ARGT_M16N16 26 // Not implemented
|
||||
#define ARGT_M32N32 27 // Not implemented
|
||||
#define ARGt_M1632 24 // Not implemented
|
||||
#define ARGt_M16N32 25 // Not implemented
|
||||
#define ARGt_M16N16 26 // Not implemented
|
||||
#define ARGt_M32N32 27 // Not implemented
|
||||
#define ARGT_M1632 (1<<ARGt_M1632)
|
||||
#define ARGT_M16N32 (1<<ARGt_M16N32)
|
||||
#define ARGT_M16N16 (1<<ARGt_M16N16)
|
||||
#define ARGT_M32N32 (1<<ARGt_M32N32)
|
||||
|
||||
#define ARGT_MOFFS8 28
|
||||
#define ARGT_MOFFS16 29
|
||||
#define ARGT_MOFFS32 30
|
||||
#define ARGT_MOFFS64 31
|
||||
#define ARGt_MOFFS8 28
|
||||
#define ARGt_MOFFS16 29
|
||||
#define ARGt_MOFFS32 30
|
||||
#define ARGt_MOFFS64 31
|
||||
#define ARGT_MOFFS8 (1<<ARGt_MOFFS8)
|
||||
#define ARGT_MOFFS16 (1<<ARGt_MOFFS16)
|
||||
#define ARGT_MOFFS32 (1<<ARGt_MOFFS32)
|
||||
#define ARGT_MOFFS64 (1<<ARGt_MOFFS64)
|
||||
|
||||
#define ARGT_AL 32
|
||||
#define ARGT_AX 33
|
||||
#define ARGT_EAX 34
|
||||
#define ARGT_RAX 35
|
||||
#define ARGt_AL 32
|
||||
#define ARGt_AX 33
|
||||
#define ARGt_EAX 34
|
||||
#define ARGt_RAX 35
|
||||
#define ARGt_CL 36
|
||||
#define ARGt_DX 37
|
||||
#define ARGT_AL (1<<ARGt_AL)
|
||||
#define ARGT_AX (1<<ARGt_AX)
|
||||
#define ARGT_EAX (1<<ARGt_EAX)
|
||||
#define ARGT_RAX (1<<ARGt_RAX)
|
||||
#define ARGT_CL (1<<ARGt_CL)
|
||||
#define ARGT_DX (1<<ARGt_DX)
|
||||
|
||||
#define ARGT_CL 36
|
||||
#define ARGT_DX 37
|
||||
#define ARGT_SREG 39
|
||||
#define ARGt_SREG 39
|
||||
#define ARGt_SS 40
|
||||
#define ARGt_DS 41
|
||||
#define ARGt_ES 42
|
||||
#define ARGt_FS 43
|
||||
#define ARGt_GS 44
|
||||
#define ARGt_CS 45
|
||||
#define ARGT_SREG (1<<ARGt_SREG)
|
||||
#define ARGT_SS (1<<ARGt_SS)
|
||||
#define ARGT_DS (1<<ARGt_DS)
|
||||
#define ARGT_ES (1<<ARGt_ES)
|
||||
#define ARGT_FS (1<<ARGt_FS)
|
||||
#define ARGT_GS (1<<ARGt_GS)
|
||||
#define ARGT_CS (1<<ARGt_CS)
|
||||
|
||||
#define ARGT_SS 40
|
||||
#define ARGT_DS 41
|
||||
#define ARGT_ES 42
|
||||
#define ARGT_FS 43
|
||||
#define ARGt_ST0 46
|
||||
#define ARGt_STI 47
|
||||
#define ARGT_ST0 (1<<ARGt_ST0)
|
||||
#define ARGT_STI (1<<ARGt_STI)
|
||||
|
||||
#define ARGT_GS 44
|
||||
#define ARGT_CS 45
|
||||
#define ARGT_ST0 46
|
||||
#define ARGT_STI 47
|
||||
#define ARGt_MM 48 // Not implemented
|
||||
#define ARGt_MM32 49 // Not implemented
|
||||
#define ARGt_MM64 50 // Not implemented
|
||||
#define ARGT_MM (1<<ARGt_MM)
|
||||
#define ARGT_MM32 (1<<ARGt_MM32)
|
||||
#define ARGT_MM64 (1<<ARGt_MM64)
|
||||
|
||||
#define ARGT_MM 48 // Not implemented
|
||||
#define ARGT_MM32 49 // Not implemented
|
||||
#define ARGT_MM64 50 // Not implemented
|
||||
#define ARGT_XMM 51 // Not implemented
|
||||
#define ARGt_XMM 51 // Not implemented
|
||||
#define ARGt_XMM0 52 // Not implemented
|
||||
#define ARGt_XMM64 53 // Not implemented
|
||||
#define ARGt_XMM128 54 // Not implemented
|
||||
#define ARGT_XMM (1<<ARGt_XMM)
|
||||
#define ARGT_XMM0 (1<<ARGt_XMM0)
|
||||
#define ARGT_XMM64 (1<<ARGt_XMM64)
|
||||
#define ARGT_XMM128 (1<<ARGt_XMM128)
|
||||
#define ARGT_M128 (1<<55)
|
||||
|
||||
#define ARGT_XMM32 52 // Not implemented
|
||||
#define ARGT_XMM64 53 // Not implemented
|
||||
#define ARGT_XMM128 54 // Not implemented
|
||||
#define ARGT_XMM0 55 // Not implemented
|
||||
#define ARGG_SIZE_1 (1)
|
||||
#define ARGG_SIZE_2 (1)
|
||||
#define ARGG_SIZE_4 (1)
|
||||
#define ARGG_SIZE_8 (ARGT_IMM64|ARGT_UIMM64|ARGT_R64|ARGT_RM64|ARGT_M64|ARGT_MOFFS64|ARGT_RAX|ARGT_XMM64)
|
||||
#define ARGG_SIZE_16 (ARGT_XMM|ARGT_XMM0|ARGT_XMM128|ARGT_M128)
|
||||
|
||||
#help_index "Compiler/Internal;Hash/System"
|
||||
#define OCF_ALIAS 1
|
||||
@ -2357,7 +2415,7 @@ public class CCompGlobals
|
||||
I64 num_reg_vars,num_non_ptr_vars,
|
||||
stack_tmps_mask,reg_vars_mask,non_ptr_vars_mask;
|
||||
U8 *to_reg_vars_map,*non_ptr_vars_map;
|
||||
I64 size_arg_mask[9],
|
||||
I64 size_arg_mask[17],
|
||||
compiled_lines;
|
||||
};
|
||||
|
||||
|
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user