From f7037aa1567e0b27c7cf61fbe02f68971e8fa345 Mon Sep 17 00:00:00 2001 From: Zoltan Herczeg Date: Tue, 26 Nov 2024 13:11:22 +0100 Subject: [PATCH] Improve vector reg support on s390x (#279) --- sljit_src/sljitNativeARM_32.c | 2 +- sljit_src/sljitNativeARM_T2_32.c | 2 +- sljit_src/sljitNativeS390X.c | 2 +- test_src/sljitTestSimd.h | 10 ++++++++++ 4 files changed, 13 insertions(+), 3 deletions(-) diff --git a/sljit_src/sljitNativeARM_32.c b/sljit_src/sljitNativeARM_32.c index ea835f29..da79a80d 100644 --- a/sljit_src/sljitNativeARM_32.c +++ b/sljit_src/sljitNativeARM_32.c @@ -2676,7 +2676,7 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit_get_register_index(sljit_s32 type, slji if (type == SLJIT_FLOAT_REGISTER || type == SLJIT_SIMD_REG_64) return freg_map[reg]; - if (type != SLJIT_SIMD_REG_128) + if (type == SLJIT_SIMD_REG_128) return freg_map[reg] & ~0x1; return -1; diff --git a/sljit_src/sljitNativeARM_T2_32.c b/sljit_src/sljitNativeARM_T2_32.c index b2a54dbb..f97b3cf9 100644 --- a/sljit_src/sljitNativeARM_T2_32.c +++ b/sljit_src/sljitNativeARM_T2_32.c @@ -2244,7 +2244,7 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit_get_register_index(sljit_s32 type, slji if (type == SLJIT_FLOAT_REGISTER || type == SLJIT_SIMD_REG_64) return freg_map[reg]; - if (type != SLJIT_SIMD_REG_128) + if (type == SLJIT_SIMD_REG_128) return freg_map[reg] & ~0x1; return -1; diff --git a/sljit_src/sljitNativeS390X.c b/sljit_src/sljitNativeS390X.c index cfd7e392..18f91706 100644 --- a/sljit_src/sljitNativeS390X.c +++ b/sljit_src/sljitNativeS390X.c @@ -3187,7 +3187,7 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit_get_register_index(sljit_s32 type, slji if (type == SLJIT_GP_REGISTER) return (sljit_s32)gpr(reg); - if (type != SLJIT_FLOAT_REGISTER) + if (type != SLJIT_FLOAT_REGISTER && type != SLJIT_SIMD_REG_128) return -1; return (sljit_s32)freg_map[reg]; diff --git a/test_src/sljitTestSimd.h b/test_src/sljitTestSimd.h index 3758a640..93e266c6 100644 --- a/test_src/sljitTestSimd.h +++ b/test_src/sljitTestSimd.h @@ -81,6 +81,12 @@ static void test_simd1(void) sljit_u8 data[63 + 880]; sljit_s32 vs0 = SLJIT_NUMBER_OF_SAVED_VECTOR_REGISTERS > 0 ? SLJIT_VS0 : SLJIT_VR5; + SLJIT_ASSERT(sljit_get_register_index(SLJIT_SIMD_REG_128, SLJIT_VR0) != -1 + && sljit_get_register_index(SLJIT_SIMD_REG_128, SLJIT_TMP_DEST_VREG) != -1); + + SLJIT_ASSERT(SLJIT_NUMBER_OF_SAVED_VECTOR_REGISTERS == 0 + || sljit_get_register_index(SLJIT_SIMD_REG_128, SLJIT_VS0) != -1); + if (verbose) printf("Run test_simd1\n"); @@ -235,6 +241,8 @@ static void test_simd1(void) FAILED(!check_simd_mov(buf + 288, 239, 16), "test_simd1 case 6 failed\n"); FAILED(!check_simd_mov(buf + 344, 176, 16), "test_simd1 case 7 failed\n"); #if IS_ARM + SLJIT_ASSERT(sljit_get_register_index(SLJIT_SIMD_REG_64, SLJIT_VR0) != -1 + && sljit_get_register_index(SLJIT_SIMD_REG_64, SLJIT_TMP_DEST_VREG) != -1); FAILED(!check_simd_mov(buf + 384, 88, 8), "test_simd1 case 8 failed\n"); FAILED(!check_simd_mov(buf + 402, 197, 8), "test_simd1 case 9 failed\n"); #endif /* IS_ARM */ @@ -247,6 +255,8 @@ static void test_simd1(void) #endif /* IS_ARM */ if (supported[0]) { + SLJIT_ASSERT(sljit_get_register_index(SLJIT_SIMD_REG_256, SLJIT_VR0) != -1 + && sljit_get_register_index(SLJIT_SIMD_REG_256, SLJIT_TMP_DEST_VREG) != -1); FAILED(!check_simd_mov(buf + 768, 85, 32), "test_simd1 case 15 failed\n"); FAILED(!check_simd_mov(buf + 834, 215, 32), "test_simd1 case 16 failed\n"); }