• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //===-- CodeGen/RuntimeLibcalls.h - Runtime Library Calls -------*- C++ -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file defines the enum representing the list of runtime library calls
11 // the backend may emit during code generation, and also some helper functions.
12 //
13 //===----------------------------------------------------------------------===//
14 
15 #ifndef LLVM_CODEGEN_RUNTIMELIBCALLS_H
16 #define LLVM_CODEGEN_RUNTIMELIBCALLS_H
17 
18 #include "llvm/CodeGen/ValueTypes.h"
19 
20 namespace llvm {
21 namespace RTLIB {
22   /// RTLIB::Libcall enum - This enum defines all of the runtime library calls
23   /// the backend can emit.  The various long double types cannot be merged,
24   /// because 80-bit library functions use "xf" and 128-bit use "tf".
25   ///
26   /// When adding PPCF128 functions here, note that their names generally need
27   /// to be overridden for Darwin with the xxx$LDBL128 form.  See
28   /// PPCISelLowering.cpp.
29   ///
30   enum Libcall {
31     // Integer
32     SHL_I16,
33     SHL_I32,
34     SHL_I64,
35     SHL_I128,
36     SRL_I16,
37     SRL_I32,
38     SRL_I64,
39     SRL_I128,
40     SRA_I16,
41     SRA_I32,
42     SRA_I64,
43     SRA_I128,
44     MUL_I8,
45     MUL_I16,
46     MUL_I32,
47     MUL_I64,
48     MUL_I128,
49     MULO_I32,
50     MULO_I64,
51     MULO_I128,
52     SDIV_I8,
53     SDIV_I16,
54     SDIV_I32,
55     SDIV_I64,
56     SDIV_I128,
57     UDIV_I8,
58     UDIV_I16,
59     UDIV_I32,
60     UDIV_I64,
61     UDIV_I128,
62     SREM_I8,
63     SREM_I16,
64     SREM_I32,
65     SREM_I64,
66     SREM_I128,
67     UREM_I8,
68     UREM_I16,
69     UREM_I32,
70     UREM_I64,
71     UREM_I128,
72     SDIVREM_I8,
73     SDIVREM_I16,
74     SDIVREM_I32,
75     SDIVREM_I64,
76     SDIVREM_I128,
77     UDIVREM_I8,
78     UDIVREM_I16,
79     UDIVREM_I32,
80     UDIVREM_I64,
81     UDIVREM_I128,
82     NEG_I32,
83     NEG_I64,
84 
85     // FLOATING POINT
86     ADD_F32,
87     ADD_F64,
88     ADD_F80,
89     ADD_F128,
90     ADD_PPCF128,
91     SUB_F32,
92     SUB_F64,
93     SUB_F80,
94     SUB_F128,
95     SUB_PPCF128,
96     MUL_F32,
97     MUL_F64,
98     MUL_F80,
99     MUL_F128,
100     MUL_PPCF128,
101     DIV_F32,
102     DIV_F64,
103     DIV_F80,
104     DIV_F128,
105     DIV_PPCF128,
106     REM_F32,
107     REM_F64,
108     REM_F80,
109     REM_F128,
110     REM_PPCF128,
111     FMA_F32,
112     FMA_F64,
113     FMA_F80,
114     FMA_F128,
115     FMA_PPCF128,
116     POWI_F32,
117     POWI_F64,
118     POWI_F80,
119     POWI_F128,
120     POWI_PPCF128,
121     SQRT_F32,
122     SQRT_F64,
123     SQRT_F80,
124     SQRT_F128,
125     SQRT_PPCF128,
126     LOG_F32,
127     LOG_F64,
128     LOG_F80,
129     LOG_F128,
130     LOG_PPCF128,
131     LOG2_F32,
132     LOG2_F64,
133     LOG2_F80,
134     LOG2_F128,
135     LOG2_PPCF128,
136     LOG10_F32,
137     LOG10_F64,
138     LOG10_F80,
139     LOG10_F128,
140     LOG10_PPCF128,
141     EXP_F32,
142     EXP_F64,
143     EXP_F80,
144     EXP_F128,
145     EXP_PPCF128,
146     EXP2_F32,
147     EXP2_F64,
148     EXP2_F80,
149     EXP2_F128,
150     EXP2_PPCF128,
151     SIN_F32,
152     SIN_F64,
153     SIN_F80,
154     SIN_F128,
155     SIN_PPCF128,
156     COS_F32,
157     COS_F64,
158     COS_F80,
159     COS_F128,
160     COS_PPCF128,
161     SINCOS_F32,
162     SINCOS_F64,
163     SINCOS_F80,
164     SINCOS_F128,
165     SINCOS_PPCF128,
166     POW_F32,
167     POW_F64,
168     POW_F80,
169     POW_F128,
170     POW_PPCF128,
171     CEIL_F32,
172     CEIL_F64,
173     CEIL_F80,
174     CEIL_F128,
175     CEIL_PPCF128,
176     TRUNC_F32,
177     TRUNC_F64,
178     TRUNC_F80,
179     TRUNC_F128,
180     TRUNC_PPCF128,
181     RINT_F32,
182     RINT_F64,
183     RINT_F80,
184     RINT_F128,
185     RINT_PPCF128,
186     NEARBYINT_F32,
187     NEARBYINT_F64,
188     NEARBYINT_F80,
189     NEARBYINT_F128,
190     NEARBYINT_PPCF128,
191     ROUND_F32,
192     ROUND_F64,
193     ROUND_F80,
194     ROUND_F128,
195     ROUND_PPCF128,
196     FLOOR_F32,
197     FLOOR_F64,
198     FLOOR_F80,
199     FLOOR_F128,
200     FLOOR_PPCF128,
201     COPYSIGN_F32,
202     COPYSIGN_F64,
203     COPYSIGN_F80,
204     COPYSIGN_F128,
205     COPYSIGN_PPCF128,
206     FMIN_F32,
207     FMIN_F64,
208     FMIN_F80,
209     FMIN_F128,
210     FMIN_PPCF128,
211     FMAX_F32,
212     FMAX_F64,
213     FMAX_F80,
214     FMAX_F128,
215     FMAX_PPCF128,
216 
217     // CONVERSION
218     FPEXT_F32_PPCF128,
219     FPEXT_F64_PPCF128,
220     FPEXT_F64_F128,
221     FPEXT_F32_F128,
222     FPEXT_F32_F64,
223     FPEXT_F16_F32,
224     FPROUND_F32_F16,
225     FPROUND_F64_F16,
226     FPROUND_F80_F16,
227     FPROUND_F128_F16,
228     FPROUND_PPCF128_F16,
229     FPROUND_F64_F32,
230     FPROUND_F80_F32,
231     FPROUND_F128_F32,
232     FPROUND_PPCF128_F32,
233     FPROUND_F80_F64,
234     FPROUND_F128_F64,
235     FPROUND_PPCF128_F64,
236     FPTOSINT_F32_I32,
237     FPTOSINT_F32_I64,
238     FPTOSINT_F32_I128,
239     FPTOSINT_F64_I32,
240     FPTOSINT_F64_I64,
241     FPTOSINT_F64_I128,
242     FPTOSINT_F80_I32,
243     FPTOSINT_F80_I64,
244     FPTOSINT_F80_I128,
245     FPTOSINT_F128_I32,
246     FPTOSINT_F128_I64,
247     FPTOSINT_F128_I128,
248     FPTOSINT_PPCF128_I32,
249     FPTOSINT_PPCF128_I64,
250     FPTOSINT_PPCF128_I128,
251     FPTOUINT_F32_I32,
252     FPTOUINT_F32_I64,
253     FPTOUINT_F32_I128,
254     FPTOUINT_F64_I32,
255     FPTOUINT_F64_I64,
256     FPTOUINT_F64_I128,
257     FPTOUINT_F80_I32,
258     FPTOUINT_F80_I64,
259     FPTOUINT_F80_I128,
260     FPTOUINT_F128_I32,
261     FPTOUINT_F128_I64,
262     FPTOUINT_F128_I128,
263     FPTOUINT_PPCF128_I32,
264     FPTOUINT_PPCF128_I64,
265     FPTOUINT_PPCF128_I128,
266     SINTTOFP_I32_F32,
267     SINTTOFP_I32_F64,
268     SINTTOFP_I32_F80,
269     SINTTOFP_I32_F128,
270     SINTTOFP_I32_PPCF128,
271     SINTTOFP_I64_F32,
272     SINTTOFP_I64_F64,
273     SINTTOFP_I64_F80,
274     SINTTOFP_I64_F128,
275     SINTTOFP_I64_PPCF128,
276     SINTTOFP_I128_F32,
277     SINTTOFP_I128_F64,
278     SINTTOFP_I128_F80,
279     SINTTOFP_I128_F128,
280     SINTTOFP_I128_PPCF128,
281     UINTTOFP_I32_F32,
282     UINTTOFP_I32_F64,
283     UINTTOFP_I32_F80,
284     UINTTOFP_I32_F128,
285     UINTTOFP_I32_PPCF128,
286     UINTTOFP_I64_F32,
287     UINTTOFP_I64_F64,
288     UINTTOFP_I64_F80,
289     UINTTOFP_I64_F128,
290     UINTTOFP_I64_PPCF128,
291     UINTTOFP_I128_F32,
292     UINTTOFP_I128_F64,
293     UINTTOFP_I128_F80,
294     UINTTOFP_I128_F128,
295     UINTTOFP_I128_PPCF128,
296 
297     // COMPARISON
298     OEQ_F32,
299     OEQ_F64,
300     OEQ_F128,
301     OEQ_PPCF128,
302     UNE_F32,
303     UNE_F64,
304     UNE_F128,
305     UNE_PPCF128,
306     OGE_F32,
307     OGE_F64,
308     OGE_F128,
309     OGE_PPCF128,
310     OLT_F32,
311     OLT_F64,
312     OLT_F128,
313     OLT_PPCF128,
314     OLE_F32,
315     OLE_F64,
316     OLE_F128,
317     OLE_PPCF128,
318     OGT_F32,
319     OGT_F64,
320     OGT_F128,
321     OGT_PPCF128,
322     UO_F32,
323     UO_F64,
324     UO_F128,
325     UO_PPCF128,
326     O_F32,
327     O_F64,
328     O_F128,
329     O_PPCF128,
330 
331     // MEMORY
332     MEMCPY,
333     MEMSET,
334     MEMMOVE,
335 
336     // EXCEPTION HANDLING
337     UNWIND_RESUME,
338 
339     // Note: there's two sets of atomics libcalls; see
340     // <http://llvm.org/docs/Atomics.html> for more info on the
341     // difference between them.
342 
343     // Atomic '__sync_*' libcalls.
344     SYNC_VAL_COMPARE_AND_SWAP_1,
345     SYNC_VAL_COMPARE_AND_SWAP_2,
346     SYNC_VAL_COMPARE_AND_SWAP_4,
347     SYNC_VAL_COMPARE_AND_SWAP_8,
348     SYNC_VAL_COMPARE_AND_SWAP_16,
349     SYNC_LOCK_TEST_AND_SET_1,
350     SYNC_LOCK_TEST_AND_SET_2,
351     SYNC_LOCK_TEST_AND_SET_4,
352     SYNC_LOCK_TEST_AND_SET_8,
353     SYNC_LOCK_TEST_AND_SET_16,
354     SYNC_FETCH_AND_ADD_1,
355     SYNC_FETCH_AND_ADD_2,
356     SYNC_FETCH_AND_ADD_4,
357     SYNC_FETCH_AND_ADD_8,
358     SYNC_FETCH_AND_ADD_16,
359     SYNC_FETCH_AND_SUB_1,
360     SYNC_FETCH_AND_SUB_2,
361     SYNC_FETCH_AND_SUB_4,
362     SYNC_FETCH_AND_SUB_8,
363     SYNC_FETCH_AND_SUB_16,
364     SYNC_FETCH_AND_AND_1,
365     SYNC_FETCH_AND_AND_2,
366     SYNC_FETCH_AND_AND_4,
367     SYNC_FETCH_AND_AND_8,
368     SYNC_FETCH_AND_AND_16,
369     SYNC_FETCH_AND_OR_1,
370     SYNC_FETCH_AND_OR_2,
371     SYNC_FETCH_AND_OR_4,
372     SYNC_FETCH_AND_OR_8,
373     SYNC_FETCH_AND_OR_16,
374     SYNC_FETCH_AND_XOR_1,
375     SYNC_FETCH_AND_XOR_2,
376     SYNC_FETCH_AND_XOR_4,
377     SYNC_FETCH_AND_XOR_8,
378     SYNC_FETCH_AND_XOR_16,
379     SYNC_FETCH_AND_NAND_1,
380     SYNC_FETCH_AND_NAND_2,
381     SYNC_FETCH_AND_NAND_4,
382     SYNC_FETCH_AND_NAND_8,
383     SYNC_FETCH_AND_NAND_16,
384     SYNC_FETCH_AND_MAX_1,
385     SYNC_FETCH_AND_MAX_2,
386     SYNC_FETCH_AND_MAX_4,
387     SYNC_FETCH_AND_MAX_8,
388     SYNC_FETCH_AND_MAX_16,
389     SYNC_FETCH_AND_UMAX_1,
390     SYNC_FETCH_AND_UMAX_2,
391     SYNC_FETCH_AND_UMAX_4,
392     SYNC_FETCH_AND_UMAX_8,
393     SYNC_FETCH_AND_UMAX_16,
394     SYNC_FETCH_AND_MIN_1,
395     SYNC_FETCH_AND_MIN_2,
396     SYNC_FETCH_AND_MIN_4,
397     SYNC_FETCH_AND_MIN_8,
398     SYNC_FETCH_AND_MIN_16,
399     SYNC_FETCH_AND_UMIN_1,
400     SYNC_FETCH_AND_UMIN_2,
401     SYNC_FETCH_AND_UMIN_4,
402     SYNC_FETCH_AND_UMIN_8,
403     SYNC_FETCH_AND_UMIN_16,
404 
405     // Atomic '__atomic_*' libcalls.
406     ATOMIC_LOAD,
407     ATOMIC_LOAD_1,
408     ATOMIC_LOAD_2,
409     ATOMIC_LOAD_4,
410     ATOMIC_LOAD_8,
411     ATOMIC_LOAD_16,
412 
413     ATOMIC_STORE,
414     ATOMIC_STORE_1,
415     ATOMIC_STORE_2,
416     ATOMIC_STORE_4,
417     ATOMIC_STORE_8,
418     ATOMIC_STORE_16,
419 
420     ATOMIC_EXCHANGE,
421     ATOMIC_EXCHANGE_1,
422     ATOMIC_EXCHANGE_2,
423     ATOMIC_EXCHANGE_4,
424     ATOMIC_EXCHANGE_8,
425     ATOMIC_EXCHANGE_16,
426 
427     ATOMIC_COMPARE_EXCHANGE,
428     ATOMIC_COMPARE_EXCHANGE_1,
429     ATOMIC_COMPARE_EXCHANGE_2,
430     ATOMIC_COMPARE_EXCHANGE_4,
431     ATOMIC_COMPARE_EXCHANGE_8,
432     ATOMIC_COMPARE_EXCHANGE_16,
433 
434     ATOMIC_FETCH_ADD_1,
435     ATOMIC_FETCH_ADD_2,
436     ATOMIC_FETCH_ADD_4,
437     ATOMIC_FETCH_ADD_8,
438     ATOMIC_FETCH_ADD_16,
439 
440     ATOMIC_FETCH_SUB_1,
441     ATOMIC_FETCH_SUB_2,
442     ATOMIC_FETCH_SUB_4,
443     ATOMIC_FETCH_SUB_8,
444     ATOMIC_FETCH_SUB_16,
445 
446     ATOMIC_FETCH_AND_1,
447     ATOMIC_FETCH_AND_2,
448     ATOMIC_FETCH_AND_4,
449     ATOMIC_FETCH_AND_8,
450     ATOMIC_FETCH_AND_16,
451 
452     ATOMIC_FETCH_OR_1,
453     ATOMIC_FETCH_OR_2,
454     ATOMIC_FETCH_OR_4,
455     ATOMIC_FETCH_OR_8,
456     ATOMIC_FETCH_OR_16,
457 
458     ATOMIC_FETCH_XOR_1,
459     ATOMIC_FETCH_XOR_2,
460     ATOMIC_FETCH_XOR_4,
461     ATOMIC_FETCH_XOR_8,
462     ATOMIC_FETCH_XOR_16,
463 
464     ATOMIC_FETCH_NAND_1,
465     ATOMIC_FETCH_NAND_2,
466     ATOMIC_FETCH_NAND_4,
467     ATOMIC_FETCH_NAND_8,
468     ATOMIC_FETCH_NAND_16,
469 
470     // Stack Protector Fail.
471     STACKPROTECTOR_CHECK_FAIL,
472 
473     // Deoptimization.
474     DEOPTIMIZE,
475 
476     UNKNOWN_LIBCALL
477   };
478 
479   /// getFPEXT - Return the FPEXT_*_* value for the given types, or
480   /// UNKNOWN_LIBCALL if there is none.
481   Libcall getFPEXT(EVT OpVT, EVT RetVT);
482 
483   /// getFPROUND - Return the FPROUND_*_* value for the given types, or
484   /// UNKNOWN_LIBCALL if there is none.
485   Libcall getFPROUND(EVT OpVT, EVT RetVT);
486 
487   /// getFPTOSINT - Return the FPTOSINT_*_* value for the given types, or
488   /// UNKNOWN_LIBCALL if there is none.
489   Libcall getFPTOSINT(EVT OpVT, EVT RetVT);
490 
491   /// getFPTOUINT - Return the FPTOUINT_*_* value for the given types, or
492   /// UNKNOWN_LIBCALL if there is none.
493   Libcall getFPTOUINT(EVT OpVT, EVT RetVT);
494 
495   /// getSINTTOFP - Return the SINTTOFP_*_* value for the given types, or
496   /// UNKNOWN_LIBCALL if there is none.
497   Libcall getSINTTOFP(EVT OpVT, EVT RetVT);
498 
499   /// getUINTTOFP - Return the UINTTOFP_*_* value for the given types, or
500   /// UNKNOWN_LIBCALL if there is none.
501   Libcall getUINTTOFP(EVT OpVT, EVT RetVT);
502 
503   /// Return the SYNC_FETCH_AND_* value for the given opcode and type, or
504   /// UNKNOWN_LIBCALL if there is none.
505   Libcall getSYNC(unsigned Opc, MVT VT);
506 }
507 }
508 
509 #endif
510