Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

unittests/ASM: Adds missing unaligned atomic tests #4119

Merged
merged 1 commit into from
Oct 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 52 additions & 0 deletions unittests/ASM/Atomics/adc_atomic16.asm
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
%ifdef CONFIG
{
"RegData": {
"RAX": "0x4242434446464848",
"RBX": "0x4242434445464748",
"RCX": "0x4142434445464748",
"RDX": "0x4142434445464748",
"RSI": "0x4242434445464748",
"RDI": "0x4142434445464748"
}
}
%endif

mov r15, 0xe0000000

mov rax, 0x4142434445464748
mov [r15 + 8 * 0], rax
mov [r15 + 8 * 1], rax
mov [r15 + 8 * 2], rax
mov [r15 + 8 * 3], rax
mov [r15 + 8 * 4], rax
mov [r15 + 8 * 5], rax
mov [r15 + 8 * 6], rax
mov [r15 + 8 * 7], rax
mov [r15 + 8 * 8], rax
mov [r15 + 8 * 9], rax

mov rax, 1

; Test 1 byte offset within 4byte boundary
lock adc word [r15 + 8 * 0 + 1], ax

; Test 3 byte offset across 4byte boundary
lock adc word [r15 + 8 * 0 + 3], ax

; Test 7 byte offset across 8byte boundary
lock adc word [r15 + 8 * 0 + 7], ax

; Test 15 byte offset across 16byte boundary
lock adc word [r15 + 8 * 0 + 15], ax

; Test 63 byte offset across cacheline boundary
lock adc word [r15 + 8 * 0 + 63], ax

mov rax, qword [r15 + 8 * 0]
mov rbx, qword [r15 + 8 * 1]
mov rcx, qword [r15 + 8 * 2]
mov rdx, qword [r15 + 8 * 3]
mov rsi, qword [r15 + 8 * 7]
mov rdi, qword [r15 + 8 * 8]

hlt
49 changes: 49 additions & 0 deletions unittests/ASM/Atomics/adc_atomic32.asm
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
%ifdef CONFIG
{
"RegData": {
"RAX": "0x4242434446464748",
"RBX": "0x4242434445464748",
"RCX": "0x4142434445464748",
"RDX": "0x4142434445464748",
"RSI": "0x4242434445464748",
"RDI": "0x4142434445464748"
}
}
%endif

mov r15, 0xe0000000

mov rax, 0x4142434445464748
mov [r15 + 8 * 0], rax
mov [r15 + 8 * 1], rax
mov [r15 + 8 * 2], rax
mov [r15 + 8 * 3], rax
mov [r15 + 8 * 4], rax
mov [r15 + 8 * 5], rax
mov [r15 + 8 * 6], rax
mov [r15 + 8 * 7], rax
mov [r15 + 8 * 8], rax
mov [r15 + 8 * 9], rax

mov rax, 1

; Test 3 byte offset across 4byte boundary
lock adc dword [r15 + 8 * 0 + 3], eax

; Test 7 byte offset across 8byte boundary
lock adc dword [r15 + 8 * 0 + 7], eax

; Test 15 byte offset across 16byte boundary
lock adc dword [r15 + 8 * 0 + 15], eax

; Test 63 byte offset across cacheline boundary
lock adc dword [r15 + 8 * 0 + 63], eax

mov rax, qword [r15 + 8 * 0]
mov rbx, qword [r15 + 8 * 1]
mov rcx, qword [r15 + 8 * 2]
mov rdx, qword [r15 + 8 * 3]
mov rsi, qword [r15 + 8 * 7]
mov rdi, qword [r15 + 8 * 8]

hlt
46 changes: 46 additions & 0 deletions unittests/ASM/Atomics/adc_atomic64.asm
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
%ifdef CONFIG
{
"RegData": {
"RAX": "0x4242434445464748",
"RBX": "0x4242434445464748",
"RCX": "0x4142434445464748",
"RDX": "0x4142434445464748",
"RSI": "0x4242434445464748",
"RDI": "0x4142434445464748"
}
}
%endif

mov r15, 0xe0000000

mov rax, 0x4142434445464748
mov [r15 + 8 * 0], rax
mov [r15 + 8 * 1], rax
mov [r15 + 8 * 2], rax
mov [r15 + 8 * 3], rax
mov [r15 + 8 * 4], rax
mov [r15 + 8 * 5], rax
mov [r15 + 8 * 6], rax
mov [r15 + 8 * 7], rax
mov [r15 + 8 * 8], rax
mov [r15 + 8 * 9], rax

mov rax, 1

