Skip to content

Commit 2d3e837

Browse files
committed
Auto merge of #28079 - huonw:simd, r=alexcrichton
This adds a new Python script (compatible with 2.7 and 3.x) that will consume some JSON files that define a platform's intrinsics. It can output a file that defines the intrinsics in the compiler, or an `extern` block that will import them. The complexity of the generator is to be DRY: platforms (especially ARM and AArch64) have a lot of repetition with their intrinsics, for different versions with different types, so being able to write it once is nice.
2 parents f9f82f8 + 14f9c97 commit 2d3e837

File tree

19 files changed

+8173
-610
lines changed

19 files changed

+8173
-610
lines changed

src/etc/platform-intrinsics/aarch64.json

Lines changed: 550 additions & 0 deletions
Large diffs are not rendered by default.

src/etc/platform-intrinsics/arm.json

Lines changed: 396 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,396 @@
1+
{
2+
"platform": "arm",
3+
"intrinsic_prefix": "arm_v",
4+
"llvm_prefix": "llvm.neon.v",
5+
"number_info": {
6+
"signed": {
7+
"kind": "s",
8+
"data_type": { "pattern": "s{bitwidth}" }
9+
},
10+
"unsigned": {
11+
"kind": "u",
12+
"data_type": { "pattern": "u{bitwidth}" }
13+
},
14+
"float": {
15+
"kind": "f",
16+
"data_type": { "pattern": "f{bitwidth}" }
17+
}
18+
},
19+
"width_info": {
20+
"64": { "width": "" },
21+
"128": { "width": "q" }
22+
},
23+
"intrinsics": [
24+
{
25+
"intrinsic": "hadd{0.width}_{0.data_type}",
26+
"width": [64, 128],
27+
"llvm": "hadd{0.kind}.{0.llvm_name}",
28+
"ret": "i(8-32)",
29+
"args": ["0", "0"]
30+
},
31+
{
32+
"intrinsic": "rhadd{0.width}_{0.data_type}",
33+
"width": [64, 128],
34+
"llvm": "rhadd{0.kind}.{0.llvm_name}",
35+
"ret": "i(8-32)",
36+
"args": ["0", "0"]
37+
},
38+
{
39+
"intrinsic": "qadd{0.width}_{0.data_type}",
40+
"width": [64, 128],
41+
"llvm": "qadd{0.kind}.{0.llvm_name}",
42+
"ret": "i(8-64)",
43+
"args": ["0", "0"]
44+
},
45+
{
46+
"intrinsic": "raddhn_{1.data_type}",
47+
"width": [64],
48+
"llvm": "raddhn.{0.llvm_name}",
49+
"ret": "i(8-32)",
50+
"args": ["0w", "0w"]
51+
},
52+
{
53+
"intrinsic": "fma{0.width}_{0.data_type}",
54+
"width": [64, 128],
55+
"llvm": "!llvm.fma.{0.llvm_name}",
56+
"ret": "f32",
57+
"args": ["0", "0"]
58+
},
59+
{
60+
"intrinsic": "qdmulh{0.width}_{0.data_type}",
61+
"width": [64, 128],
62+
"llvm": "sqdmulh.{0.llvm_name}",
63+
"ret": "s(16-32)",
64+
"args": ["0", "0"]
65+
},
66+
{
67+
"intrinsic": "qrdmulh{0.width}_{0.data_type}",
68+
"width": [64, 128],
69+
"llvm": "sqrdmulh.{0.llvm_name}",
70+
"ret": "s(16-32)",
71+
"args": ["0", "0"]
72+
},
73+
{
74+
"intrinsic": "mull_{1.data_type}",
75+
"width": [128],
76+
"llvm": "mull{0.kind}.{0.llvm_name}",
77+
"ret": "i(16-64)",
78+
"args": ["0n", "0n"]
79+
},
80+
{
81+
"intrinsic": "qdmull{0.width}_{1.data_type}",
82+
"width": [128],
83+
"llvm": "sqdmull.{0.llvm_name}",
84+
"ret": "s(16-32)",
85+
"args": ["0n", "0n"]
86+
},
87+
{
88+
"intrinsic": "hsub{0.width}_{1.data_type}",
89+
"width": [64, 128],
90+
"llvm": "hsub{0.kind}.{0.llvm_name}",
91+
"ret": "i(8-32)",
92+
"args": ["0", "0"]
93+
},
94+
{
95+
"intrinsic": "qsub{0.width}_{1.data_type}",
96+
"width": [64, 128],
97+
"llvm": "qsub{0.kind}.{0.llvm_name}",
98+
"ret": "i(8-64)",
99+
"args": ["0", "0"]
100+
},
101+
{
102+
"intrinsic": "rsubhn_{1.data_type}",
103+
"width": [64],
104+
"llvm": "rsubhn.{0.llvm_name}",
105+
"ret": "i(8-32)",
106+
"args": ["0w", "0w"]
107+
},
108+
{
109+
"intrinsic": "abd{0.width}_{1.data_type}",
110+
"width": [64, 128],
111+
"llvm": "abd{0.kind}.{0.llvm_name}",
112+
"ret": ["i(8-32)","f32"],
113+
"args": ["0", "0"]
114+
},
115+
{
116+
"intrinsic": "max{0.width}_{0.data_type}",
117+
"width": [64, 128],
118+
"llvm": "max{0.kind}.{0.llvm_name}",
119+
"ret": ["i(8-32)","f32"],
120+
"args": ["0", "0"]
121+
},
122+
{
123+
"intrinsic": "min{0.width}_{0.data_type}",
124+
"width": [64, 128],
125+
"llvm": "min{0.kind}.{0.llvm_name}",
126+
"ret": ["i(8-32)","f32"],
127+
"args": ["0", "0"]
128+
},
129+
{
130+
"intrinsic": "shl{0.width}_{0.data_type}",
131+
"width": [64, 128],
132+
"llvm": "shl{0.kind}.{0.llvm_name}",
133+
"ret": "i(8-64)",
134+
"args": ["0", "0s"]
135+
},
136+
{
137+
"intrinsic": "qshl{0.width}_{0.data_type}",
138+
"width": [64, 128],
139+
"llvm": "qshl{0.kind}.{0.llvm_name}",
140+
"ret": "i(8-64)",
141+
"args": ["0", "0s"]
142+
},
143+
{
144+
"intrinsic": "rshl{0.width}_{0.data_type}",
145+
"width": [64, 128],
146+
"llvm": "rshl{0.kind}.{0.llvm_name}",
147+
"ret": "i(8-64)",
148+
"args": ["0", "0s"]
149+
},
150+
{
151+
"intrinsic": "qrshl{0.width}_{0.data_type}",
152+
"width": [64, 128],
153+
"llvm": "qrshl{0.kind}.{0.llvm_name}",
154+
"ret": "i(8-64)",
155+
"args": ["0", "0s"]
156+
},
157+
{
158+
"intrinsic": "qshrun_n_{1.data_type}",
159+
"width": [64],
160+
"llvm": "sqshrun.{0.llvm_name}",
161+
"ret": "s(8-32)",
162+
"args": ["0w", "U32"]
163+
},
164+
{
165+
"intrinsic": "qrshrun_n_{1.data_type}",
166+
"width": [64],
167+
"llvm": "sqrshrun.{0.llvm_name}",
168+
"ret": "s(8-32)",
169+
"args": ["0w", "U32"]
170+
},
171+
{
172+
"intrinsic": "qshrn_n_{1.data_type}",
173+
"width": [64],
174+
"llvm": "qshrn{0.kind}.{0.llvm_name}",
175+
"ret": "i(8-32)",
176+
"args": ["0w", "U32"]
177+
},
178+
{
179+
"intrinsic": "rshrn_n_{1.data_type}",
180+
"width": [64],
181+
"llvm": "rshrn.{0.llvm_name}",
182+
"ret": "i(8-32)",
183+
"args": ["0w", "U32"]
184+
},
185+
{
186+
"intrinsic": "qrshrn_n_{1.data_type}",
187+
"width": [64],
188+
"llvm": "qrshrn{0.kind}.{0.llvm_name}",
189+
"ret": "i(8-32)",
190+
"args": ["0w", "U32"]
191+
},
192+
{
193+
"intrinsic": "sri{0.width}_{0.data_type}",
194+
"width": [64, 128],
195+
"llvm": "vsri.{0.llvm_name}",
196+
"ret": "i(8-64)",
197+
"args": ["0", "0"]
198+
},
199+
{
200+
"intrinsic": "sli{0.width}_{0.data_type}",
201+
"width": [64, 128],
202+
"llvm": "vsli.{0.llvm_name}",
203+
"ret": "i(8-64)",
204+
"args": ["0", "0"]
205+
},
206+
{
207+
"intrinsic": "vqmovn_{1.data_type}",
208+
"width": [64],
209+
"llvm": "qxtn{0.kind}.{0.llvm_name}",
210+
"ret": "i(8-32)",
211+
"args": ["0w"]
212+
},
213+
{
214+
"intrinsic": "abs{0.width}_{0.data_type}",
215+
"width": [64,128],
216+
"llvm": "abs.{0.llvm_name}",
217+
"ret": "s(8-32)",
218+
"args": ["0"]
219+
},
220+
{
221+
"intrinsic": "abs{0.width}_{0.data_type}",
222+
"width": [64, 128],
223+
"llvm": "!llvm.fabs.{0.llvm_name}",
224+
"ret": "f32",
225+
"args": ["0"]
226+
},
227+
{
228+
"intrinsic": "qabs{0.width}_{0.data_type}",
229+
"width": [64,128],
230+
"llvm": "sqabs.{0.llvm_name}",
231+
"ret": "s(8-32)",
232+
"args": ["0"]
233+
},
234+
{
235+
"intrinsic": "qneg{0.width}_{0.data_type}",
236+
"width": [64, 128],
237+
"llvm": "sqneg.{0.llvm_name}",
238+
"ret": "s(8-32)",
239+
"args": ["0"]
240+
},
241+
{
242+
"intrinsic": "clz{0.width}_{0.data_type}",
243+
"width": [64, 128],
244+
"llvm": "!llvm.ctlz.{0.llvm_name}",
245+
"ret": "i(8-32)",
246+
"args": ["0"]
247+
},
248+
{
249+
"intrinsic": "cls{0.width}_{0.data_type}",
250+
"width": [64, 128],
251+
"llvm": "cls.{0.llvm_name}",
252+
"ret": "i(8-32)",
253+
"args": ["0"]
254+
},
255+
{
256+
"intrinsic": "cnt{0.width}_{0.data_type}",
257+
"width": [64, 128],
258+
"llvm": "!llvm.ctpop.{0.llvm_name}",
259+
"ret": "i8",
260+
"args": ["0"]
261+
},
262+
{
263+
"intrinsic": "recpe{0.width}_{0.data_type}",
264+
"width": [64, 128],
265+
"llvm": "recpe.{0.llvm_name}",
266+
"ret": ["u32","f32"],
267+
"args": ["0"]
268+
},
269+
{
270+
"intrinsic": "recps{0.width}_{0.data_type}",
271+
"width": [64,128],
272+
"llvm": "frecps.{0.llvm_name}",
273+
"ret": "f32",
274+
"args": ["0", "0"]
275+
},
276+
{
277+
"intrinsic": "sqrt{0.width}_{0.data_type}",
278+
"width": [64, 128],
279+
"llvm": "!llvm.sqrt.{0.llvm_name}",
280+
"ret": "f32",
281+
"args": ["0"]
282+
},
283+
{
284+
"intrinsic": "rsqrte{0.width}_{0.data_type}",
285+
"width": [64, 128],
286+
"llvm": "rsqrte.{0.llvm_name}",
287+
"ret": ["u32","f32"],
288+
"args": ["0"]
289+
},
290+
{
291+
"intrinsic": "rsqrts{0.width}_{0.data_type}",
292+
"width": [64,128],
293+
"llvm": "rsqrts.{0.llvm_name}",
294+
"ret": "f32",
295+
"args": ["0", "0"]
296+
},
297+
{
298+
"intrinsic": "bsl{0.width}_{0.data_type}",
299+
"width": [64, 128],
300+
"llvm": "bsl.{0.llvm_name}",
301+
"ret": "i(8-64)",
302+
"args": ["0u", "0"]
303+
},
304+
{
305+
"intrinsic": "padd{0.width}_{0.data_type}",
306+
"width": [64],
307+
"llvm": "padd.{0.llvm_name}",
308+
"ret": ["i(8-32)","f32"],
309+
"args": ["0", "0"]
310+
},
311+
{
312+
"intrinsic": "paddl{0.width}_{0.data_type}",
313+
"width": [64, 128],
314+
"llvm": "paddl{0.kind}.{0.llvm_name}.{1.llvm_name}",
315+
"ret": "i(16-64)",
316+
"args": ["0dn"]
317+
},
318+
{
319+
"intrinsic": "padal{0.width}_{0.data_type}",
320+
"width": [64, 128],
321+
"llvm": "padal{0.kind}.{0.llvm_name}.{1.llvm_name}",
322+
"ret": "i(16-64)",
323+
"args": ["0", "0dn"]
324+
},
325+
{
326+
"intrinsic": "pmax{0.width}_{0.data_type}",
327+
"width": [64],
328+
"llvm": "pmax{0.kind}.{0.llvm_name}",
329+
"ret": ["i(8-32)","f32"],
330+
"args": ["0", "0"]
331+
},
332+
{
333+
"intrinsic": "pmin{0.width}_{0.data_type}",
334+
"width": [64, 128],
335+
"llvm": "pmin{0.kind}.{0.llvm_name}",
336+
"ret": ["i(8-32)","f32"],
337+
"args": ["0", "0"]
338+
},
339+
{
340+
"intrinsic": "tbl1_{0.data_type}",
341+
"width": [64],
342+
"llvm": "tbl1",
343+
"ret": "i8",
344+
"args": ["0", "0u"]
345+
},
346+
{
347+
"intrinsic": "tbx1_{0.data_type}",
348+
"width": [64],
349+
"llvm": "tbx1",
350+
"ret": "i8",
351+
"args": ["0", "0", "0u"]
352+
},
353+
{
354+
"intrinsic": "tbl2_{0.data_type}",
355+
"width": [64],
356+
"llvm": "tbl2",
357+
"ret": "i8",
358+
"args": ["(0,0)f", "0u"]
359+
},
360+
{
361+
"intrinsic": "tbx2_{0.data_type}",
362+
"width": [64],
363+
"llvm": "tbx2",
364+
"ret": "i8",
365+
"args": ["(0,0)f", "0u"]
366+
},
367+
{
368+
"intrinsic": "tbl3_{0.data_type}",
369+
"width": [64],
370+
"llvm": "tbl3",
371+
"ret": "i8",
372+
"args": ["(0,0,0)f", "0u"]
373+
},
374+
{
375+
"intrinsic": "tbx3_{0.data_type}",
376+
"width": [64],
377+
"llvm": "tbx3",
378+
"ret": "i8",
379+
"args": ["0", "(0,0,0)f", "0u"]
380+
},
381+
{
382+
"intrinsic": "tbl4_{0.data_type}",
383+
"width": [64],
384+
"llvm": "tbl4",
385+
"ret": "i8",
386+
"args": ["(0,0,0,0)f", "0u"]
387+
},
388+
{
389+
"intrinsic": "tbx4_{0.data_type}",
390+
"width": [64],
391+
"llvm": "tbx4",
392+
"ret": "i8",
393+
"args": ["0", "(0,0,0,0)f", "0u"]
394+
}
395+
]
396+
}

0 commit comments

Comments
 (0)