git subrepo pull --force deps/lightrec
authorPaul Cercueil <paul@crapouillou.net>
Fri, 10 Jun 2022 23:17:16 +0000 (00:17 +0100)
committerPaul Cercueil <paul@crapouillou.net>
Sat, 11 Jun 2022 08:43:09 +0000 (09:43 +0100)
subrepo:
  subdir:   "deps/lightrec"
  merged:   "30bad28d"
upstream:
  origin:   "https://github.com/pcercuei/lightrec.git"
  branch:   "master"
  commit:   "30bad28d"
git-subrepo:
  version:  "0.4.3"
  origin:   "https://github.com/ingydotnet/git-subrepo.git"
  commit:   "2f68596"

deps/lightrec/.gitrepo
deps/lightrec/emitter.c
deps/lightrec/lightrec-private.h
deps/lightrec/lightrec.c
deps/lightrec/recompiler.c

index 809f13b..125d138 100644 (file)
@@ -6,7 +6,7 @@
 [subrepo]
        remote = https://github.com/pcercuei/lightrec.git
        branch = master
-       commit = a8fe7568cef718517b230a13fe48891faa60f04b
-       parent = 2f609094ad9ec14212fb730897ccb63f2f44bc40
+       commit = 30bad28d7a2b2903cd7f3d8024ae7a34a0c8b482
+       parent = 0141267e1c5e17c27548f6ad57c7acc22e589990
        method = merge
        cmdver = 0.4.3
index fd28935..15e1c6e 100644 (file)
@@ -75,7 +75,7 @@ static void lightrec_emit_end_of_block(struct lightrec_cstate *state,
                pr_debug("EOB: %u cycles\n", cycles);
        }
 
-       if (offset + !!(op->flags & LIGHTREC_NO_DS) < block->nb_ops - 1)
+       if (offset - !!(op->flags & LIGHTREC_NO_DS) < block->nb_ops - 1)
                state->branches[state->nb_branches++] = jit_b();
 }
 
index fe89e66..3c043d5 100644 (file)
@@ -71,6 +71,14 @@ struct regcache;
 struct opcode;
 struct reaper;
 
+struct u16x2 {
+#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
+       u16 h, l;
+#else
+       u16 l, h;
+#endif
+};
+
 struct block {
        jit_state_t *_jit;
        struct opcode *opcode_list;
index ba734ad..3b3fd09 100644 (file)
@@ -370,6 +370,16 @@ static u32 clamp_s32(s32 val, s32 min, s32 max)
        return val < min ? min : val > max ? max : val;
 }
 
+static u16 load_u16(u32 *ptr)
+{
+       return ((struct u16x2 *) ptr)->l;
+}
+
+static void store_u16(u32 *ptr, u16 value)
+{
+       ((struct u16x2 *) ptr)->l = value;
+}
+
 static u32 lightrec_mfc2(struct lightrec_state *state, u8 reg)
 {
        s16 gteir1, gteir2, gteir3;
@@ -382,18 +392,18 @@ static u32 lightrec_mfc2(struct lightrec_state *state, u8 reg)
        case 9:
        case 10:
        case 11:
-               return (s32)(s16) state->regs.cp2d[reg];
+               return (s32)(s16) load_u16(&state->regs.cp2d[reg]);
        case 7:
        case 16:
        case 17:
        case 18:
        case 19:
-               return (u16) state->regs.cp2d[reg];
+               return load_u16(&state->regs.cp2d[reg]);
        case 28:
        case 29:
-               gteir1 = (s16) state->regs.cp2d[9];
-               gteir2 = (s16) state->regs.cp2d[10];
-               gteir3 = (s16) state->regs.cp2d[11];
+               gteir1 = (s16) load_u16(&state->regs.cp2d[9]);
+               gteir2 = (s16) load_u16(&state->regs.cp2d[10]);
+               gteir3 = (s16) load_u16(&state->regs.cp2d[11]);
 
                return clamp_s32(gteir1 >> 7, 0, 0x1f) << 0 |
                        clamp_s32(gteir2 >> 7, 0, 0x1f) << 5 |
@@ -519,16 +529,15 @@ static void lightrec_ctc2(struct lightrec_state *state, u8 reg, u32 data)
        case 27:
        case 29:
        case 30:
-               data = (s32)(s16) data;
+               store_u16(&state->regs.cp2c[reg], data);
                break;
        case 31:
                data = (data & 0x7ffff000) | !!(data & 0x7f87e000) << 31;
                fallthrough;
        default:
+               state->regs.cp2c[reg] = data;
                break;
        }
-
-       state->regs.cp2c[reg] = data;
 }
 
 void lightrec_mtc(struct lightrec_state *state, union code op, u32 data)
index 4ddc522..7350adb 100644 (file)
@@ -48,7 +48,7 @@ struct recompiler {
 
 static unsigned int get_processors_count(void)
 {
-       unsigned int nb;
+       unsigned int nb = 1;
 
 #if defined(PTW32_VERSION)
         nb = pthread_num_processors_np();
@@ -57,7 +57,7 @@ static unsigned int get_processors_count(void)
         size_t size = sizeof(count);
 
         nb = sysctlbyname("hw.ncpu", &count, &size, NULL, 0) ? 1 : count;
-#elif defined(__linux__)
+#elif defined(_SC_NPROCESSORS_ONLN)
        nb = sysconf(_SC_NPROCESSORS_ONLN);
 #endif