; Test 7 byte offset across 8byte boundary
lock adc qword [r15 + 8 * 0 + 7], rax

; Test 15 byte offset across 16byte boundary
lock adc qword [r15 + 8 * 0 + 15], rax

; Test 63 byte offset across cacheline boundary
lock adc qword [r15 + 8 * 0 + 63], rax

mov rax, qword [r15 + 8 * 0]
mov rbx, qword [r15 + 8 * 1]
mov rcx, qword [r15 + 8 * 2]
mov rdx, qword [r15 + 8 * 3]
mov rsi, qword [r15 + 8 * 7]
mov rdi, qword [r15 + 8 * 8]

hlt
50 changes: 50 additions & 0 deletions unittests/ASM/Atomics/neg_atomic16.asm
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
%ifdef CONFIG
{
"RegData": {
"RAX": "0xbf4243bbbbb9b948",
"RBX": "0xbf424344454647b7",
"RCX": "0x41424344454647b7",
"RDX": "0x4142434445464748",
"RSI": "0xbf42434445464748",
"RDI": "0x41424344454647b7"
}
}
%endif

mov r15, 0xe0000000

mov rax, 0x4142434445464748
mov [r15 + 8 * 0], rax
mov [r15 + 8 * 1], rax
mov [r15 + 8 * 2], rax
mov [r15 + 8 * 3], rax
mov [r15 + 8 * 4], rax
mov [r15 + 8 * 5], rax
mov [r15 + 8 * 6], rax
mov [r15 + 8 * 7], rax
mov [r15 + 8 * 8], rax
mov [r15 + 8 * 9], rax

; Test 1 byte offset within 4byte boundary
lock neg word [r15 + 8 * 0 + 1]

; Test 3 byte offset across 4byte boundary
lock neg word [r15 + 8 * 0 + 3]

; Test 7 byte offset across 8byte boundary
lock neg word [r15 + 8 * 0 + 7]

; Test 15 byte offset across 16byte boundary
lock neg word [r15 + 8 * 0 + 15]

; Test 63 byte offset across cacheline boundary
lock neg word [r15 + 8 * 0 + 63]

mov rax, qword [r15 + 8 * 0]
mov rbx, qword [r15 + 8 * 1]
mov rcx, qword [r15 + 8 * 2]
mov rdx, qword [r15 + 8 * 3]
mov rsi, qword [r15 + 8 * 7]
mov rdi, qword [r15 + 8 * 8]

hlt
47 changes: 47 additions & 0 deletions unittests/ASM/Atomics/neg_atomic32.asm
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
%ifdef CONFIG
{
"RegData": {
"RAX": "0xbfbdbcbbbb464748",
"RBX": "0xbf42434445b9b8b7",
"RCX": "0x4142434445b9b8b7",
"RDX": "0x4142434445464748",
"RSI": "0xbf42434445464748",
"RDI": "0x4142434445b9b8b7"
}
}
%endif

mov r15, 0xe0000000

mov rax, 0x4142434445464748
mov [r15 + 8 * 0], rax
mov [r15 + 8 * 1], rax
mov [r15 + 8 * 2], rax
mov [r15 + 8 * 3], rax
mov [r15 + 8 * 4], rax
mov [r15 + 8 * 5], rax
mov [r15 + 8 * 6], rax
mov [r15 + 8 * 7], rax
mov [r15 + 8 * 8], rax
mov [r15 + 8 * 9], rax

; Test 3 byte offset across 4byte boundary
lock neg dword [r15 + 8 * 0 + 3]

; Test 7 byte offset across 8byte boundary
lock neg dword [r15 + 8 * 0 + 7]

; Test 15 byte offset across 16byte boundary
lock neg dword [r15 + 8 * 0 + 15]

; Test 63 byte offset across cacheline boundary
lock neg dword [r15 + 8 * 0 + 63]

mov rax, qword [r15 + 8 * 0]
mov rbx, qword [r15 + 8 * 1]
mov rcx, qword [r15 + 8 * 2]
mov rdx, qword [r15 + 8 * 3]
mov rsi, qword [r15 + 8 * 7]
mov rdi, qword [r15 + 8 * 8]

hlt
44 changes: 44 additions & 0 deletions unittests/ASM/Atomics/neg_atomic64.asm
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
%ifdef CONFIG
{
"RegData": {
"RAX": "0xbf42434445464748",
"RBX": "0xbfbdbcbbbab9b8b7",
"RCX": "0x41bdbcbbbab9b8b7",
"RDX": "0x4142434445464748",
"RSI": "0xbf42434445464748",
"RDI": "0x41bdbcbbbab9b8b7"
}
}
%endif

