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
|
-- LLVM binding
-- Copyright (C) 2014 Tristan Gingold
--
-- GHDL is free software; you can redistribute it and/or modify it under
-- the terms of the GNU General Public License as published by the Free
-- Software Foundation; either version 2, or (at your option) any later
-- version.
--
-- GHDL is distributed in the hope that it will be useful, but WITHOUT ANY
-- WARRANTY; without even the implied warranty of MERCHANTABILITY or
-- FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
-- for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with GHDL; see the file COPYING. If not, write to the Free
-- Software Foundation, 59 Temple Place - Suite 330, Boston, MA
-- 02111-1307, USA.
with System;
with Interfaces.C; use Interfaces.C;
use Interfaces;
package LLVM.Core is
subtype Cstring is System.Address;
function "=" (L, R : Cstring) return Boolean renames System."=";
-- Null_Cstring : constant Cstring := Null_Address;
Nul : constant String := (1 => Character'Val (0));
Empty_Cstring : constant Cstring := Nul'Address;
-- The top-level container for all LLVM global data. See the LLVMContext
-- class.
type ContextRef is new System.Address;
-- The top-level container for all other LLVM Intermediate
-- Representation (IR) objects. See the llvm::Module class.
type ModuleRef is new System.Address;
subtype Bool is int;
-- Each value in the LLVM IR has a type, an LLVMTypeRef. See the llvm::Type
-- class.
type TypeRef is new System.Address;
Null_TypeRef : constant TypeRef := TypeRef (System.Null_Address);
type TypeRefArray is array (unsigned range <>) of TypeRef;
pragma Convention (C, TypeRefArray);
type ValueRef is new System.Address;
Null_ValueRef : constant ValueRef := ValueRef (System.Null_Address);
type ValueRefArray is array (unsigned range <>) of ValueRef; -- Ada
pragma Convention (C, ValueRefArray);
type BasicBlockRef is new System.Address;
Null_BasicBlockRef : constant BasicBlockRef :=
BasicBlockRef (System.Null_Address);
type BasicBlockRefArray is
array (unsigned range <>) of BasicBlockRef; -- Ada
pragma Convention (C, BasicBlockRefArray);
type BuilderRef is new System.Address;
-- Used to provide a module to JIT or interpreter.
-- See the llvm::MemoryBuffer class.
type MemoryBufferRef is new System.Address;
-- See the llvm::PassManagerBase class.
type PassManagerRef is new System.Address;
type Attribute is new unsigned;
ZExtAttribute : constant Attribute := 2**0;
SExtAttribute : constant Attribute := 2**1;
NoReturnAttribute : constant Attribute := 2**2;
InRegAttribute : constant Attribute := 2**3;
StructRetAttribute : constant Attribute := 2**4;
NoUnwindAttribute : constant Attribute := 2**5;
NoAliasAttribute : constant Attribute := 2**6;
ByValAttribute : constant Attribute := 2**7;
NestAttribute : constant Attribute := 2**8;
ReadNoneAttribute : constant Attribute := 2**9;
ReadOnlyAttribute : constant Attribute := 2**10;
NoInlineAttribute : constant Attribute := 2**11;
AlwaysInlineAttribute : constant Attribute := 2**12;
OptimizeForSizeAttribute : constant Attribute := 2**13;
StackProtectAttribute : constant Attribute := 2**14;
StackProtectReqAttribute : constant Attribute := 2**15;
Alignment : constant Attribute := 31 * 2**16;
NoCaptureAttribute : constant Attribute := 2**21;
NoRedZoneAttribute : constant Attribute := 2**22;
NoImplicitFloatAttribute : constant Attribute := 2**23;
NakedAttribute : constant Attribute := 2**24;
InlineHintAttribute : constant Attribute := 2**25;
StackAlignment : constant Attribute := 7 * 2**26;
ReturnsTwice : constant Attribute := 2**29;
UWTable : constant Attribute := 2**30;
NonLazyBind : constant Attribute := 2**31;
type TypeKind is
(
VoidTypeKind, -- type with no size
HalfTypeKind, -- 16 bit floating point type
FloatTypeKind, -- 32 bit floating point type
DoubleTypeKind, -- 64 bit floating point type
X86_FP80TypeKind, -- 80 bit floating point type (X87)
FP128TypeKind, -- 128 bit floating point type (112-bit mantissa)
PPC_FP128TypeKind, -- 128 bit floating point type (two 64-bits)
LabelTypeKind, -- Labels
IntegerTypeKind, -- Arbitrary bit width integers
FunctionTypeKind, -- Functions
StructTypeKind, -- Structures
ArrayTypeKind, -- Arrays
PointerTypeKind, -- Pointers
VectorTypeKind, -- SIMD 'packed' format, or other vector type
MetadataTypeKind, -- Metadata
X86_MMXTypeKind -- X86 MMX
);
pragma Convention (C, TypeKind);
type Linkage is
(
ExternalLinkage, -- Externally visible function
AvailableExternallyLinkage,
LinkOnceAnyLinkage, -- Keep one copy of function when linking (inline)
LinkOnceODRLinkage, -- Same, but only replaced by someth equivalent.
LinkOnceODRAutoHideLinkage, -- Obsolete
WeakAnyLinkage, -- Keep one copy of function when linking (weak)
WeakODRLinkage, -- Same, but only replaced by someth equivalent.
AppendingLinkage, -- Special purpose, only applies to global arrays
InternalLinkage, -- Rename collisions when linking (static func)
PrivateLinkage, -- Like Internal, but omit from symbol table
DLLImportLinkage, -- Obsolete
DLLExportLinkage, -- Obsolete
ExternalWeakLinkage,-- ExternalWeak linkage description
GhostLinkage, -- Obsolete
CommonLinkage, -- Tentative definitions
LinkerPrivateLinkage, -- Like Private, but linker removes.
LinkerPrivateWeakLinkage -- Like LinkerPrivate, but is weak.
);
pragma Convention (C, Linkage);
type Visibility is
(
DefaultVisibility, -- The GV is visible
HiddenVisibility, -- The GV is hidden
ProtectedVisibility -- The GV is protected
);
pragma Convention (C, Visibility);
type CallConv is new unsigned;
CCallConv : constant CallConv := 0;
FastCallConv : constant CallConv := 8;
ColdCallConv : constant CallConv := 9;
X86StdcallCallConv : constant CallConv := 64;
X86FastcallCallConv : constant CallConv := 6;
type IntPredicate is new unsigned;
IntEQ : constant IntPredicate := 32; -- equal
IntNE : constant IntPredicate := 33; -- not equal
IntUGT : constant IntPredicate := 34; -- unsigned greater than
IntUGE : constant IntPredicate := 35; -- unsigned greater or equal
IntULT : constant IntPredicate := 36; -- unsigned less than
IntULE : constant IntPredicate := 37; -- unsigned less or equal
IntSGT : constant IntPredicate := 38; -- signed greater than
IntSGE : constant IntPredicate := 39; -- signed greater or equal
IntSLT : constant IntPredicate := 40; -- signed less than
IntSLE : constant IntPredicate := 41; -- signed less or equal
type RealPredicate is
(
RealPredicateFalse, -- Always false (always folded)
RealOEQ, -- True if ordered and equal
RealOGT, -- True if ordered and greater than
RealOGE, -- True if ordered and greater than or equal
RealOLT, -- True if ordered and less than
RealOLE, -- True if ordered and less than or equal
RealONE, -- True if ordered and operands are unequal
RealORD, -- True if ordered (no nans)
RealUNO, -- True if unordered: isnan(X) | isnan(Y)
RealUEQ, -- True if unordered or equal
RealUGT, -- True if unordered or greater than
RealUGE, -- True if unordered, greater than, or equal
RealULT, -- True if unordered or less than
RealULE, -- True if unordered, less than, or equal
RealUNE, -- True if unordered or not equal
RealPredicateTrue -- Always true (always folded)
);
-- Error handling ----------------------------------------------------
procedure DisposeMessage (Message : Cstring);
-- Context
-- Create a new context.
-- Every call to this function should be paired with a call to
-- LLVMContextDispose() or the context will leak memory.
function ContextCreate return ContextRef;
-- Obtain the global context instance.
function GetGlobalContext return ContextRef;
-- Destroy a context instance.
-- This should be called for every call to LLVMContextCreate() or memory
-- will be leaked.
procedure ContextDispose (C : ContextRef);
function GetMDKindIDInContext
(C : ContextRef; Name : Cstring; Slen : unsigned)
return unsigned;
function GetMDKindID(Name : String; Slen : unsigned) return unsigned;
-- Modules -----------------------------------------------------------
-- Create and destroy modules.
-- See llvm::Module::Module.
function ModuleCreateWithName (ModuleID : Cstring) return ModuleRef;
-- See llvm::Module::~Module.
procedure DisposeModule (M : ModuleRef);
-- Data layout. See Module::getDataLayout.
function GetDataLayout(M : ModuleRef) return Cstring;
procedure SetDataLayout(M : ModuleRef; Triple : Cstring);
-- Target triple. See Module::getTargetTriple.
function GetTarget (M : ModuleRef) return Cstring;
procedure SetTarget (M : ModuleRef; Triple : Cstring);
-- See Module::dump.
procedure DumpModule(M : ModuleRef);
-- 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()
function PrintModuleToFile(M : ModuleRef;
Filename : Cstring;
ErrorMessage : access Cstring) return Bool;
-- Types -------------------------------------------------------------
-- LLVM types conform to the following hierarchy:
--
-- types:
-- integer type
-- real type
-- function type
-- sequence types:
-- array type
-- pointer type
-- vector type
-- void type
-- label type
-- opaque type
-- See llvm::LLVMTypeKind::getTypeID.
function GetTypeKind (Ty : TypeRef) return TypeKind;
-- Operations on integer types
function Int1Type return TypeRef;
function Int8Type return TypeRef;
function Int16Type return TypeRef;
function Int32Type return TypeRef;
function Int64Type return TypeRef;
function IntType(NumBits : unsigned) return TypeRef;
function GetIntTypeWidth(IntegerTy : TypeRef) return unsigned;
function MetadataType return TypeRef;
-- Operations on real types
function FloatType return TypeRef;
function DoubleType return TypeRef;
function X86FP80Type return TypeRef;
function FP128Type return TypeRef;
function PPCFP128Type return TypeRef;
-- Operations on function types
function FunctionType(ReturnType : TypeRef;
ParamTypes : TypeRefArray;
ParamCount : unsigned;
IsVarArg : int) return TypeRef;
function IsFunctionVarArg(FunctionTy : TypeRef) return int;
function GetReturnType(FunctionTy : TypeRef) return TypeRef;
function CountParamTypes(FunctionTy : TypeRef) return unsigned;
procedure GetParamTypes(FunctionTy : TypeRef; Dest : out TypeRefArray);
-- Operations on struct types
function StructType(ElementTypes : TypeRefArray;
ElementCount : unsigned;
Packed : Bool) return TypeRef;
function StructCreateNamed(C : ContextRef; Name : Cstring) return TypeRef;
procedure StructSetBody(StructTy : TypeRef;
ElementTypes : TypeRefArray;
ElementCount : unsigned;
Packed : Bool);
function CountStructElementTypes(StructTy : TypeRef) return unsigned;
procedure GetStructElementTypes(StructTy : TypeRef;
Dest : out TypeRefArray);
function IsPackedStruct(StructTy : TypeRef) return Bool;
-- Operations on array, pointer, and vector types (sequence types)
function ArrayType(ElementType : TypeRef; ElementCount : unsigned)
return TypeRef;
function PointerType(ElementType : TypeRef; AddressSpace : unsigned := 0)
return TypeRef;
function VectorType(ElementType : TypeRef; ElementCount : unsigned)
return TypeRef;
function GetElementType(Ty : TypeRef) return TypeRef;
function GetArrayLength(ArrayTy : TypeRef) return unsigned;
function GetPointerAddressSpace(PointerTy : TypeRef) return unsigned;
function GetVectorSize(VectorTy : TypeRef) return unsigned;
-- Operations on other types.
function VoidType return TypeRef;
function LabelType return TypeRef;
-- Values ------------------------------------------------------------
-- The bulk of LLVM's object model consists of values, which comprise a very
-- rich type hierarchy.
--
-- values:
-- constants:
-- scalar constants
-- composite contants
-- globals:
-- global variable
-- function
-- alias
-- basic blocks
-- Operations on all values
function TypeOf(Val : ValueRef) return TypeRef;
function GetValueName(Val : ValueRef) return Cstring;
procedure SetValueName(Val : ValueRef; Name : Cstring);
procedure DumpValue(Val : ValueRef);
-- Operations on constants of any type
function ConstNull(Ty : TypeRef) return ValueRef; -- All zero
function ConstAllOnes(Ty : TypeRef) return ValueRef; -- Int or Vec
function GetUndef(Ty : TypeRef) return ValueRef;
function IsConstant(Val : ValueRef) return int;
function IsNull(Val : ValueRef) return int;
function IsUndef(Val : ValueRef) return int;
-- 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<>
function IsAInstruction (Val : ValueRef) return ValueRef;
-- Operations on scalar constants
function ConstInt(IntTy : TypeRef; N : Unsigned_64; SignExtend : int)
return ValueRef;
function ConstReal(RealTy : TypeRef; N : double) return ValueRef;
function ConstRealOfString(RealTy : TypeRef; Text : Cstring)
return ValueRef;
-- Obtain the zero extended value for an integer constant value.
-- @see llvm::ConstantInt::getZExtValue()
function ConstIntGetZExtValue (ConstantVal : ValueRef) return Unsigned_64;
-- Operations on composite constants
function ConstString(Str : Cstring;
Length : unsigned; DontNullTerminate : int)
return ValueRef;
function ConstArray(ElementTy : TypeRef;
ConstantVals : ValueRefArray; Length : unsigned)
return ValueRef;
function ConstStruct(ConstantVals : ValueRefArray;
Count : unsigned; packed : int) return ValueRef;
-- Create a non-anonymous ConstantStruct from values.
-- @see llvm::ConstantStruct::get()
function ConstNamedStruct(StructTy : TypeRef;
ConstantVals : ValueRefArray;
Count : unsigned) return ValueRef;
function ConstVector(ScalarConstantVals : ValueRefArray; Size : unsigned)
return ValueRef;
-- Constant expressions
function SizeOf(Ty : TypeRef) return ValueRef;
function AlignOf(Ty : TypeRef) return ValueRef;
function ConstNeg(ConstantVal : ValueRef) return ValueRef;
function ConstNot(ConstantVal : ValueRef) return ValueRef;
function ConstAdd(LHSConstant : ValueRef; RHSConstant : ValueRef)
return ValueRef;
function ConstSub(LHSConstant : ValueRef; RHSConstant : ValueRef)
return ValueRef;
function ConstMul(LHSConstant : ValueRef; RHSConstant : ValueRef)
return ValueRef;
function ConstUDiv(LHSConstant : ValueRef; RHSConstant : ValueRef)
return ValueRef;
function ConstSDiv(LHSConstant : ValueRef; RHSConstant : ValueRef)
return ValueRef;
function ConstFDiv(LHSConstant : ValueRef; RHSConstant : ValueRef)
return ValueRef;
function ConstURem(LHSConstant : ValueRef; RHSConstant : ValueRef)
return ValueRef;
function ConstSRem(LHSConstant : ValueRef; RHSConstant : ValueRef)
return ValueRef;
function ConstFRem(LHSConstant : ValueRef; RHSConstant : ValueRef)
return ValueRef;
function ConstAnd(LHSConstant : ValueRef; RHSConstant : ValueRef)
return ValueRef;
function ConstOr(LHSConstant : ValueRef; RHSConstant : ValueRef)
return ValueRef;
function ConstXor(LHSConstant : ValueRef; RHSConstant : ValueRef)
return ValueRef;
function ConstICmp(Predicate : IntPredicate;
LHSConstant : ValueRef; RHSConstant : ValueRef)
return ValueRef;
function ConstFCmp(Predicate : RealPredicate;
LHSConstant : ValueRef; RHSConstant : ValueRef)
return ValueRef;
function ConstShl(LHSConstant : ValueRef; RHSConstant : ValueRef)
return ValueRef;
function ConstLShr(LHSConstant : ValueRef; RHSConstant : ValueRef)
return ValueRef;
function ConstAShr(LHSConstant : ValueRef; RHSConstant : ValueRef)
return ValueRef;
function ConstGEP(ConstantVal : ValueRef;
ConstantIndices : ValueRefArray; NumIndices : unsigned)
return ValueRef;
function ConstTrunc(ConstantVal : ValueRef; ToType : TypeRef)
return ValueRef;
function ConstSExt(ConstantVal : ValueRef; ToType : TypeRef)
return ValueRef;
function ConstZExt(ConstantVal : ValueRef; ToType : TypeRef)
return ValueRef;
function ConstFPTrunc(ConstantVal : ValueRef; ToType : TypeRef)
return ValueRef;
function ConstFPExt(ConstantVal : ValueRef; ToType : TypeRef)
return ValueRef;
function ConstUIToFP(ConstantVal : ValueRef; ToType : TypeRef)
return ValueRef;
function ConstSIToFP(ConstantVal : ValueRef; ToType : TypeRef)
return ValueRef;
function ConstFPToUI(ConstantVal : ValueRef; ToType : TypeRef)
return ValueRef;
function ConstFPToSI(ConstantVal : ValueRef; ToType : TypeRef)
return ValueRef;
function ConstPtrToInt(ConstantVal : ValueRef; ToType : TypeRef)
return ValueRef;
function ConstIntToPtr(ConstantVal : ValueRef; ToType : TypeRef)
return ValueRef;
function ConstBitCast(ConstantVal : ValueRef; ToType : TypeRef)
return ValueRef;
function ConstTruncOrBitCast(ConstantVal : ValueRef; ToType : TypeRef)
return ValueRef;
function ConstSelect(ConstantCondition : ValueRef;
ConstantIfTrue : ValueRef;
ConstantIfFalse : ValueRef) return ValueRef;
function ConstExtractElement(VectorConstant : ValueRef;
IndexConstant : ValueRef) return ValueRef;
function ConstInsertElement(VectorConstant : ValueRef;
ElementValueConstant : ValueRef;
IndexConstant : ValueRef) return ValueRef;
function ConstShuffleVector(VectorAConstant : ValueRef;
VectorBConstant : ValueRef;
MaskConstant : ValueRef) return ValueRef;
-- Operations on global variables, functions, and aliases (globals)
function GetGlobalParent(Global : ValueRef) return ModuleRef;
function IsDeclaration(Global : ValueRef) return int;
function GetLinkage(Global : ValueRef) return Linkage;
procedure SetLinkage(Global : ValueRef; Link : Linkage);
function GetSection(Global : ValueRef) return Cstring;
procedure SetSection(Global : ValueRef; Section : Cstring);
function GetVisibility(Global : ValueRef) return Visibility;
procedure SetVisibility(Global : ValueRef; Viz : Visibility);
function GetAlignment(Global : ValueRef) return unsigned;
procedure SetAlignment(Global : ValueRef; Bytes : unsigned);
-- Operations on global variables
function AddGlobal(M : ModuleRef; Ty : TypeRef; Name : Cstring)
return ValueRef;
function GetNamedGlobal(M : ModuleRef; Name : Cstring) return ValueRef;
function GetFirstGlobal(M : ModuleRef) return ValueRef;
function GetLastGlobal(M : ModuleRef) return ValueRef;
function GetNextGlobal(GlobalVar : ValueRef) return ValueRef;
function GetPreviousGlobal(GlobalVar : ValueRef) return ValueRef;
procedure DeleteGlobal(GlobalVar : ValueRef);
function GetInitializer(GlobalVar : ValueRef) return ValueRef;
procedure SetInitializer(GlobalVar : ValueRef; ConstantVal : ValueRef);
function IsThreadLocal(GlobalVar : ValueRef) return int;
procedure SetThreadLocal(GlobalVar : ValueRef; IsThreadLocal : int);
function IsGlobalConstant(GlobalVar : ValueRef) return int;
procedure SetGlobalConstant(GlobalVar : ValueRef; IsConstant : int);
-- Obtain the number of operands for named metadata in a module.
-- @see llvm::Module::getNamedMetadata()
function GetNamedMetadataNumOperands(M : ModuleRef; Name : Cstring)
return unsigned;
-- 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()
procedure GetNamedMetadataOperands
(M : ModuleRef; Name : Cstring; Dest : ValueRefArray);
-- Add an operand to named metadata.
-- @see llvm::Module::getNamedMetadata()
-- @see llvm::MDNode::addOperand()
procedure AddNamedMetadataOperand
(M : ModuleRef; Name : Cstring; Val : ValueRef);
-- Operations on functions
function AddFunction(M : ModuleRef; Name : Cstring; FunctionTy : TypeRef)
return ValueRef;
function GetNamedFunction(M : ModuleRef; Name : Cstring) return ValueRef;
function GetFirstFunction(M : ModuleRef) return ValueRef;
function GetLastFunction(M : ModuleRef) return ValueRef;
function GetNextFunction(Fn : ValueRef) return ValueRef;
function GetPreviousFunction(Fn : ValueRef) return ValueRef;
procedure DeleteFunction(Fn : ValueRef);
function GetIntrinsicID(Fn : ValueRef) return unsigned;
function GetFunctionCallConv(Fn : ValueRef) return CallConv;
procedure SetFunctionCallConv(Fn : ValueRef; CC : CallConv);
function GetGC(Fn : ValueRef) return Cstring;
procedure SetGC(Fn : ValueRef; Name : Cstring);
-- Add an attribute to a function.
-- @see llvm::Function::addAttribute()
procedure AddFunctionAttr (Fn : ValueRef; PA : Attribute);
-- Add a target-dependent attribute to a fuction
-- @see llvm::AttrBuilder::addAttribute()
procedure AddTargetDependentFunctionAttr
(Fn : ValueRef; A : Cstring; V : Cstring);
-- Obtain an attribute from a function.
-- @see llvm::Function::getAttributes()
function GetFunctionAttr (Fn : ValueRef) return Attribute;
-- Remove an attribute from a function.
procedure RemoveFunctionAttr (Fn : ValueRef; PA : Attribute);
-- Operations on parameters
function CountParams(Fn : ValueRef) return unsigned;
procedure GetParams(Fn : ValueRef; Params : ValueRefArray);
function GetParam(Fn : ValueRef; Index : unsigned) return ValueRef;
function GetParamParent(Inst : ValueRef) return ValueRef;
function GetFirstParam(Fn : ValueRef) return ValueRef;
function GetLastParam(Fn : ValueRef) return ValueRef;
function GetNextParam(Arg : ValueRef) return ValueRef;
function GetPreviousParam(Arg : ValueRef) return ValueRef;
procedure AddAttribute(Arg : ValueRef; PA : Attribute);
procedure RemoveAttribute(Arg : ValueRef; PA : Attribute);
procedure SetParamAlignment(Arg : ValueRef; align : unsigned);
-- Metadata
-- Obtain a MDString value from a context.
-- The returned instance corresponds to the llvm::MDString class.
-- The instance is specified by string data of a specified length. The
-- string content is copied, so the backing memory can be freed after
-- this function returns.
function MDStringInContext(C : ContextRef; Str : Cstring; Len : unsigned)
return ValueRef;
-- Obtain a MDString value from the global context.
function MDString(Str : Cstring; Len : unsigned) return ValueRef;
-- Obtain a MDNode value from a context.
-- The returned value corresponds to the llvm::MDNode class.
function MDNodeInContext
(C : ContextRef; Vals : ValueRefArray; Count : unsigned)
return ValueRef;
-- Obtain a MDNode value from the global context.
function MDNode(Vals : ValueRefArray; Count : unsigned) return ValueRef;
-- Obtain the underlying string from a MDString value.
-- @param V Instance to obtain string from.
-- @param Len Memory address which will hold length of returned string.
-- @return String data in MDString.
function GetMDString(V : ValueRef; Len : access unsigned) return Cstring;
-- 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.
function GetMDNodeNumOperands(V : ValueRef) return unsigned;
-- 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.
procedure GetMDNodeOperands(V : ValueRef; Dest : ValueRefArray);
procedure MDNodeReplaceOperandWith
(N : ValueRef; I : unsigned; V : ValueRef);
-- Operations on basic blocks
function BasicBlockAsValue(BB : BasicBlockRef) return ValueRef;
function ValueIsBasicBlock(Val : ValueRef) return int;
function ValueAsBasicBlock(Val : ValueRef) return BasicBlockRef;
function GetBasicBlockParent(BB : BasicBlockRef) return ValueRef;
function CountBasicBlocks(Fn : ValueRef) return unsigned;
procedure GetBasicBlocks(Fn : ValueRef; BasicBlocks : BasicBlockRefArray);
function GetFirstBasicBlock(Fn : ValueRef) return BasicBlockRef;
function GetLastBasicBlock(Fn : ValueRef) return BasicBlockRef;
function GetNextBasicBlock(BB : BasicBlockRef) return BasicBlockRef;
function GetPreviousBasicBlock(BB : BasicBlockRef) return BasicBlockRef;
function GetEntryBasicBlock(Fn : ValueRef) return BasicBlockRef;
function AppendBasicBlock(Fn : ValueRef; Name : Cstring)
return BasicBlockRef;
function InsertBasicBlock(InsertBeforeBB : BasicBlockRef;
Name : Cstring) return BasicBlockRef;
procedure DeleteBasicBlock(BB : BasicBlockRef);
-- Operations on instructions
-- Determine whether an instruction has any metadata attached.
function HasMetadata(Val: ValueRef) return Bool;
-- Return metadata associated with an instruction value.
function GetMetadata(Val : ValueRef; KindID : unsigned) return ValueRef;
-- Set metadata associated with an instruction value.
procedure SetMetadata(Val : ValueRef; KindID : unsigned; Node : ValueRef);
function GetInstructionParent(Inst : ValueRef) return BasicBlockRef;
function GetFirstInstruction(BB : BasicBlockRef) return ValueRef;
function GetLastInstruction(BB : BasicBlockRef) return ValueRef;
function GetNextInstruction(Inst : ValueRef) return ValueRef;
function GetPreviousInstruction(Inst : ValueRef) return ValueRef;
-- Operations on call sites
procedure SetInstructionCallConv(Instr : ValueRef; CC : unsigned);
function GetInstructionCallConv(Instr : ValueRef) return unsigned;
procedure AddInstrAttribute(Instr : ValueRef;
index : unsigned; Attr : Attribute);
procedure RemoveInstrAttribute(Instr : ValueRef;
index : unsigned; Attr : Attribute);
procedure SetInstrParamAlignment(Instr : ValueRef;
index : unsigned; align : unsigned);
-- Operations on call instructions (only)
function IsTailCall(CallInst : ValueRef) return int;
procedure SetTailCall(CallInst : ValueRef; IsTailCall : int);
-- Operations on phi nodes
procedure AddIncoming(PhiNode : ValueRef; IncomingValues : ValueRefArray;
IncomingBlocks : BasicBlockRefArray; Count : unsigned);
function CountIncoming(PhiNode : ValueRef) return unsigned;
function GetIncomingValue(PhiNode : ValueRef; Index : unsigned)
return ValueRef;
function GetIncomingBlock(PhiNode : ValueRef; Index : unsigned)
return BasicBlockRef;
-- Instruction builders ----------------------------------------------
-- An instruction builder represents a point within a basic block,
-- and is the exclusive means of building instructions using the C
-- interface.
function CreateBuilder return BuilderRef;
procedure PositionBuilder(Builder : BuilderRef;
Block : BasicBlockRef; Instr : ValueRef);
procedure PositionBuilderBefore(Builder : BuilderRef; Instr : ValueRef);
procedure PositionBuilderAtEnd(Builder : BuilderRef; Block : BasicBlockRef);
function GetInsertBlock(Builder : BuilderRef) return BasicBlockRef;
procedure DisposeBuilder(Builder : BuilderRef);
-- Terminators
function BuildRetVoid(Builder : BuilderRef) return ValueRef;
function BuildRet(Builder : BuilderRef; V : ValueRef) return ValueRef;
function BuildBr(Builder : BuilderRef; Dest : BasicBlockRef)
return ValueRef;
function BuildCondBr(Builder : BuilderRef;
If_Br : ValueRef;
Then_Br : BasicBlockRef; Else_Br : BasicBlockRef)
return ValueRef;
function BuildSwitch(Builder : BuilderRef;
V : ValueRef;
Else_Br : BasicBlockRef; NumCases : unsigned)
return ValueRef;
function BuildInvoke(Builder : BuilderRef;
Fn : ValueRef;
Args : ValueRefArray;
NumArgs : unsigned;
Then_Br : BasicBlockRef;
Catch : BasicBlockRef;
Name : Cstring) return ValueRef;
function BuildUnwind(Builder : BuilderRef) return ValueRef;
function BuildUnreachable(Builder : BuilderRef) return ValueRef;
-- Add a case to the switch instruction
procedure AddCase(Switch : ValueRef;
OnVal : ValueRef; Dest : BasicBlockRef);
-- Arithmetic
function BuildAdd(Builder : BuilderRef;
LHS : ValueRef; RHS : ValueRef; Name : Cstring)
return ValueRef;
function BuildNSWAdd(Builder : BuilderRef;
LHS : ValueRef; RHS : ValueRef; Name : Cstring)
return ValueRef;
function BuildNUWAdd(Builder : BuilderRef;
LHS : ValueRef; RHS : ValueRef; Name : Cstring)
return ValueRef;
function BuildFAdd(Builder : BuilderRef;
LHS : ValueRef; RHS : ValueRef; Name : Cstring)
return ValueRef;
function BuildSub(Builder : BuilderRef;
LHS : ValueRef; RHS : ValueRef; Name : Cstring)
return ValueRef;
function BuildNSWSub(Builder : BuilderRef;
LHS : ValueRef; RHS : ValueRef; Name : Cstring)
return ValueRef;
function BuildNUWSub(Builder : BuilderRef;
LHS : ValueRef; RHS : ValueRef; Name : Cstring)
return ValueRef;
function BuildFSub(Builder : BuilderRef;
LHS : ValueRef; RHS : ValueRef; Name : Cstring)
return ValueRef;
function BuildMul(Builder : BuilderRef;
LHS : ValueRef; RHS : ValueRef; Name : Cstring)
return ValueRef;
function BuildFMul(Builder : BuilderRef;
LHS : ValueRef; RHS : ValueRef; Name : Cstring)
return ValueRef;
function BuildUDiv(Builder : BuilderRef;
LHS : ValueRef; RHS : ValueRef; Name : Cstring)
return ValueRef;
function BuildSDiv(Builder : BuilderRef;
LHS : ValueRef; RHS : ValueRef; Name : Cstring)
return ValueRef;
function BuildFDiv(Builder : BuilderRef;
LHS : ValueRef; RHS : ValueRef; Name : Cstring)
return ValueRef;
function BuildURem(Builder : BuilderRef;
LHS : ValueRef; RHS : ValueRef; Name : Cstring)
return ValueRef;
function BuildSRem(Builder : BuilderRef;
LHS : ValueRef; RHS : ValueRef; Name : Cstring)
return ValueRef;
function BuildFRem(Builder : BuilderRef;
LHS : ValueRef; RHS : ValueRef; Name : Cstring)
return ValueRef;
function BuildShl(Builder : BuilderRef;
LHS : ValueRef; RHS : ValueRef; Name : Cstring)
return ValueRef;
function BuildLShr(Builder : BuilderRef;
LHS : ValueRef; RHS : ValueRef; Name : Cstring)
return ValueRef;
function BuildAShr(Builder : BuilderRef;
LHS : ValueRef; RHS : ValueRef; Name : Cstring)
return ValueRef;
function BuildAnd(Builder : BuilderRef;
LHS : ValueRef; RHS : ValueRef; Name : Cstring)
return ValueRef;
function BuildOr(Builder : BuilderRef;
LHS : ValueRef; RHS : ValueRef; Name : Cstring)
return ValueRef;
function BuildXor(Builder : BuilderRef;
LHS : ValueRef; RHS : ValueRef; Name : Cstring)
return ValueRef;
function BuildNeg(Builder : BuilderRef; V : ValueRef; Name : Cstring)
return ValueRef;
function BuildFNeg(Builder : BuilderRef; V : ValueRef; Name : Cstring)
return ValueRef;
function BuildNot(Builder : BuilderRef; V : ValueRef; Name : Cstring)
return ValueRef;
-- Memory
function BuildMalloc(Builder : BuilderRef; Ty : TypeRef; Name : Cstring)
return ValueRef;
function BuildArrayMalloc(Builder : BuilderRef;
Ty : TypeRef; Val : ValueRef; Name : Cstring)
return ValueRef;
function BuildAlloca(Builder : BuilderRef; Ty : TypeRef; Name : Cstring)
return ValueRef;
function BuildArrayAlloca(Builder : BuilderRef;
Ty : TypeRef; Val : ValueRef; Name : Cstring)
return ValueRef;
function BuildFree(Builder : BuilderRef; PointerVal : ValueRef)
return ValueRef;
function BuildLoad(Builder : BuilderRef; PointerVal : ValueRef;
Name : Cstring) return ValueRef;
function BuildStore(Builder : BuilderRef; Val : ValueRef; Ptr : ValueRef)
return ValueRef;
function BuildGEP(Builder : BuilderRef;
Pointer : ValueRef;
Indices : ValueRefArray;
NumIndices : unsigned; Name : Cstring) return ValueRef;
-- Casts
function BuildTrunc(Builder : BuilderRef;
Val : ValueRef; DestTy : TypeRef; Name : Cstring)
return ValueRef;
function BuildZExt(Builder : BuilderRef;
Val : ValueRef; DestTy : TypeRef; Name : Cstring)
return ValueRef;
function BuildSExt(Builder : BuilderRef;
Val : ValueRef; DestTy : TypeRef; Name : Cstring)
return ValueRef;
function BuildFPToUI(Builder : BuilderRef;
Val : ValueRef; DestTy : TypeRef; Name : Cstring)
return ValueRef;
function BuildFPToSI(Builder : BuilderRef;
Val : ValueRef; DestTy : TypeRef; Name : Cstring)
return ValueRef;
function BuildUIToFP(Builder : BuilderRef;
Val : ValueRef; DestTy : TypeRef; Name : Cstring)
return ValueRef;
function BuildSIToFP(Builder : BuilderRef;
Val : ValueRef; DestTy : TypeRef; Name : Cstring)
return ValueRef;
function BuildFPTrunc(Builder : BuilderRef;
Val : ValueRef; DestTy : TypeRef; Name : Cstring)
return ValueRef;
function BuildFPExt(Builder : BuilderRef;
Val : ValueRef; DestTy : TypeRef; Name : Cstring)
return ValueRef;
function BuildPtrToInt(Builder : BuilderRef;
Val : ValueRef; DestTy : TypeRef; Name : Cstring)
return ValueRef;
function BuildIntToPtr(Builder : BuilderRef;
Val : ValueRef; DestTy : TypeRef; Name : Cstring)
return ValueRef;
function BuildBitCast(Builder : BuilderRef;
Val : ValueRef; DestTy : TypeRef; Name : Cstring)
return ValueRef;
-- Comparisons
function BuildICmp(Builder : BuilderRef;
Op : IntPredicate;
LHS : ValueRef; RHS : ValueRef; Name : Cstring)
return ValueRef;
function BuildFCmp(Builder : BuilderRef;
Op : RealPredicate;
LHS : ValueRef; RHS : ValueRef; Name : Cstring)
return ValueRef;
-- Miscellaneous instructions
function BuildPhi(Builder : BuilderRef; Ty : TypeRef; Name : Cstring)
return ValueRef;
function BuildCall(Builder : BuilderRef;
Fn : ValueRef;
Args : ValueRefArray; NumArgs : unsigned; Name : Cstring)
return ValueRef;
function BuildSelect(Builder : BuilderRef;
If_Sel : ValueRef;
Then_Sel : ValueRef;
Else_Sel : ValueRef;
Name : Cstring) return ValueRef;
function BuildVAArg(Builder : BuilderRef;
List : ValueRef; Ty : TypeRef; Name : Cstring)
return ValueRef;
function BuildExtractElement(Builder : BuilderRef;
VecVal : ValueRef;
Index : ValueRef;
Name : Cstring) return ValueRef;
function BuildInsertElement(Builder : BuilderRef;
VecVal : ValueRef;
EltVal : ValueRef;
Index : ValueRef;
Name : Cstring) return ValueRef;
function BuildShuffleVector(Builder : BuilderRef;
V1 : ValueRef;
V2 : ValueRef;
Mask : ValueRef;
Name : Cstring) return ValueRef;
-- Memory buffers ----------------------------------------------------
function CreateMemoryBufferWithContentsOfFile
(Path : Cstring;
OutMemBuf : access MemoryBufferRef;
OutMessage : access Cstring) return int;
function CreateMemoryBufferWithSTDIN
(OutMemBuf : access MemoryBufferRef;
OutMessage : access Cstring) return int;
procedure DisposeMemoryBuffer(MemBuf : MemoryBufferRef);
-- 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.
function CreatePassManager return PassManagerRef;
-- 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.
function CreateFunctionPassManagerForModule(M : ModuleRef)
return PassManagerRef;
-- 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&).
function RunPassManager(PM : PassManagerRef; M : ModuleRef)
return int;
-- 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.
function InitializeFunctionPassManager(FPM : PassManagerRef)
return int;
-- 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&).
function RunFunctionPassManager (FPM : PassManagerRef; F : ValueRef)
return int;
-- Finalizes all of the function passes scheduled in in the function pass
-- manager. Returns 1 if any of the passes modified the module, 0 otherwise.
-- See llvm::FunctionPassManager::doFinalization.
function FinalizeFunctionPassManager(FPM : PassManagerRef)
return int;
-- Frees the memory of a pass pipeline. For function pipelines,
-- does not free the module provider.
-- See llvm::PassManagerBase::~PassManagerBase.
procedure DisposePassManager(PM : PassManagerRef);
private
pragma Import (C, ContextCreate, "LLVMContextCreate");
pragma Import (C, GetGlobalContext, "LLVMGetGlobalContext");
pragma Import (C, ContextDispose, "LLVMContextDispose");
pragma Import (C, GetMDKindIDInContext, "LLVMGetMDKindIDInContext");
pragma Import (C, GetMDKindID, "LLVMGetMDKindID");
pragma Import (C, DisposeMessage, "LLVMDisposeMessage");
pragma Import (C, ModuleCreateWithName, "LLVMModuleCreateWithName");
pragma Import (C, DisposeModule, "LLVMDisposeModule");
pragma Import (C, GetDataLayout, "LLVMGetDataLayout");
pragma Import (C, SetDataLayout, "LLVMSetDataLayout");
pragma Import (C, GetTarget, "LLVMGetTarget");
pragma Import (C, SetTarget, "LLVMSetTarget");
pragma Import (C, DumpModule, "LLVMDumpModule");
pragma Import (C, PrintModuleToFile, "LLVMPrintModuleToFile");
pragma Import (C, GetTypeKind, "LLVMGetTypeKind");
pragma Import (C, Int1Type, "LLVMInt1Type");
pragma Import (C, Int8Type, "LLVMInt8Type");
pragma Import (C, Int16Type, "LLVMInt16Type");
pragma Import (C, Int32Type, "LLVMInt32Type");
pragma Import (C, Int64Type, "LLVMInt64Type");
pragma Import (C, IntType, "LLVMIntType");
pragma Import (C, GetIntTypeWidth, "LLVMGetIntTypeWidth");
pragma Import (C, MetadataType, "LLVMMetadataType_extra");
pragma Import (C, FloatType, "LLVMFloatType");
pragma Import (C, DoubleType, "LLVMDoubleType");
pragma Import (C, X86FP80Type, "LLVMX86FP80Type");
pragma Import (C, FP128Type, "LLVMFP128Type");
pragma Import (C, PPCFP128Type, "LLVMPPCFP128Type");
pragma Import (C, FunctionType, "LLVMFunctionType");
pragma Import (C, IsFunctionVarArg, "LLVMIsFunctionVarArg");
pragma Import (C, GetReturnType, "LLVMGetReturnType");
pragma Import (C, CountParamTypes, "LLVMCountParamTypes");
pragma Import (C, GetParamTypes, "LLVMGetParamTypes");
pragma Import (C, StructType, "LLVMStructType");
pragma Import (C, StructCreateNamed, "LLVMStructCreateNamed");
pragma Import (C, StructSetBody, "LLVMStructSetBody");
pragma Import (C, CountStructElementTypes, "LLVMCountStructElementTypes");
pragma Import (C, GetStructElementTypes, "LLVMGetStructElementTypes");
pragma Import (C, IsPackedStruct, "LLVMIsPackedStruct");
pragma Import (C, ArrayType, "LLVMArrayType");
pragma Import (C, PointerType, "LLVMPointerType");
pragma Import (C, VectorType, "LLVMVectorType");
pragma Import (C, GetElementType, "LLVMGetElementType");
pragma Import (C, GetArrayLength, "LLVMGetArrayLength");
pragma Import (C, GetPointerAddressSpace, "LLVMGetPointerAddressSpace");
pragma Import (C, GetVectorSize, "LLVMGetVectorSize");
pragma Import (C, VoidType, "LLVMVoidType");
pragma Import (C, LabelType, "LLVMLabelType");
pragma Import (C, TypeOf, "LLVMTypeOf");
pragma Import (C, GetValueName, "LLVMGetValueName");
pragma Import (C, SetValueName, "LLVMSetValueName");
pragma Import (C, DumpValue, "LLVMDumpValue");
pragma Import (C, ConstNull, "LLVMConstNull");
pragma Import (C, ConstAllOnes, "LLVMConstAllOnes");
pragma Import (C, GetUndef, "LLVMGetUndef");
pragma Import (C, IsConstant, "LLVMIsConstant");
pragma Import (C, IsNull, "LLVMIsNull");
pragma Import (C, IsUndef, "LLVMIsUndef");
pragma Import (C, IsAInstruction, "LLVMIsAInstruction");
pragma Import (C, ConstInt, "LLVMConstInt");
pragma Import (C, ConstReal, "LLVMConstReal");
pragma Import (C, ConstIntGetZExtValue, "LLVMConstIntGetZExtValue");
pragma Import (C, ConstRealOfString, "LLVMConstRealOfString");
pragma Import (C, ConstString, "LLVMConstString");
pragma Import (C, ConstArray, "LLVMConstArray");
pragma Import (C, ConstStruct, "LLVMConstStruct");
pragma Import (C, ConstNamedStruct, "LLVMConstNamedStruct");
pragma Import (C, ConstVector, "LLVMConstVector");
pragma Import (C, SizeOf, "LLVMSizeOf");
pragma Import (C, AlignOf, "LLVMAlignOf");
pragma Import (C, ConstNeg, "LLVMConstNeg");
pragma Import (C, ConstNot, "LLVMConstNot");
pragma Import (C, ConstAdd, "LLVMConstAdd");
pragma Import (C, ConstSub, "LLVMConstSub");
pragma Import (C, ConstMul, "LLVMConstMul");
pragma Import (C, ConstUDiv, "LLVMConstUDiv");
pragma Import (C, ConstSDiv, "LLVMConstSDiv");
pragma Import (C, ConstFDiv, "LLVMConstFDiv");
pragma Import (C, ConstURem, "LLVMConstURem");
pragma Import (C, ConstSRem, "LLVMConstSRem");
pragma Import (C, ConstFRem, "LLVMConstFRem");
pragma Import (C, ConstAnd, "LLVMConstAnd");
pragma Import (C, ConstOr, "LLVMConstOr");
pragma Import (C, ConstXor, "LLVMConstXor");
pragma Import (C, ConstICmp, "LLVMConstICmp");
pragma Import (C, ConstFCmp, "LLVMConstFCmp");
pragma Import (C, ConstShl, "LLVMConstShl");
pragma Import (C, ConstLShr, "LLVMConstLShr");
pragma Import (C, ConstAShr, "LLVMConstAShr");
pragma Import (C, ConstGEP, "LLVMConstGEP");
pragma Import (C, ConstTrunc, "LLVMConstTrunc");
pragma Import (C, ConstSExt, "LLVMConstSExt");
pragma Import (C, ConstZExt, "LLVMConstZExt");
pragma Import (C, ConstFPTrunc, "LLVMConstFPTrunc");
pragma Import (C, ConstFPExt, "LLVMConstFPExt");
pragma Import (C, ConstUIToFP, "LLVMConstUIToFP");
pragma Import (C, ConstSIToFP, "LLVMConstSIToFP");
pragma Import (C, ConstFPToUI, "LLVMConstFPToUI");
pragma Import (C, ConstFPToSI, "LLVMConstFPToSI");
pragma Import (C, ConstPtrToInt, "LLVMConstPtrToInt");
pragma Import (C, ConstIntToPtr, "LLVMConstIntToPtr");
pragma Import (C, ConstBitCast, "LLVMConstBitCast");
pragma Import (C, ConstTruncOrBitCast, "LLVMConstTruncOrBitCast");
pragma Import (C, ConstSelect, "LLVMConstSelect");
pragma Import (C, ConstExtractElement, "LLVMConstExtractElement");
pragma Import (C, ConstInsertElement, "LLVMConstInsertElement");
pragma Import (C, ConstShuffleVector, "LLVMConstShuffleVector");
pragma Import (C, GetGlobalParent, "LLVMGetGlobalParent");
pragma Import (C, IsDeclaration, "LLVMIsDeclaration");
pragma Import (C, GetLinkage, "LLVMGetLinkage");
pragma Import (C, SetLinkage, "LLVMSetLinkage");
pragma Import (C, GetSection, "LLVMGetSection");
pragma Import (C, SetSection, "LLVMSetSection");
pragma Import (C, GetVisibility, "LLVMGetVisibility");
pragma Import (C, SetVisibility, "LLVMSetVisibility");
pragma Import (C, GetAlignment, "LLVMGetAlignment");
pragma Import (C, SetAlignment, "LLVMSetAlignment");
pragma Import (C, AddGlobal, "LLVMAddGlobal");
pragma Import (C, GetNamedGlobal, "LLVMGetNamedGlobal");
pragma Import (C, GetFirstGlobal, "LLVMGetFirstGlobal");
pragma Import (C, GetLastGlobal, "LLVMGetLastGlobal");
pragma Import (C, GetNextGlobal, "LLVMGetNextGlobal");
pragma Import (C, GetPreviousGlobal, "LLVMGetPreviousGlobal");
pragma Import (C, DeleteGlobal, "LLVMDeleteGlobal");
pragma Import (C, GetInitializer, "LLVMGetInitializer");
pragma Import (C, SetInitializer, "LLVMSetInitializer");
pragma Import (C, IsThreadLocal, "LLVMIsThreadLocal");
pragma Import (C, SetThreadLocal, "LLVMSetThreadLocal");
pragma Import (C, IsGlobalConstant, "LLVMIsGlobalConstant");
pragma Import (C, SetGlobalConstant, "LLVMSetGlobalConstant");
pragma Import (C, GetNamedMetadataNumOperands,
"LLVMGetNamedMetadataNumOperands");
pragma Import (C, GetNamedMetadataOperands, "LLVMGetNamedMetadataOperands");
pragma Import (C, AddNamedMetadataOperand, "LLVMAddNamedMetadataOperand");
pragma Import (C, AddFunction, "LLVMAddFunction");
pragma Import (C, GetNamedFunction, "LLVMGetNamedFunction");
pragma Import (C, GetFirstFunction, "LLVMGetFirstFunction");
pragma Import (C, GetLastFunction, "LLVMGetLastFunction");
pragma Import (C, GetNextFunction, "LLVMGetNextFunction");
pragma Import (C, GetPreviousFunction, "LLVMGetPreviousFunction");
pragma Import (C, DeleteFunction, "LLVMDeleteFunction");
pragma Import (C, GetIntrinsicID, "LLVMGetIntrinsicID");
pragma Import (C, GetFunctionCallConv, "LLVMGetFunctionCallConv");
pragma Import (C, SetFunctionCallConv, "LLVMSetFunctionCallConv");
pragma Import (C, GetGC, "LLVMGetGC");
pragma Import (C, SetGC, "LLVMSetGC");
pragma Import (C, AddFunctionAttr, "LLVMAddFunctionAttr");
pragma import (C, AddTargetDependentFunctionAttr,
"LLVMAddTargetDependentFunctionAttr");
pragma Import (C, GetFunctionAttr, "LLVMGetFunctionAttr");
pragma Import (C, RemoveFunctionAttr, "LLVMRemoveFunctionAttr");
pragma Import (C, CountParams, "LLVMCountParams");
pragma Import (C, GetParams, "LLVMGetParams");
pragma Import (C, GetParam, "LLVMGetParam");
pragma Import (C, GetParamParent, "LLVMGetParamParent");
pragma Import (C, GetFirstParam, "LLVMGetFirstParam");
pragma Import (C, GetLastParam, "LLVMGetLastParam");
pragma Import (C, GetNextParam, "LLVMGetNextParam");
pragma Import (C, GetPreviousParam, "LLVMGetPreviousParam");
pragma Import (C, AddAttribute, "LLVMAddAttribute");
pragma Import (C, RemoveAttribute, "LLVMRemoveAttribute");
pragma Import (C, SetParamAlignment, "LLVMSetParamAlignment");
pragma Import (C, MDStringInContext, "LLVMMDStringInContext");
pragma Import (C, MDString, "LLVMMDString");
pragma Import (C, MDNodeInContext, "LLVMMDNodeInContext");
pragma Import (C, MDNode, "LLVMMDNode");
pragma Import (C, GetMDString, "LLVMGetMDString");
pragma Import (C, GetMDNodeNumOperands, "LLVMGetMDNodeNumOperands");
pragma Import (C, GetMDNodeOperands, "LLVMGetMDNodeOperands");
pragma Import (C, MDNodeReplaceOperandWith,
"LLVMMDNodeReplaceOperandWith_extra");
pragma Import (C, BasicBlockAsValue, "LLVMBasicBlockAsValue");
pragma Import (C, ValueIsBasicBlock, "LLVMValueIsBasicBlock");
pragma Import (C, ValueAsBasicBlock, "LLVMValueAsBasicBlock");
pragma Import (C, GetBasicBlockParent, "LLVMGetBasicBlockParent");
pragma Import (C, CountBasicBlocks, "LLVMCountBasicBlocks");
pragma Import (C, GetBasicBlocks, "LLVMGetBasicBlocks");
pragma Import (C, GetFirstBasicBlock, "LLVMGetFirstBasicBlock");
pragma Import (C, GetLastBasicBlock, "LLVMGetLastBasicBlock");
pragma Import (C, GetNextBasicBlock, "LLVMGetNextBasicBlock");
pragma Import (C, GetPreviousBasicBlock, "LLVMGetPreviousBasicBlock");
pragma Import (C, GetEntryBasicBlock, "LLVMGetEntryBasicBlock");
pragma Import (C, AppendBasicBlock, "LLVMAppendBasicBlock");
pragma Import (C, InsertBasicBlock, "LLVMInsertBasicBlock");
pragma Import (C, DeleteBasicBlock, "LLVMDeleteBasicBlock");
pragma Import (C, HasMetadata, "LLVMHasMetadata");
pragma Import (C, GetMetadata, "LLVMGetMetadata");
pragma Import (C, SetMetadata, "LLVMSetMetadata");
pragma Import (C, GetInstructionParent, "LLVMGetInstructionParent");
pragma Import (C, GetFirstInstruction, "LLVMGetFirstInstruction");
pragma Import (C, GetLastInstruction, "LLVMGetLastInstruction");
pragma Import (C, GetNextInstruction, "LLVMGetNextInstruction");
pragma Import (C, GetPreviousInstruction, "LLVMGetPreviousInstruction");
pragma Import (C, SetInstructionCallConv, "LLVMSetInstructionCallConv");
pragma Import (C, GetInstructionCallConv, "LLVMGetInstructionCallConv");
pragma Import (C, AddInstrAttribute, "LLVMAddInstrAttribute");
pragma Import (C, RemoveInstrAttribute, "LLVMRemoveInstrAttribute");
pragma Import (C, SetInstrParamAlignment, "LLVMSetInstrParamAlignment");
pragma Import (C, IsTailCall, "LLVMIsTailCall");
pragma Import (C, SetTailCall, "LLVMSetTailCall");
pragma Import (C, AddIncoming, "LLVMAddIncoming");
pragma Import (C, CountIncoming, "LLVMCountIncoming");
pragma Import (C, GetIncomingValue, "LLVMGetIncomingValue");
pragma Import (C, GetIncomingBlock, "LLVMGetIncomingBlock");
pragma Import (C, CreateBuilder, "LLVMCreateBuilder");
pragma Import (C, PositionBuilder, "LLVMPositionBuilder");
pragma Import (C, PositionBuilderBefore, "LLVMPositionBuilderBefore");
pragma Import (C, PositionBuilderAtEnd, "LLVMPositionBuilderAtEnd");
pragma Import (C, GetInsertBlock, "LLVMGetInsertBlock");
pragma Import (C, DisposeBuilder, "LLVMDisposeBuilder");
-- Terminators
pragma Import (C, BuildRetVoid, "LLVMBuildRetVoid");
pragma Import (C, BuildRet, "LLVMBuildRet");
pragma Import (C, BuildBr, "LLVMBuildBr");
pragma Import (C, BuildCondBr, "LLVMBuildCondBr");
pragma Import (C, BuildSwitch, "LLVMBuildSwitch");
pragma Import (C, BuildInvoke, "LLVMBuildInvoke");
pragma Import (C, BuildUnwind, "LLVMBuildUnwind");
pragma Import (C, BuildUnreachable, "LLVMBuildUnreachable");
-- Add a case to the switch instruction
pragma Import (C, AddCase, "LLVMAddCase");
-- Arithmetic
pragma Import (C, BuildAdd, "LLVMBuildAdd");
pragma Import (C, BuildNSWAdd, "LLVMBuildNSWAdd");
pragma Import (C, BuildNUWAdd, "LLVMBuildNUWAdd");
pragma Import (C, BuildFAdd, "LLVMBuildFAdd");
pragma Import (C, BuildSub, "LLVMBuildSub");
pragma Import (C, BuildNSWSub, "LLVMBuildNSWSub");
pragma Import (C, BuildNUWSub, "LLVMBuildNUWSub");
pragma Import (C, BuildFSub, "LLVMBuildFSub");
pragma Import (C, BuildMul, "LLVMBuildMul");
pragma Import (C, BuildFMul, "LLVMBuildFMul");
pragma Import (C, BuildUDiv, "LLVMBuildUDiv");
pragma Import (C, BuildSDiv, "LLVMBuildSDiv");
pragma Import (C, BuildFDiv, "LLVMBuildFDiv");
pragma Import (C, BuildURem, "LLVMBuildURem");
pragma Import (C, BuildSRem, "LLVMBuildSRem");
pragma Import (C, BuildFRem, "LLVMBuildFRem");
pragma Import (C, BuildShl, "LLVMBuildShl");
pragma Import (C, BuildLShr, "LLVMBuildLShr");
pragma Import (C, BuildAShr, "LLVMBuildAShr");
pragma Import (C, BuildAnd, "LLVMBuildAnd");
pragma Import (C, BuildOr, "LLVMBuildOr");
pragma Import (C, BuildXor, "LLVMBuildXor");
pragma Import (C, BuildNeg, "LLVMBuildNeg");
pragma Import (C, BuildFNeg, "LLVMBuildFNeg");
pragma Import (C, BuildNot, "LLVMBuildNot");
-- Memory
pragma Import (C, BuildMalloc, "LLVMBuildMalloc");
pragma Import (C, BuildArrayMalloc, "LLVMBuildArrayMalloc");
pragma Import (C, BuildAlloca, "LLVMBuildAlloca");
pragma Import (C, BuildArrayAlloca, "LLVMBuildArrayAlloca");
pragma Import (C, BuildFree, "LLVMBuildFree");
pragma Import (C, BuildLoad, "LLVMBuildLoad");
pragma Import (C, BuildStore, "LLVMBuildStore");
pragma Import (C, BuildGEP, "LLVMBuildGEP");
-- Casts
pragma Import (C, BuildTrunc, "LLVMBuildTrunc");
pragma Import (C, BuildZExt, "LLVMBuildZExt");
pragma Import (C, BuildSExt, "LLVMBuildSExt");
pragma Import (C, BuildFPToUI, "LLVMBuildFPToUI");
pragma Import (C, BuildFPToSI, "LLVMBuildFPToSI");
pragma Import (C, BuildUIToFP, "LLVMBuildUIToFP");
pragma Import (C, BuildSIToFP, "LLVMBuildSIToFP");
pragma Import (C, BuildFPTrunc, "LLVMBuildFPTrunc");
pragma Import (C, BuildFPExt, "LLVMBuildFPExt");
pragma Import (C, BuildPtrToInt, "LLVMBuildPtrToInt");
pragma Import (C, BuildIntToPtr, "LLVMBuildIntToPtr");
pragma Import (C, BuildBitCast, "LLVMBuildBitCast");
-- Comparisons
pragma Import (C, BuildICmp, "LLVMBuildICmp");
pragma Import (C, BuildFCmp, "LLVMBuildFCmp");
-- Miscellaneous instructions
pragma Import (C, BuildPhi, "LLVMBuildPhi");
pragma Import (C, BuildCall, "LLVMBuildCall");
pragma Import (C, BuildSelect, "LLVMBuildSelect");
pragma Import (C, BuildVAArg, "LLVMBuildVAArg");
pragma Import (C, BuildExtractElement, "LLVMBuildExtractElement");
pragma Import (C, BuildInsertElement, "LLVMBuildInsertElement");
pragma Import (C, BuildShuffleVector, "LLVMBuildShuffleVector");
-- Memory buffers ----------------------------------------------------
pragma Import (C, CreateMemoryBufferWithContentsOfFile,
"LLVMCreateMemoryBufferWithContentsOfFile");
pragma Import (C, CreateMemoryBufferWithSTDIN,
"LLVMCreateMemoryBufferWithSTDIN");
pragma Import (C, DisposeMemoryBuffer, "LLVMDisposeMemoryBuffer");
-- Pass Managers -----------------------------------------------------
pragma Import (C, CreatePassManager, "LLVMCreatePassManager");
pragma Import (C, CreateFunctionPassManagerForModule,
"LLVMCreateFunctionPassManagerForModule");
pragma Import (C, RunPassManager, "LLVMRunPassManager");
pragma Import (C, InitializeFunctionPassManager,
"LLVMInitializeFunctionPassManager");
pragma Import (C, RunFunctionPassManager,
"LLVMRunFunctionPassManager");
pragma Import (C, FinalizeFunctionPassManager,
"LLVMFinalizeFunctionPassManager");
pragma Import (C, DisposePassManager, "LLVMDisposePassManager");
end LLVM.Core;
|