mirror of
https://github.com/cirosantilli/linux-kernel-module-cheat.git
synced 2026-01-23 02:05:57 +01:00
x86 asm: expand macros in the most basic SIMD examples
Make it easier on the newbs I guess.
This commit is contained in:
@@ -18,16 +18,17 @@ LKMC_PROLOGUE
|
|||||||
.align 16
|
.align 16
|
||||||
output: .skip 16
|
output: .skip 16
|
||||||
.text
|
.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 */
|
/* 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 */
|
/* 2x 64-bit */
|
||||||
TEST(d)
|
movaps addpd_input0, %xmm0
|
||||||
#undef TEST
|
movaps addpd_input1, %xmm1
|
||||||
|
addpd %xmm1, %xmm0
|
||||||
|
movaps %xmm0, output
|
||||||
|
LKMC_ASSERT_MEMCMP(output, addpd_expect, $0x10)
|
||||||
LKMC_EPILOGUE
|
LKMC_EPILOGUE
|
||||||
|
|||||||
@@ -22,19 +22,28 @@ LKMC_PROLOGUE
|
|||||||
output: .skip 16
|
output: .skip 16
|
||||||
.text
|
.text
|
||||||
movaps input1, %xmm1
|
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 */
|
/* 16x 8bit */
|
||||||
TEST(b)
|
movaps input0, %xmm0
|
||||||
/* 8x 4-bit */
|
paddb %xmm1, %xmm0
|
||||||
TEST(w)
|
movaps %xmm0, output
|
||||||
/* 4x 8-bit */
|
LKMC_ASSERT_MEMCMP(output, paddb_expect, $0x10)
|
||||||
TEST(d)
|
|
||||||
/* 2x 16-bit */
|
/* 8x 16-bit */
|
||||||
TEST(q)
|
movaps input0, %xmm0
|
||||||
#undef TEST
|
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
|
LKMC_EPILOGUE
|
||||||
|
|||||||
Reference in New Issue
Block a user