This commit is contained in:
Pavel 2024-03-17 22:10:11 +03:00
parent c2991ffd65
commit 6ebcf51c08
5 changed files with 150 additions and 90 deletions

View File

@ -22,7 +22,7 @@ type
ALock :Boolean;
end;
t_op_opt=Set of (not_impl,not_prefix,not_vex_len);
t_op_opt=Set of (not_impl,not_os8,not_prefix,not_vex_len);
t_op_type=packed object
op :DWORD;
@ -2153,7 +2153,7 @@ begin
op:=desc.op;
case mreg.AMemSize of
os8:
if (not (not_prefix in desc.opt)) then
if (not (not_os8 in desc.opt)) then
begin
Dec(op);
end;
@ -2234,7 +2234,7 @@ begin
op:=desc.op;
case mreg.AMemSize of
os8:
if (not (not_prefix in desc.opt)) then
if (not (not_os8 in desc.opt)) then
begin
Dec(op);
end;
@ -2323,7 +2323,7 @@ begin
op:=desc.op;
case mreg.AMemSize of
os8:
if (not (not_prefix in desc.opt)) then
if (not (not_os8 in desc.opt)) then
begin
Dec(op);
end;
@ -2405,7 +2405,7 @@ begin
op:=desc.op;
case size of
os8:
if (not (not_prefix in desc.opt)) then
if (not (not_os8 in desc.opt)) then
begin
Dec(op);
end;
@ -2475,7 +2475,7 @@ begin
op:=desc.op;
case size of
os8:
if (not (not_prefix in desc.opt)) then
if (not (not_os8 in desc.opt)) then
begin
Dec(op);
end;
@ -2551,7 +2551,7 @@ begin
op:=desc.op;
case size of
os8:
if (not (not_prefix in desc.opt)) then
if (not (not_os8 in desc.opt)) then
begin
Dec(op);
end;
@ -2609,7 +2609,7 @@ begin
op:=desc.op;
case reg.ASize of
os8:
if (not (not_prefix in desc.opt)) then
if (not (not_os8 in desc.opt)) then
begin
Dec(op);
end;
@ -2658,7 +2658,7 @@ begin
case Size of
os8:
if (not (not_prefix in opt)) then
if (not (not_os8 in opt)) then
begin
Dec(op);
end;
@ -2729,7 +2729,7 @@ begin
op:=desc.op;
case reg.ASize of
os8:
if (not (not_prefix in desc.opt)) then
if (not (not_os8 in desc.opt)) then
begin
Dec(op);
end;
@ -2829,7 +2829,7 @@ begin
begin
case mreg.AMemSize of
os8:
if (not (not_prefix in desc.opt)) then
if (not (not_os8 in desc.opt)) then
begin
Dec(op);
end;
@ -2904,7 +2904,7 @@ begin
op:=desc.op;
case reg.ASize of
os8:
if (not (not_prefix in desc.opt)) then
if (not (not_os8 in desc.opt)) then
begin
Dec(op);
end;
@ -2971,7 +2971,7 @@ begin
op:=desc.op;
case mreg.AMemSize of
os8:
if (not (not_prefix in desc.opt)) then
if (not (not_os8 in desc.opt)) then
begin
Dec(op);
end;

View File

@ -671,7 +671,7 @@ begin
if (p_print_jit_preload<>0) then
begin
Writeln('build_chunk:0x',HexStr(jcode^.dest,16),'..',HexStr(jcode^.d_end,16),':',i,':',count);
Writeln('build_chunk:0x',HexStr(jcode^.dest,16),'..',HexStr(jcode^.d_end,16),':',count);
end;
//writeln('[0x',HexStr(start,16),':0x',HexStr(__end,16),':',count);

View File

