-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathllvmAPI.pas
10213 lines (9499 loc) · 456 KB
/
llvmAPI.pas
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
(*
LLVM API for Delphi
> Author: Aleksey A. Naumov [[email protected]]
> License: BSD
> Delphi API Version: 0.3c
> LLVM C API Version: 3.1 Official Release
Tested on Windows only & D2007, DXE2, FPC 2.6.
*)
unit llvmAPI;
{$IFDEF FPC}
{$IFDEF CPUX86_64}
{$DEFINE CPUX64}
{$ENDIF}
{$ENDIF}
{.$DEFINE LLVM_DEBUG} // Only for debug w/ vLogs
{.$DEFINE LLVM_TRACE} // Only for trace w/ vLogs
{.$DEFINE LLVM_DYNAMIC_LINK} // Dynamic or Static linking of llvm.dll
// Modules
{$DEFINE LLVM_API_ANALYSIS} // Analysis.h
{$DEFINE LLVM_API_BITREADER} // BitReader.h
{$DEFINE LLVM_API_BITWRITER} // BitWriter.h
{$DEFINE LLVM_API_CORE} // Core.h
{.$DEFINE LLVM_API_DISASSEMBLER} // Disassembler.h
{.$DEFINE LLVM_API_ENHANCEDDISASSEMBLY} // EnhancedDisassembly.h
{$DEFINE LLVM_API_EXECUTIONENGINE} // ExecutionEngine.h
{.$DEFINE LLVM_API_INITIALIZATION} // Initialization.h
{.$DEFINE LLVM_API_LINKTIMEOPTIMIZER} // LinkTimeOptimizer.h
{.$DEFINE LLVM_API_LTO} // lto.h
{$DEFINE LLVM_API_OBJECT} // Object.h
{$DEFINE LLVM_API_TARGET} // Target.h
{.$DEFINE LLVM_API_TARGETMACHINE} // TargetMachine.h
{.$DEFINE LLVM_API_IPO} // Transforms\IPO.h
{.$DEFINE LLVM_API_PASSMANAGERBUILDER} // Transforms\PassManagerBuilder.h
{$DEFINE LLVM_API_SCALAR} // Transforms\Scalar.h
{$DEFINE LLVM_API_VECTORIZE} // Transforms\Vectorize.h
// Options
{.$DEFINE ORIGINAL_LLVMBOOL} // Use LLVMBool = Integer
interface
uses
Windows
{$IFDEF LLVM_DEBUG}
, vLogs
{$ENDIF};
// Internals & workarounds
const
LLVMVersion = '3.1';
{$IFNDEF CPUX64}
LLVMArch = 'x86';
{$ELSE}
LLVMArch = 'x86_64';
{$ENDIF}
LLVMVersionMajor = 3;
LLVMVersionMinor = 1;
{$IFDEF MSWINDOWS}
LLVMLibraryExt = '.dll';
{$ENDIF}
LLVMLibrary = 'llvm-' + LLVMVersion + '.' + LLVMArch + LLVMLibraryExt;
type
uint64_t = UInt64;
puint64_t = ^UInt64;
uint8_t = Byte;
size_t = {$IFDEF CPUX64}UInt64{$ELSE}Cardinal{$ENDIF};
psize_t = ^size_t;
off_t = Int64; // #WARNING
{$IFNDEF ORIGINAL_LLVMBOOL}
type
LLVMBool = (
LLVMFalse = 0,
LLVMTrue = 1
);
{$ENDIF}
// Converted C API
type
//*================================================= START of Core.h =================================================*//
{$IFDEF LLVM_API_CORE}
(*
* @defgroup LLVMCCore Core
*
* This modules provide an interface to libLLVMCore, which implements
* the LLVM intermediate representation as well as other related types
* and utilities.
*
* LLVM uses a polymorphic type hierarchy which C cannot represent, therefore
* parameters must be passed as base types. Despite the declared types, most
* of the functions provided operate only on branches of the type hierarchy.
* The declared parameter names are descriptive and specify which type is
* required. Additionally, each type hierarchy is documented along with the
* functions that operate upon it. For more detail, refer to LLVM's C++ code.
* If in doubt, refer to Core.cpp, which performs paramter downcasts in the
* form unwrap<RequiredType>(Param).
*
* 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.
*
* When included into a C++ source file, also declares 'wrap' and 'unwrap'
* helpers to perform opaque reference<-->pointer conversions. These helpers
* are shorter and more tightly typed than writing the casts by hand when
* authoring bindings. In assert builds, they will do runtime type checking.
*
* @{
*)
//typedef int LLVMBool;
{$IFDEF ORIGINAL_LLVMBOOL}
LLVMBool = Integer;
{$ENDIF}
(* Opaque types. *)
(*
* The top-level container for all LLVM global data. See the LLVMContext class.
*)
//typedef struct LLVMOpaqueContext *LLVMContextRef;
LLVMOpaqueContext = packed record
end;
LLVMContextRef = ^LLVMOpaqueContext;
(*
* The top-level container for all other LLVM Intermediate Representation (IR)
* objects.
*
* @see llvm::Module
*)
//typedef struct LLVMOpaqueModule *LLVMModuleRef;
LLVMOpaqueModule = packed record
end;
LLVMModuleRef = ^LLVMOpaqueModule;
(*
* Each value in the LLVM IR has a type, an LLVMTypeRef.
*
* @see llvm::Type
*)
//typedef struct LLVMOpaqueType *LLVMTypeRef;
LLVMOpaqueType = packed record
end;
LLVMTypeRef = ^LLVMOpaqueType;
(*
* Represents an individual value in LLVM IR.
*
* This models llvm::Value.
*)
//typedef struct LLVMOpaqueValue *LLVMValueRef;
LLVMOpaqueValue = packed record
end;
LLVMValueRef = ^LLVMOpaqueValue;
(*
* Represents a basic block of instruction in LLVM IR.
*
* This models llvm::BasicBlock.
*)
//typedef struct LLVMOpaqueBasicBlock *LLVMBasicBlockRef;
LLVMOpaqueBasicBlock = packed record
end;
LLVMBasicBlockRef = ^LLVMOpaqueBasicBlock;
(*
* Represents an LLVM basic block builder.
*
* This models llvm::IRBuilder.
*)
//typedef struct LLVMOpaqueBuilder *LLVMBuilderRef;
LLVMOpaqueBuilder = packed record
end;
LLVMBuilderRef = ^LLVMOpaqueBuilder;
(*
* Interface used to provide a module to JIT or interpreter.
* This is now just a synonym for llvm::Module, but we have to keep using the
* different type to keep binary compatibility.
*)
//typedef struct LLVMOpaqueModuleProvider *LLVMModuleProviderRef;
LLVMOpaqueModuleProvider = packed record
end;
LLVMModuleProviderRef = ^LLVMOpaqueModuleProvider;
(*
* Used to provide a module to JIT or interpreter.
*
* @see llvm::MemoryBuffer
*)
//typedef struct LLVMOpaqueMemoryBuffer *LLVMMemoryBufferRef;
LLVMOpaqueMemoryBuffer = packed record
end;
LLVMMemoryBufferRef = ^LLVMOpaqueMemoryBuffer;
(* @see llvm::PassManagerBase *)
//typedef struct LLVMOpaquePassManager *LLVMPassManagerRef;
LLVMOpaquePassManager = packed record
end;
LLVMPassManagerRef = ^LLVMOpaquePassManager;
(* @see llvm::PassRegistry *)
//typedef struct LLVMOpaquePassRegistry *LLVMPassRegistryRef;
LLVMOpaquePassRegistry = packed record
end;
LLVMPassRegistryRef = ^LLVMOpaquePassRegistry;
(*
* Used to get the users and usees of a Value.
*
* @see llvm::Use *)
//typedef struct LLVMOpaqueUse *LLVMUseRef;
LLVMOpaqueUse = packed record
end;
LLVMUseRef = ^LLVMOpaqueUse;
(*
typedef enum {
LLVMZExtAttribute = 1<<0,
LLVMSExtAttribute = 1<<1,
LLVMNoReturnAttribute = 1<<2,
LLVMInRegAttribute = 1<<3,
LLVMStructRetAttribute = 1<<4,
LLVMNoUnwindAttribute = 1<<5,
LLVMNoAliasAttribute = 1<<6,
LLVMByValAttribute = 1<<7,
LLVMNestAttribute = 1<<8,
LLVMReadNoneAttribute = 1<<9,
LLVMReadOnlyAttribute = 1<<10,
LLVMNoInlineAttribute = 1<<11,
LLVMAlwaysInlineAttribute = 1<<12,
LLVMOptimizeForSizeAttribute = 1<<13,
LLVMStackProtectAttribute = 1<<14,
LLVMStackProtectReqAttribute = 1<<15,
LLVMAlignment = 31<<16,
LLVMNoCaptureAttribute = 1<<21,
LLVMNoRedZoneAttribute = 1<<22,
LLVMNoImplicitFloatAttribute = 1<<23,
LLVMNakedAttribute = 1<<24,
LLVMInlineHintAttribute = 1<<25,
LLVMStackAlignment = 7<<26,
LLVMReturnsTwice = 1 << 29,
LLVMUWTable = 1 << 30,
LLVMNonLazyBind = 1 << 31
// FIXME: This attribute is currently not included in the C API as
// a temporary measure until the API/ABI impact to the C API is understood
// and the path forward agreed upon.
//LLVMAddressSafety = 1ULL << 32
} LLVMAttribute;
*)
// #WARNING
LLVMAttribute = (
LLVMZExtAttribute = 1 shl 0,
LLVMSExtAttribute = 1 shl 1,
LLVMNoReturnAttribute = 1 shl 2,
LLVMInRegAttribute = 1 shl 3,
LLVMStructRetAttribute = 1 shl 4,
LLVMNoUnwindAttribute = 1 shl 5,
LLVMNoAliasAttribute = 1 shl 6,
LLVMByValAttribute = 1 shl 7,
LLVMNestAttribute = 1 shl 8,
LLVMReadNoneAttribute = 1 shl 9,
LLVMReadOnlyAttribute = 1 shl 10,
LLVMNoInlineAttribute = 1 shl 11,
LLVMAlwaysInlineAttribute = 1 shl 12,
LLVMOptimizeForSizeAttribute = 1 shl 13,
LLVMStackProtectAttribute = 1 shl 14,
LLVMStackProtectReqAttribute = 1 shl 15,
LLVMAlignment = 31 shl 16,
LLVMNoCaptureAttribute = 1 shl 21,
LLVMNoRedZoneAttribute = 1 shl 22,
LLVMNoImplicitFloatAttribute = 1 shl 23,
LLVMNakedAttribute = 1 shl 24,
LLVMInlineHintAttribute = 1 shl 25,
LLVMStackAlignment = 7 shl 26,
LLVMReturnsTwice = 1 shl 29,
LLVMUWTable = 1 shl 30,
LLVMNonLazyBind = 1 shl 31
// FIXME: This attribute is currently not included in the C API as
// a temporary measure until the API/ABI impact to the C API is understood
// and the path forward agreed upon.
//LLVMAddressSafety = 1ULL shl 32
);
(*
typedef enum {
// Terminator Instructions
LLVMRet = 1,
LLVMBr = 2,
LLVMSwitch = 3,
LLVMIndirectBr = 4,
LLVMInvoke = 5,
// removed 6 due to API changes
LLVMUnreachable = 7,
// 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,
// 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,
// Atomic operators
LLVMFence = 55,
LLVMAtomicCmpXchg = 56,
LLVMAtomicRMW = 57,
// Exception Handling Operators
LLVMResume = 58,
LLVMLandingPad = 59
} LLVMOpcode;
*)
LLVMOpcode = (
// Terminator Instructions
LLVMRet = 1,
LLVMBr = 2,
LLVMSwitch = 3,
LLVMIndirectBr = 4,
LLVMInvoke = 5,
// removed 6 due to API changes
LLVMUnreachable = 7,
// 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,
// 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,
// Atomic operators
LLVMFence = 55,
LLVMAtomicCmpXchg = 56,
LLVMAtomicRMW = 57,
// Exception Handling Operators
LLVMResume = 58,
LLVMLandingPad = 59
);
(*
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
} LLVMTypeKind;
*)
LLVMTypeKind = (
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
);
(*
typedef enum {
LLVMExternalLinkage, // Externally visible function
LLVMAvailableExternallyLinkage,
LLVMLinkOnceAnyLinkage, // Keep one copy of function when linking (inline)
LLVMLinkOnceODRLinkage, // Same, but only replaced by something
equivalent.
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, // Function to be imported from DLL
LLVMDLLExportLinkage, // Function to be accessible from DLL
LLVMExternalWeakLinkage,// ExternalWeak linkage description
LLVMGhostLinkage, // Obsolete
LLVMCommonLinkage, // Tentative definitions
LLVMLinkerPrivateLinkage, // Like Private, but linker removes.
LLVMLinkerPrivateWeakLinkage, // Like LinkerPrivate, but is weak.
LLVMLinkerPrivateWeakDefAutoLinkage // Like LinkerPrivateWeak, but possibly
hidden.
} LLVMLinkage;
*)
LLVMLinkage = (
LLVMExternalLinkage, // Externally visible function
LLVMAvailableExternallyLinkage,
LLVMLinkOnceAnyLinkage, // Keep one copy of function when linking (inline)
LLVMLinkOnceODRLinkage, // Same, but only replaced by something equivalent.
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, // Function to be imported from DLL
LLVMDLLExportLinkage, // Function to be accessible from DLL
LLVMExternalWeakLinkage,// ExternalWeak linkage description
LLVMGhostLinkage, // Obsolete
LLVMCommonLinkage, // Tentative definitions
LLVMLinkerPrivateLinkage, // Like Private, but linker removes.
LLVMLinkerPrivateWeakLinkage, // Like LinkerPrivate, but is weak.
LLVMLinkerPrivateWeakDefAutoLinkage // Like LinkerPrivateWeak, but possibly hidden.
);
(*
typedef enum {
LLVMDefaultVisibility, // The GV is visible
LLVMHiddenVisibility, // The GV is hidden
LLVMProtectedVisibility // The GV is protected
} LLVMVisibility;
*)
LLVMVisibility = (
LLVMDefaultVisibility, // The GV is visible
LLVMHiddenVisibility, // The GV is hidden
LLVMProtectedVisibility // The GV is protected
);
(*
typedef enum {
LLVMCCallConv = 0,
LLVMFastCallConv = 8,
LLVMColdCallConv = 9,
LLVMX86StdcallCallConv = 64,
LLVMX86FastcallCallConv = 65
} LLVMCallConv;
*)
LLVMCallConv = (
LLVMCCallConv = 0,
LLVMFastCallConv = 8,
LLVMColdCallConv = 9,
LLVMX86StdcallCallConv = 64,
LLVMX86FastcallCallConv = 65
);
(*
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;
*)
LLVMIntPredicate = (
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
);
(*
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;
*)
LLVMRealPredicate = (
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)
);
(*
typedef enum {
LLVMLandingPadCatch, // A catch clause
LLVMLandingPadFilter // A filter clause
} LLVMLandingPadClauseTy;
*)
LLVMLandingPadClauseTy = (
LLVMLandingPadCatch, // A catch clause
LLVMLandingPadFilter // A filter clause
);
(*
* @}
*)
//void LLVMInitializeCore(LLVMPassRegistryRef R);
{$IFDEF LLVM_DYNAMIC_LINK}
TLLVMInitializeCore = procedure(R: LLVMPassRegistryRef); cdecl;
{$ELSE}
procedure LLVMInitializeCore(R: LLVMPassRegistryRef); cdecl; external LLVMLibrary name 'LLVMInitializeCore';
{$ENDIF}
(*===-- Error handling ----------------------------------------------------===*)
//void LLVMDisposeMessage(char *Message);
{$IFDEF LLVM_DYNAMIC_LINK}
TLLVMDisposeMessage = procedure(_Message: PAnsiChar); cdecl;
{$ELSE}
procedure LLVMDisposeMessage(_Message: PAnsiChar); cdecl; external LLVMLibrary name 'LLVMDisposeMessage';
{$ENDIF}
(*
* @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.
*
* @{
*)
(*
* 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);
{$IFDEF LLVM_DYNAMIC_LINK}
TLLVMContextCreate = function(): LLVMContextRef; cdecl;
{$ELSE}
function LLVMContextCreate(): LLVMContextRef; cdecl; external LLVMLibrary name 'LLVMContextCreate';
{$ENDIF}
(*
* Obtain the global context instance.
*)
//LLVMContextRef LLVMGetGlobalContext(void);
{$IFDEF LLVM_DYNAMIC_LINK}
TLLVMGetGlobalContext = function(): LLVMContextRef; cdecl;
{$ELSE}
function LLVMGetGlobalContext(): LLVMContextRef; cdecl; external LLVMLibrary name 'LLVMGetGlobalContext';
{$ENDIF}
(*
* Destroy a context instance.
*
* This should be called for every call to LLVMContextCreate() or memory
* will be leaked.
*)
//void LLVMContextDispose(LLVMContextRef C);
{$IFDEF LLVM_DYNAMIC_LINK}
TLLVMContextDispose = procedure(C: LLVMContextRef); cdecl;
{$ELSE}
procedure LLVMContextDispose(C: LLVMContextRef); cdecl; external LLVMLibrary name 'LLVMContextDispose';
{$ENDIF}
//unsigned LLVMGetMDKindIDInContext(LLVMContextRef C, const char* Name, unsigned SLen);
{$IFDEF LLVM_DYNAMIC_LINK}
TLLVMGetMDKindIDInContext = function(C: LLVMContextRef; Name: PAnsiChar; SLen: Cardinal): Cardinal; cdecl;
{$ELSE}
function LLVMGetMDKindIDInContext(C: LLVMContextRef; Name: PAnsiChar; SLen: Cardinal): Cardinal; cdecl; external LLVMLibrary name 'LLVMGetMDKindIDInContext';
{$ENDIF}
//unsigned LLVMGetMDKindID(const char* Name, unsigned SLen);
{$IFDEF LLVM_DYNAMIC_LINK}
TLLVMGetMDKindID = function(Name: PAnsiChar; SLen: Cardinal): Cardinal; cdecl;
{$ELSE}
function LLVMGetMDKindID(Name: PAnsiChar; SLen: Cardinal): Cardinal; cdecl; external LLVMLibrary name 'LLVMGetMDKindID';
{$ENDIF}
(*
* @}
*)
(*
* @defgroup LLVMCCoreModule Modules
*
* Modules represent the top-level structure in a 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);
{$IFDEF LLVM_DYNAMIC_LINK}
TLLVMModuleCreateWithName = function(ModuleID: PAnsiChar): LLVMModuleRef; cdecl;
{$ELSE}
function LLVMModuleCreateWithName(ModuleID: PAnsiChar): LLVMModuleRef; cdecl; external LLVMLibrary name 'LLVMModuleCreateWithName';
{$ENDIF}
(*
* 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);
{$IFDEF LLVM_DYNAMIC_LINK}
TLLVMModuleCreateWithNameInContext = function(ModuleID: PAnsiChar; C: LLVMContextRef): LLVMModuleRef; cdecl;
{$ELSE}
function LLVMModuleCreateWithNameInContext(ModuleID: PAnsiChar; C: LLVMContextRef): LLVMModuleRef; cdecl; external LLVMLibrary name 'LLVMModuleCreateWithNameInContext';
{$ENDIF}
(*
* Destroy a module instance.
*
* This must be called for every created module or memory will be
* leaked.
*)
//void LLVMDisposeModule(LLVMModuleRef M);
{$IFDEF LLVM_DYNAMIC_LINK}
TLLVMDisposeModule = procedure(M: LLVMModuleRef); cdecl;
{$ELSE}
procedure LLVMDisposeModule(M: LLVMModuleRef); cdecl; external LLVMLibrary name 'LLVMDisposeModule';
{$ENDIF}
(*
* Obtain the data layout for a module.
*
* @see Module::getDataLayout()
*)
//const char *LLVMGetDataLayout(LLVMModuleRef M);
{$IFDEF LLVM_DYNAMIC_LINK}
TLLVMGetDataLayout = function(M: LLVMModuleRef): PAnsiChar; cdecl;
{$ELSE}
function LLVMGetDataLayout(M: LLVMModuleRef): PAnsiChar; cdecl; external LLVMLibrary name 'LLVMGetDataLayout';
{$ENDIF}
(*
* Set the data layout for a module.
*
* @see Module::setDataLayout()
*)
//void LLVMSetDataLayout(LLVMModuleRef M, const char *Triple);
{$IFDEF LLVM_DYNAMIC_LINK}
TLLVMSetDataLayout = procedure(M: LLVMModuleRef; Triple: PAnsiChar); cdecl;
{$ELSE}
procedure LLVMSetDataLayout(M: LLVMModuleRef; Triple: PAnsiChar); cdecl; external LLVMLibrary name 'LLVMSetDataLayout';
{$ENDIF}
(*
* Obtain the target triple for a module.
*
* @see Module::getTargetTriple()
*)
//const char *LLVMGetTarget(LLVMModuleRef M);
{$IFDEF LLVM_DYNAMIC_LINK}
TLLVMGetTarget = function(M: LLVMModuleRef): PAnsiChar; cdecl;
{$ELSE}
function LLVMGetTarget(M: LLVMModuleRef): PAnsiChar; cdecl; external LLVMLibrary name 'LLVMGetTarget';
{$ENDIF}
(*
* Set the target triple for a module.
*
* @see Module::setTargetTriple()
*)
//void LLVMSetTarget(LLVMModuleRef M, const char *Triple);
{$IFDEF LLVM_DYNAMIC_LINK}
TLLVMSetTarget = procedure(M: LLVMModuleRef; Triple: PAnsiChar); cdecl;
{$ELSE}
procedure LLVMSetTarget(M: LLVMModuleRef; Triple: PAnsiChar); cdecl; external LLVMLibrary name 'LLVMSetTarget';
{$ENDIF}
(*
* Dump a representation of a module to stderr.
*
* @see Module::dump()
*)
//void LLVMDumpModule(LLVMModuleRef M);
{$IFDEF LLVM_DYNAMIC_LINK}
TLLVMDumpModule = procedure(M: LLVMModuleRef); cdecl;
{$ELSE}
procedure LLVMDumpModule(M: LLVMModuleRef); cdecl; external LLVMLibrary name 'LLVMDumpModule';
{$ENDIF}
(*
* Set inline assembly for a module.
*
* @see Module::setModuleInlineAsm()
*)
//void LLVMSetModuleInlineAsm(LLVMModuleRef M, const char *Asm);
{$IFDEF LLVM_DYNAMIC_LINK}
TLLVMSetModuleInlineAsm = procedure(M: LLVMModuleRef; _Asm: PAnsiChar); cdecl;
{$ELSE}
procedure LLVMSetModuleInlineAsm(M: LLVMModuleRef; _Asm: PAnsiChar); cdecl; external LLVMLibrary name 'LLVMSetModuleInlineAsm';
{$ENDIF}
(*
* Obtain the context to which this module is associated.
*
* @see Module::getContext()
*)
//LLVMContextRef LLVMGetModuleContext(LLVMModuleRef M);
{$IFDEF LLVM_DYNAMIC_LINK}
TLLVMGetModuleContext = function(M: LLVMModuleRef): LLVMContextRef; cdecl;
{$ELSE}
function LLVMGetModuleContext(M: LLVMModuleRef): LLVMContextRef; cdecl; external LLVMLibrary name 'LLVMGetModuleContext';
{$ENDIF}
(*
* Obtain a Type from a module by its registered name.
*)
//LLVMTypeRef LLVMGetTypeByName(LLVMModuleRef M, const char *Name);
{$IFDEF LLVM_DYNAMIC_LINK}
TLLVMGetTypeByName = function(M: LLVMModuleRef; Name: PAnsiChar): LLVMTypeRef; cdecl;
{$ELSE}
function LLVMGetTypeByName(M: LLVMModuleRef; Name: PAnsiChar): LLVMTypeRef; cdecl; external LLVMLibrary name 'LLVMGetTypeByName';
{$ENDIF}
(*
* Obtain the number of operands for named metadata in a module.
*
* @see llvm::Module::getNamedMetadata()
*)
//unsigned LLVMGetNamedMetadataNumOperands(LLVMModuleRef M, const char* name);
{$IFDEF LLVM_DYNAMIC_LINK}
TLLVMGetNamedMetadataNumOperands = function(M: LLVMModuleRef; Name: PAnsiChar): Cardinal; cdecl;
{$ELSE}
function LLVMGetNamedMetadataNumOperands(M: LLVMModuleRef; Name: PAnsiChar): Cardinal; cdecl; external LLVMLibrary name 'LLVMGetNamedMetadataNumOperands';
{$ENDIF}
(*
* 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);
{$IFDEF LLVM_DYNAMIC_LINK}
TLLVMGetNamedMetadataOperands = procedure(M: LLVMModuleRef; Name: PAnsiChar; var Dest: LLVMValueRef); cdecl;
{$ELSE}
procedure LLVMGetNamedMetadataOperands(M: LLVMModuleRef; Name: PAnsiChar; var Dest: LLVMValueRef); cdecl; external LLVMLibrary name 'LLVMGetNamedMetadataOperands';
{$ENDIF}
(*
* Add an operand to named metadata.
*
* @see llvm::Module::getNamedMetadata()
* @see llvm::MDNode::addOperand()
*)
//void LLVMAddNamedMetadataOperand(LLVMModuleRef M, const char* name,
// LLVMValueRef Val);
{$IFDEF LLVM_DYNAMIC_LINK}
TLLVMAddNamedMetadataOperand = procedure(M: LLVMModuleRef; Name: PAnsiChar; Val: LLVMValueRef); cdecl;
{$ELSE}
procedure LLVMAddNamedMetadataOperand(M: LLVMModuleRef; Name: PAnsiChar; Val: LLVMValueRef); cdecl; external LLVMLibrary name 'LLVMAddNamedMetadataOperand';
{$ENDIF}
(*
* Add a function to a module under a specified name.
*
* @see llvm::Function::Create()
*)
//LLVMValueRef LLVMAddFunction(LLVMModuleRef M, const char *Name, LLVMTypeRef FunctionTy);
{$IFDEF LLVM_DYNAMIC_LINK}
TLLVMAddFunction = function(M: LLVMModuleRef; Name: PAnsiChar; FunctionTy: LLVMTypeRef): LLVMValueRef; cdecl;
{$ELSE}
function LLVMAddFunction(M: LLVMModuleRef; Name: PAnsiChar; FunctionTy: LLVMTypeRef): LLVMValueRef; cdecl; external LLVMLibrary name 'LLVMAddFunction';
{$ENDIF}
(*
* 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);
{$IFDEF LLVM_DYNAMIC_LINK}
TLLVMGetNamedFunction = function(M: LLVMModuleRef; Name: PAnsiChar): LLVMValueRef; cdecl;
{$ELSE}
function LLVMGetNamedFunction(M: LLVMModuleRef; Name: PAnsiChar): LLVMValueRef; cdecl; external LLVMLibrary name 'LLVMGetNamedFunction';
{$ENDIF}
(*
* Obtain an iterator to the first Function in a Module.
*
* @see llvm::Module::begin()
*)
//LLVMValueRef LLVMGetFirstFunction(LLVMModuleRef M);
{$IFDEF LLVM_DYNAMIC_LINK}
TLLVMGetFirstFunction = function(M: LLVMModuleRef): LLVMValueRef; cdecl;
{$ELSE}
function LLVMGetFirstFunction(M: LLVMModuleRef): LLVMValueRef; cdecl; external LLVMLibrary name 'LLVMGetFirstFunction';
{$ENDIF}
(*
* Obtain an iterator to the last Function in a Module.
*
* @see llvm::Module::end()
*)
//LLVMValueRef LLVMGetLastFunction(LLVMModuleRef M);
{$IFDEF LLVM_DYNAMIC_LINK}
TLLVMGetLastFunction = function(M: LLVMModuleRef): LLVMValueRef; cdecl;
{$ELSE}
function LLVMGetLastFunction(M: LLVMModuleRef): LLVMValueRef; cdecl; external LLVMLibrary name 'LLVMGetLastFunction';
{$ENDIF}
(*
* 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);
{$IFDEF LLVM_DYNAMIC_LINK}
TLLVMGetNextFunction = function(Fn: LLVMValueRef): LLVMValueRef; cdecl;
{$ELSE}
function LLVMGetNextFunction(Fn: LLVMValueRef): LLVMValueRef; cdecl; external LLVMLibrary name 'LLVMGetNextFunction';
{$ENDIF}
(*
* 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);
{$IFDEF LLVM_DYNAMIC_LINK}
TLLVMGetPreviousFunction = function(Fn: LLVMValueRef): LLVMValueRef; cdecl;
{$ELSE}
function LLVMGetPreviousFunction(Fn: LLVMValueRef): LLVMValueRef; cdecl; external LLVMLibrary name 'LLVMGetPreviousFunction';
{$ENDIF}
(*
* @}
*)
(*
* @defgroup LLVMCCoreType Types