mov r15, 0xe0000000

mov rax, 0x4142434445464748
mov [r15 + 8 * 0], rax
mov [r15 + 8 * 1], rax
mov [r15 + 8 * 2], rax
mov [r15 + 8 * 3], rax
mov [r15 + 8 * 4], rax
mov [r15 + 8 * 5], rax
mov [r15 + 8 * 6], rax
mov [r15 + 8 * 7], rax
mov [r15 + 8 * 8], rax
mov [r15 + 8 * 9], rax

; Test 7 byte offset across 8byte boundary
lock neg qword [r15 + 8 * 0 + 7]

; Test 15 byte offset across 16byte boundary
lock neg qword [r15 + 8 * 0 + 15]

; Test 63 byte offset across cacheline boundary
lock neg qword [r15 + 8 * 0 + 63]

mov rax, qword [r15 + 8 * 0]
mov rbx, qword [r15 + 8 * 1]
mov rcx, qword [r15 + 8 * 2]
mov rdx, qword [r15 + 8 * 3]
mov rsi, qword [r15 + 8 * 7]
mov rdi, qword [r15 + 8 * 8]

hlt
50 changes: 50 additions & 0 deletions unittests/ASM/Atomics/not_atomic16.asm
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
%ifdef CONFIG
{
"RegData": {
"RAX": "0xbe4243bbbab9b848",
"RBX": "0xbe424344454647b7",
"RCX": "0x41424344454647b7",
"RDX": "0x4142434445464748",
"RSI": "0xbe42434445464748",
"RDI": "0x41424344454647b7"
}
}
%endif

mov r15, 0xe0000000

mov rax, 0x4142434445464748
mov [r15 + 8 * 0], rax
mov [r15 + 8 * 1], rax
mov [r15 + 8 * 2], rax
mov [r15 + 8 * 3], rax
mov [r15 + 8 * 4], rax
mov [r15 + 8 * 5], rax
mov [r15 + 8 * 6], rax
mov [r15 + 8 * 7], rax
mov [r15 + 8 * 8], rax
mov [r15 + 8 * 9], rax

; Test 1 byte offset within 4byte boundary
lock not word [r15 + 8 * 0 + 1]

; Test 3 byte offset across 4byte boundary
lock not word [r15 + 8 * 0 + 3]

; Test 7 byte offset across 8byte boundary
lock not word [r15 + 8 * 0 + 7]

; Test 15 byte offset across 16byte boundary
lock not word [r15 + 8 * 0 + 15]

; Test 63 byte offset across cacheline boundary
lock not word [r15 + 8 * 0 + 63]

mov rax, qword [r15 + 8 * 0]
mov rbx, qword [r15 + 8 * 1]
mov rcx, qword [r15 + 8 * 2]
mov rdx, qword [r15 + 8 * 3]
mov rsi, qword [r15 + 8 * 7]
mov rdi, qword [r15 + 8 * 8]

hlt
47 changes: 47 additions & 0 deletions unittests/ASM/Atomics/not_atomic32.asm
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
%ifdef CONFIG
{
"RegData": {
"RAX": "0xbebdbcbbba464748",
"RBX": "0xbe42434445b9b8b7",
"RCX": "0x4142434445b9b8b7",
"RDX": "0x4142434445464748",
"RSI": "0xbe42434445464748",
"RDI": "0x4142434445b9b8b7"
}
}
%endif

mov r15, 0xe0000000

mov rax, 0x4142434445464748
mov [r15 + 8 * 0], rax
mov [r15 + 8 * 1], rax
mov [r15 + 8 * 2], rax
mov [r15 + 8 * 3], rax
mov [r15 + 8 * 4], rax
mov [r15 + 8 * 5], rax
mov [r15 + 8 * 6], rax
mov [r15 + 8 * 7], rax
mov [r15 + 8 * 8], rax
mov [r15 + 8 * 9], rax

; Test 3 byte offset across 4byte boundary
lock not dword [r15 + 8 * 0 + 3]

; Test 7 byte offset across 8byte boundary
lock not dword [r15 + 8 * 0 + 7]

; Test 15 byte offset across 16byte boundary
lock not dword [r15 + 8 * 0 + 15]

; Test 63 byte offset across cacheline boundary
lock not dword [r15 + 8 * 0 + 63]

mov rax, qword [r15 + 8 * 0]
mov rbx, qword [r15 + 8 * 1]
mov rcx, qword [r15 + 8 * 2]
mov rdx, qword [r15 + 8 * 3]
mov rsi, qword [r15 + 8 * 7]
mov rdi, qword [r15 + 8 * 8]

hlt
Loading
Loading