xref: /openbmc/qemu/tests/tcg/xtensa/macros.inc (revision d6032e06)
1#include "core-isa.h"
2
3.macro test_suite name
4.data
5status: .word result
6result: .space 256
7.text
8.global main
9.align 4
10main:
11.endm
12
13.macro reset_ps
14    movi    a2, 0x4000f
15    wsr     a2, ps
16    isync
17.endm
18
19.macro test_suite_end
20    reset_ps
21    movi    a0, status
22    l32i    a2, a0, 0
23    movi    a0, result
24    sub     a2, a2, a0
25    movi    a3, 0
26    loopnez a2, 1f
27    l8ui    a2, a0, 0
28    or      a3, a3, a2
29    addi    a0, a0, 1
301:
31    exit
32.endm
33
34.macro print text
35.data
3697: .ascii "\text\n"
3798:
38    .align 4
39.text
40    movi    a2, 4
41    movi    a3, 2
42    movi    a4, 97b
43    movi    a5, 98b
44    sub     a5, a5, a4
45    simcall
46.endm
47
48.macro test_init
49.endm
50
51.macro test name
52    //print test_\name
53    test_init
54test_\name:
55.global test_\name
56.endm
57
58.macro test_end
5999:
60    reset_ps
61    movi    a2, status
62    l32i    a3, a2, 0
63    addi    a3, a3, 1
64    s32i    a3, a2, 0
65.endm
66
67.macro exit
68    movi    a2, 1
69    simcall
70.endm
71
72.macro test_fail
73    movi    a2, status
74    l32i    a2, a2, 0
75    movi    a3, 1
76    s8i     a3, a2, 0
77    j       99f
78.endm
79
80.macro assert cond, arg1, arg2
81    b\cond  \arg1, \arg2, 90f
82    test_fail
8390:
84    nop
85.endm
86
87.macro set_vector vector, addr
88    movi    a2, handler_\vector
89    movi    a3, \addr
90    s32i    a3, a2, 0
91.endm
92