]> git.proxmox.com Git - rustc.git/blob - src/librustc_llvm/ffi.rs
New upstream version 1.12.0+dfsg1
[rustc.git] / src / librustc_llvm / ffi.rs
1 // Copyright 2012-2015 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
4 //
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
10
11 use debuginfo::{DIBuilderRef, DIDescriptor,
12 DIFile, DILexicalBlock, DISubprogram, DIType,
13 DIBasicType, DIDerivedType, DICompositeType, DIScope,
14 DIVariable, DIGlobalVariable, DIArray, DISubrange,
15 DITemplateTypeParameter, DIEnumerator, DINameSpace};
16
17 use libc::{c_uint, c_int, size_t, c_char};
18 use libc::{c_longlong, c_ulonglong, c_void};
19
20 use RustStringRef;
21
22 pub type Opcode = u32;
23 pub type Bool = c_uint;
24
25 pub const True: Bool = 1 as Bool;
26 pub const False: Bool = 0 as Bool;
27
28 #[derive(Copy, Clone, PartialEq)]
29 #[repr(C)]
30 pub enum LLVMRustResult {
31 Success,
32 Failure,
33 }
34 // Consts for the LLVM CallConv type, pre-cast to usize.
35
36 /// LLVM CallingConv::ID. Should we wrap this?
37 #[derive(Copy, Clone, PartialEq)]
38 #[repr(C)]
39 pub enum CallConv {
40 CCallConv = 0,
41 FastCallConv = 8,
42 ColdCallConv = 9,
43 X86StdcallCallConv = 64,
44 X86FastcallCallConv = 65,
45 X86_64_Win64 = 79,
46 X86_VectorCall = 80
47 }
48
49 /// LLVMLinkage
50 ///
51 /// This enum omits the obsolete (and no-op) linkage types DLLImportLinkage,
52 /// DLLExportLinkage, GhostLinkage and LinkOnceODRAutoHideLinkage.
53 /// LinkerPrivateLinkage and LinkerPrivateWeakLinkage are not included either;
54 /// they've been removed in upstream LLVM commit r203866.
55 #[derive(Copy, Clone, PartialEq, Eq, Hash, Debug)]
56 #[repr(C)]
57 pub enum Linkage {
58 ExternalLinkage = 0,
59 AvailableExternallyLinkage = 1,
60 LinkOnceAnyLinkage = 2,
61 LinkOnceODRLinkage = 3,
62 WeakAnyLinkage = 5,
63 WeakODRLinkage = 6,
64 AppendingLinkage = 7,
65 InternalLinkage = 8,
66 PrivateLinkage = 9,
67 ExternalWeakLinkage = 12,
68 CommonLinkage = 14,
69 }
70
71 /// LLVMDiagnosticSeverity
72 #[derive(Copy, Clone, Debug)]
73 #[repr(C)]
74 pub enum DiagnosticSeverity {
75 Error = 0,
76 Warning = 1,
77 Remark = 2,
78 Note = 3,
79 }
80
81 /// LLVMDLLStorageClass
82 #[derive(Copy, Clone)]
83 #[repr(C)]
84 pub enum DLLStorageClass {
85 Default = 0,
86 DllImport = 1, /* Function to be imported from DLL. */
87 DllExport = 2, /* Function to be accessible from DLL. */
88 }
89
90 bitflags! {
91 #[derive(Default, Debug)]
92 flags Attribute : u64 {
93 const ZExt = 1 << 0,
94 const SExt = 1 << 1,
95 const NoReturn = 1 << 2,
96 const InReg = 1 << 3,
97 const StructRet = 1 << 4,
98 const NoUnwind = 1 << 5,
99 const NoAlias = 1 << 6,
100 const ByVal = 1 << 7,
101 const Nest = 1 << 8,
102 const ReadNone = 1 << 9,
103 const ReadOnly = 1 << 10,
104 const NoInline = 1 << 11,
105 const AlwaysInline = 1 << 12,
106 const OptimizeForSize = 1 << 13,
107 const StackProtect = 1 << 14,
108 const StackProtectReq = 1 << 15,
109 const NoCapture = 1 << 21,
110 const NoRedZone = 1 << 22,
111 const NoImplicitFloat = 1 << 23,
112 const Naked = 1 << 24,
113 const InlineHint = 1 << 25,
114 const ReturnsTwice = 1 << 29,
115 const UWTable = 1 << 30,
116 const NonLazyBind = 1 << 31,
117
118 // Some of these are missing from the LLVM C API, the rest are
119 // present, but commented out, and preceded by the following warning:
120 // FIXME: These attributes are currently not included in the C API as
121 // a temporary measure until the API/ABI impact to the C API is understood
122 // and the path forward agreed upon.
123 const SanitizeAddress = 1 << 32,
124 const MinSize = 1 << 33,
125 const NoDuplicate = 1 << 34,
126 const StackProtectStrong = 1 << 35,
127 const SanitizeThread = 1 << 36,
128 const SanitizeMemory = 1 << 37,
129 const NoBuiltin = 1 << 38,
130 const Returned = 1 << 39,
131 const Cold = 1 << 40,
132 const Builtin = 1 << 41,
133 const OptimizeNone = 1 << 42,
134 const InAlloca = 1 << 43,
135 const NonNull = 1 << 44,
136 const JumpTable = 1 << 45,
137 const Convergent = 1 << 46,
138 const SafeStack = 1 << 47,
139 const NoRecurse = 1 << 48,
140 const InaccessibleMemOnly = 1 << 49,
141 const InaccessibleMemOrArgMemOnly = 1 << 50,
142 }
143 }
144
145 /// LLVMIntPredicate
146 #[derive(Copy, Clone)]
147 #[repr(C)]
148 pub enum IntPredicate {
149 IntEQ = 32,
150 IntNE = 33,
151 IntUGT = 34,
152 IntUGE = 35,
153 IntULT = 36,
154 IntULE = 37,
155 IntSGT = 38,
156 IntSGE = 39,
157 IntSLT = 40,
158 IntSLE = 41,
159 }
160
161 /// LLVMRealPredicate
162 #[derive(Copy, Clone)]
163 #[repr(C)]
164 pub enum RealPredicate {
165 RealPredicateFalse = 0,
166 RealOEQ = 1,
167 RealOGT = 2,
168 RealOGE = 3,
169 RealOLT = 4,
170 RealOLE = 5,
171 RealONE = 6,
172 RealORD = 7,
173 RealUNO = 8,
174 RealUEQ = 9,
175 RealUGT = 10,
176 RealUGE = 11,
177 RealULT = 12,
178 RealULE = 13,
179 RealUNE = 14,
180 RealPredicateTrue = 15,
181 }
182
183 /// LLVMTypeKind
184 #[derive(Copy, Clone, PartialEq, Debug)]
185 #[repr(C)]
186 pub enum TypeKind {
187 Void = 0,
188 Half = 1,
189 Float = 2,
190 Double = 3,
191 X86_FP80 = 4,
192 FP128 = 5,
193 PPC_FP128 = 6,
194 Label = 7,
195 Integer = 8,
196 Function = 9,
197 Struct = 10,
198 Array = 11,
199 Pointer = 12,
200 Vector = 13,
201 Metadata = 14,
202 X86_MMX = 15,
203 Token = 16,
204 }
205
206 /// LLVMAtomicRmwBinOp
207 #[derive(Copy, Clone)]
208 #[repr(C)]
209 pub enum AtomicRmwBinOp {
210 AtomicXchg = 0,
211 AtomicAdd = 1,
212 AtomicSub = 2,
213 AtomicAnd = 3,
214 AtomicNand = 4,
215 AtomicOr = 5,
216 AtomicXor = 6,
217 AtomicMax = 7,
218 AtomicMin = 8,
219 AtomicUMax = 9,
220 AtomicUMin = 10,
221 }
222
223 /// LLVMAtomicOrdering
224 #[derive(Copy, Clone)]
225 #[repr(C)]
226 pub enum AtomicOrdering {
227 NotAtomic = 0,
228 Unordered = 1,
229 Monotonic = 2,
230 // Consume = 3, // Not specified yet.
231 Acquire = 4,
232 Release = 5,
233 AcquireRelease = 6,
234 SequentiallyConsistent = 7
235 }
236
237 /// LLVMRustSynchronizationScope
238 #[derive(Copy, Clone)]
239 #[repr(C)]
240 pub enum SynchronizationScope {
241 Other,
242 SingleThread,
243 CrossThread,
244 }
245
246 /// LLVMRustFileType
247 #[derive(Copy, Clone)]
248 #[repr(C)]
249 pub enum FileType {
250 Other,
251 AssemblyFile,
252 ObjectFile,
253 }
254
255 /// Enum pinned in LLVMContext, used in
256 /// LLVMSetMetadata so ABI-stable.
257 #[derive(Copy, Clone)]
258 #[repr(C)]
259 pub enum MetadataType {
260 MD_dbg = 0,
261 MD_tbaa = 1,
262 MD_prof = 2,
263 MD_fpmath = 3,
264 MD_range = 4,
265 MD_tbaa_struct = 5,
266 MD_invariant_load = 6,
267 MD_alias_scope = 7,
268 MD_noalias = 8,
269 MD_nontemporal = 9,
270 MD_mem_parallel_loop_access = 10,
271 MD_nonnull = 11,
272 }
273
274 /// LLVMRustAsmDialect
275 #[derive(Copy, Clone)]
276 #[repr(C)]
277 pub enum AsmDialect {
278 Other,
279 Att,
280 Intel,
281 }
282
283 /// LLVMRustCodeGenOptLevel
284 #[derive(Copy, Clone, PartialEq)]
285 #[repr(C)]
286 pub enum CodeGenOptLevel {
287 Other,
288 None,
289 Less,
290 Default,
291 Aggressive,
292 }
293
294 /// LLVMRelocMode
295 #[derive(Copy, Clone, PartialEq)]
296 #[repr(C)]
297 pub enum RelocMode {
298 Default = 0,
299 Static = 1,
300 PIC = 2,
301 DynamicNoPic = 3,
302 }
303
304 /// LLVMRustCodeModel
305 #[derive(Copy, Clone)]
306 #[repr(C)]
307 pub enum CodeModel {
308 Other,
309 Default,
310 JITDefault,
311 Small,
312 Kernel,
313 Medium,
314 Large,
315 }
316
317 /// LLVMRustDiagnosticKind
318 #[derive(Copy, Clone)]
319 #[repr(C)]
320 pub enum DiagnosticKind {
321 Other,
322 InlineAsm,
323 StackSize,
324 DebugMetadataVersion,
325 SampleProfile,
326 OptimizationRemark,
327 OptimizationRemarkMissed,
328 OptimizationRemarkAnalysis,
329 OptimizationRemarkAnalysisFPCommute,
330 OptimizationRemarkAnalysisAliasing,
331 OptimizationRemarkOther,
332 OptimizationFailure,
333 }
334
335 /// LLVMRustArchiveKind
336 #[derive(Copy, Clone)]
337 #[repr(C)]
338 pub enum ArchiveKind {
339 Other,
340 K_GNU,
341 K_MIPS64,
342 K_BSD,
343 K_COFF,
344 }
345
346 /// LLVMRustPassKind
347 #[derive(Copy, Clone, PartialEq, Debug)]
348 #[repr(C)]
349 pub enum PassKind {
350 Other,
351 Function,
352 Module,
353 }
354
355 // Opaque pointer types
356 #[allow(missing_copy_implementations)]
357 pub enum Module_opaque {}
358 pub type ModuleRef = *mut Module_opaque;
359 #[allow(missing_copy_implementations)]
360 pub enum Context_opaque {}
361 pub type ContextRef = *mut Context_opaque;
362 #[allow(missing_copy_implementations)]
363 pub enum Type_opaque {}
364 pub type TypeRef = *mut Type_opaque;
365 #[allow(missing_copy_implementations)]
366 pub enum Value_opaque {}
367 pub type ValueRef = *mut Value_opaque;
368 #[allow(missing_copy_implementations)]
369 pub enum Metadata_opaque {}
370 pub type MetadataRef = *mut Metadata_opaque;
371 #[allow(missing_copy_implementations)]
372 pub enum BasicBlock_opaque {}
373 pub type BasicBlockRef = *mut BasicBlock_opaque;
374 #[allow(missing_copy_implementations)]
375 pub enum Builder_opaque {}
376 pub type BuilderRef = *mut Builder_opaque;
377 #[allow(missing_copy_implementations)]
378 pub enum ExecutionEngine_opaque {}
379 pub type ExecutionEngineRef = *mut ExecutionEngine_opaque;
380 #[allow(missing_copy_implementations)]
381 pub enum MemoryBuffer_opaque {}
382 pub type MemoryBufferRef = *mut MemoryBuffer_opaque;
383 #[allow(missing_copy_implementations)]
384 pub enum PassManager_opaque {}
385 pub type PassManagerRef = *mut PassManager_opaque;
386 #[allow(missing_copy_implementations)]
387 pub enum PassManagerBuilder_opaque {}
388 pub type PassManagerBuilderRef = *mut PassManagerBuilder_opaque;
389 #[allow(missing_copy_implementations)]
390 pub enum Use_opaque {}
391 pub type UseRef = *mut Use_opaque;
392 #[allow(missing_copy_implementations)]
393 pub enum TargetData_opaque {}
394 pub type TargetDataRef = *mut TargetData_opaque;
395 #[allow(missing_copy_implementations)]
396 pub enum ObjectFile_opaque {}
397 pub type ObjectFileRef = *mut ObjectFile_opaque;
398 #[allow(missing_copy_implementations)]
399 pub enum SectionIterator_opaque {}
400 pub type SectionIteratorRef = *mut SectionIterator_opaque;
401 #[allow(missing_copy_implementations)]
402 pub enum Pass_opaque {}
403 pub type PassRef = *mut Pass_opaque;
404 #[allow(missing_copy_implementations)]
405 pub enum TargetMachine_opaque {}
406 pub type TargetMachineRef = *mut TargetMachine_opaque;
407 pub enum Archive_opaque {}
408 pub type ArchiveRef = *mut Archive_opaque;
409 pub enum ArchiveIterator_opaque {}
410 pub type ArchiveIteratorRef = *mut ArchiveIterator_opaque;
411 pub enum ArchiveChild_opaque {}
412 pub type ArchiveChildRef = *mut ArchiveChild_opaque;
413 #[allow(missing_copy_implementations)]
414 pub enum Twine_opaque {}
415 pub type TwineRef = *mut Twine_opaque;
416 #[allow(missing_copy_implementations)]
417 pub enum DiagnosticInfo_opaque {}
418 pub type DiagnosticInfoRef = *mut DiagnosticInfo_opaque;
419 #[allow(missing_copy_implementations)]
420 pub enum DebugLoc_opaque {}
421 pub type DebugLocRef = *mut DebugLoc_opaque;
422 #[allow(missing_copy_implementations)]
423 pub enum SMDiagnostic_opaque {}
424 pub type SMDiagnosticRef = *mut SMDiagnostic_opaque;
425 #[allow(missing_copy_implementations)]
426 pub enum RustArchiveMember_opaque {}
427 pub type RustArchiveMemberRef = *mut RustArchiveMember_opaque;
428 #[allow(missing_copy_implementations)]
429 pub enum OperandBundleDef_opaque {}
430 pub type OperandBundleDefRef = *mut OperandBundleDef_opaque;
431
432 pub type DiagnosticHandler = unsafe extern "C" fn(DiagnosticInfoRef, *mut c_void);
433 pub type InlineAsmDiagHandler = unsafe extern "C" fn(SMDiagnosticRef, *const c_void, c_uint);
434
435 pub mod debuginfo {
436 pub use self::DIDescriptorFlags::*;
437 use super::{MetadataRef};
438
439 #[allow(missing_copy_implementations)]
440 pub enum DIBuilder_opaque {}
441 pub type DIBuilderRef = *mut DIBuilder_opaque;
442
443 pub type DIDescriptor = MetadataRef;
444 pub type DIScope = DIDescriptor;
445 pub type DILocation = DIDescriptor;
446 pub type DIFile = DIScope;
447 pub type DILexicalBlock = DIScope;
448 pub type DISubprogram = DIScope;
449 pub type DINameSpace = DIScope;
450 pub type DIType = DIDescriptor;
451 pub type DIBasicType = DIType;
452 pub type DIDerivedType = DIType;
453 pub type DICompositeType = DIDerivedType;
454 pub type DIVariable = DIDescriptor;
455 pub type DIGlobalVariable = DIDescriptor;
456 pub type DIArray = DIDescriptor;
457 pub type DISubrange = DIDescriptor;
458 pub type DIEnumerator = DIDescriptor;
459 pub type DITemplateTypeParameter = DIDescriptor;
460
461 #[derive(Copy, Clone)]
462 pub enum DIDescriptorFlags {
463 FlagPrivate = 1 << 0,
464 FlagProtected = 1 << 1,
465 FlagFwdDecl = 1 << 2,
466 FlagAppleBlock = 1 << 3,
467 FlagBlockByrefStruct = 1 << 4,
468 FlagVirtual = 1 << 5,
469 FlagArtificial = 1 << 6,
470 FlagExplicit = 1 << 7,
471 FlagPrototyped = 1 << 8,
472 FlagObjcClassComplete = 1 << 9,
473 FlagObjectPointer = 1 << 10,
474 FlagVector = 1 << 11,
475 FlagStaticMember = 1 << 12,
476 FlagIndirectVariable = 1 << 13,
477 FlagLValueReference = 1 << 14,
478 FlagRValueReference = 1 << 15
479 }
480 }
481
482
483 // Link to our native llvm bindings (things that we need to use the C++ api
484 // for) and because llvm is written in C++ we need to link against libstdc++
485 //
486 // You'll probably notice that there is an omission of all LLVM libraries
487 // from this location. This is because the set of LLVM libraries that we
488 // link to is mostly defined by LLVM, and the `llvm-config` tool is used to
489 // figure out the exact set of libraries. To do this, the build system
490 // generates an llvmdeps.rs file next to this one which will be
491 // automatically updated whenever LLVM is updated to include an up-to-date
492 // set of the libraries we need to link to LLVM for.
493 #[link(name = "rustllvm", kind = "static")]
494 #[cfg(not(cargobuild))]
495 extern {}
496
497 #[linked_from = "rustllvm"] // not quite true but good enough
498 extern {
499 /* Create and destroy contexts. */
500 pub fn LLVMContextCreate() -> ContextRef;
501 pub fn LLVMContextDispose(C: ContextRef);
502 pub fn LLVMGetMDKindIDInContext(C: ContextRef,
503 Name: *const c_char,
504 SLen: c_uint)
505 -> c_uint;
506
507 /* Create and destroy modules. */
508 pub fn LLVMModuleCreateWithNameInContext(ModuleID: *const c_char,
509 C: ContextRef)
510 -> ModuleRef;
511 pub fn LLVMGetModuleContext(M: ModuleRef) -> ContextRef;
512 pub fn LLVMCloneModule(M: ModuleRef) -> ModuleRef;
513 pub fn LLVMDisposeModule(M: ModuleRef);
514
515 /// Data layout. See Module::getDataLayout.
516 pub fn LLVMGetDataLayout(M: ModuleRef) -> *const c_char;
517 pub fn LLVMSetDataLayout(M: ModuleRef, Triple: *const c_char);
518
519 /// Target triple. See Module::getTargetTriple.
520 pub fn LLVMGetTarget(M: ModuleRef) -> *const c_char;
521 pub fn LLVMSetTarget(M: ModuleRef, Triple: *const c_char);
522
523 /// See Module::dump.
524 pub fn LLVMDumpModule(M: ModuleRef);
525
526 /// See Module::setModuleInlineAsm.
527 pub fn LLVMSetModuleInlineAsm(M: ModuleRef, Asm: *const c_char);
528
529 /// See llvm::LLVMTypeKind::getTypeID.
530 pub fn LLVMRustGetTypeKind(Ty: TypeRef) -> TypeKind;
531
532 /// See llvm::LLVMType::getContext.
533 pub fn LLVMGetTypeContext(Ty: TypeRef) -> ContextRef;
534
535 /* Operations on integer types */
536 pub fn LLVMInt1TypeInContext(C: ContextRef) -> TypeRef;
537 pub fn LLVMInt8TypeInContext(C: ContextRef) -> TypeRef;
538 pub fn LLVMInt16TypeInContext(C: ContextRef) -> TypeRef;
539 pub fn LLVMInt32TypeInContext(C: ContextRef) -> TypeRef;
540 pub fn LLVMInt64TypeInContext(C: ContextRef) -> TypeRef;
541 pub fn LLVMIntTypeInContext(C: ContextRef, NumBits: c_uint)
542 -> TypeRef;
543
544 pub fn LLVMGetIntTypeWidth(IntegerTy: TypeRef) -> c_uint;
545
546 /* Operations on real types */
547 pub fn LLVMFloatTypeInContext(C: ContextRef) -> TypeRef;
548 pub fn LLVMDoubleTypeInContext(C: ContextRef) -> TypeRef;
549 pub fn LLVMX86FP80TypeInContext(C: ContextRef) -> TypeRef;
550 pub fn LLVMFP128TypeInContext(C: ContextRef) -> TypeRef;
551 pub fn LLVMPPCFP128TypeInContext(C: ContextRef) -> TypeRef;
552
553 /* Operations on function types */
554 pub fn LLVMFunctionType(ReturnType: TypeRef,
555 ParamTypes: *const TypeRef,
556 ParamCount: c_uint,
557 IsVarArg: Bool)
558 -> TypeRef;
559 pub fn LLVMIsFunctionVarArg(FunctionTy: TypeRef) -> Bool;
560 pub fn LLVMGetReturnType(FunctionTy: TypeRef) -> TypeRef;
561 pub fn LLVMCountParamTypes(FunctionTy: TypeRef) -> c_uint;
562 pub fn LLVMGetParamTypes(FunctionTy: TypeRef, Dest: *mut TypeRef);
563
564 /* Operations on struct types */
565 pub fn LLVMStructTypeInContext(C: ContextRef,
566 ElementTypes: *const TypeRef,
567 ElementCount: c_uint,
568 Packed: Bool)
569 -> TypeRef;
570 pub fn LLVMCountStructElementTypes(StructTy: TypeRef) -> c_uint;
571 pub fn LLVMGetStructElementTypes(StructTy: TypeRef,
572 Dest: *mut TypeRef);
573 pub fn LLVMIsPackedStruct(StructTy: TypeRef) -> Bool;
574
575 /* Operations on array, pointer, and vector types (sequence types) */
576 pub fn LLVMRustArrayType(ElementType: TypeRef, ElementCount: u64) -> TypeRef;
577 pub fn LLVMPointerType(ElementType: TypeRef, AddressSpace: c_uint)
578 -> TypeRef;
579 pub fn LLVMVectorType(ElementType: TypeRef, ElementCount: c_uint)
580 -> TypeRef;
581
582 pub fn LLVMGetElementType(Ty: TypeRef) -> TypeRef;
583 pub fn LLVMGetArrayLength(ArrayTy: TypeRef) -> c_uint;
584 pub fn LLVMGetPointerAddressSpace(PointerTy: TypeRef) -> c_uint;
585 pub fn LLVMGetPointerToGlobal(EE: ExecutionEngineRef, V: ValueRef)
586 -> *const c_void;
587 pub fn LLVMGetVectorSize(VectorTy: TypeRef) -> c_uint;
588
589 /* Operations on other types */
590 pub fn LLVMVoidTypeInContext(C: ContextRef) -> TypeRef;
591 pub fn LLVMLabelTypeInContext(C: ContextRef) -> TypeRef;
592 pub fn LLVMRustMetadataTypeInContext(C: ContextRef) -> TypeRef;
593
594 /* Operations on all values */
595 pub fn LLVMTypeOf(Val: ValueRef) -> TypeRef;
596 pub fn LLVMGetValueName(Val: ValueRef) -> *const c_char;
597 pub fn LLVMSetValueName(Val: ValueRef, Name: *const c_char);
598 pub fn LLVMDumpValue(Val: ValueRef);
599 pub fn LLVMReplaceAllUsesWith(OldVal: ValueRef, NewVal: ValueRef);
600 pub fn LLVMSetMetadata(Val: ValueRef, KindID: c_uint, Node: ValueRef);
601
602 /* Operations on Uses */
603 pub fn LLVMGetFirstUse(Val: ValueRef) -> UseRef;
604 pub fn LLVMGetNextUse(U: UseRef) -> UseRef;
605 pub fn LLVMGetUser(U: UseRef) -> ValueRef;
606 pub fn LLVMGetUsedValue(U: UseRef) -> ValueRef;
607
608 /* Operations on Users */
609 pub fn LLVMGetNumOperands(Val: ValueRef) -> c_int;
610 pub fn LLVMGetOperand(Val: ValueRef, Index: c_uint) -> ValueRef;
611 pub fn LLVMSetOperand(Val: ValueRef, Index: c_uint, Op: ValueRef);
612
613 /* Operations on constants of any type */
614 pub fn LLVMConstNull(Ty: TypeRef) -> ValueRef;
615 /* all zeroes */
616 pub fn LLVMConstAllOnes(Ty: TypeRef) -> ValueRef;
617 pub fn LLVMConstICmp(Pred: IntPredicate, V1: ValueRef, V2: ValueRef)
618 -> ValueRef;
619 pub fn LLVMConstFCmp(Pred: RealPredicate, V1: ValueRef, V2: ValueRef)
620 -> ValueRef;
621 /* only for isize/vector */
622 pub fn LLVMGetUndef(Ty: TypeRef) -> ValueRef;
623 pub fn LLVMIsConstant(Val: ValueRef) -> Bool;
624 pub fn LLVMIsNull(Val: ValueRef) -> Bool;
625 pub fn LLVMIsUndef(Val: ValueRef) -> Bool;
626 pub fn LLVMConstPointerNull(Ty: TypeRef) -> ValueRef;
627
628 /* Operations on metadata */
629 pub fn LLVMMDStringInContext(C: ContextRef,
630 Str: *const c_char,
631 SLen: c_uint)
632 -> ValueRef;
633 pub fn LLVMMDNodeInContext(C: ContextRef,
634 Vals: *const ValueRef,
635 Count: c_uint)
636 -> ValueRef;
637 pub fn LLVMAddNamedMetadataOperand(M: ModuleRef,
638 Str: *const c_char,
639 Val: ValueRef);
640
641 /* Operations on scalar constants */
642 pub fn LLVMConstInt(IntTy: TypeRef, N: c_ulonglong, SignExtend: Bool)
643 -> ValueRef;
644 pub fn LLVMConstIntOfString(IntTy: TypeRef, Text: *const c_char, Radix: u8)
645 -> ValueRef;
646 pub fn LLVMConstIntOfStringAndSize(IntTy: TypeRef,
647 Text: *const c_char,
648 SLen: c_uint,
649 Radix: u8)
650 -> ValueRef;
651 pub fn LLVMConstReal(RealTy: TypeRef, N: f64) -> ValueRef;
652 pub fn LLVMConstRealOfString(RealTy: TypeRef, Text: *const c_char)
653 -> ValueRef;
654 pub fn LLVMConstRealOfStringAndSize(RealTy: TypeRef,
655 Text: *const c_char,
656 SLen: c_uint)
657 -> ValueRef;
658 pub fn LLVMConstIntGetZExtValue(ConstantVal: ValueRef) -> c_ulonglong;
659 pub fn LLVMConstIntGetSExtValue(ConstantVal: ValueRef) -> c_longlong;
660
661
662 /* Operations on composite constants */
663 pub fn LLVMConstStringInContext(C: ContextRef,
664 Str: *const c_char,
665 Length: c_uint,
666 DontNullTerminate: Bool)
667 -> ValueRef;
668 pub fn LLVMConstStructInContext(C: ContextRef,
669 ConstantVals: *const ValueRef,
670 Count: c_uint,
671 Packed: Bool)
672 -> ValueRef;
673
674 pub fn LLVMConstArray(ElementTy: TypeRef,
675 ConstantVals: *const ValueRef,
676 Length: c_uint)
677 -> ValueRef;
678 pub fn LLVMConstVector(ScalarConstantVals: *const ValueRef, Size: c_uint)
679 -> ValueRef;
680
681 /* Constant expressions */
682 pub fn LLVMAlignOf(Ty: TypeRef) -> ValueRef;
683 pub fn LLVMSizeOf(Ty: TypeRef) -> ValueRef;
684 pub fn LLVMConstNeg(ConstantVal: ValueRef) -> ValueRef;
685 pub fn LLVMConstNSWNeg(ConstantVal: ValueRef) -> ValueRef;
686 pub fn LLVMConstNUWNeg(ConstantVal: ValueRef) -> ValueRef;
687 pub fn LLVMConstFNeg(ConstantVal: ValueRef) -> ValueRef;
688 pub fn LLVMConstNot(ConstantVal: ValueRef) -> ValueRef;
689 pub fn LLVMConstAdd(LHSConstant: ValueRef, RHSConstant: ValueRef)
690 -> ValueRef;
691 pub fn LLVMConstNSWAdd(LHSConstant: ValueRef, RHSConstant: ValueRef)
692 -> ValueRef;
693 pub fn LLVMConstNUWAdd(LHSConstant: ValueRef, RHSConstant: ValueRef)
694 -> ValueRef;
695 pub fn LLVMConstFAdd(LHSConstant: ValueRef, RHSConstant: ValueRef)
696 -> ValueRef;
697 pub fn LLVMConstSub(LHSConstant: ValueRef, RHSConstant: ValueRef)
698 -> ValueRef;
699 pub fn LLVMConstNSWSub(LHSConstant: ValueRef, RHSConstant: ValueRef)
700 -> ValueRef;
701 pub fn LLVMConstNUWSub(LHSConstant: ValueRef, RHSConstant: ValueRef)
702 -> ValueRef;
703 pub fn LLVMConstFSub(LHSConstant: ValueRef, RHSConstant: ValueRef)
704 -> ValueRef;
705 pub fn LLVMConstMul(LHSConstant: ValueRef, RHSConstant: ValueRef)
706 -> ValueRef;
707 pub fn LLVMConstNSWMul(LHSConstant: ValueRef, RHSConstant: ValueRef)
708 -> ValueRef;
709 pub fn LLVMConstNUWMul(LHSConstant: ValueRef, RHSConstant: ValueRef)
710 -> ValueRef;
711 pub fn LLVMConstFMul(LHSConstant: ValueRef, RHSConstant: ValueRef)
712 -> ValueRef;
713 pub fn LLVMConstUDiv(LHSConstant: ValueRef, RHSConstant: ValueRef)
714 -> ValueRef;
715 pub fn LLVMConstSDiv(LHSConstant: ValueRef, RHSConstant: ValueRef)
716 -> ValueRef;
717 pub fn LLVMConstExactSDiv(LHSConstant: ValueRef,
718 RHSConstant: ValueRef)
719 -> ValueRef;
720 pub fn LLVMConstFDiv(LHSConstant: ValueRef, RHSConstant: ValueRef)
721 -> ValueRef;
722 pub fn LLVMConstURem(LHSConstant: ValueRef, RHSConstant: ValueRef)
723 -> ValueRef;
724 pub fn LLVMConstSRem(LHSConstant: ValueRef, RHSConstant: ValueRef)
725 -> ValueRef;
726 pub fn LLVMConstFRem(LHSConstant: ValueRef, RHSConstant: ValueRef)
727 -> ValueRef;
728 pub fn LLVMConstAnd(LHSConstant: ValueRef, RHSConstant: ValueRef)
729 -> ValueRef;
730 pub fn LLVMConstOr(LHSConstant: ValueRef, RHSConstant: ValueRef)
731 -> ValueRef;
732 pub fn LLVMConstXor(LHSConstant: ValueRef, RHSConstant: ValueRef)
733 -> ValueRef;
734 pub fn LLVMConstShl(LHSConstant: ValueRef, RHSConstant: ValueRef)
735 -> ValueRef;
736 pub fn LLVMConstLShr(LHSConstant: ValueRef, RHSConstant: ValueRef)
737 -> ValueRef;
738 pub fn LLVMConstAShr(LHSConstant: ValueRef, RHSConstant: ValueRef)
739 -> ValueRef;
740 pub fn LLVMConstGEP(ConstantVal: ValueRef,
741 ConstantIndices: *const ValueRef,
742 NumIndices: c_uint)
743 -> ValueRef;
744 pub fn LLVMConstInBoundsGEP(ConstantVal: ValueRef,
745 ConstantIndices: *const ValueRef,
746 NumIndices: c_uint)
747 -> ValueRef;
748 pub fn LLVMConstTrunc(ConstantVal: ValueRef, ToType: TypeRef)
749 -> ValueRef;
750 pub fn LLVMConstSExt(ConstantVal: ValueRef, ToType: TypeRef)
751 -> ValueRef;
752 pub fn LLVMConstZExt(ConstantVal: ValueRef, ToType: TypeRef)
753 -> ValueRef;
754 pub fn LLVMConstFPTrunc(ConstantVal: ValueRef, ToType: TypeRef)
755 -> ValueRef;
756 pub fn LLVMConstFPExt(ConstantVal: ValueRef, ToType: TypeRef)
757 -> ValueRef;
758 pub fn LLVMConstUIToFP(ConstantVal: ValueRef, ToType: TypeRef)
759 -> ValueRef;
760 pub fn LLVMConstSIToFP(ConstantVal: ValueRef, ToType: TypeRef)
761 -> ValueRef;
762 pub fn LLVMConstFPToUI(ConstantVal: ValueRef, ToType: TypeRef)
763 -> ValueRef;
764 pub fn LLVMConstFPToSI(ConstantVal: ValueRef, ToType: TypeRef)
765 -> ValueRef;
766 pub fn LLVMConstPtrToInt(ConstantVal: ValueRef, ToType: TypeRef)
767 -> ValueRef;
768 pub fn LLVMConstIntToPtr(ConstantVal: ValueRef, ToType: TypeRef)
769 -> ValueRef;
770 pub fn LLVMConstBitCast(ConstantVal: ValueRef, ToType: TypeRef)
771 -> ValueRef;
772 pub fn LLVMConstZExtOrBitCast(ConstantVal: ValueRef, ToType: TypeRef)
773 -> ValueRef;
774 pub fn LLVMConstSExtOrBitCast(ConstantVal: ValueRef, ToType: TypeRef)
775 -> ValueRef;
776 pub fn LLVMConstTruncOrBitCast(ConstantVal: ValueRef, ToType: TypeRef)
777 -> ValueRef;
778 pub fn LLVMConstPointerCast(ConstantVal: ValueRef, ToType: TypeRef)
779 -> ValueRef;
780 pub fn LLVMConstIntCast(ConstantVal: ValueRef,
781 ToType: TypeRef,
782 isSigned: Bool)
783 -> ValueRef;
784 pub fn LLVMConstFPCast(ConstantVal: ValueRef, ToType: TypeRef)
785 -> ValueRef;
786 pub fn LLVMConstSelect(ConstantCondition: ValueRef,
787 ConstantIfTrue: ValueRef,
788 ConstantIfFalse: ValueRef)
789 -> ValueRef;
790 pub fn LLVMConstExtractElement(VectorConstant: ValueRef,
791 IndexConstant: ValueRef)
792 -> ValueRef;
793 pub fn LLVMConstInsertElement(VectorConstant: ValueRef,
794 ElementValueConstant: ValueRef,
795 IndexConstant: ValueRef)
796 -> ValueRef;
797 pub fn LLVMConstShuffleVector(VectorAConstant: ValueRef,
798 VectorBConstant: ValueRef,
799 MaskConstant: ValueRef)
800 -> ValueRef;
801 pub fn LLVMConstExtractValue(AggConstant: ValueRef,
802 IdxList: *const c_uint,
803 NumIdx: c_uint)
804 -> ValueRef;
805 pub fn LLVMConstInsertValue(AggConstant: ValueRef,
806 ElementValueConstant: ValueRef,
807 IdxList: *const c_uint,
808 NumIdx: c_uint)
809 -> ValueRef;
810 pub fn LLVMConstInlineAsm(Ty: TypeRef,
811 AsmString: *const c_char,
812 Constraints: *const c_char,
813 HasSideEffects: Bool,
814 IsAlignStack: Bool)
815 -> ValueRef;
816 pub fn LLVMBlockAddress(F: ValueRef, BB: BasicBlockRef) -> ValueRef;
817
818
819
820 /* Operations on global variables, functions, and aliases (globals) */
821 pub fn LLVMGetGlobalParent(Global: ValueRef) -> ModuleRef;
822 pub fn LLVMIsDeclaration(Global: ValueRef) -> Bool;
823 pub fn LLVMGetLinkage(Global: ValueRef) -> c_uint;
824 pub fn LLVMSetLinkage(Global: ValueRef, Link: Linkage);
825 pub fn LLVMGetSection(Global: ValueRef) -> *const c_char;
826 pub fn LLVMSetSection(Global: ValueRef, Section: *const c_char);
827 pub fn LLVMGetVisibility(Global: ValueRef) -> c_uint;
828 pub fn LLVMSetVisibility(Global: ValueRef, Viz: c_uint);
829 pub fn LLVMGetAlignment(Global: ValueRef) -> c_uint;
830 pub fn LLVMSetAlignment(Global: ValueRef, Bytes: c_uint);
831 pub fn LLVMSetDLLStorageClass(V: ValueRef,
832 C: DLLStorageClass);
833
834
835 /* Operations on global variables */
836 pub fn LLVMIsAGlobalVariable(GlobalVar: ValueRef) -> ValueRef;
837 pub fn LLVMAddGlobal(M: ModuleRef, Ty: TypeRef, Name: *const c_char)
838 -> ValueRef;
839 pub fn LLVMAddGlobalInAddressSpace(M: ModuleRef,
840 Ty: TypeRef,
841 Name: *const c_char,
842 AddressSpace: c_uint)
843 -> ValueRef;
844 pub fn LLVMGetNamedGlobal(M: ModuleRef,
845 Name: *const c_char)
846 -> ValueRef;
847 pub fn LLVMRustGetOrInsertGlobal(M: ModuleRef,
848 Name: *const c_char,
849 T: TypeRef)
850 -> ValueRef;
851 pub fn LLVMGetFirstGlobal(M: ModuleRef) -> ValueRef;
852 pub fn LLVMGetLastGlobal(M: ModuleRef) -> ValueRef;
853 pub fn LLVMGetNextGlobal(GlobalVar: ValueRef) -> ValueRef;
854 pub fn LLVMGetPreviousGlobal(GlobalVar: ValueRef) -> ValueRef;
855 pub fn LLVMDeleteGlobal(GlobalVar: ValueRef);
856 pub fn LLVMGetInitializer(GlobalVar: ValueRef) -> ValueRef;
857 pub fn LLVMSetInitializer(GlobalVar: ValueRef,
858 ConstantVal: ValueRef);
859 pub fn LLVMIsThreadLocal(GlobalVar: ValueRef) -> Bool;
860 pub fn LLVMSetThreadLocal(GlobalVar: ValueRef, IsThreadLocal: Bool);
861 pub fn LLVMIsGlobalConstant(GlobalVar: ValueRef) -> Bool;
862 pub fn LLVMSetGlobalConstant(GlobalVar: ValueRef, IsConstant: Bool);
863 pub fn LLVMRustGetNamedValue(M: ModuleRef, Name: *const c_char) -> ValueRef;
864
865 /* Operations on aliases */
866 pub fn LLVMAddAlias(M: ModuleRef,
867 Ty: TypeRef,
868 Aliasee: ValueRef,
869 Name: *const c_char)
870 -> ValueRef;
871
872 /* Operations on functions */
873 pub fn LLVMAddFunction(M: ModuleRef,
874 Name: *const c_char,
875 FunctionTy: TypeRef)
876 -> ValueRef;
877 pub fn LLVMGetNamedFunction(M: ModuleRef, Name: *const c_char) -> ValueRef;
878 pub fn LLVMGetFirstFunction(M: ModuleRef) -> ValueRef;
879 pub fn LLVMGetLastFunction(M: ModuleRef) -> ValueRef;
880 pub fn LLVMGetNextFunction(Fn: ValueRef) -> ValueRef;
881 pub fn LLVMGetPreviousFunction(Fn: ValueRef) -> ValueRef;
882 pub fn LLVMDeleteFunction(Fn: ValueRef);
883 pub fn LLVMRustGetOrInsertFunction(M: ModuleRef,
884 Name: *const c_char,
885 FunctionTy: TypeRef)
886 -> ValueRef;
887 pub fn LLVMGetIntrinsicID(Fn: ValueRef) -> c_uint;
888 pub fn LLVMGetFunctionCallConv(Fn: ValueRef) -> c_uint;
889 pub fn LLVMSetFunctionCallConv(Fn: ValueRef, CC: c_uint);
890 pub fn LLVMGetGC(Fn: ValueRef) -> *const c_char;
891 pub fn LLVMSetGC(Fn: ValueRef, Name: *const c_char);
892 pub fn LLVMRustAddDereferenceableAttr(Fn: ValueRef, index: c_uint, bytes: u64);
893 pub fn LLVMRustAddFunctionAttribute(Fn: ValueRef, index: c_uint, PA: u64);
894 pub fn LLVMRustAddFunctionAttrString(Fn: ValueRef, index: c_uint, Name: *const c_char);
895 pub fn LLVMRustAddFunctionAttrStringValue(Fn: ValueRef, index: c_uint,
896 Name: *const c_char,
897 Value: *const c_char);
898 pub fn LLVMRustRemoveFunctionAttributes(Fn: ValueRef,
899 index: c_uint,
900 attr: u64);
901 pub fn LLVMRustRemoveFunctionAttrString(Fn: ValueRef,
902 index: c_uint,
903 Name: *const c_char);
904 pub fn LLVMGetFunctionAttr(Fn: ValueRef) -> c_uint;
905 pub fn LLVMRemoveFunctionAttr(Fn: ValueRef, val: c_uint);
906
907 /* Operations on parameters */
908 pub fn LLVMCountParams(Fn: ValueRef) -> c_uint;
909 pub fn LLVMGetParams(Fn: ValueRef, Params: *const ValueRef);
910 pub fn LLVMGetParam(Fn: ValueRef, Index: c_uint) -> ValueRef;
911 pub fn LLVMGetParamParent(Inst: ValueRef) -> ValueRef;
912 pub fn LLVMGetFirstParam(Fn: ValueRef) -> ValueRef;
913 pub fn LLVMGetLastParam(Fn: ValueRef) -> ValueRef;
914 pub fn LLVMGetNextParam(Arg: ValueRef) -> ValueRef;
915 pub fn LLVMGetPreviousParam(Arg: ValueRef) -> ValueRef;
916 pub fn LLVMAddAttribute(Arg: ValueRef, PA: c_uint);
917 pub fn LLVMRemoveAttribute(Arg: ValueRef, PA: c_uint);
918 pub fn LLVMGetAttribute(Arg: ValueRef) -> c_uint;
919 pub fn LLVMSetParamAlignment(Arg: ValueRef, align: c_uint);
920
921 /* Operations on basic blocks */
922 pub fn LLVMBasicBlockAsValue(BB: BasicBlockRef) -> ValueRef;
923 pub fn LLVMValueIsBasicBlock(Val: ValueRef) -> Bool;
924 pub fn LLVMValueAsBasicBlock(Val: ValueRef) -> BasicBlockRef;
925 pub fn LLVMGetBasicBlockParent(BB: BasicBlockRef) -> ValueRef;
926 pub fn LLVMCountBasicBlocks(Fn: ValueRef) -> c_uint;
927 pub fn LLVMGetBasicBlocks(Fn: ValueRef, BasicBlocks: *const ValueRef);
928 pub fn LLVMGetFirstBasicBlock(Fn: ValueRef) -> BasicBlockRef;
929 pub fn LLVMGetLastBasicBlock(Fn: ValueRef) -> BasicBlockRef;
930 pub fn LLVMGetNextBasicBlock(BB: BasicBlockRef) -> BasicBlockRef;
931 pub fn LLVMGetPreviousBasicBlock(BB: BasicBlockRef) -> BasicBlockRef;
932 pub fn LLVMGetEntryBasicBlock(Fn: ValueRef) -> BasicBlockRef;
933
934 pub fn LLVMAppendBasicBlockInContext(C: ContextRef,
935 Fn: ValueRef,
936 Name: *const c_char)
937 -> BasicBlockRef;
938 pub fn LLVMInsertBasicBlockInContext(C: ContextRef,
939 BB: BasicBlockRef,
940 Name: *const c_char)
941 -> BasicBlockRef;
942 pub fn LLVMDeleteBasicBlock(BB: BasicBlockRef);
943
944 pub fn LLVMMoveBasicBlockAfter(BB: BasicBlockRef,
945 MoveAfter: BasicBlockRef);
946
947 pub fn LLVMMoveBasicBlockBefore(BB: BasicBlockRef,
948 MoveBefore: BasicBlockRef);
949
950 /* Operations on instructions */
951 pub fn LLVMGetInstructionParent(Inst: ValueRef) -> BasicBlockRef;
952 pub fn LLVMGetFirstInstruction(BB: BasicBlockRef) -> ValueRef;
953 pub fn LLVMGetLastInstruction(BB: BasicBlockRef) -> ValueRef;
954 pub fn LLVMGetNextInstruction(Inst: ValueRef) -> ValueRef;
955 pub fn LLVMGetPreviousInstruction(Inst: ValueRef) -> ValueRef;
956 pub fn LLVMInstructionEraseFromParent(Inst: ValueRef);
957
958 /* Operations on call sites */
959 pub fn LLVMSetInstructionCallConv(Instr: ValueRef, CC: c_uint);
960 pub fn LLVMGetInstructionCallConv(Instr: ValueRef) -> c_uint;
961 pub fn LLVMAddInstrAttribute(Instr: ValueRef,
962 index: c_uint,
963 IA: c_uint);
964 pub fn LLVMRemoveInstrAttribute(Instr: ValueRef,
965 index: c_uint,
966 IA: c_uint);
967 pub fn LLVMSetInstrParamAlignment(Instr: ValueRef,
968 index: c_uint,
969 align: c_uint);
970 pub fn LLVMRustAddCallSiteAttribute(Instr: ValueRef,
971 index: c_uint,
972 Val: u64);
973 pub fn LLVMRustAddDereferenceableCallSiteAttr(Instr: ValueRef,
974 index: c_uint,
975 bytes: u64);
976
977 /* Operations on call instructions (only) */
978 pub fn LLVMIsTailCall(CallInst: ValueRef) -> Bool;
979 pub fn LLVMSetTailCall(CallInst: ValueRef, IsTailCall: Bool);
980
981 /* Operations on load/store instructions (only) */
982 pub fn LLVMGetVolatile(MemoryAccessInst: ValueRef) -> Bool;
983 pub fn LLVMSetVolatile(MemoryAccessInst: ValueRef, volatile: Bool);
984
985 /* Operations on phi nodes */
986 pub fn LLVMAddIncoming(PhiNode: ValueRef,
987 IncomingValues: *const ValueRef,
988 IncomingBlocks: *const BasicBlockRef,
989 Count: c_uint);
990 pub fn LLVMCountIncoming(PhiNode: ValueRef) -> c_uint;
991 pub fn LLVMGetIncomingValue(PhiNode: ValueRef, Index: c_uint)
992 -> ValueRef;
993 pub fn LLVMGetIncomingBlock(PhiNode: ValueRef, Index: c_uint)
994 -> BasicBlockRef;
995
996 /* Instruction builders */
997 pub fn LLVMCreateBuilderInContext(C: ContextRef) -> BuilderRef;
998 pub fn LLVMPositionBuilder(Builder: BuilderRef,
999 Block: BasicBlockRef,
1000 Instr: ValueRef);
1001 pub fn LLVMPositionBuilderBefore(Builder: BuilderRef,
1002 Instr: ValueRef);
1003 pub fn LLVMPositionBuilderAtEnd(Builder: BuilderRef,
1004 Block: BasicBlockRef);
1005 pub fn LLVMGetInsertBlock(Builder: BuilderRef) -> BasicBlockRef;
1006 pub fn LLVMClearInsertionPosition(Builder: BuilderRef);
1007 pub fn LLVMInsertIntoBuilder(Builder: BuilderRef, Instr: ValueRef);
1008 pub fn LLVMInsertIntoBuilderWithName(Builder: BuilderRef,
1009 Instr: ValueRef,
1010 Name: *const c_char);
1011 pub fn LLVMDisposeBuilder(Builder: BuilderRef);
1012
1013 /* Metadata */
1014 pub fn LLVMSetCurrentDebugLocation(Builder: BuilderRef, L: ValueRef);
1015 pub fn LLVMGetCurrentDebugLocation(Builder: BuilderRef) -> ValueRef;
1016 pub fn LLVMSetInstDebugLocation(Builder: BuilderRef, Inst: ValueRef);
1017
1018 /* Terminators */
1019 pub fn LLVMBuildRetVoid(B: BuilderRef) -> ValueRef;
1020 pub fn LLVMBuildRet(B: BuilderRef, V: ValueRef) -> ValueRef;
1021 pub fn LLVMBuildAggregateRet(B: BuilderRef,
1022 RetVals: *const ValueRef,
1023 N: c_uint)
1024 -> ValueRef;
1025 pub fn LLVMBuildBr(B: BuilderRef, Dest: BasicBlockRef) -> ValueRef;
1026 pub fn LLVMBuildCondBr(B: BuilderRef,
1027 If: ValueRef,
1028 Then: BasicBlockRef,
1029 Else: BasicBlockRef)
1030 -> ValueRef;
1031 pub fn LLVMBuildSwitch(B: BuilderRef,
1032 V: ValueRef,
1033 Else: BasicBlockRef,
1034 NumCases: c_uint)
1035 -> ValueRef;
1036 pub fn LLVMBuildIndirectBr(B: BuilderRef,
1037 Addr: ValueRef,
1038 NumDests: c_uint)
1039 -> ValueRef;
1040 pub fn LLVMRustBuildInvoke(B: BuilderRef,
1041 Fn: ValueRef,
1042 Args: *const ValueRef,
1043 NumArgs: c_uint,
1044 Then: BasicBlockRef,
1045 Catch: BasicBlockRef,
1046 Bundle: OperandBundleDefRef,
1047 Name: *const c_char)
1048 -> ValueRef;
1049 pub fn LLVMRustBuildLandingPad(B: BuilderRef,
1050 Ty: TypeRef,
1051 PersFn: ValueRef,
1052 NumClauses: c_uint,
1053 Name: *const c_char,
1054 F: ValueRef)
1055 -> ValueRef;
1056 pub fn LLVMBuildResume(B: BuilderRef, Exn: ValueRef) -> ValueRef;
1057 pub fn LLVMBuildUnreachable(B: BuilderRef) -> ValueRef;
1058
1059 pub fn LLVMRustBuildCleanupPad(B: BuilderRef,
1060 ParentPad: ValueRef,
1061 ArgCnt: c_uint,
1062 Args: *const ValueRef,
1063 Name: *const c_char) -> ValueRef;
1064 pub fn LLVMRustBuildCleanupRet(B: BuilderRef,
1065 CleanupPad: ValueRef,
1066 UnwindBB: BasicBlockRef) -> ValueRef;
1067 pub fn LLVMRustBuildCatchPad(B: BuilderRef,
1068 ParentPad: ValueRef,
1069 ArgCnt: c_uint,
1070 Args: *const ValueRef,
1071 Name: *const c_char) -> ValueRef;
1072 pub fn LLVMRustBuildCatchRet(B: BuilderRef,
1073 Pad: ValueRef,
1074 BB: BasicBlockRef) -> ValueRef;
1075 pub fn LLVMRustBuildCatchSwitch(Builder: BuilderRef,
1076 ParentPad: ValueRef,
1077 BB: BasicBlockRef,
1078 NumHandlers: c_uint,
1079 Name: *const c_char) -> ValueRef;
1080 pub fn LLVMRustAddHandler(CatchSwitch: ValueRef,
1081 Handler: BasicBlockRef);
1082 pub fn LLVMRustSetPersonalityFn(B: BuilderRef, Pers: ValueRef);
1083
1084 /* Add a case to the switch instruction */
1085 pub fn LLVMAddCase(Switch: ValueRef,
1086 OnVal: ValueRef,
1087 Dest: BasicBlockRef);
1088
1089 /* Add a destination to the indirectbr instruction */
1090 pub fn LLVMAddDestination(IndirectBr: ValueRef, Dest: BasicBlockRef);
1091
1092 /* Add a clause to the landing pad instruction */
1093 pub fn LLVMAddClause(LandingPad: ValueRef, ClauseVal: ValueRef);
1094
1095 /* Set the cleanup on a landing pad instruction */
1096 pub fn LLVMSetCleanup(LandingPad: ValueRef, Val: Bool);
1097
1098 /* Arithmetic */
1099 pub fn LLVMBuildAdd(B: BuilderRef,
1100 LHS: ValueRef,
1101 RHS: ValueRef,
1102 Name: *const c_char)
1103 -> ValueRef;
1104 pub fn LLVMBuildNSWAdd(B: BuilderRef,
1105 LHS: ValueRef,
1106 RHS: ValueRef,
1107 Name: *const c_char)
1108 -> ValueRef;
1109 pub fn LLVMBuildNUWAdd(B: BuilderRef,
1110 LHS: ValueRef,
1111 RHS: ValueRef,
1112 Name: *const c_char)
1113 -> ValueRef;
1114 pub fn LLVMBuildFAdd(B: BuilderRef,
1115 LHS: ValueRef,
1116 RHS: ValueRef,
1117 Name: *const c_char)
1118 -> ValueRef;
1119 pub fn LLVMBuildSub(B: BuilderRef,
1120 LHS: ValueRef,
1121 RHS: ValueRef,
1122 Name: *const c_char)
1123 -> ValueRef;
1124 pub fn LLVMBuildNSWSub(B: BuilderRef,
1125 LHS: ValueRef,
1126 RHS: ValueRef,
1127 Name: *const c_char)
1128 -> ValueRef;
1129 pub fn LLVMBuildNUWSub(B: BuilderRef,
1130 LHS: ValueRef,
1131 RHS: ValueRef,
1132 Name: *const c_char)
1133 -> ValueRef;
1134 pub fn LLVMBuildFSub(B: BuilderRef,
1135 LHS: ValueRef,
1136 RHS: ValueRef,
1137 Name: *const c_char)
1138 -> ValueRef;
1139 pub fn LLVMBuildMul(B: BuilderRef,
1140 LHS: ValueRef,
1141 RHS: ValueRef,
1142 Name: *const c_char)
1143 -> ValueRef;
1144 pub fn LLVMBuildNSWMul(B: BuilderRef,
1145 LHS: ValueRef,
1146 RHS: ValueRef,
1147 Name: *const c_char)
1148 -> ValueRef;
1149 pub fn LLVMBuildNUWMul(B: BuilderRef,
1150 LHS: ValueRef,
1151 RHS: ValueRef,
1152 Name: *const c_char)
1153 -> ValueRef;
1154 pub fn LLVMBuildFMul(B: BuilderRef,
1155 LHS: ValueRef,
1156 RHS: ValueRef,
1157 Name: *const c_char)
1158 -> ValueRef;
1159 pub fn LLVMBuildUDiv(B: BuilderRef,
1160 LHS: ValueRef,
1161 RHS: ValueRef,
1162 Name: *const c_char)
1163 -> ValueRef;
1164 pub fn LLVMBuildSDiv(B: BuilderRef,
1165 LHS: ValueRef,
1166 RHS: ValueRef,
1167 Name: *const c_char)
1168 -> ValueRef;
1169 pub fn LLVMBuildExactSDiv(B: BuilderRef,
1170 LHS: ValueRef,
1171 RHS: ValueRef,
1172 Name: *const c_char)
1173 -> ValueRef;
1174 pub fn LLVMBuildFDiv(B: BuilderRef,
1175 LHS: ValueRef,
1176 RHS: ValueRef,
1177 Name: *const c_char)
1178 -> ValueRef;
1179 pub fn LLVMBuildURem(B: BuilderRef,
1180 LHS: ValueRef,
1181 RHS: ValueRef,
1182 Name: *const c_char)
1183 -> ValueRef;
1184 pub fn LLVMBuildSRem(B: BuilderRef,
1185 LHS: ValueRef,
1186 RHS: ValueRef,
1187 Name: *const c_char)
1188 -> ValueRef;
1189 pub fn LLVMBuildFRem(B: BuilderRef,
1190 LHS: ValueRef,
1191 RHS: ValueRef,
1192 Name: *const c_char)
1193 -> ValueRef;
1194 pub fn LLVMBuildShl(B: BuilderRef,
1195 LHS: ValueRef,
1196 RHS: ValueRef,
1197 Name: *const c_char)
1198 -> ValueRef;
1199 pub fn LLVMBuildLShr(B: BuilderRef,
1200 LHS: ValueRef,
1201 RHS: ValueRef,
1202 Name: *const c_char)
1203 -> ValueRef;
1204 pub fn LLVMBuildAShr(B: BuilderRef,
1205 LHS: ValueRef,
1206 RHS: ValueRef,
1207 Name: *const c_char)
1208 -> ValueRef;
1209 pub fn LLVMBuildAnd(B: BuilderRef,
1210 LHS: ValueRef,
1211 RHS: ValueRef,
1212 Name: *const c_char)
1213 -> ValueRef;
1214 pub fn LLVMBuildOr(B: BuilderRef,
1215 LHS: ValueRef,
1216 RHS: ValueRef,
1217 Name: *const c_char)
1218 -> ValueRef;
1219 pub fn LLVMBuildXor(B: BuilderRef,
1220 LHS: ValueRef,
1221 RHS: ValueRef,
1222 Name: *const c_char)
1223 -> ValueRef;
1224 pub fn LLVMBuildBinOp(B: BuilderRef,
1225 Op: Opcode,
1226 LHS: ValueRef,
1227 RHS: ValueRef,
1228 Name: *const c_char)
1229 -> ValueRef;
1230 pub fn LLVMBuildNeg(B: BuilderRef, V: ValueRef, Name: *const c_char)
1231 -> ValueRef;
1232 pub fn LLVMBuildNSWNeg(B: BuilderRef, V: ValueRef, Name: *const c_char)
1233 -> ValueRef;
1234 pub fn LLVMBuildNUWNeg(B: BuilderRef, V: ValueRef, Name: *const c_char)
1235 -> ValueRef;
1236 pub fn LLVMBuildFNeg(B: BuilderRef, V: ValueRef, Name: *const c_char)
1237 -> ValueRef;
1238 pub fn LLVMBuildNot(B: BuilderRef, V: ValueRef, Name: *const c_char)
1239 -> ValueRef;
1240 pub fn LLVMRustSetHasUnsafeAlgebra(Instr: ValueRef);
1241
1242 /* Memory */
1243 pub fn LLVMBuildAlloca(B: BuilderRef, Ty: TypeRef, Name: *const c_char)
1244 -> ValueRef;
1245 pub fn LLVMBuildFree(B: BuilderRef, PointerVal: ValueRef) -> ValueRef;
1246 pub fn LLVMBuildLoad(B: BuilderRef,
1247 PointerVal: ValueRef,
1248 Name: *const c_char)
1249 -> ValueRef;
1250
1251 pub fn LLVMBuildStore(B: BuilderRef, Val: ValueRef, Ptr: ValueRef)
1252 -> ValueRef;
1253
1254 pub fn LLVMBuildGEP(B: BuilderRef,
1255 Pointer: ValueRef,
1256 Indices: *const ValueRef,
1257 NumIndices: c_uint,
1258 Name: *const c_char)
1259 -> ValueRef;
1260 pub fn LLVMBuildInBoundsGEP(B: BuilderRef,
1261 Pointer: ValueRef,
1262 Indices: *const ValueRef,
1263 NumIndices: c_uint,
1264 Name: *const c_char)
1265 -> ValueRef;
1266 pub fn LLVMBuildStructGEP(B: BuilderRef,
1267 Pointer: ValueRef,
1268 Idx: c_uint,
1269 Name: *const c_char)
1270 -> ValueRef;
1271 pub fn LLVMBuildGlobalString(B: BuilderRef,
1272 Str: *const c_char,
1273 Name: *const c_char)
1274 -> ValueRef;
1275 pub fn LLVMBuildGlobalStringPtr(B: BuilderRef,
1276 Str: *const c_char,
1277 Name: *const c_char)
1278 -> ValueRef;
1279
1280 /* Casts */
1281 pub fn LLVMBuildTrunc(B: BuilderRef,
1282 Val: ValueRef,
1283 DestTy: TypeRef,
1284 Name: *const c_char)
1285 -> ValueRef;
1286 pub fn LLVMBuildZExt(B: BuilderRef,
1287 Val: ValueRef,
1288 DestTy: TypeRef,
1289 Name: *const c_char)
1290 -> ValueRef;
1291 pub fn LLVMBuildSExt(B: BuilderRef,
1292 Val: ValueRef,
1293 DestTy: TypeRef,
1294 Name: *const c_char)
1295 -> ValueRef;
1296 pub fn LLVMBuildFPToUI(B: BuilderRef,
1297 Val: ValueRef,
1298 DestTy: TypeRef,
1299 Name: *const c_char)
1300 -> ValueRef;
1301 pub fn LLVMBuildFPToSI(B: BuilderRef,
1302 Val: ValueRef,
1303 DestTy: TypeRef,
1304 Name: *const c_char)
1305 -> ValueRef;
1306 pub fn LLVMBuildUIToFP(B: BuilderRef,
1307 Val: ValueRef,
1308 DestTy: TypeRef,
1309 Name: *const c_char)
1310 -> ValueRef;
1311 pub fn LLVMBuildSIToFP(B: BuilderRef,
1312 Val: ValueRef,
1313 DestTy: TypeRef,
1314 Name: *const c_char)
1315 -> ValueRef;
1316 pub fn LLVMBuildFPTrunc(B: BuilderRef,
1317 Val: ValueRef,
1318 DestTy: TypeRef,
1319 Name: *const c_char)
1320 -> ValueRef;
1321 pub fn LLVMBuildFPExt(B: BuilderRef,
1322 Val: ValueRef,
1323 DestTy: TypeRef,
1324 Name: *const c_char)
1325 -> ValueRef;
1326 pub fn LLVMBuildPtrToInt(B: BuilderRef,
1327 Val: ValueRef,
1328 DestTy: TypeRef,
1329 Name: *const c_char)
1330 -> ValueRef;
1331 pub fn LLVMBuildIntToPtr(B: BuilderRef,
1332 Val: ValueRef,
1333 DestTy: TypeRef,
1334 Name: *const c_char)
1335 -> ValueRef;
1336 pub fn LLVMBuildBitCast(B: BuilderRef,
1337 Val: ValueRef,
1338 DestTy: TypeRef,
1339 Name: *const c_char)
1340 -> ValueRef;
1341 pub fn LLVMBuildZExtOrBitCast(B: BuilderRef,
1342 Val: ValueRef,
1343 DestTy: TypeRef,
1344 Name: *const c_char)
1345 -> ValueRef;
1346 pub fn LLVMBuildSExtOrBitCast(B: BuilderRef,
1347 Val: ValueRef,
1348 DestTy: TypeRef,
1349 Name: *const c_char)
1350 -> ValueRef;
1351 pub fn LLVMBuildTruncOrBitCast(B: BuilderRef,
1352 Val: ValueRef,
1353 DestTy: TypeRef,
1354 Name: *const c_char)
1355 -> ValueRef;
1356 pub fn LLVMBuildCast(B: BuilderRef,
1357 Op: Opcode,
1358 Val: ValueRef,
1359 DestTy: TypeRef,
1360 Name: *const c_char) -> ValueRef;
1361 pub fn LLVMBuildPointerCast(B: BuilderRef,
1362 Val: ValueRef,
1363 DestTy: TypeRef,
1364 Name: *const c_char)
1365 -> ValueRef;
1366 pub fn LLVMBuildIntCast(B: BuilderRef,
1367 Val: ValueRef,
1368 DestTy: TypeRef,
1369 Name: *const c_char)
1370 -> ValueRef;
1371 pub fn LLVMBuildFPCast(B: BuilderRef,
1372 Val: ValueRef,
1373 DestTy: TypeRef,
1374 Name: *const c_char)
1375 -> ValueRef;
1376
1377 /* Comparisons */
1378 pub fn LLVMBuildICmp(B: BuilderRef,
1379 Op: c_uint,
1380 LHS: ValueRef,
1381 RHS: ValueRef,
1382 Name: *const c_char)
1383 -> ValueRef;
1384 pub fn LLVMBuildFCmp(B: BuilderRef,
1385 Op: c_uint,
1386 LHS: ValueRef,
1387 RHS: ValueRef,
1388 Name: *const c_char)
1389 -> ValueRef;
1390
1391 /* Miscellaneous instructions */
1392 pub fn LLVMBuildPhi(B: BuilderRef, Ty: TypeRef, Name: *const c_char)
1393 -> ValueRef;
1394 pub fn LLVMRustBuildCall(B: BuilderRef,
1395 Fn: ValueRef,
1396 Args: *const ValueRef,
1397 NumArgs: c_uint,
1398 Bundle: OperandBundleDefRef,
1399 Name: *const c_char)
1400 -> ValueRef;
1401 pub fn LLVMBuildSelect(B: BuilderRef,
1402 If: ValueRef,
1403 Then: ValueRef,
1404 Else: ValueRef,
1405 Name: *const c_char)
1406 -> ValueRef;
1407 pub fn LLVMBuildVAArg(B: BuilderRef,
1408 list: ValueRef,
1409 Ty: TypeRef,
1410 Name: *const c_char)
1411 -> ValueRef;
1412 pub fn LLVMBuildExtractElement(B: BuilderRef,
1413 VecVal: ValueRef,
1414 Index: ValueRef,
1415 Name: *const c_char)
1416 -> ValueRef;
1417 pub fn LLVMBuildInsertElement(B: BuilderRef,
1418 VecVal: ValueRef,
1419 EltVal: ValueRef,
1420 Index: ValueRef,
1421 Name: *const c_char)
1422 -> ValueRef;
1423 pub fn LLVMBuildShuffleVector(B: BuilderRef,
1424 V1: ValueRef,
1425 V2: ValueRef,
1426 Mask: ValueRef,
1427 Name: *const c_char)
1428 -> ValueRef;
1429 pub fn LLVMBuildExtractValue(B: BuilderRef,
1430 AggVal: ValueRef,
1431 Index: c_uint,
1432 Name: *const c_char)
1433 -> ValueRef;
1434 pub fn LLVMBuildInsertValue(B: BuilderRef,
1435 AggVal: ValueRef,
1436 EltVal: ValueRef,
1437 Index: c_uint,
1438 Name: *const c_char)
1439 -> ValueRef;
1440
1441 pub fn LLVMBuildIsNull(B: BuilderRef, Val: ValueRef, Name: *const c_char)
1442 -> ValueRef;
1443 pub fn LLVMBuildIsNotNull(B: BuilderRef, Val: ValueRef, Name: *const c_char)
1444 -> ValueRef;
1445 pub fn LLVMBuildPtrDiff(B: BuilderRef,
1446 LHS: ValueRef,
1447 RHS: ValueRef,
1448 Name: *const c_char)
1449 -> ValueRef;
1450
1451 /* Atomic Operations */
1452 pub fn LLVMRustBuildAtomicLoad(B: BuilderRef,
1453 PointerVal: ValueRef,
1454 Name: *const c_char,
1455 Order: AtomicOrdering,
1456 Alignment: c_uint)
1457 -> ValueRef;
1458
1459 pub fn LLVMRustBuildAtomicStore(B: BuilderRef,
1460 Val: ValueRef,
1461 Ptr: ValueRef,
1462 Order: AtomicOrdering,
1463 Alignment: c_uint)
1464 -> ValueRef;
1465
1466 pub fn LLVMRustBuildAtomicCmpXchg(B: BuilderRef,
1467 LHS: ValueRef,
1468 CMP: ValueRef,
1469 RHS: ValueRef,
1470 Order: AtomicOrdering,
1471 FailureOrder: AtomicOrdering,
1472 Weak: Bool)
1473 -> ValueRef;
1474
1475 pub fn LLVMBuildAtomicRMW(B: BuilderRef,
1476 Op: AtomicRmwBinOp,
1477 LHS: ValueRef,
1478 RHS: ValueRef,
1479 Order: AtomicOrdering,
1480 SingleThreaded: Bool)
1481 -> ValueRef;
1482
1483 pub fn LLVMRustBuildAtomicFence(B: BuilderRef,
1484 Order: AtomicOrdering,
1485 Scope: SynchronizationScope);
1486
1487
1488 /* Selected entries from the downcasts. */
1489 pub fn LLVMIsATerminatorInst(Inst: ValueRef) -> ValueRef;
1490 pub fn LLVMIsAStoreInst(Inst: ValueRef) -> ValueRef;
1491
1492 /// Writes a module to the specified path. Returns 0 on success.
1493 pub fn LLVMWriteBitcodeToFile(M: ModuleRef, Path: *const c_char) -> c_int;
1494
1495 /// Creates target data from a target layout string.
1496 pub fn LLVMCreateTargetData(StringRep: *const c_char) -> TargetDataRef;
1497 /// Number of bytes clobbered when doing a Store to *T.
1498 pub fn LLVMStoreSizeOfType(TD: TargetDataRef, Ty: TypeRef)
1499 -> c_ulonglong;
1500
1501 /// Number of bytes clobbered when doing a Store to *T.
1502 pub fn LLVMSizeOfTypeInBits(TD: TargetDataRef, Ty: TypeRef)
1503 -> c_ulonglong;
1504
1505 /// Distance between successive elements in an array of T. Includes ABI padding.
1506 pub fn LLVMABISizeOfType(TD: TargetDataRef, Ty: TypeRef) -> c_ulonglong;
1507
1508 /// Returns the preferred alignment of a type.
1509 pub fn LLVMPreferredAlignmentOfType(TD: TargetDataRef, Ty: TypeRef)
1510 -> c_uint;
1511 /// Returns the minimum alignment of a type.
1512 pub fn LLVMABIAlignmentOfType(TD: TargetDataRef, Ty: TypeRef)
1513 -> c_uint;
1514
1515 /// Computes the byte offset of the indexed struct element for a
1516 /// target.
1517 pub fn LLVMOffsetOfElement(TD: TargetDataRef,
1518 StructTy: TypeRef,
1519 Element: c_uint)
1520 -> c_ulonglong;
1521
1522 /// Returns the minimum alignment of a type when part of a call frame.
1523 pub fn LLVMCallFrameAlignmentOfType(TD: TargetDataRef, Ty: TypeRef)
1524 -> c_uint;
1525
1526 /// Disposes target data.
1527 pub fn LLVMDisposeTargetData(TD: TargetDataRef);
1528
1529 /// Creates a pass manager.
1530 pub fn LLVMCreatePassManager() -> PassManagerRef;
1531
1532 /// Creates a function-by-function pass manager
1533 pub fn LLVMCreateFunctionPassManagerForModule(M: ModuleRef)
1534 -> PassManagerRef;
1535
1536 /// Disposes a pass manager.
1537 pub fn LLVMDisposePassManager(PM: PassManagerRef);
1538
1539 /// Runs a pass manager on a module.
1540 pub fn LLVMRunPassManager(PM: PassManagerRef, M: ModuleRef) -> Bool;
1541
1542 /// Runs the function passes on the provided function.
1543 pub fn LLVMRunFunctionPassManager(FPM: PassManagerRef, F: ValueRef)
1544 -> Bool;
1545
1546 /// Initializes all the function passes scheduled in the manager
1547 pub fn LLVMInitializeFunctionPassManager(FPM: PassManagerRef) -> Bool;
1548
1549 /// Finalizes all the function passes scheduled in the manager
1550 pub fn LLVMFinalizeFunctionPassManager(FPM: PassManagerRef) -> Bool;
1551
1552 pub fn LLVMInitializePasses();
1553
1554 /// Adds a verification pass.
1555 pub fn LLVMAddVerifierPass(PM: PassManagerRef);
1556
1557 pub fn LLVMAddGlobalOptimizerPass(PM: PassManagerRef);
1558 pub fn LLVMAddIPSCCPPass(PM: PassManagerRef);
1559 pub fn LLVMAddDeadArgEliminationPass(PM: PassManagerRef);
1560 pub fn LLVMAddInstructionCombiningPass(PM: PassManagerRef);
1561 pub fn LLVMAddCFGSimplificationPass(PM: PassManagerRef);
1562 pub fn LLVMAddFunctionInliningPass(PM: PassManagerRef);
1563 pub fn LLVMAddFunctionAttrsPass(PM: PassManagerRef);
1564 pub fn LLVMAddScalarReplAggregatesPass(PM: PassManagerRef);
1565 pub fn LLVMAddScalarReplAggregatesPassSSA(PM: PassManagerRef);
1566 pub fn LLVMAddJumpThreadingPass(PM: PassManagerRef);
1567 pub fn LLVMAddConstantPropagationPass(PM: PassManagerRef);
1568 pub fn LLVMAddReassociatePass(PM: PassManagerRef);
1569 pub fn LLVMAddLoopRotatePass(PM: PassManagerRef);
1570 pub fn LLVMAddLICMPass(PM: PassManagerRef);
1571 pub fn LLVMAddLoopUnswitchPass(PM: PassManagerRef);
1572 pub fn LLVMAddLoopDeletionPass(PM: PassManagerRef);
1573 pub fn LLVMAddLoopUnrollPass(PM: PassManagerRef);
1574 pub fn LLVMAddGVNPass(PM: PassManagerRef);
1575 pub fn LLVMAddMemCpyOptPass(PM: PassManagerRef);
1576 pub fn LLVMAddSCCPPass(PM: PassManagerRef);
1577 pub fn LLVMAddDeadStoreEliminationPass(PM: PassManagerRef);
1578 pub fn LLVMAddStripDeadPrototypesPass(PM: PassManagerRef);
1579 pub fn LLVMAddConstantMergePass(PM: PassManagerRef);
1580 pub fn LLVMAddArgumentPromotionPass(PM: PassManagerRef);
1581 pub fn LLVMAddTailCallEliminationPass(PM: PassManagerRef);
1582 pub fn LLVMAddIndVarSimplifyPass(PM: PassManagerRef);
1583 pub fn LLVMAddAggressiveDCEPass(PM: PassManagerRef);
1584 pub fn LLVMAddGlobalDCEPass(PM: PassManagerRef);
1585 pub fn LLVMAddCorrelatedValuePropagationPass(PM: PassManagerRef);
1586 pub fn LLVMAddPruneEHPass(PM: PassManagerRef);
1587 pub fn LLVMAddSimplifyLibCallsPass(PM: PassManagerRef);
1588 pub fn LLVMAddLoopIdiomPass(PM: PassManagerRef);
1589 pub fn LLVMAddEarlyCSEPass(PM: PassManagerRef);
1590 pub fn LLVMAddTypeBasedAliasAnalysisPass(PM: PassManagerRef);
1591 pub fn LLVMAddBasicAliasAnalysisPass(PM: PassManagerRef);
1592
1593 pub fn LLVMPassManagerBuilderCreate() -> PassManagerBuilderRef;
1594 pub fn LLVMPassManagerBuilderDispose(PMB: PassManagerBuilderRef);
1595 pub fn LLVMPassManagerBuilderSetOptLevel(PMB: PassManagerBuilderRef,
1596 OptimizationLevel: c_uint);
1597 pub fn LLVMPassManagerBuilderSetSizeLevel(PMB: PassManagerBuilderRef,
1598 Value: Bool);
1599 pub fn LLVMPassManagerBuilderSetDisableUnitAtATime(
1600 PMB: PassManagerBuilderRef,
1601 Value: Bool);
1602 pub fn LLVMPassManagerBuilderSetDisableUnrollLoops(
1603 PMB: PassManagerBuilderRef,
1604 Value: Bool);
1605 pub fn LLVMPassManagerBuilderSetDisableSimplifyLibCalls(
1606 PMB: PassManagerBuilderRef,
1607 Value: Bool);
1608 pub fn LLVMPassManagerBuilderUseInlinerWithThreshold(
1609 PMB: PassManagerBuilderRef,
1610 threshold: c_uint);
1611 pub fn LLVMPassManagerBuilderPopulateModulePassManager(
1612 PMB: PassManagerBuilderRef,
1613 PM: PassManagerRef);
1614
1615 pub fn LLVMPassManagerBuilderPopulateFunctionPassManager(
1616 PMB: PassManagerBuilderRef,
1617 PM: PassManagerRef);
1618 pub fn LLVMPassManagerBuilderPopulateLTOPassManager(
1619 PMB: PassManagerBuilderRef,
1620 PM: PassManagerRef,
1621 Internalize: Bool,
1622 RunInliner: Bool);
1623
1624 /// Destroys a memory buffer.
1625 pub fn LLVMDisposeMemoryBuffer(MemBuf: MemoryBufferRef);
1626
1627
1628 /* Stuff that's in rustllvm/ because it's not upstream yet. */
1629
1630 /// Opens an object file.
1631 pub fn LLVMCreateObjectFile(MemBuf: MemoryBufferRef) -> ObjectFileRef;
1632 /// Closes an object file.
1633 pub fn LLVMDisposeObjectFile(ObjFile: ObjectFileRef);
1634
1635 /// Enumerates the sections in an object file.
1636 pub fn LLVMGetSections(ObjFile: ObjectFileRef) -> SectionIteratorRef;
1637 /// Destroys a section iterator.
1638 pub fn LLVMDisposeSectionIterator(SI: SectionIteratorRef);
1639 /// Returns true if the section iterator is at the end of the section
1640 /// list:
1641 pub fn LLVMIsSectionIteratorAtEnd(ObjFile: ObjectFileRef,
1642 SI: SectionIteratorRef)
1643 -> Bool;
1644 /// Moves the section iterator to point to the next section.
1645 pub fn LLVMMoveToNextSection(SI: SectionIteratorRef);
1646 /// Returns the current section size.
1647 pub fn LLVMGetSectionSize(SI: SectionIteratorRef) -> c_ulonglong;
1648 /// Returns the current section contents as a string buffer.
1649 pub fn LLVMGetSectionContents(SI: SectionIteratorRef) -> *const c_char;
1650
1651 /// Reads the given file and returns it as a memory buffer. Use
1652 /// LLVMDisposeMemoryBuffer() to get rid of it.
1653 pub fn LLVMRustCreateMemoryBufferWithContentsOfFile(Path: *const c_char)
1654 -> MemoryBufferRef;
1655 /// Borrows the contents of the memory buffer (doesn't copy it)
1656 pub fn LLVMCreateMemoryBufferWithMemoryRange(InputData: *const c_char,
1657 InputDataLength: size_t,
1658 BufferName: *const c_char,
1659 RequiresNull: Bool)
1660 -> MemoryBufferRef;
1661 pub fn LLVMCreateMemoryBufferWithMemoryRangeCopy(InputData: *const c_char,
1662 InputDataLength: size_t,
1663 BufferName: *const c_char)
1664 -> MemoryBufferRef;
1665
1666 pub fn LLVMIsMultithreaded() -> Bool;
1667 pub fn LLVMStartMultithreaded() -> Bool;
1668
1669 /// Returns a string describing the last error caused by an LLVMRust* call.
1670 pub fn LLVMRustGetLastError() -> *const c_char;
1671
1672 /// Print the pass timings since static dtors aren't picking them up.
1673 pub fn LLVMRustPrintPassTimings();
1674
1675 pub fn LLVMStructCreateNamed(C: ContextRef, Name: *const c_char) -> TypeRef;
1676
1677 pub fn LLVMStructSetBody(StructTy: TypeRef,
1678 ElementTypes: *const TypeRef,
1679 ElementCount: c_uint,
1680 Packed: Bool);
1681
1682 pub fn LLVMConstNamedStruct(S: TypeRef,
1683 ConstantVals: *const ValueRef,
1684 Count: c_uint)
1685 -> ValueRef;
1686
1687 /// Enables LLVM debug output.
1688 pub fn LLVMRustSetDebug(Enabled: c_int);
1689
1690 /// Prepares inline assembly.
1691 pub fn LLVMRustInlineAsm(Ty: TypeRef,
1692 AsmString: *const c_char,
1693 Constraints: *const c_char,
1694 SideEffects: Bool,
1695 AlignStack: Bool,
1696 Dialect: AsmDialect)
1697 -> ValueRef;
1698
1699 pub fn LLVMRustDebugMetadataVersion() -> u32;
1700 pub fn LLVMRustVersionMajor() -> u32;
1701 pub fn LLVMRustVersionMinor() -> u32;
1702
1703 pub fn LLVMRustAddModuleFlag(M: ModuleRef,
1704 name: *const c_char,
1705 value: u32);
1706
1707 pub fn LLVMRustDIBuilderCreate(M: ModuleRef) -> DIBuilderRef;
1708
1709 pub fn LLVMRustDIBuilderDispose(Builder: DIBuilderRef);
1710
1711 pub fn LLVMRustDIBuilderFinalize(Builder: DIBuilderRef);
1712
1713 pub fn LLVMRustDIBuilderCreateCompileUnit(Builder: DIBuilderRef,
1714 Lang: c_uint,
1715 File: *const c_char,
1716 Dir: *const c_char,
1717 Producer: *const c_char,
1718 isOptimized: bool,
1719 Flags: *const c_char,
1720 RuntimeVer: c_uint,
1721 SplitName: *const c_char)
1722 -> DIDescriptor;
1723
1724 pub fn LLVMRustDIBuilderCreateFile(Builder: DIBuilderRef,
1725 Filename: *const c_char,
1726 Directory: *const c_char)
1727 -> DIFile;
1728
1729 pub fn LLVMRustDIBuilderCreateSubroutineType(Builder: DIBuilderRef,
1730 File: DIFile,
1731 ParameterTypes: DIArray)
1732 -> DICompositeType;
1733
1734 pub fn LLVMRustDIBuilderCreateFunction(Builder: DIBuilderRef,
1735 Scope: DIDescriptor,
1736 Name: *const c_char,
1737 LinkageName: *const c_char,
1738 File: DIFile,
1739 LineNo: c_uint,
1740 Ty: DIType,
1741 isLocalToUnit: bool,
1742 isDefinition: bool,
1743 ScopeLine: c_uint,
1744 Flags: c_uint,
1745 isOptimized: bool,
1746 Fn: ValueRef,
1747 TParam: DIArray,
1748 Decl: DIDescriptor)
1749 -> DISubprogram;
1750
1751 pub fn LLVMRustDIBuilderCreateBasicType(Builder: DIBuilderRef,
1752 Name: *const c_char,
1753 SizeInBits: u64,
1754 AlignInBits: u64,
1755 Encoding: c_uint)
1756 -> DIBasicType;
1757
1758 pub fn LLVMRustDIBuilderCreatePointerType(Builder: DIBuilderRef,
1759 PointeeTy: DIType,
1760 SizeInBits: u64,
1761 AlignInBits: u64,
1762 Name: *const c_char)
1763 -> DIDerivedType;
1764
1765 pub fn LLVMRustDIBuilderCreateStructType(Builder: DIBuilderRef,
1766 Scope: DIDescriptor,
1767 Name: *const c_char,
1768 File: DIFile,
1769 LineNumber: c_uint,
1770 SizeInBits: u64,
1771 AlignInBits: u64,
1772 Flags: c_uint,
1773 DerivedFrom: DIType,
1774 Elements: DIArray,
1775 RunTimeLang: c_uint,
1776 VTableHolder: DIType,
1777 UniqueId: *const c_char)
1778 -> DICompositeType;
1779
1780 pub fn LLVMRustDIBuilderCreateMemberType(Builder: DIBuilderRef,
1781 Scope: DIDescriptor,
1782 Name: *const c_char,
1783 File: DIFile,
1784 LineNo: c_uint,
1785 SizeInBits: u64,
1786 AlignInBits: u64,
1787 OffsetInBits: u64,
1788 Flags: c_uint,
1789 Ty: DIType)
1790 -> DIDerivedType;
1791
1792 pub fn LLVMRustDIBuilderCreateLexicalBlock(Builder: DIBuilderRef,
1793 Scope: DIScope,
1794 File: DIFile,
1795 Line: c_uint,
1796 Col: c_uint)
1797 -> DILexicalBlock;
1798
1799 pub fn LLVMRustDIBuilderCreateStaticVariable(Builder: DIBuilderRef,
1800 Context: DIScope,
1801 Name: *const c_char,
1802 LinkageName: *const c_char,
1803 File: DIFile,
1804 LineNo: c_uint,
1805 Ty: DIType,
1806 isLocalToUnit: bool,
1807 Val: ValueRef,
1808 Decl: DIDescriptor)
1809 -> DIGlobalVariable;
1810
1811 pub fn LLVMRustDIBuilderCreateVariable(Builder: DIBuilderRef,
1812 Tag: c_uint,
1813 Scope: DIDescriptor,
1814 Name: *const c_char,
1815 File: DIFile,
1816 LineNo: c_uint,
1817 Ty: DIType,
1818 AlwaysPreserve: bool,
1819 Flags: c_uint,
1820 AddrOps: *const i64,
1821 AddrOpsCount: c_uint,
1822 ArgNo: c_uint)
1823 -> DIVariable;
1824
1825 pub fn LLVMRustDIBuilderCreateArrayType(Builder: DIBuilderRef,
1826 Size: u64,
1827 AlignInBits: u64,
1828 Ty: DIType,
1829 Subscripts: DIArray)
1830 -> DIType;
1831
1832 pub fn LLVMRustDIBuilderCreateVectorType(Builder: DIBuilderRef,
1833 Size: u64,
1834 AlignInBits: u64,
1835 Ty: DIType,
1836 Subscripts: DIArray)
1837 -> DIType;
1838
1839 pub fn LLVMRustDIBuilderGetOrCreateSubrange(Builder: DIBuilderRef,
1840 Lo: i64,
1841 Count: i64)
1842 -> DISubrange;
1843
1844 pub fn LLVMRustDIBuilderGetOrCreateArray(Builder: DIBuilderRef,
1845 Ptr: *const DIDescriptor,
1846 Count: c_uint)
1847 -> DIArray;
1848
1849 pub fn LLVMRustDIBuilderInsertDeclareAtEnd(Builder: DIBuilderRef,
1850 Val: ValueRef,
1851 VarInfo: DIVariable,
1852 AddrOps: *const i64,
1853 AddrOpsCount: c_uint,
1854 DL: ValueRef,
1855 InsertAtEnd: BasicBlockRef)
1856 -> ValueRef;
1857
1858 pub fn LLVMRustDIBuilderInsertDeclareBefore(Builder: DIBuilderRef,
1859 Val: ValueRef,
1860 VarInfo: DIVariable,
1861 AddrOps: *const i64,
1862 AddrOpsCount: c_uint,
1863 DL: ValueRef,
1864 InsertBefore: ValueRef)
1865 -> ValueRef;
1866
1867 pub fn LLVMRustDIBuilderCreateEnumerator(Builder: DIBuilderRef,
1868 Name: *const c_char,
1869 Val: u64)
1870 -> DIEnumerator;
1871
1872 pub fn LLVMRustDIBuilderCreateEnumerationType(Builder: DIBuilderRef,
1873 Scope: DIScope,
1874 Name: *const c_char,
1875 File: DIFile,
1876 LineNumber: c_uint,
1877 SizeInBits: u64,
1878 AlignInBits: u64,
1879 Elements: DIArray,
1880 ClassType: DIType)
1881 -> DIType;
1882
1883 pub fn LLVMRustDIBuilderCreateUnionType(Builder: DIBuilderRef,
1884 Scope: DIScope,
1885 Name: *const c_char,
1886 File: DIFile,
1887 LineNumber: c_uint,
1888 SizeInBits: u64,
1889 AlignInBits: u64,
1890 Flags: c_uint,
1891 Elements: DIArray,
1892 RunTimeLang: c_uint,
1893 UniqueId: *const c_char)
1894 -> DIType;
1895
1896 pub fn LLVMSetUnnamedAddr(GlobalVar: ValueRef, UnnamedAddr: Bool);
1897
1898 pub fn LLVMRustDIBuilderCreateTemplateTypeParameter(Builder: DIBuilderRef,
1899 Scope: DIScope,
1900 Name: *const c_char,
1901 Ty: DIType,
1902 File: DIFile,
1903 LineNo: c_uint,
1904 ColumnNo: c_uint)
1905 -> DITemplateTypeParameter;
1906
1907
1908 pub fn LLVMRustDIBuilderCreateNameSpace(Builder: DIBuilderRef,
1909 Scope: DIScope,
1910 Name: *const c_char,
1911 File: DIFile,
1912 LineNo: c_uint)
1913 -> DINameSpace;
1914 pub fn LLVMRustDICompositeTypeSetTypeArray(Builder: DIBuilderRef,
1915 CompositeType: DIType,
1916 TypeArray: DIArray);
1917
1918
1919 pub fn LLVMRustDIBuilderCreateDebugLocation(Context: ContextRef,
1920 Line: c_uint,
1921 Column: c_uint,
1922 Scope: DIScope,
1923 InlinedAt: MetadataRef)
1924 -> ValueRef;
1925 pub fn LLVMRustDIBuilderCreateOpDeref() -> i64;
1926 pub fn LLVMRustDIBuilderCreateOpPlus() -> i64;
1927
1928 pub fn LLVMRustWriteTypeToString(Type: TypeRef, s: RustStringRef);
1929 pub fn LLVMRustWriteValueToString(value_ref: ValueRef, s: RustStringRef);
1930
1931 pub fn LLVMIsAArgument(value_ref: ValueRef) -> ValueRef;
1932
1933 pub fn LLVMIsAAllocaInst(value_ref: ValueRef) -> ValueRef;
1934 pub fn LLVMIsAConstantInt(value_ref: ValueRef) -> ValueRef;
1935
1936 pub fn LLVMRustPassKind(Pass: PassRef) -> PassKind;
1937 pub fn LLVMRustFindAndCreatePass(Pass: *const c_char) -> PassRef;
1938 pub fn LLVMRustAddPass(PM: PassManagerRef, Pass: PassRef);
1939
1940 pub fn LLVMRustHasFeature(T: TargetMachineRef,
1941 s: *const c_char) -> bool;
1942
1943 pub fn LLVMRustPrintTargetCPUs(T: TargetMachineRef);
1944 pub fn LLVMRustPrintTargetFeatures(T: TargetMachineRef);
1945
1946 pub fn LLVMRustCreateTargetMachine(Triple: *const c_char,
1947 CPU: *const c_char,
1948 Features: *const c_char,
1949 Model: CodeModel,
1950 Reloc: RelocMode,
1951 Level: CodeGenOptLevel,
1952 UseSoftFP: bool,
1953 PositionIndependentExecutable: bool,
1954 FunctionSections: bool,
1955 DataSections: bool) -> TargetMachineRef;
1956 pub fn LLVMRustDisposeTargetMachine(T: TargetMachineRef);
1957 pub fn LLVMRustAddAnalysisPasses(T: TargetMachineRef,
1958 PM: PassManagerRef,
1959 M: ModuleRef);
1960 pub fn LLVMRustAddBuilderLibraryInfo(PMB: PassManagerBuilderRef,
1961 M: ModuleRef,
1962 DisableSimplifyLibCalls: bool);
1963 pub fn LLVMRustConfigurePassManagerBuilder(PMB: PassManagerBuilderRef,
1964 OptLevel: CodeGenOptLevel,
1965 MergeFunctions: bool,
1966 SLPVectorize: bool,
1967 LoopVectorize: bool);
1968 pub fn LLVMRustAddLibraryInfo(PM: PassManagerRef, M: ModuleRef,
1969 DisableSimplifyLibCalls: bool);
1970 pub fn LLVMRustRunFunctionPassManager(PM: PassManagerRef, M: ModuleRef);
1971 pub fn LLVMRustWriteOutputFile(T: TargetMachineRef,
1972 PM: PassManagerRef,
1973 M: ModuleRef,
1974 Output: *const c_char,
1975 FileType: FileType)
1976 -> LLVMRustResult;
1977 pub fn LLVMRustPrintModule(PM: PassManagerRef,
1978 M: ModuleRef,
1979 Output: *const c_char);
1980 pub fn LLVMRustSetLLVMOptions(Argc: c_int, Argv: *const *const c_char);
1981 pub fn LLVMRustPrintPasses();
1982 pub fn LLVMRustSetNormalizedTarget(M: ModuleRef, triple: *const c_char);
1983 pub fn LLVMRustAddAlwaysInlinePass(P: PassManagerBuilderRef,
1984 AddLifetimes: bool);
1985 pub fn LLVMRustLinkInExternalBitcode(M: ModuleRef,
1986 bc: *const c_char,
1987 len: size_t) -> bool;
1988 pub fn LLVMRustRunRestrictionPass(M: ModuleRef,
1989 syms: *const *const c_char,
1990 len: size_t);
1991 pub fn LLVMRustMarkAllFunctionsNounwind(M: ModuleRef);
1992
1993 pub fn LLVMRustOpenArchive(path: *const c_char) -> ArchiveRef;
1994 pub fn LLVMRustArchiveIteratorNew(AR: ArchiveRef) -> ArchiveIteratorRef;
1995 pub fn LLVMRustArchiveIteratorNext(AIR: ArchiveIteratorRef) -> ArchiveChildRef;
1996 pub fn LLVMRustArchiveChildName(ACR: ArchiveChildRef,
1997 size: *mut size_t) -> *const c_char;
1998 pub fn LLVMRustArchiveChildData(ACR: ArchiveChildRef,
1999 size: *mut size_t) -> *const c_char;
2000 pub fn LLVMRustArchiveChildFree(ACR: ArchiveChildRef);
2001 pub fn LLVMRustArchiveIteratorFree(AIR: ArchiveIteratorRef);
2002 pub fn LLVMRustDestroyArchive(AR: ArchiveRef);
2003
2004 pub fn LLVMRustGetSectionName(SI: SectionIteratorRef,
2005 data: *mut *const c_char) -> size_t;
2006
2007 pub fn LLVMRustWriteTwineToString(T: TwineRef, s: RustStringRef);
2008
2009 pub fn LLVMContextSetDiagnosticHandler(C: ContextRef,
2010 Handler: DiagnosticHandler,
2011 DiagnosticContext: *mut c_void);
2012
2013 pub fn LLVMRustUnpackOptimizationDiagnostic(DI: DiagnosticInfoRef,
2014 pass_name_out: *mut *const c_char,
2015 function_out: *mut ValueRef,
2016 debugloc_out: *mut DebugLocRef,
2017 message_out: *mut TwineRef);
2018 pub fn LLVMRustUnpackInlineAsmDiagnostic(DI: DiagnosticInfoRef,
2019 cookie_out: *mut c_uint,
2020 message_out: *mut TwineRef,
2021 instruction_out: *mut ValueRef);
2022
2023 pub fn LLVMRustWriteDiagnosticInfoToString(DI: DiagnosticInfoRef,
2024 s: RustStringRef);
2025 pub fn LLVMGetDiagInfoSeverity(DI: DiagnosticInfoRef) -> DiagnosticSeverity;
2026 pub fn LLVMRustGetDiagInfoKind(DI: DiagnosticInfoRef) -> DiagnosticKind;
2027
2028 pub fn LLVMRustWriteDebugLocToString(C: ContextRef,
2029 DL: DebugLocRef,
2030 s: RustStringRef);
2031
2032 pub fn LLVMRustSetInlineAsmDiagnosticHandler(C: ContextRef,
2033 H: InlineAsmDiagHandler,
2034 CX: *mut c_void);
2035
2036 pub fn LLVMRustWriteSMDiagnosticToString(d: SMDiagnosticRef, s: RustStringRef);
2037
2038 pub fn LLVMRustWriteArchive(Dst: *const c_char,
2039 NumMembers: size_t,
2040 Members: *const RustArchiveMemberRef,
2041 WriteSymbtab: bool,
2042 Kind: ArchiveKind) ->
2043 LLVMRustResult;
2044 pub fn LLVMRustArchiveMemberNew(Filename: *const c_char,
2045 Name: *const c_char,
2046 Child: ArchiveChildRef) -> RustArchiveMemberRef;
2047 pub fn LLVMRustArchiveMemberFree(Member: RustArchiveMemberRef);
2048
2049 pub fn LLVMRustSetDataLayoutFromTargetMachine(M: ModuleRef,
2050 TM: TargetMachineRef);
2051 pub fn LLVMRustGetModuleDataLayout(M: ModuleRef) -> TargetDataRef;
2052
2053 pub fn LLVMRustBuildOperandBundleDef(Name: *const c_char,
2054 Inputs: *const ValueRef,
2055 NumInputs: c_uint)
2056 -> OperandBundleDefRef;
2057 pub fn LLVMRustFreeOperandBundleDef(Bundle: OperandBundleDefRef);
2058
2059 pub fn LLVMRustPositionBuilderAtStart(B: BuilderRef, BB: BasicBlockRef);
2060
2061 pub fn LLVMRustSetComdat(M: ModuleRef, V: ValueRef, Name: *const c_char);
2062 pub fn LLVMRustUnsetComdat(V: ValueRef);
2063 pub fn LLVMRustSetModulePIELevel(M: ModuleRef);
2064 }
2065
2066
2067 // LLVM requires symbols from this library, but apparently they're not printed
2068 // during llvm-config?
2069 #[cfg(windows)]
2070 #[link(name = "ole32")]
2071 extern {}