@ -914,7 +914,26 @@ begin
tmp.op :=ctx.dis.opcode;
tmp.index:=ctx.dis.ModRM.Index;
tmp.opt :=[not_prefix];
tmp.opt :=[not_os8];
op_emit1(ctx,tmp,[]);
end else
begin
add_orig(ctx);
end;
end;
procedure op_emit1_gn_np(var ctx:t_jit_context2);
var
tmp:t_op_type;
begin
if is_preserved(ctx.din) or is_memory(ctx.din) then
begin
tmp:=Default(t_op_type);
tmp.op :=ctx.dis.opcode;
tmp.index:=ctx.dis.ModRM.Index;
tmp.opt :=[not_os8,not_prefix];
op_emit1(ctx,tmp,[]);
end else
@ -933,7 +952,26 @@ begin
tmp.op :=ctx.dis.opcode;
tmp.index:=ctx.dis.ModRM.Index;
tmp.opt :=[not_prefix];
tmp.opt :=[not_os8];
op_emit1(ctx,tmp,[his_ro]);
end else
begin
add_orig(ctx);
end;
end;
procedure op_emit1_ro_np(var ctx:t_jit_context2);
var
tmp:t_op_type;
begin
if is_preserved(ctx.din) or is_memory(ctx.din) then
begin
tmp:=Default(t_op_type);
tmp.op :=ctx.dis.opcode;
tmp.index:=ctx.dis.ModRM.Index;
tmp.opt :=[not_os8,not_prefix];
op_emit1(ctx,tmp,[his_ro]);
end else
@ -952,7 +990,26 @@ begin
tmp.op :=ctx.dis.opcode;
tmp.index:=ctx.dis.ModRM.Index;
tmp.opt :=[not_prefix];
tmp.opt :=[not_os8];
op_emit1(ctx,tmp,[his_rw]);
end else
begin
add_orig(ctx);
end;
end;
procedure op_emit1_rw_np(var ctx:t_jit_context2);
var
tmp:t_op_type;
begin
if is_preserved(ctx.din) or is_memory(ctx.din) then
begin
tmp:=Default(t_op_type);
tmp.op :=ctx.dis.opcode;
tmp.index:=ctx.dis.ModRM.Index;
tmp.opt :=[not_os8,not_prefix];
op_emit1(ctx,tmp,[his_rw]);
end else
@ -1199,7 +1256,7 @@ end;
const
movx_desc:t_op_desc=(
mem_reg:(opt:[not_impl]);
reg_mem:(op:$00;opt:[not_prefix]);
reg_mem:(op:$00;opt:[not_os8]);
reg_imm:(opt:[not_impl]);
reg_im8:(opt:[not_impl]);
hint:[his_mov,his_wo];
@ -1253,8 +1310,8 @@ end;
const
movbe_desc:t_op_desc=(
mem_reg:(op:$0F38F1;opt:[not_prefix]);
reg_mem:(op:$0F38F0;opt:[not_prefix]);
mem_reg:(op:$0F38F1;opt:[not_os8]);
reg_mem:(op:$0F38F0;opt:[not_os8]);
reg_imm:(opt:[not_impl]);
reg_im8:(opt:[not_impl]);
hint:[his_mov,his_wo];
@ -1274,7 +1331,7 @@ end;
const
movsxd_desc:t_op_desc=(
mem_reg:(opt:[not_impl]);
reg_mem:(op:$63;opt:[not_prefix]);
reg_mem:(op:$63;opt:[not_os8]);
reg_imm:(opt:[not_impl]);
reg_im8:(opt:[not_impl]);
hint:[his_mov,his_wo];
@ -1703,22 +1760,22 @@ begin
jit_cbs[OPPnone,OPshl ,OPSx_d ]:=@op_shld;
jit_cbs[OPPnone,OPshr ,OPSx_d ]:=@op_shrd;
jit_cbs[OPPnone,OPset__,OPSc_o ]:=@op_emit1_gn;
jit_cbs[OPPnone,OPset__,OPSc_no ]:=@op_emit1_gn;
jit_cbs[OPPnone,OPset__,OPSc_b ]:=@op_emit1_gn;
jit_cbs[OPPnone,OPset__,OPSc_nb ]:=@op_emit1_gn;
jit_cbs[OPPnone,OPset__,OPSc_z ]:=@op_emit1_gn;
jit_cbs[OPPnone,OPset__,OPSc_nz ]:=@op_emit1_gn;
jit_cbs[OPPnone,OPset__,OPSc_be ]:=@op_emit1_gn;
jit_cbs[OPPnone,OPset__,OPSc_nbe]:=@op_emit1_gn;
jit_cbs[OPPnone,OPset__,OPSc_s ]:=@op_emit1_gn;
jit_cbs[OPPnone,OPset__,OPSc_ns ]:=@op_emit1_gn;
jit_cbs[OPPnone,OPset__,OPSc_p ]:=@op_emit1_gn;
jit_cbs[OPPnone,OPset__,OPSc_np ]:=@op_emit1_gn;
jit_cbs[OPPnone,OPset__,OPSc_l ]:=@op_emit1_gn;
jit_cbs[OPPnone,OPset__,OPSc_nl ]:=@op_emit1_gn;
jit_cbs[OPPnone,OPset__,OPSc_le ]:=@op_emit1_gn;
jit_cbs[OPPnone,OPset__,OPSc_nle]:=@op_emit1_gn;
jit_cbs[OPPnone,OPset__,OPSc_o ]:=@op_emit1_gn_np;
jit_cbs[OPPnone,OPset__,OPSc_no ]:=@op_emit1_gn_np;
jit_cbs[OPPnone,OPset__,OPSc_b ]:=@op_emit1_gn_np;
jit_cbs[OPPnone,OPset__,OPSc_nb ]:=@op_emit1_gn_np;
jit_cbs[OPPnone,OPset__,OPSc_z ]:=@op_emit1_gn_np;
jit_cbs[OPPnone,OPset__,OPSc_nz ]:=@op_emit1_gn_np;
jit_cbs[OPPnone,OPset__,OPSc_be ]:=@op_emit1_gn_np;
jit_cbs[OPPnone,OPset__,OPSc_nbe]:=@op_emit1_gn_np;
jit_cbs[OPPnone,OPset__,OPSc_s ]:=@op_emit1_gn_np;
jit_cbs[OPPnone,OPset__,OPSc_ns ]:=@op_emit1_gn_np;
jit_cbs[OPPnone,OPset__,OPSc_p ]:=@op_emit1_gn_np;
jit_cbs[OPPnone,OPset__,OPSc_np ]:=@op_emit1_gn_np;
jit_cbs[OPPnone,OPset__,OPSc_l ]:=@op_emit1_gn_np;
jit_cbs[OPPnone,OPset__,OPSc_nl ]:=@op_emit1_gn_np;
jit_cbs[OPPnone,OPset__,OPSc_le ]:=@op_emit1_gn_np;
jit_cbs[OPPnone,OPset__,OPSc_nle]:=@op_emit1_gn_np;
jit_cbs[OPPnone,OPemms ,OPSnone]:=@add_orig;
jit_cbs[OPPnone,OPfemms ,OPSnone]:=@add_orig;
@ -1832,42 +1889,42 @@ begin
//
jit_cbs[OPPnone,OPfldcw ,OPSnone]:=@op_emit1_ro;
jit_cbs[OPPnone,OPfld ,OPSnone]:=@op_emit1_ro;
jit_cbs[OPPnone,OPfild ,OPSnone]:=@op_emit1_ro;
jit_cbs[OPPnone,OPfldcw ,OPSnone]:=@op_emit1_ro_np;
jit_cbs[OPPnone,OPfld ,OPSnone]:=@op_emit1_ro_np;
jit_cbs[OPPnone,OPfild ,OPSnone]:=@op_emit1_ro_np;
jit_cbs[OPPnone,OPfldenv ,OPSnone]:=@op_emit1_ro;
jit_cbs[OPPnone,OPfnstenv,OPSnone]:=@op_emit1_gn;
jit_cbs[OPPnone,OPfnstcw ,OPSnone]:=@op_emit1_gn;
jit_cbs[OPPnone,OPfnstsw ,OPSnone]:=@op_emit1_gn;
jit_cbs[OPPnone,OPfldenv ,OPSnone]:=@op_emit1_ro_np;
jit_cbs[OPPnone,OPfnstenv,OPSnone]:=@op_emit1_gn_np;
jit_cbs[OPPnone,OPfnstcw ,OPSnone]:=@op_emit1_gn_np;
jit_cbs[OPPnone,OPfnstsw ,OPSnone]:=@op_emit1_gn_np;
jit_cbs[OPPnone,OPfxsave ,OPSnone]:=@op_emit1_gn;
jit_cbs[OPPnone,OPfxrstor,OPSnone]:=@op_emit1_ro;
jit_cbs[OPPnone,OPfst ,OPSnone]:=@op_emit1_gn;
jit_cbs[OPPnone,OPfst ,OPSx_p ]:=@op_emit1_gn;
jit_cbs[OPPnone,OPfist ,OPSnone]:=@op_emit1_gn;
jit_cbs[OPPnone,OPfist ,OPSx_p ]:=@op_emit1_gn;
jit_cbs[OPPnone,OPfisttp ,OPSnone]:=@op_emit1_gn;
jit_cbs[OPPnone,OPfadd ,OPSnone]:=@op_emit1_ro;
jit_cbs[OPPnone,OPfiadd ,OPSnone]:=@op_emit1_ro;
jit_cbs[OPPnone,OPfmul ,OPSnone]:=@op_emit1_ro;
jit_cbs[OPPnone,OPfimul ,OPSnone]:=@op_emit1_ro;
jit_cbs[OPPnone,OPfsub ,OPSnone]:=@op_emit1_ro;
jit_cbs[OPPnone,OPfsubr ,OPSnone]:=@op_emit1_ro;
jit_cbs[OPPnone,OPfisub ,OPSnone]:=@op_emit1_ro;
jit_cbs[OPPnone,OPfdiv ,OPSnone]:=@op_emit1_ro;
jit_cbs[OPPnone,OPfdivr ,OPSnone]:=@op_emit1_ro;
jit_cbs[OPPnone,OPfxsave ,OPSnone]:=@op_emit1_gn_np;
jit_cbs[OPPnone,OPfxrstor,OPSnone]:=@op_emit1_ro_np;
jit_cbs[OPPnone,OPfst ,OPSnone]:=@op_emit1_gn_np;
jit_cbs[OPPnone,OPfst ,OPSx_p ]:=@op_emit1_gn_np;
jit_cbs[OPPnone,OPfist ,OPSnone]:=@op_emit1_gn_np;
jit_cbs[OPPnone,OPfist ,OPSx_p ]:=@op_emit1_gn_np;
jit_cbs[OPPnone,OPfisttp ,OPSnone]:=@op_emit1_gn_np;
jit_cbs[OPPnone,OPfadd ,OPSnone]:=@op_emit1_ro_np;
jit_cbs[OPPnone,OPfiadd ,OPSnone]:=@op_emit1_ro_np;
jit_cbs[OPPnone,OPfmul ,OPSnone]:=@op_emit1_ro_np;
jit_cbs[OPPnone,OPfimul ,OPSnone]:=@op_emit1_ro_np;
jit_cbs[OPPnone,OPfsub ,OPSnone]:=@op_emit1_ro_np;
jit_cbs[OPPnone,OPfsubr ,OPSnone]:=@op_emit1_ro_np;
jit_cbs[OPPnone,OPfisub ,OPSnone]:=@op_emit1_ro_np;
jit_cbs[OPPnone,OPfdiv ,OPSnone]:=@op_emit1_ro_np;
jit_cbs[OPPnone,OPfdivr ,OPSnone]:=@op_emit1_ro_np;
jit_cbs[OPPnone,OPclflush,OPSnone]:=@op_emit1_rw;
jit_cbs[OPPnone,OPclflush,OPSnone]:=@op_emit1_rw_np;
//fpu
jit_cbs[OPPnone,OPprefetch,OPSnone ]:=@op_emit1_rw;
jit_cbs[OPPnone,OPprefetch,OPSp_w ]:=@op_emit1_rw;
jit_cbs[OPPnone,OPprefetch,OPSp_nta]:=@op_emit1_rw;
jit_cbs[OPPnone,OPprefetch,OPSp_t0 ]:=@op_emit1_rw;
jit_cbs[OPPnone,OPprefetch,OPSp_t1 ]:=@op_emit1_rw;
jit_cbs[OPPnone,OPprefetch,OPSp_t2 ]:=@op_emit1_rw;
jit_cbs[OPPnone,OPprefetch,OPSnone ]:=@op_emit1_rw_np;
jit_cbs[OPPnone,OPprefetch,OPSp_w ]:=@op_emit1_rw_np;
jit_cbs[OPPnone,OPprefetch,OPSp_nta]:=@op_emit1_rw_np;
jit_cbs[OPPnone,OPprefetch,OPSp_t0 ]:=@op_emit1_rw_np;
jit_cbs[OPPnone,OPprefetch,OPSp_t1 ]:=@op_emit1_rw_np;
jit_cbs[OPPnone,OPprefetch,OPSp_t2 ]:=@op_emit1_rw_np;
end;

View File

@ -61,7 +61,7 @@ end;
procedure op_emit2_simd_mem_reg(var ctx:t_jit_context2;hint:t_op_hint);
const
desc:t_op_desc=(
mem_reg:(op:0;opt:[not_prefix]);
mem_reg:(op:0;opt:[not_os8,not_prefix]);
reg_mem:(opt:[not_impl]);
reg_imm:(opt:[not_impl]);
reg_im8:(opt:[not_impl]);
@ -81,7 +81,7 @@ procedure op_emit2_simd_reg_mem(var ctx:t_jit_context2;hint:t_op_hint);
const
desc:t_op_desc=(
mem_reg:(opt:[not_impl]);
reg_mem:(op:0;opt:[not_prefix]);
reg_mem:(op:0;opt:[not_os8,not_prefix]);
reg_imm:(opt:[not_impl]);
reg_im8:(opt:[not_impl]);
hint:[];
@ -159,8 +159,8 @@ end;
const
movsd_desc:t_op_desc=(
mem_reg:(op:$F20F11;opt:[not_prefix]);
reg_mem:(op:$F20F10;opt:[not_prefix]);
mem_reg:(op:$F20F11;opt:[not_os8,not_prefix]);
reg_mem:(op:$F20F10;opt:[not_os8,not_prefix]);
reg_imm:(opt:[not_impl]);
reg_im8:(opt:[not_impl]);
hint:[his_mov,his_wo];
@ -179,8 +179,8 @@ end;
const
movss_desc:t_op_desc=(
mem_reg:(op:$F30F11;opt:[not_prefix]);
reg_mem:(op:$F30F10;opt:[not_prefix]);
mem_reg:(op:$F30F11;opt:[not_os8,not_prefix]);
reg_mem:(op:$F30F10;opt:[not_os8,not_prefix]);
reg_imm:(opt:[not_impl]);
reg_im8:(opt:[not_impl]);
hint:[his_mov,his_wo];
@ -199,8 +199,8 @@ end;
const
mov_dq_desc:t_op_desc=(
mem_reg:(op:$0F7E;opt:[not_prefix]);
reg_mem:(op:$0F6E;opt:[not_prefix]);
mem_reg:(op:$0F7E;opt:[not_os8,not_prefix]);
reg_mem:(op:$0F6E;opt:[not_os8,not_prefix]);
reg_imm:(opt:[not_impl]);
reg_im8:(opt:[not_impl]);
hint:[his_mov,his_wo];
@ -219,8 +219,8 @@ end;
const
movdqa_desc:t_op_desc=(
mem_reg:(op:$660F7F;opt:[not_prefix]);
reg_mem:(op:$660F6F;opt:[not_prefix]);
mem_reg:(op:$660F7F;opt:[not_os8,not_prefix]);
reg_mem:(op:$660F6F;opt:[not_os8,not_prefix]);
reg_imm:(opt:[not_impl]);
reg_im8:(opt:[not_impl]);
hint:[his_mov,his_wo,his_align];
@ -239,8 +239,8 @@ end;
const
movdqu_desc:t_op_desc=(
mem_reg:(op:$F30F7F;opt:[not_prefix]);
reg_mem:(op:$F30F6F;opt:[not_prefix]);
mem_reg:(op:$F30F7F;opt:[not_os8,not_prefix]);
reg_mem:(op:$F30F6F;opt:[not_os8,not_prefix]);
reg_imm:(opt:[not_impl]);
reg_im8:(opt:[not_impl]);
hint:[his_mov,his_wo];
@ -261,8 +261,8 @@ end;
const
movu_ps_pd_desc:t_op_desc=(
mem_reg:(op:$0F11;opt:[not_prefix]);
reg_mem:(op:$0F10;opt:[not_prefix]);
mem_reg:(op:$0F11;opt:[not_os8,not_prefix]);
reg_mem:(op:$0F10;opt:[not_os8,not_prefix]);
reg_imm:(opt:[not_impl]);
reg_im8:(opt:[not_impl]);
hint:[his_mov,his_wo];
@ -283,8 +283,8 @@ end;
const
mova_ps_pd_desc:t_op_desc=(
mem_reg:(op:$0F29;opt:[not_prefix]);
reg_mem:(op:$0F28;opt:[not_prefix]);
mem_reg:(op:$0F29;opt:[not_os8,not_prefix]);
reg_mem:(op:$0F28;opt:[not_os8,not_prefix]);
reg_imm:(opt:[not_impl]);
reg_im8:(opt:[not_impl]);
hint:[his_mov,his_wo,his_align];
@ -306,7 +306,7 @@ end;
const
movntdqa_desc:t_op_desc=(
mem_reg:(opt:[not_impl]);
reg_mem:(op:$660F382A;opt:[not_prefix]);
reg_mem:(op:$660F382A;opt:[not_os8,not_prefix]);
reg_imm:(opt:[not_impl]);
reg_im8:(opt:[not_impl]);
hint:[his_mov,his_wo,his_align];
@ -334,8 +334,8 @@ end;
const
movl_ps_pd_desc:t_op_desc=(
mem_reg:(op:$0F13;opt:[not_prefix]);
reg_mem:(op:$0F12;opt:[not_prefix]);
mem_reg:(op:$0F13;opt:[not_os8,not_prefix]);
reg_mem:(op:$0F12;opt:[not_os8,not_prefix]);
reg_imm:(opt:[not_impl]);
reg_im8:(opt:[not_impl]);
hint:[his_mov,his_wo];
@ -356,8 +356,8 @@ end;
const
movh_ps_pd_desc:t_op_desc=(
mem_reg:(op:$0F17;opt:[not_prefix]);
reg_mem:(op:$0F16;opt:[not_prefix]);
mem_reg:(op:$0F17;opt:[not_os8,not_prefix]);
reg_mem:(op:$0F16;opt:[not_os8,not_prefix]);
reg_imm:(opt:[not_impl]);
reg_im8:(opt:[not_impl]);
hint:[his_mov,his_wo];
@ -379,7 +379,7 @@ end;
const
ldmxcsr_desc:t_op_type=(
op:$0FAE;index:2;opt:[not_prefix];
op:$0FAE;index:2;opt:[not_os8,not_prefix];
);
procedure op_ldmxcsr(var ctx:t_jit_context2);
@ -389,7 +389,7 @@ end;
const
stmxcsr_desc:t_op_type=(
op:$0FAE;index:3;opt:[not_prefix];
op:$0FAE;index:3;opt:[not_os8,not_prefix];
);
procedure op_stmxcsr(var ctx:t_jit_context2);

View File

@ -137,6 +137,9 @@ begin
td^.td_frame.tf_rip:=tf_addr;
end;
Writeln('tf_tsp:0x',HexStr(td^.td_frame.tf_rsp,16));
Writeln('tf_tbp:0x',HexStr(td^.td_frame.tf_rbp,16));
print_backtrace_td(stderr);
td^.td_frame.tf_trapno:=0;