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_mips-cpu.c
diff options
context:
space:
mode:
authorPaul Cercueil <paul@crapouillou.net>2023年01月14日 15:10:51 +0000
committerpcpa <paulo.cesar.pereira.de.andrade@gmail.com>2023年01月14日 21:37:29 -0300
commit3c134a06ff2e474e9e2779b9c625fcfcb4ad2862 (patch)
tree7083740eb5f0b61f433ac5d0eb3bc594519e9f1d /lib/jit_mips-cpu.c
parente789a06724d994bd27d53723a9c714b49f222149 (diff)
downloadlightning-3c134a06ff2e474e9e2779b9c625fcfcb4ad2862.tar.gz
mips: Fill delay slots of JALR opcodes in jit_callr
Fill the delay slot of the generated JALR opcode, if it is not already used to set the $t9 register. When we know that the last generated opcode is not the target of a jump, and that it does not write the register used by the JALR opcode, we can swap it with the JALR opcode, so that it now becomes the delay slot of the JALR opcode. Signed-off-by: Paul Cercueil <paul@crapouillou.net>
Diffstat (limited to 'lib/jit_mips-cpu.c')
-rw-r--r--lib/jit_mips-cpu.c 28
1 files changed, 20 insertions, 8 deletions
diff --git a/lib/jit_mips-cpu.c b/lib/jit_mips-cpu.c
index 033315e..028b806 100644
--- a/lib/jit_mips-cpu.c
+++ b/lib/jit_mips-cpu.c
@@ -757,8 +757,8 @@ static jit_word_t _bmsi(jit_state_t*,jit_word_t,jit_int32_t,jit_word_t);
static jit_word_t _bmcr(jit_state_t*,jit_word_t,jit_int32_t,jit_int32_t);
# define bmci(i0,r0,i1) _bmci(_jit,i0,r0,i1)
static jit_word_t _bmci(jit_state_t*,jit_word_t,jit_int32_t,jit_word_t);
-# define callr(r0) _callr(_jit,r0)
-static void _callr(jit_state_t*,jit_int32_t);
+# define callr(r0,prev) _callr(_jit,r0,prev)
+static void _callr(jit_state_t*,jit_int32_t,jit_node_t*);
# define calli(i0) _calli(_jit,i0)
static void _calli(jit_state_t*,jit_word_t);
# define calli_p(i0) _calli_p(_jit,i0)
@@ -3167,13 +3167,25 @@ _bmci(jit_state_t *_jit, jit_word_t i0, jit_int32_t r0, jit_word_t i1)
}
static void
-_callr(jit_state_t *_jit, jit_int32_t r0)
+_callr(jit_state_t *_jit, jit_int32_t r0, jit_node_t *prev)
{
- JALR(r0);
- if (r0 != _T9_REGNO)
- movr(_T9_REGNO, r0);
- else
- NOP(1);
+ jit_bool_t swap_ds;
+ jit_int32_t op;
+
+ if (r0 != _T9_REGNO) {
+ JALR(r0);
+ movr(_T9_REGNO, r0);
+ } else {
+ swap_ds = can_swap_ds(prev, r0, 0);
+ if (swap_ds)
+ op = *--_jit->pc.ui;
+
+ JALR(r0);
+ if (swap_ds)
+ ii(op);
+ else
+ NOP(1);
+ }
}
static void
generated by cgit v1.2.3 (git 2.25.1) at 2025年09月10日 23:50:54 +0000

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