mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-05-15 10:10:21 +02:00
Implement new synthesized IR codes sequences
* lib/jit_rewind.c: New file implementing generic functions to "rewind", or rewrite IR code sequences. * include/lightning.h: Add several new codes, that previously were a function call, that would synthesize the operation. Now, there is a code for the operation, and a new flag to know an operation is synthesized. * include/lightning/jit_private.h: Add several new macros to help construct synthesized IR code sequences. * lib/Makefile.am: Update for lib/jit_rewind.c. * lib/jit_disasm.c: Update for a small rework on jit_node_t, so that --enable-devel-disassembler does not need a change in the layout of jit_node_t. * lib/jit_names.c: Update for the new codes. * lib/jit_print.c: Update to print more readable output, and flag synthesized IR code sequences. * lib/jit_aarch64-sz.c, lib/jit_aarch64.c, lib/jit_arm-sz.c, lib/jit_arm.c, lib/jit_x86-sz.c, lib/jit_x86.c: Update for new synthesized IR code sequences. * lib/jit_ppc-cpu.c, lib/jit_ppc-fpu., lib/jit_ppc-sz.c, lib/jit_ppc.c, lib/jit_mips-cpu.c, lib/jit_mips-fpu.c, lib/jit_mips-sz.c, lib/jit_mips.c, lib/jit_s390-fpu.c, lib/jit_s390-sz.c, lib/jit_s390.c: Update for new synthesized IR code sequences and correct bugs in the initial varargs implementation support. * lib/jit_alpha-sz.c, lib/jit_alpha.c, lib/jit_hppa-sz.c, lib/jit_hppa.c, lib/jit_ia64-sz.c, lib/jit_ia64.c, lib/jit_sparc-sz.c, lib/jit_sparc.c: Add generic, untested support for the new synthesized IR code sequences. Known most likely broken right now, and should be corrected once access to these hosts is available. * lib/lightning.c: Update for new IR codes, and add support for not yet existing instructions that change third argument. * size.c: Change to use different tables for LE and BE PowerPC. Correct a wrong endif for x32.
This commit is contained in:
parent
7f1e0dfb34
commit
d0a5bd8d3d
35 changed files with 4397 additions and 1152 deletions
240
lib/jit_x86.c
240
lib/jit_x86.c
|
@ -423,6 +423,10 @@ _jit_prolog(jit_state_t *_jit)
|
|||
jit_alloc((jit_pointer_t *)&_jitc->function->regoff,
|
||||
_jitc->reglen * sizeof(jit_int32_t));
|
||||
|
||||
/* _no_link here does not mean the jit_link() call can be removed
|
||||
* by rewriting as:
|
||||
* _jitc->function->prolog = jit_new_node(jit_code_prolog);
|
||||
*/
|
||||
_jitc->function->prolog = jit_new_node_no_link(jit_code_prolog);
|
||||
jit_link(_jitc->function->prolog);
|
||||
_jitc->function->prolog->w.w = offset;
|
||||
|
@ -447,6 +451,18 @@ _jit_allocai(jit_state_t *_jit, jit_int32_t length)
|
|||
default: _jitc->function->self.aoff &= -8; break;
|
||||
}
|
||||
_jitc->function->self.aoff -= length;
|
||||
|
||||
/* jit_allocai() may be called from jit_x86-cpu.c, and force a function
|
||||
* generation restart on some conditions: div/rem and qmul/qdiv, due
|
||||
* to registers constraints.
|
||||
* The check is to prevent an assertion of a jit_xyz() being called
|
||||
* during code generation, and attempting to add a node to the tail
|
||||
* of the current IR generation. */
|
||||
if (!_jitc->realize) {
|
||||
jit_inc_synth_ww(allocai, _jitc->function->self.aoff, length);
|
||||
jit_dec_synth();
|
||||
}
|
||||
|
||||
return (_jitc->function->self.aoff);
|
||||
}
|
||||
|
||||
|
@ -455,6 +471,7 @@ _jit_allocar(jit_state_t *_jit, jit_int32_t u, jit_int32_t v)
|
|||
{
|
||||
jit_int32_t reg;
|
||||
assert(_jitc->function);
|
||||
jit_inc_synth_ww(allocar, u, v);
|
||||
if (!_jitc->function->allocar) {
|
||||
_jitc->function->aoffoff = jit_allocai(sizeof(jit_int32_t));
|
||||
_jitc->function->allocar = 1;
|
||||
|
@ -467,23 +484,25 @@ _jit_allocar(jit_state_t *_jit, jit_int32_t u, jit_int32_t v)
|
|||
jit_addr(JIT_SP, JIT_SP, reg);
|
||||
jit_stxi_i(_jitc->function->aoffoff, JIT_FP, u);
|
||||
jit_unget_reg(reg);
|
||||
jit_dec_synth();
|
||||
}
|
||||
|
||||
void
|
||||
_jit_ret(jit_state_t *_jit)
|
||||
{
|
||||
jit_node_t *instr;
|
||||
|
||||
assert(_jitc->function);
|
||||
|
||||
jit_inc_synth(ret);
|
||||
/* jump to epilog */
|
||||
instr = jit_jmpi();
|
||||
jit_patch_at(instr, _jitc->function->epilog);
|
||||
jit_dec_synth();
|
||||
}
|
||||
|
||||
void
|
||||
_jit_retr(jit_state_t *_jit, jit_int32_t u)
|
||||
{
|
||||
jit_inc_synth_w(retr, u);
|
||||
/* movr(%ret, %ret) would be optimized out */
|
||||
if (JIT_RET != u)
|
||||
jit_movr(JIT_RET, u);
|
||||
|
@ -491,47 +510,58 @@ _jit_retr(jit_state_t *_jit, jit_int32_t u)
|
|||
else
|
||||
jit_live(JIT_RET);
|
||||
jit_ret();
|
||||
jit_dec_synth();
|
||||
}
|
||||
|
||||
void
|
||||
_jit_reti(jit_state_t *_jit, jit_word_t u)
|
||||
{
|
||||
jit_inc_synth_w(reti, u);
|
||||
jit_movi(JIT_RET, u);
|
||||
jit_ret();
|
||||
jit_dec_synth();
|
||||
}
|
||||
|
||||
void
|
||||
_jit_retr_f(jit_state_t *_jit, jit_int32_t u)
|
||||
{
|
||||
jit_inc_synth_w(retr_f, u);
|
||||
if (JIT_FRET != u)
|
||||
jit_movr_f(JIT_FRET, u);
|
||||
else
|
||||
jit_live(JIT_FRET);
|
||||
jit_ret();
|
||||
jit_dec_synth();
|
||||
}
|
||||
|
||||
void
|
||||
_jit_reti_f(jit_state_t *_jit, jit_float32_t u)
|
||||
{
|
||||
jit_inc_synth_f(reti_f, u);
|
||||
jit_movi_f(JIT_FRET, u);
|
||||
jit_ret();
|
||||
jit_dec_synth();
|
||||
}
|
||||
|
||||
void
|
||||
_jit_retr_d(jit_state_t *_jit, jit_int32_t u)
|
||||
{
|
||||
jit_inc_synth_w(retr_d, u);
|
||||
if (JIT_FRET != u)
|
||||
jit_movr_d(JIT_FRET, u);
|
||||
else
|
||||
jit_live(JIT_FRET);
|
||||
jit_ret();
|
||||
jit_dec_synth();
|
||||
}
|
||||
|
||||
void
|
||||
_jit_reti_d(jit_state_t *_jit, jit_float64_t u)
|
||||
{
|
||||
jit_inc_synth_d(reti_d, u);
|
||||
jit_movi_d(JIT_FRET, u);
|
||||
jit_ret();
|
||||
jit_dec_synth();
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -555,12 +585,15 @@ _jit_arg_register_p(jit_state_t *_jit, jit_node_t *u)
|
|||
void
|
||||
_jit_ellipsis(jit_state_t *_jit)
|
||||
{
|
||||
jit_inc_synth(ellipsis);
|
||||
if (_jitc->prepare) {
|
||||
jit_link_prepare();
|
||||
/* Remember that a varargs function call is being constructed. */
|
||||
assert(!(_jitc->function->call.call & jit_call_varargs));
|
||||
_jitc->function->call.call |= jit_call_varargs;
|
||||
}
|
||||
else {
|
||||
jit_link_prolog();
|
||||
/* Remember the current function is varargs. */
|
||||
assert(!(_jitc->function->self.call & jit_call_varargs));
|
||||
_jitc->function->self.call |= jit_call_varargs;
|
||||
|
@ -585,13 +618,14 @@ _jit_ellipsis(jit_state_t *_jit)
|
|||
_jitc->function->vafp = va_fp_max_offset;
|
||||
#endif
|
||||
}
|
||||
jit_dec_synth();
|
||||
}
|
||||
|
||||
jit_node_t *
|
||||
_jit_arg(jit_state_t *_jit)
|
||||
{
|
||||
jit_int32_t offset;
|
||||
|
||||
jit_node_t *node;
|
||||
jit_int32_t offset;
|
||||
assert(_jitc->function);
|
||||
assert(!(_jitc->function->self.call & jit_call_varargs));
|
||||
#if __X64
|
||||
|
@ -607,14 +641,17 @@ _jit_arg(jit_state_t *_jit)
|
|||
offset = _jitc->function->self.size;
|
||||
_jitc->function->self.size += REAL_WORDSIZE;
|
||||
}
|
||||
return (jit_new_node_w(jit_code_arg, offset));
|
||||
node = jit_new_node_ww(jit_code_arg, offset,
|
||||
++_jitc->function->self.argn);
|
||||
jit_link_prolog();
|
||||
return (node);
|
||||
}
|
||||
|
||||
jit_node_t *
|
||||
_jit_arg_f(jit_state_t *_jit)
|
||||
{
|
||||
jit_int32_t offset;
|
||||
|
||||
jit_node_t *node;
|
||||
jit_int32_t offset;
|
||||
assert(_jitc->function);
|
||||
assert(!(_jitc->function->self.call & jit_call_varargs));
|
||||
#if __X64
|
||||
|
@ -633,14 +670,17 @@ _jit_arg_f(jit_state_t *_jit)
|
|||
offset = _jitc->function->self.size;
|
||||
_jitc->function->self.size += REAL_WORDSIZE;
|
||||
}
|
||||
return (jit_new_node_w(jit_code_arg_f, offset));
|
||||
node = jit_new_node_ww(jit_code_arg_f, offset,
|
||||
++_jitc->function->self.argn);
|
||||
jit_link_prolog();
|
||||
return (node);
|
||||
}
|
||||
|
||||
jit_node_t *
|
||||
_jit_arg_d(jit_state_t *_jit)
|
||||
{
|
||||
jit_int32_t offset;
|
||||
|
||||
jit_node_t *node;
|
||||
jit_int32_t offset;
|
||||
assert(_jitc->function);
|
||||
assert(!(_jitc->function->self.call & jit_call_varargs));
|
||||
#if __X64
|
||||
|
@ -659,61 +699,73 @@ _jit_arg_d(jit_state_t *_jit)
|
|||
offset = _jitc->function->self.size;
|
||||
_jitc->function->self.size += sizeof(jit_float64_t);
|
||||
}
|
||||
return (jit_new_node_w(jit_code_arg_d, offset));
|
||||
node = jit_new_node_ww(jit_code_arg_d, offset,
|
||||
++_jitc->function->self.argn);
|
||||
jit_link_prolog();
|
||||
return (node);
|
||||
}
|
||||
|
||||
void
|
||||
_jit_getarg_c(jit_state_t *_jit, jit_int32_t u, jit_node_t *v)
|
||||
{
|
||||
assert(v->code == jit_code_arg);
|
||||
jit_inc_synth_wp(getarg_c, u, v);
|
||||
#if __X64
|
||||
if (jit_arg_reg_p(v->u.w))
|
||||
jit_extr_c(u, JIT_RA0 - v->u.w);
|
||||
else
|
||||
#endif
|
||||
jit_ldxi_c(u, _RBP, v->u.w);
|
||||
jit_dec_synth();
|
||||
}
|
||||
|
||||
void
|
||||
_jit_getarg_uc(jit_state_t *_jit, jit_int32_t u, jit_node_t *v)
|
||||
{
|
||||
assert(v->code == jit_code_arg);
|
||||
jit_inc_synth_wp(getarg_uc, u, v);
|
||||
#if __X64
|
||||
if (jit_arg_reg_p(v->u.w))
|
||||
jit_extr_uc(u, JIT_RA0 - v->u.w);
|
||||
else
|
||||
#endif
|
||||
jit_ldxi_uc(u, _RBP, v->u.w);
|
||||
jit_dec_synth();
|
||||
}
|
||||
|
||||
void
|
||||
_jit_getarg_s(jit_state_t *_jit, jit_int32_t u, jit_node_t *v)
|
||||
{
|
||||
assert(v->code == jit_code_arg);
|
||||
jit_inc_synth_wp(getarg_s, u, v);
|
||||
#if __X64
|
||||
if (jit_arg_reg_p(v->u.w))
|
||||
jit_extr_s(u, JIT_RA0 - v->u.w);
|
||||
else
|
||||
#endif
|
||||
jit_ldxi_s(u, _RBP, v->u.w);
|
||||
jit_dec_synth();
|
||||
}
|
||||
|
||||
void
|
||||
_jit_getarg_us(jit_state_t *_jit, jit_int32_t u, jit_node_t *v)
|
||||
{
|
||||
assert(v->code == jit_code_arg);
|
||||
jit_inc_synth_wp(getarg_us, u, v);
|
||||
#if __X64
|
||||
if (jit_arg_reg_p(v->u.w))
|
||||
jit_extr_us(u, JIT_RA0 - v->u.w);
|
||||
else
|
||||
#endif
|
||||
jit_ldxi_us(u, _RBP, v->u.w);
|
||||
jit_dec_synth();
|
||||
}
|
||||
|
||||
void
|
||||
_jit_getarg_i(jit_state_t *_jit, jit_int32_t u, jit_node_t *v)
|
||||
{
|
||||
assert(v->code == jit_code_arg);
|
||||
jit_inc_synth_wp(getarg_i, u, v);
|
||||
#if __X64
|
||||
if (jit_arg_reg_p(v->u.w)) {
|
||||
# if __X64_32
|
||||
|
@ -725,6 +777,7 @@ _jit_getarg_i(jit_state_t *_jit, jit_int32_t u, jit_node_t *v)
|
|||
else
|
||||
#endif
|
||||
jit_ldxi_i(u, _RBP, v->u.w);
|
||||
jit_dec_synth();
|
||||
}
|
||||
|
||||
#if __X64 && !__X64_32
|
||||
|
@ -732,20 +785,24 @@ void
|
|||
_jit_getarg_ui(jit_state_t *_jit, jit_int32_t u, jit_node_t *v)
|
||||
{
|
||||
assert(v->code == jit_code_arg);
|
||||
jit_inc_synth_wp(getarg_ui, u, v);
|
||||
if (jit_arg_reg_p(v->u.w))
|
||||
jit_extr_ui(u, JIT_RA0 - v->u.w);
|
||||
else
|
||||
jit_ldxi_ui(u, _RBP, v->u.w);
|
||||
jit_dec_synth();
|
||||
}
|
||||
|
||||
void
|
||||
_jit_getarg_l(jit_state_t *_jit, jit_int32_t u, jit_node_t *v)
|
||||
{
|
||||
assert(v->code == jit_code_arg);
|
||||
jit_inc_synth_wp(getarg_l, u, v);
|
||||
if (jit_arg_reg_p(v->u.w))
|
||||
jit_movr(u, JIT_RA0 - v->u.w);
|
||||
else
|
||||
jit_ldxi_l(u, _RBP, v->u.w);
|
||||
jit_dec_synth();
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -753,12 +810,14 @@ void
|
|||
_jit_putargr(jit_state_t *_jit, jit_int32_t u, jit_node_t *v)
|
||||
{
|
||||
assert(v->code == jit_code_arg);
|
||||
jit_inc_synth_wp(putargr, u, v);
|
||||
#if __X64
|
||||
if (jit_arg_reg_p(v->u.w))
|
||||
jit_movr(JIT_RA0 - v->u.w, u);
|
||||
else
|
||||
#endif
|
||||
jit_stxi(v->u.w, _RBP, u);
|
||||
jit_dec_synth();
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -766,6 +825,7 @@ _jit_putargi(jit_state_t *_jit, jit_word_t u, jit_node_t *v)
|
|||
{
|
||||
jit_int32_t regno;
|
||||
assert(v->code == jit_code_arg);
|
||||
jit_inc_synth_wp(putargi, u, v);
|
||||
#if __X64
|
||||
if (jit_arg_reg_p(v->u.w))
|
||||
jit_movi(JIT_RA0 - v->u.w, u);
|
||||
|
@ -777,30 +837,35 @@ _jit_putargi(jit_state_t *_jit, jit_word_t u, jit_node_t *v)
|
|||
jit_stxi(v->u.w, _RBP, regno);
|
||||
jit_unget_reg(regno);
|
||||
}
|
||||
jit_dec_synth();
|
||||
}
|
||||
|
||||
void
|
||||
_jit_getarg_f(jit_state_t *_jit, jit_int32_t u, jit_node_t *v)
|
||||
{
|
||||
assert(v->code == jit_code_arg_f);
|
||||
jit_inc_synth_wp(getarg_f, u, v);
|
||||
#if __X64
|
||||
if (jit_arg_f_reg_p(v->u.w))
|
||||
jit_movr_f(u, _XMM0 - v->u.w);
|
||||
else
|
||||
#endif
|
||||
jit_ldxi_f(u, _RBP, v->u.w);
|
||||
jit_dec_synth();
|
||||
}
|
||||
|
||||
void
|
||||
_jit_putargr_f(jit_state_t *_jit, jit_int32_t u, jit_node_t *v)
|
||||
{
|
||||
assert(v->code == jit_code_arg_f);
|
||||
jit_inc_synth_wp(putargr_f, u, v);
|
||||
#if __X64
|
||||
if (jit_arg_reg_p(v->u.w))
|
||||
jit_movr_f(_XMM0 - v->u.w, u);
|
||||
else
|
||||
#endif
|
||||
jit_stxi_f(v->u.w, _RBP, u);
|
||||
jit_dec_synth();
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -808,6 +873,7 @@ _jit_putargi_f(jit_state_t *_jit, jit_float32_t u, jit_node_t *v)
|
|||
{
|
||||
jit_int32_t regno;
|
||||
assert(v->code == jit_code_arg_f);
|
||||
jit_inc_synth_fp(putargi_f, u, v);
|
||||
#if __X64
|
||||
if (jit_arg_reg_p(v->u.w))
|
||||
jit_movi_f(_XMM0 - v->u.w, u);
|
||||
|
@ -819,30 +885,35 @@ _jit_putargi_f(jit_state_t *_jit, jit_float32_t u, jit_node_t *v)
|
|||
jit_stxi_f(v->u.w, _RBP, regno);
|
||||
jit_unget_reg(regno);
|
||||
}
|
||||
jit_dec_synth();
|
||||
}
|
||||
|
||||
void
|
||||
_jit_getarg_d(jit_state_t *_jit, jit_int32_t u, jit_node_t *v)
|
||||
{
|
||||
assert(v->code == jit_code_arg_d);
|
||||
jit_inc_synth_wp(getarg_d, u, v);
|
||||
#if __X64
|
||||
if (jit_arg_f_reg_p(v->u.w))
|
||||
jit_movr_d(u, _XMM0 - v->u.w);
|
||||
else
|
||||
#endif
|
||||
jit_ldxi_d(u, _RBP, v->u.w);
|
||||
jit_dec_synth();
|
||||
}
|
||||
|
||||
void
|
||||
_jit_putargr_d(jit_state_t *_jit, jit_int32_t u, jit_node_t *v)
|
||||
{
|
||||
assert(v->code == jit_code_arg_d);
|
||||
jit_inc_synth_wp(putargr_d, u, v);
|
||||
#if __X64
|
||||
if (jit_arg_reg_p(v->u.w))
|
||||
jit_movr_d(_XMM0 - v->u.w, u);
|
||||
else
|
||||
#endif
|
||||
jit_stxi_d(v->u.w, _RBP, u);
|
||||
jit_dec_synth();
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -850,6 +921,7 @@ _jit_putargi_d(jit_state_t *_jit, jit_float64_t u, jit_node_t *v)
|
|||
{
|
||||
jit_int32_t regno;
|
||||
assert(v->code == jit_code_arg_d);
|
||||
jit_inc_synth_dp(putargi_d, u, v);
|
||||
#if __X64
|
||||
if (jit_arg_reg_p(v->u.w))
|
||||
jit_movi_d(_XMM0 - v->u.w, u);
|
||||
|
@ -861,12 +933,15 @@ _jit_putargi_d(jit_state_t *_jit, jit_float64_t u, jit_node_t *v)
|
|||
jit_stxi_d(v->u.w, _RBP, regno);
|
||||
jit_unget_reg(regno);
|
||||
}
|
||||
jit_dec_synth();
|
||||
}
|
||||
|
||||
void
|
||||
_jit_pushargr(jit_state_t *_jit, jit_int32_t u)
|
||||
{
|
||||
assert(_jitc->function);
|
||||
jit_inc_synth_w(pushargr, u);
|
||||
jit_link_prepare();
|
||||
#if __X64
|
||||
if (jit_arg_reg_p(_jitc->function->call.argi)) {
|
||||
jit_movr(JIT_RA0 - _jitc->function->call.argi, u);
|
||||
|
@ -883,14 +958,16 @@ _jit_pushargr(jit_state_t *_jit, jit_int32_t u)
|
|||
jit_stxi(_jitc->function->call.size, _RSP, u);
|
||||
_jitc->function->call.size += REAL_WORDSIZE;
|
||||
}
|
||||
jit_dec_synth();
|
||||
}
|
||||
|
||||
void
|
||||
_jit_pushargi(jit_state_t *_jit, jit_word_t u)
|
||||
{
|
||||
jit_int32_t regno;
|
||||
|
||||
assert(_jitc->function);
|
||||
jit_inc_synth_w(pushargi, u);
|
||||
jit_link_prepare();
|
||||
#if __X64
|
||||
if (jit_arg_reg_p(_jitc->function->call.argi)) {
|
||||
jit_movi(JIT_RA0 - _jitc->function->call.argi, u);
|
||||
|
@ -911,12 +988,15 @@ _jit_pushargi(jit_state_t *_jit, jit_word_t u)
|
|||
_jitc->function->call.size += REAL_WORDSIZE;
|
||||
jit_unget_reg(regno);
|
||||
}
|
||||
jit_dec_synth();
|
||||
}
|
||||
|
||||
void
|
||||
_jit_pushargr_f(jit_state_t *_jit, jit_int32_t u)
|
||||
{
|
||||
assert(_jitc->function);
|
||||
jit_inc_synth_w(pushargr_f, u);
|
||||
jit_link_prepare();
|
||||
#if __X64
|
||||
# if __CYGWIN__
|
||||
if (jit_arg_reg_p(_jitc->function->call.argi)) {
|
||||
|
@ -942,14 +1022,16 @@ _jit_pushargr_f(jit_state_t *_jit, jit_int32_t u)
|
|||
jit_stxi_f(_jitc->function->call.size, _RSP, u);
|
||||
_jitc->function->call.size += REAL_WORDSIZE;
|
||||
}
|
||||
jit_dec_synth();
|
||||
}
|
||||
|
||||
void
|
||||
_jit_pushargi_f(jit_state_t *_jit, jit_float32_t u)
|
||||
{
|
||||
jit_int32_t regno;
|
||||
|
||||
assert(_jitc->function);
|
||||
jit_inc_synth_f(pushargi_f, u);
|
||||
jit_link_prepare();
|
||||
#if __X64
|
||||
# if __CYGWIN__
|
||||
if (jit_arg_reg_p(_jitc->function->call.argi)) {
|
||||
|
@ -978,12 +1060,15 @@ _jit_pushargi_f(jit_state_t *_jit, jit_float32_t u)
|
|||
_jitc->function->call.size += REAL_WORDSIZE;
|
||||
jit_unget_reg(regno);
|
||||
}
|
||||
jit_dec_synth();
|
||||
}
|
||||
|
||||
void
|
||||
_jit_pushargr_d(jit_state_t *_jit, jit_int32_t u)
|
||||
{
|
||||
assert(_jitc->function);
|
||||
jit_inc_synth_w(pushargr_d, u);
|
||||
jit_link_prepare();
|
||||
#if __X64
|
||||
# if __CYGWIN__
|
||||
if (jit_arg_reg_p(_jitc->function->call.argi)) {
|
||||
|
@ -1009,14 +1094,16 @@ _jit_pushargr_d(jit_state_t *_jit, jit_int32_t u)
|
|||
jit_stxi_d(_jitc->function->call.size, _RSP, u);
|
||||
_jitc->function->call.size += sizeof(jit_float64_t);
|
||||
}
|
||||
jit_dec_synth();
|
||||
}
|
||||
|
||||
void
|
||||
_jit_pushargi_d(jit_state_t *_jit, jit_float64_t u)
|
||||
{
|
||||
jit_int32_t regno;
|
||||
|
||||
assert(_jitc->function);
|
||||
jit_inc_synth_d(pushargi_d, u);
|
||||
jit_link_prepare();
|
||||
#if __X64
|
||||
# if __CYGWIN__
|
||||
if (jit_arg_reg_p(_jitc->function->call.argi)) {
|
||||
|
@ -1045,6 +1132,7 @@ _jit_pushargi_d(jit_state_t *_jit, jit_float64_t u)
|
|||
_jitc->function->call.size += sizeof(jit_float64_t);
|
||||
jit_unget_reg(regno);
|
||||
}
|
||||
jit_dec_synth();
|
||||
}
|
||||
|
||||
jit_bool_t
|
||||
|
@ -1075,9 +1163,9 @@ _jit_finishr(jit_state_t *_jit, jit_int32_t r0)
|
|||
{
|
||||
jit_int32_t reg;
|
||||
jit_node_t *call;
|
||||
|
||||
reg = r0;
|
||||
assert(_jitc->function);
|
||||
reg = r0;
|
||||
jit_inc_synth_w(finishr, r0);
|
||||
if (_jitc->function->self.alen < _jitc->function->call.size)
|
||||
_jitc->function->self.alen = _jitc->function->call.size;
|
||||
#if __X64
|
||||
|
@ -1102,6 +1190,7 @@ _jit_finishr(jit_state_t *_jit, jit_int32_t r0)
|
|||
_jitc->function->call.argi = _jitc->function->call.argf =
|
||||
_jitc->function->call.size = 0;
|
||||
_jitc->prepare = 0;
|
||||
jit_dec_synth();
|
||||
}
|
||||
|
||||
jit_node_t *
|
||||
|
@ -1111,8 +1200,8 @@ _jit_finishi(jit_state_t *_jit, jit_pointer_t i0)
|
|||
jit_int32_t reg;
|
||||
#endif
|
||||
jit_node_t *node;
|
||||
|
||||
assert(_jitc->function);
|
||||
jit_inc_synth_w(finishi, (jit_word_t)i0);
|
||||
if (_jitc->function->self.alen < _jitc->function->call.size)
|
||||
_jitc->function->self.alen = _jitc->function->call.size;
|
||||
#if __X64
|
||||
|
@ -1136,79 +1225,94 @@ _jit_finishi(jit_state_t *_jit, jit_pointer_t i0)
|
|||
_jitc->function->call.argi = _jitc->function->call.argf =
|
||||
_jitc->function->call.size = 0;
|
||||
_jitc->prepare = 0;
|
||||
jit_dec_synth();
|
||||
return (node);
|
||||
}
|
||||
|
||||
void
|
||||
_jit_retval_c(jit_state_t *_jit, jit_int32_t r0)
|
||||
{
|
||||
jit_inc_synth_w(retval_c, r0);
|
||||
jit_extr_c(r0, JIT_RET);
|
||||
jit_dec_synth();
|
||||
}
|
||||
|
||||
void
|
||||
_jit_retval_uc(jit_state_t *_jit, jit_int32_t r0)
|
||||
{
|
||||
jit_inc_synth_w(retval_uc, r0);
|
||||
jit_extr_uc(r0, JIT_RET);
|
||||
jit_dec_synth();
|
||||
}
|
||||
|
||||
void
|
||||
_jit_retval_s(jit_state_t *_jit, jit_int32_t r0)
|
||||
{
|
||||
jit_inc_synth_w(retval_s, r0);
|
||||
jit_extr_s(r0, JIT_RET);
|
||||
jit_dec_synth();
|
||||
}
|
||||
|
||||
void
|
||||
_jit_retval_us(jit_state_t *_jit, jit_int32_t r0)
|
||||
{
|
||||
jit_inc_synth_w(retval_us, r0);
|
||||
jit_extr_us(r0, JIT_RET);
|
||||
jit_dec_synth();
|
||||
}
|
||||
|
||||
void
|
||||
_jit_retval_i(jit_state_t *_jit, jit_int32_t r0)
|
||||
{
|
||||
jit_inc_synth_w(retval_i, r0);
|
||||
#if __X32 || __X64_32
|
||||
if (r0 != JIT_RET)
|
||||
jit_movr(r0, JIT_RET);
|
||||
#else
|
||||
jit_extr_i(r0, JIT_RET);
|
||||
#endif
|
||||
jit_dec_synth();
|
||||
}
|
||||
|
||||
#if __X64 && !__X64_32
|
||||
void
|
||||
_jit_retval_ui(jit_state_t *_jit, jit_int32_t r0)
|
||||
{
|
||||
jit_inc_synth_w(retval_ui, r0);
|
||||
jit_extr_ui(r0, JIT_RET);
|
||||
jit_dec_synth();
|
||||
}
|
||||
|
||||
void
|
||||
_jit_retval_l(jit_state_t *_jit, jit_int32_t r0)
|
||||
{
|
||||
jit_inc_synth_w(retval_l, r0);
|
||||
if (r0 != JIT_RET)
|
||||
jit_movr(r0, JIT_RET);
|
||||
jit_dec_synth();
|
||||
}
|
||||
#endif
|
||||
|
||||
void
|
||||
_jit_retval_f(jit_state_t *_jit, jit_int32_t r0)
|
||||
{
|
||||
# if __X32
|
||||
jit_new_node_w(jit_code_x86_retval_f, r0);
|
||||
# else
|
||||
jit_inc_synth_w(retval_f, r0);
|
||||
#if __X64
|
||||
if (r0 != JIT_FRET)
|
||||
jit_movr_f(r0, JIT_FRET);
|
||||
# endif
|
||||
#endif
|
||||
jit_dec_synth();
|
||||
}
|
||||
|
||||
void
|
||||
_jit_retval_d(jit_state_t *_jit, jit_int32_t r0)
|
||||
{
|
||||
# if __X32
|
||||
jit_new_node_w(jit_code_x86_retval_d, r0);
|
||||
# else
|
||||
jit_inc_synth_w(retval_d, r0);
|
||||
#if __X64
|
||||
if (r0 != JIT_FRET)
|
||||
jit_movr_d(r0, JIT_FRET);
|
||||
# endif
|
||||
#endif
|
||||
jit_dec_synth();
|
||||
}
|
||||
|
||||
jit_pointer_t
|
||||
|
@ -1222,8 +1326,14 @@ _emit_code(jit_state_t *_jit)
|
|||
struct {
|
||||
jit_node_t *node;
|
||||
jit_word_t word;
|
||||
#if DEVEL_DISASSEMBLER
|
||||
jit_word_t prevw;
|
||||
#endif
|
||||
jit_int32_t patch_offset;
|
||||
} undo;
|
||||
#if DEVEL_DISASSEMBLER
|
||||
jit_word_t prevw;
|
||||
#endif
|
||||
|
||||
_jitc->function = NULL;
|
||||
|
||||
|
@ -1461,12 +1571,16 @@ _emit_code(jit_state_t *_jit)
|
|||
patch(word, node); \
|
||||
} \
|
||||
break
|
||||
#if DEVEL_DISASSEMBLER
|
||||
prevw = _jit->pc.w;
|
||||
#endif
|
||||
for (node = _jitc->head; node; node = node->next) {
|
||||
if (_jit->pc.uc >= _jitc->code.end)
|
||||
return (NULL);
|
||||
|
||||
#if DEVEL_DISASSEMBLER
|
||||
node->offset = _jit->pc.w;
|
||||
node->offset = (jit_uword_t)_jit->pc.w - (jit_uword_t)prevw;
|
||||
prevw = _jit->pc.w;
|
||||
#endif
|
||||
value = jit_classify(node->code);
|
||||
jit_regarg_set(node, value);
|
||||
|
@ -1917,6 +2031,9 @@ _emit_code(jit_state_t *_jit)
|
|||
_jitc->function = _jitc->functions.ptr + node->w.w;
|
||||
undo.node = node;
|
||||
undo.word = _jit->pc.w;
|
||||
#if DEVEL_DISASSEMBLER
|
||||
undo.prevw = prevw;
|
||||
#endif
|
||||
undo.patch_offset = _jitc->patches.offset;
|
||||
restart_function:
|
||||
_jitc->again = 0;
|
||||
|
@ -1934,6 +2051,9 @@ _emit_code(jit_state_t *_jit)
|
|||
temp->flag &= ~jit_flag_patch;
|
||||
node = undo.node;
|
||||
_jit->pc.w = undo.word;
|
||||
#if DEVEL_DISASSEMBLER
|
||||
prevw = undo.prevw;
|
||||
#endif
|
||||
_jitc->patches.offset = undo.patch_offset;
|
||||
goto restart_function;
|
||||
}
|
||||
|
@ -1946,24 +2066,6 @@ _emit_code(jit_state_t *_jit)
|
|||
epilog(node);
|
||||
_jitc->function = NULL;
|
||||
break;
|
||||
#if __X32
|
||||
case jit_code_x86_retval_f:
|
||||
if (jit_sse_reg_p(node->u.w)) {
|
||||
fstpr(_ST1_REGNO);
|
||||
sse_from_x87_f(rn(node->u.w), _ST0_REGNO);
|
||||
}
|
||||
else
|
||||
fstpr(rn(node->u.w) + 1);
|
||||
break;
|
||||
case jit_code_x86_retval_d:
|
||||
if (jit_sse_reg_p(node->u.w)) {
|
||||
fstpr(_ST1_REGNO);
|
||||
sse_from_x87_d(rn(node->u.w), _ST0_REGNO);
|
||||
}
|
||||
else
|
||||
fstpr(rn(node->u.w) + 1);
|
||||
break;
|
||||
#endif
|
||||
case jit_code_va_start:
|
||||
vastart(rn(node->u.w));
|
||||
break;
|
||||
|
@ -1973,16 +2075,62 @@ _emit_code(jit_state_t *_jit)
|
|||
case jit_code_va_arg_d:
|
||||
vaarg_d(rn(node->u.w), rn(node->v.w), jit_x87_reg_p(node->u.w));
|
||||
break;
|
||||
case jit_code_live:
|
||||
case jit_code_live: case jit_code_ellipsis:
|
||||
case jit_code_allocai: case jit_code_allocar:
|
||||
case jit_code_arg:
|
||||
case jit_code_arg_f: case jit_code_arg_d:
|
||||
case jit_code_va_end:
|
||||
case jit_code_ret:
|
||||
case jit_code_retr: case jit_code_reti:
|
||||
case jit_code_retr_f: case jit_code_reti_f:
|
||||
case jit_code_retr_d: case jit_code_reti_d:
|
||||
case jit_code_getarg_c: case jit_code_getarg_uc:
|
||||
case jit_code_getarg_s: case jit_code_getarg_us:
|
||||
case jit_code_getarg_i:
|
||||
#if __X64 && !__X64_32
|
||||
case jit_code_getarg_ui: case jit_code_getarg_l:
|
||||
#endif
|
||||
case jit_code_getarg_f: case jit_code_getarg_d:
|
||||
case jit_code_putargr: case jit_code_putargi:
|
||||
case jit_code_putargr_f: case jit_code_putargi_f:
|
||||
case jit_code_putargr_d: case jit_code_putargi_d:
|
||||
case jit_code_pushargr: case jit_code_pushargi:
|
||||
case jit_code_pushargr_f: case jit_code_pushargi_f:
|
||||
case jit_code_pushargr_d: case jit_code_pushargi_d:
|
||||
case jit_code_retval_c: case jit_code_retval_uc:
|
||||
case jit_code_retval_s: case jit_code_retval_us:
|
||||
case jit_code_retval_i:
|
||||
#if __X64 && !__X32
|
||||
case jit_code_retval_ui: case jit_code_retval_l:
|
||||
#endif
|
||||
case jit_code_prepare:
|
||||
case jit_code_finishr: case jit_code_finishi:
|
||||
break;
|
||||
case jit_code_retval_f:
|
||||
#if __X32
|
||||
if (jit_sse_reg_p(node->u.w)) {
|
||||
fstpr(_ST1_REGNO);
|
||||
sse_from_x87_f(rn(node->u.w), _ST0_REGNO);
|
||||
}
|
||||
else
|
||||
fstpr(rn(node->u.w) + 1);
|
||||
#endif
|
||||
break;
|
||||
case jit_code_retval_d:
|
||||
#if __X32
|
||||
if (jit_sse_reg_p(node->u.w)) {
|
||||
fstpr(_ST1_REGNO);
|
||||
sse_from_x87_d(rn(node->u.w), _ST0_REGNO);
|
||||
}
|
||||
else
|
||||
fstpr(rn(node->u.w) + 1);
|
||||
#endif
|
||||
break;
|
||||
default:
|
||||
abort();
|
||||
}
|
||||
jit_regarg_clr(node, value);
|
||||
assert(_jitc->regarg == 0);
|
||||
assert(_jitc->regarg == 0 && _jitc->synth == 0);
|
||||
/* update register live state */
|
||||
jit_reglive(node);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue