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 // FIXME: Rename 'DIGlobalVariable' to 'DIGlobalVariableExpression'
12 // once support for LLVM 3.9 is dropped.
14 // This method was changed in this LLVM patch:
15 // https://reviews.llvm.org/D26769
17 use debuginfo::{DIBuilderRef, DIDescriptor, DIFile, DILexicalBlock, DISubprogram, DIType,
18 DIBasicType, DIDerivedType, DICompositeType, DIScope, DIVariable,
19 DIGlobalVariable, DIArray, DISubrange, DITemplateTypeParameter, DIEnumerator,
20 DINameSpace, DIFlags};
22 use libc::{c_uint, c_int, size_t, c_char};
23 use libc::{c_longlong, c_ulonglong, c_void};
27 pub type Opcode = u32;
28 pub type Bool = c_uint;
30 pub const True: Bool = 1 as Bool;
31 pub const False: Bool = 0 as Bool;
33 #[derive(Copy, Clone, PartialEq)]
35 pub enum LLVMRustResult {
39 // Consts for the LLVM CallConv type, pre-cast to usize.
41 /// LLVM CallingConv::ID. Should we wrap this?
42 #[derive(Copy, Clone, PartialEq, Debug)]
48 X86StdcallCallConv = 64,
49 X86FastcallCallConv = 65,
50 ArmAapcsCallConv = 67,
59 #[derive(Copy, Clone, PartialEq, Eq, Hash, Debug)]
63 AvailableExternallyLinkage = 1,
64 LinkOnceAnyLinkage = 2,
65 LinkOnceODRLinkage = 3,
71 ExternalWeakLinkage = 9,
76 #[derive(Copy, Clone, PartialEq, Eq, Hash, Debug)]
84 /// LLVMDiagnosticSeverity
85 #[derive(Copy, Clone, Debug)]
87 pub enum DiagnosticSeverity {
94 /// LLVMDLLStorageClass
95 #[derive(Copy, Clone)]
97 pub enum DLLStorageClass {
99 DllImport = 1, // Function to be imported from DLL.
100 DllExport = 2, // Function to be accessible from DLL.
103 /// Matches LLVMRustAttribute in rustllvm.h
104 /// Semantically a subset of the C++ enum llvm::Attribute::AttrKind,
105 /// though it is not ABI compatible (since it's a C++ enum)
107 #[derive(Copy, Clone, Debug)]
122 OptimizeForSize = 13,
130 SanitizeAddress = 21,
135 #[derive(Copy, Clone)]
137 pub enum IntPredicate {
150 /// LLVMRealPredicate
151 #[derive(Copy, Clone)]
153 pub enum RealPredicate {
154 RealPredicateFalse = 0,
169 RealPredicateTrue = 15,
173 #[derive(Copy, Clone, PartialEq, Debug)]
195 /// LLVMAtomicRmwBinOp
196 #[derive(Copy, Clone)]
198 pub enum AtomicRmwBinOp {
212 /// LLVMAtomicOrdering
213 #[derive(Copy, Clone)]
215 pub enum AtomicOrdering {
219 // Consume = 3, // Not specified yet.
223 SequentiallyConsistent = 7,
226 /// LLVMRustSynchronizationScope
227 #[derive(Copy, Clone)]
229 pub enum SynchronizationScope {
236 #[derive(Copy, Clone)]
245 #[derive(Copy, Clone)]
247 pub enum MetadataType {
254 MD_invariant_load = 6,
258 MD_mem_parallel_loop_access = 10,
262 /// LLVMRustAsmDialect
263 #[derive(Copy, Clone)]
265 pub enum AsmDialect {
271 /// LLVMRustCodeGenOptLevel
272 #[derive(Copy, Clone, PartialEq)]
274 pub enum CodeGenOptLevel {
283 #[derive(Copy, Clone, PartialEq)]
292 /// LLVMRustCodeModel
293 #[derive(Copy, Clone)]
305 /// LLVMRustDiagnosticKind
306 #[derive(Copy, Clone)]
308 pub enum DiagnosticKind {
312 DebugMetadataVersion,
315 OptimizationRemarkMissed,
316 OptimizationRemarkAnalysis,
317 OptimizationRemarkAnalysisFPCommute,
318 OptimizationRemarkAnalysisAliasing,
319 OptimizationRemarkOther,
323 /// LLVMRustArchiveKind
324 #[derive(Copy, Clone)]
326 pub enum ArchiveKind {
335 #[derive(Copy, Clone, PartialEq, Debug)]
343 // Opaque pointer types
344 #[allow(missing_copy_implementations)]
345 pub enum Module_opaque {}
346 pub type ModuleRef = *mut Module_opaque;
347 #[allow(missing_copy_implementations)]
348 pub enum Context_opaque {}
349 pub type ContextRef = *mut Context_opaque;
350 #[allow(missing_copy_implementations)]
351 pub enum Type_opaque {}
352 pub type TypeRef = *mut Type_opaque;
353 #[allow(missing_copy_implementations)]
354 pub enum Value_opaque {}
355 pub type ValueRef = *mut Value_opaque;
356 #[allow(missing_copy_implementations)]
357 pub enum Metadata_opaque {}
358 pub type MetadataRef = *mut Metadata_opaque;
359 #[allow(missing_copy_implementations)]
360 pub enum BasicBlock_opaque {}
361 pub type BasicBlockRef = *mut BasicBlock_opaque;
362 #[allow(missing_copy_implementations)]
363 pub enum Builder_opaque {}
364 pub type BuilderRef = *mut Builder_opaque;
365 #[allow(missing_copy_implementations)]
366 pub enum ExecutionEngine_opaque {}
367 pub type ExecutionEngineRef = *mut ExecutionEngine_opaque;
368 #[allow(missing_copy_implementations)]
369 pub enum MemoryBuffer_opaque {}
370 pub type MemoryBufferRef = *mut MemoryBuffer_opaque;
371 #[allow(missing_copy_implementations)]
372 pub enum PassManager_opaque {}
373 pub type PassManagerRef = *mut PassManager_opaque;
374 #[allow(missing_copy_implementations)]
375 pub enum PassManagerBuilder_opaque {}
376 pub type PassManagerBuilderRef = *mut PassManagerBuilder_opaque;
377 #[allow(missing_copy_implementations)]
378 pub enum Use_opaque {}
379 pub type UseRef = *mut Use_opaque;
380 #[allow(missing_copy_implementations)]
381 pub enum TargetData_opaque {}
382 pub type TargetDataRef = *mut TargetData_opaque;
383 #[allow(missing_copy_implementations)]
384 pub enum ObjectFile_opaque {}
385 pub type ObjectFileRef = *mut ObjectFile_opaque;
386 #[allow(missing_copy_implementations)]
387 pub enum SectionIterator_opaque {}
388 pub type SectionIteratorRef = *mut SectionIterator_opaque;
389 #[allow(missing_copy_implementations)]
390 pub enum Pass_opaque {}
391 pub type PassRef = *mut Pass_opaque;
392 #[allow(missing_copy_implementations)]
393 pub enum TargetMachine_opaque {}
394 pub type TargetMachineRef = *mut TargetMachine_opaque;
395 pub enum Archive_opaque {}
396 pub type ArchiveRef = *mut Archive_opaque;
397 pub enum ArchiveIterator_opaque {}
398 pub type ArchiveIteratorRef = *mut ArchiveIterator_opaque;
399 pub enum ArchiveChild_opaque {}
400 pub type ArchiveChildRef = *mut ArchiveChild_opaque;
401 #[allow(missing_copy_implementations)]
402 pub enum Twine_opaque {}
403 pub type TwineRef = *mut Twine_opaque;
404 #[allow(missing_copy_implementations)]
405 pub enum DiagnosticInfo_opaque {}
406 pub type DiagnosticInfoRef = *mut DiagnosticInfo_opaque;
407 #[allow(missing_copy_implementations)]
408 pub enum DebugLoc_opaque {}
409 pub type DebugLocRef = *mut DebugLoc_opaque;
410 #[allow(missing_copy_implementations)]
411 pub enum SMDiagnostic_opaque {}
412 pub type SMDiagnosticRef = *mut SMDiagnostic_opaque;
413 #[allow(missing_copy_implementations)]
414 pub enum RustArchiveMember_opaque {}
415 pub type RustArchiveMemberRef = *mut RustArchiveMember_opaque;
416 #[allow(missing_copy_implementations)]
417 pub enum OperandBundleDef_opaque {}
418 pub type OperandBundleDefRef = *mut OperandBundleDef_opaque;
420 pub type DiagnosticHandler = unsafe extern "C" fn(DiagnosticInfoRef, *mut c_void);
421 pub type InlineAsmDiagHandler = unsafe extern "C" fn(SMDiagnosticRef, *const c_void, c_uint);
425 use super::MetadataRef;
427 #[allow(missing_copy_implementations)]
428 pub enum DIBuilder_opaque {}
429 pub type DIBuilderRef = *mut DIBuilder_opaque;
431 pub type DIDescriptor = MetadataRef;
432 pub type DIScope = DIDescriptor;
433 pub type DILocation = DIDescriptor;
434 pub type DIFile = DIScope;
435 pub type DILexicalBlock = DIScope;
436 pub type DISubprogram = DIScope;
437 pub type DINameSpace = DIScope;
438 pub type DIType = DIDescriptor;
439 pub type DIBasicType = DIType;
440 pub type DIDerivedType = DIType;
441 pub type DICompositeType = DIDerivedType;
442 pub type DIVariable = DIDescriptor;
443 pub type DIGlobalVariable = DIDescriptor;
444 pub type DIArray = DIDescriptor;
445 pub type DISubrange = DIDescriptor;
446 pub type DIEnumerator = DIDescriptor;
447 pub type DITemplateTypeParameter = DIDescriptor;
449 // These values **must** match with LLVMRustDIFlags!!
452 #[derive(Debug, Default)]
453 flags DIFlags: ::libc::uint32_t {
455 const FlagPrivate = 1,
456 const FlagProtected = 2,
457 const FlagPublic = 3,
458 const FlagFwdDecl = (1 << 2),
459 const FlagAppleBlock = (1 << 3),
460 const FlagBlockByrefStruct = (1 << 4),
461 const FlagVirtual = (1 << 5),
462 const FlagArtificial = (1 << 6),
463 const FlagExplicit = (1 << 7),
464 const FlagPrototyped = (1 << 8),
465 const FlagObjcClassComplete = (1 << 9),
466 const FlagObjectPointer = (1 << 10),
467 const FlagVector = (1 << 11),
468 const FlagStaticMember = (1 << 12),
469 const FlagLValueReference = (1 << 13),
470 const FlagRValueReference = (1 << 14),
476 // Link to our native llvm bindings (things that we need to use the C++ api
477 // for) and because llvm is written in C++ we need to link against libstdc++
479 // You'll probably notice that there is an omission of all LLVM libraries
480 // from this location. This is because the set of LLVM libraries that we
481 // link to is mostly defined by LLVM, and the `llvm-config` tool is used to
482 // figure out the exact set of libraries. To do this, the build system
483 // generates an llvmdeps.rs file next to this one which will be
484 // automatically updated whenever LLVM is updated to include an up-to-date
485 // set of the libraries we need to link to LLVM for.
486 #[link(name = "rustllvm", kind = "static")] // not quite true but good enough
488 // Create and destroy contexts.
489 pub fn LLVMContextCreate() -> ContextRef;
490 pub fn LLVMContextDispose(C: ContextRef);
491 pub fn LLVMGetMDKindIDInContext(C: ContextRef, Name: *const c_char, SLen: c_uint) -> c_uint;
493 // Create and destroy modules.
494 pub fn LLVMModuleCreateWithNameInContext(ModuleID: *const c_char, C: ContextRef) -> ModuleRef;
495 pub fn LLVMGetModuleContext(M: ModuleRef) -> ContextRef;
496 pub fn LLVMCloneModule(M: ModuleRef) -> ModuleRef;
497 pub fn LLVMDisposeModule(M: ModuleRef);
499 /// Data layout. See Module::getDataLayout.
500 pub fn LLVMGetDataLayout(M: ModuleRef) -> *const c_char;
501 pub fn LLVMSetDataLayout(M: ModuleRef, Triple: *const c_char);
503 /// See Module::dump.
504 pub fn LLVMDumpModule(M: ModuleRef);
506 /// See Module::setModuleInlineAsm.
507 pub fn LLVMSetModuleInlineAsm(M: ModuleRef, Asm: *const c_char);
509 /// See llvm::LLVMTypeKind::getTypeID.
510 pub fn LLVMRustGetTypeKind(Ty: TypeRef) -> TypeKind;
512 /// See llvm::Value::getContext
513 pub fn LLVMRustGetValueContext(V: ValueRef) -> ContextRef;
515 // Operations on integer types
516 pub fn LLVMInt1TypeInContext(C: ContextRef) -> TypeRef;
517 pub fn LLVMInt8TypeInContext(C: ContextRef) -> TypeRef;
518 pub fn LLVMInt16TypeInContext(C: ContextRef) -> TypeRef;
519 pub fn LLVMInt32TypeInContext(C: ContextRef) -> TypeRef;
520 pub fn LLVMInt64TypeInContext(C: ContextRef) -> TypeRef;
521 pub fn LLVMIntTypeInContext(C: ContextRef, NumBits: c_uint) -> TypeRef;
523 pub fn LLVMGetIntTypeWidth(IntegerTy: TypeRef) -> c_uint;
525 // Operations on real types
526 pub fn LLVMFloatTypeInContext(C: ContextRef) -> TypeRef;
527 pub fn LLVMDoubleTypeInContext(C: ContextRef) -> TypeRef;
529 // Operations on function types
530 pub fn LLVMFunctionType(ReturnType: TypeRef,
531 ParamTypes: *const TypeRef,
535 pub fn LLVMGetReturnType(FunctionTy: TypeRef) -> TypeRef;
536 pub fn LLVMCountParamTypes(FunctionTy: TypeRef) -> c_uint;
537 pub fn LLVMGetParamTypes(FunctionTy: TypeRef, Dest: *mut TypeRef);
539 // Operations on struct types
540 pub fn LLVMStructTypeInContext(C: ContextRef,
541 ElementTypes: *const TypeRef,
542 ElementCount: c_uint,
545 pub fn LLVMCountStructElementTypes(StructTy: TypeRef) -> c_uint;
546 pub fn LLVMGetStructElementTypes(StructTy: TypeRef, Dest: *mut TypeRef);
547 pub fn LLVMIsPackedStruct(StructTy: TypeRef) -> Bool;
549 // Operations on array, pointer, and vector types (sequence types)
550 pub fn LLVMRustArrayType(ElementType: TypeRef, ElementCount: u64) -> TypeRef;
551 pub fn LLVMPointerType(ElementType: TypeRef, AddressSpace: c_uint) -> TypeRef;
552 pub fn LLVMVectorType(ElementType: TypeRef, ElementCount: c_uint) -> TypeRef;
554 pub fn LLVMGetElementType(Ty: TypeRef) -> TypeRef;
555 pub fn LLVMGetArrayLength(ArrayTy: TypeRef) -> c_uint;
556 pub fn LLVMGetVectorSize(VectorTy: TypeRef) -> c_uint;
558 // Operations on other types
559 pub fn LLVMVoidTypeInContext(C: ContextRef) -> TypeRef;
560 pub fn LLVMRustMetadataTypeInContext(C: ContextRef) -> TypeRef;
562 // Operations on all values
563 pub fn LLVMTypeOf(Val: ValueRef) -> TypeRef;
564 pub fn LLVMGetValueName(Val: ValueRef) -> *const c_char;
565 pub fn LLVMSetValueName(Val: ValueRef, Name: *const c_char);
566 pub fn LLVMReplaceAllUsesWith(OldVal: ValueRef, NewVal: ValueRef);
567 pub fn LLVMSetMetadata(Val: ValueRef, KindID: c_uint, Node: ValueRef);
569 // Operations on Uses
570 pub fn LLVMGetFirstUse(Val: ValueRef) -> UseRef;
571 pub fn LLVMGetNextUse(U: UseRef) -> UseRef;
572 pub fn LLVMGetUser(U: UseRef) -> ValueRef;
574 // Operations on Users
575 pub fn LLVMGetOperand(Val: ValueRef, Index: c_uint) -> ValueRef;
577 // Operations on constants of any type
578 pub fn LLVMConstNull(Ty: TypeRef) -> ValueRef;
579 pub fn LLVMConstICmp(Pred: IntPredicate, V1: ValueRef, V2: ValueRef) -> ValueRef;
580 pub fn LLVMConstFCmp(Pred: RealPredicate, V1: ValueRef, V2: ValueRef) -> ValueRef;
581 // only for isize/vector
582 pub fn LLVMGetUndef(Ty: TypeRef) -> ValueRef;
583 pub fn LLVMIsNull(Val: ValueRef) -> Bool;
584 pub fn LLVMIsUndef(Val: ValueRef) -> Bool;
586 // Operations on metadata
587 pub fn LLVMMDNodeInContext(C: ContextRef, Vals: *const ValueRef, Count: c_uint) -> ValueRef;
589 // Operations on scalar constants
590 pub fn LLVMConstInt(IntTy: TypeRef, N: c_ulonglong, SignExtend: Bool) -> ValueRef;
591 pub fn LLVMConstIntOfArbitraryPrecision(IntTy: TypeRef, Wn: c_uint, Ws: *const u64) -> ValueRef;
592 pub fn LLVMConstReal(RealTy: TypeRef, N: f64) -> ValueRef;
593 pub fn LLVMConstIntGetZExtValue(ConstantVal: ValueRef) -> c_ulonglong;
594 pub fn LLVMConstIntGetSExtValue(ConstantVal: ValueRef) -> c_longlong;
595 pub fn LLVMRustConstInt128Get(ConstantVal: ValueRef, SExt: bool,
596 high: *mut u64, low: *mut u64) -> bool;
599 // Operations on composite constants
600 pub fn LLVMConstStringInContext(C: ContextRef,
603 DontNullTerminate: Bool)
605 pub fn LLVMConstStructInContext(C: ContextRef,
606 ConstantVals: *const ValueRef,
611 pub fn LLVMConstArray(ElementTy: TypeRef,
612 ConstantVals: *const ValueRef,
615 pub fn LLVMConstVector(ScalarConstantVals: *const ValueRef, Size: c_uint) -> ValueRef;
617 // Constant expressions
618 pub fn LLVMSizeOf(Ty: TypeRef) -> ValueRef;
619 pub fn LLVMConstNeg(ConstantVal: ValueRef) -> ValueRef;
620 pub fn LLVMConstFNeg(ConstantVal: ValueRef) -> ValueRef;
621 pub fn LLVMConstNot(ConstantVal: ValueRef) -> ValueRef;
622 pub fn LLVMConstAdd(LHSConstant: ValueRef, RHSConstant: ValueRef) -> ValueRef;
623 pub fn LLVMConstFAdd(LHSConstant: ValueRef, RHSConstant: ValueRef) -> ValueRef;
624 pub fn LLVMConstSub(LHSConstant: ValueRef, RHSConstant: ValueRef) -> ValueRef;
625 pub fn LLVMConstFSub(LHSConstant: ValueRef, RHSConstant: ValueRef) -> ValueRef;
626 pub fn LLVMConstMul(LHSConstant: ValueRef, RHSConstant: ValueRef) -> ValueRef;
627 pub fn LLVMConstFMul(LHSConstant: ValueRef, RHSConstant: ValueRef) -> ValueRef;
628 pub fn LLVMConstUDiv(LHSConstant: ValueRef, RHSConstant: ValueRef) -> ValueRef;
629 pub fn LLVMConstSDiv(LHSConstant: ValueRef, RHSConstant: ValueRef) -> ValueRef;
630 pub fn LLVMConstFDiv(LHSConstant: ValueRef, RHSConstant: ValueRef) -> ValueRef;
631 pub fn LLVMConstURem(LHSConstant: ValueRef, RHSConstant: ValueRef) -> ValueRef;
632 pub fn LLVMConstSRem(LHSConstant: ValueRef, RHSConstant: ValueRef) -> ValueRef;
633 pub fn LLVMConstFRem(LHSConstant: ValueRef, RHSConstant: ValueRef) -> ValueRef;
634 pub fn LLVMConstAnd(LHSConstant: ValueRef, RHSConstant: ValueRef) -> ValueRef;
635 pub fn LLVMConstOr(LHSConstant: ValueRef, RHSConstant: ValueRef) -> ValueRef;
636 pub fn LLVMConstXor(LHSConstant: ValueRef, RHSConstant: ValueRef) -> ValueRef;
637 pub fn LLVMConstShl(LHSConstant: ValueRef, RHSConstant: ValueRef) -> ValueRef;
638 pub fn LLVMConstLShr(LHSConstant: ValueRef, RHSConstant: ValueRef) -> ValueRef;
639 pub fn LLVMConstAShr(LHSConstant: ValueRef, RHSConstant: ValueRef) -> ValueRef;
640 pub fn LLVMConstTrunc(ConstantVal: ValueRef, ToType: TypeRef) -> ValueRef;
641 pub fn LLVMConstZExt(ConstantVal: ValueRef, ToType: TypeRef) -> ValueRef;
642 pub fn LLVMConstUIToFP(ConstantVal: ValueRef, ToType: TypeRef) -> ValueRef;
643 pub fn LLVMConstSIToFP(ConstantVal: ValueRef, ToType: TypeRef) -> ValueRef;
644 pub fn LLVMConstFPToUI(ConstantVal: ValueRef, ToType: TypeRef) -> ValueRef;
645 pub fn LLVMConstFPToSI(ConstantVal: ValueRef, ToType: TypeRef) -> ValueRef;
646 pub fn LLVMConstPtrToInt(ConstantVal: ValueRef, ToType: TypeRef) -> ValueRef;
647 pub fn LLVMConstIntToPtr(ConstantVal: ValueRef, ToType: TypeRef) -> ValueRef;
648 pub fn LLVMConstBitCast(ConstantVal: ValueRef, ToType: TypeRef) -> ValueRef;
649 pub fn LLVMConstPointerCast(ConstantVal: ValueRef, ToType: TypeRef) -> ValueRef;
650 pub fn LLVMConstIntCast(ConstantVal: ValueRef, ToType: TypeRef, isSigned: Bool) -> ValueRef;
651 pub fn LLVMConstFPCast(ConstantVal: ValueRef, ToType: TypeRef) -> ValueRef;
652 pub fn LLVMConstExtractValue(AggConstant: ValueRef,
653 IdxList: *const c_uint,
656 pub fn LLVMConstInlineAsm(Ty: TypeRef,
657 AsmString: *const c_char,
658 Constraints: *const c_char,
659 HasSideEffects: Bool,
664 // Operations on global variables, functions, and aliases (globals)
665 pub fn LLVMGetGlobalParent(Global: ValueRef) -> ModuleRef;
666 pub fn LLVMIsDeclaration(Global: ValueRef) -> Bool;
667 pub fn LLVMRustGetLinkage(Global: ValueRef) -> Linkage;
668 pub fn LLVMRustSetLinkage(Global: ValueRef, RustLinkage: Linkage);
669 pub fn LLVMGetSection(Global: ValueRef) -> *const c_char;
670 pub fn LLVMSetSection(Global: ValueRef, Section: *const c_char);
671 pub fn LLVMRustGetVisibility(Global: ValueRef) -> Visibility;
672 pub fn LLVMRustSetVisibility(Global: ValueRef, Viz: Visibility);
673 pub fn LLVMGetAlignment(Global: ValueRef) -> c_uint;
674 pub fn LLVMSetAlignment(Global: ValueRef, Bytes: c_uint);
675 pub fn LLVMSetDLLStorageClass(V: ValueRef, C: DLLStorageClass);
678 // Operations on global variables
679 pub fn LLVMIsAGlobalVariable(GlobalVar: ValueRef) -> ValueRef;
680 pub fn LLVMAddGlobal(M: ModuleRef, Ty: TypeRef, Name: *const c_char) -> ValueRef;
681 pub fn LLVMGetNamedGlobal(M: ModuleRef, Name: *const c_char) -> ValueRef;
682 pub fn LLVMRustGetOrInsertGlobal(M: ModuleRef, Name: *const c_char, T: TypeRef) -> ValueRef;
683 pub fn LLVMGetFirstGlobal(M: ModuleRef) -> ValueRef;
684 pub fn LLVMGetNextGlobal(GlobalVar: ValueRef) -> ValueRef;
685 pub fn LLVMDeleteGlobal(GlobalVar: ValueRef);
686 pub fn LLVMGetInitializer(GlobalVar: ValueRef) -> ValueRef;
687 pub fn LLVMSetInitializer(GlobalVar: ValueRef, ConstantVal: ValueRef);
688 pub fn LLVMSetThreadLocal(GlobalVar: ValueRef, IsThreadLocal: Bool);
689 pub fn LLVMIsGlobalConstant(GlobalVar: ValueRef) -> Bool;
690 pub fn LLVMSetGlobalConstant(GlobalVar: ValueRef, IsConstant: Bool);
691 pub fn LLVMRustGetNamedValue(M: ModuleRef, Name: *const c_char) -> ValueRef;
693 // Operations on functions
694 pub fn LLVMAddFunction(M: ModuleRef, Name: *const c_char, FunctionTy: TypeRef) -> ValueRef;
695 pub fn LLVMGetNamedFunction(M: ModuleRef, Name: *const c_char) -> ValueRef;
696 pub fn LLVMGetFirstFunction(M: ModuleRef) -> ValueRef;
697 pub fn LLVMGetNextFunction(Fn: ValueRef) -> ValueRef;
698 pub fn LLVMRustGetOrInsertFunction(M: ModuleRef,
702 pub fn LLVMSetFunctionCallConv(Fn: ValueRef, CC: c_uint);
703 pub fn LLVMRustAddDereferenceableAttr(Fn: ValueRef, index: c_uint, bytes: u64);
704 pub fn LLVMRustAddFunctionAttribute(Fn: ValueRef, index: c_uint, attr: Attribute);
705 pub fn LLVMRustAddFunctionAttrStringValue(Fn: ValueRef,
708 Value: *const c_char);
709 pub fn LLVMRustRemoveFunctionAttributes(Fn: ValueRef, index: c_uint, attr: Attribute);
711 // Operations on parameters
712 pub fn LLVMCountParams(Fn: ValueRef) -> c_uint;
713 pub fn LLVMGetParam(Fn: ValueRef, Index: c_uint) -> ValueRef;
715 // Operations on basic blocks
716 pub fn LLVMBasicBlockAsValue(BB: BasicBlockRef) -> ValueRef;
717 pub fn LLVMGetBasicBlockParent(BB: BasicBlockRef) -> ValueRef;
718 pub fn LLVMAppendBasicBlockInContext(C: ContextRef,
722 pub fn LLVMDeleteBasicBlock(BB: BasicBlockRef);
724 // Operations on instructions
725 pub fn LLVMGetInstructionParent(Inst: ValueRef) -> BasicBlockRef;
726 pub fn LLVMGetFirstBasicBlock(Fn: ValueRef) -> BasicBlockRef;
727 pub fn LLVMGetFirstInstruction(BB: BasicBlockRef) -> ValueRef;
728 pub fn LLVMInstructionEraseFromParent(Inst: ValueRef);
730 // Operations on call sites
731 pub fn LLVMSetInstructionCallConv(Instr: ValueRef, CC: c_uint);
732 pub fn LLVMRustAddCallSiteAttribute(Instr: ValueRef, index: c_uint, attr: Attribute);
733 pub fn LLVMRustAddDereferenceableCallSiteAttr(Instr: ValueRef, index: c_uint, bytes: u64);
735 // Operations on load/store instructions (only)
736 pub fn LLVMSetVolatile(MemoryAccessInst: ValueRef, volatile: Bool);
738 // Operations on phi nodes
739 pub fn LLVMAddIncoming(PhiNode: ValueRef,
740 IncomingValues: *const ValueRef,
741 IncomingBlocks: *const BasicBlockRef,
744 // Instruction builders
745 pub fn LLVMCreateBuilderInContext(C: ContextRef) -> BuilderRef;
746 pub fn LLVMPositionBuilder(Builder: BuilderRef, Block: BasicBlockRef, Instr: ValueRef);
747 pub fn LLVMPositionBuilderBefore(Builder: BuilderRef, Instr: ValueRef);
748 pub fn LLVMPositionBuilderAtEnd(Builder: BuilderRef, Block: BasicBlockRef);
749 pub fn LLVMGetInsertBlock(Builder: BuilderRef) -> BasicBlockRef;
750 pub fn LLVMDisposeBuilder(Builder: BuilderRef);
753 pub fn LLVMSetCurrentDebugLocation(Builder: BuilderRef, L: ValueRef);
754 pub fn LLVMGetCurrentDebugLocation(Builder: BuilderRef) -> ValueRef;
755 pub fn LLVMSetInstDebugLocation(Builder: BuilderRef, Inst: ValueRef);
758 pub fn LLVMBuildRetVoid(B: BuilderRef) -> ValueRef;
759 pub fn LLVMBuildRet(B: BuilderRef, V: ValueRef) -> ValueRef;
760 pub fn LLVMBuildAggregateRet(B: BuilderRef, RetVals: *const ValueRef, N: c_uint) -> ValueRef;
761 pub fn LLVMBuildBr(B: BuilderRef, Dest: BasicBlockRef) -> ValueRef;
762 pub fn LLVMBuildCondBr(B: BuilderRef,
767 pub fn LLVMBuildSwitch(B: BuilderRef,
772 pub fn LLVMBuildIndirectBr(B: BuilderRef, Addr: ValueRef, NumDests: c_uint) -> ValueRef;
773 pub fn LLVMRustBuildInvoke(B: BuilderRef,
775 Args: *const ValueRef,
778 Catch: BasicBlockRef,
779 Bundle: OperandBundleDefRef,
782 pub fn LLVMRustBuildLandingPad(B: BuilderRef,
789 pub fn LLVMBuildResume(B: BuilderRef, Exn: ValueRef) -> ValueRef;
790 pub fn LLVMBuildUnreachable(B: BuilderRef) -> ValueRef;
792 pub fn LLVMRustBuildCleanupPad(B: BuilderRef,
795 Args: *const ValueRef,
798 pub fn LLVMRustBuildCleanupRet(B: BuilderRef,
799 CleanupPad: ValueRef,
800 UnwindBB: BasicBlockRef)
802 pub fn LLVMRustBuildCatchPad(B: BuilderRef,
805 Args: *const ValueRef,
808 pub fn LLVMRustBuildCatchRet(B: BuilderRef, Pad: ValueRef, BB: BasicBlockRef) -> ValueRef;
809 pub fn LLVMRustBuildCatchSwitch(Builder: BuilderRef,
815 pub fn LLVMRustAddHandler(CatchSwitch: ValueRef, Handler: BasicBlockRef);
816 pub fn LLVMSetPersonalityFn(Func: ValueRef, Pers: ValueRef);
818 // Add a case to the switch instruction
819 pub fn LLVMAddCase(Switch: ValueRef, OnVal: ValueRef, Dest: BasicBlockRef);
821 // Add a clause to the landing pad instruction
822 pub fn LLVMAddClause(LandingPad: ValueRef, ClauseVal: ValueRef);
824 // Set the cleanup on a landing pad instruction
825 pub fn LLVMSetCleanup(LandingPad: ValueRef, Val: Bool);
828 pub fn LLVMBuildAdd(B: BuilderRef,
833 pub fn LLVMBuildNSWAdd(B: BuilderRef,
838 pub fn LLVMBuildNUWAdd(B: BuilderRef,
843 pub fn LLVMBuildFAdd(B: BuilderRef,
848 pub fn LLVMBuildSub(B: BuilderRef,
853 pub fn LLVMBuildNSWSub(B: BuilderRef,
858 pub fn LLVMBuildNUWSub(B: BuilderRef,
863 pub fn LLVMBuildFSub(B: BuilderRef,
868 pub fn LLVMBuildMul(B: BuilderRef,
873 pub fn LLVMBuildNSWMul(B: BuilderRef,
878 pub fn LLVMBuildNUWMul(B: BuilderRef,
883 pub fn LLVMBuildFMul(B: BuilderRef,
888 pub fn LLVMBuildUDiv(B: BuilderRef,
893 pub fn LLVMBuildSDiv(B: BuilderRef,
898 pub fn LLVMBuildExactSDiv(B: BuilderRef,
903 pub fn LLVMBuildFDiv(B: BuilderRef,
908 pub fn LLVMBuildURem(B: BuilderRef,
913 pub fn LLVMBuildSRem(B: BuilderRef,
918 pub fn LLVMBuildFRem(B: BuilderRef,
923 pub fn LLVMBuildShl(B: BuilderRef,
928 pub fn LLVMBuildLShr(B: BuilderRef,
933 pub fn LLVMBuildAShr(B: BuilderRef,
938 pub fn LLVMBuildAnd(B: BuilderRef,
943 pub fn LLVMBuildOr(B: BuilderRef,
948 pub fn LLVMBuildXor(B: BuilderRef,
953 pub fn LLVMBuildBinOp(B: BuilderRef,
959 pub fn LLVMBuildNeg(B: BuilderRef, V: ValueRef, Name: *const c_char) -> ValueRef;
960 pub fn LLVMBuildNSWNeg(B: BuilderRef, V: ValueRef, Name: *const c_char) -> ValueRef;
961 pub fn LLVMBuildNUWNeg(B: BuilderRef, V: ValueRef, Name: *const c_char) -> ValueRef;
962 pub fn LLVMBuildFNeg(B: BuilderRef, V: ValueRef, Name: *const c_char) -> ValueRef;
963 pub fn LLVMBuildNot(B: BuilderRef, V: ValueRef, Name: *const c_char) -> ValueRef;
964 pub fn LLVMRustSetHasUnsafeAlgebra(Instr: ValueRef);
967 pub fn LLVMBuildAlloca(B: BuilderRef, Ty: TypeRef, Name: *const c_char) -> ValueRef;
968 pub fn LLVMBuildFree(B: BuilderRef, PointerVal: ValueRef) -> ValueRef;
969 pub fn LLVMBuildLoad(B: BuilderRef, PointerVal: ValueRef, Name: *const c_char) -> ValueRef;
971 pub fn LLVMBuildStore(B: BuilderRef, Val: ValueRef, Ptr: ValueRef) -> ValueRef;
973 pub fn LLVMBuildGEP(B: BuilderRef,
975 Indices: *const ValueRef,
979 pub fn LLVMBuildInBoundsGEP(B: BuilderRef,
981 Indices: *const ValueRef,
985 pub fn LLVMBuildStructGEP(B: BuilderRef,
990 pub fn LLVMBuildGlobalString(B: BuilderRef,
994 pub fn LLVMBuildGlobalStringPtr(B: BuilderRef,
1000 pub fn LLVMBuildTrunc(B: BuilderRef,
1003 Name: *const c_char)
1005 pub fn LLVMBuildZExt(B: BuilderRef,
1008 Name: *const c_char)
1010 pub fn LLVMBuildSExt(B: BuilderRef,
1013 Name: *const c_char)
1015 pub fn LLVMBuildFPToUI(B: BuilderRef,
1018 Name: *const c_char)
1020 pub fn LLVMBuildFPToSI(B: BuilderRef,
1023 Name: *const c_char)
1025 pub fn LLVMBuildUIToFP(B: BuilderRef,
1028 Name: *const c_char)
1030 pub fn LLVMBuildSIToFP(B: BuilderRef,
1033 Name: *const c_char)
1035 pub fn LLVMBuildFPTrunc(B: BuilderRef,
1038 Name: *const c_char)
1040 pub fn LLVMBuildFPExt(B: BuilderRef,
1043 Name: *const c_char)
1045 pub fn LLVMBuildPtrToInt(B: BuilderRef,
1048 Name: *const c_char)
1050 pub fn LLVMBuildIntToPtr(B: BuilderRef,
1053 Name: *const c_char)
1055 pub fn LLVMBuildBitCast(B: BuilderRef,
1058 Name: *const c_char)
1060 pub fn LLVMBuildZExtOrBitCast(B: BuilderRef,
1063 Name: *const c_char)
1065 pub fn LLVMBuildSExtOrBitCast(B: BuilderRef,
1068 Name: *const c_char)
1070 pub fn LLVMBuildTruncOrBitCast(B: BuilderRef,
1073 Name: *const c_char)
1075 pub fn LLVMBuildCast(B: BuilderRef,
1079 Name: *const c_char)
1081 pub fn LLVMBuildPointerCast(B: BuilderRef,
1084 Name: *const c_char)
1086 pub fn LLVMBuildIntCast(B: BuilderRef,
1089 Name: *const c_char)
1091 pub fn LLVMBuildFPCast(B: BuilderRef,
1094 Name: *const c_char)
1098 pub fn LLVMBuildICmp(B: BuilderRef,
1102 Name: *const c_char)
1104 pub fn LLVMBuildFCmp(B: BuilderRef,
1108 Name: *const c_char)
1111 // Miscellaneous instructions
1112 pub fn LLVMBuildPhi(B: BuilderRef, Ty: TypeRef, Name: *const c_char) -> ValueRef;
1113 pub fn LLVMRustBuildCall(B: BuilderRef,
1115 Args: *const ValueRef,
1117 Bundle: OperandBundleDefRef,
1118 Name: *const c_char)
1120 pub fn LLVMBuildSelect(B: BuilderRef,
1124 Name: *const c_char)
1126 pub fn LLVMBuildVAArg(B: BuilderRef,
1129 Name: *const c_char)
1131 pub fn LLVMBuildExtractElement(B: BuilderRef,
1134 Name: *const c_char)
1136 pub fn LLVMBuildInsertElement(B: BuilderRef,
1140 Name: *const c_char)
1142 pub fn LLVMBuildShuffleVector(B: BuilderRef,
1146 Name: *const c_char)
1148 pub fn LLVMBuildExtractValue(B: BuilderRef,
1151 Name: *const c_char)
1153 pub fn LLVMBuildInsertValue(B: BuilderRef,
1157 Name: *const c_char)
1160 pub fn LLVMBuildIsNull(B: BuilderRef, Val: ValueRef, Name: *const c_char) -> ValueRef;
1161 pub fn LLVMBuildIsNotNull(B: BuilderRef, Val: ValueRef, Name: *const c_char) -> ValueRef;
1162 pub fn LLVMBuildPtrDiff(B: BuilderRef,
1165 Name: *const c_char)
1168 // Atomic Operations
1169 pub fn LLVMRustBuildAtomicLoad(B: BuilderRef,
1170 PointerVal: ValueRef,
1171 Name: *const c_char,
1172 Order: AtomicOrdering,
1176 pub fn LLVMRustBuildAtomicStore(B: BuilderRef,
1179 Order: AtomicOrdering,
1183 pub fn LLVMRustBuildAtomicCmpXchg(B: BuilderRef,
1187 Order: AtomicOrdering,
1188 FailureOrder: AtomicOrdering,
1192 pub fn LLVMBuildAtomicRMW(B: BuilderRef,
1196 Order: AtomicOrdering,
1197 SingleThreaded: Bool)
1200 pub fn LLVMRustBuildAtomicFence(B: BuilderRef,
1201 Order: AtomicOrdering,
1202 Scope: SynchronizationScope);
1205 // Selected entries from the downcasts.
1206 pub fn LLVMIsATerminatorInst(Inst: ValueRef) -> ValueRef;
1207 pub fn LLVMIsAStoreInst(Inst: ValueRef) -> ValueRef;
1209 /// Writes a module to the specified path. Returns 0 on success.
1210 pub fn LLVMWriteBitcodeToFile(M: ModuleRef, Path: *const c_char) -> c_int;
1212 /// Creates target data from a target layout string.
1213 pub fn LLVMCreateTargetData(StringRep: *const c_char) -> TargetDataRef;
1214 /// Number of bytes clobbered when doing a Store to *T.
1215 pub fn LLVMSizeOfTypeInBits(TD: TargetDataRef, Ty: TypeRef) -> c_ulonglong;
1217 /// Distance between successive elements in an array of T. Includes ABI padding.
1218 pub fn LLVMABISizeOfType(TD: TargetDataRef, Ty: TypeRef) -> c_ulonglong;
1220 /// Returns the preferred alignment of a type.
1221 pub fn LLVMPreferredAlignmentOfType(TD: TargetDataRef, Ty: TypeRef) -> c_uint;
1222 /// Returns the minimum alignment of a type.
1223 pub fn LLVMABIAlignmentOfType(TD: TargetDataRef, Ty: TypeRef) -> c_uint;
1225 /// Computes the byte offset of the indexed struct element for a
1227 pub fn LLVMOffsetOfElement(TD: TargetDataRef,
1232 /// Disposes target data.
1233 pub fn LLVMDisposeTargetData(TD: TargetDataRef);
1235 /// Creates a pass manager.
1236 pub fn LLVMCreatePassManager() -> PassManagerRef;
1238 /// Creates a function-by-function pass manager
1239 pub fn LLVMCreateFunctionPassManagerForModule(M: ModuleRef) -> PassManagerRef;
1241 /// Disposes a pass manager.
1242 pub fn LLVMDisposePassManager(PM: PassManagerRef);
1244 /// Runs a pass manager on a module.
1245 pub fn LLVMRunPassManager(PM: PassManagerRef, M: ModuleRef) -> Bool;
1247 pub fn LLVMInitializePasses();
1249 pub fn LLVMPassManagerBuilderCreate() -> PassManagerBuilderRef;
1250 pub fn LLVMPassManagerBuilderDispose(PMB: PassManagerBuilderRef);
1251 pub fn LLVMPassManagerBuilderSetSizeLevel(PMB: PassManagerBuilderRef, Value: Bool);
1252 pub fn LLVMPassManagerBuilderSetDisableUnrollLoops(PMB: PassManagerBuilderRef, Value: Bool);
1253 pub fn LLVMPassManagerBuilderUseInlinerWithThreshold(PMB: PassManagerBuilderRef,
1255 pub fn LLVMPassManagerBuilderPopulateModulePassManager(PMB: PassManagerBuilderRef,
1256 PM: PassManagerRef);
1258 pub fn LLVMPassManagerBuilderPopulateFunctionPassManager(PMB: PassManagerBuilderRef,
1259 PM: PassManagerRef);
1260 pub fn LLVMPassManagerBuilderPopulateLTOPassManager(PMB: PassManagerBuilderRef,
1265 // Stuff that's in rustllvm/ because it's not upstream yet.
1267 /// Opens an object file.
1268 pub fn LLVMCreateObjectFile(MemBuf: MemoryBufferRef) -> ObjectFileRef;
1269 /// Closes an object file.
1270 pub fn LLVMDisposeObjectFile(ObjFile: ObjectFileRef);
1272 /// Enumerates the sections in an object file.
1273 pub fn LLVMGetSections(ObjFile: ObjectFileRef) -> SectionIteratorRef;
1274 /// Destroys a section iterator.
1275 pub fn LLVMDisposeSectionIterator(SI: SectionIteratorRef);
1276 /// Returns true if the section iterator is at the end of the section
1278 pub fn LLVMIsSectionIteratorAtEnd(ObjFile: ObjectFileRef, SI: SectionIteratorRef) -> Bool;
1279 /// Moves the section iterator to point to the next section.
1280 pub fn LLVMMoveToNextSection(SI: SectionIteratorRef);
1281 /// Returns the current section size.
1282 pub fn LLVMGetSectionSize(SI: SectionIteratorRef) -> c_ulonglong;
1283 /// Returns the current section contents as a string buffer.
1284 pub fn LLVMGetSectionContents(SI: SectionIteratorRef) -> *const c_char;
1286 /// Reads the given file and returns it as a memory buffer. Use
1287 /// LLVMDisposeMemoryBuffer() to get rid of it.
1288 pub fn LLVMRustCreateMemoryBufferWithContentsOfFile(Path: *const c_char) -> MemoryBufferRef;
1290 pub fn LLVMStartMultithreaded() -> Bool;
1292 /// Returns a string describing the last error caused by an LLVMRust* call.
1293 pub fn LLVMRustGetLastError() -> *const c_char;
1295 /// Print the pass timings since static dtors aren't picking them up.
1296 pub fn LLVMRustPrintPassTimings();
1298 pub fn LLVMStructCreateNamed(C: ContextRef, Name: *const c_char) -> TypeRef;
1300 pub fn LLVMStructSetBody(StructTy: TypeRef,
1301 ElementTypes: *const TypeRef,
1302 ElementCount: c_uint,
1305 pub fn LLVMConstNamedStruct(S: TypeRef,
1306 ConstantVals: *const ValueRef,
1310 /// Enables LLVM debug output.
1311 pub fn LLVMRustSetDebug(Enabled: c_int);
1313 /// Prepares inline assembly.
1314 pub fn LLVMRustInlineAsm(Ty: TypeRef,
1315 AsmString: *const c_char,
1316 Constraints: *const c_char,
1319 Dialect: AsmDialect)
1322 pub fn LLVMRustDebugMetadataVersion() -> u32;
1323 pub fn LLVMRustVersionMajor() -> u32;
1324 pub fn LLVMRustVersionMinor() -> u32;
1326 pub fn LLVMRustAddModuleFlag(M: ModuleRef, name: *const c_char, value: u32);
1328 pub fn LLVMRustDIBuilderCreate(M: ModuleRef) -> DIBuilderRef;
1330 pub fn LLVMRustDIBuilderDispose(Builder: DIBuilderRef);
1332 pub fn LLVMRustDIBuilderFinalize(Builder: DIBuilderRef);
1334 pub fn LLVMRustDIBuilderCreateCompileUnit(Builder: DIBuilderRef,
1336 File: *const c_char,
1338 Producer: *const c_char,
1340 Flags: *const c_char,
1342 SplitName: *const c_char)
1345 pub fn LLVMRustDIBuilderCreateFile(Builder: DIBuilderRef,
1346 Filename: *const c_char,
1347 Directory: *const c_char)
1350 pub fn LLVMRustDIBuilderCreateSubroutineType(Builder: DIBuilderRef,
1352 ParameterTypes: DIArray)
1355 pub fn LLVMRustDIBuilderCreateFunction(Builder: DIBuilderRef,
1356 Scope: DIDescriptor,
1357 Name: *const c_char,
1358 LinkageName: *const c_char,
1362 isLocalToUnit: bool,
1372 pub fn LLVMRustDIBuilderCreateBasicType(Builder: DIBuilderRef,
1373 Name: *const c_char,
1379 pub fn LLVMRustDIBuilderCreatePointerType(Builder: DIBuilderRef,
1383 Name: *const c_char)
1386 pub fn LLVMRustDIBuilderCreateStructType(Builder: DIBuilderRef,
1387 Scope: DIDescriptor,
1388 Name: *const c_char,
1394 DerivedFrom: DIType,
1396 RunTimeLang: c_uint,
1397 VTableHolder: DIType,
1398 UniqueId: *const c_char)
1401 pub fn LLVMRustDIBuilderCreateMemberType(Builder: DIBuilderRef,
1402 Scope: DIDescriptor,
1403 Name: *const c_char,
1413 pub fn LLVMRustDIBuilderCreateLexicalBlock(Builder: DIBuilderRef,
1420 pub fn LLVMRustDIBuilderCreateLexicalBlockFile(Builder: DIBuilderRef,
1425 pub fn LLVMRustDIBuilderCreateStaticVariable(Builder: DIBuilderRef,
1427 Name: *const c_char,
1428 LinkageName: *const c_char,
1432 isLocalToUnit: bool,
1436 -> DIGlobalVariable;
1438 pub fn LLVMRustDIBuilderCreateVariable(Builder: DIBuilderRef,
1440 Scope: DIDescriptor,
1441 Name: *const c_char,
1445 AlwaysPreserve: bool,
1451 pub fn LLVMRustDIBuilderCreateArrayType(Builder: DIBuilderRef,
1455 Subscripts: DIArray)
1458 pub fn LLVMRustDIBuilderCreateVectorType(Builder: DIBuilderRef,
1462 Subscripts: DIArray)
1465 pub fn LLVMRustDIBuilderGetOrCreateSubrange(Builder: DIBuilderRef,
1470 pub fn LLVMRustDIBuilderGetOrCreateArray(Builder: DIBuilderRef,
1471 Ptr: *const DIDescriptor,
1475 pub fn LLVMRustDIBuilderInsertDeclareAtEnd(Builder: DIBuilderRef,
1477 VarInfo: DIVariable,
1478 AddrOps: *const i64,
1479 AddrOpsCount: c_uint,
1481 InsertAtEnd: BasicBlockRef)
1484 pub fn LLVMRustDIBuilderCreateEnumerator(Builder: DIBuilderRef,
1485 Name: *const c_char,
1489 pub fn LLVMRustDIBuilderCreateEnumerationType(Builder: DIBuilderRef,
1491 Name: *const c_char,
1500 pub fn LLVMRustDIBuilderCreateUnionType(Builder: DIBuilderRef,
1502 Name: *const c_char,
1509 RunTimeLang: c_uint,
1510 UniqueId: *const c_char)
1513 pub fn LLVMSetUnnamedAddr(GlobalVar: ValueRef, UnnamedAddr: Bool);
1515 pub fn LLVMRustDIBuilderCreateTemplateTypeParameter(Builder: DIBuilderRef,
1517 Name: *const c_char,
1522 -> DITemplateTypeParameter;
1525 pub fn LLVMRustDIBuilderCreateNameSpace(Builder: DIBuilderRef,
1527 Name: *const c_char,
1531 pub fn LLVMRustDICompositeTypeSetTypeArray(Builder: DIBuilderRef,
1532 CompositeType: DIType,
1533 TypeArray: DIArray);
1536 pub fn LLVMRustDIBuilderCreateDebugLocation(Context: ContextRef,
1540 InlinedAt: MetadataRef)
1542 pub fn LLVMRustDIBuilderCreateOpDeref() -> i64;
1543 pub fn LLVMRustDIBuilderCreateOpPlus() -> i64;
1545 pub fn LLVMRustWriteTypeToString(Type: TypeRef, s: RustStringRef);
1546 pub fn LLVMRustWriteValueToString(value_ref: ValueRef, s: RustStringRef);
1548 pub fn LLVMIsAConstantInt(value_ref: ValueRef) -> ValueRef;
1550 pub fn LLVMRustPassKind(Pass: PassRef) -> PassKind;
1551 pub fn LLVMRustFindAndCreatePass(Pass: *const c_char) -> PassRef;
1552 pub fn LLVMRustAddPass(PM: PassManagerRef, Pass: PassRef);
1554 pub fn LLVMRustHasFeature(T: TargetMachineRef, s: *const c_char) -> bool;
1556 pub fn LLVMRustPrintTargetCPUs(T: TargetMachineRef);
1557 pub fn LLVMRustPrintTargetFeatures(T: TargetMachineRef);
1559 pub fn LLVMRustCreateTargetMachine(Triple: *const c_char,
1561 Features: *const c_char,
1564 Level: CodeGenOptLevel,
1566 PositionIndependentExecutable: bool,
1567 FunctionSections: bool,
1569 -> TargetMachineRef;
1570 pub fn LLVMRustDisposeTargetMachine(T: TargetMachineRef);
1571 pub fn LLVMRustAddAnalysisPasses(T: TargetMachineRef, PM: PassManagerRef, M: ModuleRef);
1572 pub fn LLVMRustAddBuilderLibraryInfo(PMB: PassManagerBuilderRef,
1574 DisableSimplifyLibCalls: bool);
1575 pub fn LLVMRustConfigurePassManagerBuilder(PMB: PassManagerBuilderRef,
1576 OptLevel: CodeGenOptLevel,
1577 MergeFunctions: bool,
1579 LoopVectorize: bool);
1580 pub fn LLVMRustAddLibraryInfo(PM: PassManagerRef,
1582 DisableSimplifyLibCalls: bool);
1583 pub fn LLVMRustRunFunctionPassManager(PM: PassManagerRef, M: ModuleRef);
1584 pub fn LLVMRustWriteOutputFile(T: TargetMachineRef,
1587 Output: *const c_char,
1590 pub fn LLVMRustPrintModule(PM: PassManagerRef, M: ModuleRef, Output: *const c_char);
1591 pub fn LLVMRustSetLLVMOptions(Argc: c_int, Argv: *const *const c_char);
1592 pub fn LLVMRustPrintPasses();
1593 pub fn LLVMRustSetNormalizedTarget(M: ModuleRef, triple: *const c_char);
1594 pub fn LLVMRustAddAlwaysInlinePass(P: PassManagerBuilderRef, AddLifetimes: bool);
1595 pub fn LLVMRustLinkInExternalBitcode(M: ModuleRef, bc: *const c_char, len: size_t) -> bool;
1596 pub fn LLVMRustRunRestrictionPass(M: ModuleRef, syms: *const *const c_char, len: size_t);
1597 pub fn LLVMRustMarkAllFunctionsNounwind(M: ModuleRef);
1599 pub fn LLVMRustOpenArchive(path: *const c_char) -> ArchiveRef;
1600 pub fn LLVMRustArchiveIteratorNew(AR: ArchiveRef) -> ArchiveIteratorRef;
1601 pub fn LLVMRustArchiveIteratorNext(AIR: ArchiveIteratorRef) -> ArchiveChildRef;
1602 pub fn LLVMRustArchiveChildName(ACR: ArchiveChildRef, size: *mut size_t) -> *const c_char;
1603 pub fn LLVMRustArchiveChildData(ACR: ArchiveChildRef, size: *mut size_t) -> *const c_char;
1604 pub fn LLVMRustArchiveChildFree(ACR: ArchiveChildRef);
1605 pub fn LLVMRustArchiveIteratorFree(AIR: ArchiveIteratorRef);
1606 pub fn LLVMRustDestroyArchive(AR: ArchiveRef);
1608 pub fn LLVMRustGetSectionName(SI: SectionIteratorRef, data: *mut *const c_char) -> size_t;
1610 pub fn LLVMRustWriteTwineToString(T: TwineRef, s: RustStringRef);
1612 pub fn LLVMContextSetDiagnosticHandler(C: ContextRef,
1613 Handler: DiagnosticHandler,
1614 DiagnosticContext: *mut c_void);
1616 pub fn LLVMRustUnpackOptimizationDiagnostic(DI: DiagnosticInfoRef,
1617 pass_name_out: RustStringRef,
1618 function_out: *mut ValueRef,
1619 debugloc_out: *mut DebugLocRef,
1620 message_out: RustStringRef);
1621 pub fn LLVMRustUnpackInlineAsmDiagnostic(DI: DiagnosticInfoRef,
1622 cookie_out: *mut c_uint,
1623 message_out: *mut TwineRef,
1624 instruction_out: *mut ValueRef);
1626 pub fn LLVMRustWriteDiagnosticInfoToString(DI: DiagnosticInfoRef, s: RustStringRef);
1627 pub fn LLVMRustGetDiagInfoKind(DI: DiagnosticInfoRef) -> DiagnosticKind;
1629 pub fn LLVMRustWriteDebugLocToString(C: ContextRef, DL: DebugLocRef, s: RustStringRef);
1631 pub fn LLVMRustSetInlineAsmDiagnosticHandler(C: ContextRef,
1632 H: InlineAsmDiagHandler,
1635 pub fn LLVMRustWriteSMDiagnosticToString(d: SMDiagnosticRef, s: RustStringRef);
1637 pub fn LLVMRustWriteArchive(Dst: *const c_char,
1639 Members: *const RustArchiveMemberRef,
1643 pub fn LLVMRustArchiveMemberNew(Filename: *const c_char,
1644 Name: *const c_char,
1645 Child: ArchiveChildRef)
1646 -> RustArchiveMemberRef;
1647 pub fn LLVMRustArchiveMemberFree(Member: RustArchiveMemberRef);
1649 pub fn LLVMRustSetDataLayoutFromTargetMachine(M: ModuleRef, TM: TargetMachineRef);
1650 pub fn LLVMRustGetModuleDataLayout(M: ModuleRef) -> TargetDataRef;
1652 pub fn LLVMRustBuildOperandBundleDef(Name: *const c_char,
1653 Inputs: *const ValueRef,
1655 -> OperandBundleDefRef;
1656 pub fn LLVMRustFreeOperandBundleDef(Bundle: OperandBundleDefRef);
1658 pub fn LLVMRustPositionBuilderAtStart(B: BuilderRef, BB: BasicBlockRef);
1660 pub fn LLVMRustSetComdat(M: ModuleRef, V: ValueRef, Name: *const c_char);
1661 pub fn LLVMRustUnsetComdat(V: ValueRef);
1662 pub fn LLVMRustSetModulePIELevel(M: ModuleRef);
1666 // LLVM requires symbols from this library, but apparently they're not printed
1667 // during llvm-config?
1669 #[link(name = "ole32")]