xref: /openbmc/qemu/tests/tcg/xtensa/test_sar.S (revision 09a274d8)
1#include "macros.inc"
2
3test_suite sar
4
5.macro test_sar prefix, imm
6    \prefix\()_set \imm
7    \prefix\()_ver \imm
8.endm
9
10.macro tests_sar prefix
11    test_sar \prefix, 0
12    test_sar \prefix, 1
13    test_sar \prefix, 2
14    test_sar \prefix, 3
15    test_sar \prefix, 0x1f
16    test_sar \prefix, 0x20
17    test_sar \prefix, 0x3f
18    test_sar \prefix, 0x40
19    test_sar \prefix, 0xfffffffe
20.endm
21
22.macro sar_set imm
23    movi    a2, \imm
24    wsr     a2, sar
25.endm
26
27.macro sar_ver imm
28    rsr     a3, sar
29    movi    a2, \imm & 0x3f
30    assert  eq, a2, a3
31.endm
32
33test sar
34    tests_sar sar
35test_end
36
37.macro ssr_set imm
38    movi    a2, \imm
39    ssr     a2
40.endm
41
42.macro ssr_ver imm
43    rsr     a3, sar
44    movi    a2, \imm & 0x1f
45    assert  eq, a2, a3
46.endm
47
48test ssr
49    tests_sar ssr
50test_end
51
52.macro ssl_set imm
53    movi    a2, \imm
54    ssl     a2
55.endm
56
57.macro ssl_ver imm
58    rsr     a3, sar
59    movi    a2, 32 - (\imm & 0x1f)
60    assert  eq, a2, a3
61.endm
62
63test ssl
64    tests_sar ssl
65test_end
66
67.macro ssa8l_set imm
68    movi    a2, \imm
69    ssa8l   a2
70.endm
71
72.macro ssa8l_ver imm
73    rsr     a3, sar
74    movi    a2, (\imm & 0x3) << 3
75    assert  eq, a2, a3
76.endm
77
78test ssa8l
79    tests_sar ssa8l
80test_end
81
82.macro ssa8b_set imm
83    movi    a2, \imm
84    ssa8b   a2
85.endm
86
87.macro ssa8b_ver imm
88    rsr     a3, sar
89    movi    a2, 32 - ((\imm & 0x3) << 3)
90    assert  eq, a2, a3
91.endm
92
93test ssa8b
94    tests_sar ssa8b
95test_end
96
97.macro ssai_set imm
98    ssai    \imm & 0x1f
99.endm
100
101.macro ssai_ver imm
102    rsr     a3, sar
103    movi    a2, \imm & 0x1f
104    assert  eq, a2, a3
105.endm
106
107test ssai
108    tests_sar ssai
109test_end
110
111test_suite_end
112