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.
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.
11 use debuginfo::{DIBuilderRef, DIDescriptor,
12 DIFile, DILexicalBlock, DISubprogram, DIType,
13 DIBasicType, DIDerivedType, DICompositeType, DIScope,
14 DIVariable, DIGlobalVariable, DIArray, DISubrange,
15 DITemplateTypeParameter, DIEnumerator, DINameSpace};
17 use libc::{c_uint, c_int, size_t, c_char};
18 use libc::{c_longlong, c_ulonglong, c_void};
22 pub type Opcode = u32;
23 pub type Bool = c_uint;
25 pub const True: Bool = 1 as Bool;
26 pub const False: Bool = 0 as Bool;
28 #[derive(Copy, Clone, PartialEq)]
30 pub enum LLVMRustResult {
34 // Consts for the LLVM CallConv type, pre-cast to usize.
36 /// LLVM CallingConv::ID. Should we wrap this?
37 #[derive(Copy, Clone, PartialEq)]
43 X86StdcallCallConv = 64,
44 X86FastcallCallConv = 65,
51 #[derive(Copy, Clone, PartialEq, Eq, Hash, Debug)]
55 AvailableExternallyLinkage = 1,
56 LinkOnceAnyLinkage = 2,
57 LinkOnceODRLinkage = 3,
63 ExternalWeakLinkage = 9,
67 /// LLVMDiagnosticSeverity
68 #[derive(Copy, Clone, Debug)]
70 pub enum DiagnosticSeverity {
77 /// LLVMDLLStorageClass
78 #[derive(Copy, Clone)]
80 pub enum DLLStorageClass {
82 DllImport = 1, /* Function to be imported from DLL. */
83 DllExport = 2, /* Function to be accessible from DLL. */
87 #[derive(Default, Debug)]
88 flags Attribute : u64 {
91 const NoReturn = 1 << 2,
93 const StructRet = 1 << 4,
94 const NoUnwind = 1 << 5,
95 const NoAlias = 1 << 6,
98 const ReadNone = 1 << 9,
99 const ReadOnly = 1 << 10,
100 const NoInline = 1 << 11,
101 const AlwaysInline = 1 << 12,
102 const OptimizeForSize = 1 << 13,
103 const StackProtect = 1 << 14,
104 const StackProtectReq = 1 << 15,
105 const NoCapture = 1 << 21,
106 const NoRedZone = 1 << 22,
107 const NoImplicitFloat = 1 << 23,
108 const Naked = 1 << 24,
109 const InlineHint = 1 << 25,
110 const ReturnsTwice = 1 << 29,
111 const UWTable = 1 << 30,
112 const NonLazyBind = 1 << 31,
114 // Some of these are missing from the LLVM C API, the rest are
115 // present, but commented out, and preceded by the following warning:
116 // FIXME: These attributes are currently not included in the C API as
117 // a temporary measure until the API/ABI impact to the C API is understood
118 // and the path forward agreed upon.
119 const SanitizeAddress = 1 << 32,
120 const MinSize = 1 << 33,
121 const NoDuplicate = 1 << 34,
122 const StackProtectStrong = 1 << 35,
123 const SanitizeThread = 1 << 36,
124 const SanitizeMemory = 1 << 37,
125 const NoBuiltin = 1 << 38,
126 const Returned = 1 << 39,
127 const Cold = 1 << 40,
128 const Builtin = 1 << 41,
129 const OptimizeNone = 1 << 42,
130 const InAlloca = 1 << 43,
131 const NonNull = 1 << 44,
132 const JumpTable = 1 << 45,
133 const Convergent = 1 << 46,
134 const SafeStack = 1 << 47,
135 const NoRecurse = 1 << 48,
136 const InaccessibleMemOnly = 1 << 49,
137 const InaccessibleMemOrArgMemOnly = 1 << 50,
142 #[derive(Copy, Clone)]
144 pub enum IntPredicate {
157 /// LLVMRealPredicate
158 #[derive(Copy, Clone)]
160 pub enum RealPredicate {
161 RealPredicateFalse = 0,
176 RealPredicateTrue = 15,
180 #[derive(Copy, Clone, PartialEq, Debug)]
202 /// LLVMAtomicRmwBinOp
203 #[derive(Copy, Clone)]
205 pub enum AtomicRmwBinOp {
219 /// LLVMAtomicOrdering
220 #[derive(Copy, Clone)]
222 pub enum AtomicOrdering {
226 // Consume = 3, // Not specified yet.
230 SequentiallyConsistent = 7
233 /// LLVMRustSynchronizationScope
234 #[derive(Copy, Clone)]
236 pub enum SynchronizationScope {
243 #[derive(Copy, Clone)]
252 #[derive(Copy, Clone)]
254 pub enum MetadataType {
261 MD_invariant_load = 6,
265 MD_mem_parallel_loop_access = 10,
269 /// LLVMRustAsmDialect
270 #[derive(Copy, Clone)]
272 pub enum AsmDialect {
278 /// LLVMRustCodeGenOptLevel
279 #[derive(Copy, Clone, PartialEq)]
281 pub enum CodeGenOptLevel {
290 #[derive(Copy, Clone, PartialEq)]
299 /// LLVMRustCodeModel
300 #[derive(Copy, Clone)]
312 /// LLVMRustDiagnosticKind
313 #[derive(Copy, Clone)]
315 pub enum DiagnosticKind {
319 DebugMetadataVersion,
322 OptimizationRemarkMissed,
323 OptimizationRemarkAnalysis,
324 OptimizationRemarkAnalysisFPCommute,
325 OptimizationRemarkAnalysisAliasing,
326 OptimizationRemarkOther,
330 /// LLVMRustArchiveKind
331 #[derive(Copy, Clone)]
333 pub enum ArchiveKind {
342 #[derive(Copy, Clone, PartialEq, Debug)]
350 // Opaque pointer types
351 #[allow(missing_copy_implementations)]
352 pub enum Module_opaque {}
353 pub type ModuleRef = *mut Module_opaque;
354 #[allow(missing_copy_implementations)]
355 pub enum Context_opaque {}
356 pub type ContextRef = *mut Context_opaque;
357 #[allow(missing_copy_implementations)]
358 pub enum Type_opaque {}
359 pub type TypeRef = *mut Type_opaque;
360 #[allow(missing_copy_implementations)]
361 pub enum Value_opaque {}
362 pub type ValueRef = *mut Value_opaque;
363 #[allow(missing_copy_implementations)]
364 pub enum Metadata_opaque {}
365 pub type MetadataRef = *mut Metadata_opaque;
366 #[allow(missing_copy_implementations)]
367 pub enum BasicBlock_opaque {}
368 pub type BasicBlockRef = *mut BasicBlock_opaque;
369 #[allow(missing_copy_implementations)]
370 pub enum Builder_opaque {}
371 pub type BuilderRef = *mut Builder_opaque;
372 #[allow(missing_copy_implementations)]
373 pub enum ExecutionEngine_opaque {}
374 pub type ExecutionEngineRef = *mut ExecutionEngine_opaque;
375 #[allow(missing_copy_implementations)]
376 pub enum MemoryBuffer_opaque {}
377 pub type MemoryBufferRef = *mut MemoryBuffer_opaque;
378 #[allow(missing_copy_implementations)]
379 pub enum PassManager_opaque {}
380 pub type PassManagerRef = *mut PassManager_opaque;
381 #[allow(missing_copy_implementations)]
382 pub enum PassManagerBuilder_opaque {}
383 pub type PassManagerBuilderRef = *mut PassManagerBuilder_opaque;
384 #[allow(missing_copy_implementations)]
385 pub enum Use_opaque {}
386 pub type UseRef = *mut Use_opaque;
387 #[allow(missing_copy_implementations)]
388 pub enum TargetData_opaque {}
389 pub type TargetDataRef = *mut TargetData_opaque;
390 #[allow(missing_copy_implementations)]
391 pub enum ObjectFile_opaque {}
392 pub type ObjectFileRef = *mut ObjectFile_opaque;
393 #[allow(missing_copy_implementations)]
394 pub enum SectionIterator_opaque {}
395 pub type SectionIteratorRef = *mut SectionIterator_opaque;
396 #[allow(missing_copy_implementations)]
397 pub enum Pass_opaque {}
398 pub type PassRef = *mut Pass_opaque;
399 #[allow(missing_copy_implementations)]
400 pub enum TargetMachine_opaque {}
401 pub type TargetMachineRef = *mut TargetMachine_opaque;
402 pub enum Archive_opaque {}
403 pub type ArchiveRef = *mut Archive_opaque;
404 pub enum ArchiveIterator_opaque {}
405 pub type ArchiveIteratorRef = *mut ArchiveIterator_opaque;
406 pub enum ArchiveChild_opaque {}
407 pub type ArchiveChildRef = *mut ArchiveChild_opaque;
408 #[allow(missing_copy_implementations)]
409 pub enum Twine_opaque {}
410 pub type TwineRef = *mut Twine_opaque;
411 #[allow(missing_copy_implementations)]
412 pub enum DiagnosticInfo_opaque {}
413 pub type DiagnosticInfoRef = *mut DiagnosticInfo_opaque;
414 #[allow(missing_copy_implementations)]
415 pub enum DebugLoc_opaque {}
416 pub type DebugLocRef = *mut DebugLoc_opaque;
417 #[allow(missing_copy_implementations)]
418 pub enum SMDiagnostic_opaque {}
419 pub type SMDiagnosticRef = *mut SMDiagnostic_opaque;
420 #[allow(missing_copy_implementations)]
421 pub enum RustArchiveMember_opaque {}
422 pub type RustArchiveMemberRef = *mut RustArchiveMember_opaque;
423 #[allow(missing_copy_implementations)]
424 pub enum OperandBundleDef_opaque {}
425 pub type OperandBundleDefRef = *mut OperandBundleDef_opaque;
427 pub type DiagnosticHandler = unsafe extern "C" fn(DiagnosticInfoRef, *mut c_void);
428 pub type InlineAsmDiagHandler = unsafe extern "C" fn(SMDiagnosticRef, *const c_void, c_uint);
431 pub use self::DIDescriptorFlags::*;
432 use super::{MetadataRef};
434 #[allow(missing_copy_implementations)]
435 pub enum DIBuilder_opaque {}
436 pub type DIBuilderRef = *mut DIBuilder_opaque;
438 pub type DIDescriptor = MetadataRef;
439 pub type DIScope = DIDescriptor;
440 pub type DILocation = DIDescriptor;
441 pub type DIFile = DIScope;
442 pub type DILexicalBlock = DIScope;
443 pub type DISubprogram = DIScope;
444 pub type DINameSpace = DIScope;
445 pub type DIType = DIDescriptor;
446 pub type DIBasicType = DIType;
447 pub type DIDerivedType = DIType;
448 pub type DICompositeType = DIDerivedType;
449 pub type DIVariable = DIDescriptor;
450 pub type DIGlobalVariable = DIDescriptor;
451 pub type DIArray = DIDescriptor;
452 pub type DISubrange = DIDescriptor;
453 pub type DIEnumerator = DIDescriptor;
454 pub type DITemplateTypeParameter = DIDescriptor;
456 #[derive(Copy, Clone)]
457 pub enum DIDescriptorFlags {
458 FlagPrivate = 1 << 0,
459 FlagProtected = 1 << 1,
460 FlagFwdDecl = 1 << 2,
461 FlagAppleBlock = 1 << 3,
462 FlagBlockByrefStruct = 1 << 4,
463 FlagVirtual = 1 << 5,
464 FlagArtificial = 1 << 6,
465 FlagExplicit = 1 << 7,
466 FlagPrototyped = 1 << 8,
467 FlagObjcClassComplete = 1 << 9,
468 FlagObjectPointer = 1 << 10,
469 FlagVector = 1 << 11,
470 FlagStaticMember = 1 << 12,
471 FlagIndirectVariable = 1 << 13,
472 FlagLValueReference = 1 << 14,
473 FlagRValueReference = 1 << 15
478 // Link to our native llvm bindings (things that we need to use the C++ api
479 // for) and because llvm is written in C++ we need to link against libstdc++
481 // You'll probably notice that there is an omission of all LLVM libraries
482 // from this location. This is because the set of LLVM libraries that we
483 // link to is mostly defined by LLVM, and the `llvm-config` tool is used to
484 // figure out the exact set of libraries. To do this, the build system
485 // generates an llvmdeps.rs file next to this one which will be
486 // automatically updated whenever LLVM is updated to include an up-to-date
487 // set of the libraries we need to link to LLVM for.
488 #[link(name = "rustllvm", kind = "static")]
489 #[cfg(not(cargobuild))]
492 #[linked_from = "rustllvm"] // not quite true but good enough
494 /* Create and destroy contexts. */
495 pub fn LLVMContextCreate() -> ContextRef;
496 pub fn LLVMContextDispose(C: ContextRef);
497 pub fn LLVMGetMDKindIDInContext(C: ContextRef,
502 /* Create and destroy modules. */
503 pub fn LLVMModuleCreateWithNameInContext(ModuleID: *const c_char,
506 pub fn LLVMGetModuleContext(M: ModuleRef) -> ContextRef;
507 pub fn LLVMCloneModule(M: ModuleRef) -> ModuleRef;
508 pub fn LLVMDisposeModule(M: ModuleRef);
510 /// Data layout. See Module::getDataLayout.
511 pub fn LLVMGetDataLayout(M: ModuleRef) -> *const c_char;
512 pub fn LLVMSetDataLayout(M: ModuleRef, Triple: *const c_char);
514 /// Target triple. See Module::getTargetTriple.
515 pub fn LLVMGetTarget(M: ModuleRef) -> *const c_char;
516 pub fn LLVMSetTarget(M: ModuleRef, Triple: *const c_char);
518 /// See Module::dump.
519 pub fn LLVMDumpModule(M: ModuleRef);
521 /// See Module::setModuleInlineAsm.
522 pub fn LLVMSetModuleInlineAsm(M: ModuleRef, Asm: *const c_char);
524 /// See llvm::LLVMTypeKind::getTypeID.
525 pub fn LLVMRustGetTypeKind(Ty: TypeRef) -> TypeKind;
527 /// See llvm::LLVMType::getContext.
528 pub fn LLVMGetTypeContext(Ty: TypeRef) -> ContextRef;
530 /* Operations on integer types */
531 pub fn LLVMInt1TypeInContext(C: ContextRef) -> TypeRef;
532 pub fn LLVMInt8TypeInContext(C: ContextRef) -> TypeRef;
533 pub fn LLVMInt16TypeInContext(C: ContextRef) -> TypeRef;
534 pub fn LLVMInt32TypeInContext(C: ContextRef) -> TypeRef;
535 pub fn LLVMInt64TypeInContext(C: ContextRef) -> TypeRef;
536 pub fn LLVMIntTypeInContext(C: ContextRef, NumBits: c_uint)
539 pub fn LLVMGetIntTypeWidth(IntegerTy: TypeRef) -> c_uint;
541 /* Operations on real types */
542 pub fn LLVMFloatTypeInContext(C: ContextRef) -> TypeRef;
543 pub fn LLVMDoubleTypeInContext(C: ContextRef) -> TypeRef;
544 pub fn LLVMX86FP80TypeInContext(C: ContextRef) -> TypeRef;
545 pub fn LLVMFP128TypeInContext(C: ContextRef) -> TypeRef;
546 pub fn LLVMPPCFP128TypeInContext(C: ContextRef) -> TypeRef;
548 /* Operations on function types */
549 pub fn LLVMFunctionType(ReturnType: TypeRef,
550 ParamTypes: *const TypeRef,
554 pub fn LLVMIsFunctionVarArg(FunctionTy: TypeRef) -> Bool;
555 pub fn LLVMGetReturnType(FunctionTy: TypeRef) -> TypeRef;
556 pub fn LLVMCountParamTypes(FunctionTy: TypeRef) -> c_uint;
557 pub fn LLVMGetParamTypes(FunctionTy: TypeRef, Dest: *mut TypeRef);
559 /* Operations on struct types */
560 pub fn LLVMStructTypeInContext(C: ContextRef,
561 ElementTypes: *const TypeRef,
562 ElementCount: c_uint,
565 pub fn LLVMCountStructElementTypes(StructTy: TypeRef) -> c_uint;
566 pub fn LLVMGetStructElementTypes(StructTy: TypeRef,
568 pub fn LLVMIsPackedStruct(StructTy: TypeRef) -> Bool;
570 /* Operations on array, pointer, and vector types (sequence types) */
571 pub fn LLVMRustArrayType(ElementType: TypeRef, ElementCount: u64) -> TypeRef;
572 pub fn LLVMPointerType(ElementType: TypeRef, AddressSpace: c_uint)
574 pub fn LLVMVectorType(ElementType: TypeRef, ElementCount: c_uint)
577 pub fn LLVMGetElementType(Ty: TypeRef) -> TypeRef;
578 pub fn LLVMGetArrayLength(ArrayTy: TypeRef) -> c_uint;
579 pub fn LLVMGetPointerAddressSpace(PointerTy: TypeRef) -> c_uint;
580 pub fn LLVMGetPointerToGlobal(EE: ExecutionEngineRef, V: ValueRef)
582 pub fn LLVMGetVectorSize(VectorTy: TypeRef) -> c_uint;
584 /* Operations on other types */
585 pub fn LLVMVoidTypeInContext(C: ContextRef) -> TypeRef;
586 pub fn LLVMLabelTypeInContext(C: ContextRef) -> TypeRef;
587 pub fn LLVMRustMetadataTypeInContext(C: ContextRef) -> TypeRef;
589 /* Operations on all values */
590 pub fn LLVMTypeOf(Val: ValueRef) -> TypeRef;
591 pub fn LLVMGetValueName(Val: ValueRef) -> *const c_char;
592 pub fn LLVMSetValueName(Val: ValueRef, Name: *const c_char);
593 pub fn LLVMDumpValue(Val: ValueRef);
594 pub fn LLVMReplaceAllUsesWith(OldVal: ValueRef, NewVal: ValueRef);
595 pub fn LLVMSetMetadata(Val: ValueRef, KindID: c_uint, Node: ValueRef);
597 /* Operations on Uses */
598 pub fn LLVMGetFirstUse(Val: ValueRef) -> UseRef;
599 pub fn LLVMGetNextUse(U: UseRef) -> UseRef;
600 pub fn LLVMGetUser(U: UseRef) -> ValueRef;
601 pub fn LLVMGetUsedValue(U: UseRef) -> ValueRef;
603 /* Operations on Users */
604 pub fn LLVMGetNumOperands(Val: ValueRef) -> c_int;
605 pub fn LLVMGetOperand(Val: ValueRef, Index: c_uint) -> ValueRef;
606 pub fn LLVMSetOperand(Val: ValueRef, Index: c_uint, Op: ValueRef);
608 /* Operations on constants of any type */
609 pub fn LLVMConstNull(Ty: TypeRef) -> ValueRef;
611 pub fn LLVMConstAllOnes(Ty: TypeRef) -> ValueRef;
612 pub fn LLVMConstICmp(Pred: IntPredicate, V1: ValueRef, V2: ValueRef)
614 pub fn LLVMConstFCmp(Pred: RealPredicate, V1: ValueRef, V2: ValueRef)
616 /* only for isize/vector */
617 pub fn LLVMGetUndef(Ty: TypeRef) -> ValueRef;
618 pub fn LLVMIsConstant(Val: ValueRef) -> Bool;
619 pub fn LLVMIsNull(Val: ValueRef) -> Bool;
620 pub fn LLVMIsUndef(Val: ValueRef) -> Bool;
621 pub fn LLVMConstPointerNull(Ty: TypeRef) -> ValueRef;
623 /* Operations on metadata */
624 pub fn LLVMMDStringInContext(C: ContextRef,
628 pub fn LLVMMDNodeInContext(C: ContextRef,
629 Vals: *const ValueRef,
632 pub fn LLVMAddNamedMetadataOperand(M: ModuleRef,
636 /* Operations on scalar constants */
637 pub fn LLVMConstInt(IntTy: TypeRef, N: c_ulonglong, SignExtend: Bool)
639 pub fn LLVMConstIntOfString(IntTy: TypeRef, Text: *const c_char, Radix: u8)
641 pub fn LLVMConstIntOfStringAndSize(IntTy: TypeRef,
646 pub fn LLVMConstReal(RealTy: TypeRef, N: f64) -> ValueRef;
647 pub fn LLVMConstRealOfString(RealTy: TypeRef, Text: *const c_char)
649 pub fn LLVMConstRealOfStringAndSize(RealTy: TypeRef,
653 pub fn LLVMConstIntGetZExtValue(ConstantVal: ValueRef) -> c_ulonglong;
654 pub fn LLVMConstIntGetSExtValue(ConstantVal: ValueRef) -> c_longlong;
657 /* Operations on composite constants */
658 pub fn LLVMConstStringInContext(C: ContextRef,
661 DontNullTerminate: Bool)
663 pub fn LLVMConstStructInContext(C: ContextRef,
664 ConstantVals: *const ValueRef,
669 pub fn LLVMConstArray(ElementTy: TypeRef,
670 ConstantVals: *const ValueRef,
673 pub fn LLVMConstVector(ScalarConstantVals: *const ValueRef, Size: c_uint)
676 /* Constant expressions */
677 pub fn LLVMAlignOf(Ty: TypeRef) -> ValueRef;
678 pub fn LLVMSizeOf(Ty: TypeRef) -> ValueRef;
679 pub fn LLVMConstNeg(ConstantVal: ValueRef) -> ValueRef;
680 pub fn LLVMConstNSWNeg(ConstantVal: ValueRef) -> ValueRef;
681 pub fn LLVMConstNUWNeg(ConstantVal: ValueRef) -> ValueRef;
682 pub fn LLVMConstFNeg(ConstantVal: ValueRef) -> ValueRef;
683 pub fn LLVMConstNot(ConstantVal: ValueRef) -> ValueRef;
684 pub fn LLVMConstAdd(LHSConstant: ValueRef, RHSConstant: ValueRef)
686 pub fn LLVMConstNSWAdd(LHSConstant: ValueRef, RHSConstant: ValueRef)
688 pub fn LLVMConstNUWAdd(LHSConstant: ValueRef, RHSConstant: ValueRef)
690 pub fn LLVMConstFAdd(LHSConstant: ValueRef, RHSConstant: ValueRef)
692 pub fn LLVMConstSub(LHSConstant: ValueRef, RHSConstant: ValueRef)
694 pub fn LLVMConstNSWSub(LHSConstant: ValueRef, RHSConstant: ValueRef)
696 pub fn LLVMConstNUWSub(LHSConstant: ValueRef, RHSConstant: ValueRef)
698 pub fn LLVMConstFSub(LHSConstant: ValueRef, RHSConstant: ValueRef)
700 pub fn LLVMConstMul(LHSConstant: ValueRef, RHSConstant: ValueRef)
702 pub fn LLVMConstNSWMul(LHSConstant: ValueRef, RHSConstant: ValueRef)
704 pub fn LLVMConstNUWMul(LHSConstant: ValueRef, RHSConstant: ValueRef)
706 pub fn LLVMConstFMul(LHSConstant: ValueRef, RHSConstant: ValueRef)
708 pub fn LLVMConstUDiv(LHSConstant: ValueRef, RHSConstant: ValueRef)
710 pub fn LLVMConstSDiv(LHSConstant: ValueRef, RHSConstant: ValueRef)
712 pub fn LLVMConstExactSDiv(LHSConstant: ValueRef,
713 RHSConstant: ValueRef)
715 pub fn LLVMConstFDiv(LHSConstant: ValueRef, RHSConstant: ValueRef)
717 pub fn LLVMConstURem(LHSConstant: ValueRef, RHSConstant: ValueRef)
719 pub fn LLVMConstSRem(LHSConstant: ValueRef, RHSConstant: ValueRef)
721 pub fn LLVMConstFRem(LHSConstant: ValueRef, RHSConstant: ValueRef)
723 pub fn LLVMConstAnd(LHSConstant: ValueRef, RHSConstant: ValueRef)
725 pub fn LLVMConstOr(LHSConstant: ValueRef, RHSConstant: ValueRef)
727 pub fn LLVMConstXor(LHSConstant: ValueRef, RHSConstant: ValueRef)
729 pub fn LLVMConstShl(LHSConstant: ValueRef, RHSConstant: ValueRef)
731 pub fn LLVMConstLShr(LHSConstant: ValueRef, RHSConstant: ValueRef)
733 pub fn LLVMConstAShr(LHSConstant: ValueRef, RHSConstant: ValueRef)
735 pub fn LLVMConstGEP(ConstantVal: ValueRef,
736 ConstantIndices: *const ValueRef,
739 pub fn LLVMConstInBoundsGEP(ConstantVal: ValueRef,
740 ConstantIndices: *const ValueRef,
743 pub fn LLVMConstTrunc(ConstantVal: ValueRef, ToType: TypeRef)
745 pub fn LLVMConstSExt(ConstantVal: ValueRef, ToType: TypeRef)
747 pub fn LLVMConstZExt(ConstantVal: ValueRef, ToType: TypeRef)
749 pub fn LLVMConstFPTrunc(ConstantVal: ValueRef, ToType: TypeRef)
751 pub fn LLVMConstFPExt(ConstantVal: ValueRef, ToType: TypeRef)
753 pub fn LLVMConstUIToFP(ConstantVal: ValueRef, ToType: TypeRef)
755 pub fn LLVMConstSIToFP(ConstantVal: ValueRef, ToType: TypeRef)
757 pub fn LLVMConstFPToUI(ConstantVal: ValueRef, ToType: TypeRef)
759 pub fn LLVMConstFPToSI(ConstantVal: ValueRef, ToType: TypeRef)
761 pub fn LLVMConstPtrToInt(ConstantVal: ValueRef, ToType: TypeRef)
763 pub fn LLVMConstIntToPtr(ConstantVal: ValueRef, ToType: TypeRef)
765 pub fn LLVMConstBitCast(ConstantVal: ValueRef, ToType: TypeRef)
767 pub fn LLVMConstZExtOrBitCast(ConstantVal: ValueRef, ToType: TypeRef)
769 pub fn LLVMConstSExtOrBitCast(ConstantVal: ValueRef, ToType: TypeRef)
771 pub fn LLVMConstTruncOrBitCast(ConstantVal: ValueRef, ToType: TypeRef)
773 pub fn LLVMConstPointerCast(ConstantVal: ValueRef, ToType: TypeRef)
775 pub fn LLVMConstIntCast(ConstantVal: ValueRef,
779 pub fn LLVMConstFPCast(ConstantVal: ValueRef, ToType: TypeRef)
781 pub fn LLVMConstSelect(ConstantCondition: ValueRef,
782 ConstantIfTrue: ValueRef,
783 ConstantIfFalse: ValueRef)
785 pub fn LLVMConstExtractElement(VectorConstant: ValueRef,
786 IndexConstant: ValueRef)
788 pub fn LLVMConstInsertElement(VectorConstant: ValueRef,
789 ElementValueConstant: ValueRef,
790 IndexConstant: ValueRef)
792 pub fn LLVMConstShuffleVector(VectorAConstant: ValueRef,
793 VectorBConstant: ValueRef,
794 MaskConstant: ValueRef)
796 pub fn LLVMConstExtractValue(AggConstant: ValueRef,
797 IdxList: *const c_uint,
800 pub fn LLVMConstInsertValue(AggConstant: ValueRef,
801 ElementValueConstant: ValueRef,
802 IdxList: *const c_uint,
805 pub fn LLVMConstInlineAsm(Ty: TypeRef,
806 AsmString: *const c_char,
807 Constraints: *const c_char,
808 HasSideEffects: Bool,
811 pub fn LLVMBlockAddress(F: ValueRef, BB: BasicBlockRef) -> ValueRef;
815 /* Operations on global variables, functions, and aliases (globals) */
816 pub fn LLVMGetGlobalParent(Global: ValueRef) -> ModuleRef;
817 pub fn LLVMIsDeclaration(Global: ValueRef) -> Bool;
818 pub fn LLVMRustGetLinkage(Global: ValueRef) -> Linkage;
819 pub fn LLVMRustSetLinkage(Global: ValueRef, RustLinkage: Linkage);
820 pub fn LLVMGetSection(Global: ValueRef) -> *const c_char;
821 pub fn LLVMSetSection(Global: ValueRef, Section: *const c_char);
822 pub fn LLVMGetVisibility(Global: ValueRef) -> c_uint;
823 pub fn LLVMSetVisibility(Global: ValueRef, Viz: c_uint);
824 pub fn LLVMGetAlignment(Global: ValueRef) -> c_uint;
825 pub fn LLVMSetAlignment(Global: ValueRef, Bytes: c_uint);
826 pub fn LLVMSetDLLStorageClass(V: ValueRef,
830 /* Operations on global variables */
831 pub fn LLVMIsAGlobalVariable(GlobalVar: ValueRef) -> ValueRef;
832 pub fn LLVMAddGlobal(M: ModuleRef, Ty: TypeRef, Name: *const c_char)
834 pub fn LLVMAddGlobalInAddressSpace(M: ModuleRef,
837 AddressSpace: c_uint)
839 pub fn LLVMGetNamedGlobal(M: ModuleRef,
842 pub fn LLVMRustGetOrInsertGlobal(M: ModuleRef,
846 pub fn LLVMGetFirstGlobal(M: ModuleRef) -> ValueRef;
847 pub fn LLVMGetLastGlobal(M: ModuleRef) -> ValueRef;
848 pub fn LLVMGetNextGlobal(GlobalVar: ValueRef) -> ValueRef;
849 pub fn LLVMGetPreviousGlobal(GlobalVar: ValueRef) -> ValueRef;
850 pub fn LLVMDeleteGlobal(GlobalVar: ValueRef);
851 pub fn LLVMGetInitializer(GlobalVar: ValueRef) -> ValueRef;
852 pub fn LLVMSetInitializer(GlobalVar: ValueRef,
853 ConstantVal: ValueRef);
854 pub fn LLVMIsThreadLocal(GlobalVar: ValueRef) -> Bool;
855 pub fn LLVMSetThreadLocal(GlobalVar: ValueRef, IsThreadLocal: Bool);
856 pub fn LLVMIsGlobalConstant(GlobalVar: ValueRef) -> Bool;
857 pub fn LLVMSetGlobalConstant(GlobalVar: ValueRef, IsConstant: Bool);
858 pub fn LLVMRustGetNamedValue(M: ModuleRef, Name: *const c_char) -> ValueRef;
860 /* Operations on aliases */
861 pub fn LLVMAddAlias(M: ModuleRef,
867 /* Operations on functions */
868 pub fn LLVMAddFunction(M: ModuleRef,
872 pub fn LLVMGetNamedFunction(M: ModuleRef, Name: *const c_char) -> ValueRef;
873 pub fn LLVMGetFirstFunction(M: ModuleRef) -> ValueRef;
874 pub fn LLVMGetLastFunction(M: ModuleRef) -> ValueRef;
875 pub fn LLVMGetNextFunction(Fn: ValueRef) -> ValueRef;
876 pub fn LLVMGetPreviousFunction(Fn: ValueRef) -> ValueRef;
877 pub fn LLVMDeleteFunction(Fn: ValueRef);
878 pub fn LLVMRustGetOrInsertFunction(M: ModuleRef,
882 pub fn LLVMGetIntrinsicID(Fn: ValueRef) -> c_uint;
883 pub fn LLVMGetFunctionCallConv(Fn: ValueRef) -> c_uint;
884 pub fn LLVMSetFunctionCallConv(Fn: ValueRef, CC: c_uint);
885 pub fn LLVMGetGC(Fn: ValueRef) -> *const c_char;
886 pub fn LLVMSetGC(Fn: ValueRef, Name: *const c_char);
887 pub fn LLVMRustAddDereferenceableAttr(Fn: ValueRef, index: c_uint, bytes: u64);
888 pub fn LLVMRustAddFunctionAttribute(Fn: ValueRef, index: c_uint, PA: u64);
889 pub fn LLVMRustAddFunctionAttrString(Fn: ValueRef, index: c_uint, Name: *const c_char);
890 pub fn LLVMRustAddFunctionAttrStringValue(Fn: ValueRef, index: c_uint,
892 Value: *const c_char);
893 pub fn LLVMRustRemoveFunctionAttributes(Fn: ValueRef,
896 pub fn LLVMRustRemoveFunctionAttrString(Fn: ValueRef,
898 Name: *const c_char);
899 pub fn LLVMGetFunctionAttr(Fn: ValueRef) -> c_uint;
900 pub fn LLVMRemoveFunctionAttr(Fn: ValueRef, val: c_uint);
902 /* Operations on parameters */
903 pub fn LLVMCountParams(Fn: ValueRef) -> c_uint;
904 pub fn LLVMGetParams(Fn: ValueRef, Params: *const ValueRef);
905 pub fn LLVMGetParam(Fn: ValueRef, Index: c_uint) -> ValueRef;
906 pub fn LLVMGetParamParent(Inst: ValueRef) -> ValueRef;
907 pub fn LLVMGetFirstParam(Fn: ValueRef) -> ValueRef;
908 pub fn LLVMGetLastParam(Fn: ValueRef) -> ValueRef;
909 pub fn LLVMGetNextParam(Arg: ValueRef) -> ValueRef;
910 pub fn LLVMGetPreviousParam(Arg: ValueRef) -> ValueRef;
911 pub fn LLVMAddAttribute(Arg: ValueRef, PA: c_uint);
912 pub fn LLVMRemoveAttribute(Arg: ValueRef, PA: c_uint);
913 pub fn LLVMGetAttribute(Arg: ValueRef) -> c_uint;
914 pub fn LLVMSetParamAlignment(Arg: ValueRef, align: c_uint);
916 /* Operations on basic blocks */
917 pub fn LLVMBasicBlockAsValue(BB: BasicBlockRef) -> ValueRef;
918 pub fn LLVMValueIsBasicBlock(Val: ValueRef) -> Bool;
919 pub fn LLVMValueAsBasicBlock(Val: ValueRef) -> BasicBlockRef;
920 pub fn LLVMGetBasicBlockParent(BB: BasicBlockRef) -> ValueRef;
921 pub fn LLVMCountBasicBlocks(Fn: ValueRef) -> c_uint;
922 pub fn LLVMGetBasicBlocks(Fn: ValueRef, BasicBlocks: *const ValueRef);
923 pub fn LLVMGetFirstBasicBlock(Fn: ValueRef) -> BasicBlockRef;
924 pub fn LLVMGetLastBasicBlock(Fn: ValueRef) -> BasicBlockRef;
925 pub fn LLVMGetNextBasicBlock(BB: BasicBlockRef) -> BasicBlockRef;
926 pub fn LLVMGetPreviousBasicBlock(BB: BasicBlockRef) -> BasicBlockRef;
927 pub fn LLVMGetEntryBasicBlock(Fn: ValueRef) -> BasicBlockRef;
929 pub fn LLVMAppendBasicBlockInContext(C: ContextRef,
933 pub fn LLVMInsertBasicBlockInContext(C: ContextRef,
937 pub fn LLVMDeleteBasicBlock(BB: BasicBlockRef);
939 pub fn LLVMMoveBasicBlockAfter(BB: BasicBlockRef,
940 MoveAfter: BasicBlockRef);
942 pub fn LLVMMoveBasicBlockBefore(BB: BasicBlockRef,
943 MoveBefore: BasicBlockRef);
945 /* Operations on instructions */
946 pub fn LLVMGetInstructionParent(Inst: ValueRef) -> BasicBlockRef;
947 pub fn LLVMGetFirstInstruction(BB: BasicBlockRef) -> ValueRef;
948 pub fn LLVMGetLastInstruction(BB: BasicBlockRef) -> ValueRef;
949 pub fn LLVMGetNextInstruction(Inst: ValueRef) -> ValueRef;
950 pub fn LLVMGetPreviousInstruction(Inst: ValueRef) -> ValueRef;
951 pub fn LLVMInstructionEraseFromParent(Inst: ValueRef);
953 /* Operations on call sites */
954 pub fn LLVMSetInstructionCallConv(Instr: ValueRef, CC: c_uint);
955 pub fn LLVMGetInstructionCallConv(Instr: ValueRef) -> c_uint;
956 pub fn LLVMAddInstrAttribute(Instr: ValueRef,
959 pub fn LLVMRemoveInstrAttribute(Instr: ValueRef,
962 pub fn LLVMSetInstrParamAlignment(Instr: ValueRef,
965 pub fn LLVMRustAddCallSiteAttribute(Instr: ValueRef,
968 pub fn LLVMRustAddDereferenceableCallSiteAttr(Instr: ValueRef,
972 /* Operations on call instructions (only) */
973 pub fn LLVMIsTailCall(CallInst: ValueRef) -> Bool;
974 pub fn LLVMSetTailCall(CallInst: ValueRef, IsTailCall: Bool);
976 /* Operations on load/store instructions (only) */
977 pub fn LLVMGetVolatile(MemoryAccessInst: ValueRef) -> Bool;
978 pub fn LLVMSetVolatile(MemoryAccessInst: ValueRef, volatile: Bool);
980 /* Operations on phi nodes */
981 pub fn LLVMAddIncoming(PhiNode: ValueRef,
982 IncomingValues: *const ValueRef,
983 IncomingBlocks: *const BasicBlockRef,
985 pub fn LLVMCountIncoming(PhiNode: ValueRef) -> c_uint;
986 pub fn LLVMGetIncomingValue(PhiNode: ValueRef, Index: c_uint)
988 pub fn LLVMGetIncomingBlock(PhiNode: ValueRef, Index: c_uint)
991 /* Instruction builders */
992 pub fn LLVMCreateBuilderInContext(C: ContextRef) -> BuilderRef;
993 pub fn LLVMPositionBuilder(Builder: BuilderRef,
994 Block: BasicBlockRef,
996 pub fn LLVMPositionBuilderBefore(Builder: BuilderRef,
998 pub fn LLVMPositionBuilderAtEnd(Builder: BuilderRef,
999 Block: BasicBlockRef);
1000 pub fn LLVMGetInsertBlock(Builder: BuilderRef) -> BasicBlockRef;
1001 pub fn LLVMClearInsertionPosition(Builder: BuilderRef);
1002 pub fn LLVMInsertIntoBuilder(Builder: BuilderRef, Instr: ValueRef);
1003 pub fn LLVMInsertIntoBuilderWithName(Builder: BuilderRef,
1005 Name: *const c_char);
1006 pub fn LLVMDisposeBuilder(Builder: BuilderRef);
1009 pub fn LLVMSetCurrentDebugLocation(Builder: BuilderRef, L: ValueRef);
1010 pub fn LLVMGetCurrentDebugLocation(Builder: BuilderRef) -> ValueRef;
1011 pub fn LLVMSetInstDebugLocation(Builder: BuilderRef, Inst: ValueRef);
1014 pub fn LLVMBuildRetVoid(B: BuilderRef) -> ValueRef;
1015 pub fn LLVMBuildRet(B: BuilderRef, V: ValueRef) -> ValueRef;
1016 pub fn LLVMBuildAggregateRet(B: BuilderRef,
1017 RetVals: *const ValueRef,
1020 pub fn LLVMBuildBr(B: BuilderRef, Dest: BasicBlockRef) -> ValueRef;
1021 pub fn LLVMBuildCondBr(B: BuilderRef,
1023 Then: BasicBlockRef,
1024 Else: BasicBlockRef)
1026 pub fn LLVMBuildSwitch(B: BuilderRef,
1028 Else: BasicBlockRef,
1031 pub fn LLVMBuildIndirectBr(B: BuilderRef,
1035 pub fn LLVMRustBuildInvoke(B: BuilderRef,
1037 Args: *const ValueRef,
1039 Then: BasicBlockRef,
1040 Catch: BasicBlockRef,
1041 Bundle: OperandBundleDefRef,
1042 Name: *const c_char)
1044 pub fn LLVMRustBuildLandingPad(B: BuilderRef,
1048 Name: *const c_char,
1051 pub fn LLVMBuildResume(B: BuilderRef, Exn: ValueRef) -> ValueRef;
1052 pub fn LLVMBuildUnreachable(B: BuilderRef) -> ValueRef;
1054 pub fn LLVMRustBuildCleanupPad(B: BuilderRef,
1055 ParentPad: ValueRef,
1057 Args: *const ValueRef,
1058 Name: *const c_char) -> ValueRef;
1059 pub fn LLVMRustBuildCleanupRet(B: BuilderRef,
1060 CleanupPad: ValueRef,
1061 UnwindBB: BasicBlockRef) -> ValueRef;
1062 pub fn LLVMRustBuildCatchPad(B: BuilderRef,
1063 ParentPad: ValueRef,
1065 Args: *const ValueRef,
1066 Name: *const c_char) -> ValueRef;
1067 pub fn LLVMRustBuildCatchRet(B: BuilderRef,
1069 BB: BasicBlockRef) -> ValueRef;
1070 pub fn LLVMRustBuildCatchSwitch(Builder: BuilderRef,
1071 ParentPad: ValueRef,
1073 NumHandlers: c_uint,
1074 Name: *const c_char) -> ValueRef;
1075 pub fn LLVMRustAddHandler(CatchSwitch: ValueRef,
1076 Handler: BasicBlockRef);
1077 pub fn LLVMRustSetPersonalityFn(B: BuilderRef, Pers: ValueRef);
1079 /* Add a case to the switch instruction */
1080 pub fn LLVMAddCase(Switch: ValueRef,
1082 Dest: BasicBlockRef);
1084 /* Add a destination to the indirectbr instruction */
1085 pub fn LLVMAddDestination(IndirectBr: ValueRef, Dest: BasicBlockRef);
1087 /* Add a clause to the landing pad instruction */
1088 pub fn LLVMAddClause(LandingPad: ValueRef, ClauseVal: ValueRef);
1090 /* Set the cleanup on a landing pad instruction */
1091 pub fn LLVMSetCleanup(LandingPad: ValueRef, Val: Bool);
1094 pub fn LLVMBuildAdd(B: BuilderRef,
1097 Name: *const c_char)
1099 pub fn LLVMBuildNSWAdd(B: BuilderRef,
1102 Name: *const c_char)
1104 pub fn LLVMBuildNUWAdd(B: BuilderRef,
1107 Name: *const c_char)
1109 pub fn LLVMBuildFAdd(B: BuilderRef,
1112 Name: *const c_char)
1114 pub fn LLVMBuildSub(B: BuilderRef,
1117 Name: *const c_char)
1119 pub fn LLVMBuildNSWSub(B: BuilderRef,
1122 Name: *const c_char)
1124 pub fn LLVMBuildNUWSub(B: BuilderRef,
1127 Name: *const c_char)
1129 pub fn LLVMBuildFSub(B: BuilderRef,
1132 Name: *const c_char)
1134 pub fn LLVMBuildMul(B: BuilderRef,
1137 Name: *const c_char)
1139 pub fn LLVMBuildNSWMul(B: BuilderRef,
1142 Name: *const c_char)
1144 pub fn LLVMBuildNUWMul(B: BuilderRef,
1147 Name: *const c_char)
1149 pub fn LLVMBuildFMul(B: BuilderRef,
1152 Name: *const c_char)
1154 pub fn LLVMBuildUDiv(B: BuilderRef,
1157 Name: *const c_char)
1159 pub fn LLVMBuildSDiv(B: BuilderRef,
1162 Name: *const c_char)
1164 pub fn LLVMBuildExactSDiv(B: BuilderRef,
1167 Name: *const c_char)
1169 pub fn LLVMBuildFDiv(B: BuilderRef,
1172 Name: *const c_char)
1174 pub fn LLVMBuildURem(B: BuilderRef,
1177 Name: *const c_char)
1179 pub fn LLVMBuildSRem(B: BuilderRef,
1182 Name: *const c_char)
1184 pub fn LLVMBuildFRem(B: BuilderRef,
1187 Name: *const c_char)
1189 pub fn LLVMBuildShl(B: BuilderRef,
1192 Name: *const c_char)
1194 pub fn LLVMBuildLShr(B: BuilderRef,
1197 Name: *const c_char)
1199 pub fn LLVMBuildAShr(B: BuilderRef,
1202 Name: *const c_char)
1204 pub fn LLVMBuildAnd(B: BuilderRef,
1207 Name: *const c_char)
1209 pub fn LLVMBuildOr(B: BuilderRef,
1212 Name: *const c_char)
1214 pub fn LLVMBuildXor(B: BuilderRef,
1217 Name: *const c_char)
1219 pub fn LLVMBuildBinOp(B: BuilderRef,
1223 Name: *const c_char)
1225 pub fn LLVMBuildNeg(B: BuilderRef, V: ValueRef, Name: *const c_char)
1227 pub fn LLVMBuildNSWNeg(B: BuilderRef, V: ValueRef, Name: *const c_char)
1229 pub fn LLVMBuildNUWNeg(B: BuilderRef, V: ValueRef, Name: *const c_char)
1231 pub fn LLVMBuildFNeg(B: BuilderRef, V: ValueRef, Name: *const c_char)
1233 pub fn LLVMBuildNot(B: BuilderRef, V: ValueRef, Name: *const c_char)
1235 pub fn LLVMRustSetHasUnsafeAlgebra(Instr: ValueRef);
1238 pub fn LLVMBuildAlloca(B: BuilderRef, Ty: TypeRef, Name: *const c_char)
1240 pub fn LLVMBuildFree(B: BuilderRef, PointerVal: ValueRef) -> ValueRef;
1241 pub fn LLVMBuildLoad(B: BuilderRef,
1242 PointerVal: ValueRef,
1243 Name: *const c_char)
1246 pub fn LLVMBuildStore(B: BuilderRef, Val: ValueRef, Ptr: ValueRef)
1249 pub fn LLVMBuildGEP(B: BuilderRef,
1251 Indices: *const ValueRef,
1253 Name: *const c_char)
1255 pub fn LLVMBuildInBoundsGEP(B: BuilderRef,
1257 Indices: *const ValueRef,
1259 Name: *const c_char)
1261 pub fn LLVMBuildStructGEP(B: BuilderRef,
1264 Name: *const c_char)
1266 pub fn LLVMBuildGlobalString(B: BuilderRef,
1268 Name: *const c_char)
1270 pub fn LLVMBuildGlobalStringPtr(B: BuilderRef,
1272 Name: *const c_char)
1276 pub fn LLVMBuildTrunc(B: BuilderRef,
1279 Name: *const c_char)
1281 pub fn LLVMBuildZExt(B: BuilderRef,
1284 Name: *const c_char)
1286 pub fn LLVMBuildSExt(B: BuilderRef,
1289 Name: *const c_char)
1291 pub fn LLVMBuildFPToUI(B: BuilderRef,
1294 Name: *const c_char)
1296 pub fn LLVMBuildFPToSI(B: BuilderRef,
1299 Name: *const c_char)
1301 pub fn LLVMBuildUIToFP(B: BuilderRef,
1304 Name: *const c_char)
1306 pub fn LLVMBuildSIToFP(B: BuilderRef,
1309 Name: *const c_char)
1311 pub fn LLVMBuildFPTrunc(B: BuilderRef,
1314 Name: *const c_char)
1316 pub fn LLVMBuildFPExt(B: BuilderRef,
1319 Name: *const c_char)
1321 pub fn LLVMBuildPtrToInt(B: BuilderRef,
1324 Name: *const c_char)
1326 pub fn LLVMBuildIntToPtr(B: BuilderRef,
1329 Name: *const c_char)
1331 pub fn LLVMBuildBitCast(B: BuilderRef,
1334 Name: *const c_char)
1336 pub fn LLVMBuildZExtOrBitCast(B: BuilderRef,
1339 Name: *const c_char)
1341 pub fn LLVMBuildSExtOrBitCast(B: BuilderRef,
1344 Name: *const c_char)
1346 pub fn LLVMBuildTruncOrBitCast(B: BuilderRef,
1349 Name: *const c_char)
1351 pub fn LLVMBuildCast(B: BuilderRef,
1355 Name: *const c_char) -> ValueRef;
1356 pub fn LLVMBuildPointerCast(B: BuilderRef,
1359 Name: *const c_char)
1361 pub fn LLVMBuildIntCast(B: BuilderRef,
1364 Name: *const c_char)
1366 pub fn LLVMBuildFPCast(B: BuilderRef,
1369 Name: *const c_char)
1373 pub fn LLVMBuildICmp(B: BuilderRef,
1377 Name: *const c_char)
1379 pub fn LLVMBuildFCmp(B: BuilderRef,
1383 Name: *const c_char)
1386 /* Miscellaneous instructions */
1387 pub fn LLVMBuildPhi(B: BuilderRef, Ty: TypeRef, Name: *const c_char)
1389 pub fn LLVMRustBuildCall(B: BuilderRef,
1391 Args: *const ValueRef,
1393 Bundle: OperandBundleDefRef,
1394 Name: *const c_char)
1396 pub fn LLVMBuildSelect(B: BuilderRef,
1400 Name: *const c_char)
1402 pub fn LLVMBuildVAArg(B: BuilderRef,
1405 Name: *const c_char)
1407 pub fn LLVMBuildExtractElement(B: BuilderRef,
1410 Name: *const c_char)
1412 pub fn LLVMBuildInsertElement(B: BuilderRef,
1416 Name: *const c_char)
1418 pub fn LLVMBuildShuffleVector(B: BuilderRef,
1422 Name: *const c_char)
1424 pub fn LLVMBuildExtractValue(B: BuilderRef,
1427 Name: *const c_char)
1429 pub fn LLVMBuildInsertValue(B: BuilderRef,
1433 Name: *const c_char)
1436 pub fn LLVMBuildIsNull(B: BuilderRef, Val: ValueRef, Name: *const c_char)
1438 pub fn LLVMBuildIsNotNull(B: BuilderRef, Val: ValueRef, Name: *const c_char)
1440 pub fn LLVMBuildPtrDiff(B: BuilderRef,
1443 Name: *const c_char)
1446 /* Atomic Operations */
1447 pub fn LLVMRustBuildAtomicLoad(B: BuilderRef,
1448 PointerVal: ValueRef,
1449 Name: *const c_char,
1450 Order: AtomicOrdering,
1454 pub fn LLVMRustBuildAtomicStore(B: BuilderRef,
1457 Order: AtomicOrdering,
1461 pub fn LLVMRustBuildAtomicCmpXchg(B: BuilderRef,
1465 Order: AtomicOrdering,
1466 FailureOrder: AtomicOrdering,
1470 pub fn LLVMBuildAtomicRMW(B: BuilderRef,
1474 Order: AtomicOrdering,
1475 SingleThreaded: Bool)
1478 pub fn LLVMRustBuildAtomicFence(B: BuilderRef,
1479 Order: AtomicOrdering,
1480 Scope: SynchronizationScope);
1483 /* Selected entries from the downcasts. */
1484 pub fn LLVMIsATerminatorInst(Inst: ValueRef) -> ValueRef;
1485 pub fn LLVMIsAStoreInst(Inst: ValueRef) -> ValueRef;
1487 /// Writes a module to the specified path. Returns 0 on success.
1488 pub fn LLVMWriteBitcodeToFile(M: ModuleRef, Path: *const c_char) -> c_int;
1490 /// Creates target data from a target layout string.
1491 pub fn LLVMCreateTargetData(StringRep: *const c_char) -> TargetDataRef;
1492 /// Number of bytes clobbered when doing a Store to *T.
1493 pub fn LLVMStoreSizeOfType(TD: TargetDataRef, Ty: TypeRef)
1496 /// Number of bytes clobbered when doing a Store to *T.
1497 pub fn LLVMSizeOfTypeInBits(TD: TargetDataRef, Ty: TypeRef)
1500 /// Distance between successive elements in an array of T. Includes ABI padding.
1501 pub fn LLVMABISizeOfType(TD: TargetDataRef, Ty: TypeRef) -> c_ulonglong;
1503 /// Returns the preferred alignment of a type.
1504 pub fn LLVMPreferredAlignmentOfType(TD: TargetDataRef, Ty: TypeRef)
1506 /// Returns the minimum alignment of a type.
1507 pub fn LLVMABIAlignmentOfType(TD: TargetDataRef, Ty: TypeRef)
1510 /// Computes the byte offset of the indexed struct element for a
1512 pub fn LLVMOffsetOfElement(TD: TargetDataRef,
1517 /// Returns the minimum alignment of a type when part of a call frame.
1518 pub fn LLVMCallFrameAlignmentOfType(TD: TargetDataRef, Ty: TypeRef)
1521 /// Disposes target data.
1522 pub fn LLVMDisposeTargetData(TD: TargetDataRef);
1524 /// Creates a pass manager.
1525 pub fn LLVMCreatePassManager() -> PassManagerRef;
1527 /// Creates a function-by-function pass manager
1528 pub fn LLVMCreateFunctionPassManagerForModule(M: ModuleRef)
1531 /// Disposes a pass manager.
1532 pub fn LLVMDisposePassManager(PM: PassManagerRef);
1534 /// Runs a pass manager on a module.
1535 pub fn LLVMRunPassManager(PM: PassManagerRef, M: ModuleRef) -> Bool;
1537 /// Runs the function passes on the provided function.
1538 pub fn LLVMRunFunctionPassManager(FPM: PassManagerRef, F: ValueRef)
1541 /// Initializes all the function passes scheduled in the manager
1542 pub fn LLVMInitializeFunctionPassManager(FPM: PassManagerRef) -> Bool;
1544 /// Finalizes all the function passes scheduled in the manager
1545 pub fn LLVMFinalizeFunctionPassManager(FPM: PassManagerRef) -> Bool;
1547 pub fn LLVMInitializePasses();
1549 /// Adds a verification pass.
1550 pub fn LLVMAddVerifierPass(PM: PassManagerRef);
1552 pub fn LLVMAddGlobalOptimizerPass(PM: PassManagerRef);
1553 pub fn LLVMAddIPSCCPPass(PM: PassManagerRef);
1554 pub fn LLVMAddDeadArgEliminationPass(PM: PassManagerRef);
1555 pub fn LLVMAddInstructionCombiningPass(PM: PassManagerRef);
1556 pub fn LLVMAddCFGSimplificationPass(PM: PassManagerRef);
1557 pub fn LLVMAddFunctionInliningPass(PM: PassManagerRef);
1558 pub fn LLVMAddFunctionAttrsPass(PM: PassManagerRef);
1559 pub fn LLVMAddScalarReplAggregatesPass(PM: PassManagerRef);
1560 pub fn LLVMAddScalarReplAggregatesPassSSA(PM: PassManagerRef);
1561 pub fn LLVMAddJumpThreadingPass(PM: PassManagerRef);
1562 pub fn LLVMAddConstantPropagationPass(PM: PassManagerRef);
1563 pub fn LLVMAddReassociatePass(PM: PassManagerRef);
1564 pub fn LLVMAddLoopRotatePass(PM: PassManagerRef);
1565 pub fn LLVMAddLICMPass(PM: PassManagerRef);
1566 pub fn LLVMAddLoopUnswitchPass(PM: PassManagerRef);
1567 pub fn LLVMAddLoopDeletionPass(PM: PassManagerRef);
1568 pub fn LLVMAddLoopUnrollPass(PM: PassManagerRef);
1569 pub fn LLVMAddGVNPass(PM: PassManagerRef);
1570 pub fn LLVMAddMemCpyOptPass(PM: PassManagerRef);
1571 pub fn LLVMAddSCCPPass(PM: PassManagerRef);
1572 pub fn LLVMAddDeadStoreEliminationPass(PM: PassManagerRef);
1573 pub fn LLVMAddStripDeadPrototypesPass(PM: PassManagerRef);
1574 pub fn LLVMAddConstantMergePass(PM: PassManagerRef);
1575 pub fn LLVMAddArgumentPromotionPass(PM: PassManagerRef);
1576 pub fn LLVMAddTailCallEliminationPass(PM: PassManagerRef);
1577 pub fn LLVMAddIndVarSimplifyPass(PM: PassManagerRef);
1578 pub fn LLVMAddAggressiveDCEPass(PM: PassManagerRef);
1579 pub fn LLVMAddGlobalDCEPass(PM: PassManagerRef);
1580 pub fn LLVMAddCorrelatedValuePropagationPass(PM: PassManagerRef);
1581 pub fn LLVMAddPruneEHPass(PM: PassManagerRef);
1582 pub fn LLVMAddSimplifyLibCallsPass(PM: PassManagerRef);
1583 pub fn LLVMAddLoopIdiomPass(PM: PassManagerRef);
1584 pub fn LLVMAddEarlyCSEPass(PM: PassManagerRef);
1585 pub fn LLVMAddTypeBasedAliasAnalysisPass(PM: PassManagerRef);
1586 pub fn LLVMAddBasicAliasAnalysisPass(PM: PassManagerRef);
1588 pub fn LLVMPassManagerBuilderCreate() -> PassManagerBuilderRef;
1589 pub fn LLVMPassManagerBuilderDispose(PMB: PassManagerBuilderRef);
1590 pub fn LLVMPassManagerBuilderSetOptLevel(PMB: PassManagerBuilderRef,
1591 OptimizationLevel: c_uint);
1592 pub fn LLVMPassManagerBuilderSetSizeLevel(PMB: PassManagerBuilderRef,
1594 pub fn LLVMPassManagerBuilderSetDisableUnitAtATime(
1595 PMB: PassManagerBuilderRef,
1597 pub fn LLVMPassManagerBuilderSetDisableUnrollLoops(
1598 PMB: PassManagerBuilderRef,
1600 pub fn LLVMPassManagerBuilderSetDisableSimplifyLibCalls(
1601 PMB: PassManagerBuilderRef,
1603 pub fn LLVMPassManagerBuilderUseInlinerWithThreshold(
1604 PMB: PassManagerBuilderRef,
1606 pub fn LLVMPassManagerBuilderPopulateModulePassManager(
1607 PMB: PassManagerBuilderRef,
1608 PM: PassManagerRef);
1610 pub fn LLVMPassManagerBuilderPopulateFunctionPassManager(
1611 PMB: PassManagerBuilderRef,
1612 PM: PassManagerRef);
1613 pub fn LLVMPassManagerBuilderPopulateLTOPassManager(
1614 PMB: PassManagerBuilderRef,
1619 /// Destroys a memory buffer.
1620 pub fn LLVMDisposeMemoryBuffer(MemBuf: MemoryBufferRef);
1623 /* Stuff that's in rustllvm/ because it's not upstream yet. */
1625 /// Opens an object file.
1626 pub fn LLVMCreateObjectFile(MemBuf: MemoryBufferRef) -> ObjectFileRef;
1627 /// Closes an object file.
1628 pub fn LLVMDisposeObjectFile(ObjFile: ObjectFileRef);
1630 /// Enumerates the sections in an object file.
1631 pub fn LLVMGetSections(ObjFile: ObjectFileRef) -> SectionIteratorRef;
1632 /// Destroys a section iterator.
1633 pub fn LLVMDisposeSectionIterator(SI: SectionIteratorRef);
1634 /// Returns true if the section iterator is at the end of the section
1636 pub fn LLVMIsSectionIteratorAtEnd(ObjFile: ObjectFileRef,
1637 SI: SectionIteratorRef)
1639 /// Moves the section iterator to point to the next section.
1640 pub fn LLVMMoveToNextSection(SI: SectionIteratorRef);
1641 /// Returns the current section size.
1642 pub fn LLVMGetSectionSize(SI: SectionIteratorRef) -> c_ulonglong;
1643 /// Returns the current section contents as a string buffer.
1644 pub fn LLVMGetSectionContents(SI: SectionIteratorRef) -> *const c_char;
1646 /// Reads the given file and returns it as a memory buffer. Use
1647 /// LLVMDisposeMemoryBuffer() to get rid of it.
1648 pub fn LLVMRustCreateMemoryBufferWithContentsOfFile(Path: *const c_char)
1650 /// Borrows the contents of the memory buffer (doesn't copy it)
1651 pub fn LLVMCreateMemoryBufferWithMemoryRange(InputData: *const c_char,
1652 InputDataLength: size_t,
1653 BufferName: *const c_char,
1656 pub fn LLVMCreateMemoryBufferWithMemoryRangeCopy(InputData: *const c_char,
1657 InputDataLength: size_t,
1658 BufferName: *const c_char)
1661 pub fn LLVMIsMultithreaded() -> Bool;
1662 pub fn LLVMStartMultithreaded() -> Bool;
1664 /// Returns a string describing the last error caused by an LLVMRust* call.
1665 pub fn LLVMRustGetLastError() -> *const c_char;
1667 /// Print the pass timings since static dtors aren't picking them up.
1668 pub fn LLVMRustPrintPassTimings();
1670 pub fn LLVMStructCreateNamed(C: ContextRef, Name: *const c_char) -> TypeRef;
1672 pub fn LLVMStructSetBody(StructTy: TypeRef,
1673 ElementTypes: *const TypeRef,
1674 ElementCount: c_uint,
1677 pub fn LLVMConstNamedStruct(S: TypeRef,
1678 ConstantVals: *const ValueRef,
1682 /// Enables LLVM debug output.
1683 pub fn LLVMRustSetDebug(Enabled: c_int);
1685 /// Prepares inline assembly.
1686 pub fn LLVMRustInlineAsm(Ty: TypeRef,
1687 AsmString: *const c_char,
1688 Constraints: *const c_char,
1691 Dialect: AsmDialect)
1694 pub fn LLVMRustDebugMetadataVersion() -> u32;
1695 pub fn LLVMRustVersionMajor() -> u32;
1696 pub fn LLVMRustVersionMinor() -> u32;
1698 pub fn LLVMRustAddModuleFlag(M: ModuleRef,
1699 name: *const c_char,
1702 pub fn LLVMRustDIBuilderCreate(M: ModuleRef) -> DIBuilderRef;
1704 pub fn LLVMRustDIBuilderDispose(Builder: DIBuilderRef);
1706 pub fn LLVMRustDIBuilderFinalize(Builder: DIBuilderRef);
1708 pub fn LLVMRustDIBuilderCreateCompileUnit(Builder: DIBuilderRef,
1710 File: *const c_char,
1712 Producer: *const c_char,
1714 Flags: *const c_char,
1716 SplitName: *const c_char)
1719 pub fn LLVMRustDIBuilderCreateFile(Builder: DIBuilderRef,
1720 Filename: *const c_char,
1721 Directory: *const c_char)
1724 pub fn LLVMRustDIBuilderCreateSubroutineType(Builder: DIBuilderRef,
1726 ParameterTypes: DIArray)
1729 pub fn LLVMRustDIBuilderCreateFunction(Builder: DIBuilderRef,
1730 Scope: DIDescriptor,
1731 Name: *const c_char,
1732 LinkageName: *const c_char,
1736 isLocalToUnit: bool,
1746 pub fn LLVMRustDIBuilderCreateBasicType(Builder: DIBuilderRef,
1747 Name: *const c_char,
1753 pub fn LLVMRustDIBuilderCreatePointerType(Builder: DIBuilderRef,
1757 Name: *const c_char)
1760 pub fn LLVMRustDIBuilderCreateStructType(Builder: DIBuilderRef,
1761 Scope: DIDescriptor,
1762 Name: *const c_char,
1768 DerivedFrom: DIType,
1770 RunTimeLang: c_uint,
1771 VTableHolder: DIType,
1772 UniqueId: *const c_char)
1775 pub fn LLVMRustDIBuilderCreateMemberType(Builder: DIBuilderRef,
1776 Scope: DIDescriptor,
1777 Name: *const c_char,
1787 pub fn LLVMRustDIBuilderCreateLexicalBlock(Builder: DIBuilderRef,
1794 pub fn LLVMRustDIBuilderCreateLexicalBlockFile(Builder: DIBuilderRef,
1799 pub fn LLVMRustDIBuilderCreateStaticVariable(Builder: DIBuilderRef,
1801 Name: *const c_char,
1802 LinkageName: *const c_char,
1806 isLocalToUnit: bool,
1809 -> DIGlobalVariable;
1811 pub fn LLVMRustDIBuilderCreateVariable(Builder: DIBuilderRef,
1813 Scope: DIDescriptor,
1814 Name: *const c_char,
1818 AlwaysPreserve: bool,
1820 AddrOps: *const i64,
1821 AddrOpsCount: c_uint,
1825 pub fn LLVMRustDIBuilderCreateArrayType(Builder: DIBuilderRef,
1829 Subscripts: DIArray)
1832 pub fn LLVMRustDIBuilderCreateVectorType(Builder: DIBuilderRef,
1836 Subscripts: DIArray)
1839 pub fn LLVMRustDIBuilderGetOrCreateSubrange(Builder: DIBuilderRef,
1844 pub fn LLVMRustDIBuilderGetOrCreateArray(Builder: DIBuilderRef,
1845 Ptr: *const DIDescriptor,
1849 pub fn LLVMRustDIBuilderInsertDeclareAtEnd(Builder: DIBuilderRef,
1851 VarInfo: DIVariable,
1852 AddrOps: *const i64,
1853 AddrOpsCount: c_uint,
1855 InsertAtEnd: BasicBlockRef)
1858 pub fn LLVMRustDIBuilderInsertDeclareBefore(Builder: DIBuilderRef,
1860 VarInfo: DIVariable,
1861 AddrOps: *const i64,
1862 AddrOpsCount: c_uint,
1864 InsertBefore: ValueRef)
1867 pub fn LLVMRustDIBuilderCreateEnumerator(Builder: DIBuilderRef,
1868 Name: *const c_char,
1872 pub fn LLVMRustDIBuilderCreateEnumerationType(Builder: DIBuilderRef,
1874 Name: *const c_char,
1883 pub fn LLVMRustDIBuilderCreateUnionType(Builder: DIBuilderRef,
1885 Name: *const c_char,
1892 RunTimeLang: c_uint,
1893 UniqueId: *const c_char)
1896 pub fn LLVMSetUnnamedAddr(GlobalVar: ValueRef, UnnamedAddr: Bool);
1898 pub fn LLVMRustDIBuilderCreateTemplateTypeParameter(Builder: DIBuilderRef,
1900 Name: *const c_char,
1905 -> DITemplateTypeParameter;
1908 pub fn LLVMRustDIBuilderCreateNameSpace(Builder: DIBuilderRef,
1910 Name: *const c_char,
1914 pub fn LLVMRustDICompositeTypeSetTypeArray(Builder: DIBuilderRef,
1915 CompositeType: DIType,
1916 TypeArray: DIArray);
1919 pub fn LLVMRustDIBuilderCreateDebugLocation(Context: ContextRef,
1923 InlinedAt: MetadataRef)
1925 pub fn LLVMRustDIBuilderCreateOpDeref() -> i64;
1926 pub fn LLVMRustDIBuilderCreateOpPlus() -> i64;
1928 pub fn LLVMRustWriteTypeToString(Type: TypeRef, s: RustStringRef);
1929 pub fn LLVMRustWriteValueToString(value_ref: ValueRef, s: RustStringRef);
1931 pub fn LLVMIsAArgument(value_ref: ValueRef) -> ValueRef;
1933 pub fn LLVMIsAAllocaInst(value_ref: ValueRef) -> ValueRef;
1934 pub fn LLVMIsAConstantInt(value_ref: ValueRef) -> ValueRef;
1936 pub fn LLVMRustPassKind(Pass: PassRef) -> PassKind;
1937 pub fn LLVMRustFindAndCreatePass(Pass: *const c_char) -> PassRef;
1938 pub fn LLVMRustAddPass(PM: PassManagerRef, Pass: PassRef);
1940 pub fn LLVMRustHasFeature(T: TargetMachineRef,
1941 s: *const c_char) -> bool;
1943 pub fn LLVMRustPrintTargetCPUs(T: TargetMachineRef);
1944 pub fn LLVMRustPrintTargetFeatures(T: TargetMachineRef);
1946 pub fn LLVMRustCreateTargetMachine(Triple: *const c_char,
1948 Features: *const c_char,
1951 Level: CodeGenOptLevel,
1953 PositionIndependentExecutable: bool,
1954 FunctionSections: bool,
1955 DataSections: bool) -> TargetMachineRef;
1956 pub fn LLVMRustDisposeTargetMachine(T: TargetMachineRef);
1957 pub fn LLVMRustAddAnalysisPasses(T: TargetMachineRef,
1960 pub fn LLVMRustAddBuilderLibraryInfo(PMB: PassManagerBuilderRef,
1962 DisableSimplifyLibCalls: bool);
1963 pub fn LLVMRustConfigurePassManagerBuilder(PMB: PassManagerBuilderRef,
1964 OptLevel: CodeGenOptLevel,
1965 MergeFunctions: 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,
1974 Output: *const c_char,
1977 pub fn LLVMRustPrintModule(PM: PassManagerRef,
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,
1987 len: size_t) -> bool;
1988 pub fn LLVMRustRunRestrictionPass(M: ModuleRef,
1989 syms: *const *const c_char,
1991 pub fn LLVMRustMarkAllFunctionsNounwind(M: ModuleRef);
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);
2004 pub fn LLVMRustGetSectionName(SI: SectionIteratorRef,
2005 data: *mut *const c_char) -> size_t;
2007 pub fn LLVMRustWriteTwineToString(T: TwineRef, s: RustStringRef);
2009 pub fn LLVMContextSetDiagnosticHandler(C: ContextRef,
2010 Handler: DiagnosticHandler,
2011 DiagnosticContext: *mut c_void);
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);
2023 pub fn LLVMRustWriteDiagnosticInfoToString(DI: DiagnosticInfoRef,
2025 pub fn LLVMGetDiagInfoSeverity(DI: DiagnosticInfoRef) -> DiagnosticSeverity;
2026 pub fn LLVMRustGetDiagInfoKind(DI: DiagnosticInfoRef) -> DiagnosticKind;
2028 pub fn LLVMRustWriteDebugLocToString(C: ContextRef,
2032 pub fn LLVMRustSetInlineAsmDiagnosticHandler(C: ContextRef,
2033 H: InlineAsmDiagHandler,
2036 pub fn LLVMRustWriteSMDiagnosticToString(d: SMDiagnosticRef, s: RustStringRef);
2038 pub fn LLVMRustWriteArchive(Dst: *const c_char,
2040 Members: *const RustArchiveMemberRef,
2042 Kind: ArchiveKind) ->
2044 pub fn LLVMRustArchiveMemberNew(Filename: *const c_char,
2045 Name: *const c_char,
2046 Child: ArchiveChildRef) -> RustArchiveMemberRef;
2047 pub fn LLVMRustArchiveMemberFree(Member: RustArchiveMemberRef);
2049 pub fn LLVMRustSetDataLayoutFromTargetMachine(M: ModuleRef,
2050 TM: TargetMachineRef);
2051 pub fn LLVMRustGetModuleDataLayout(M: ModuleRef) -> TargetDataRef;
2053 pub fn LLVMRustBuildOperandBundleDef(Name: *const c_char,
2054 Inputs: *const ValueRef,
2056 -> OperandBundleDefRef;
2057 pub fn LLVMRustFreeOperandBundleDef(Bundle: OperandBundleDefRef);
2059 pub fn LLVMRustPositionBuilderAtStart(B: BuilderRef, BB: BasicBlockRef);
2061 pub fn LLVMRustSetComdat(M: ModuleRef, V: ValueRef, Name: *const c_char);
2062 pub fn LLVMRustUnsetComdat(V: ValueRef);
2063 pub fn LLVMRustSetModulePIELevel(M: ModuleRef);
2067 // LLVM requires symbols from this library, but apparently they're not printed
2068 // during llvm-config?
2070 #[link(name = "ole32")]