1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-05-18 18:40:22 +02:00

Build and pass all test cases on Alpha Linux

* check/lightning.c, include/lightning.h: Add the new jit_va_push
	interface. That should be called when passing a va_list to a C
	function. This is required because on Alpha a va_list is passed
	by value, and lightning does not know about data types, so, cannot
	understand it is pushing a va_list as argument.

	* lib/jit_names.c, lib/lightning.c: Minor changes for the new
	jit_code_va_push.

	* check/cva_list.c: Update only test case using jit_va_push, to
	pass a va_list to a C function.

	doc/body.texi: Better documentation of the varargs interface.

	* jit_alpha.c, jit_alpha-cpu.c: Update to properly push a
	C va_list and correctly calculate varargs offset.

	* lib/jit_aarch64-sz.c, lib/jit_aarch64.c, lib/jit_alpha-sz.c,
	lib/jit_arm-sz.c, lib/jit_arm.c, lib/jit_hppa-sz.c, lib/jit_hppa.c,
	lib/jit_ia64-sz.c, lib/jit_ia64.c, lib/jit_mips-sz.c, lib/jit_mips.c,
	lib/jit_ppc-sz.c, lib/jit_ppc.c, lib/jit_s390-sz.c, lib/jit_s390.c,
	lib/jit_sparc-sz.c, lib/jit_sparc.c, lib/jit_x86-sz.c, lib/jit_x86.c:
	Update for the new jit_va_push interface.
This commit is contained in:
Paulo Andrade 2018-02-26 09:48:50 -03:00
parent b64b82ca51
commit ed5589ce59
28 changed files with 186 additions and 21 deletions

View file

@ -1,3 +1,29 @@
2018-02-26 Paulo Andrade <pcpa@gnu.org>
* check/lightning.c, include/lightning.h: Add the new jit_va_push
interface. That should be called when passing a va_list to a C
function. This is required because on Alpha a va_list is passed
by value, and lightning does not know about data types, so, cannot
understand it is pushing a va_list as argument.
* lib/jit_names.c, lib/lightning.c: Minor changes for the new
jit_code_va_push.
* check/cva_list.c: Update only test case using jit_va_push, to
pass a va_list to a C function.
doc/body.texi: Better documentation of the varargs interface.
* jit_alpha.c, jit_alpha-cpu.c: Update to properly push a
C va_list and correctly calculate varargs offset.
* lib/jit_aarch64-sz.c, lib/jit_aarch64.c, lib/jit_alpha-sz.c,
lib/jit_arm-sz.c, lib/jit_arm.c, lib/jit_hppa-sz.c, lib/jit_hppa.c,
lib/jit_ia64-sz.c, lib/jit_ia64.c, lib/jit_mips-sz.c, lib/jit_mips.c,
lib/jit_ppc-sz.c, lib/jit_ppc.c, lib/jit_s390-sz.c, lib/jit_s390.c,
lib/jit_sparc-sz.c, lib/jit_sparc.c, lib/jit_x86-sz.c, lib/jit_x86.c:
Update for the new jit_va_push interface.
2018-02-22 Paulo Andrade <pcpa@gnu.org>
* lib/jit_alpha-cpu.c: Always set t12 to the address of the

View file

