Core.h
128 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
3505
3506
3507
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
3543
3544
3545
3546
3547
3548
3549
3550
3551
3552
3553
3554
3555
3556
3557
3558
3559
3560
3561
3562
3563
3564
3565
3566
3567
3568
3569
3570
3571
3572
3573
3574
3575
3576
3577
3578
3579
3580
3581
3582
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
3602
3603
3604
3605
3606
3607
3608
3609
3610
3611
3612
3613
3614
3615
3616
3617
3618
3619
3620
3621
3622
3623
3624
3625
3626
3627
3628
3629
3630
3631
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
3642
3643
3644
3645
3646
3647
3648
3649
3650
3651
3652
3653
3654
3655
3656
3657
3658
3659
3660
3661
3662
3663
3664
3665
3666
3667
3668
3669
3670
3671
3672
3673
3674
3675
3676
3677
3678
3679
3680
3681
3682
3683
3684
3685
3686
3687
3688
3689
3690
3691
3692
3693
3694
3695
3696
3697
3698
3699
3700
3701
3702
3703
3704
3705
3706
3707
3708
3709
3710
3711
3712
3713
3714
3715
3716
3717
3718
3719
3720
3721
3722
3723
3724
3725
3726
3727
3728
3729
3730
3731
3732
3733
3734
3735
3736
3737
3738
3739
3740
3741
3742
3743
3744
3745
3746
3747
3748
3749
3750
3751
3752
3753
3754
3755
3756
3757
3758
3759
3760
3761
3762
3763
3764
3765
3766
3767
3768
3769
3770
3771
3772
3773
3774
3775
3776
3777
3778
3779
3780
3781
3782
3783
3784
3785
3786
3787
3788
3789
3790
3791
3792
3793
3794
3795
3796
3797
3798
3799
3800
3801
3802
3803
3804
3805
3806
3807
3808
3809
3810
3811
3812
3813
3814
3815
3816
3817
3818
3819
3820
3821
3822
3823
3824
3825
3826
3827
3828
3829
3830
3831
3832
3833
3834
3835
3836
3837
3838
3839
3840
3841
3842
3843
3844
3845
3846
3847
3848
3849
3850
3851
3852
3853
3854
3855
3856
3857
3858
3859
3860
3861
3862
3863
3864
3865
3866
3867
3868
3869
3870
3871
3872
3873
3874
3875
3876
3877
3878
3879
3880
3881
3882
3883
3884
3885
3886
3887
3888
3889
3890
3891
3892
3893
3894
3895
3896
3897
3898
3899
3900
3901
3902
3903
3904
3905
3906
3907
3908
3909
3910
3911
3912
3913
3914
3915
3916
3917
3918
3919
3920
3921
3922
3923
3924
3925
3926
3927
3928
3929
3930
3931
3932
3933
3934
3935
3936
3937
3938
3939
3940
3941
3942
3943
3944
3945
3946
3947
3948
3949
3950
3951
3952
3953
3954
3955
3956
3957
3958
3959
3960
3961
3962
3963
3964
3965
3966
3967
3968
3969
3970
3971
3972
3973
3974
3975
3976
3977
3978
3979
3980
3981
3982
3983
3984
3985
3986
3987
3988
3989
3990
3991
3992
3993
3994
3995
3996
3997
3998
3999
4000
4001
4002
4003
4004
4005
4006
4007
4008
4009
4010
4011
4012
4013
4014
4015
4016
4017
4018
4019
4020
4021
4022
4023
4024
4025
4026
4027
4028
4029
4030
4031
4032
4033
4034
4035
4036
4037
4038
4039
4040
4041
4042
4043
4044
4045
4046
4047
4048
4049
4050
4051
4052
4053
4054
4055
4056
4057
4058
4059
4060
4061
4062
4063
4064
4065
4066
4067
4068
4069
4070
4071
4072
4073
4074
4075
4076
4077
4078
4079
4080
4081
4082
4083
4084
4085
4086
4087
4088
4089
4090
4091
4092
4093
4094
/*===-- llvm-c/Core.h - Core Library C Interface ------------------*- C -*-===*\
|* *|
|* Part of the LLVM Project, under the Apache License v2.0 with LLVM *|
|* Exceptions. *|
|* See https://llvm.org/LICENSE.txt for license information. *|
|* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception *|
|* *|
|*===----------------------------------------------------------------------===*|
|* *|
|* This header declares the C interface to libLLVMCore.a, which implements *|
|* the LLVM intermediate representation. *|
|* *|
\*===----------------------------------------------------------------------===*/
#ifndef LLVM_C_CORE_H
#define LLVM_C_CORE_H
#include "llvm-c/ErrorHandling.h"
#include "llvm-c/ExternC.h"
#include "llvm-c/Types.h"
LLVM_C_EXTERN_C_BEGIN
/**
* @defgroup LLVMC LLVM-C: C interface to LLVM
*
* This module exposes parts of the LLVM library as a C API.
*
* @{
*/
/**
* @defgroup LLVMCTransforms Transforms
*/
/**
* @defgroup LLVMCCore Core
*
* This modules provide an interface to libLLVMCore, which implements
* the LLVM intermediate representation as well as other related types
* and utilities.
*
* Many exotic languages can interoperate with C code but have a harder time
* with C++ due to name mangling. So in addition to C, this interface enables
* tools written in such languages.
*
* @{
*/
/**
* @defgroup LLVMCCoreTypes Types and Enumerations
*
* @{
*/
/// External users depend on the following values being stable. It is not safe
/// to reorder them.
typedef enum {
/* Terminator Instructions */
LLVMRet = 1,
LLVMBr = 2,
LLVMSwitch = 3,
LLVMIndirectBr = 4,
LLVMInvoke = 5,
/* removed 6 due to API changes */
LLVMUnreachable = 7,
LLVMCallBr = 67,
/* Standard Unary Operators */
LLVMFNeg = 66,
/* Standard Binary Operators */
LLVMAdd = 8,
LLVMFAdd = 9,
LLVMSub = 10,
LLVMFSub = 11,
LLVMMul = 12,
LLVMFMul = 13,
LLVMUDiv = 14,
LLVMSDiv = 15,
LLVMFDiv = 16,
LLVMURem = 17,
LLVMSRem = 18,
LLVMFRem = 19,
/* Logical Operators */
LLVMShl = 20,
LLVMLShr = 21,
LLVMAShr = 22,
LLVMAnd = 23,
LLVMOr = 24,
LLVMXor = 25,
/* Memory Operators */
LLVMAlloca = 26,
LLVMLoad = 27,
LLVMStore = 28,
LLVMGetElementPtr = 29,
/* Cast Operators */
LLVMTrunc = 30,
LLVMZExt = 31,
LLVMSExt = 32,
LLVMFPToUI = 33,
LLVMFPToSI = 34,
LLVMUIToFP = 35,
LLVMSIToFP = 36,
LLVMFPTrunc = 37,
LLVMFPExt = 38,
LLVMPtrToInt = 39,
LLVMIntToPtr = 40,
LLVMBitCast = 41,
LLVMAddrSpaceCast = 60,
/* Other Operators */
LLVMICmp = 42,
LLVMFCmp = 43,
LLVMPHI = 44,
LLVMCall = 45,
LLVMSelect = 46,
LLVMUserOp1 = 47,
LLVMUserOp2 = 48,
LLVMVAArg = 49,
LLVMExtractElement = 50,
LLVMInsertElement = 51,
LLVMShuffleVector = 52,
LLVMExtractValue = 53,
LLVMInsertValue = 54,
LLVMFreeze = 68,
/* Atomic operators */
LLVMFence = 55,
LLVMAtomicCmpXchg = 56,
LLVMAtomicRMW = 57,
/* Exception Handling Operators */
LLVMResume = 58,
LLVMLandingPad = 59,
LLVMCleanupRet = 61,
LLVMCatchRet = 62,
LLVMCatchPad = 63,
LLVMCleanupPad = 64,
LLVMCatchSwitch = 65
} LLVMOpcode;
typedef enum {
LLVMVoidTypeKind, /**< type with no size */
LLVMHalfTypeKind, /**< 16 bit floating point type */
LLVMFloatTypeKind, /**< 32 bit floating point type */
LLVMDoubleTypeKind, /**< 64 bit floating point type */
LLVMX86_FP80TypeKind, /**< 80 bit floating point type (X87) */
LLVMFP128TypeKind, /**< 128 bit floating point type (112-bit mantissa)*/
LLVMPPC_FP128TypeKind, /**< 128 bit floating point type (two 64-bits) */
LLVMLabelTypeKind, /**< Labels */
LLVMIntegerTypeKind, /**< Arbitrary bit width integers */
LLVMFunctionTypeKind, /**< Functions */
LLVMStructTypeKind, /**< Structures */
LLVMArrayTypeKind, /**< Arrays */
LLVMPointerTypeKind, /**< Pointers */
LLVMVectorTypeKind, /**< SIMD 'packed' format, or other vector type */
LLVMMetadataTypeKind, /**< Metadata */
LLVMX86_MMXTypeKind, /**< X86 MMX */
LLVMTokenTypeKind /**< Tokens */
} LLVMTypeKind;
typedef enum {
LLVMExternalLinkage, /**< Externally visible function */
LLVMAvailableExternallyLinkage,
LLVMLinkOnceAnyLinkage, /**< Keep one copy of function when linking (inline)*/
LLVMLinkOnceODRLinkage, /**< Same, but only replaced by something
equivalent. */
LLVMLinkOnceODRAutoHideLinkage, /**< Obsolete */
LLVMWeakAnyLinkage, /**< Keep one copy of function when linking (weak) */
LLVMWeakODRLinkage, /**< Same, but only replaced by something
equivalent. */
LLVMAppendingLinkage, /**< Special purpose, only applies to global arrays */
LLVMInternalLinkage, /**< Rename collisions when linking (static
functions) */
LLVMPrivateLinkage, /**< Like Internal, but omit from symbol table */
LLVMDLLImportLinkage, /**< Obsolete */
LLVMDLLExportLinkage, /**< Obsolete */
LLVMExternalWeakLinkage,/**< ExternalWeak linkage description */
LLVMGhostLinkage, /**< Obsolete */
LLVMCommonLinkage, /**< Tentative definitions */
LLVMLinkerPrivateLinkage, /**< Like Private, but linker removes. */
LLVMLinkerPrivateWeakLinkage /**< Like LinkerPrivate, but is weak. */
} LLVMLinkage;
typedef enum {
LLVMDefaultVisibility, /**< The GV is visible */
LLVMHiddenVisibility, /**< The GV is hidden */
LLVMProtectedVisibility /**< The GV is protected */
} LLVMVisibility;
typedef enum {
LLVMNoUnnamedAddr, /**< Address of the GV is significant. */
LLVMLocalUnnamedAddr, /**< Address of the GV is locally insignificant. */
LLVMGlobalUnnamedAddr /**< Address of the GV is globally insignificant. */
} LLVMUnnamedAddr;
typedef enum {
LLVMDefaultStorageClass = 0,
LLVMDLLImportStorageClass = 1, /**< Function to be imported from DLL. */
LLVMDLLExportStorageClass = 2 /**< Function to be accessible from DLL. */
} LLVMDLLStorageClass;
typedef enum {
LLVMCCallConv = 0,
LLVMFastCallConv = 8,
LLVMColdCallConv = 9,
LLVMGHCCallConv = 10,
LLVMHiPECallConv = 11,
LLVMWebKitJSCallConv = 12,
LLVMAnyRegCallConv = 13,
LLVMPreserveMostCallConv = 14,
LLVMPreserveAllCallConv = 15,
LLVMSwiftCallConv = 16,
LLVMCXXFASTTLSCallConv = 17,
LLVMX86StdcallCallConv = 64,
LLVMX86FastcallCallConv = 65,
LLVMARMAPCSCallConv = 66,
LLVMARMAAPCSCallConv = 67,
LLVMARMAAPCSVFPCallConv = 68,
LLVMMSP430INTRCallConv = 69,
LLVMX86ThisCallCallConv = 70,
LLVMPTXKernelCallConv = 71,
LLVMPTXDeviceCallConv = 72,
LLVMSPIRFUNCCallConv = 75,
LLVMSPIRKERNELCallConv = 76,
LLVMIntelOCLBICallConv = 77,
LLVMX8664SysVCallConv = 78,
LLVMWin64CallConv = 79,
LLVMX86VectorCallCallConv = 80,
LLVMHHVMCallConv = 81,
LLVMHHVMCCallConv = 82,
LLVMX86INTRCallConv = 83,
LLVMAVRINTRCallConv = 84,
LLVMAVRSIGNALCallConv = 85,
LLVMAVRBUILTINCallConv = 86,
LLVMAMDGPUVSCallConv = 87,
LLVMAMDGPUGSCallConv = 88,
LLVMAMDGPUPSCallConv = 89,
LLVMAMDGPUCSCallConv = 90,
LLVMAMDGPUKERNELCallConv = 91,
LLVMX86RegCallCallConv = 92,
LLVMAMDGPUHSCallConv = 93,
LLVMMSP430BUILTINCallConv = 94,
LLVMAMDGPULSCallConv = 95,
LLVMAMDGPUESCallConv = 96
} LLVMCallConv;
typedef enum {
LLVMArgumentValueKind,
LLVMBasicBlockValueKind,
LLVMMemoryUseValueKind,
LLVMMemoryDefValueKind,
LLVMMemoryPhiValueKind,
LLVMFunctionValueKind,
LLVMGlobalAliasValueKind,
LLVMGlobalIFuncValueKind,
LLVMGlobalVariableValueKind,
LLVMBlockAddressValueKind,
LLVMConstantExprValueKind,
LLVMConstantArrayValueKind,
LLVMConstantStructValueKind,
LLVMConstantVectorValueKind,
LLVMUndefValueValueKind,
LLVMConstantAggregateZeroValueKind,
LLVMConstantDataArrayValueKind,
LLVMConstantDataVectorValueKind,
LLVMConstantIntValueKind,
LLVMConstantFPValueKind,
LLVMConstantPointerNullValueKind,
LLVMConstantTokenNoneValueKind,
LLVMMetadataAsValueValueKind,
LLVMInlineAsmValueKind,
LLVMInstructionValueKind,
} LLVMValueKind;
typedef enum {
LLVMIntEQ = 32, /**< equal */
LLVMIntNE, /**< not equal */
LLVMIntUGT, /**< unsigned greater than */
LLVMIntUGE, /**< unsigned greater or equal */
LLVMIntULT, /**< unsigned less than */
LLVMIntULE, /**< unsigned less or equal */
LLVMIntSGT, /**< signed greater than */
LLVMIntSGE, /**< signed greater or equal */
LLVMIntSLT, /**< signed less than */
LLVMIntSLE /**< signed less or equal */
} LLVMIntPredicate;
typedef enum {
LLVMRealPredicateFalse, /**< Always false (always folded) */
LLVMRealOEQ, /**< True if ordered and equal */
LLVMRealOGT, /**< True if ordered and greater than */
LLVMRealOGE, /**< True if ordered and greater than or equal */
LLVMRealOLT, /**< True if ordered and less than */
LLVMRealOLE, /**< True if ordered and less than or equal */
LLVMRealONE, /**< True if ordered and operands are unequal */
LLVMRealORD, /**< True if ordered (no nans) */
LLVMRealUNO, /**< True if unordered: isnan(X) | isnan(Y) */
LLVMRealUEQ, /**< True if unordered or equal */
LLVMRealUGT, /**< True if unordered or greater than */
LLVMRealUGE, /**< True if unordered, greater than, or equal */
LLVMRealULT, /**< True if unordered or less than */
LLVMRealULE, /**< True if unordered, less than, or equal */
LLVMRealUNE, /**< True if unordered or not equal */
LLVMRealPredicateTrue /**< Always true (always folded) */
} LLVMRealPredicate;
typedef enum {
LLVMLandingPadCatch, /**< A catch clause */
LLVMLandingPadFilter /**< A filter clause */
} LLVMLandingPadClauseTy;
typedef enum {
LLVMNotThreadLocal = 0,
LLVMGeneralDynamicTLSModel,
LLVMLocalDynamicTLSModel,
LLVMInitialExecTLSModel,
LLVMLocalExecTLSModel
} LLVMThreadLocalMode;
typedef enum {
LLVMAtomicOrderingNotAtomic = 0, /**< A load or store which is not atomic */
LLVMAtomicOrderingUnordered = 1, /**< Lowest level of atomicity, guarantees
somewhat sane results, lock free. */
LLVMAtomicOrderingMonotonic = 2, /**< guarantees that if you take all the
operations affecting a specific address,
a consistent ordering exists */
LLVMAtomicOrderingAcquire = 4, /**< Acquire provides a barrier of the sort
necessary to acquire a lock to access other
memory with normal loads and stores. */
LLVMAtomicOrderingRelease = 5, /**< Release is similar to Acquire, but with
a barrier of the sort necessary to release
a lock. */
LLVMAtomicOrderingAcquireRelease = 6, /**< provides both an Acquire and a
Release barrier (for fences and
operations which both read and write
memory). */
LLVMAtomicOrderingSequentiallyConsistent = 7 /**< provides Acquire semantics
for loads and Release
semantics for stores.
Additionally, it guarantees
that a total ordering exists
between all
SequentiallyConsistent
operations. */
} LLVMAtomicOrdering;
typedef enum {
LLVMAtomicRMWBinOpXchg, /**< Set the new value and return the one old */
LLVMAtomicRMWBinOpAdd, /**< Add a value and return the old one */
LLVMAtomicRMWBinOpSub, /**< Subtract a value and return the old one */
LLVMAtomicRMWBinOpAnd, /**< And a value and return the old one */
LLVMAtomicRMWBinOpNand, /**< Not-And a value and return the old one */
LLVMAtomicRMWBinOpOr, /**< OR a value and return the old one */
LLVMAtomicRMWBinOpXor, /**< Xor a value and return the old one */
LLVMAtomicRMWBinOpMax, /**< Sets the value if it's greater than the
original using a signed comparison and return
the old one */
LLVMAtomicRMWBinOpMin, /**< Sets the value if it's Smaller than the
original using a signed comparison and return
the old one */
LLVMAtomicRMWBinOpUMax, /**< Sets the value if it's greater than the
original using an unsigned comparison and return
the old one */
LLVMAtomicRMWBinOpUMin, /**< Sets the value if it's greater than the
original using an unsigned comparison and return
the old one */
LLVMAtomicRMWBinOpFAdd, /**< Add a floating point value and return the
old one */
LLVMAtomicRMWBinOpFSub /**< Subtract a floating point value and return the
old one */
} LLVMAtomicRMWBinOp;
typedef enum {
LLVMDSError,
LLVMDSWarning,
LLVMDSRemark,
LLVMDSNote
} LLVMDiagnosticSeverity;
typedef enum {
LLVMInlineAsmDialectATT,
LLVMInlineAsmDialectIntel
} LLVMInlineAsmDialect;
typedef enum {
/**
* Emits an error if two values disagree, otherwise the resulting value is
* that of the operands.
*
* @see Module::ModFlagBehavior::Error
*/
LLVMModuleFlagBehaviorError,
/**
* Emits a warning if two values disagree. The result value will be the
* operand for the flag from the first module being linked.
*
* @see Module::ModFlagBehavior::Warning
*/
LLVMModuleFlagBehaviorWarning,
/**
* Adds a requirement that another module flag be present and have a
* specified value after linking is performed. The value must be a metadata
* pair, where the first element of the pair is the ID of the module flag
* to be restricted, and the second element of the pair is the value the
* module flag should be restricted to. This behavior can be used to
* restrict the allowable results (via triggering of an error) of linking
* IDs with the **Override** behavior.
*
* @see Module::ModFlagBehavior::Require
*/
LLVMModuleFlagBehaviorRequire,
/**
* Uses the specified value, regardless of the behavior or value of the
* other module. If both modules specify **Override**, but the values
* differ, an error will be emitted.
*
* @see Module::ModFlagBehavior::Override
*/
LLVMModuleFlagBehaviorOverride,
/**
* Appends the two values, which are required to be metadata nodes.
*
* @see Module::ModFlagBehavior::Append
*/
LLVMModuleFlagBehaviorAppend,
/**
* Appends the two values, which are required to be metadata
* nodes. However, duplicate entries in the second list are dropped
* during the append operation.
*
* @see Module::ModFlagBehavior::AppendUnique
*/
LLVMModuleFlagBehaviorAppendUnique,
} LLVMModuleFlagBehavior;
/**
* Attribute index are either LLVMAttributeReturnIndex,
* LLVMAttributeFunctionIndex or a parameter number from 1 to N.
*/
enum {
LLVMAttributeReturnIndex = 0U,
// ISO C restricts enumerator values to range of 'int'
// (4294967295 is too large)
// LLVMAttributeFunctionIndex = ~0U,
LLVMAttributeFunctionIndex = -1,
};
typedef unsigned LLVMAttributeIndex;
/**
* @}
*/
void LLVMInitializeCore(LLVMPassRegistryRef R);
/** Deallocate and destroy all ManagedStatic variables.
@see llvm::llvm_shutdown
@see ManagedStatic */
void LLVMShutdown(void);
/*===-- Error handling ----------------------------------------------------===*/
char *LLVMCreateMessage(const char *Message);
void LLVMDisposeMessage(char *Message);
/**
* @defgroup LLVMCCoreContext Contexts
*
* Contexts are execution states for the core LLVM IR system.
*
* Most types are tied to a context instance. Multiple contexts can
* exist simultaneously. A single context is not thread safe. However,
* different contexts can execute on different threads simultaneously.
*
* @{
*/
typedef void (*LLVMDiagnosticHandler)(LLVMDiagnosticInfoRef, void *);
typedef void (*LLVMYieldCallback)(LLVMContextRef, void *);
/**
* Create a new context.
*
* Every call to this function should be paired with a call to
* LLVMContextDispose() or the context will leak memory.
*/
LLVMContextRef LLVMContextCreate(void);
/**
* Obtain the global context instance.
*/
LLVMContextRef LLVMGetGlobalContext(void);
/**
* Set the diagnostic handler for this context.
*/
void LLVMContextSetDiagnosticHandler(LLVMContextRef C,
LLVMDiagnosticHandler Handler,
void *DiagnosticContext);
/**
* Get the diagnostic handler of this context.
*/
LLVMDiagnosticHandler LLVMContextGetDiagnosticHandler(LLVMContextRef C);
/**
* Get the diagnostic context of this context.
*/
void *LLVMContextGetDiagnosticContext(LLVMContextRef C);
/**
* Set the yield callback function for this context.
*
* @see LLVMContext::setYieldCallback()
*/
void LLVMContextSetYieldCallback(LLVMContextRef C, LLVMYieldCallback Callback,
void *OpaqueHandle);
/**
* Retrieve whether the given context is set to discard all value names.
*
* @see LLVMContext::shouldDiscardValueNames()
*/
LLVMBool LLVMContextShouldDiscardValueNames(LLVMContextRef C);
/**
* Set whether the given context discards all value names.
*
* If true, only the names of GlobalValue objects will be available in the IR.
* This can be used to save memory and runtime, especially in release mode.
*
* @see LLVMContext::setDiscardValueNames()
*/
void LLVMContextSetDiscardValueNames(LLVMContextRef C, LLVMBool Discard);
/**
* Destroy a context instance.
*
* This should be called for every call to LLVMContextCreate() or memory
* will be leaked.
*/
void LLVMContextDispose(LLVMContextRef C);
/**
* Return a string representation of the DiagnosticInfo. Use
* LLVMDisposeMessage to free the string.
*
* @see DiagnosticInfo::print()
*/
char *LLVMGetDiagInfoDescription(LLVMDiagnosticInfoRef DI);
/**
* Return an enum LLVMDiagnosticSeverity.
*
* @see DiagnosticInfo::getSeverity()
*/
LLVMDiagnosticSeverity LLVMGetDiagInfoSeverity(LLVMDiagnosticInfoRef DI);
unsigned LLVMGetMDKindIDInContext(LLVMContextRef C, const char *Name,
unsigned SLen);
unsigned LLVMGetMDKindID(const char *Name, unsigned SLen);
/**
* Return an unique id given the name of a enum attribute,
* or 0 if no attribute by that name exists.
*
* See http://llvm.org/docs/LangRef.html#parameter-attributes
* and http://llvm.org/docs/LangRef.html#function-attributes
* for the list of available attributes.
*
* NB: Attribute names and/or id are subject to change without
* going through the C API deprecation cycle.
*/
unsigned LLVMGetEnumAttributeKindForName(const char *Name, size_t SLen);
unsigned LLVMGetLastEnumAttributeKind(void);
/**
* Create an enum attribute.
*/
LLVMAttributeRef LLVMCreateEnumAttribute(LLVMContextRef C, unsigned KindID,
uint64_t Val);
/**
* Get the unique id corresponding to the enum attribute
* passed as argument.
*/
unsigned LLVMGetEnumAttributeKind(LLVMAttributeRef A);
/**
* Get the enum attribute's value. 0 is returned if none exists.
*/
uint64_t LLVMGetEnumAttributeValue(LLVMAttributeRef A);
/**
* Create a string attribute.
*/
LLVMAttributeRef LLVMCreateStringAttribute(LLVMContextRef C,
const char *K, unsigned KLength,
const char *V, unsigned VLength);
/**
* Get the string attribute's kind.
*/
const char *LLVMGetStringAttributeKind(LLVMAttributeRef A, unsigned *Length);
/**
* Get the string attribute's value.
*/
const char *LLVMGetStringAttributeValue(LLVMAttributeRef A, unsigned *Length);
/**
* Check for the different types of attributes.
*/
LLVMBool LLVMIsEnumAttribute(LLVMAttributeRef A);
LLVMBool LLVMIsStringAttribute(LLVMAttributeRef A);
/**
* @}
*/
/**
* @defgroup LLVMCCoreModule Modules
*
* Modules represent the top-level structure in an LLVM program. An LLVM
* module is effectively a translation unit or a collection of
* translation units merged together.
*
* @{
*/
/**
* Create a new, empty module in the global context.
*
* This is equivalent to calling LLVMModuleCreateWithNameInContext with
* LLVMGetGlobalContext() as the context parameter.
*
* Every invocation should be paired with LLVMDisposeModule() or memory
* will be leaked.
*/
LLVMModuleRef LLVMModuleCreateWithName(const char *ModuleID);
/**
* Create a new, empty module in a specific context.
*
* Every invocation should be paired with LLVMDisposeModule() or memory
* will be leaked.
*/
LLVMModuleRef LLVMModuleCreateWithNameInContext(const char *ModuleID,
LLVMContextRef C);
/**
* Return an exact copy of the specified module.
*/
LLVMModuleRef LLVMCloneModule(LLVMModuleRef M);
/**
* Destroy a module instance.
*
* This must be called for every created module or memory will be
* leaked.
*/
void LLVMDisposeModule(LLVMModuleRef M);
/**
* Obtain the identifier of a module.
*
* @param M Module to obtain identifier of
* @param Len Out parameter which holds the length of the returned string.
* @return The identifier of M.
* @see Module::getModuleIdentifier()
*/
const char *LLVMGetModuleIdentifier(LLVMModuleRef M, size_t *Len);
/**
* Set the identifier of a module to a string Ident with length Len.
*
* @param M The module to set identifier
* @param Ident The string to set M's identifier to
* @param Len Length of Ident
* @see Module::setModuleIdentifier()
*/
void LLVMSetModuleIdentifier(LLVMModuleRef M, const char *Ident, size_t Len);
/**
* Obtain the module's original source file name.
*
* @param M Module to obtain the name of
* @param Len Out parameter which holds the length of the returned string
* @return The original source file name of M
* @see Module::getSourceFileName()
*/
const char *LLVMGetSourceFileName(LLVMModuleRef M, size_t *Len);
/**
* Set the original source file name of a module to a string Name with length
* Len.
*
* @param M The module to set the source file name of
* @param Name The string to set M's source file name to
* @param Len Length of Name
* @see Module::setSourceFileName()
*/
void LLVMSetSourceFileName(LLVMModuleRef M, const char *Name, size_t Len);
/**
* Obtain the data layout for a module.
*
* @see Module::getDataLayoutStr()
*
* LLVMGetDataLayout is DEPRECATED, as the name is not only incorrect,
* but match the name of another method on the module. Prefer the use
* of LLVMGetDataLayoutStr, which is not ambiguous.
*/
const char *LLVMGetDataLayoutStr(LLVMModuleRef M);
const char *LLVMGetDataLayout(LLVMModuleRef M);
/**
* Set the data layout for a module.
*
* @see Module::setDataLayout()
*/
void LLVMSetDataLayout(LLVMModuleRef M, const char *DataLayoutStr);
/**
* Obtain the target triple for a module.
*
* @see Module::getTargetTriple()
*/
const char *LLVMGetTarget(LLVMModuleRef M);
/**
* Set the target triple for a module.
*
* @see Module::setTargetTriple()
*/
void LLVMSetTarget(LLVMModuleRef M, const char *Triple);
/**
* Returns the module flags as an array of flag-key-value triples. The caller
* is responsible for freeing this array by calling
* \c LLVMDisposeModuleFlagsMetadata.
*
* @see Module::getModuleFlagsMetadata()
*/
LLVMModuleFlagEntry *LLVMCopyModuleFlagsMetadata(LLVMModuleRef M, size_t *Len);
/**
* Destroys module flags metadata entries.
*/
void LLVMDisposeModuleFlagsMetadata(LLVMModuleFlagEntry *Entries);
/**
* Returns the flag behavior for a module flag entry at a specific index.
*
* @see Module::ModuleFlagEntry::Behavior
*/
LLVMModuleFlagBehavior
LLVMModuleFlagEntriesGetFlagBehavior(LLVMModuleFlagEntry *Entries,
unsigned Index);
/**
* Returns the key for a module flag entry at a specific index.
*
* @see Module::ModuleFlagEntry::Key
*/
const char *LLVMModuleFlagEntriesGetKey(LLVMModuleFlagEntry *Entries,
unsigned Index, size_t *Len);
/**
* Returns the metadata for a module flag entry at a specific index.
*
* @see Module::ModuleFlagEntry::Val
*/
LLVMMetadataRef LLVMModuleFlagEntriesGetMetadata(LLVMModuleFlagEntry *Entries,
unsigned Index);
/**
* Add a module-level flag to the module-level flags metadata if it doesn't
* already exist.
*
* @see Module::getModuleFlag()
*/
LLVMMetadataRef LLVMGetModuleFlag(LLVMModuleRef M,
const char *Key, size_t KeyLen);
/**
* Add a module-level flag to the module-level flags metadata if it doesn't
* already exist.
*
* @see Module::addModuleFlag()
*/
void LLVMAddModuleFlag(LLVMModuleRef M, LLVMModuleFlagBehavior Behavior,
const char *Key, size_t KeyLen,
LLVMMetadataRef Val);
/**
* Dump a representation of a module to stderr.
*
* @see Module::dump()
*/
void LLVMDumpModule(LLVMModuleRef M);
/**
* Print a representation of a module to a file. The ErrorMessage needs to be
* disposed with LLVMDisposeMessage. Returns 0 on success, 1 otherwise.
*
* @see Module::print()
*/
LLVMBool LLVMPrintModuleToFile(LLVMModuleRef M, const char *Filename,
char **ErrorMessage);
/**
* Return a string representation of the module. Use
* LLVMDisposeMessage to free the string.
*
* @see Module::print()
*/
char *LLVMPrintModuleToString(LLVMModuleRef M);
/**
* Get inline assembly for a module.
*
* @see Module::getModuleInlineAsm()
*/
const char *LLVMGetModuleInlineAsm(LLVMModuleRef M, size_t *Len);
/**
* Set inline assembly for a module.
*
* @see Module::setModuleInlineAsm()
*/
void LLVMSetModuleInlineAsm2(LLVMModuleRef M, const char *Asm, size_t Len);
/**
* Append inline assembly to a module.
*
* @see Module::appendModuleInlineAsm()
*/
void LLVMAppendModuleInlineAsm(LLVMModuleRef M, const char *Asm, size_t Len);
/**
* Create the specified uniqued inline asm string.
*
* @see InlineAsm::get()
*/
LLVMValueRef LLVMGetInlineAsm(LLVMTypeRef Ty,
char *AsmString, size_t AsmStringSize,
char *Constraints, size_t ConstraintsSize,
LLVMBool HasSideEffects, LLVMBool IsAlignStack,
LLVMInlineAsmDialect Dialect);
/**
* Obtain the context to which this module is associated.
*
* @see Module::getContext()
*/
LLVMContextRef LLVMGetModuleContext(LLVMModuleRef M);
/**
* Obtain a Type from a module by its registered name.
*/
LLVMTypeRef LLVMGetTypeByName(LLVMModuleRef M, const char *Name);
/**
* Obtain an iterator to the first NamedMDNode in a Module.
*
* @see llvm::Module::named_metadata_begin()
*/
LLVMNamedMDNodeRef LLVMGetFirstNamedMetadata(LLVMModuleRef M);
/**
* Obtain an iterator to the last NamedMDNode in a Module.
*
* @see llvm::Module::named_metadata_end()
*/
LLVMNamedMDNodeRef LLVMGetLastNamedMetadata(LLVMModuleRef M);
/**
* Advance a NamedMDNode iterator to the next NamedMDNode.
*
* Returns NULL if the iterator was already at the end and there are no more
* named metadata nodes.
*/
LLVMNamedMDNodeRef LLVMGetNextNamedMetadata(LLVMNamedMDNodeRef NamedMDNode);
/**
* Decrement a NamedMDNode iterator to the previous NamedMDNode.
*
* Returns NULL if the iterator was already at the beginning and there are
* no previous named metadata nodes.
*/
LLVMNamedMDNodeRef LLVMGetPreviousNamedMetadata(LLVMNamedMDNodeRef NamedMDNode);
/**
* Retrieve a NamedMDNode with the given name, returning NULL if no such
* node exists.
*
* @see llvm::Module::getNamedMetadata()
*/
LLVMNamedMDNodeRef LLVMGetNamedMetadata(LLVMModuleRef M,
const char *Name, size_t NameLen);
/**
* Retrieve a NamedMDNode with the given name, creating a new node if no such
* node exists.
*
* @see llvm::Module::getOrInsertNamedMetadata()
*/
LLVMNamedMDNodeRef LLVMGetOrInsertNamedMetadata(LLVMModuleRef M,
const char *Name,
size_t NameLen);
/**
* Retrieve the name of a NamedMDNode.
*
* @see llvm::NamedMDNode::getName()
*/
const char *LLVMGetNamedMetadataName(LLVMNamedMDNodeRef NamedMD,
size_t *NameLen);
/**
* Obtain the number of operands for named metadata in a module.
*
* @see llvm::Module::getNamedMetadata()
*/
unsigned LLVMGetNamedMetadataNumOperands(LLVMModuleRef M, const char *Name);
/**
* Obtain the named metadata operands for a module.
*
* The passed LLVMValueRef pointer should refer to an array of
* LLVMValueRef at least LLVMGetNamedMetadataNumOperands long. This
* array will be populated with the LLVMValueRef instances. Each
* instance corresponds to a llvm::MDNode.
*
* @see llvm::Module::getNamedMetadata()
* @see llvm::MDNode::getOperand()
*/
void LLVMGetNamedMetadataOperands(LLVMModuleRef M, const char *Name,
LLVMValueRef *Dest);
/**
* Add an operand to named metadata.
*
* @see llvm::Module::getNamedMetadata()
* @see llvm::MDNode::addOperand()
*/
void LLVMAddNamedMetadataOperand(LLVMModuleRef M, const char *Name,
LLVMValueRef Val);
/**
* Return the directory of the debug location for this value, which must be
* an llvm::Instruction, llvm::GlobalVariable, or llvm::Function.
*
* @see llvm::Instruction::getDebugLoc()
* @see llvm::GlobalVariable::getDebugInfo()
* @see llvm::Function::getSubprogram()
*/
const char *LLVMGetDebugLocDirectory(LLVMValueRef Val, unsigned *Length);
/**
* Return the filename of the debug location for this value, which must be
* an llvm::Instruction, llvm::GlobalVariable, or llvm::Function.
*
* @see llvm::Instruction::getDebugLoc()
* @see llvm::GlobalVariable::getDebugInfo()
* @see llvm::Function::getSubprogram()
*/
const char *LLVMGetDebugLocFilename(LLVMValueRef Val, unsigned *Length);
/**
* Return the line number of the debug location for this value, which must be
* an llvm::Instruction, llvm::GlobalVariable, or llvm::Function.
*
* @see llvm::Instruction::getDebugLoc()
* @see llvm::GlobalVariable::getDebugInfo()
* @see llvm::Function::getSubprogram()
*/
unsigned LLVMGetDebugLocLine(LLVMValueRef Val);
/**
* Return the column number of the debug location for this value, which must be
* an llvm::Instruction.
*
* @see llvm::Instruction::getDebugLoc()
*/
unsigned LLVMGetDebugLocColumn(LLVMValueRef Val);
/**
* Add a function to a module under a specified name.
*
* @see llvm::Function::Create()
*/
LLVMValueRef LLVMAddFunction(LLVMModuleRef M, const char *Name,
LLVMTypeRef FunctionTy);
/**
* Obtain a Function value from a Module by its name.
*
* The returned value corresponds to a llvm::Function value.
*
* @see llvm::Module::getFunction()
*/
LLVMValueRef LLVMGetNamedFunction(LLVMModuleRef M, const char *Name);
/**
* Obtain an iterator to the first Function in a Module.
*
* @see llvm::Module::begin()
*/
LLVMValueRef LLVMGetFirstFunction(LLVMModuleRef M);
/**
* Obtain an iterator to the last Function in a Module.
*
* @see llvm::Module::end()
*/
LLVMValueRef LLVMGetLastFunction(LLVMModuleRef M);
/**
* Advance a Function iterator to the next Function.
*
* Returns NULL if the iterator was already at the end and there are no more
* functions.
*/
LLVMValueRef LLVMGetNextFunction(LLVMValueRef Fn);
/**
* Decrement a Function iterator to the previous Function.
*
* Returns NULL if the iterator was already at the beginning and there are
* no previous functions.
*/
LLVMValueRef LLVMGetPreviousFunction(LLVMValueRef Fn);
/** Deprecated: Use LLVMSetModuleInlineAsm2 instead. */
void LLVMSetModuleInlineAsm(LLVMModuleRef M, const char *Asm);
/**
* @}
*/
/**
* @defgroup LLVMCCoreType Types
*
* Types represent the type of a value.
*
* Types are associated with a context instance. The context internally
* deduplicates types so there is only 1 instance of a specific type
* alive at a time. In other words, a unique type is shared among all
* consumers within a context.
*
* A Type in the C API corresponds to llvm::Type.
*
* Types have the following hierarchy:
*
* types:
* integer type
* real type
* function type
* sequence types:
* array type
* pointer type
* vector type
* void type
* label type
* opaque type
*
* @{
*/
/**
* Obtain the enumerated type of a Type instance.
*
* @see llvm::Type:getTypeID()
*/
LLVMTypeKind LLVMGetTypeKind(LLVMTypeRef Ty);
/**
* Whether the type has a known size.
*
* Things that don't have a size are abstract types, labels, and void.a
*
* @see llvm::Type::isSized()
*/
LLVMBool LLVMTypeIsSized(LLVMTypeRef Ty);
/**
* Obtain the context to which this type instance is associated.
*
* @see llvm::Type::getContext()
*/
LLVMContextRef LLVMGetTypeContext(LLVMTypeRef Ty);
/**
* Dump a representation of a type to stderr.
*
* @see llvm::Type::dump()
*/
void LLVMDumpType(LLVMTypeRef Val);
/**
* Return a string representation of the type. Use
* LLVMDisposeMessage to free the string.
*
* @see llvm::Type::print()
*/
char *LLVMPrintTypeToString(LLVMTypeRef Val);
/**
* @defgroup LLVMCCoreTypeInt Integer Types
*
* Functions in this section operate on integer types.
*
* @{
*/
/**
* Obtain an integer type from a context with specified bit width.
*/
LLVMTypeRef LLVMInt1TypeInContext(LLVMContextRef C);
LLVMTypeRef LLVMInt8TypeInContext(LLVMContextRef C);
LLVMTypeRef LLVMInt16TypeInContext(LLVMContextRef C);
LLVMTypeRef LLVMInt32TypeInContext(LLVMContextRef C);
LLVMTypeRef LLVMInt64TypeInContext(LLVMContextRef C);
LLVMTypeRef LLVMInt128TypeInContext(LLVMContextRef C);
LLVMTypeRef LLVMIntTypeInContext(LLVMContextRef C, unsigned NumBits);
/**
* Obtain an integer type from the global context with a specified bit
* width.
*/
LLVMTypeRef LLVMInt1Type(void);
LLVMTypeRef LLVMInt8Type(void);
LLVMTypeRef LLVMInt16Type(void);
LLVMTypeRef LLVMInt32Type(void);
LLVMTypeRef LLVMInt64Type(void);
LLVMTypeRef LLVMInt128Type(void);
LLVMTypeRef LLVMIntType(unsigned NumBits);
unsigned LLVMGetIntTypeWidth(LLVMTypeRef IntegerTy);
/**
* @}
*/
/**
* @defgroup LLVMCCoreTypeFloat Floating Point Types
*
* @{
*/
/**
* Obtain a 16-bit floating point type from a context.
*/
LLVMTypeRef LLVMHalfTypeInContext(LLVMContextRef C);
/**
* Obtain a 32-bit floating point type from a context.
*/
LLVMTypeRef LLVMFloatTypeInContext(LLVMContextRef C);
/**
* Obtain a 64-bit floating point type from a context.
*/
LLVMTypeRef LLVMDoubleTypeInContext(LLVMContextRef C);
/**
* Obtain a 80-bit floating point type (X87) from a context.
*/
LLVMTypeRef LLVMX86FP80TypeInContext(LLVMContextRef C);
/**
* Obtain a 128-bit floating point type (112-bit mantissa) from a
* context.
*/
LLVMTypeRef LLVMFP128TypeInContext(LLVMContextRef C);
/**
* Obtain a 128-bit floating point type (two 64-bits) from a context.
*/
LLVMTypeRef LLVMPPCFP128TypeInContext(LLVMContextRef C);
/**
* Obtain a floating point type from the global context.
*
* These map to the functions in this group of the same name.
*/
LLVMTypeRef LLVMHalfType(void);
LLVMTypeRef LLVMFloatType(void);
LLVMTypeRef LLVMDoubleType(void);
LLVMTypeRef LLVMX86FP80Type(void);
LLVMTypeRef LLVMFP128Type(void);
LLVMTypeRef LLVMPPCFP128Type(void);
/**
* @}
*/
/**
* @defgroup LLVMCCoreTypeFunction Function Types
*
* @{
*/
/**
* Obtain a function type consisting of a specified signature.
*
* The function is defined as a tuple of a return Type, a list of
* parameter types, and whether the function is variadic.
*/
LLVMTypeRef LLVMFunctionType(LLVMTypeRef ReturnType,
LLVMTypeRef *ParamTypes, unsigned ParamCount,
LLVMBool IsVarArg);
/**
* Returns whether a function type is variadic.
*/
LLVMBool LLVMIsFunctionVarArg(LLVMTypeRef FunctionTy);
/**
* Obtain the Type this function Type returns.
*/
LLVMTypeRef LLVMGetReturnType(LLVMTypeRef FunctionTy);
/**
* Obtain the number of parameters this function accepts.
*/
unsigned LLVMCountParamTypes(LLVMTypeRef FunctionTy);
/**
* Obtain the types of a function's parameters.
*
* The Dest parameter should point to a pre-allocated array of
* LLVMTypeRef at least LLVMCountParamTypes() large. On return, the
* first LLVMCountParamTypes() entries in the array will be populated
* with LLVMTypeRef instances.
*
* @param FunctionTy The function type to operate on.
* @param Dest Memory address of an array to be filled with result.
*/
void LLVMGetParamTypes(LLVMTypeRef FunctionTy, LLVMTypeRef *Dest);
/**
* @}
*/
/**
* @defgroup LLVMCCoreTypeStruct Structure Types
*
* These functions relate to LLVMTypeRef instances.
*
* @see llvm::StructType
*
* @{
*/
/**
* Create a new structure type in a context.
*
* A structure is specified by a list of inner elements/types and
* whether these can be packed together.
*
* @see llvm::StructType::create()
*/
LLVMTypeRef LLVMStructTypeInContext(LLVMContextRef C, LLVMTypeRef *ElementTypes,
unsigned ElementCount, LLVMBool Packed);
/**
* Create a new structure type in the global context.
*
* @see llvm::StructType::create()
*/
LLVMTypeRef LLVMStructType(LLVMTypeRef *ElementTypes, unsigned ElementCount,
LLVMBool Packed);
/**
* Create an empty structure in a context having a specified name.
*
* @see llvm::StructType::create()
*/
LLVMTypeRef LLVMStructCreateNamed(LLVMContextRef C, const char *Name);
/**
* Obtain the name of a structure.
*
* @see llvm::StructType::getName()
*/
const char *LLVMGetStructName(LLVMTypeRef Ty);
/**
* Set the contents of a structure type.
*
* @see llvm::StructType::setBody()
*/
void LLVMStructSetBody(LLVMTypeRef StructTy, LLVMTypeRef *ElementTypes,
unsigned ElementCount, LLVMBool Packed);
/**
* Get the number of elements defined inside the structure.
*
* @see llvm::StructType::getNumElements()
*/
unsigned LLVMCountStructElementTypes(LLVMTypeRef StructTy);
/**
* Get the elements within a structure.
*
* The function is passed the address of a pre-allocated array of
* LLVMTypeRef at least LLVMCountStructElementTypes() long. After
* invocation, this array will be populated with the structure's
* elements. The objects in the destination array will have a lifetime
* of the structure type itself, which is the lifetime of the context it
* is contained in.
*/
void LLVMGetStructElementTypes(LLVMTypeRef StructTy, LLVMTypeRef *Dest);
/**
* Get the type of the element at a given index in the structure.
*
* @see llvm::StructType::getTypeAtIndex()
*/
LLVMTypeRef LLVMStructGetTypeAtIndex(LLVMTypeRef StructTy, unsigned i);
/**
* Determine whether a structure is packed.
*
* @see llvm::StructType::isPacked()
*/
LLVMBool LLVMIsPackedStruct(LLVMTypeRef StructTy);
/**
* Determine whether a structure is opaque.
*
* @see llvm::StructType::isOpaque()
*/
LLVMBool LLVMIsOpaqueStruct(LLVMTypeRef StructTy);
/**
* Determine whether a structure is literal.
*
* @see llvm::StructType::isLiteral()
*/
LLVMBool LLVMIsLiteralStruct(LLVMTypeRef StructTy);
/**
* @}
*/
/**
* @defgroup LLVMCCoreTypeSequential Sequential Types
*
* Sequential types represents "arrays" of types. This is a super class
* for array, vector, and pointer types.
*
* @{
*/
/**
* Obtain the type of elements within a sequential type.
*
* This works on array, vector, and pointer types.
*
* @see llvm::SequentialType::getElementType()
*/
LLVMTypeRef LLVMGetElementType(LLVMTypeRef Ty);
/**
* Returns type's subtypes
*
* @see llvm::Type::subtypes()
*/
void LLVMGetSubtypes(LLVMTypeRef Tp, LLVMTypeRef *Arr);
/**
* Return the number of types in the derived type.
*
* @see llvm::Type::getNumContainedTypes()
*/
unsigned LLVMGetNumContainedTypes(LLVMTypeRef Tp);
/**
* Create a fixed size array type that refers to a specific type.
*
* The created type will exist in the context that its element type
* exists in.
*
* @see llvm::ArrayType::get()
*/
LLVMTypeRef LLVMArrayType(LLVMTypeRef ElementType, unsigned ElementCount);
/**
* Obtain the length of an array type.
*
* This only works on types that represent arrays.
*
* @see llvm::ArrayType::getNumElements()
*/
unsigned LLVMGetArrayLength(LLVMTypeRef ArrayTy);
/**
* Create a pointer type that points to a defined type.
*
* The created type will exist in the context that its pointee type
* exists in.
*
* @see llvm::PointerType::get()
*/
LLVMTypeRef LLVMPointerType(LLVMTypeRef ElementType, unsigned AddressSpace);
/**
* Obtain the address space of a pointer type.
*
* This only works on types that represent pointers.
*
* @see llvm::PointerType::getAddressSpace()
*/
unsigned LLVMGetPointerAddressSpace(LLVMTypeRef PointerTy);
/**
* Create a vector type that contains a defined type and has a specific
* number of elements.
*
* The created type will exist in the context thats its element type
* exists in.
*
* @see llvm::VectorType::get()
*/
LLVMTypeRef LLVMVectorType(LLVMTypeRef ElementType, unsigned ElementCount);
/**
* Obtain the number of elements in a vector type.
*
* This only works on types that represent vectors.
*
* @see llvm::VectorType::getNumElements()
*/
unsigned LLVMGetVectorSize(LLVMTypeRef VectorTy);
/**
* @}
*/
/**
* @defgroup LLVMCCoreTypeOther Other Types
*
* @{
*/
/**
* Create a void type in a context.
*/
LLVMTypeRef LLVMVoidTypeInContext(LLVMContextRef C);
/**
* Create a label type in a context.
*/
LLVMTypeRef LLVMLabelTypeInContext(LLVMContextRef C);
/**
* Create a X86 MMX type in a context.
*/
LLVMTypeRef LLVMX86MMXTypeInContext(LLVMContextRef C);
/**
* Create a token type in a context.
*/
LLVMTypeRef LLVMTokenTypeInContext(LLVMContextRef C);
/**
* Create a metadata type in a context.
*/
LLVMTypeRef LLVMMetadataTypeInContext(LLVMContextRef C);
/**
* These are similar to the above functions except they operate on the
* global context.
*/
LLVMTypeRef LLVMVoidType(void);
LLVMTypeRef LLVMLabelType(void);
LLVMTypeRef LLVMX86MMXType(void);
/**
* @}
*/
/**
* @}
*/
/**
* @defgroup LLVMCCoreValues Values
*
* The bulk of LLVM's object model consists of values, which comprise a very
* rich type hierarchy.
*
* LLVMValueRef essentially represents llvm::Value. There is a rich
* hierarchy of classes within this type. Depending on the instance
* obtained, not all APIs are available.
*
* Callers can determine the type of an LLVMValueRef by calling the
* LLVMIsA* family of functions (e.g. LLVMIsAArgument()). These
* functions are defined by a macro, so it isn't obvious which are
* available by looking at the Doxygen source code. Instead, look at the
* source definition of LLVM_FOR_EACH_VALUE_SUBCLASS and note the list
* of value names given. These value names also correspond to classes in
* the llvm::Value hierarchy.
*
* @{
*/
#define LLVM_FOR_EACH_VALUE_SUBCLASS(macro) \
macro(Argument) \
macro(BasicBlock) \
macro(InlineAsm) \
macro(User) \
macro(Constant) \
macro(BlockAddress) \
macro(ConstantAggregateZero) \
macro(ConstantArray) \
macro(ConstantDataSequential) \
macro(ConstantDataArray) \
macro(ConstantDataVector) \
macro(ConstantExpr) \
macro(ConstantFP) \
macro(ConstantInt) \
macro(ConstantPointerNull) \
macro(ConstantStruct) \
macro(ConstantTokenNone) \
macro(ConstantVector) \
macro(GlobalValue) \
macro(GlobalAlias) \
macro(GlobalIFunc) \
macro(GlobalObject) \
macro(Function) \
macro(GlobalVariable) \
macro(UndefValue) \
macro(Instruction) \
macro(UnaryOperator) \
macro(BinaryOperator) \
macro(CallInst) \
macro(IntrinsicInst) \
macro(DbgInfoIntrinsic) \
macro(DbgVariableIntrinsic) \
macro(DbgDeclareInst) \
macro(DbgLabelInst) \
macro(MemIntrinsic) \
macro(MemCpyInst) \
macro(MemMoveInst) \
macro(MemSetInst) \
macro(CmpInst) \
macro(FCmpInst) \
macro(ICmpInst) \
macro(ExtractElementInst) \
macro(GetElementPtrInst) \
macro(InsertElementInst) \
macro(InsertValueInst) \
macro(LandingPadInst) \
macro(PHINode) \
macro(SelectInst) \
macro(ShuffleVectorInst) \
macro(StoreInst) \
macro(BranchInst) \
macro(IndirectBrInst) \
macro(InvokeInst) \
macro(ReturnInst) \
macro(SwitchInst) \
macro(UnreachableInst) \
macro(ResumeInst) \
macro(CleanupReturnInst) \
macro(CatchReturnInst) \
macro(CatchSwitchInst) \
macro(CallBrInst) \
macro(FuncletPadInst) \
macro(CatchPadInst) \
macro(CleanupPadInst) \
macro(UnaryInstruction) \
macro(AllocaInst) \
macro(CastInst) \
macro(AddrSpaceCastInst) \
macro(BitCastInst) \
macro(FPExtInst) \
macro(FPToSIInst) \
macro(FPToUIInst) \
macro(FPTruncInst) \
macro(IntToPtrInst) \
macro(PtrToIntInst) \
macro(SExtInst) \
macro(SIToFPInst) \
macro(TruncInst) \
macro(UIToFPInst) \
macro(ZExtInst) \
macro(ExtractValueInst) \
macro(LoadInst) \
macro(VAArgInst) \
macro(FreezeInst) \
macro(AtomicCmpXchgInst) \
macro(AtomicRMWInst) \
macro(FenceInst)
/**
* @defgroup LLVMCCoreValueGeneral General APIs
*
* Functions in this section work on all LLVMValueRef instances,
* regardless of their sub-type. They correspond to functions available
* on llvm::Value.
*
* @{
*/
/**
* Obtain the type of a value.
*
* @see llvm::Value::getType()
*/
LLVMTypeRef LLVMTypeOf(LLVMValueRef Val);
/**
* Obtain the enumerated type of a Value instance.
*
* @see llvm::Value::getValueID()
*/
LLVMValueKind LLVMGetValueKind(LLVMValueRef Val);
/**
* Obtain the string name of a value.
*
* @see llvm::Value::getName()
*/
const char *LLVMGetValueName2(LLVMValueRef Val, size_t *Length);
/**
* Set the string name of a value.
*
* @see llvm::Value::setName()
*/
void LLVMSetValueName2(LLVMValueRef Val, const char *Name, size_t NameLen);
/**
* Dump a representation of a value to stderr.
*
* @see llvm::Value::dump()
*/
void LLVMDumpValue(LLVMValueRef Val);
/**
* Return a string representation of the value. Use
* LLVMDisposeMessage to free the string.
*
* @see llvm::Value::print()
*/
char *LLVMPrintValueToString(LLVMValueRef Val);
/**
* Replace all uses of a value with another one.
*
* @see llvm::Value::replaceAllUsesWith()
*/
void LLVMReplaceAllUsesWith(LLVMValueRef OldVal, LLVMValueRef NewVal);
/**
* Determine whether the specified value instance is constant.
*/
LLVMBool LLVMIsConstant(LLVMValueRef Val);
/**
* Determine whether a value instance is undefined.
*/
LLVMBool LLVMIsUndef(LLVMValueRef Val);
/**
* Convert value instances between types.
*
* Internally, an LLVMValueRef is "pinned" to a specific type. This
* series of functions allows you to cast an instance to a specific
* type.
*
* If the cast is not valid for the specified type, NULL is returned.
*
* @see llvm::dyn_cast_or_null<>
*/
#define LLVM_DECLARE_VALUE_CAST(name) \
LLVMValueRef LLVMIsA##name(LLVMValueRef Val);
LLVM_FOR_EACH_VALUE_SUBCLASS(LLVM_DECLARE_VALUE_CAST)
LLVMValueRef LLVMIsAMDNode(LLVMValueRef Val);
LLVMValueRef LLVMIsAMDString(LLVMValueRef Val);
/** Deprecated: Use LLVMGetValueName2 instead. */
const char *LLVMGetValueName(LLVMValueRef Val);
/** Deprecated: Use LLVMSetValueName2 instead. */
void LLVMSetValueName(LLVMValueRef Val, const char *Name);
/**
* @}
*/
/**
* @defgroup LLVMCCoreValueUses Usage
*
* This module defines functions that allow you to inspect the uses of a
* LLVMValueRef.
*
* It is possible to obtain an LLVMUseRef for any LLVMValueRef instance.
* Each LLVMUseRef (which corresponds to a llvm::Use instance) holds a
* llvm::User and llvm::Value.
*
* @{
*/
/**
* Obtain the first use of a value.
*
* Uses are obtained in an iterator fashion. First, call this function
* to obtain a reference to the first use. Then, call LLVMGetNextUse()
* on that instance and all subsequently obtained instances until
* LLVMGetNextUse() returns NULL.
*
* @see llvm::Value::use_begin()
*/
LLVMUseRef LLVMGetFirstUse(LLVMValueRef Val);
/**
* Obtain the next use of a value.
*
* This effectively advances the iterator. It returns NULL if you are on
* the final use and no more are available.
*/
LLVMUseRef LLVMGetNextUse(LLVMUseRef U);
/**
* Obtain the user value for a user.
*
* The returned value corresponds to a llvm::User type.
*
* @see llvm::Use::getUser()
*/
LLVMValueRef LLVMGetUser(LLVMUseRef U);
/**
* Obtain the value this use corresponds to.
*
* @see llvm::Use::get().
*/
LLVMValueRef LLVMGetUsedValue(LLVMUseRef U);
/**
* @}
*/
/**
* @defgroup LLVMCCoreValueUser User value
*
* Function in this group pertain to LLVMValueRef instances that descent
* from llvm::User. This includes constants, instructions, and
* operators.
*
* @{
*/
/**
* Obtain an operand at a specific index in a llvm::User value.
*
* @see llvm::User::getOperand()
*/
LLVMValueRef LLVMGetOperand(LLVMValueRef Val, unsigned Index);
/**
* Obtain the use of an operand at a specific index in a llvm::User value.
*
* @see llvm::User::getOperandUse()
*/
LLVMUseRef LLVMGetOperandUse(LLVMValueRef Val, unsigned Index);
/**
* Set an operand at a specific index in a llvm::User value.
*
* @see llvm::User::setOperand()
*/
void LLVMSetOperand(LLVMValueRef User, unsigned Index, LLVMValueRef Val);
/**
* Obtain the number of operands in a llvm::User value.
*
* @see llvm::User::getNumOperands()
*/
int LLVMGetNumOperands(LLVMValueRef Val);
/**
* @}
*/
/**
* @defgroup LLVMCCoreValueConstant Constants
*
* This section contains APIs for interacting with LLVMValueRef that
* correspond to llvm::Constant instances.
*
* These functions will work for any LLVMValueRef in the llvm::Constant
* class hierarchy.
*
* @{
*/
/**
* Obtain a constant value referring to the null instance of a type.
*
* @see llvm::Constant::getNullValue()
*/
LLVMValueRef LLVMConstNull(LLVMTypeRef Ty); /* all zeroes */
/**
* Obtain a constant value referring to the instance of a type
* consisting of all ones.
*
* This is only valid for integer types.
*
* @see llvm::Constant::getAllOnesValue()
*/
LLVMValueRef LLVMConstAllOnes(LLVMTypeRef Ty);
/**
* Obtain a constant value referring to an undefined value of a type.
*
* @see llvm::UndefValue::get()
*/
LLVMValueRef LLVMGetUndef(LLVMTypeRef Ty);
/**
* Determine whether a value instance is null.
*
* @see llvm::Constant::isNullValue()
*/
LLVMBool LLVMIsNull(LLVMValueRef Val);
/**
* Obtain a constant that is a constant pointer pointing to NULL for a
* specified type.
*/
LLVMValueRef LLVMConstPointerNull(LLVMTypeRef Ty);
/**
* @defgroup LLVMCCoreValueConstantScalar Scalar constants
*
* Functions in this group model LLVMValueRef instances that correspond
* to constants referring to scalar types.
*
* For integer types, the LLVMTypeRef parameter should correspond to a
* llvm::IntegerType instance and the returned LLVMValueRef will
* correspond to a llvm::ConstantInt.
*
* For floating point types, the LLVMTypeRef returned corresponds to a
* llvm::ConstantFP.
*
* @{
*/
/**
* Obtain a constant value for an integer type.
*
* The returned value corresponds to a llvm::ConstantInt.
*
* @see llvm::ConstantInt::get()
*
* @param IntTy Integer type to obtain value of.
* @param N The value the returned instance should refer to.
* @param SignExtend Whether to sign extend the produced value.
*/
LLVMValueRef LLVMConstInt(LLVMTypeRef IntTy, unsigned long long N,
LLVMBool SignExtend);
/**
* Obtain a constant value for an integer of arbitrary precision.
*
* @see llvm::ConstantInt::get()
*/
LLVMValueRef LLVMConstIntOfArbitraryPrecision(LLVMTypeRef IntTy,
unsigned NumWords,
const uint64_t Words[]);
/**
* Obtain a constant value for an integer parsed from a string.
*
* A similar API, LLVMConstIntOfStringAndSize is also available. If the
* string's length is available, it is preferred to call that function
* instead.
*
* @see llvm::ConstantInt::get()
*/
LLVMValueRef LLVMConstIntOfString(LLVMTypeRef IntTy, const char *Text,
uint8_t Radix);
/**
* Obtain a constant value for an integer parsed from a string with
* specified length.
*
* @see llvm::ConstantInt::get()
*/
LLVMValueRef LLVMConstIntOfStringAndSize(LLVMTypeRef IntTy, const char *Text,
unsigned SLen, uint8_t Radix);
/**
* Obtain a constant value referring to a double floating point value.
*/
LLVMValueRef LLVMConstReal(LLVMTypeRef RealTy, double N);
/**
* Obtain a constant for a floating point value parsed from a string.
*
* A similar API, LLVMConstRealOfStringAndSize is also available. It
* should be used if the input string's length is known.
*/
LLVMValueRef LLVMConstRealOfString(LLVMTypeRef RealTy, const char *Text);
/**
* Obtain a constant for a floating point value parsed from a string.
*/
LLVMValueRef LLVMConstRealOfStringAndSize(LLVMTypeRef RealTy, const char *Text,
unsigned SLen);
/**
* Obtain the zero extended value for an integer constant value.
*
* @see llvm::ConstantInt::getZExtValue()
*/
unsigned long long LLVMConstIntGetZExtValue(LLVMValueRef ConstantVal);
/**
* Obtain the sign extended value for an integer constant value.
*
* @see llvm::ConstantInt::getSExtValue()
*/
long long LLVMConstIntGetSExtValue(LLVMValueRef ConstantVal);
/**
* Obtain the double value for an floating point constant value.
* losesInfo indicates if some precision was lost in the conversion.
*
* @see llvm::ConstantFP::getDoubleValue
*/
double LLVMConstRealGetDouble(LLVMValueRef ConstantVal, LLVMBool *losesInfo);
/**
* @}
*/
/**
* @defgroup LLVMCCoreValueConstantComposite Composite Constants
*
* Functions in this group operate on composite constants.
*
* @{
*/
/**
* Create a ConstantDataSequential and initialize it with a string.
*
* @see llvm::ConstantDataArray::getString()
*/
LLVMValueRef LLVMConstStringInContext(LLVMContextRef C, const char *Str,
unsigned Length, LLVMBool DontNullTerminate);
/**
* Create a ConstantDataSequential with string content in the global context.
*
* This is the same as LLVMConstStringInContext except it operates on the
* global context.
*
* @see LLVMConstStringInContext()
* @see llvm::ConstantDataArray::getString()
*/
LLVMValueRef LLVMConstString(const char *Str, unsigned Length,
LLVMBool DontNullTerminate);
/**
* Returns true if the specified constant is an array of i8.
*
* @see ConstantDataSequential::getAsString()
*/
LLVMBool LLVMIsConstantString(LLVMValueRef c);
/**
* Get the given constant data sequential as a string.
*
* @see ConstantDataSequential::getAsString()
*/
const char *LLVMGetAsString(LLVMValueRef c, size_t *Length);
/**
* Create an anonymous ConstantStruct with the specified values.
*
* @see llvm::ConstantStruct::getAnon()
*/
LLVMValueRef LLVMConstStructInContext(LLVMContextRef C,
LLVMValueRef *ConstantVals,
unsigned Count, LLVMBool Packed);
/**
* Create a ConstantStruct in the global Context.
*
* This is the same as LLVMConstStructInContext except it operates on the
* global Context.
*
* @see LLVMConstStructInContext()
*/
LLVMValueRef LLVMConstStruct(LLVMValueRef *ConstantVals, unsigned Count,
LLVMBool Packed);
/**
* Create a ConstantArray from values.
*
* @see llvm::ConstantArray::get()
*/
LLVMValueRef LLVMConstArray(LLVMTypeRef ElementTy,
LLVMValueRef *ConstantVals, unsigned Length);
/**
* Create a non-anonymous ConstantStruct from values.
*
* @see llvm::ConstantStruct::get()
*/
LLVMValueRef LLVMConstNamedStruct(LLVMTypeRef StructTy,
LLVMValueRef *ConstantVals,
unsigned Count);
/**
* Get an element at specified index as a constant.
*
* @see ConstantDataSequential::getElementAsConstant()
*/
LLVMValueRef LLVMGetElementAsConstant(LLVMValueRef C, unsigned idx);
/**
* Create a ConstantVector from values.
*
* @see llvm::ConstantVector::get()
*/
LLVMValueRef LLVMConstVector(LLVMValueRef *ScalarConstantVals, unsigned Size);
/**
* @}
*/
/**
* @defgroup LLVMCCoreValueConstantExpressions Constant Expressions
*
* Functions in this group correspond to APIs on llvm::ConstantExpr.
*
* @see llvm::ConstantExpr.
*
* @{
*/
LLVMOpcode LLVMGetConstOpcode(LLVMValueRef ConstantVal);
LLVMValueRef LLVMAlignOf(LLVMTypeRef Ty);
LLVMValueRef LLVMSizeOf(LLVMTypeRef Ty);
LLVMValueRef LLVMConstNeg(LLVMValueRef ConstantVal);
LLVMValueRef LLVMConstNSWNeg(LLVMValueRef ConstantVal);
LLVMValueRef LLVMConstNUWNeg(LLVMValueRef ConstantVal);
LLVMValueRef LLVMConstFNeg(LLVMValueRef ConstantVal);
LLVMValueRef LLVMConstNot(LLVMValueRef ConstantVal);
LLVMValueRef LLVMConstAdd(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
LLVMValueRef LLVMConstNSWAdd(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
LLVMValueRef LLVMConstNUWAdd(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
LLVMValueRef LLVMConstFAdd(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
LLVMValueRef LLVMConstSub(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
LLVMValueRef LLVMConstNSWSub(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
LLVMValueRef LLVMConstNUWSub(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
LLVMValueRef LLVMConstFSub(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
LLVMValueRef LLVMConstMul(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
LLVMValueRef LLVMConstNSWMul(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
LLVMValueRef LLVMConstNUWMul(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
LLVMValueRef LLVMConstFMul(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
LLVMValueRef LLVMConstUDiv(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
LLVMValueRef LLVMConstExactUDiv(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
LLVMValueRef LLVMConstSDiv(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
LLVMValueRef LLVMConstExactSDiv(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
LLVMValueRef LLVMConstFDiv(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
LLVMValueRef LLVMConstURem(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
LLVMValueRef LLVMConstSRem(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
LLVMValueRef LLVMConstFRem(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
LLVMValueRef LLVMConstAnd(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
LLVMValueRef LLVMConstOr(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
LLVMValueRef LLVMConstXor(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
LLVMValueRef LLVMConstICmp(LLVMIntPredicate Predicate,
LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
LLVMValueRef LLVMConstFCmp(LLVMRealPredicate Predicate,
LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
LLVMValueRef LLVMConstShl(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
LLVMValueRef LLVMConstLShr(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
LLVMValueRef LLVMConstAShr(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
LLVMValueRef LLVMConstGEP(LLVMValueRef ConstantVal,
LLVMValueRef *ConstantIndices, unsigned NumIndices);
LLVMValueRef LLVMConstGEP2(LLVMTypeRef Ty, LLVMValueRef ConstantVal,
LLVMValueRef *ConstantIndices, unsigned NumIndices);
LLVMValueRef LLVMConstInBoundsGEP(LLVMValueRef ConstantVal,
LLVMValueRef *ConstantIndices,
unsigned NumIndices);
LLVMValueRef LLVMConstInBoundsGEP2(LLVMTypeRef Ty, LLVMValueRef ConstantVal,
LLVMValueRef *ConstantIndices,
unsigned NumIndices);
LLVMValueRef LLVMConstTrunc(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
LLVMValueRef LLVMConstSExt(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
LLVMValueRef LLVMConstZExt(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
LLVMValueRef LLVMConstFPTrunc(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
LLVMValueRef LLVMConstFPExt(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
LLVMValueRef LLVMConstUIToFP(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
LLVMValueRef LLVMConstSIToFP(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
LLVMValueRef LLVMConstFPToUI(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
LLVMValueRef LLVMConstFPToSI(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
LLVMValueRef LLVMConstPtrToInt(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
LLVMValueRef LLVMConstIntToPtr(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
LLVMValueRef LLVMConstBitCast(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
LLVMValueRef LLVMConstAddrSpaceCast(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
LLVMValueRef LLVMConstZExtOrBitCast(LLVMValueRef ConstantVal,
LLVMTypeRef ToType);
LLVMValueRef LLVMConstSExtOrBitCast(LLVMValueRef ConstantVal,
LLVMTypeRef ToType);
LLVMValueRef LLVMConstTruncOrBitCast(LLVMValueRef ConstantVal,
LLVMTypeRef ToType);
LLVMValueRef LLVMConstPointerCast(LLVMValueRef ConstantVal,
LLVMTypeRef ToType);
LLVMValueRef LLVMConstIntCast(LLVMValueRef ConstantVal, LLVMTypeRef ToType,
LLVMBool isSigned);
LLVMValueRef LLVMConstFPCast(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
LLVMValueRef LLVMConstSelect(LLVMValueRef ConstantCondition,
LLVMValueRef ConstantIfTrue,
LLVMValueRef ConstantIfFalse);
LLVMValueRef LLVMConstExtractElement(LLVMValueRef VectorConstant,
LLVMValueRef IndexConstant);
LLVMValueRef LLVMConstInsertElement(LLVMValueRef VectorConstant,
LLVMValueRef ElementValueConstant,
LLVMValueRef IndexConstant);
LLVMValueRef LLVMConstShuffleVector(LLVMValueRef VectorAConstant,
LLVMValueRef VectorBConstant,
LLVMValueRef MaskConstant);
LLVMValueRef LLVMConstExtractValue(LLVMValueRef AggConstant, unsigned *IdxList,
unsigned NumIdx);
LLVMValueRef LLVMConstInsertValue(LLVMValueRef AggConstant,
LLVMValueRef ElementValueConstant,
unsigned *IdxList, unsigned NumIdx);
LLVMValueRef LLVMBlockAddress(LLVMValueRef F, LLVMBasicBlockRef BB);
/** Deprecated: Use LLVMGetInlineAsm instead. */
LLVMValueRef LLVMConstInlineAsm(LLVMTypeRef Ty,
const char *AsmString, const char *Constraints,
LLVMBool HasSideEffects, LLVMBool IsAlignStack);
/**
* @}
*/
/**
* @defgroup LLVMCCoreValueConstantGlobals Global Values
*
* This group contains functions that operate on global values. Functions in
* this group relate to functions in the llvm::GlobalValue class tree.
*
* @see llvm::GlobalValue
*
* @{
*/
LLVMModuleRef LLVMGetGlobalParent(LLVMValueRef Global);
LLVMBool LLVMIsDeclaration(LLVMValueRef Global);
LLVMLinkage LLVMGetLinkage(LLVMValueRef Global);
void LLVMSetLinkage(LLVMValueRef Global, LLVMLinkage Linkage);
const char *LLVMGetSection(LLVMValueRef Global);
void LLVMSetSection(LLVMValueRef Global, const char *Section);
LLVMVisibility LLVMGetVisibility(LLVMValueRef Global);
void LLVMSetVisibility(LLVMValueRef Global, LLVMVisibility Viz);
LLVMDLLStorageClass LLVMGetDLLStorageClass(LLVMValueRef Global);
void LLVMSetDLLStorageClass(LLVMValueRef Global, LLVMDLLStorageClass Class);
LLVMUnnamedAddr LLVMGetUnnamedAddress(LLVMValueRef Global);
void LLVMSetUnnamedAddress(LLVMValueRef Global, LLVMUnnamedAddr UnnamedAddr);
/**
* Returns the "value type" of a global value. This differs from the formal
* type of a global value which is always a pointer type.
*
* @see llvm::GlobalValue::getValueType()
*/
LLVMTypeRef LLVMGlobalGetValueType(LLVMValueRef Global);
/** Deprecated: Use LLVMGetUnnamedAddress instead. */
LLVMBool LLVMHasUnnamedAddr(LLVMValueRef Global);
/** Deprecated: Use LLVMSetUnnamedAddress instead. */
void LLVMSetUnnamedAddr(LLVMValueRef Global, LLVMBool HasUnnamedAddr);
/**
* @defgroup LLVMCCoreValueWithAlignment Values with alignment
*
* Functions in this group only apply to values with alignment, i.e.
* global variables, load and store instructions.
*/
/**
* Obtain the preferred alignment of the value.
* @see llvm::AllocaInst::getAlignment()
* @see llvm::LoadInst::getAlignment()
* @see llvm::StoreInst::getAlignment()
* @see llvm::GlobalValue::getAlignment()
*/
unsigned LLVMGetAlignment(LLVMValueRef V);
/**
* Set the preferred alignment of the value.
* @see llvm::AllocaInst::setAlignment()
* @see llvm::LoadInst::setAlignment()
* @see llvm::StoreInst::setAlignment()
* @see llvm::GlobalValue::setAlignment()
*/
void LLVMSetAlignment(LLVMValueRef V, unsigned Bytes);
/**
* Sets a metadata attachment, erasing the existing metadata attachment if
* it already exists for the given kind.
*
* @see llvm::GlobalObject::setMetadata()
*/
void LLVMGlobalSetMetadata(LLVMValueRef Global, unsigned Kind,
LLVMMetadataRef MD);
/**
* Erases a metadata attachment of the given kind if it exists.
*
* @see llvm::GlobalObject::eraseMetadata()
*/
void LLVMGlobalEraseMetadata(LLVMValueRef Global, unsigned Kind);
/**
* Removes all metadata attachments from this value.
*
* @see llvm::GlobalObject::clearMetadata()
*/
void LLVMGlobalClearMetadata(LLVMValueRef Global);
/**
* Retrieves an array of metadata entries representing the metadata attached to
* this value. The caller is responsible for freeing this array by calling
* \c LLVMDisposeValueMetadataEntries.
*
* @see llvm::GlobalObject::getAllMetadata()
*/
LLVMValueMetadataEntry *LLVMGlobalCopyAllMetadata(LLVMValueRef Value,
size_t *NumEntries);
/**
* Destroys value metadata entries.
*/
void LLVMDisposeValueMetadataEntries(LLVMValueMetadataEntry *Entries);
/**
* Returns the kind of a value metadata entry at a specific index.
*/
unsigned LLVMValueMetadataEntriesGetKind(LLVMValueMetadataEntry *Entries,
unsigned Index);
/**
* Returns the underlying metadata node of a value metadata entry at a
* specific index.
*/
LLVMMetadataRef
LLVMValueMetadataEntriesGetMetadata(LLVMValueMetadataEntry *Entries,
unsigned Index);
/**
* @}
*/
/**
* @defgroup LLVMCoreValueConstantGlobalVariable Global Variables
*
* This group contains functions that operate on global variable values.
*
* @see llvm::GlobalVariable
*
* @{
*/
LLVMValueRef LLVMAddGlobal(LLVMModuleRef M, LLVMTypeRef Ty, const char *Name);
LLVMValueRef LLVMAddGlobalInAddressSpace(LLVMModuleRef M, LLVMTypeRef Ty,
const char *Name,
unsigned AddressSpace);
LLVMValueRef LLVMGetNamedGlobal(LLVMModuleRef M, const char *Name);
LLVMValueRef LLVMGetFirstGlobal(LLVMModuleRef M);
LLVMValueRef LLVMGetLastGlobal(LLVMModuleRef M);
LLVMValueRef LLVMGetNextGlobal(LLVMValueRef GlobalVar);
LLVMValueRef LLVMGetPreviousGlobal(LLVMValueRef GlobalVar);
void LLVMDeleteGlobal(LLVMValueRef GlobalVar);
LLVMValueRef LLVMGetInitializer(LLVMValueRef GlobalVar);
void LLVMSetInitializer(LLVMValueRef GlobalVar, LLVMValueRef ConstantVal);
LLVMBool LLVMIsThreadLocal(LLVMValueRef GlobalVar);
void LLVMSetThreadLocal(LLVMValueRef GlobalVar, LLVMBool IsThreadLocal);
LLVMBool LLVMIsGlobalConstant(LLVMValueRef GlobalVar);
void LLVMSetGlobalConstant(LLVMValueRef GlobalVar, LLVMBool IsConstant);
LLVMThreadLocalMode LLVMGetThreadLocalMode(LLVMValueRef GlobalVar);
void LLVMSetThreadLocalMode(LLVMValueRef GlobalVar, LLVMThreadLocalMode Mode);
LLVMBool LLVMIsExternallyInitialized(LLVMValueRef GlobalVar);
void LLVMSetExternallyInitialized(LLVMValueRef GlobalVar, LLVMBool IsExtInit);
/**
* @}
*/
/**
* @defgroup LLVMCoreValueConstantGlobalAlias Global Aliases
*
* This group contains function that operate on global alias values.
*
* @see llvm::GlobalAlias
*
* @{
*/
LLVMValueRef LLVMAddAlias(LLVMModuleRef M, LLVMTypeRef Ty, LLVMValueRef Aliasee,
const char *Name);
/**
* Obtain a GlobalAlias value from a Module by its name.
*
* The returned value corresponds to a llvm::GlobalAlias value.
*
* @see llvm::Module::getNamedAlias()
*/
LLVMValueRef LLVMGetNamedGlobalAlias(LLVMModuleRef M,
const char *Name, size_t NameLen);
/**
* Obtain an iterator to the first GlobalAlias in a Module.
*
* @see llvm::Module::alias_begin()
*/
LLVMValueRef LLVMGetFirstGlobalAlias(LLVMModuleRef M);
/**
* Obtain an iterator to the last GlobalAlias in a Module.
*
* @see llvm::Module::alias_end()
*/
LLVMValueRef LLVMGetLastGlobalAlias(LLVMModuleRef M);
/**
* Advance a GlobalAlias iterator to the next GlobalAlias.
*
* Returns NULL if the iterator was already at the end and there are no more
* global aliases.
*/
LLVMValueRef LLVMGetNextGlobalAlias(LLVMValueRef GA);
/**
* Decrement a GlobalAlias iterator to the previous GlobalAlias.
*
* Returns NULL if the iterator was already at the beginning and there are
* no previous global aliases.
*/
LLVMValueRef LLVMGetPreviousGlobalAlias(LLVMValueRef GA);
/**
* Retrieve the target value of an alias.
*/
LLVMValueRef LLVMAliasGetAliasee(LLVMValueRef Alias);
/**
* Set the target value of an alias.
*/
void LLVMAliasSetAliasee(LLVMValueRef Alias, LLVMValueRef Aliasee);
/**
* @}
*/
/**
* @defgroup LLVMCCoreValueFunction Function values
*
* Functions in this group operate on LLVMValueRef instances that
* correspond to llvm::Function instances.
*
* @see llvm::Function
*
* @{
*/
/**
* Remove a function from its containing module and deletes it.
*
* @see llvm::Function::eraseFromParent()
*/
void LLVMDeleteFunction(LLVMValueRef Fn);
/**
* Check whether the given function has a personality function.
*
* @see llvm::Function::hasPersonalityFn()
*/
LLVMBool LLVMHasPersonalityFn(LLVMValueRef Fn);
/**
* Obtain the personality function attached to the function.
*
* @see llvm::Function::getPersonalityFn()
*/
LLVMValueRef LLVMGetPersonalityFn(LLVMValueRef Fn);
/**
* Set the personality function attached to the function.
*
* @see llvm::Function::setPersonalityFn()
*/
void LLVMSetPersonalityFn(LLVMValueRef Fn, LLVMValueRef PersonalityFn);
/**
* Obtain the intrinsic ID number which matches the given function name.
*
* @see llvm::Function::lookupIntrinsicID()
*/
unsigned LLVMLookupIntrinsicID(const char *Name, size_t NameLen);
/**
* Obtain the ID number from a function instance.
*
* @see llvm::Function::getIntrinsicID()
*/
unsigned LLVMGetIntrinsicID(LLVMValueRef Fn);
/**
* Create or insert the declaration of an intrinsic. For overloaded intrinsics,
* parameter types must be provided to uniquely identify an overload.
*
* @see llvm::Intrinsic::getDeclaration()
*/
LLVMValueRef LLVMGetIntrinsicDeclaration(LLVMModuleRef Mod,
unsigned ID,
LLVMTypeRef *ParamTypes,
size_t ParamCount);
/**
* Retrieves the type of an intrinsic. For overloaded intrinsics, parameter
* types must be provided to uniquely identify an overload.
*
* @see llvm::Intrinsic::getType()
*/
LLVMTypeRef LLVMIntrinsicGetType(LLVMContextRef Ctx, unsigned ID,
LLVMTypeRef *ParamTypes, size_t ParamCount);
/**
* Retrieves the name of an intrinsic.
*
* @see llvm::Intrinsic::getName()
*/
const char *LLVMIntrinsicGetName(unsigned ID, size_t *NameLength);
/**
* Copies the name of an overloaded intrinsic identified by a given list of
* parameter types.
*
* Unlike LLVMIntrinsicGetName, the caller is responsible for freeing the
* returned string.
*
* @see llvm::Intrinsic::getName()
*/
const char *LLVMIntrinsicCopyOverloadedName(unsigned ID,
LLVMTypeRef *ParamTypes,
size_t ParamCount,
size_t *NameLength);
/**
* Obtain if the intrinsic identified by the given ID is overloaded.
*
* @see llvm::Intrinsic::isOverloaded()
*/
LLVMBool LLVMIntrinsicIsOverloaded(unsigned ID);
/**
* Obtain the calling function of a function.
*
* The returned value corresponds to the LLVMCallConv enumeration.
*
* @see llvm::Function::getCallingConv()
*/
unsigned LLVMGetFunctionCallConv(LLVMValueRef Fn);
/**
* Set the calling convention of a function.
*
* @see llvm::Function::setCallingConv()
*
* @param Fn Function to operate on
* @param CC LLVMCallConv to set calling convention to
*/
void LLVMSetFunctionCallConv(LLVMValueRef Fn, unsigned CC);
/**
* Obtain the name of the garbage collector to use during code
* generation.
*
* @see llvm::Function::getGC()
*/
const char *LLVMGetGC(LLVMValueRef Fn);
/**
* Define the garbage collector to use during code generation.
*
* @see llvm::Function::setGC()
*/
void LLVMSetGC(LLVMValueRef Fn, const char *Name);
/**
* Add an attribute to a function.
*
* @see llvm::Function::addAttribute()
*/
void LLVMAddAttributeAtIndex(LLVMValueRef F, LLVMAttributeIndex Idx,
LLVMAttributeRef A);
unsigned LLVMGetAttributeCountAtIndex(LLVMValueRef F, LLVMAttributeIndex Idx);
void LLVMGetAttributesAtIndex(LLVMValueRef F, LLVMAttributeIndex Idx,
LLVMAttributeRef *Attrs);
LLVMAttributeRef LLVMGetEnumAttributeAtIndex(LLVMValueRef F,
LLVMAttributeIndex Idx,
unsigned KindID);
LLVMAttributeRef LLVMGetStringAttributeAtIndex(LLVMValueRef F,
LLVMAttributeIndex Idx,
const char *K, unsigned KLen);
void LLVMRemoveEnumAttributeAtIndex(LLVMValueRef F, LLVMAttributeIndex Idx,
unsigned KindID);
void LLVMRemoveStringAttributeAtIndex(LLVMValueRef F, LLVMAttributeIndex Idx,
const char *K, unsigned KLen);
/**
* Add a target-dependent attribute to a function
* @see llvm::AttrBuilder::addAttribute()
*/
void LLVMAddTargetDependentFunctionAttr(LLVMValueRef Fn, const char *A,
const char *V);
/**
* @defgroup LLVMCCoreValueFunctionParameters Function Parameters
*
* Functions in this group relate to arguments/parameters on functions.
*
* Functions in this group expect LLVMValueRef instances that correspond
* to llvm::Function instances.
*
* @{
*/
/**
* Obtain the number of parameters in a function.
*
* @see llvm::Function::arg_size()
*/
unsigned LLVMCountParams(LLVMValueRef Fn);
/**
* Obtain the parameters in a function.
*
* The takes a pointer to a pre-allocated array of LLVMValueRef that is
* at least LLVMCountParams() long. This array will be filled with
* LLVMValueRef instances which correspond to the parameters the
* function receives. Each LLVMValueRef corresponds to a llvm::Argument
* instance.
*
* @see llvm::Function::arg_begin()
*/
void LLVMGetParams(LLVMValueRef Fn, LLVMValueRef *Params);
/**
* Obtain the parameter at the specified index.
*
* Parameters are indexed from 0.
*
* @see llvm::Function::arg_begin()
*/
LLVMValueRef LLVMGetParam(LLVMValueRef Fn, unsigned Index);
/**
* Obtain the function to which this argument belongs.
*
* Unlike other functions in this group, this one takes an LLVMValueRef
* that corresponds to a llvm::Attribute.
*
* The returned LLVMValueRef is the llvm::Function to which this
* argument belongs.
*/
LLVMValueRef LLVMGetParamParent(LLVMValueRef Inst);
/**
* Obtain the first parameter to a function.
*
* @see llvm::Function::arg_begin()
*/
LLVMValueRef LLVMGetFirstParam(LLVMValueRef Fn);
/**
* Obtain the last parameter to a function.
*
* @see llvm::Function::arg_end()
*/
LLVMValueRef LLVMGetLastParam(LLVMValueRef Fn);
/**
* Obtain the next parameter to a function.
*
* This takes an LLVMValueRef obtained from LLVMGetFirstParam() (which is
* actually a wrapped iterator) and obtains the next parameter from the
* underlying iterator.
*/
LLVMValueRef LLVMGetNextParam(LLVMValueRef Arg);
/**
* Obtain the previous parameter to a function.
*
* This is the opposite of LLVMGetNextParam().
*/
LLVMValueRef LLVMGetPreviousParam(LLVMValueRef Arg);
/**
* Set the alignment for a function parameter.
*
* @see llvm::Argument::addAttr()
* @see llvm::AttrBuilder::addAlignmentAttr()
*/
void LLVMSetParamAlignment(LLVMValueRef Arg, unsigned Align);
/**
* @}
*/
/**
* @defgroup LLVMCCoreValueGlobalIFunc IFuncs
*
* Functions in this group relate to indirect functions.
*
* Functions in this group expect LLVMValueRef instances that correspond
* to llvm::GlobalIFunc instances.
*
* @{
*/
/**
* Add a global indirect function to a module under a specified name.
*
* @see llvm::GlobalIFunc::create()
*/
LLVMValueRef LLVMAddGlobalIFunc(LLVMModuleRef M,
const char *Name, size_t NameLen,
LLVMTypeRef Ty, unsigned AddrSpace,
LLVMValueRef Resolver);
/**
* Obtain a GlobalIFunc value from a Module by its name.
*
* The returned value corresponds to a llvm::GlobalIFunc value.
*
* @see llvm::Module::getNamedIFunc()
*/
LLVMValueRef LLVMGetNamedGlobalIFunc(LLVMModuleRef M,
const char *Name, size_t NameLen);
/**
* Obtain an iterator to the first GlobalIFunc in a Module.
*
* @see llvm::Module::ifunc_begin()
*/
LLVMValueRef LLVMGetFirstGlobalIFunc(LLVMModuleRef M);
/**
* Obtain an iterator to the last GlobalIFunc in a Module.
*
* @see llvm::Module::ifunc_end()
*/
LLVMValueRef LLVMGetLastGlobalIFunc(LLVMModuleRef M);
/**
* Advance a GlobalIFunc iterator to the next GlobalIFunc.
*
* Returns NULL if the iterator was already at the end and there are no more
* global aliases.
*/
LLVMValueRef LLVMGetNextGlobalIFunc(LLVMValueRef IFunc);
/**
* Decrement a GlobalIFunc iterator to the previous GlobalIFunc.
*
* Returns NULL if the iterator was already at the beginning and there are
* no previous global aliases.
*/
LLVMValueRef LLVMGetPreviousGlobalIFunc(LLVMValueRef IFunc);
/**
* Retrieves the resolver function associated with this indirect function, or
* NULL if it doesn't not exist.
*
* @see llvm::GlobalIFunc::getResolver()
*/
LLVMValueRef LLVMGetGlobalIFuncResolver(LLVMValueRef IFunc);
/**
* Sets the resolver function associated with this indirect function.
*
* @see llvm::GlobalIFunc::setResolver()
*/
void LLVMSetGlobalIFuncResolver(LLVMValueRef IFunc, LLVMValueRef Resolver);
/**
* Remove a global indirect function from its parent module and delete it.
*
* @see llvm::GlobalIFunc::eraseFromParent()
*/
void LLVMEraseGlobalIFunc(LLVMValueRef IFunc);
/**
* Remove a global indirect function from its parent module.
*
* This unlinks the global indirect function from its containing module but
* keeps it alive.
*
* @see llvm::GlobalIFunc::removeFromParent()
*/
void LLVMRemoveGlobalIFunc(LLVMValueRef IFunc);
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/**
* @defgroup LLVMCCoreValueMetadata Metadata
*
* @{
*/
/**
* Create an MDString value from a given string value.
*
* The MDString value does not take ownership of the given string, it remains
* the responsibility of the caller to free it.
*
* @see llvm::MDString::get()
*/
LLVMMetadataRef LLVMMDStringInContext2(LLVMContextRef C, const char *Str,
size_t SLen);
/**
* Create an MDNode value with the given array of operands.
*
* @see llvm::MDNode::get()
*/
LLVMMetadataRef LLVMMDNodeInContext2(LLVMContextRef C, LLVMMetadataRef *MDs,
size_t Count);
/**
* Obtain a Metadata as a Value.
*/
LLVMValueRef LLVMMetadataAsValue(LLVMContextRef C, LLVMMetadataRef MD);
/**
* Obtain a Value as a Metadata.
*/
LLVMMetadataRef LLVMValueAsMetadata(LLVMValueRef Val);
/**
* Obtain the underlying string from a MDString value.
*
* @param V Instance to obtain string from.
* @param Length Memory address which will hold length of returned string.
* @return String data in MDString.
*/
const char *LLVMGetMDString(LLVMValueRef V, unsigned *Length);
/**
* Obtain the number of operands from an MDNode value.
*
* @param V MDNode to get number of operands from.
* @return Number of operands of the MDNode.
*/
unsigned LLVMGetMDNodeNumOperands(LLVMValueRef V);
/**
* Obtain the given MDNode's operands.
*
* The passed LLVMValueRef pointer should point to enough memory to hold all of
* the operands of the given MDNode (see LLVMGetMDNodeNumOperands) as
* LLVMValueRefs. This memory will be populated with the LLVMValueRefs of the
* MDNode's operands.
*
* @param V MDNode to get the operands from.
* @param Dest Destination array for operands.
*/
void LLVMGetMDNodeOperands(LLVMValueRef V, LLVMValueRef *Dest);
/** Deprecated: Use LLVMMDStringInContext2 instead. */
LLVMValueRef LLVMMDStringInContext(LLVMContextRef C, const char *Str,
unsigned SLen);
/** Deprecated: Use LLVMMDStringInContext2 instead. */
LLVMValueRef LLVMMDString(const char *Str, unsigned SLen);
/** Deprecated: Use LLVMMDNodeInContext2 instead. */
LLVMValueRef LLVMMDNodeInContext(LLVMContextRef C, LLVMValueRef *Vals,
unsigned Count);
/** Deprecated: Use LLVMMDNodeInContext2 instead. */
LLVMValueRef LLVMMDNode(LLVMValueRef *Vals, unsigned Count);
/**
* @}
*/
/**
* @defgroup LLVMCCoreValueBasicBlock Basic Block
*
* A basic block represents a single entry single exit section of code.
* Basic blocks contain a list of instructions which form the body of
* the block.
*
* Basic blocks belong to functions. They have the type of label.
*
* Basic blocks are themselves values. However, the C API models them as
* LLVMBasicBlockRef.
*
* @see llvm::BasicBlock
*
* @{
*/
/**
* Convert a basic block instance to a value type.
*/
LLVMValueRef LLVMBasicBlockAsValue(LLVMBasicBlockRef BB);
/**
* Determine whether an LLVMValueRef is itself a basic block.
*/
LLVMBool LLVMValueIsBasicBlock(LLVMValueRef Val);
/**
* Convert an LLVMValueRef to an LLVMBasicBlockRef instance.
*/
LLVMBasicBlockRef LLVMValueAsBasicBlock(LLVMValueRef Val);
/**
* Obtain the string name of a basic block.
*/
const char *LLVMGetBasicBlockName(LLVMBasicBlockRef BB);
/**
* Obtain the function to which a basic block belongs.
*
* @see llvm::BasicBlock::getParent()
*/
LLVMValueRef LLVMGetBasicBlockParent(LLVMBasicBlockRef BB);
/**
* Obtain the terminator instruction for a basic block.
*
* If the basic block does not have a terminator (it is not well-formed
* if it doesn't), then NULL is returned.
*
* The returned LLVMValueRef corresponds to an llvm::Instruction.
*
* @see llvm::BasicBlock::getTerminator()
*/
LLVMValueRef LLVMGetBasicBlockTerminator(LLVMBasicBlockRef BB);
/**
* Obtain the number of basic blocks in a function.
*
* @param Fn Function value to operate on.
*/
unsigned LLVMCountBasicBlocks(LLVMValueRef Fn);
/**
* Obtain all of the basic blocks in a function.
*
* This operates on a function value. The BasicBlocks parameter is a
* pointer to a pre-allocated array of LLVMBasicBlockRef of at least
* LLVMCountBasicBlocks() in length. This array is populated with
* LLVMBasicBlockRef instances.
*/
void LLVMGetBasicBlocks(LLVMValueRef Fn, LLVMBasicBlockRef *BasicBlocks);
/**
* Obtain the first basic block in a function.
*
* The returned basic block can be used as an iterator. You will likely
* eventually call into LLVMGetNextBasicBlock() with it.
*
* @see llvm::Function::begin()
*/
LLVMBasicBlockRef LLVMGetFirstBasicBlock(LLVMValueRef Fn);
/**
* Obtain the last basic block in a function.
*
* @see llvm::Function::end()
*/
LLVMBasicBlockRef LLVMGetLastBasicBlock(LLVMValueRef Fn);
/**
* Advance a basic block iterator.
*/
LLVMBasicBlockRef LLVMGetNextBasicBlock(LLVMBasicBlockRef BB);
/**
* Go backwards in a basic block iterator.
*/
LLVMBasicBlockRef LLVMGetPreviousBasicBlock(LLVMBasicBlockRef BB);
/**
* Obtain the basic block that corresponds to the entry point of a
* function.
*
* @see llvm::Function::getEntryBlock()
*/
LLVMBasicBlockRef LLVMGetEntryBasicBlock(LLVMValueRef Fn);
/**
* Insert the given basic block after the insertion point of the given builder.
*
* The insertion point must be valid.
*
* @see llvm::Function::BasicBlockListType::insertAfter()
*/
void LLVMInsertExistingBasicBlockAfterInsertBlock(LLVMBuilderRef Builder,
LLVMBasicBlockRef BB);
/**
* Append the given basic block to the basic block list of the given function.
*
* @see llvm::Function::BasicBlockListType::push_back()
*/
void LLVMAppendExistingBasicBlock(LLVMValueRef Fn,
LLVMBasicBlockRef BB);
/**
* Create a new basic block without inserting it into a function.
*
* @see llvm::BasicBlock::Create()
*/
LLVMBasicBlockRef LLVMCreateBasicBlockInContext(LLVMContextRef C,
const char *Name);
/**
* Append a basic block to the end of a function.
*
* @see llvm::BasicBlock::Create()
*/
LLVMBasicBlockRef LLVMAppendBasicBlockInContext(LLVMContextRef C,
LLVMValueRef Fn,
const char *Name);
/**
* Append a basic block to the end of a function using the global
* context.
*
* @see llvm::BasicBlock::Create()
*/
LLVMBasicBlockRef LLVMAppendBasicBlock(LLVMValueRef Fn, const char *Name);
/**
* Insert a basic block in a function before another basic block.
*
* The function to add to is determined by the function of the
* passed basic block.
*
* @see llvm::BasicBlock::Create()
*/
LLVMBasicBlockRef LLVMInsertBasicBlockInContext(LLVMContextRef C,
LLVMBasicBlockRef BB,
const char *Name);
/**
* Insert a basic block in a function using the global context.
*
* @see llvm::BasicBlock::Create()
*/
LLVMBasicBlockRef LLVMInsertBasicBlock(LLVMBasicBlockRef InsertBeforeBB,
const char *Name);
/**
* Remove a basic block from a function and delete it.
*
* This deletes the basic block from its containing function and deletes
* the basic block itself.
*
* @see llvm::BasicBlock::eraseFromParent()
*/
void LLVMDeleteBasicBlock(LLVMBasicBlockRef BB);
/**
* Remove a basic block from a function.
*
* This deletes the basic block from its containing function but keep
* the basic block alive.
*
* @see llvm::BasicBlock::removeFromParent()
*/
void LLVMRemoveBasicBlockFromParent(LLVMBasicBlockRef BB);
/**
* Move a basic block to before another one.
*
* @see llvm::BasicBlock::moveBefore()
*/
void LLVMMoveBasicBlockBefore(LLVMBasicBlockRef BB, LLVMBasicBlockRef MovePos);
/**
* Move a basic block to after another one.
*
* @see llvm::BasicBlock::moveAfter()
*/
void LLVMMoveBasicBlockAfter(LLVMBasicBlockRef BB, LLVMBasicBlockRef MovePos);
/**
* Obtain the first instruction in a basic block.
*
* The returned LLVMValueRef corresponds to a llvm::Instruction
* instance.
*/
LLVMValueRef LLVMGetFirstInstruction(LLVMBasicBlockRef BB);
/**
* Obtain the last instruction in a basic block.
*
* The returned LLVMValueRef corresponds to an LLVM:Instruction.
*/
LLVMValueRef LLVMGetLastInstruction(LLVMBasicBlockRef BB);
/**
* @}
*/
/**
* @defgroup LLVMCCoreValueInstruction Instructions
*
* Functions in this group relate to the inspection and manipulation of
* individual instructions.
*
* In the C++ API, an instruction is modeled by llvm::Instruction. This
* class has a large number of descendents. llvm::Instruction is a
* llvm::Value and in the C API, instructions are modeled by
* LLVMValueRef.
*
* This group also contains sub-groups which operate on specific
* llvm::Instruction types, e.g. llvm::CallInst.
*
* @{
*/
/**
* Determine whether an instruction has any metadata attached.
*/
int LLVMHasMetadata(LLVMValueRef Val);
/**
* Return metadata associated with an instruction value.
*/
LLVMValueRef LLVMGetMetadata(LLVMValueRef Val, unsigned KindID);
/**
* Set metadata associated with an instruction value.
*/
void LLVMSetMetadata(LLVMValueRef Val, unsigned KindID, LLVMValueRef Node);
/**
* Returns the metadata associated with an instruction value, but filters out
* all the debug locations.
*
* @see llvm::Instruction::getAllMetadataOtherThanDebugLoc()
*/
LLVMValueMetadataEntry *
LLVMInstructionGetAllMetadataOtherThanDebugLoc(LLVMValueRef Instr,
size_t *NumEntries);
/**
* Obtain the basic block to which an instruction belongs.
*
* @see llvm::Instruction::getParent()
*/
LLVMBasicBlockRef LLVMGetInstructionParent(LLVMValueRef Inst);
/**
* Obtain the instruction that occurs after the one specified.
*
* The next instruction will be from the same basic block.
*
* If this is the last instruction in a basic block, NULL will be
* returned.
*/
LLVMValueRef LLVMGetNextInstruction(LLVMValueRef Inst);
/**
* Obtain the instruction that occurred before this one.
*
* If the instruction is the first instruction in a basic block, NULL
* will be returned.
*/
LLVMValueRef LLVMGetPreviousInstruction(LLVMValueRef Inst);
/**
* Remove and delete an instruction.
*
* The instruction specified is removed from its containing building
* block but is kept alive.
*
* @see llvm::Instruction::removeFromParent()
*/
void LLVMInstructionRemoveFromParent(LLVMValueRef Inst);
/**
* Remove and delete an instruction.
*
* The instruction specified is removed from its containing building
* block and then deleted.
*
* @see llvm::Instruction::eraseFromParent()
*/
void LLVMInstructionEraseFromParent(LLVMValueRef Inst);
/**
* Obtain the code opcode for an individual instruction.
*
* @see llvm::Instruction::getOpCode()
*/
LLVMOpcode LLVMGetInstructionOpcode(LLVMValueRef Inst);
/**
* Obtain the predicate of an instruction.
*
* This is only valid for instructions that correspond to llvm::ICmpInst
* or llvm::ConstantExpr whose opcode is llvm::Instruction::ICmp.
*
* @see llvm::ICmpInst::getPredicate()
*/
LLVMIntPredicate LLVMGetICmpPredicate(LLVMValueRef Inst);
/**
* Obtain the float predicate of an instruction.
*
* This is only valid for instructions that correspond to llvm::FCmpInst
* or llvm::ConstantExpr whose opcode is llvm::Instruction::FCmp.
*
* @see llvm::FCmpInst::getPredicate()
*/
LLVMRealPredicate LLVMGetFCmpPredicate(LLVMValueRef Inst);
/**
* Create a copy of 'this' instruction that is identical in all ways
* except the following:
* * The instruction has no parent
* * The instruction has no name
*
* @see llvm::Instruction::clone()
*/
LLVMValueRef LLVMInstructionClone(LLVMValueRef Inst);
/**
* Determine whether an instruction is a terminator. This routine is named to
* be compatible with historical functions that did this by querying the
* underlying C++ type.
*
* @see llvm::Instruction::isTerminator()
*/
LLVMValueRef LLVMIsATerminatorInst(LLVMValueRef Inst);
/**
* @defgroup LLVMCCoreValueInstructionCall Call Sites and Invocations
*
* Functions in this group apply to instructions that refer to call
* sites and invocations. These correspond to C++ types in the
* llvm::CallInst class tree.
*
* @{
*/
/**
* Obtain the argument count for a call instruction.
*
* This expects an LLVMValueRef that corresponds to a llvm::CallInst,
* llvm::InvokeInst, or llvm:FuncletPadInst.
*
* @see llvm::CallInst::getNumArgOperands()
* @see llvm::InvokeInst::getNumArgOperands()
* @see llvm::FuncletPadInst::getNumArgOperands()
*/
unsigned LLVMGetNumArgOperands(LLVMValueRef Instr);
/**
* Set the calling convention for a call instruction.
*
* This expects an LLVMValueRef that corresponds to a llvm::CallInst or
* llvm::InvokeInst.
*
* @see llvm::CallInst::setCallingConv()
* @see llvm::InvokeInst::setCallingConv()
*/
void LLVMSetInstructionCallConv(LLVMValueRef Instr, unsigned CC);
/**
* Obtain the calling convention for a call instruction.
*
* This is the opposite of LLVMSetInstructionCallConv(). Reads its
* usage.
*
* @see LLVMSetInstructionCallConv()
*/
unsigned LLVMGetInstructionCallConv(LLVMValueRef Instr);
void LLVMSetInstrParamAlignment(LLVMValueRef Instr, unsigned index,
unsigned Align);
void LLVMAddCallSiteAttribute(LLVMValueRef C, LLVMAttributeIndex Idx,
LLVMAttributeRef A);
unsigned LLVMGetCallSiteAttributeCount(LLVMValueRef C, LLVMAttributeIndex Idx);
void LLVMGetCallSiteAttributes(LLVMValueRef C, LLVMAttributeIndex Idx,
LLVMAttributeRef *Attrs);
LLVMAttributeRef LLVMGetCallSiteEnumAttribute(LLVMValueRef C,
LLVMAttributeIndex Idx,
unsigned KindID);
LLVMAttributeRef LLVMGetCallSiteStringAttribute(LLVMValueRef C,
LLVMAttributeIndex Idx,
const char *K, unsigned KLen);
void LLVMRemoveCallSiteEnumAttribute(LLVMValueRef C, LLVMAttributeIndex Idx,
unsigned KindID);
void LLVMRemoveCallSiteStringAttribute(LLVMValueRef C, LLVMAttributeIndex Idx,
const char *K, unsigned KLen);
/**
* Obtain the function type called by this instruction.
*
* @see llvm::CallBase::getFunctionType()
*/
LLVMTypeRef LLVMGetCalledFunctionType(LLVMValueRef C);
/**
* Obtain the pointer to the function invoked by this instruction.
*
* This expects an LLVMValueRef that corresponds to a llvm::CallInst or
* llvm::InvokeInst.
*
* @see llvm::CallInst::getCalledValue()
* @see llvm::InvokeInst::getCalledValue()
*/
LLVMValueRef LLVMGetCalledValue(LLVMValueRef Instr);
/**
* Obtain whether a call instruction is a tail call.
*
* This only works on llvm::CallInst instructions.
*
* @see llvm::CallInst::isTailCall()
*/
LLVMBool LLVMIsTailCall(LLVMValueRef CallInst);
/**
* Set whether a call instruction is a tail call.
*
* This only works on llvm::CallInst instructions.
*
* @see llvm::CallInst::setTailCall()
*/
void LLVMSetTailCall(LLVMValueRef CallInst, LLVMBool IsTailCall);
/**
* Return the normal destination basic block.
*
* This only works on llvm::InvokeInst instructions.
*
* @see llvm::InvokeInst::getNormalDest()
*/
LLVMBasicBlockRef LLVMGetNormalDest(LLVMValueRef InvokeInst);
/**
* Return the unwind destination basic block.
*
* Works on llvm::InvokeInst, llvm::CleanupReturnInst, and
* llvm::CatchSwitchInst instructions.
*
* @see llvm::InvokeInst::getUnwindDest()
* @see llvm::CleanupReturnInst::getUnwindDest()
* @see llvm::CatchSwitchInst::getUnwindDest()
*/
LLVMBasicBlockRef LLVMGetUnwindDest(LLVMValueRef InvokeInst);
/**
* Set the normal destination basic block.
*
* This only works on llvm::InvokeInst instructions.
*
* @see llvm::InvokeInst::setNormalDest()
*/
void LLVMSetNormalDest(LLVMValueRef InvokeInst, LLVMBasicBlockRef B);
/**
* Set the unwind destination basic block.
*
* Works on llvm::InvokeInst, llvm::CleanupReturnInst, and
* llvm::CatchSwitchInst instructions.
*
* @see llvm::InvokeInst::setUnwindDest()
* @see llvm::CleanupReturnInst::setUnwindDest()
* @see llvm::CatchSwitchInst::setUnwindDest()
*/
void LLVMSetUnwindDest(LLVMValueRef InvokeInst, LLVMBasicBlockRef B);
/**
* @}
*/
/**
* @defgroup LLVMCCoreValueInstructionTerminator Terminators
*
* Functions in this group only apply to instructions for which
* LLVMIsATerminatorInst returns true.
*
* @{
*/
/**
* Return the number of successors that this terminator has.
*
* @see llvm::Instruction::getNumSuccessors
*/
unsigned LLVMGetNumSuccessors(LLVMValueRef Term);
/**
* Return the specified successor.
*
* @see llvm::Instruction::getSuccessor
*/
LLVMBasicBlockRef LLVMGetSuccessor(LLVMValueRef Term, unsigned i);
/**
* Update the specified successor to point at the provided block.
*
* @see llvm::Instruction::setSuccessor
*/
void LLVMSetSuccessor(LLVMValueRef Term, unsigned i, LLVMBasicBlockRef block);
/**
* Return if a branch is conditional.
*
* This only works on llvm::BranchInst instructions.
*
* @see llvm::BranchInst::isConditional
*/
LLVMBool LLVMIsConditional(LLVMValueRef Branch);
/**
* Return the condition of a branch instruction.
*
* This only works on llvm::BranchInst instructions.
*
* @see llvm::BranchInst::getCondition
*/
LLVMValueRef LLVMGetCondition(LLVMValueRef Branch);
/**
* Set the condition of a branch instruction.
*
* This only works on llvm::BranchInst instructions.
*
* @see llvm::BranchInst::setCondition
*/
void LLVMSetCondition(LLVMValueRef Branch, LLVMValueRef Cond);
/**
* Obtain the default destination basic block of a switch instruction.
*
* This only works on llvm::SwitchInst instructions.
*
* @see llvm::SwitchInst::getDefaultDest()
*/
LLVMBasicBlockRef LLVMGetSwitchDefaultDest(LLVMValueRef SwitchInstr);
/**
* @}
*/
/**
* @defgroup LLVMCCoreValueInstructionAlloca Allocas
*
* Functions in this group only apply to instructions that map to
* llvm::AllocaInst instances.
*
* @{
*/
/**
* Obtain the type that is being allocated by the alloca instruction.
*/
LLVMTypeRef LLVMGetAllocatedType(LLVMValueRef Alloca);
/**
* @}
*/
/**
* @defgroup LLVMCCoreValueInstructionGetElementPointer GEPs
*
* Functions in this group only apply to instructions that map to
* llvm::GetElementPtrInst instances.
*
* @{
*/
/**
* Check whether the given GEP instruction is inbounds.
*/
LLVMBool LLVMIsInBounds(LLVMValueRef GEP);
/**
* Set the given GEP instruction to be inbounds or not.
*/
void LLVMSetIsInBounds(LLVMValueRef GEP, LLVMBool InBounds);
/**
* @}
*/
/**
* @defgroup LLVMCCoreValueInstructionPHINode PHI Nodes
*
* Functions in this group only apply to instructions that map to
* llvm::PHINode instances.
*
* @{
*/
/**
* Add an incoming value to the end of a PHI list.
*/
void LLVMAddIncoming(LLVMValueRef PhiNode, LLVMValueRef *IncomingValues,
LLVMBasicBlockRef *IncomingBlocks, unsigned Count);
/**
* Obtain the number of incoming basic blocks to a PHI node.
*/
unsigned LLVMCountIncoming(LLVMValueRef PhiNode);
/**
* Obtain an incoming value to a PHI node as an LLVMValueRef.
*/
LLVMValueRef LLVMGetIncomingValue(LLVMValueRef PhiNode, unsigned Index);
/**
* Obtain an incoming value to a PHI node as an LLVMBasicBlockRef.
*/
LLVMBasicBlockRef LLVMGetIncomingBlock(LLVMValueRef PhiNode, unsigned Index);
/**
* @}
*/
/**
* @defgroup LLVMCCoreValueInstructionExtractValue ExtractValue
* @defgroup LLVMCCoreValueInstructionInsertValue InsertValue
*
* Functions in this group only apply to instructions that map to
* llvm::ExtractValue and llvm::InsertValue instances.
*
* @{
*/
/**
* Obtain the number of indices.
* NB: This also works on GEP.
*/
unsigned LLVMGetNumIndices(LLVMValueRef Inst);
/**
* Obtain the indices as an array.
*/
const unsigned *LLVMGetIndices(LLVMValueRef Inst);
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/**
* @defgroup LLVMCCoreInstructionBuilder Instruction Builders
*
* An instruction builder represents a point within a basic block and is
* the exclusive means of building instructions using the C interface.
*
* @{
*/
LLVMBuilderRef LLVMCreateBuilderInContext(LLVMContextRef C);
LLVMBuilderRef LLVMCreateBuilder(void);
void LLVMPositionBuilder(LLVMBuilderRef Builder, LLVMBasicBlockRef Block,
LLVMValueRef Instr);
void LLVMPositionBuilderBefore(LLVMBuilderRef Builder, LLVMValueRef Instr);
void LLVMPositionBuilderAtEnd(LLVMBuilderRef Builder, LLVMBasicBlockRef Block);
LLVMBasicBlockRef LLVMGetInsertBlock(LLVMBuilderRef Builder);
void LLVMClearInsertionPosition(LLVMBuilderRef Builder);
void LLVMInsertIntoBuilder(LLVMBuilderRef Builder, LLVMValueRef Instr);
void LLVMInsertIntoBuilderWithName(LLVMBuilderRef Builder, LLVMValueRef Instr,
const char *Name);
void LLVMDisposeBuilder(LLVMBuilderRef Builder);
/* Metadata */
/**
* Get location information used by debugging information.
*
* @see llvm::IRBuilder::getCurrentDebugLocation()
*/
LLVMMetadataRef LLVMGetCurrentDebugLocation2(LLVMBuilderRef Builder);
/**
* Set location information used by debugging information.
*
* To clear the location metadata of the given instruction, pass NULL to \p Loc.
*
* @see llvm::IRBuilder::SetCurrentDebugLocation()
*/
void LLVMSetCurrentDebugLocation2(LLVMBuilderRef Builder, LLVMMetadataRef Loc);
/**
* Attempts to set the debug location for the given instruction using the
* current debug location for the given builder. If the builder has no current
* debug location, this function is a no-op.
*
* @see llvm::IRBuilder::SetInstDebugLocation()
*/
void LLVMSetInstDebugLocation(LLVMBuilderRef Builder, LLVMValueRef Inst);
/**
* Get the dafult floating-point math metadata for a given builder.
*
* @see llvm::IRBuilder::getDefaultFPMathTag()
*/
LLVMMetadataRef LLVMBuilderGetDefaultFPMathTag(LLVMBuilderRef Builder);
/**
* Set the default floating-point math metadata for the given builder.
*
* To clear the metadata, pass NULL to \p FPMathTag.
*
* @see llvm::IRBuilder::setDefaultFPMathTag()
*/
void LLVMBuilderSetDefaultFPMathTag(LLVMBuilderRef Builder,
LLVMMetadataRef FPMathTag);
/**
* Deprecated: Passing the NULL location will crash.
* Use LLVMGetCurrentDebugLocation2 instead.
*/
void LLVMSetCurrentDebugLocation(LLVMBuilderRef Builder, LLVMValueRef L);
/**
* Deprecated: Returning the NULL location will crash.
* Use LLVMGetCurrentDebugLocation2 instead.
*/
LLVMValueRef LLVMGetCurrentDebugLocation(LLVMBuilderRef Builder);
/* Terminators */
LLVMValueRef LLVMBuildRetVoid(LLVMBuilderRef);
LLVMValueRef LLVMBuildRet(LLVMBuilderRef, LLVMValueRef V);
LLVMValueRef LLVMBuildAggregateRet(LLVMBuilderRef, LLVMValueRef *RetVals,
unsigned N);
LLVMValueRef LLVMBuildBr(LLVMBuilderRef, LLVMBasicBlockRef Dest);
LLVMValueRef LLVMBuildCondBr(LLVMBuilderRef, LLVMValueRef If,
LLVMBasicBlockRef Then, LLVMBasicBlockRef Else);
LLVMValueRef LLVMBuildSwitch(LLVMBuilderRef, LLVMValueRef V,
LLVMBasicBlockRef Else, unsigned NumCases);
LLVMValueRef LLVMBuildIndirectBr(LLVMBuilderRef B, LLVMValueRef Addr,
unsigned NumDests);
// LLVMBuildInvoke is deprecated in favor of LLVMBuildInvoke2, in preparation
// for opaque pointer types.
LLVMValueRef LLVMBuildInvoke(LLVMBuilderRef, LLVMValueRef Fn,
LLVMValueRef *Args, unsigned NumArgs,
LLVMBasicBlockRef Then, LLVMBasicBlockRef Catch,
const char *Name);
LLVMValueRef LLVMBuildInvoke2(LLVMBuilderRef, LLVMTypeRef Ty, LLVMValueRef Fn,
LLVMValueRef *Args, unsigned NumArgs,
LLVMBasicBlockRef Then, LLVMBasicBlockRef Catch,
const char *Name);
LLVMValueRef LLVMBuildUnreachable(LLVMBuilderRef);
/* Exception Handling */
LLVMValueRef LLVMBuildResume(LLVMBuilderRef B, LLVMValueRef Exn);
LLVMValueRef LLVMBuildLandingPad(LLVMBuilderRef B, LLVMTypeRef Ty,
LLVMValueRef PersFn, unsigned NumClauses,
const char *Name);
LLVMValueRef LLVMBuildCleanupRet(LLVMBuilderRef B, LLVMValueRef CatchPad,
LLVMBasicBlockRef BB);
LLVMValueRef LLVMBuildCatchRet(LLVMBuilderRef B, LLVMValueRef CatchPad,
LLVMBasicBlockRef BB);
LLVMValueRef LLVMBuildCatchPad(LLVMBuilderRef B, LLVMValueRef ParentPad,
LLVMValueRef *Args, unsigned NumArgs,
const char *Name);
LLVMValueRef LLVMBuildCleanupPad(LLVMBuilderRef B, LLVMValueRef ParentPad,
LLVMValueRef *Args, unsigned NumArgs,
const char *Name);
LLVMValueRef LLVMBuildCatchSwitch(LLVMBuilderRef B, LLVMValueRef ParentPad,
LLVMBasicBlockRef UnwindBB,
unsigned NumHandlers, const char *Name);
/* Add a case to the switch instruction */
void LLVMAddCase(LLVMValueRef Switch, LLVMValueRef OnVal,
LLVMBasicBlockRef Dest);
/* Add a destination to the indirectbr instruction */
void LLVMAddDestination(LLVMValueRef IndirectBr, LLVMBasicBlockRef Dest);
/* Get the number of clauses on the landingpad instruction */
unsigned LLVMGetNumClauses(LLVMValueRef LandingPad);
/* Get the value of the clause at idnex Idx on the landingpad instruction */
LLVMValueRef LLVMGetClause(LLVMValueRef LandingPad, unsigned Idx);
/* Add a catch or filter clause to the landingpad instruction */
void LLVMAddClause(LLVMValueRef LandingPad, LLVMValueRef ClauseVal);
/* Get the 'cleanup' flag in the landingpad instruction */
LLVMBool LLVMIsCleanup(LLVMValueRef LandingPad);
/* Set the 'cleanup' flag in the landingpad instruction */
void LLVMSetCleanup(LLVMValueRef LandingPad, LLVMBool Val);
/* Add a destination to the catchswitch instruction */
void LLVMAddHandler(LLVMValueRef CatchSwitch, LLVMBasicBlockRef Dest);
/* Get the number of handlers on the catchswitch instruction */
unsigned LLVMGetNumHandlers(LLVMValueRef CatchSwitch);
/**
* Obtain the basic blocks acting as handlers for a catchswitch instruction.
*
* The Handlers parameter should point to a pre-allocated array of
* LLVMBasicBlockRefs at least LLVMGetNumHandlers() large. On return, the
* first LLVMGetNumHandlers() entries in the array will be populated
* with LLVMBasicBlockRef instances.
*
* @param CatchSwitch The catchswitch instruction to operate on.
* @param Handlers Memory address of an array to be filled with basic blocks.
*/
void LLVMGetHandlers(LLVMValueRef CatchSwitch, LLVMBasicBlockRef *Handlers);
/* Funclets */
/* Get the number of funcletpad arguments. */
LLVMValueRef LLVMGetArgOperand(LLVMValueRef Funclet, unsigned i);
/* Set a funcletpad argument at the given index. */
void LLVMSetArgOperand(LLVMValueRef Funclet, unsigned i, LLVMValueRef value);
/**
* Get the parent catchswitch instruction of a catchpad instruction.
*
* This only works on llvm::CatchPadInst instructions.
*
* @see llvm::CatchPadInst::getCatchSwitch()
*/
LLVMValueRef LLVMGetParentCatchSwitch(LLVMValueRef CatchPad);
/**
* Set the parent catchswitch instruction of a catchpad instruction.
*
* This only works on llvm::CatchPadInst instructions.
*
* @see llvm::CatchPadInst::setCatchSwitch()
*/
void LLVMSetParentCatchSwitch(LLVMValueRef CatchPad, LLVMValueRef CatchSwitch);
/* Arithmetic */
LLVMValueRef LLVMBuildAdd(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
const char *Name);
LLVMValueRef LLVMBuildNSWAdd(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
const char *Name);
LLVMValueRef LLVMBuildNUWAdd(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
const char *Name);
LLVMValueRef LLVMBuildFAdd(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
const char *Name);
LLVMValueRef LLVMBuildSub(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
const char *Name);
LLVMValueRef LLVMBuildNSWSub(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
const char *Name);
LLVMValueRef LLVMBuildNUWSub(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
const char *Name);
LLVMValueRef LLVMBuildFSub(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
const char *Name);
LLVMValueRef LLVMBuildMul(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
const char *Name);
LLVMValueRef LLVMBuildNSWMul(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
const char *Name);
LLVMValueRef LLVMBuildNUWMul(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
const char *Name);
LLVMValueRef LLVMBuildFMul(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
const char *Name);
LLVMValueRef LLVMBuildUDiv(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
const char *Name);
LLVMValueRef LLVMBuildExactUDiv(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
const char *Name);
LLVMValueRef LLVMBuildSDiv(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
const char *Name);
LLVMValueRef LLVMBuildExactSDiv(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
const char *Name);
LLVMValueRef LLVMBuildFDiv(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
const char *Name);
LLVMValueRef LLVMBuildURem(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
const char *Name);
LLVMValueRef LLVMBuildSRem(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
const char *Name);
LLVMValueRef LLVMBuildFRem(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
const char *Name);
LLVMValueRef LLVMBuildShl(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
const char *Name);
LLVMValueRef LLVMBuildLShr(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
const char *Name);
LLVMValueRef LLVMBuildAShr(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
const char *Name);
LLVMValueRef LLVMBuildAnd(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
const char *Name);
LLVMValueRef LLVMBuildOr(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
const char *Name);
LLVMValueRef LLVMBuildXor(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS,
const char *Name);
LLVMValueRef LLVMBuildBinOp(LLVMBuilderRef B, LLVMOpcode Op,
LLVMValueRef LHS, LLVMValueRef RHS,
const char *Name);
LLVMValueRef LLVMBuildNeg(LLVMBuilderRef, LLVMValueRef V, const char *Name);
LLVMValueRef LLVMBuildNSWNeg(LLVMBuilderRef B, LLVMValueRef V,
const char *Name);
LLVMValueRef LLVMBuildNUWNeg(LLVMBuilderRef B, LLVMValueRef V,
const char *Name);
LLVMValueRef LLVMBuildFNeg(LLVMBuilderRef, LLVMValueRef V, const char *Name);
LLVMValueRef LLVMBuildNot(LLVMBuilderRef, LLVMValueRef V, const char *Name);
/* Memory */
LLVMValueRef LLVMBuildMalloc(LLVMBuilderRef, LLVMTypeRef Ty, const char *Name);
LLVMValueRef LLVMBuildArrayMalloc(LLVMBuilderRef, LLVMTypeRef Ty,
LLVMValueRef Val, const char *Name);
/**
* Creates and inserts a memset to the specified pointer and the
* specified value.
*
* @see llvm::IRRBuilder::CreateMemSet()
*/
LLVMValueRef LLVMBuildMemSet(LLVMBuilderRef B, LLVMValueRef Ptr,
LLVMValueRef Val, LLVMValueRef Len,
unsigned Align);
/**
* Creates and inserts a memcpy between the specified pointers.
*
* @see llvm::IRRBuilder::CreateMemCpy()
*/
LLVMValueRef LLVMBuildMemCpy(LLVMBuilderRef B,
LLVMValueRef Dst, unsigned DstAlign,
LLVMValueRef Src, unsigned SrcAlign,
LLVMValueRef Size);
/**
* Creates and inserts a memmove between the specified pointers.
*
* @see llvm::IRRBuilder::CreateMemMove()
*/
LLVMValueRef LLVMBuildMemMove(LLVMBuilderRef B,
LLVMValueRef Dst, unsigned DstAlign,
LLVMValueRef Src, unsigned SrcAlign,
LLVMValueRef Size);
LLVMValueRef LLVMBuildAlloca(LLVMBuilderRef, LLVMTypeRef Ty, const char *Name);
LLVMValueRef LLVMBuildArrayAlloca(LLVMBuilderRef, LLVMTypeRef Ty,
LLVMValueRef Val, const char *Name);
LLVMValueRef LLVMBuildFree(LLVMBuilderRef, LLVMValueRef PointerVal);
// LLVMBuildLoad is deprecated in favor of LLVMBuildLoad2, in preparation for
// opaque pointer types.
LLVMValueRef LLVMBuildLoad(LLVMBuilderRef, LLVMValueRef PointerVal,
const char *Name);
LLVMValueRef LLVMBuildLoad2(LLVMBuilderRef, LLVMTypeRef Ty,
LLVMValueRef PointerVal, const char *Name);
LLVMValueRef LLVMBuildStore(LLVMBuilderRef, LLVMValueRef Val, LLVMValueRef Ptr);
// LLVMBuildGEP, LLVMBuildInBoundsGEP, and LLVMBuildStructGEP are deprecated in
// favor of LLVMBuild*GEP2, in preparation for opaque pointer types.
LLVMValueRef LLVMBuildGEP(LLVMBuilderRef B, LLVMValueRef Pointer,
LLVMValueRef *Indices, unsigned NumIndices,
const char *Name);
LLVMValueRef LLVMBuildInBoundsGEP(LLVMBuilderRef B, LLVMValueRef Pointer,
LLVMValueRef *Indices, unsigned NumIndices,
const char *Name);
LLVMValueRef LLVMBuildStructGEP(LLVMBuilderRef B, LLVMValueRef Pointer,
unsigned Idx, const char *Name);
LLVMValueRef LLVMBuildGEP2(LLVMBuilderRef B, LLVMTypeRef Ty,
LLVMValueRef Pointer, LLVMValueRef *Indices,
unsigned NumIndices, const char *Name);
LLVMValueRef LLVMBuildInBoundsGEP2(LLVMBuilderRef B, LLVMTypeRef Ty,
LLVMValueRef Pointer, LLVMValueRef *Indices,
unsigned NumIndices, const char *Name);
LLVMValueRef LLVMBuildStructGEP2(LLVMBuilderRef B, LLVMTypeRef Ty,
LLVMValueRef Pointer, unsigned Idx,
const char *Name);
LLVMValueRef LLVMBuildGlobalString(LLVMBuilderRef B, const char *Str,
const char *Name);
LLVMValueRef LLVMBuildGlobalStringPtr(LLVMBuilderRef B, const char *Str,
const char *Name);
LLVMBool LLVMGetVolatile(LLVMValueRef MemoryAccessInst);
void LLVMSetVolatile(LLVMValueRef MemoryAccessInst, LLVMBool IsVolatile);
LLVMBool LLVMGetWeak(LLVMValueRef CmpXchgInst);
void LLVMSetWeak(LLVMValueRef CmpXchgInst, LLVMBool IsWeak);
LLVMAtomicOrdering LLVMGetOrdering(LLVMValueRef MemoryAccessInst);
void LLVMSetOrdering(LLVMValueRef MemoryAccessInst, LLVMAtomicOrdering Ordering);
LLVMAtomicRMWBinOp LLVMGetAtomicRMWBinOp(LLVMValueRef AtomicRMWInst);
void LLVMSetAtomicRMWBinOp(LLVMValueRef AtomicRMWInst, LLVMAtomicRMWBinOp BinOp);
/* Casts */
LLVMValueRef LLVMBuildTrunc(LLVMBuilderRef, LLVMValueRef Val,
LLVMTypeRef DestTy, const char *Name);
LLVMValueRef LLVMBuildZExt(LLVMBuilderRef, LLVMValueRef Val,
LLVMTypeRef DestTy, const char *Name);
LLVMValueRef LLVMBuildSExt(LLVMBuilderRef, LLVMValueRef Val,
LLVMTypeRef DestTy, const char *Name);
LLVMValueRef LLVMBuildFPToUI(LLVMBuilderRef, LLVMValueRef Val,
LLVMTypeRef DestTy, const char *Name);
LLVMValueRef LLVMBuildFPToSI(LLVMBuilderRef, LLVMValueRef Val,
LLVMTypeRef DestTy, const char *Name);
LLVMValueRef LLVMBuildUIToFP(LLVMBuilderRef, LLVMValueRef Val,
LLVMTypeRef DestTy, const char *Name);
LLVMValueRef LLVMBuildSIToFP(LLVMBuilderRef, LLVMValueRef Val,
LLVMTypeRef DestTy, const char *Name);
LLVMValueRef LLVMBuildFPTrunc(LLVMBuilderRef, LLVMValueRef Val,
LLVMTypeRef DestTy, const char *Name);
LLVMValueRef LLVMBuildFPExt(LLVMBuilderRef, LLVMValueRef Val,
LLVMTypeRef DestTy, const char *Name);
LLVMValueRef LLVMBuildPtrToInt(LLVMBuilderRef, LLVMValueRef Val,
LLVMTypeRef DestTy, const char *Name);
LLVMValueRef LLVMBuildIntToPtr(LLVMBuilderRef, LLVMValueRef Val,
LLVMTypeRef DestTy, const char *Name);
LLVMValueRef LLVMBuildBitCast(LLVMBuilderRef, LLVMValueRef Val,
LLVMTypeRef DestTy, const char *Name);
LLVMValueRef LLVMBuildAddrSpaceCast(LLVMBuilderRef, LLVMValueRef Val,
LLVMTypeRef DestTy, const char *Name);
LLVMValueRef LLVMBuildZExtOrBitCast(LLVMBuilderRef, LLVMValueRef Val,
LLVMTypeRef DestTy, const char *Name);
LLVMValueRef LLVMBuildSExtOrBitCast(LLVMBuilderRef, LLVMValueRef Val,
LLVMTypeRef DestTy, const char *Name);
LLVMValueRef LLVMBuildTruncOrBitCast(LLVMBuilderRef, LLVMValueRef Val,
LLVMTypeRef DestTy, const char *Name);
LLVMValueRef LLVMBuildCast(LLVMBuilderRef B, LLVMOpcode Op, LLVMValueRef Val,
LLVMTypeRef DestTy, const char *Name);
LLVMValueRef LLVMBuildPointerCast(LLVMBuilderRef, LLVMValueRef Val,
LLVMTypeRef DestTy, const char *Name);
LLVMValueRef LLVMBuildIntCast2(LLVMBuilderRef, LLVMValueRef Val,
LLVMTypeRef DestTy, LLVMBool IsSigned,
const char *Name);
LLVMValueRef LLVMBuildFPCast(LLVMBuilderRef, LLVMValueRef Val,
LLVMTypeRef DestTy, const char *Name);
/** Deprecated: This cast is always signed. Use LLVMBuildIntCast2 instead. */
LLVMValueRef LLVMBuildIntCast(LLVMBuilderRef, LLVMValueRef Val, /*Signed cast!*/
LLVMTypeRef DestTy, const char *Name);
/* Comparisons */
LLVMValueRef LLVMBuildICmp(LLVMBuilderRef, LLVMIntPredicate Op,
LLVMValueRef LHS, LLVMValueRef RHS,
const char *Name);
LLVMValueRef LLVMBuildFCmp(LLVMBuilderRef, LLVMRealPredicate Op,
LLVMValueRef LHS, LLVMValueRef RHS,
const char *Name);
/* Miscellaneous instructions */
LLVMValueRef LLVMBuildPhi(LLVMBuilderRef, LLVMTypeRef Ty, const char *Name);
// LLVMBuildCall is deprecated in favor of LLVMBuildCall2, in preparation for
// opaque pointer types.
LLVMValueRef LLVMBuildCall(LLVMBuilderRef, LLVMValueRef Fn,
LLVMValueRef *Args, unsigned NumArgs,
const char *Name);
LLVMValueRef LLVMBuildCall2(LLVMBuilderRef, LLVMTypeRef, LLVMValueRef Fn,
LLVMValueRef *Args, unsigned NumArgs,
const char *Name);
LLVMValueRef LLVMBuildSelect(LLVMBuilderRef, LLVMValueRef If,
LLVMValueRef Then, LLVMValueRef Else,
const char *Name);
LLVMValueRef LLVMBuildVAArg(LLVMBuilderRef, LLVMValueRef List, LLVMTypeRef Ty,
const char *Name);
LLVMValueRef LLVMBuildExtractElement(LLVMBuilderRef, LLVMValueRef VecVal,
LLVMValueRef Index, const char *Name);
LLVMValueRef LLVMBuildInsertElement(LLVMBuilderRef, LLVMValueRef VecVal,
LLVMValueRef EltVal, LLVMValueRef Index,
const char *Name);
LLVMValueRef LLVMBuildShuffleVector(LLVMBuilderRef, LLVMValueRef V1,
LLVMValueRef V2, LLVMValueRef Mask,
const char *Name);
LLVMValueRef LLVMBuildExtractValue(LLVMBuilderRef, LLVMValueRef AggVal,
unsigned Index, const char *Name);
LLVMValueRef LLVMBuildInsertValue(LLVMBuilderRef, LLVMValueRef AggVal,
LLVMValueRef EltVal, unsigned Index,
const char *Name);
LLVMValueRef LLVMBuildFreeze(LLVMBuilderRef, LLVMValueRef Val,
const char *Name);
LLVMValueRef LLVMBuildIsNull(LLVMBuilderRef, LLVMValueRef Val,
const char *Name);
LLVMValueRef LLVMBuildIsNotNull(LLVMBuilderRef, LLVMValueRef Val,
const char *Name);
LLVMValueRef LLVMBuildPtrDiff(LLVMBuilderRef, LLVMValueRef LHS,
LLVMValueRef RHS, const char *Name);
LLVMValueRef LLVMBuildFence(LLVMBuilderRef B, LLVMAtomicOrdering ordering,
LLVMBool singleThread, const char *Name);
LLVMValueRef LLVMBuildAtomicRMW(LLVMBuilderRef B, LLVMAtomicRMWBinOp op,
LLVMValueRef PTR, LLVMValueRef Val,
LLVMAtomicOrdering ordering,
LLVMBool singleThread);
LLVMValueRef LLVMBuildAtomicCmpXchg(LLVMBuilderRef B, LLVMValueRef Ptr,
LLVMValueRef Cmp, LLVMValueRef New,
LLVMAtomicOrdering SuccessOrdering,
LLVMAtomicOrdering FailureOrdering,
LLVMBool SingleThread);
LLVMBool LLVMIsAtomicSingleThread(LLVMValueRef AtomicInst);
void LLVMSetAtomicSingleThread(LLVMValueRef AtomicInst, LLVMBool SingleThread);
LLVMAtomicOrdering LLVMGetCmpXchgSuccessOrdering(LLVMValueRef CmpXchgInst);
void LLVMSetCmpXchgSuccessOrdering(LLVMValueRef CmpXchgInst,
LLVMAtomicOrdering Ordering);
LLVMAtomicOrdering LLVMGetCmpXchgFailureOrdering(LLVMValueRef CmpXchgInst);
void LLVMSetCmpXchgFailureOrdering(LLVMValueRef CmpXchgInst,
LLVMAtomicOrdering Ordering);
/**
* @}
*/
/**
* @defgroup LLVMCCoreModuleProvider Module Providers
*
* @{
*/
/**
* Changes the type of M so it can be passed to FunctionPassManagers and the
* JIT. They take ModuleProviders for historical reasons.
*/
LLVMModuleProviderRef
LLVMCreateModuleProviderForExistingModule(LLVMModuleRef M);
/**
* Destroys the module M.
*/
void LLVMDisposeModuleProvider(LLVMModuleProviderRef M);
/**
* @}
*/
/**
* @defgroup LLVMCCoreMemoryBuffers Memory Buffers
*
* @{
*/
LLVMBool LLVMCreateMemoryBufferWithContentsOfFile(const char *Path,
LLVMMemoryBufferRef *OutMemBuf,
char **OutMessage);
LLVMBool LLVMCreateMemoryBufferWithSTDIN(LLVMMemoryBufferRef *OutMemBuf,
char **OutMessage);
LLVMMemoryBufferRef LLVMCreateMemoryBufferWithMemoryRange(const char *InputData,
size_t InputDataLength,
const char *BufferName,
LLVMBool RequiresNullTerminator);
LLVMMemoryBufferRef LLVMCreateMemoryBufferWithMemoryRangeCopy(const char *InputData,
size_t InputDataLength,
const char *BufferName);
const char *LLVMGetBufferStart(LLVMMemoryBufferRef MemBuf);
size_t LLVMGetBufferSize(LLVMMemoryBufferRef MemBuf);
void LLVMDisposeMemoryBuffer(LLVMMemoryBufferRef MemBuf);
/**
* @}
*/
/**
* @defgroup LLVMCCorePassRegistry Pass Registry
*
* @{
*/
/** Return the global pass registry, for use with initialization functions.
@see llvm::PassRegistry::getPassRegistry */
LLVMPassRegistryRef LLVMGetGlobalPassRegistry(void);
/**
* @}
*/
/**
* @defgroup LLVMCCorePassManagers Pass Managers
*
* @{
*/
/** Constructs a new whole-module pass pipeline. This type of pipeline is
suitable for link-time optimization and whole-module transformations.
@see llvm::PassManager::PassManager */
LLVMPassManagerRef LLVMCreatePassManager(void);
/** Constructs a new function-by-function pass pipeline over the module
provider. It does not take ownership of the module provider. This type of
pipeline is suitable for code generation and JIT compilation tasks.
@see llvm::FunctionPassManager::FunctionPassManager */
LLVMPassManagerRef LLVMCreateFunctionPassManagerForModule(LLVMModuleRef M);
/** Deprecated: Use LLVMCreateFunctionPassManagerForModule instead. */
LLVMPassManagerRef LLVMCreateFunctionPassManager(LLVMModuleProviderRef MP);
/** Initializes, executes on the provided module, and finalizes all of the
passes scheduled in the pass manager. Returns 1 if any of the passes
modified the module, 0 otherwise.
@see llvm::PassManager::run(Module&) */
LLVMBool LLVMRunPassManager(LLVMPassManagerRef PM, LLVMModuleRef M);
/** Initializes all of the function passes scheduled in the function pass
manager. Returns 1 if any of the passes modified the module, 0 otherwise.
@see llvm::FunctionPassManager::doInitialization */
LLVMBool LLVMInitializeFunctionPassManager(LLVMPassManagerRef FPM);
/** Executes all of the function passes scheduled in the function pass manager
on the provided function. Returns 1 if any of the passes modified the
function, false otherwise.
@see llvm::FunctionPassManager::run(Function&) */
LLVMBool LLVMRunFunctionPassManager(LLVMPassManagerRef FPM, LLVMValueRef F);
/** Finalizes all of the function passes scheduled in the function pass
manager. Returns 1 if any of the passes modified the module, 0 otherwise.
@see llvm::FunctionPassManager::doFinalization */
LLVMBool LLVMFinalizeFunctionPassManager(LLVMPassManagerRef FPM);
/** Frees the memory of a pass pipeline. For function pipelines, does not free
the module provider.
@see llvm::PassManagerBase::~PassManagerBase. */
void LLVMDisposePassManager(LLVMPassManagerRef PM);
/**
* @}
*/
/**
* @defgroup LLVMCCoreThreading Threading
*
* Handle the structures needed to make LLVM safe for multithreading.
*
* @{
*/
/** Deprecated: Multi-threading can only be enabled/disabled with the compile
time define LLVM_ENABLE_THREADS. This function always returns
LLVMIsMultithreaded(). */
LLVMBool LLVMStartMultithreaded(void);
/** Deprecated: Multi-threading can only be enabled/disabled with the compile
time define LLVM_ENABLE_THREADS. */
void LLVMStopMultithreaded(void);
/** Check whether LLVM is executing in thread-safe mode or not.
@see llvm::llvm_is_multithreaded */
LLVMBool LLVMIsMultithreaded(void);
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
LLVM_C_EXTERN_C_END
#endif /* LLVM_C_CORE_H */