forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathllvm.rs
More file actions
2407 lines (2214 loc) · 92.3 KB
/
Copy pathllvm.rs
File metadata and controls
2407 lines (2214 loc) · 92.3 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
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use std::hashmap::HashMap;
use std::libc::{c_uint, c_ushort};
use std::option;
use std::str;
use middle::trans::type_::Type;
pub type Opcode = u32;
pub type Bool = c_uint;
pub static True: Bool = 1 as Bool;
pub static False: Bool = 0 as Bool;
// Consts for the LLVM CallConv type, pre-cast to uint.
pub enum CallConv {
CCallConv = 0,
FastCallConv = 8,
ColdCallConv = 9,
X86StdcallCallConv = 64,
X86FastcallCallConv = 65,
}
pub enum Visibility {
LLVMDefaultVisibility = 0,
HiddenVisibility = 1,
ProtectedVisibility = 2,
}
pub enum Linkage {
ExternalLinkage = 0,
AvailableExternallyLinkage = 1,
LinkOnceAnyLinkage = 2,
LinkOnceODRLinkage = 3,
LinkOnceODRAutoHideLinkage = 4,
WeakAnyLinkage = 5,
WeakODRLinkage = 6,
AppendingLinkage = 7,
InternalLinkage = 8,
PrivateLinkage = 9,
DLLImportLinkage = 10,
DLLExportLinkage = 11,
ExternalWeakLinkage = 12,
GhostLinkage = 13,
CommonLinkage = 14,
LinkerPrivateLinkage = 15,
LinkerPrivateWeakLinkage = 16,
}
#[deriving(Clone)]
pub enum Attribute {
ZExtAttribute = 1,
SExtAttribute = 2,
NoReturnAttribute = 4,
InRegAttribute = 8,
StructRetAttribute = 16,
NoUnwindAttribute = 32,
NoAliasAttribute = 64,
ByValAttribute = 128,
NestAttribute = 256,
ReadNoneAttribute = 512,
ReadOnlyAttribute = 1024,
NoInlineAttribute = 2048,
AlwaysInlineAttribute = 4096,
OptimizeForSizeAttribute = 8192,
StackProtectAttribute = 16384,
StackProtectReqAttribute = 32768,
// 31 << 16
AlignmentAttribute = 2031616,
NoCaptureAttribute = 2097152,
NoRedZoneAttribute = 4194304,
NoImplicitFloatAttribute = 8388608,
NakedAttribute = 16777216,
InlineHintAttribute = 33554432,
// 7 << 26
StackAttribute = 469762048,
ReturnsTwiceAttribute = 536870912,
// 1 << 30
UWTableAttribute = 1073741824,
NonLazyBindAttribute = 2147483648,
}
// enum for the LLVM IntPredicate type
pub enum IntPredicate {
IntEQ = 32,
IntNE = 33,
IntUGT = 34,
IntUGE = 35,
IntULT = 36,
IntULE = 37,
IntSGT = 38,
IntSGE = 39,
IntSLT = 40,
IntSLE = 41,
}
// enum for the LLVM RealPredicate type
pub enum RealPredicate {
RealPredicateFalse = 0,
RealOEQ = 1,
RealOGT = 2,
RealOGE = 3,
RealOLT = 4,
RealOLE = 5,
RealONE = 6,
RealORD = 7,
RealUNO = 8,
RealUEQ = 9,
RealUGT = 10,
RealUGE = 11,
RealULT = 12,
RealULE = 13,
RealUNE = 14,
RealPredicateTrue = 15,
}
// The LLVM TypeKind type - must stay in sync with the def of
// LLVMTypeKind in llvm/include/llvm-c/Core.h
pub type TypeKind = u32;
pub static Void: TypeKind = 0;
pub static Half: TypeKind = 1;
pub static Float: TypeKind = 2;
pub static Double: TypeKind = 3;
pub static X86_FP80: TypeKind = 4;
pub static FP128: TypeKind = 5;
pub static PPC_FP128: TypeKind = 6;
pub static Label: TypeKind = 7;
pub static Integer: TypeKind = 8;
pub static Function: TypeKind = 9;
pub static Struct: TypeKind = 10;
pub static Array: TypeKind = 11;
pub static Pointer: TypeKind = 12;
pub static Vector: TypeKind = 13;
pub static Metadata: TypeKind = 14;
pub static X86_MMX: TypeKind = 15;
pub enum AtomicBinOp {
Xchg = 0,
Add = 1,
Sub = 2,
And = 3,
Nand = 4,
Or = 5,
Xor = 6,
Max = 7,
Min = 8,
UMax = 9,
UMin = 10,
}
pub enum AtomicOrdering {
NotAtomic = 0,
Unordered = 1,
Monotonic = 2,
// Consume = 3, // Not specified yet.
Acquire = 4,
Release = 5,
AcquireRelease = 6,
SequentiallyConsistent = 7
}
// FIXME: Not used right now, but will be once #2334 is fixed
// Consts for the LLVMCodeGenFileType type (in include/llvm/c/TargetMachine.h)
pub enum FileType {
AssemblyFile = 0,
ObjectFile = 1
}
pub enum Metadata {
MD_dbg = 0,
MD_tbaa = 1,
MD_prof = 2,
MD_fpmath = 3,
MD_range = 4,
MD_tbaa_struct = 5
}
// Inline Asm Dialect
pub enum AsmDialect {
AD_ATT = 0,
AD_Intel = 1
}
// Opaque pointer types
pub enum Module_opaque {}
pub type ModuleRef = *'static Module_opaque;
pub enum Context_opaque {}
pub type ContextRef = *'static Context_opaque;
pub enum Type_opaque {}
pub type TypeRef = *'static Type_opaque;
pub enum Value_opaque {}
pub type ValueRef = *'static Value_opaque;
pub enum BasicBlock_opaque {}
pub type BasicBlockRef = *'static BasicBlock_opaque;
pub enum Builder_opaque {}
pub type BuilderRef = *'static Builder_opaque;
pub enum ExecutionEngine_opaque {}
pub type ExecutionEngineRef = *'static ExecutionEngine_opaque;
pub enum MemoryBuffer_opaque {}
pub type MemoryBufferRef = *'static MemoryBuffer_opaque;
pub enum PassManager_opaque {}
pub type PassManagerRef = *'static PassManager_opaque;
pub enum PassManagerBuilder_opaque {}
pub type PassManagerBuilderRef = *'static PassManagerBuilder_opaque;
pub enum Use_opaque {}
pub type UseRef = *'static Use_opaque;
pub enum TargetData_opaque {}
pub type TargetDataRef = *'static TargetData_opaque;
pub enum ObjectFile_opaque {}
pub type ObjectFileRef = *'static ObjectFile_opaque;
pub enum SectionIterator_opaque {}
pub type SectionIteratorRef = *'static SectionIterator_opaque;
pub enum Pass_opaque {}
pub type PassRef = *'static Pass_opaque;
pub mod debuginfo {
use super::{ValueRef};
pub enum DIBuilder_opaque {}
pub type DIBuilderRef = *'static DIBuilder_opaque;
pub type DIDescriptor = ValueRef;
pub type DIScope = DIDescriptor;
pub type DILocation = DIDescriptor;
pub type DIFile = DIScope;
pub type DILexicalBlock = DIScope;
pub type DISubprogram = DIScope;
pub type DIType = DIDescriptor;
pub type DIBasicType = DIType;
pub type DIDerivedType = DIType;
pub type DICompositeType = DIDerivedType;
pub type DIVariable = DIDescriptor;
pub type DIArray = DIDescriptor;
pub type DISubrange = DIDescriptor;
pub enum DIDescriptorFlags {
FlagPrivate = 1 << 0,
FlagProtected = 1 << 1,
FlagFwdDecl = 1 << 2,
FlagAppleBlock = 1 << 3,
FlagBlockByrefStruct = 1 << 4,
FlagVirtual = 1 << 5,
FlagArtificial = 1 << 6,
FlagExplicit = 1 << 7,
FlagPrototyped = 1 << 8,
FlagObjcClassComplete = 1 << 9,
FlagObjectPointer = 1 << 10,
FlagVector = 1 << 11,
FlagStaticMember = 1 << 12
}
}
pub mod llvm {
use super::{AtomicBinOp, AtomicOrdering, BasicBlockRef, ExecutionEngineRef};
use super::{Bool, BuilderRef, ContextRef, MemoryBufferRef, ModuleRef};
use super::{ObjectFileRef, Opcode, PassManagerRef, PassManagerBuilderRef};
use super::{SectionIteratorRef, TargetDataRef, TypeKind, TypeRef, UseRef};
use super::{ValueRef, PassRef};
use super::debuginfo::*;
use std::libc::{c_char, c_int, c_longlong, c_ushort, c_uint, c_ulonglong};
#[link_args = "-Lrustllvm -lrustllvm"]
#[link_name = "rustllvm"]
#[abi = "cdecl"]
extern {
/* Create and destroy contexts. */
#[fast_ffi]
pub unsafe fn LLVMContextCreate() -> ContextRef;
#[fast_ffi]
pub unsafe fn LLVMContextDispose(C: ContextRef);
#[fast_ffi]
pub unsafe fn LLVMGetMDKindIDInContext(C: ContextRef,
Name: *c_char,
SLen: c_uint)
-> c_uint;
/* Create and destroy modules. */
#[fast_ffi]
pub unsafe fn LLVMModuleCreateWithNameInContext(ModuleID: *c_char,
C: ContextRef)
-> ModuleRef;
#[fast_ffi]
pub unsafe fn LLVMGetModuleContext(M: ModuleRef) -> ContextRef;
#[fast_ffi]
pub unsafe fn LLVMDisposeModule(M: ModuleRef);
/** Data layout. See Module::getDataLayout. */
#[fast_ffi]
pub unsafe fn LLVMGetDataLayout(M: ModuleRef) -> *c_char;
#[fast_ffi]
pub unsafe fn LLVMSetDataLayout(M: ModuleRef, Triple: *c_char);
/** Target triple. See Module::getTargetTriple. */
#[fast_ffi]
pub unsafe fn LLVMGetTarget(M: ModuleRef) -> *c_char;
#[fast_ffi]
pub unsafe fn LLVMSetTarget(M: ModuleRef, Triple: *c_char);
/** See Module::dump. */
#[fast_ffi]
pub unsafe fn LLVMDumpModule(M: ModuleRef);
/** See Module::setModuleInlineAsm. */
#[fast_ffi]
pub unsafe fn LLVMSetModuleInlineAsm(M: ModuleRef, Asm: *c_char);
/** See llvm::LLVMTypeKind::getTypeID. */
pub unsafe fn LLVMGetTypeKind(Ty: TypeRef) -> TypeKind;
/** See llvm::LLVMType::getContext. */
#[fast_ffi]
pub unsafe fn LLVMGetTypeContext(Ty: TypeRef) -> ContextRef;
/* Operations on integer types */
#[fast_ffi]
pub unsafe fn LLVMInt1TypeInContext(C: ContextRef) -> TypeRef;
#[fast_ffi]
pub unsafe fn LLVMInt8TypeInContext(C: ContextRef) -> TypeRef;
#[fast_ffi]
pub unsafe fn LLVMInt16TypeInContext(C: ContextRef) -> TypeRef;
#[fast_ffi]
pub unsafe fn LLVMInt32TypeInContext(C: ContextRef) -> TypeRef;
#[fast_ffi]
pub unsafe fn LLVMInt64TypeInContext(C: ContextRef) -> TypeRef;
#[fast_ffi]
pub unsafe fn LLVMIntTypeInContext(C: ContextRef,
NumBits: c_uint) -> TypeRef;
#[fast_ffi]
pub unsafe fn LLVMGetIntTypeWidth(IntegerTy: TypeRef) -> c_uint;
/* Operations on real types */
#[fast_ffi]
pub unsafe fn LLVMFloatTypeInContext(C: ContextRef) -> TypeRef;
#[fast_ffi]
pub unsafe fn LLVMDoubleTypeInContext(C: ContextRef) -> TypeRef;
#[fast_ffi]
pub unsafe fn LLVMX86FP80TypeInContext(C: ContextRef) -> TypeRef;
#[fast_ffi]
pub unsafe fn LLVMFP128TypeInContext(C: ContextRef) -> TypeRef;
#[fast_ffi]
pub unsafe fn LLVMPPCFP128TypeInContext(C: ContextRef) -> TypeRef;
/* Operations on function types */
#[fast_ffi]
pub unsafe fn LLVMFunctionType(ReturnType: TypeRef,
ParamTypes: *TypeRef,
ParamCount: c_uint,
IsVarArg: Bool)
-> TypeRef;
#[fast_ffi]
pub unsafe fn LLVMIsFunctionVarArg(FunctionTy: TypeRef) -> Bool;
#[fast_ffi]
pub unsafe fn LLVMGetReturnType(FunctionTy: TypeRef) -> TypeRef;
#[fast_ffi]
pub unsafe fn LLVMCountParamTypes(FunctionTy: TypeRef) -> c_uint;
#[fast_ffi]
pub unsafe fn LLVMGetParamTypes(FunctionTy: TypeRef, Dest: *TypeRef);
/* Operations on struct types */
#[fast_ffi]
pub unsafe fn LLVMStructTypeInContext(C: ContextRef,
ElementTypes: *TypeRef,
ElementCount: c_uint,
Packed: Bool) -> TypeRef;
#[fast_ffi]
pub unsafe fn LLVMCountStructElementTypes(StructTy: TypeRef)
-> c_uint;
#[fast_ffi]
pub unsafe fn LLVMGetStructElementTypes(StructTy: TypeRef,
Dest: *mut TypeRef);
#[fast_ffi]
pub unsafe fn LLVMIsPackedStruct(StructTy: TypeRef) -> Bool;
/* Operations on array, pointer, and vector types (sequence types) */
#[fast_ffi]
pub unsafe fn LLVMArrayType(ElementType: TypeRef,
ElementCount: c_uint) -> TypeRef;
#[fast_ffi]
pub unsafe fn LLVMPointerType(ElementType: TypeRef,
AddressSpace: c_uint) -> TypeRef;
#[fast_ffi]
pub unsafe fn LLVMVectorType(ElementType: TypeRef,
ElementCount: c_uint) -> TypeRef;
#[fast_ffi]
pub unsafe fn LLVMGetElementType(Ty: TypeRef) -> TypeRef;
#[fast_ffi]
pub unsafe fn LLVMGetArrayLength(ArrayTy: TypeRef) -> c_uint;
#[fast_ffi]
pub unsafe fn LLVMGetPointerAddressSpace(PointerTy: TypeRef)
-> c_uint;
#[fast_ffi]
pub unsafe fn LLVMGetPointerToGlobal(EE: ExecutionEngineRef,
V: ValueRef)
-> *();
#[fast_ffi]
pub unsafe fn LLVMGetVectorSize(VectorTy: TypeRef) -> c_uint;
/* Operations on other types */
#[fast_ffi]
pub unsafe fn LLVMVoidTypeInContext(C: ContextRef) -> TypeRef;
#[fast_ffi]
pub unsafe fn LLVMLabelTypeInContext(C: ContextRef) -> TypeRef;
#[fast_ffi]
pub unsafe fn LLVMMetadataTypeInContext(C: ContextRef) -> TypeRef;
/* Operations on all values */
#[fast_ffi]
pub unsafe fn LLVMTypeOf(Val: ValueRef) -> TypeRef;
#[fast_ffi]
pub unsafe fn LLVMGetValueName(Val: ValueRef) -> *c_char;
#[fast_ffi]
pub unsafe fn LLVMSetValueName(Val: ValueRef, Name: *c_char);
#[fast_ffi]
pub unsafe fn LLVMDumpValue(Val: ValueRef);
#[fast_ffi]
pub unsafe fn LLVMReplaceAllUsesWith(OldVal: ValueRef,
NewVal: ValueRef);
#[fast_ffi]
pub unsafe fn LLVMHasMetadata(Val: ValueRef) -> c_int;
#[fast_ffi]
pub unsafe fn LLVMGetMetadata(Val: ValueRef, KindID: c_uint)
-> ValueRef;
#[fast_ffi]
pub unsafe fn LLVMSetMetadata(Val: ValueRef,
KindID: c_uint,
Node: ValueRef);
/* Operations on Uses */
#[fast_ffi]
pub unsafe fn LLVMGetFirstUse(Val: ValueRef) -> UseRef;
#[fast_ffi]
pub unsafe fn LLVMGetNextUse(U: UseRef) -> UseRef;
#[fast_ffi]
pub unsafe fn LLVMGetUser(U: UseRef) -> ValueRef;
#[fast_ffi]
pub unsafe fn LLVMGetUsedValue(U: UseRef) -> ValueRef;
/* Operations on Users */
#[fast_ffi]
pub unsafe fn LLVMGetNumOperands(Val: ValueRef) -> c_int;
#[fast_ffi]
pub unsafe fn LLVMGetOperand(Val: ValueRef, Index: c_uint)
-> ValueRef;
#[fast_ffi]
pub unsafe fn LLVMSetOperand(Val: ValueRef,
Index: c_uint,
Op: ValueRef);
/* Operations on constants of any type */
#[fast_ffi]
pub unsafe fn LLVMConstNull(Ty: TypeRef) -> ValueRef;
/* all zeroes */
#[fast_ffi]
pub unsafe fn LLVMConstAllOnes(Ty: TypeRef) -> ValueRef;
#[fast_ffi]
pub unsafe fn LLVMConstICmp(Pred: c_ushort, V1: ValueRef, V2: ValueRef) -> ValueRef;
#[fast_ffi]
pub unsafe fn LLVMConstFCmp(Pred: c_ushort, V1: ValueRef, V2: ValueRef) -> ValueRef;
/* only for int/vector */
#[fast_ffi]
pub unsafe fn LLVMGetUndef(Ty: TypeRef) -> ValueRef;
#[fast_ffi]
pub unsafe fn LLVMIsConstant(Val: ValueRef) -> Bool;
#[fast_ffi]
pub unsafe fn LLVMIsNull(Val: ValueRef) -> Bool;
#[fast_ffi]
pub unsafe fn LLVMIsUndef(Val: ValueRef) -> Bool;
#[fast_ffi]
pub unsafe fn LLVMConstPointerNull(Ty: TypeRef) -> ValueRef;
/* Operations on metadata */
#[fast_ffi]
pub unsafe fn LLVMMDStringInContext(C: ContextRef,
Str: *c_char,
SLen: c_uint)
-> ValueRef;
#[fast_ffi]
pub unsafe fn LLVMMDNodeInContext(C: ContextRef,
Vals: *ValueRef,
Count: c_uint)
-> ValueRef;
#[fast_ffi]
pub unsafe fn LLVMAddNamedMetadataOperand(M: ModuleRef, Str: *c_char,
Val: ValueRef);
/* Operations on scalar constants */
#[fast_ffi]
pub unsafe fn LLVMConstInt(IntTy: TypeRef,
N: c_ulonglong,
SignExtend: Bool)
-> ValueRef;
#[fast_ffi]
pub unsafe fn LLVMConstIntOfString(IntTy: TypeRef,
Text: *c_char,
Radix: u8)
-> ValueRef;
#[fast_ffi]
pub unsafe fn LLVMConstIntOfStringAndSize(IntTy: TypeRef,
Text: *c_char,
SLen: c_uint,
Radix: u8)
-> ValueRef;
#[fast_ffi]
pub unsafe fn LLVMConstReal(RealTy: TypeRef, N: f64) -> ValueRef;
#[fast_ffi]
pub unsafe fn LLVMConstRealOfString(RealTy: TypeRef,
Text: *c_char)
-> ValueRef;
#[fast_ffi]
pub unsafe fn LLVMConstRealOfStringAndSize(RealTy: TypeRef,
Text: *c_char,
SLen: c_uint)
-> ValueRef;
#[fast_ffi]
pub unsafe fn LLVMConstIntGetZExtValue(ConstantVal: ValueRef)
-> c_ulonglong;
#[fast_ffi]
pub unsafe fn LLVMConstIntGetSExtValue(ConstantVal: ValueRef)
-> c_longlong;
/* Operations on composite constants */
#[fast_ffi]
pub unsafe fn LLVMConstStringInContext(C: ContextRef,
Str: *c_char,
Length: c_uint,
DontNullTerminate: Bool)
-> ValueRef;
#[fast_ffi]
pub unsafe fn LLVMConstStructInContext(C: ContextRef,
ConstantVals: *ValueRef,
Count: c_uint,
Packed: Bool) -> ValueRef;
#[fast_ffi]
pub unsafe fn LLVMConstArray(ElementTy: TypeRef,
ConstantVals: *ValueRef,
Length: c_uint)
-> ValueRef;
#[fast_ffi]
pub unsafe fn LLVMConstVector(ScalarConstantVals: *ValueRef,
Size: c_uint) -> ValueRef;
/* Constant expressions */
#[fast_ffi]
pub unsafe fn LLVMAlignOf(Ty: TypeRef) -> ValueRef;
#[fast_ffi]
pub unsafe fn LLVMSizeOf(Ty: TypeRef) -> ValueRef;
#[fast_ffi]
pub unsafe fn LLVMConstNeg(ConstantVal: ValueRef) -> ValueRef;
#[fast_ffi]
pub unsafe fn LLVMConstNSWNeg(ConstantVal: ValueRef) -> ValueRef;
#[fast_ffi]
pub unsafe fn LLVMConstNUWNeg(ConstantVal: ValueRef) -> ValueRef;
#[fast_ffi]
pub unsafe fn LLVMConstFNeg(ConstantVal: ValueRef) -> ValueRef;
#[fast_ffi]
pub unsafe fn LLVMConstNot(ConstantVal: ValueRef) -> ValueRef;
#[fast_ffi]
pub unsafe fn LLVMConstAdd(LHSConstant: ValueRef,
RHSConstant: ValueRef)
-> ValueRef;
#[fast_ffi]
pub unsafe fn LLVMConstNSWAdd(LHSConstant: ValueRef,
RHSConstant: ValueRef)
-> ValueRef;
#[fast_ffi]
pub unsafe fn LLVMConstNUWAdd(LHSConstant: ValueRef,
RHSConstant: ValueRef)
-> ValueRef;
#[fast_ffi]
pub unsafe fn LLVMConstFAdd(LHSConstant: ValueRef,
RHSConstant: ValueRef)
-> ValueRef;
#[fast_ffi]
pub unsafe fn LLVMConstSub(LHSConstant: ValueRef,
RHSConstant: ValueRef)
-> ValueRef;
#[fast_ffi]
pub unsafe fn LLVMConstNSWSub(LHSConstant: ValueRef,
RHSConstant: ValueRef)
-> ValueRef;
#[fast_ffi]
pub unsafe fn LLVMConstNUWSub(LHSConstant: ValueRef,
RHSConstant: ValueRef)
-> ValueRef;
#[fast_ffi]
pub unsafe fn LLVMConstFSub(LHSConstant: ValueRef,
RHSConstant: ValueRef)
-> ValueRef;
#[fast_ffi]
pub unsafe fn LLVMConstMul(LHSConstant: ValueRef,
RHSConstant: ValueRef)
-> ValueRef;
#[fast_ffi]
pub unsafe fn LLVMConstNSWMul(LHSConstant: ValueRef,
RHSConstant: ValueRef)
-> ValueRef;
#[fast_ffi]
pub unsafe fn LLVMConstNUWMul(LHSConstant: ValueRef,
RHSConstant: ValueRef)
-> ValueRef;
#[fast_ffi]
pub unsafe fn LLVMConstFMul(LHSConstant: ValueRef,
RHSConstant: ValueRef)
-> ValueRef;
#[fast_ffi]
pub unsafe fn LLVMConstUDiv(LHSConstant: ValueRef,
RHSConstant: ValueRef)
-> ValueRef;
#[fast_ffi]
pub unsafe fn LLVMConstSDiv(LHSConstant: ValueRef,
RHSConstant: ValueRef)
-> ValueRef;
#[fast_ffi]
pub unsafe fn LLVMConstExactSDiv(LHSConstant: ValueRef,
RHSConstant: ValueRef)
-> ValueRef;
#[fast_ffi]
pub unsafe fn LLVMConstFDiv(LHSConstant: ValueRef,
RHSConstant: ValueRef)
-> ValueRef;
#[fast_ffi]
pub unsafe fn LLVMConstURem(LHSConstant: ValueRef,
RHSConstant: ValueRef)
-> ValueRef;
#[fast_ffi]
pub unsafe fn LLVMConstSRem(LHSConstant: ValueRef,
RHSConstant: ValueRef)
-> ValueRef;
#[fast_ffi]
pub unsafe fn LLVMConstFRem(LHSConstant: ValueRef,
RHSConstant: ValueRef)
-> ValueRef;
#[fast_ffi]
pub unsafe fn LLVMConstAnd(LHSConstant: ValueRef,
RHSConstant: ValueRef)
-> ValueRef;
#[fast_ffi]
pub unsafe fn LLVMConstOr(LHSConstant: ValueRef,
RHSConstant: ValueRef)
-> ValueRef;
#[fast_ffi]
pub unsafe fn LLVMConstXor(LHSConstant: ValueRef,
RHSConstant: ValueRef)
-> ValueRef;
#[fast_ffi]
pub unsafe fn LLVMConstShl(LHSConstant: ValueRef,
RHSConstant: ValueRef)
-> ValueRef;
#[fast_ffi]
pub unsafe fn LLVMConstLShr(LHSConstant: ValueRef,
RHSConstant: ValueRef) -> ValueRef;
#[fast_ffi]
pub unsafe fn LLVMConstAShr(LHSConstant: ValueRef,
RHSConstant: ValueRef) -> ValueRef;
#[fast_ffi]
pub unsafe fn LLVMConstGEP(ConstantVal: ValueRef,
ConstantIndices: *ValueRef,
NumIndices: c_uint) -> ValueRef;
#[fast_ffi]
pub unsafe fn LLVMConstInBoundsGEP(ConstantVal: ValueRef,
ConstantIndices: *ValueRef,
NumIndices: c_uint)
-> ValueRef;
#[fast_ffi]
pub unsafe fn LLVMConstTrunc(ConstantVal: ValueRef,
ToType: TypeRef)
-> ValueRef;
#[fast_ffi]
pub unsafe fn LLVMConstSExt(ConstantVal: ValueRef,
ToType: TypeRef)
-> ValueRef;
#[fast_ffi]
pub unsafe fn LLVMConstZExt(ConstantVal: ValueRef,
ToType: TypeRef)
-> ValueRef;
#[fast_ffi]
pub unsafe fn LLVMConstFPTrunc(ConstantVal: ValueRef,
ToType: TypeRef)
-> ValueRef;
#[fast_ffi]
pub unsafe fn LLVMConstFPExt(ConstantVal: ValueRef,
ToType: TypeRef)
-> ValueRef;
#[fast_ffi]
pub unsafe fn LLVMConstUIToFP(ConstantVal: ValueRef,
ToType: TypeRef)
-> ValueRef;
#[fast_ffi]
pub unsafe fn LLVMConstSIToFP(ConstantVal: ValueRef,
ToType: TypeRef)
-> ValueRef;
#[fast_ffi]
pub unsafe fn LLVMConstFPToUI(ConstantVal: ValueRef,
ToType: TypeRef)
-> ValueRef;
#[fast_ffi]
pub unsafe fn LLVMConstFPToSI(ConstantVal: ValueRef,
ToType: TypeRef)
-> ValueRef;
#[fast_ffi]
pub unsafe fn LLVMConstPtrToInt(ConstantVal: ValueRef,
ToType: TypeRef)
-> ValueRef;
#[fast_ffi]
pub unsafe fn LLVMConstIntToPtr(ConstantVal: ValueRef,
ToType: TypeRef)
-> ValueRef;
#[fast_ffi]
pub unsafe fn LLVMConstBitCast(ConstantVal: ValueRef,
ToType: TypeRef)
-> ValueRef;
#[fast_ffi]
pub unsafe fn LLVMConstZExtOrBitCast(ConstantVal: ValueRef,
ToType: TypeRef)
-> ValueRef;
#[fast_ffi]
pub unsafe fn LLVMConstSExtOrBitCast(ConstantVal: ValueRef,
ToType: TypeRef)
-> ValueRef;
#[fast_ffi]
pub unsafe fn LLVMConstTruncOrBitCast(ConstantVal: ValueRef,
ToType: TypeRef)
-> ValueRef;
#[fast_ffi]
pub unsafe fn LLVMConstPointerCast(ConstantVal: ValueRef,
ToType: TypeRef)
-> ValueRef;
#[fast_ffi]
pub unsafe fn LLVMConstIntCast(ConstantVal: ValueRef,
ToType: TypeRef,
isSigned: Bool)
-> ValueRef;
#[fast_ffi]
pub unsafe fn LLVMConstFPCast(ConstantVal: ValueRef,
ToType: TypeRef)
-> ValueRef;
#[fast_ffi]
pub unsafe fn LLVMConstSelect(ConstantCondition: ValueRef,
ConstantIfTrue: ValueRef,
ConstantIfFalse: ValueRef)
-> ValueRef;
#[fast_ffi]
pub unsafe fn LLVMConstExtractElement(VectorConstant: ValueRef,
IndexConstant: ValueRef) -> ValueRef;
#[fast_ffi]
pub unsafe fn LLVMConstInsertElement(VectorConstant: ValueRef,
ElementValueConstant: ValueRef,
IndexConstant: ValueRef) -> ValueRef;
#[fast_ffi]
pub unsafe fn LLVMConstShuffleVector(VectorAConstant: ValueRef,
VectorBConstant: ValueRef,
MaskConstant: ValueRef) -> ValueRef;
#[fast_ffi]
pub unsafe fn LLVMConstExtractValue(AggConstant: ValueRef,
IdxList: *c_uint,
NumIdx: c_uint) -> ValueRef;
#[fast_ffi]
pub unsafe fn LLVMConstInsertValue(AggConstant: ValueRef,
ElementValueConstant: ValueRef,
IdxList: *c_uint,
NumIdx: c_uint)
-> ValueRef;
#[fast_ffi]
pub unsafe fn LLVMConstInlineAsm(Ty: TypeRef, AsmString: *c_char,
Constraints: *c_char, HasSideEffects: Bool,
IsAlignStack: Bool) -> ValueRef;
#[fast_ffi]
pub unsafe fn LLVMBlockAddress(F: ValueRef, BB: BasicBlockRef)
-> ValueRef;
/* Operations on global variables, functions, and aliases (globals) */
#[fast_ffi]
pub unsafe fn LLVMGetGlobalParent(Global: ValueRef) -> ModuleRef;
#[fast_ffi]
pub unsafe fn LLVMIsDeclaration(Global: ValueRef) -> Bool;
#[fast_ffi]
pub unsafe fn LLVMGetLinkage(Global: ValueRef) -> c_uint;
#[fast_ffi]
pub unsafe fn LLVMSetLinkage(Global: ValueRef, Link: c_uint);
#[fast_ffi]
pub unsafe fn LLVMGetSection(Global: ValueRef) -> *c_char;
#[fast_ffi]
pub unsafe fn LLVMSetSection(Global: ValueRef, Section: *c_char);
#[fast_ffi]
pub unsafe fn LLVMGetVisibility(Global: ValueRef) -> c_uint;
#[fast_ffi]
pub unsafe fn LLVMSetVisibility(Global: ValueRef, Viz: c_uint);
#[fast_ffi]
pub unsafe fn LLVMGetAlignment(Global: ValueRef) -> c_uint;
#[fast_ffi]
pub unsafe fn LLVMSetAlignment(Global: ValueRef, Bytes: c_uint);
/* Operations on global variables */
#[fast_ffi]
pub unsafe fn LLVMAddGlobal(M: ModuleRef,
Ty: TypeRef,
Name: *c_char)
-> ValueRef;
#[fast_ffi]
pub unsafe fn LLVMAddGlobalInAddressSpace(M: ModuleRef,
Ty: TypeRef,
Name: *c_char,
AddressSpace: c_uint)
-> ValueRef;
#[fast_ffi]
pub unsafe fn LLVMGetNamedGlobal(M: ModuleRef, Name: *c_char)
-> ValueRef;
#[fast_ffi]
pub unsafe fn LLVMGetFirstGlobal(M: ModuleRef) -> ValueRef;
#[fast_ffi]
pub unsafe fn LLVMGetLastGlobal(M: ModuleRef) -> ValueRef;
#[fast_ffi]
pub unsafe fn LLVMGetNextGlobal(GlobalVar: ValueRef) -> ValueRef;
#[fast_ffi]
pub unsafe fn LLVMGetPreviousGlobal(GlobalVar: ValueRef) -> ValueRef;
#[fast_ffi]
pub unsafe fn LLVMDeleteGlobal(GlobalVar: ValueRef);
#[fast_ffi]
pub unsafe fn LLVMGetInitializer(GlobalVar: ValueRef) -> ValueRef;
#[fast_ffi]
pub unsafe fn LLVMSetInitializer(GlobalVar: ValueRef,
ConstantVal: ValueRef);
#[fast_ffi]
pub unsafe fn LLVMIsThreadLocal(GlobalVar: ValueRef) -> Bool;
#[fast_ffi]
pub unsafe fn LLVMSetThreadLocal(GlobalVar: ValueRef,
IsThreadLocal: Bool);
#[fast_ffi]
pub unsafe fn LLVMIsGlobalConstant(GlobalVar: ValueRef) -> Bool;
#[fast_ffi]
pub unsafe fn LLVMSetGlobalConstant(GlobalVar: ValueRef,
IsConstant: Bool);
/* Operations on aliases */
#[fast_ffi]
pub unsafe fn LLVMAddAlias(M: ModuleRef,
Ty: TypeRef,
Aliasee: ValueRef,
Name: *c_char)
-> ValueRef;
/* Operations on functions */
#[fast_ffi]
pub unsafe fn LLVMAddFunction(M: ModuleRef,
Name: *c_char,
FunctionTy: TypeRef)
-> ValueRef;
#[fast_ffi]
pub unsafe fn LLVMGetNamedFunction(M: ModuleRef,
Name: *c_char) -> ValueRef;
#[fast_ffi]
pub unsafe fn LLVMGetFirstFunction(M: ModuleRef) -> ValueRef;
#[fast_ffi]
pub unsafe fn LLVMGetLastFunction(M: ModuleRef) -> ValueRef;
#[fast_ffi]
pub unsafe fn LLVMGetNextFunction(Fn: ValueRef) -> ValueRef;
#[fast_ffi]
pub unsafe fn LLVMGetPreviousFunction(Fn: ValueRef) -> ValueRef;
#[fast_ffi]
pub unsafe fn LLVMDeleteFunction(Fn: ValueRef);
#[fast_ffi]
pub unsafe fn LLVMGetOrInsertFunction(M: ModuleRef, Name: *c_char,
FunctionTy: TypeRef) -> ValueRef;
#[fast_ffi]
pub unsafe fn LLVMGetIntrinsicID(Fn: ValueRef) -> c_uint;
#[fast_ffi]
pub unsafe fn LLVMGetFunctionCallConv(Fn: ValueRef) -> c_uint;
#[fast_ffi]
pub unsafe fn LLVMSetFunctionCallConv(Fn: ValueRef, CC: c_uint);
#[fast_ffi]
pub unsafe fn LLVMGetGC(Fn: ValueRef) -> *c_char;
#[fast_ffi]
pub unsafe fn LLVMSetGC(Fn: ValueRef, Name: *c_char);
#[fast_ffi]
pub unsafe fn LLVMAddFunctionAttr(Fn: ValueRef,
PA: c_uint,
HighPA: c_uint);
#[fast_ffi]
pub unsafe fn LLVMGetFunctionAttr(Fn: ValueRef) -> c_ulonglong;
#[fast_ffi]
pub unsafe fn LLVMRemoveFunctionAttr(Fn: ValueRef,
PA: c_ulonglong,
HighPA: c_ulonglong);
/* Operations on parameters */
#[fast_ffi]
pub unsafe fn LLVMCountParams(Fn: ValueRef) -> c_uint;
#[fast_ffi]
pub unsafe fn LLVMGetParams(Fn: ValueRef, Params: *ValueRef);
#[fast_ffi]
pub unsafe fn LLVMGetParam(Fn: ValueRef, Index: c_uint) -> ValueRef;
#[fast_ffi]
pub unsafe fn LLVMGetParamParent(Inst: ValueRef) -> ValueRef;
#[fast_ffi]
pub unsafe fn LLVMGetFirstParam(Fn: ValueRef) -> ValueRef;
#[fast_ffi]
pub unsafe fn LLVMGetLastParam(Fn: ValueRef) -> ValueRef;
#[fast_ffi]
pub unsafe fn LLVMGetNextParam(Arg: ValueRef) -> ValueRef;
#[fast_ffi]
pub unsafe fn LLVMGetPreviousParam(Arg: ValueRef) -> ValueRef;
#[fast_ffi]
pub unsafe fn LLVMAddAttribute(Arg: ValueRef, PA: c_uint);
#[fast_ffi]
pub unsafe fn LLVMRemoveAttribute(Arg: ValueRef, PA: c_uint);
#[fast_ffi]
pub unsafe fn LLVMGetAttribute(Arg: ValueRef) -> c_uint;
#[fast_ffi]
pub unsafe fn LLVMSetParamAlignment(Arg: ValueRef, align: c_uint);
/* Operations on basic blocks */
#[fast_ffi]
pub unsafe fn LLVMBasicBlockAsValue(BB: BasicBlockRef) -> ValueRef;
#[fast_ffi]
pub unsafe fn LLVMValueIsBasicBlock(Val: ValueRef) -> Bool;
#[fast_ffi]
pub unsafe fn LLVMValueAsBasicBlock(Val: ValueRef) -> BasicBlockRef;
#[fast_ffi]
pub unsafe fn LLVMGetBasicBlockParent(BB: BasicBlockRef) -> ValueRef;
#[fast_ffi]
pub unsafe fn LLVMCountBasicBlocks(Fn: ValueRef) -> c_uint;
#[fast_ffi]
pub unsafe fn LLVMGetBasicBlocks(Fn: ValueRef,
BasicBlocks: *ValueRef);
#[fast_ffi]
pub unsafe fn LLVMGetFirstBasicBlock(Fn: ValueRef) -> BasicBlockRef;
#[fast_ffi]
pub unsafe fn LLVMGetLastBasicBlock(Fn: ValueRef) -> BasicBlockRef;
#[fast_ffi]
pub unsafe fn LLVMGetNextBasicBlock(BB: BasicBlockRef)
-> BasicBlockRef;
#[fast_ffi]
pub unsafe fn LLVMGetPreviousBasicBlock(BB: BasicBlockRef)
-> BasicBlockRef;
#[fast_ffi]
pub unsafe fn LLVMGetEntryBasicBlock(Fn: ValueRef) -> BasicBlockRef;
#[fast_ffi]
pub unsafe fn LLVMAppendBasicBlockInContext(C: ContextRef,
Fn: ValueRef,
Name: *c_char)
-> BasicBlockRef;
#[fast_ffi]
pub unsafe fn LLVMInsertBasicBlockInContext(C: ContextRef,
BB: BasicBlockRef,
Name: *c_char)
-> BasicBlockRef;
#[fast_ffi]
pub unsafe fn LLVMDeleteBasicBlock(BB: BasicBlockRef);
#[fast_ffi]
pub unsafe fn LLVMMoveBasicBlockAfter(BB: BasicBlockRef, MoveAfter: BasicBlockRef);
#[fast_ffi]
pub unsafe fn LLVMMoveBasicBlockBefore(BB: BasicBlockRef, MoveBefore: BasicBlockRef);
/* Operations on instructions */
#[fast_ffi]
pub unsafe fn LLVMGetInstructionParent(Inst: ValueRef)
-> BasicBlockRef;
#[fast_ffi]
pub unsafe fn LLVMGetFirstInstruction(BB: BasicBlockRef) -> ValueRef;
#[fast_ffi]
pub unsafe fn LLVMGetLastInstruction(BB: BasicBlockRef) -> ValueRef;
#[fast_ffi]
pub unsafe fn LLVMGetNextInstruction(Inst: ValueRef) -> ValueRef;
#[fast_ffi]
pub unsafe fn LLVMGetPreviousInstruction(Inst: ValueRef) -> ValueRef;
#[fast_ffi]
pub unsafe fn LLVMInstructionEraseFromParent(Inst: ValueRef);
/* Operations on call sites */
#[fast_ffi]
pub unsafe fn LLVMSetInstructionCallConv(Instr: ValueRef, CC: c_uint);
#[fast_ffi]
pub unsafe fn LLVMGetInstructionCallConv(Instr: ValueRef) -> c_uint;
#[fast_ffi]
pub unsafe fn LLVMAddInstrAttribute(Instr: ValueRef,
index: c_uint,
IA: c_uint);
#[fast_ffi]
pub unsafe fn LLVMRemoveInstrAttribute(Instr: ValueRef,