1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22#ifndef WRAPPERS_MSA_H
23#define WRAPPERS_MSA_H
24
25
26#define DO_MSA__WD__WS(suffix, mnemonic) \
27static inline void do_msa_##suffix(void *input, void *output) \
28{ \
29 __asm__ volatile ( \
30 "move $t0, %0\n\t" \
31 "ld.d $w11, 0($t0)\n\t" \
32 #mnemonic " $w10, $w11\n\t" \
33 "move $t0, %1\n\t" \
34 "st.d $w10, 0($t0)\n\t" \
35 : \
36 : "r" (input), "r" (output) \
37 : "t0", "memory" \
38 ); \
39}
40
41#define DO_MSA__WD__WD(suffix, mnemonic) \
42static inline void do_msa_##suffix(void *input, void *output) \
43{ \
44 __asm__ volatile ( \
45 "move $t0, %0\n\t" \
46 "ld.d $w11, 0($t0)\n\t" \
47 #mnemonic " $w10, $w10\n\t" \
48 "move $t0, %1\n\t" \
49 "st.d $w10, 0($t0)\n\t" \
50 : \
51 : "r" (input), "r" (output) \
52 : "t0", "memory" \
53 ); \
54}
55
56DO_MSA__WD__WS(NLOC_B, nloc.b)
57DO_MSA__WD__WS(NLOC_H, nloc.h)
58DO_MSA__WD__WS(NLOC_W, nloc.w)
59DO_MSA__WD__WS(NLOC_D, nloc.d)
60
61DO_MSA__WD__WS(NLZC_B, nlzc.b)
62DO_MSA__WD__WS(NLZC_H, nlzc.h)
63DO_MSA__WD__WS(NLZC_W, nlzc.w)
64DO_MSA__WD__WS(NLZC_D, nlzc.d)
65
66DO_MSA__WD__WS(PCNT_B, pcnt.b)
67DO_MSA__WD__WS(PCNT_H, pcnt.h)
68DO_MSA__WD__WS(PCNT_W, pcnt.w)
69DO_MSA__WD__WS(PCNT_D, pcnt.d)
70
71
72#define DO_MSA__WD__WS_WT(suffix, mnemonic) \
73static inline void do_msa_##suffix(void *input1, void *input2, \
74 void *output) \
75{ \
76 __asm__ volatile ( \
77 "move $t0, %0\n\t" \
78 "ld.d $w11, 0($t0)\n\t" \
79 "move $t0, %1\n\t" \
80 "ld.d $w12, 0($t0)\n\t" \
81 #mnemonic " $w10, $w11, $w12\n\t" \
82 "move $t0, %2\n\t" \
83 "st.d $w10, 0($t0)\n\t" \
84 : \
85 : "r" (input1), "r" (input2), "r" (output) \
86 : "t0", "memory" \
87 ); \
88}
89
90#define DO_MSA__WD__WD_WT(suffix, mnemonic) \
91static inline void do_msa_##suffix(void *input1, void *input2, \
92 void *output) \
93{ \
94 __asm__ volatile ( \
95 "move $t0, %0\n\t" \
96 "ld.d $w11, 0($t0)\n\t" \
97 "move $t0, %1\n\t" \
98 "ld.d $w12, 0($t0)\n\t" \
99 #mnemonic " $w10, $w10, $w12\n\t" \
100 "move $t0, %2\n\t" \
101 "st.d $w10, 0($t0)\n\t" \
102 : \
103 : "r" (input1), "r" (input2), "r" (output) \
104 : "t0", "memory" \
105 ); \
106}
107
108#define DO_MSA__WD__WS_WD(suffix, mnemonic) \
109static inline void do_msa_##suffix(void *input1, void *input2, \
110 void *output) \
111{ \
112 __asm__ volatile ( \
113 "move $t0, %0\n\t" \
114 "ld.d $w11, 0($t0)\n\t" \
115 "move $t0, %1\n\t" \
116 "ld.d $w12, 0($t0)\n\t" \
117 #mnemonic " $w10, $w11, $w10\n\t" \
118 "move $t0, %2\n\t" \
119 "st.d $w10, 0($t0)\n\t" \
120 : \
121 : "r" (input1), "r" (input2), "r" (output) \
122 : "t0", "memory" \
123 ); \
124}
125
126DO_MSA__WD__WS_WT(ILVEV_B, ilvev.b)
127DO_MSA__WD__WS_WT(ILVEV_H, ilvev.h)
128DO_MSA__WD__WS_WT(ILVEV_W, ilvev.w)
129DO_MSA__WD__WS_WT(ILVEV_D, ilvev.d)
130
131DO_MSA__WD__WS_WT(ILVOD_B, ilvod.b)
132DO_MSA__WD__WS_WT(ILVOD_H, ilvod.h)
133DO_MSA__WD__WS_WT(ILVOD_W, ilvod.w)
134DO_MSA__WD__WS_WT(ILVOD_D, ilvod.d)
135
136DO_MSA__WD__WS_WT(ILVL_B, ilvl.b)
137DO_MSA__WD__WS_WT(ILVL_H, ilvl.h)
138DO_MSA__WD__WS_WT(ILVL_W, ilvl.w)
139DO_MSA__WD__WS_WT(ILVL_D, ilvl.d)
140
141DO_MSA__WD__WS_WT(ILVR_B, ilvr.b)
142DO_MSA__WD__WS_WT(ILVR_H, ilvr.h)
143DO_MSA__WD__WS_WT(ILVR_W, ilvr.w)
144DO_MSA__WD__WS_WT(ILVR_D, ilvr.d)
145
146DO_MSA__WD__WS_WT(AND_V, and.v)
147DO_MSA__WD__WS_WT(NOR_V, nor.v)
148DO_MSA__WD__WS_WT(OR_V, or.v)
149DO_MSA__WD__WS_WT(XOR_V, xor.v)
150
151DO_MSA__WD__WS_WT(CEQ_B, ceq.b)
152DO_MSA__WD__WS_WT(CEQ_H, ceq.h)
153DO_MSA__WD__WS_WT(CEQ_W, ceq.w)
154DO_MSA__WD__WS_WT(CEQ_D, ceq.d)
155
156DO_MSA__WD__WS_WT(CLE_S_B, cle_s.b)
157DO_MSA__WD__WS_WT(CLE_S_H, cle_s.h)
158DO_MSA__WD__WS_WT(CLE_S_W, cle_s.w)
159DO_MSA__WD__WS_WT(CLE_S_D, cle_s.d)
160
161DO_MSA__WD__WS_WT(CLE_U_B, cle_u.b)
162DO_MSA__WD__WS_WT(CLE_U_H, cle_u.h)
163DO_MSA__WD__WS_WT(CLE_U_W, cle_u.w)
164DO_MSA__WD__WS_WT(CLE_U_D, cle_u.d)
165
166DO_MSA__WD__WS_WT(CLT_S_B, clt_s.b)
167DO_MSA__WD__WS_WT(CLT_S_H, clt_s.h)
168DO_MSA__WD__WS_WT(CLT_S_W, clt_s.w)
169DO_MSA__WD__WS_WT(CLT_S_D, clt_s.d)
170
171DO_MSA__WD__WS_WT(CLT_U_B, clt_u.b)
172DO_MSA__WD__WS_WT(CLT_U_H, clt_u.h)
173DO_MSA__WD__WS_WT(CLT_U_W, clt_u.w)
174DO_MSA__WD__WS_WT(CLT_U_D, clt_u.d)
175
176DO_MSA__WD__WS_WT(MAX_A_B, max_a.b)
177DO_MSA__WD__WS_WT(MAX_A_H, max_a.h)
178DO_MSA__WD__WS_WT(MAX_A_W, max_a.w)
179DO_MSA__WD__WS_WT(MAX_A_D, max_a.d)
180
181DO_MSA__WD__WS_WT(MIN_A_B, min_a.b)
182DO_MSA__WD__WS_WT(MIN_A_H, min_a.h)
183DO_MSA__WD__WS_WT(MIN_A_W, min_a.w)
184DO_MSA__WD__WS_WT(MIN_A_D, min_a.d)
185
186DO_MSA__WD__WS_WT(MAX_S_B, max_s.b)
187DO_MSA__WD__WS_WT(MAX_S_H, max_s.h)
188DO_MSA__WD__WS_WT(MAX_S_W, max_s.w)
189DO_MSA__WD__WS_WT(MAX_S_D, max_s.d)
190
191DO_MSA__WD__WS_WT(MIN_S_B, min_s.b)
192DO_MSA__WD__WS_WT(MIN_S_H, min_s.h)
193DO_MSA__WD__WS_WT(MIN_S_W, min_s.w)
194DO_MSA__WD__WS_WT(MIN_S_D, min_s.d)
195
196DO_MSA__WD__WS_WT(MAX_U_B, max_u.b)
197DO_MSA__WD__WS_WT(MAX_U_H, max_u.h)
198DO_MSA__WD__WS_WT(MAX_U_W, max_u.w)
199DO_MSA__WD__WS_WT(MAX_U_D, max_u.d)
200
201DO_MSA__WD__WS_WT(MIN_U_B, min_u.b)
202DO_MSA__WD__WS_WT(MIN_U_H, min_u.h)
203DO_MSA__WD__WS_WT(MIN_U_W, min_u.w)
204DO_MSA__WD__WS_WT(MIN_U_D, min_u.d)
205
206DO_MSA__WD__WS_WT(BCLR_B, bclr.b)
207DO_MSA__WD__WS_WT(BCLR_H, bclr.h)
208DO_MSA__WD__WS_WT(BCLR_W, bclr.w)
209DO_MSA__WD__WS_WT(BCLR_D, bclr.d)
210
211DO_MSA__WD__WS_WT(BSET_B, bset.b)
212DO_MSA__WD__WS_WT(BSET_H, bset.h)
213DO_MSA__WD__WS_WT(BSET_W, bset.w)
214DO_MSA__WD__WS_WT(BSET_D, bset.d)
215
216DO_MSA__WD__WS_WT(BNEG_B, bneg.b)
217DO_MSA__WD__WS_WT(BNEG_H, bneg.h)
218DO_MSA__WD__WS_WT(BNEG_W, bneg.w)
219DO_MSA__WD__WS_WT(BNEG_D, bneg.d)
220
221DO_MSA__WD__WS_WT(PCKEV_B, pckev.b)
222DO_MSA__WD__WS_WT(PCKEV_H, pckev.h)
223DO_MSA__WD__WS_WT(PCKEV_W, pckev.w)
224DO_MSA__WD__WS_WT(PCKEV_D, pckev.d)
225
226DO_MSA__WD__WS_WT(PCKOD_B, pckod.b)
227DO_MSA__WD__WS_WT(PCKOD_H, pckod.h)
228DO_MSA__WD__WS_WT(PCKOD_W, pckod.w)
229DO_MSA__WD__WS_WT(PCKOD_D, pckod.d)
230
231DO_MSA__WD__WS_WT(VSHF_B, vshf.b)
232DO_MSA__WD__WS_WT(VSHF_H, vshf.h)
233DO_MSA__WD__WS_WT(VSHF_W, vshf.w)
234DO_MSA__WD__WS_WT(VSHF_D, vshf.d)
235
236DO_MSA__WD__WS_WT(SLL_B, sll.b)
237DO_MSA__WD__WS_WT(SLL_H, sll.h)
238DO_MSA__WD__WS_WT(SLL_W, sll.w)
239DO_MSA__WD__WS_WT(SLL_D, sll.d)
240
241DO_MSA__WD__WS_WT(SRA_B, sra.b)
242DO_MSA__WD__WS_WT(SRA_H, sra.h)
243DO_MSA__WD__WS_WT(SRA_W, sra.w)
244DO_MSA__WD__WS_WT(SRA_D, sra.d)
245
246DO_MSA__WD__WS_WT(SRAR_B, srar.b)
247DO_MSA__WD__WS_WT(SRAR_H, srar.h)
248DO_MSA__WD__WS_WT(SRAR_W, srar.w)
249DO_MSA__WD__WS_WT(SRAR_D, srar.d)
250
251DO_MSA__WD__WS_WT(SRL_B, srl.b)
252DO_MSA__WD__WS_WT(SRL_H, srl.h)
253DO_MSA__WD__WS_WT(SRL_W, srl.w)
254DO_MSA__WD__WS_WT(SRL_D, srl.d)
255
256DO_MSA__WD__WS_WT(SRLR_B, srlr.b)
257DO_MSA__WD__WS_WT(SRLR_H, srlr.h)
258DO_MSA__WD__WS_WT(SRLR_W, srlr.w)
259DO_MSA__WD__WS_WT(SRLR_D, srlr.d)
260
261DO_MSA__WD__WS_WT(BMNZ_V, bmnz.v)
262DO_MSA__WD__WS_WT(BMZ_V, bmz.v)
263
264DO_MSA__WD__WS_WT(FMAX_W, fmax.w)
265DO_MSA__WD__WS_WT(FMAX_D, fmax.d)
266
267DO_MSA__WD__WS_WT(FMAX_A_W, fmax_a.w)
268DO_MSA__WD__WS_WT(FMAX_A_D, fmax_a.d)
269
270DO_MSA__WD__WS_WT(FMIN_W, fmin.w)
271DO_MSA__WD__WS_WT(FMIN_D, fmin.d)
272
273DO_MSA__WD__WS_WT(FMIN_A_W, fmin_a.w)
274DO_MSA__WD__WS_WT(FMIN_A_D, fmin_a.d)
275
276
277#endif
278