mirror of
https://github.com/cirosantilli/linux-kernel-module-cheat.git
synced 2026-01-25 03:01:36 +01:00
x86: paddq
This commit is contained in:
25
README.adoc
25
README.adoc
@@ -11493,7 +11493,7 @@ One "downside" of glibc is that it exercises much more kernel functionality on i
|
||||
|
||||
== C
|
||||
|
||||
Programs under link:userland/c/[] are examples of link:https://en.wikipedia.org/wiki/ANSI_C[ANSI C] programming.
|
||||
Programs under link:userland/c/[] are examples of link:https://en.wikipedia.org/wiki/ANSI_C[ANSI C] programming:
|
||||
|
||||
* Standard library
|
||||
** assert.h
|
||||
@@ -11541,19 +11541,19 @@ What is POSIX:
|
||||
|
||||
== Userland assembly
|
||||
|
||||
Programs under `userland/arch/<arch>/` are examples of userland assembly programming:
|
||||
Programs under `userland/arch/<arch>/` are examples of userland assembly programming.
|
||||
|
||||
* link:userland/arch/x86_64/[] moved from: https://github.com/cirosantilli/x86-assembly-cheat
|
||||
* link:userland/arch/arm/[] moved from: https://github.com/cirosantilli/arm-assembly-cheat
|
||||
* link:userland/arch/aarch64/[] moved from: https://github.com/cirosantilli/arm-assembly-cheat
|
||||
This section will document ISA agnostic concepts.
|
||||
|
||||
ISA specifics are covered at:
|
||||
|
||||
* <<x86-userland-assembly>> under link:userland/arch/x86_64/[], originally migrated from: https://github.com/cirosantilli/x86-assembly-cheat
|
||||
* <<arm-userland-assembly>> under originally migrated from https://github.com/cirosantilli/arm-assembly-cheat under:
|
||||
** link:userland/arch/arm/[]
|
||||
** link:userland/arch/aarch64/[]
|
||||
|
||||
Like other userland programs, these programs can be run as explained at: <<userland-setup>>.
|
||||
|
||||
This section will document ISA generic ideas. ISA specifics are documented on the following sections:
|
||||
|
||||
* <<x86-userland-assembly>>
|
||||
* <<arm-userland-assembly>>
|
||||
|
||||
The first example that you want to run for each arch is:
|
||||
|
||||
....
|
||||
@@ -11836,7 +11836,10 @@ Once those are done, everything else left on userland is just to learn a huge li
|
||||
|
||||
=== x86 userland assembly instructions
|
||||
|
||||
TODO
|
||||
==== x86 SIMD
|
||||
|
||||
* SVE2
|
||||
** link:userland/arch/x86_64/paddq.S[]
|
||||
|
||||
=== rdtsc
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ ENTRY
|
||||
.data
|
||||
u32_0: .word 0xF111F111, 0xF222F222, 0xF333F333, 0xF444F444
|
||||
u32_1: .word 0x15551555, 0x16661666, 0x17771777, 0x18881888
|
||||
u32_sum_expect: .word 0x06670666, 0x08890888, 0x0AAB0AAA, 0x0CCD0CCC
|
||||
u32_sum_expect: .word 0x06670666, 0x08890889, 0x0AAB0AAA, 0x0CCD0CCC
|
||||
.bss
|
||||
u32_sum: .skip 16
|
||||
.text
|
||||
|
||||
@@ -39,7 +39,7 @@ int assert_memcmp(const void *s1, const void *s2, size_t n) {
|
||||
printf(
|
||||
"%s failed: "
|
||||
"byte1, byte2, index: "
|
||||
"0x%02" PRIX8 " 0x%02" PRIX8 " 0x%zx\n",
|
||||
"0x%02" PRIX8 " 0x%02" PRIX8 " 0x%zX\n",
|
||||
__func__,
|
||||
b1,
|
||||
b2,
|
||||
|
||||
21
userland/arch/x86_64/paddq.S
Normal file
21
userland/arch/x86_64/paddq.S
Normal file
@@ -0,0 +1,21 @@
|
||||
/* https://github.com/cirosantilli/linux-kernel-module-cheat#x86-simd
|
||||
*
|
||||
* Add 4 32-bit integeres in one go.
|
||||
*/
|
||||
|
||||
#include "common.h"
|
||||
|
||||
ENTRY
|
||||
.data
|
||||
u32_0: .long 0xF111F111, 0xF222F222, 0xF333F333, 0xF444F444
|
||||
u32_1: .long 0x15551555, 0x16661666, 0x17771777, 0x18881888
|
||||
u32_expect: .long 0x06670666, 0x08890889, 0x0AAB0AAA, 0x0CCD0CCD
|
||||
.bss
|
||||
u32_result: .skip 16
|
||||
.text
|
||||
movups u32_0, %xmm0
|
||||
movups u32_1, %xmm1
|
||||
paddq %xmm1, %xmm0
|
||||
movups %xmm0, u32_result
|
||||
ASSERT_MEMCMP(u32_result, u32_expect, $0x10)
|
||||
EXIT
|
||||
Reference in New Issue
Block a user