Merge remote-tracking branch 'remotes/fam/tags/for-upstream' into staging
[qemu.git] / tests / tcg / lm32 / macros.inc
blob360ad53c9fc92ca7c3940f11ac382b0a860ef0d9
2 .equ MAX_TESTNAME_LEN, 32
3 .macro test_name name
4         .data
5 tn_\name:
6         .ascii "\name"
7         .space MAX_TESTNAME_LEN - (. - tn_\name), ' '
8         .text
9         .global \name
10 \name:
11         addi sp, sp, -12
12         sw (sp+4), r1
13         sw (sp+8), r2
14         sw (sp+12), r3
15         mvi r1, 1
16         mvhi r2, hi(tn_\name)
17         ori r2, r2, lo(tn_\name)
18         mvi r3, MAX_TESTNAME_LEN
19         calli _write
20         lw r3, (sp+12)
21         lw r2, (sp+8)
22         lw r1, (sp+4)
23         addi sp, sp, 12
24 .endm
26 .macro load reg val
27         mvhi \reg, hi(\val)
28         ori \reg, \reg, lo(\val)
29 .endm
31 .macro tc_pass
32         calli _tc_pass
33 .endm
35 .macro tc_fail
36         addi r12, r12, 1
37         calli _tc_fail
38 .endm
40 .macro check_r3 val
41         mvhi r13, hi(\val)
42         ori r13, r13, lo(\val)
43         be r3, r13, 1f
44         tc_fail
45         bi 2f
47         tc_pass
49 .endm
51 .macro check_mem adr val
52         mvhi r13, hi(\adr)
53         ori r13, r13, lo(\adr)
54         mvhi r14, hi(\val)
55         ori r14, r14, lo(\val)
56         lw r13, (r13+0)
57         be r13, r14, 1f
58         tc_fail
59         bi 2f
61         tc_pass
63 .endm
65 .macro check_excp excp
66         andi r13, r25, \excp
67         bne r13, r0, 1f
68         tc_fail
69         bi 2f
71         tc_pass
73 .endm
75 .macro start
76         .global _main
77         .text
78 _main:
79         mvi r12, 0
80 .endm
82 .macro end
83         mv r1, r12
84         calli _exit
85 .endm
87 # base +
88 #  0  ctrl
89 #  4  pass/fail
90 #  8  ptr to test name