committed OP_FLOAT_CMP

This commit is contained in:
David Anderson 2006-02-11 07:06:35 +00:00
parent eba5b1a920
commit e74ff6a5a4
9 changed files with 88 additions and 17 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -272,6 +272,7 @@ typedef enum {
OP_FLOAT_SUB, OP_FLOAT_SUB,
OP_FLOAT_TO, OP_FLOAT_TO,
OP_FLOAT_ROUND, OP_FLOAT_ROUND,
OP_FLOAT_CMP,
/* ----- */ /* ----- */
OP_NUM_OPCODES OP_NUM_OPCODES
} OPCODE; } OPCODE;
@ -698,6 +699,7 @@ static int amx_BrowseRelocate(AMX *amx)
case OP_FLOAT_SUB: case OP_FLOAT_SUB:
case OP_FLOAT_TO: case OP_FLOAT_TO:
case OP_FLOAT_ROUND: case OP_FLOAT_ROUND:
case OP_FLOAT_CMP:
break; break;
case OP_CALL: /* opcodes that need relocation */ case OP_CALL: /* opcodes that need relocation */
@ -1764,14 +1766,15 @@ static const void * const amx_opcodelist[] = {
&&op_jump_pri, &&op_switch, &&op_casetbl, &&op_swap_pri, &&op_jump_pri, &&op_switch, &&op_casetbl, &&op_swap_pri,
&&op_swap_alt, &&op_pushaddr, &&op_nop, &&op_sysreq_d, &&op_swap_alt, &&op_pushaddr, &&op_nop, &&op_sysreq_d,
&&op_symtag, &&op_break, &&op_float_mul, &&op_float_div, &&op_symtag, &&op_break, &&op_float_mul, &&op_float_div,
&&op_float_add, &&op_float_sub, &&op_float_to, &&op_float_round}; &&op_float_add, &&op_float_sub, &&op_float_to, &&op_float_round,
&&op_float_cmp};
AMX_HEADER *hdr; AMX_HEADER *hdr;
AMX_FUNCSTUB *func; AMX_FUNCSTUB *func;
unsigned char *code, *data; unsigned char *code, *data;
cell pri,alt,stk,frm,hea; cell pri,alt,stk,frm,hea;
cell reset_stk, reset_hea, *cip; cell reset_stk, reset_hea, *cip;
cell offs, offs2; cell offs, offs2;
REAL fnum; REAL fnum, fnum2;
ucell codesize; ucell codesize;
int num,i; int num,i;
@ -2658,6 +2661,18 @@ static const void * const amx_opcodelist[] = {
fnum = ceil(fnum); fnum = ceil(fnum);
pri = (cell)fnum; pri = (cell)fnum;
NEXT(cip); NEXT(cip);
op_float_cmp:
offs = *(cell *)(data + (int)stk + sizeof(cell)*1);
offs2 = *(cell *)(data + (int)stk + sizeof(cell)*2);
fnum = amx_ctof(offs);
fnum2 = amx_ctof(offs2);
if (fnum == fnum2)
pri = 0;
else if (fnum > fnum2)
pri = 1;
else
pri = -1;
NEXT(cip);
op_break: op_break:
if (amx->debug!=NULL) { if (amx->debug!=NULL) {
/* store status */ /* store status */
@ -2743,7 +2758,7 @@ int AMXAPI amx_Exec(AMX *amx, cell *retval, int index)
#else #else
OPCODE op; OPCODE op;
cell offs, offs2; cell offs, offs2;
REAL fnum; REAL fnum, fnum2;
int num; int num;
#endif #endif
assert(amx!=NULL); assert(amx!=NULL);
@ -3675,6 +3690,18 @@ int AMXAPI amx_Exec(AMX *amx, cell *retval, int index)
fnum = ceil(fnum); fnum = ceil(fnum);
pri = (cell)fnum; pri = (cell)fnum;
break; break;
case OP_FLOAT_CMP:
offs = *(cell *)(data + (int)stk + sizeof(cell)*1);
offs2 = *(cell *)(data + (int)stk + sizeof(cell)*2);
fnum = amx_ctof(offs);
fnum2 = amx_ctof(offs2);
if (fnum == fnum2)
pri = 0;
else if (fnum > fnum2)
pri = 1;
else
pri = -1;
break;
case OP_BREAK: case OP_BREAK:
assert((amx->flags & AMX_FLAG_BROWSE)==0); assert((amx->flags & AMX_FLAG_BROWSE)==0);
if (amx->debug!=NULL) { if (amx->debug!=NULL) {

View File

@ -1486,6 +1486,18 @@ OP_FLOAT_ROUND:
pop ebp pop ebp
GO_ON GO_ON
OP_FLOAT_CMP:
add esi, 4
fld dword [edi+ecx+8]
fld dword [edi+ecx+4]
fucompp
fnstsw ax
sahf
cmovz eax, [g_flags+4]
cmovg eax, [g_flags+8]
cmovl eax, [g_flags+0]
GO_ON
OP_BREAK: OP_BREAK:
mov ebp,amx ; get amx into ebp mov ebp,amx ; get amx into ebp
add esi,4 add esi,4
@ -1580,6 +1592,12 @@ Start_DATA
lodb_and DD 0ffh, 0ffffh, 0, 0ffffffffh lodb_and DD 0ffh, 0ffffh, 0, 0ffffffffh
GLOBAL g_flags
g_flags:
DD -1
DD 0
DD 1
GLOBAL amx_opcodelist GLOBAL amx_opcodelist
GLOBAL _amx_opcodelist GLOBAL _amx_opcodelist
amx_opcodelist: amx_opcodelist:
@ -1727,3 +1745,4 @@ _amx_opcodelist DD OP_INVALID
DD OP_FLOAT_SUB DD OP_FLOAT_SUB
DD OP_FLOAT_TO DD OP_FLOAT_TO
DD OP_FLOAT_ROUND DD OP_FLOAT_ROUND
DD OP_FLOAT_CMP

View File

@ -1941,7 +1941,7 @@ OP_FLOAT_TO:
CHECKCODESIZE j_float_to CHECKCODESIZE j_float_to
OP_FLOAT_ROUND: OP_FLOAT_ROUND:
GO_ON j_float_round, OP_INVALID GO_ON j_float_round, OP_FLOAT_CMP
j_float_round: j_float_round:
;get the float control word ;get the float control word
push 0 push 0
@ -1975,6 +1975,19 @@ OP_FLOAT_ROUND:
pop ebp pop ebp
CHECKCODESIZE j_float_round CHECKCODESIZE j_float_round
OP_FLOAT_CMP:
GO_ON j_float_cmp, OP_INVALID
j_float_cmp:
fld dword [esi+8]
fld dword [esi+4]
fucompp
fnstsw ax
sahf
cmovz eax, [g_flagsjit+4]
cmovg eax, [g_flagsjit+8]
cmovl eax, [g_flagsjit+0]
CHECKCODESIZE j_float_cmp
OP_INVALID: ; break from the compiler with an error code OP_INVALID: ; break from the compiler with an error code
mov eax,AMX_ERR_INVINSTR mov eax,AMX_ERR_INVINSTR
pop esi pop esi
@ -2403,6 +2416,12 @@ jit_switch DD JIT_OP_SWITCH
; The table for the browser/relocator function. ; The table for the browser/relocator function.
; ;
global g_flagsjit
g_flagsjit:
DD -1
DD 0
DD 1
global amx_opcodelist_jit, _amx_opcodelist_jit global amx_opcodelist_jit, _amx_opcodelist_jit
amx_opcodelist_jit: amx_opcodelist_jit:
@ -2551,5 +2570,6 @@ _amx_opcodelist_jit:
DD OP_FLOAT_SUB ; DA DD OP_FLOAT_SUB ; DA
DD OP_FLOAT_TO ; DA DD OP_FLOAT_TO ; DA
DD OP_FLOAT_ROUND ; DA DD OP_FLOAT_ROUND ; DA
DD OP_FLOAT_CMP ; DA
END END

View File

@ -9,6 +9,7 @@
#define OP_FLOAT_SUB 141 #define OP_FLOAT_SUB 141
#define OP_FLOAT_TO 142 #define OP_FLOAT_TO 142
#define OP_FLOAT_ROUND 143 #define OP_FLOAT_ROUND 143
#define OP_FLOAT_CMP 144
cell op_trans_table[N_Total_FloatOps] = cell op_trans_table[N_Total_FloatOps] =
{ {
@ -17,7 +18,8 @@ cell op_trans_table[N_Total_FloatOps] =
OP_FLOAT_ADD, OP_FLOAT_ADD,
OP_FLOAT_SUB, OP_FLOAT_SUB,
OP_FLOAT_TO, OP_FLOAT_TO,
OP_FLOAT_ROUND OP_FLOAT_ROUND,
OP_FLOAT_CMP
}; };
void OnBrowseRelocate(AMX *amx, cell *oplist, cell *cip) void OnBrowseRelocate(AMX *amx, cell *oplist, cell *cip)
@ -87,6 +89,7 @@ void _Setup_Optimizer_Stage2(AMX *amx, cell *oplist, cell *cip)
FIND_NATIVE("floatsub", N_Float_Sub); FIND_NATIVE("floatsub", N_Float_Sub);
FIND_NATIVE("float", N_Float_To); FIND_NATIVE("float", N_Float_To);
FIND_NATIVE("floatround", N_Float_Round); FIND_NATIVE("floatround", N_Float_Round);
FIND_NATIVE("floatcmp", N_Float_Cmp);
//we don't do these yet because of radix stuff >:\ //we don't do these yet because of radix stuff >:\
//FIND_NATIVE("floatsin", N_Float_Sin); //FIND_NATIVE("floatsin", N_Float_Sin);
//FIND_NATIVE("floatcos", N_Float_Cos); //FIND_NATIVE("floatcos", N_Float_Cos);

View File

@ -11,7 +11,9 @@ enum
N_Float_Sub, N_Float_Sub,
N_Float_To, N_Float_To,
N_Float_Round, N_Float_Round,
N_Total_FloatOps N_Float_Cmp,
/* ------------ */
N_Total_FloatOps,
}; };
struct optimizer_s struct optimizer_s