add a thp-based huge page alloc fallback
[pcsx_rearmed.git] / deps / lightning / check / bswap.tst
CommitLineData
40a44dcb
PC
1.data 16
2ok:
3.c "ok\n"
4
5#define us12_i 0x1234
6#define us7f_i 0x7ff7
7#define us80_i 0x8008
8#define usff_i 0xffff
9#define ui12_i 0x01234567
10#define ui7f_i 0x7f7ff7f7
11#define ui80_i 0x80800808
12#define uiff_i 0xffffffff
13#define ul12_i 0x0123456789abcdef
14#define ul7f_i 0x7f7f7f7ff7f7f7f7
15#define ul80_i 0x8080808008080808
16#define ulff_i 0xffffffffffffffff
17
18#if __WORDSIZE == 32
19# define xus12_i 0xffff1234
20# define xus7f_i 0x10107ff7
21# define xus80_i 0x81188008
22# define xusff_i 0xeaaeffff
23#else
24# define xus12_i 0xffffffffffff1234
25# define xus7f_i 0x1010100101017ff7
26# define xus80_i 0x8181811818818008
27# define xusff_i 0xeaeaeaaeaeaeffff
28# define xui12_i 0xffffffff01234567
29# define xui7f_i 0x101001017f7ff7f7
30# define xui80_i 0x8181181880800808
31# define xuiff_i 0xeaeaaeaeffffffff
32#endif
33
34# define us12_o 0x3412
35# define us7f_o 0xf77f
36# define us80_o 0x0880
37# define usff_o 0xffff
38# define ui12_o 0x67452301
39# define ui7f_o 0xf7f77f7f
40# define ui80_o 0x08088080
41# define uiff_o 0xffffffff
42# define ul12_o 0xefcdab8967452301
43# define ul7f_o 0xf7f7f7f77f7f7f7f
44# define ul80_o 0x0808080880808080
45# define ulff_o 0xffffffffffffffff
46
47#define BSWAP4(I, O, T, R0, R1) \
48 movi %R0 I \
49 bswapr_##T %R1 %R0 \
50 beqi T##R0##R1##I %R1 O \
51 calli @abort \
52T##R0##R1##I:
53
54#define BSWAP3(T, R0, R1) \
55 BSWAP4(T##12_i, T##12_o, T, R0, R1) \
56 BSWAP4(x##T##12_i, T##12_o, T, R0, R1) \
57 BSWAP4(T##7f_i, T##7f_o, T, R0, R1) \
58 BSWAP4(x##T##7f_i, T##7f_o, T, R0, R1) \
59 BSWAP4(T##80_i, T##80_o, T, R0, R1) \
60 BSWAP4(x##T##80_i, T##80_o, T, R0, R1) \
61 BSWAP4(T##ff_i, T##ff_o, T, R0, R1) \
62 BSWAP4(x##T##ff_i, T##ff_o, T, R0, R1)
63
64#define BSWAP3x(T, R0, R1) \
65 BSWAP4(T##12_i, T##12_o, T, R0, R1) \
66 BSWAP4(T##7f_i, T##7f_o, T, R0, R1) \
67 BSWAP4(T##80_i, T##80_o, T, R0, R1) \
68 BSWAP4(T##ff_i, T##ff_o, T, R0, R1)
69
70#define BSWAP2(T, V0, V1, V2, R0, R1, R2) \
71 BSWAP3(T, V0, V0) \
72 BSWAP3(T, V0, V1) \
73 BSWAP3(T, V0, V2) \
74 BSWAP3(T, V0, R0) \
75 BSWAP3(T, V0, R1) \
76 BSWAP3(T, V0, R2) \
77
78#define BSWAP2x(T, V0, V1, V2, R0, R1, R2) \
79 BSWAP3x(T, V0, V0) \
80 BSWAP3x(T, V0, V1) \
81 BSWAP3x(T, V0, V2) \
82 BSWAP3x(T, V0, R0) \
83 BSWAP3x(T, V0, R1) \
84 BSWAP3x(T, V0, R2) \
85
86#define BSWAP1(T, V0, V1, V2, R0, R1, R2) \
87 BSWAP2(T, V0, V1, V2, R0, R1, R2) \
88 BSWAP2(T, V1, V2, R0, R1, R2, V0) \
89 BSWAP2(T, V2, R0, R1, R2, V0, V1) \
90 BSWAP2(T, R0, R1, R2, V0, V1, V2) \
91 BSWAP2(T, R1, R2, V0, V1, V2, R0) \
92 BSWAP2(T, R2, V0, V1, V2, R0, R1)
93
94#define BSWAP1x(T, V0, V1, V2, R0, R1, R2) \
95 BSWAP2x(T, V0, V1, V2, R0, R1, R2) \
96 BSWAP2x(T, V1, V2, R0, R1, R2, V0) \
97 BSWAP2x(T, V2, R0, R1, R2, V0, V1) \
98 BSWAP2x(T, R0, R1, R2, V0, V1, V2) \
99 BSWAP2x(T, R1, R2, V0, V1, V2, R0) \
100 BSWAP2x(T, R2, V0, V1, V2, R0, R1)
101
102#if __WORDSIZE == 32
103# define BSWAP(V0, V1, V2, R0, R1, R2) \
104 BSWAP1(us, V0, V1, V2, R0, R1, R2) \
105 BSWAP1x(ui, V0, V1, V2, R0, R1, R2)
106#else
107# define BSWAP(V0, V1, V2, R0, R1, R2) \
108 BSWAP1(us, V0, V1, V2, R0, R1, R2) \
109 BSWAP1(ui, V0, V1, V2, R0, R1, R2) \
110 BSWAP1x(ul, V0, V1, V2, R0, R1, R2)
111#endif
112
113.code
114 prolog
115 /* simple sequence for easier disassembly reading and encoding check */
116 movi %r0 us12_i
117 bswapr_us %r1 %r0
118 beqi us %r1 us12_o
119 calli @abort
120us:
121
122 movi %r0 xus12_i
123 bswapr_us %r1 %r0
124 beqi xus %r1 us12_o
125 calli @abort
126xus:
127 movi %r0 ui12_i
128 bswapr_ui %r1 %r0
129 beqi ui %r1 ui12_o
130 calli @abort
131ui:
132#if __WORDSIZE == 64
133 movi %r0 xui12_i
134 bswapr_ui %r1 %r0
135 beqi xui %r1 ui12_o
136 calli @abort
137xui:
138 movi %r0 ul12_i
139 bswapr_ul %r1 %r0
140 beqi ul %r1 ul12_o
141 calli @abort
142ul:
143#endif
144
145 BSWAP(v0, v1, v2, r0, r1, r2)
146
147 // just to know did not abort
148 prepare
149 pushargi ok
150 ellipsis
151 finishi @printf
152
153 ret
154 epilog