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年03月08日 00:33:01 +0000
committerpcpa <paulo.cesar.pereira.de.andrade@gmail.com>2023年03月08日 08:39:39 -0300
commita6abde74b219aa1f350daf8d8c373c8197d7ba82 (patch)
tree1a58eb8017294e3ae2c10932895635cb36afd69d /lib/jit_mips-cpu.c
parent321c18023e3bb3025059da6de7fd0cca88b3dc90 (diff)
downloadlightning-a6abde74b219aa1f350daf8d8c373c8197d7ba82.tar.gz
mips: Optimize jit_ctor() / jit_ctzr()
The jit_ctzr() can be performed with just 5 instructions and 2 temporary registers. The jit_ctor() can be performed by just inversing all bits then calculating the ctzr(). Signed-off-by: Paul Cercueil <paul@crapouillou.net>
Diffstat (limited to 'lib/jit_mips-cpu.c')
-rw-r--r--lib/jit_mips-cpu.c 61
1 files changed, 25 insertions, 36 deletions
diff --git a/lib/jit_mips-cpu.c b/lib/jit_mips-cpu.c
index d71a5b5..7babc86 100644
--- a/lib/jit_mips-cpu.c
+++ b/lib/jit_mips-cpu.c
@@ -1670,49 +1670,38 @@ _clzr(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1)
static void
_ctor(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1)
{
- if (jit_mips2_p()) {
- if (jit_mips6_p()) {
-#if __WORDSIZE == 32
- BITSWAP(r0, r1);
- bswapr_ui(r0, r0);
- CLO_R6(r0, r0);
-#else
- DBITSWAP(r0, r1);
- bswapr_ul(r0, r0);
- DCLO_R6(r0, r0);
-#endif
- }
- else {
- fallback_bitswap(r0, r1);
- clor(r0, r0);
- }
+ if (jit_mips6_p()) {
+ rbitr(r0, r1);
+ clor(r0, r0);
+ }
+ else {
+ comr(r0, r1);
+ ctzr(r0, r0);
}
- else
- fallback_cto(r0, r1);
}
static void
_ctzr(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1)
{
- if (jit_mips2_p()) {
- if (jit_mips6_p()) {
-#if __WORDSIZE == 32
- BITSWAP(r0, r1);
- bswapr_ui(r0, r0);
- CLZ_R6(r0, r0);
-#else
- DBITSWAP(r0, r1);
- bswapr_ul(r0, r0);
- DCLZ_R6(r0, r0);
-#endif
- }
- else {
- fallback_bitswap(r0, r1);
- clzr(r0, r0);
- }
+ if (jit_mips6_p()) {
+ rbitr(r0, r1);
+ clzr(r0, r0);
+ }
+ else {
+ jit_int32_t t0, t1;
+
+ t0 = jit_get_reg(jit_class_gpr);
+ t1 = jit_get_reg(jit_class_gpr);
+
+ negr(rn(t0), r1);
+ andr(rn(t0), rn(t0), r1);
+ clzr(r0, rn(t0));
+ xori(rn(t1), r0, __WORDSIZE - 1);
+ movnr(r0, rn(t1), rn(t0));
+
+ jit_unget_reg(t0);
+ jit_unget_reg(t1);
}
- else
- fallback_ctz(r0, r1);
}
static void
generated by cgit v1.2.3 (git 2.25.1) at 2025年09月10日 23:50:07 +0000

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