@ -586,7 +586,7 @@ int main(int argc, char *argv[])
jit_va_start(JIT_V0);
jit_prepare();
jit_pushargr(JIT_V1);
jit_pushargr(JIT_V0);
jit_va_push(JIT_V0);
jit_finishi(va_i_iiiiiiiii);
jit_va_end(JIT_V0);
jit_ret();
@ -603,7 +603,7 @@ int main(int argc, char *argv[])
jit_prepare();
jit_pushargr(JIT_V1);
jit_pushargr(JIT_V2);
jit_pushargr(JIT_V0);
jit_va_push(JIT_V0);
jit_finishi(va_ii_iiiiiiii);
jit_va_end(JIT_V0);
jit_ret();
@ -617,7 +617,7 @@ int main(int argc, char *argv[])
jit_va_start(JIT_V0);
jit_prepare();
jit_pushargr_d(JIT_F3);
jit_pushargr(JIT_V0);
jit_va_push(JIT_V0);
jit_finishi(va_d_ddddddddd);
jit_va_end(JIT_V0);
jit_ret();
@ -634,7 +634,7 @@ int main(int argc, char *argv[])
jit_prepare();
jit_pushargr_d(JIT_F3);
jit_pushargr_d(JIT_F4);
jit_pushargr(JIT_V0);
jit_va_push(JIT_V0);
jit_finishi(va_dd_dddddddd);
jit_va_end(JIT_V0);
jit_ret();
@ -648,7 +648,7 @@ int main(int argc, char *argv[])
jit_va_start(JIT_V0);
jit_prepare();
jit_pushargr(JIT_V1);
jit_pushargr(JIT_V0);
jit_va_push(JIT_V0);
jit_finishi(va_i_didididid);
jit_va_end(JIT_V0);
jit_ret();
@ -665,7 +665,7 @@ int main(int argc, char *argv[])
jit_prepare();
jit_pushargr(JIT_V1);
jit_pushargr_d(JIT_F3);
jit_pushargr(JIT_V0);
jit_va_push(JIT_V0);
jit_finishi(va_id_idididid);
jit_va_end(JIT_V0);
jit_ret();
@ -679,7 +679,7 @@ int main(int argc, char *argv[])
jit_va_start(JIT_V0);
jit_prepare();
jit_pushargr_d(JIT_F3);
jit_pushargr(JIT_V0);
jit_va_push(JIT_V0);
jit_finishi(va_d_ididididi);
jit_va_end(JIT_V0);
jit_ret();
@ -696,7 +696,7 @@ int main(int argc, char *argv[])
jit_prepare();
jit_pushargr_d(JIT_F3);
jit_pushargr(JIT_V1);
jit_pushargr(JIT_V0);
jit_va_push(JIT_V0);
jit_finishi(va_di_didididi);
jit_va_end(JIT_V0);
jit_ret();
@ -723,7 +723,7 @@ int main(int argc, char *argv[])
jit_pushargi(1);
jit_pushargr(JIT_V1);
jit_pushargr(JIT_V2);
jit_pushargr(JIT_V0);
jit_va_push(JIT_V0);
jit_finishi(va_iii_iiiiiii);
jit_va_end(JIT_V0);
jit_ret();
@ -750,7 +750,7 @@ int main(int argc, char *argv[])
jit_pushargi(2);
jit_pushargr(JIT_V1);
jit_pushargr(JIT_V2);
jit_pushargr(JIT_V0);
jit_va_push(JIT_V0);
jit_finishi(va_iiii_iiiiii);
jit_va_end(JIT_V0);
jit_ret();
@ -771,7 +771,7 @@ int main(int argc, char *argv[])
jit_pushargi_d(1);
jit_pushargr_d(JIT_F3);
jit_pushargr_d(JIT_F4);
jit_pushargr(JIT_V0);
jit_va_push(JIT_V0);
jit_finishi(va_ddd_ddddddd);
jit_va_end(JIT_V0);
jit_ret();
@ -798,7 +798,7 @@ int main(int argc, char *argv[])
jit_pushargi_d(2);
jit_pushargr_d(JIT_F3);
jit_pushargr_d(JIT_F4);
jit_pushargr(JIT_V0);
jit_va_push(JIT_V0);
jit_finishi(va_dddd_dddddd);
jit_va_end(JIT_V0);
jit_ret();
@ -819,7 +819,7 @@ int main(int argc, char *argv[])
jit_pushargi(1);
jit_pushargr_d(JIT_F3);
jit_pushargr(JIT_V1);
jit_pushargr(JIT_V0);
jit_va_push(JIT_V0);
jit_finishi(va_idi_dididid);
jit_va_end(JIT_V0);
jit_ret();
@ -846,7 +846,7 @@ int main(int argc, char *argv[])
jit_pushargi_d(2);
jit_pushargr(JIT_V1);
jit_pushargr_d(JIT_F3);
jit_pushargr(JIT_V0);
jit_va_push(JIT_V0);
jit_finishi(va_idid_ididid);
jit_va_end(JIT_V0);
jit_ret();
@ -867,7 +867,7 @@ int main(int argc, char *argv[])
jit_pushargi_d(1);
jit_pushargr(JIT_V1);
jit_pushargr_d(JIT_F3);
jit_pushargr(JIT_V0);
jit_va_push(JIT_V0);
jit_finishi(va_did_idididi);
jit_va_end(JIT_V0);
jit_ret();
@ -894,7 +894,7 @@ int main(int argc, char *argv[])
jit_pushargi(2);
jit_pushargr_d(JIT_F3);
jit_pushargr(JIT_V1);
jit_pushargr(JIT_V0);
jit_va_push(JIT_V0);
jit_finishi(va_didi_dididi);
jit_va_end(JIT_V0);
jit_ret();

