Commit 98a5eddf authored by Martin Storsjö's avatar Martin Storsjö
Browse files

WIP: arm: Add helpers for debug printing from assembly

These currently print GPRs, and print SIMD registers as s16, and
prints generic memory addresses as s16 vectors.
parent 185194be
Pipeline #104816 passed with stages
in 7 minutes and 13 seconds
......@@ -181,4 +181,47 @@
vtrn.16 \r2, \r3
.endm
.macro call_c func, line, msg, first, last, ptr, offset
push {lr}
mov lr, sp
push {lr}
push {r0-r12}
mrs lr, cpsr
push {lr}
vpush {d16-d31}
vpush {d0-d15}
add r0, \ptr, #\offset
push {r0}
ldr r0, =\line
adr r1, 777f
mov r2, \first
mov r3, \last
bl X(\func)
pop {r0}
vpop {d0-d15}
vpop {d16-d31}
pop {lr}
msr cpsr, lr
pop {r0-r12}
add sp, sp, #4
pop {lr}
.endm
#define CALL_C(func, msg, first, last, ptr, offset) \
call_c func, __LINE__, msg, first, last, ptr, offset; \
b 778f; \
777: \
.asciz msg; \
.align 2; \
.ltorg; \
778:
#define DUMP_SIMD_S8(msg, first, last) CALL_C(dump_simd_s8, msg, first, last, sp, 0)
#define DUMP_SIMD_U8(msg, first, last) CALL_C(dump_simd_u8, msg, first, last, sp, 0)
#define DUMP_SIMD_S16(msg, first, last) CALL_C(dump_simd_s16, msg, first, last, sp, 0)
#define DUMP_SIMD_U16(msg, first, last) CALL_C(dump_simd_u16, msg, first, last, sp, 0)
#define DUMP_SIMD_S32(msg, first, last) CALL_C(dump_simd_s32, msg, first, last, sp, 0)
#define DUMP_MEM_S16(msg, reg, n) CALL_C(dump_simd_s16, msg, 0, n-1, reg, 0)
#define DUMP_GPR(msg, first, last) CALL_C(dump_gpr, msg, first, last, sp, 260)
#endif /* DAV1D_SRC_ARM_32_UTIL_S */
......@@ -226,4 +226,100 @@
trn2 \r3\().4s, \t5\().4s, \t7\().4s
.endm
#undef x18
.macro call_c func, line, msg, first, last, ptr, offset
stp x29, x30, [sp, #-16]!
stp x27, x28, [sp, #-16]!
stp x25, x26, [sp, #-16]!
stp x23, x24, [sp, #-16]!
stp x21, x22, [sp, #-16]!
stp x19, x20, [sp, #-16]!
stp x17, x18, [sp, #-16]!
stp x15, x16, [sp, #-16]!
stp x13, x14, [sp, #-16]!
stp x11, x12, [sp, #-16]!
stp x9, x10, [sp, #-16]!
stp x7, x8, [sp, #-16]!
stp x5, x6, [sp, #-16]!
stp x3, x4, [sp, #-16]!
stp x1, x2, [sp, #-16]!
mrs x30, nzcv
stp x30, x0, [sp, #-16]!
stp q30, q31, [sp, #-32]!
stp q28, q29, [sp, #-32]!
stp q26, q27, [sp, #-32]!
stp q24, q25, [sp, #-32]!
stp q22, q23, [sp, #-32]!
stp q20, q21, [sp, #-32]!
stp q18, q19, [sp, #-32]!
stp q16, q17, [sp, #-32]!
stp q14, q15, [sp, #-32]!
stp q12, q13, [sp, #-32]!
stp q10, q11, [sp, #-32]!
stp q8, q9, [sp, #-32]!
stp q6, q7, [sp, #-32]!
stp q4, q5, [sp, #-32]!
stp q2, q3, [sp, #-32]!
stp q0, q1, [sp, #-32]!
add x4, \ptr, #\offset
ldr x0, =\line
adr x1, 777f
mov x2, \first
mov x3, \last
bl X(\func)
ldp q0, q1, [sp], #32
ldp q2, q3, [sp], #32
ldp q4, q5, [sp], #32
ldp q6, q7, [sp], #32
ldp q8, q9, [sp], #32
ldp q10, q11, [sp], #32
ldp q12, q13, [sp], #32
ldp q14, q15, [sp], #32
ldp q16, q17, [sp], #32
ldp q18, q19, [sp], #32
ldp q20, q21, [sp], #32
ldp q22, q23, [sp], #32
ldp q24, q25, [sp], #32
ldp q26, q27, [sp], #32
ldp q28, q29, [sp], #32
ldp q30, q31, [sp], #32
ldp x30, x0, [sp], #16
msr nzcv, x30
ldp x1, x2, [sp], #16
ldp x3, x4, [sp], #16
ldp x5, x6, [sp], #16
ldp x7, x8, [sp], #16
ldp x9, x10, [sp], #16
ldp x11, x12, [sp], #16
ldp x13, x14, [sp], #16
ldp x15, x16, [sp], #16
ldp x17, x18, [sp], #16
ldp x19, x20, [sp], #16
ldp x21, x22, [sp], #16
ldp x23, x24, [sp], #16
ldp x25, x26, [sp], #16
ldp x27, x28, [sp], #16
ldp x29, x30, [sp], #16
.endm
#define CALL_C(func, msg, first, last, ptr, offset) \
call_c func, __LINE__, msg, first, last, ptr, offset; \
b 778f; \
777: \
.asciz msg; \
.align 2; \
778:
#define DUMP_SIMD_S8(msg, first, last) CALL_C(dump_simd_s8, msg, first, last, sp, 0)
#define DUMP_SIMD_U8(msg, first, last) CALL_C(dump_simd_u8, msg, first, last, sp, 0)
#define DUMP_SIMD_S16(msg, first, last) CALL_C(dump_simd_s16, msg, first, last, sp, 0)
#define DUMP_SIMD_U16(msg, first, last) CALL_C(dump_simd_u16, msg, first, last, sp, 0)
#define DUMP_SIMD_S32(msg, first, last) CALL_C(dump_simd_s32, msg, first, last, sp, 0)
#define DUMP_MEM_S16(msg, reg, n) CALL_C(dump_simd_s16, msg, 0, n-1, reg, 0)
#define DUMP_GPR(msg, first, last) CALL_C(dump_gpr, msg, first, last, sp, 520)
#endif /* DAV1D_SRC_ARM_64_UTIL_S */
......@@ -29,6 +29,7 @@
#include "vcs_version.h"
#include <errno.h>
#include <inttypes.h>
#include <string.h>
#if defined(__linux__) && defined(HAVE_DLSYM)
......@@ -732,3 +733,134 @@ int dav1d_data_wrap_user_data(Dav1dData *const buf,
void dav1d_data_unref(Dav1dData *const buf) {
dav1d_data_unref_internal(buf);
}
void dav1d_dump_simd_s8(int line, const char *msg, int first, int last, const int8_t *ptr);
void dav1d_dump_simd_s8(int line, const char *msg, int first, int last, const int8_t *ptr) {
printf("%d: %s:\n", line, msg);
#ifdef __aarch64__
for (int v = first; v <= last; v++) {
const int8_t *vec = &ptr[16*v];
printf("v%02d = {", v);
for (int i = 0; i < 16; i++)
printf("%s %d", i > 0 ? "," : "", vec[i]);
printf(" }\n");
}
#elif defined(__arm__)
for (int v = first; v <= last; v++) {
const int8_t *vec = &ptr[8*v];
printf("d%02d = {", v);
for (int i = 0; i < 8; i++)
printf("%s %d", i > 0 ? "," : "", vec[i]);
printf(" }\n");
}
#endif
fflush(stdout);
}
void dav1d_dump_simd_u8(int line, const char *msg, int first, int last, const uint8_t *ptr);
void dav1d_dump_simd_u8(int line, const char *msg, int first, int last, const uint8_t *ptr) {
printf("%d: %s:\n", line, msg);
#ifdef __aarch64__
for (int v = first; v <= last; v++) {
const uint8_t *vec = &ptr[16*v];
printf("v%02d = {", v);
for (int i = 0; i < 16; i++)
printf("%s %d", i > 0 ? "," : "", vec[i]);
printf(" }\n");
}
#elif defined(__arm__)
for (int v = first; v <= last; v++) {
const uint8_t *vec = &ptr[8*v];
printf("d%02d = {", v);
for (int i = 0; i < 8; i++)
printf("%s %d", i > 0 ? "," : "", vec[i]);
printf(" }\n");
}
#endif
fflush(stdout);
}
void dav1d_dump_simd_s16(int line, const char *msg, int first, int last, const int16_t *ptr);
void dav1d_dump_simd_s16(int line, const char *msg, int first, int last, const int16_t *ptr) {
printf("%d: %s:\n", line, msg);
#ifdef __aarch64__
for (int v = first; v <= last; v++) {
const int16_t *vec = &ptr[8*v];
printf("v%02d = {", v);
for (int i = 0; i < 8; i++)
printf("%s %d", i > 0 ? "," : "", vec[i]);
printf(" }\n");
}
#elif defined(__arm__)
for (int v = first; v <= last; v++) {
const int16_t *vec = &ptr[4*v];
printf("d%02d = {", v);
for (int i = 0; i < 4; i++)
printf("%s %d", i > 0 ? "," : "", vec[i]);
printf(" }\n");
}
#endif
fflush(stdout);
}
void dav1d_dump_simd_u16(int line, const char *msg, int first, int last, const uint16_t *ptr);
void dav1d_dump_simd_u16(int line, const char *msg, int first, int last, const uint16_t *ptr) {
printf("%d: %s:\n", line, msg);
#ifdef __aarch64__
for (int v = first; v <= last; v++) {
const uint16_t *vec = &ptr[8*v];
printf("v%02d = {", v);
for (int i = 0; i < 8; i++)
printf("%s %d", i > 0 ? "," : "", vec[i]);
printf(" }\n");
}
#elif defined(__arm__)
for (int v = first; v <= last; v++) {
const uint16_t *vec = &ptr[4*v];
printf("d%02d = {", v);
for (int i = 0; i < 4; i++)
printf("%s %d", i > 0 ? "," : "", vec[i]);
printf(" }\n");
}
#endif
fflush(stdout);
}
void dav1d_dump_simd_s32(int line, const char *msg, int first, int last, const int32_t *ptr);
void dav1d_dump_simd_s32(int line, const char *msg, int first, int last, const int32_t *ptr) {
printf("%d: %s:\n", line, msg);
#ifdef __aarch64__
for (int v = first; v <= last; v++) {
const int32_t *vec = &ptr[4*v];
printf("v%02d = {", v);
for (int i = 0; i < 4; i++)
printf("%s %d", i > 0 ? "," : "", vec[i]);
printf(" }\n");
}
#elif defined(__arm__)
for (int v = first; v <= last; v++) {
const int32_t *vec = &ptr[2*v];
printf("d%02d = {", v);
for (int i = 0; i < 2; i++)
printf("%s %d", i > 0 ? "," : "", vec[i]);
printf(" }\n");
}
#endif
fflush(stdout);
}
void dav1d_dump_gpr(int line, const char *msg, int first, int last, const size_t *ptr);
void dav1d_dump_gpr(int line, const char *msg, int first, int last, const size_t *ptr) {
printf("%d: %s:\n", line, msg);
#ifdef __aarch64__
for (int r = first; r <= last; r++)
printf("x%02d = %"PRIx64"\n", r, (uint64_t) ptr[r]);
#elif defined(__arm__)
for (int r = first; r <= last; r++)
if (r < 13)
printf("r%02d = %"PRIx32"\n", r, (uint32_t) ptr[r]);
else
printf("%s = %"PRIx32"\n", r == 13 ? "sp" : "lr", (uint32_t) ptr[r]);
#endif
fflush(stdout);
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment