From 402d1343dff56da4528d534b4490b2571427b33b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ciro=20Santilli=20=E5=85=AD=E5=9B=9B=E4=BA=8B=E4=BB=B6=20?= =?UTF-8?q?=E6=B3=95=E8=BD=AE=E5=8A=9F?= Date: Sun, 2 Jun 2019 00:00:02 +0000 Subject: [PATCH] x86 asm: expand macros in the most basic SIMD examples Make it easier on the newbs I guess. --- userland/arch/x86_64/addpd.S | 21 ++++++++++---------- userland/arch/x86_64/paddq.S | 37 ++++++++++++++++++++++-------------- 2 files changed, 34 insertions(+), 24 deletions(-) diff --git a/userland/arch/x86_64/addpd.S b/userland/arch/x86_64/addpd.S index cdaffb9..db91964 100644 --- a/userland/arch/x86_64/addpd.S +++ b/userland/arch/x86_64/addpd.S @@ -18,16 +18,17 @@ LKMC_PROLOGUE .align 16 output: .skip 16 .text -#define TEST(size) \ - movups addp ## size ## _input0, %xmm0; \ - movups addp ## size ## _input1, %xmm1; \ - addp ## size %xmm1, %xmm0; \ - movups %xmm0, output; \ - LKMC_ASSERT_MEMCMP(output, addp ## size ## _expect, $0x10) - /* 4x 32-bit */ - TEST(s) + movaps addps_input0, %xmm0 + movaps addps_input1, %xmm1 + addps %xmm1, %xmm0 + movaps %xmm0, output + LKMC_ASSERT_MEMCMP(output, addps_expect, $0x10) + /* 2x 64-bit */ - TEST(d) -#undef TEST + movaps addpd_input0, %xmm0 + movaps addpd_input1, %xmm1 + addpd %xmm1, %xmm0 + movaps %xmm0, output + LKMC_ASSERT_MEMCMP(output, addpd_expect, $0x10) LKMC_EPILOGUE diff --git a/userland/arch/x86_64/paddq.S b/userland/arch/x86_64/paddq.S index 879607b..e1c1dee 100644 --- a/userland/arch/x86_64/paddq.S +++ b/userland/arch/x86_64/paddq.S @@ -22,19 +22,28 @@ LKMC_PROLOGUE output: .skip 16 .text movaps input1, %xmm1 -#define TEST(size) \ - movaps input0, %xmm0; \ - padd ## size %xmm1, %xmm0; \ - movaps %xmm0, output; \ - LKMC_ASSERT_MEMCMP(output, padd ## size ## _expect, $0x10) - /* 16x 8-bit */ - TEST(b) - /* 8x 4-bit */ - TEST(w) - /* 4x 8-bit */ - TEST(d) - /* 2x 16-bit */ - TEST(q) -#undef TEST + /* 16x 8bit */ + movaps input0, %xmm0 + paddb %xmm1, %xmm0 + movaps %xmm0, output + LKMC_ASSERT_MEMCMP(output, paddb_expect, $0x10) + + /* 8x 16-bit */ + movaps input0, %xmm0 + paddw %xmm1, %xmm0 + movaps %xmm0, output + LKMC_ASSERT_MEMCMP(output, paddw_expect, $0x10) + + /* 4x 32-bit */ + movaps input0, %xmm0 + paddd %xmm1, %xmm0 + movaps %xmm0, output + LKMC_ASSERT_MEMCMP(output, paddd_expect, $0x10) + + /* 2x 64-bit */ + movaps input0, %xmm0 + paddq %xmm1, %xmm0 + movaps %xmm0, output + LKMC_ASSERT_MEMCMP(output, paddq_expect, $0x10) LKMC_EPILOGUE