View file

@ -497,7 +497,7 @@ static void bunordr_d(void); static void bunordi_d(void);
static void pushargr_d(void); static void pushargi_d(void);
static void retr_d(void); static void reti_d(void);
static void retval_d(void);
static void vastart(void);
static void vastart(void); static void vapush(void);
static void vaarg(void); static void vaarg_d(void);
static void vaend(void);
@ -811,6 +811,7 @@ static instr_t instr_vector[] = {
entry(retr_d), entry(reti_d),
entry(retval_d),
entry2("va_start", vastart),
entry2("va_push", vapush),
entry2("va_arg", vaarg),
entry2("va_arg_d", vaarg_d),
entry2("va_end", vaend),
@ -1658,6 +1659,12 @@ vastart(void)
jit_va_start(r0);
}
static void
vapush(void)
{
jit_gpr_t r0 = get_ireg();
jit_va_push(r0);
}
static void
vaarg(void)
{
jit_gpr_t r0 = get_ireg(), r1 = get_ireg();

View file

@ -400,15 +400,19 @@ that uses the appropriate wordsize call.
These are:
@example
prepare (not specified)
va_start (not specified)
pushargr _f _d
pushargi _f _d
va_push (not specified)
arg _c _uc _s _us _i _ui _l _f _d
getarg _c _uc _s _us _i _ui _l _f _d
va_arg _d
putargr _f _d
putargi _f _d
ret (not specified)
retr _f _d
reti _f _d
va_end (not specified)
retval _c _uc _s _us _i _ui _l _f _d
epilog (not specified)
@end example
@ -425,6 +429,12 @@ the @code{pushargr} or @code{pushargi} to push the arguments @strong{in
left to right order}; and use @code{finish} or @code{call} (explained below)
to perform the actual call.
@code{va_start} returns a @code{C} compatible @code{va_list}. To fetch
arguments, use @code{va_arg} for integers and @code{va_arg_d} for doubles.
@code{va_push} is required when passing a @code{va_list} to another function,
because not all architectures expect it as a single pointer. Known case
is DEC Alpha, that requires it as a structure passed by value.
@code{arg}, @code{getarg} and @code{putarg} are used by the callee.
@code{arg} is different from other instruction in that it does not
actually generate any code: instead, it is a function which returns

View file

@ -202,6 +202,8 @@ typedef enum {
#define jit_ellipsis() _jit_ellipsis(_jit)
jit_code_ellipsis,
#define jit_va_push(u) _jit_va_push(_jit,u)
jit_code_va_push,
#define jit_allocai(u) _jit_allocai(_jit,u)
#define jit_allocar(u, v) _jit_allocar(_jit,u,v)
jit_code_allocai, jit_code_allocar,
@ -950,6 +952,7 @@ extern void _jit_putargi(jit_state_t*, jit_word_t, jit_node_t*);
extern void _jit_prepare(jit_state_t*);
extern void _jit_ellipsis(jit_state_t*);
extern void _jit_va_push(jit_state_t*, jit_gpr_t);
extern void _jit_pushargr(jit_state_t*, jit_gpr_t);
extern void _jit_pushargi(jit_state_t*, jit_word_t);
extern void _jit_finishr(jit_state_t*, jit_gpr_t);

View file

@ -11,6 +11,7 @@
0, /* label */
120, /* prolog */
0, /* ellipsis */
0, /* va_push */
0, /* allocai */
0, /* allocar */
0, /* arg */

View file

@ -371,6 +371,14 @@ _jit_ellipsis(jit_state_t *_jit)
jit_dec_synth();
}
void
_jit_va_push(jit_state_t *_jit, jit_int32_t u)
{
jit_inc_synth_w(va_push, u);
jit_pushargr(u);
jit_dec_synth();
}
jit_node_t *
_jit_arg(jit_state_t *_jit)
{
@ -1452,6 +1460,7 @@ _emit_code(jit_state_t *_jit)
vaarg_d(rn(node->u.w), rn(node->v.w));
break;
case jit_code_live: case jit_code_ellipsis:
case jit_code_va_push:
case jit_code_allocai: case jit_code_allocar:
case jit_code_arg:
case jit_code_arg_f: case jit_code_arg_d:

View file

@ -2689,7 +2689,10 @@ _vastart(jit_state_t *_jit, jit_int32_t r0)
stxi(offsetof(jit_va_list_t, base), r0, rn(reg));
/* Initialize the offset field */
movi(rn(reg), _jitc->function->vagp * 8);
if (_jitc->function.vagp < 6)
movi(rn(reg), _jitc->function->vagp * 8);
else
movi(rn(reg), _jitc->function->self.size - (stack_framesize - 48));
stxi(offsetof(jit_va_list_t, offset), r0, rn(reg));
jit_unget_reg(reg);

View file

@ -11,6 +11,7 @@
0, /* label */
76, /* prolog */
0, /* ellipsis */
0, /* va_push */
0, /* allocai */
0, /* allocar */
0, /* arg */

View file

@ -346,6 +346,20 @@ _jit_ellipsis(jit_state_t *_jit)
jit_dec_synth();
}
void
_jit_va_push(jit_state_t *_jit, jit_int32_t u)
{
jit_int32_t reg;
jit_inc_synth_w(va_push, u);
reg = jit_get_reg(jit_class_gpr);
jit_ldxi(reg, u, offsetof(jit_va_list_t, base));
jit_pushargr(reg);
jit_ldxi(reg, u, offsetof(jit_va_list_t, offset));
jit_pushargr(reg);
jit_unget_reg(reg);
jit_dec_synth();
}
jit_node_t *
_jit_arg(jit_state_t *_jit)
{
@ -1406,6 +1420,7 @@ _emit_code(jit_state_t *_jit)
vaarg_d(rn(node->u.w), rn(node->v.w));
break;
case jit_code_live: case jit_code_ellipsis:
case jit_code_va_push:
case jit_code_allocai: case jit_code_allocar:
case jit_code_arg:
case jit_code_arg_f: case jit_code_arg_d:

View file

@ -12,6 +12,7 @@
0, /* label */
34, /* prolog */
0, /* ellipsis */
0, /* va_push */
0, /* allocai */
0, /* allocar */
0, /* arg */
@ -415,6 +416,7 @@
0, /* label */
30, /* prolog */
0, /* ellipsis */
0, /* va_push */
0, /* allocai */
0, /* allocar */
0, /* arg */

View file

@ -549,6 +549,14 @@ _jit_ellipsis(jit_state_t *_jit)
jit_dec_synth();
}
void
_jit_va_push(jit_state_t *_jit, jit_int32_t u)
{
jit_inc_synth_w(va_push, u);
jit_pushargr(u);
jit_dec_synth();
}
jit_node_t *
_jit_arg(jit_state_t *_jit)
{
@ -1885,6 +1893,7 @@ _emit_code(jit_state_t *_jit)
vfp_vaarg_d(rn(node->u.w), rn(node->v.w));
break;
case jit_code_live: case jit_code_ellipsis:
case jit_code_va_push:
case jit_code_allocai: case jit_code_allocar:
case jit_code_arg:
case jit_code_arg_f: case jit_code_arg_d:

View file

@ -11,6 +11,7 @@
0, /* label */
64, /* prolog */
0, /* ellipsis */
0, /* va_push */
0, /* allocai */
0, /* allocar */
0, /* arg */

View file

@ -329,6 +329,14 @@ _jit_ellipsis(jit_state_t *_jit)
jit_dec_synth();
}
void
_jit_va_push(jit_state_t *_jit, jit_int32_t u)
{
jit_inc_synth_w(va_push, u);
jit_pushargr(u);
jit_dec_synth();
}
jit_node_t *
_jit_arg(jit_state_t *_jit)
{
@ -1387,6 +1395,7 @@ _emit_code(jit_state_t *_jit)
break;
case jit_code_live:
case jit_code_arg: case jit_code_ellipsis:
case jit_code_va_push:
case jit_code_allocai: case jit_code_allocar:
case jit_code_arg_f: case jit_code_arg_d:
case jit_code_va_end:

View file

@ -11,6 +11,7 @@
0, /* label */
224, /* prolog */
0, /* ellipsis */
0, /* va_push */
0, /* allocai */
0, /* allocar */
0, /* arg */

View file

@ -432,6 +432,14 @@ _jit_ellipsis(jit_state_t *_jit)
jit_dec_synth();
}
void
_jit_va_push(jit_state_t *_jit, jit_int32_t u)
{
jit_inc_synth_w(va_push, u);
jit_pushargr(u);
jit_dec_synth();
}
jit_node_t *
_jit_arg(jit_state_t *_jit)
{
@ -1578,6 +1586,7 @@ _emit_code(jit_state_t *_jit)
break;
case jit_code_live:
case jit_code_arg: case jit_code_ellipsis:
case jit_code_va_push:
case jit_code_allocai: case jit_code_allocar:
case jit_code_arg_f: case jit_code_arg_d:
case jit_code_va_end:

View file

@ -12,6 +12,7 @@
0, /* label */
44, /* prolog */
0, /* ellipsis */
0, /* va_push */
0, /* allocai */
0, /* allocar */
0, /* arg */
@ -415,6 +416,7 @@
0, /* label */
116, /* prolog */
0, /* ellipsis */
0, /* va_push */
0, /* allocai */
0, /* allocar */
0, /* arg */
@ -817,6 +819,7 @@
0, /* label */
44, /* prolog */
0, /* ellipsis */
0, /* va_push */
0, /* allocai */
0, /* allocar */
0, /* arg */

View file

@ -489,6 +489,14 @@ _jit_ellipsis(jit_state_t *_jit)
jit_dec_synth();
}
void
_jit_va_push(jit_state_t *_jit, jit_int32_t u)
{
jit_inc_synth_w(va_push, u);
jit_pushargr(u);
jit_dec_synth();
}
jit_node_t *
_jit_arg(jit_state_t *_jit)
{
@ -1779,6 +1787,7 @@ _emit_code(jit_state_t *_jit)
break;
case jit_code_live:
case jit_code_arg: case jit_code_ellipsis:
case jit_code_va_push:
case jit_code_allocai: case jit_code_allocar:
case jit_code_arg_f: case jit_code_arg_d:
case jit_code_va_end:

View file

@ -24,7 +24,7 @@ static char *code_name[] = {
"#name", "#note",
"label",
"prolog",
"ellipsis",
"ellipsis", "va_push",
"allocai", "allocar",
"arg",
"getarg_c", "getarg_uc",

View file

@ -12,6 +12,7 @@
0, /* label */
44, /* prolog */
0, /* ellipsis */
0, /* va_push */
0, /* allocai */
0, /* allocar */
0, /* arg */
@ -416,6 +417,7 @@
0, /* label */
136, /* prolog */
0, /* ellipsis */
0, /* va_push */
0, /* allocai */
0, /* allocar */
0, /* arg */
@ -821,6 +823,7 @@
0, /* label */
148, /* prolog */
0, /* ellipsis */
0, /* va_push */
0, /* allocai */
0, /* allocar */
0, /* arg */
@ -1226,6 +1229,7 @@
0, /* label */
124, /* prolog */
0, /* ellipsis */
0, /* va_push */
0, /* allocai */
0, /* allocar */
0, /* arg */

View file

@ -340,6 +340,14 @@ _jit_ellipsis(jit_state_t *_jit)
jit_dec_synth();
}
void
_jit_va_push(jit_state_t *_jit, jit_int32_t u)
{
jit_inc_synth_w(va_push, u);
jit_pushargr(u);
jit_dec_synth();
}
jit_node_t *
_jit_arg(jit_state_t *_jit)
{
@ -1603,6 +1611,7 @@ _emit_code(jit_state_t *_jit)
break;
case jit_code_live:
case jit_code_arg: case jit_code_ellipsis:
case jit_code_va_push:
case jit_code_allocai: case jit_code_allocar:
case jit_code_arg_f: case jit_code_arg_d:
case jit_code_va_end:

View file

@ -11,6 +11,7 @@
2, /* label */
42, /* prolog */
0, /* ellipsis */
0, /* va_push */
0, /* allocai */
0, /* allocar */
0, /* arg */
@ -412,6 +413,7 @@
2, /* label */
42, /* prolog */
0, /* ellipsis */
0, /* va_push */
0, /* allocai */
0, /* allocar */
0, /* arg */

View file

@ -343,6 +343,14 @@ _jit_ellipsis(jit_state_t *_jit)
jit_dec_synth();
}
void
_jit_va_push(jit_state_t *_jit, jit_int32_t u)
{
jit_inc_synth_w(va_push, u);
jit_pushargr(u);
jit_dec_synth();
}
jit_node_t *
_jit_arg(jit_state_t *_jit)
{
@ -1480,6 +1488,7 @@ _emit_code(jit_state_t *_jit)
vaarg_d(rn(node->u.w), rn(node->v.w));
break;
case jit_code_live: case jit_code_ellipsis:
case jit_code_va_push:
case jit_code_allocai: case jit_code_allocar:
case jit_code_arg:
case jit_code_arg_f: case jit_code_arg_d:

View file

@ -11,6 +11,7 @@
0, /* label */
16, /* prolog */
0, /* ellipsis */
0, /* va_push */
0, /* allocai */
0, /* allocar */
0, /* arg */

View file

@ -298,6 +298,14 @@ _jit_ellipsis(jit_state_t *_jit)
jit_dec_synth();
}
void
_jit_va_push(jit_state_t *_jit, jit_int32_t u)
{
jit_inc_synth_w(va_push, u);
jit_pushargr(u);
jit_dec_synth();
}
jit_node_t *
_jit_arg(jit_state_t *_jit)
{
@ -1398,6 +1406,7 @@ _emit_code(jit_state_t *_jit)
vaarg_d(rn(node->u.w), rn(node->v.w));
break;
case jit_code_live: case jit_code_ellipsis:
case jit_code_va_push:
case jit_code_allocai: case jit_code_allocar:
case jit_code_arg:
case jit_code_arg_f: case jit_code_arg_d:

View file

@ -11,6 +11,7 @@
3, /* label */
34, /* prolog */
0, /* ellipsis */
0, /* va_push */
0, /* allocai */
0, /* allocar */
0, /* arg */
@ -413,6 +414,7 @@
7, /* label */
130, /* prolog */
0, /* ellipsis */
0, /* va_push */
0, /* allocai */
0, /* allocar */
0, /* arg */
@ -814,6 +816,7 @@
3, /* label */
108, /* prolog */
0, /* ellipsis */
0, /* va_push */
0, /* allocai */
0, /* allocar */
0, /* arg */
@ -1214,6 +1217,7 @@
7, /* label */
115, /* prolog */
0, /* ellipsis */
0, /* va_push */
0, /* allocai */
0, /* allocar */
0, /* arg */

View file

@ -620,6 +620,14 @@ _jit_ellipsis(jit_state_t *_jit)
jit_dec_synth();
}
void
_jit_va_push(jit_state_t *_jit, jit_int32_t u)
{
jit_inc_synth_w(va_push, u);
jit_pushargr(u);
jit_dec_synth();
}
jit_node_t *
_jit_arg(jit_state_t *_jit)
{
@ -2075,6 +2083,7 @@ _emit_code(jit_state_t *_jit)
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_ellipsis:
case jit_code_va_push:
case jit_code_allocai: case jit_code_allocar:
case jit_code_arg:
case jit_code_arg_f: case jit_code_arg_d:

View file

@ -1253,8 +1253,8 @@ _jit_classify(jit_state_t *_jit, jit_code_t code)
switch (code) {
case jit_code_data: case jit_code_save: case jit_code_load:
case jit_code_name: case jit_code_label: case jit_code_note:
case jit_code_prolog: case jit_code_ellipsis: case jit_code_epilog:
case jit_code_ret: case jit_code_prepare:
case jit_code_prolog: case jit_code_ellipsis: case jit_code_va_push:
case jit_code_epilog: case jit_code_ret: case jit_code_prepare:
mask = 0;
break;
case jit_code_live: case jit_code_va_end: