Intermediate, fully functional, rework for variadic functions - lightning.git - Portable just-in-time compiler library

index : lightning.git
Portable just-in-time compiler library
summary refs log tree commit diff
path: root/lib/jit_arm-cpu.c
diff options
context:
space:
mode:
authorpcpa <paulo.cesar.pereira.de.andrade@gmail.com>2015年05月25日 15:20:24 -0300
committerpcpa <paulo.cesar.pereira.de.andrade@gmail.com>2015年05月25日 15:20:24 -0300
commit0b6cc01eeae66bac4573cc29f346368657ac9c73 (patch)
tree9bd6cab3d42256d8430e0b83621a4a44786d042e /lib/jit_arm-cpu.c
parent237c90295aad597b095572581e5bfb46a3b239a0 (diff)
downloadlightning-0b6cc01eeae66bac4573cc29f346368657ac9c73.tar.gz
Intermediate, fully functional, rework for variadic functions
* check/cva_list.c: New file implementing a test to ensure the value returned by jit_va_start is a valid C va_list. * check/va_list.ok: New simple helper file, as now the va_list.tst test is enabled. * check/va_list.tst: Rewritten for an extensive variadic jit functions test. * check/Makefile.am: Update for the new tests. * lib/jit_arm-cpu.c, lib/jit_arm-swf.c, lib/jit_arm-vfp.c, lib/jit_arm.c: Correct broken software float in a previous commit. Note that the hard float abi implementation is known broken at this time, for special cases involving variadic functions, and should be corrected next. lib/jit_x86-cpu.c, lib/jit_x86-sz.c, lib/jit_x86.c: Correct the jit_va_list_t semantics to match C va_list.
Diffstat (limited to 'lib/jit_arm-cpu.c')
-rw-r--r--lib/jit_arm-cpu.c 91
1 files changed, 19 insertions, 72 deletions
diff --git a/lib/jit_arm-cpu.c b/lib/jit_arm-cpu.c
index 07b4630..ae0b284 100644
--- a/lib/jit_arm-cpu.c
+++ b/lib/jit_arm-cpu.c
@@ -3778,42 +3778,25 @@ _prolog(jit_state_t *_jit, jit_node_t *node)
BX(_R12_REGNO);
if (!_jitc->thumb)
_jitc->thumb = _jit->pc.w;
-
- /* If the jit function is varargs, do a slightly more
- * costly prolog to save first the 4 argument registers. */
if (jit_cpu.abi) {
- if (_jitc->function->self.call & jit_call_varargs)
- T2_PUSH(0xf);
+ T2_PUSH(0xf);
T2_PUSH(0x3f0|(1<<_FP_REGNO)|(1<<_LR_REGNO));
VPUSH_F64(_D8_REGNO, 8);
- if (!(_jitc->function->self.call & jit_call_varargs))
- T2_PUSH(0xf);
}
else {
- if (_jitc->function->self.call & jit_call_varargs) {
- T2_PUSH(0xf);
- T2_PUSH(0x3f0|(1<<_FP_REGNO)|(1<<_LR_REGNO));
- }
- else
- T2_PUSH(0x3ff|(1<<_FP_REGNO)|(1<<_LR_REGNO));
+ T2_PUSH(0xf);
+ T2_PUSH(0x3f0|(1<<_FP_REGNO)|(1<<_LR_REGNO));
}
}
else {
if (jit_cpu.abi) {
- if (_jitc->function->self.call & jit_call_varargs)
- PUSH(0xf);
+ PUSH(0xf);
PUSH(0x3f0|(1<<_FP_REGNO)|(1<<_LR_REGNO));
VPUSH_F64(_D8_REGNO, 8);
- if (!(_jitc->function->self.call & jit_call_varargs))
- PUSH(0xf);
}
else {
- if (_jitc->function->self.call & jit_call_varargs) {
- PUSH(0xf);
- PUSH(0x3f0|(1<<_FP_REGNO)|(1<<_LR_REGNO));
- }
- else
- PUSH(0x3ff|(1<<_FP_REGNO)|(1<<_LR_REGNO));
+ PUSH(0xf);
+ PUSH(0x3f0|(1<<_FP_REGNO)|(1<<_LR_REGNO));
}
}
movr(_FP_REGNO, _SP_REGNO);
@@ -3833,35 +3816,18 @@ _epilog(jit_state_t *_jit, jit_node_t *node)
if (_jitc->function->assume_frame)
return;
- /* If the jit function is varargs, need a different
- * epilog, that also does not directly restore the
- * pc, but instead branch to the lr, after correcting
- * the stack. */
- if (_jitc->function->self.call & jit_call_varargs)
- movr(_SP_REGNO, _FP_REGNO);
- else
- addi(_SP_REGNO, _FP_REGNO, 16);
+ movr(_SP_REGNO, _FP_REGNO);
if (jit_cpu.abi)
VPOP_F64(_D8_REGNO, 8);
- if (jit_thumb_p()) {
- if (!(_jitc->function->self.call & jit_call_varargs))
- T2_POP(0x3f0|(1<<_FP_REGNO)|(1<<_PC_REGNO));
- else
- T2_POP(0x3f0|(1<<_FP_REGNO)|(1<<_LR_REGNO));
- }
- else {
- if (!(_jitc->function->self.call & jit_call_varargs))
- POP(0x3f0|(1<<_FP_REGNO)|(1<<_PC_REGNO));
- else
- POP(0x3f0|(1<<_FP_REGNO)|(1<<_LR_REGNO));
- }
- if (_jitc->function->self.call & jit_call_varargs) {
- addi(_SP_REGNO, _SP_REGNO, 16);
- if (jit_thumb_p())
- T1_BX(_LR_REGNO);
- else
- BX(_LR_REGNO);
- }
+ if (jit_thumb_p())
+ T2_POP(0x3f0|(1<<_FP_REGNO)|(1<<_LR_REGNO));
+ else
+ POP(0x3f0|(1<<_FP_REGNO)|(1<<_LR_REGNO));
+ addi(_SP_REGNO, _SP_REGNO, 16);
+ if (jit_thumb_p())
+ T1_BX(_LR_REGNO);
+ else
+ BX(_LR_REGNO);
if (jit_thumb_p() && (_jit->pc.w & 2))
T1_NOP();
}
@@ -3869,45 +3835,26 @@ _epilog(jit_state_t *_jit, jit_node_t *node)
static void
_vastart(jit_state_t *_jit, jit_int32_t r0)
{
- jit_int32_t reg;
-
assert(_jitc->function->self.call & jit_call_varargs);
- /* Return jit_va_list_t in the register argument */
- addi(r0, _FP_REGNO, _jitc->function->vaoff);
- reg = jit_get_reg(jit_class_gpr);
-
/* Initialize stack pointer to the first stack argument.
* The -16 is to account for the 4 argument registers
* always saved, and _jitc->function->vagp is to account
* for declared arguments. */
- addi(rn(reg), _FP_REGNO, _jitc->function->self.size -
+ addi(r0, _FP_REGNO, _jitc->function->self.size -
16 + _jitc->function->vagp);
- stxi(offsetof(jit_va_list_t, stack), r0, rn(reg));
-
- jit_unget_reg(reg);
}
static void
_vaarg(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1)
{
- jit_int32_t reg;
-
assert(_jitc->function->self.call & jit_call_varargs);
- reg = jit_get_reg(jit_class_gpr);
-
- /* Load stack pointer. */
- ldxi(rn(reg), r1, offsetof(jit_va_list_t, stack));
-
/* Load argument. */
- ldr(r0, rn(reg));
+ ldr(r0, r1);
/* Update stack pointer. */
- addi(rn(reg), rn(reg), sizeof(jit_word_t));
- stxi(offsetof(jit_va_list_t, stack), r1, rn(reg));
-
- jit_unget_reg(reg);
+ addi(r1, r1, sizeof(jit_word_t));
}
static void
generated by cgit v1.2.3 (git 2.39.1) at 2025年09月12日 23:17:24 +0000

AltStyle によって変換されたページ (->オリジナル) /