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,
132 #[derive(Copy, Clone)]
134 pub enum IntPredicate {
147 /// LLVMRealPredicate
148 #[derive(Copy, Clone)]
150 pub enum RealPredicate {
151 RealPredicateFalse = 0,
166 RealPredicateTrue = 15,
170 #[derive(Copy, Clone, PartialEq, Debug)]
192 /// LLVMAtomicRmwBinOp
193 #[derive(Copy, Clone)]
195 pub enum AtomicRmwBinOp {
209 /// LLVMAtomicOrdering
210 #[derive(Copy, Clone)]
212 pub enum AtomicOrdering {
216 // Consume = 3, // Not specified yet.
220 SequentiallyConsistent = 7,
223 /// LLVMRustSynchronizationScope
224 #[derive(Copy, Clone)]
226 pub enum SynchronizationScope {
233 #[derive(Copy, Clone)]
242 #[derive(Copy, Clone)]
244 pub enum MetadataType {
251 MD_invariant_load = 6,
255 MD_mem_parallel_loop_access = 10,
259 /// LLVMRustAsmDialect
260 #[derive(Copy, Clone)]
262 pub enum AsmDialect {
268 /// LLVMRustCodeGenOptLevel
269 #[derive(Copy, Clone, PartialEq)]
271 pub enum CodeGenOptLevel {
280 #[derive(Copy, Clone, PartialEq)]
289 /// LLVMRustCodeModel
290 #[derive(Copy, Clone)]
302 /// LLVMRustDiagnosticKind
303 #[derive(Copy, Clone)]
305 pub enum DiagnosticKind {
309 DebugMetadataVersion,
312 OptimizationRemarkMissed,
313 OptimizationRemarkAnalysis,
314 OptimizationRemarkAnalysisFPCommute,
315 OptimizationRemarkAnalysisAliasing,
316 OptimizationRemarkOther,
320 /// LLVMRustArchiveKind
321 #[derive(Copy, Clone)]
323 pub enum ArchiveKind {
332 #[derive(Copy, Clone, PartialEq, Debug)]
340 // Opaque pointer types
341 #[allow(missing_copy_implementations)]
342 pub enum Module_opaque {}
343 pub type ModuleRef = *mut Module_opaque;
344 #[allow(missing_copy_implementations)]
345 pub enum Context_opaque {}
346 pub type ContextRef = *mut Context_opaque;
347 #[allow(missing_copy_implementations)]
348 pub enum Type_opaque {}
349 pub type TypeRef = *mut Type_opaque;
350 #[allow(missing_copy_implementations)]
351 pub enum Value_opaque {}
352 pub type ValueRef = *mut Value_opaque;
353 #[allow(missing_copy_implementations)]
354 pub enum Metadata_opaque {}
355 pub type MetadataRef = *mut Metadata_opaque;
356 #[allow(missing_copy_implementations)]
357 pub enum BasicBlock_opaque {}
358 pub type BasicBlockRef = *mut BasicBlock_opaque;
359 #[allow(missing_copy_implementations)]
360 pub enum Builder_opaque {}
361 pub type BuilderRef = *mut Builder_opaque;
362 #[allow(missing_copy_implementations)]
363 pub enum ExecutionEngine_opaque {}
364 pub type ExecutionEngineRef = *mut ExecutionEngine_opaque;
365 #[allow(missing_copy_implementations)]
366 pub enum MemoryBuffer_opaque {}
367 pub type MemoryBufferRef = *mut MemoryBuffer_opaque;
368 #[allow(missing_copy_implementations)]
369 pub enum PassManager_opaque {}
370 pub type PassManagerRef = *mut PassManager_opaque;
371 #[allow(missing_copy_implementations)]
372 pub enum PassManagerBuilder_opaque {}
373 pub type PassManagerBuilderRef = *mut PassManagerBuilder_opaque;
374 #[allow(missing_copy_implementations)]
375 pub enum Use_opaque {}
376 pub type UseRef = *mut Use_opaque;
377 #[allow(missing_copy_implementations)]
378 pub enum TargetData_opaque {}
379 pub type TargetDataRef = *mut TargetData_opaque;
380 #[allow(missing_copy_implementations)]
381 pub enum ObjectFile_opaque {}
382 pub type ObjectFileRef = *mut ObjectFile_opaque;
383 #[allow(missing_copy_implementations)]
384 pub enum SectionIterator_opaque {}
385 pub type SectionIteratorRef = *mut SectionIterator_opaque;
386 #[allow(missing_copy_implementations)]
387 pub enum Pass_opaque {}
388 pub type PassRef = *mut Pass_opaque;
389 #[allow(missing_copy_implementations)]
390 pub enum TargetMachine_opaque {}
391 pub type TargetMachineRef = *mut TargetMachine_opaque;
392 pub enum Archive_opaque {}
393 pub type ArchiveRef = *mut Archive_opaque;
394 pub enum ArchiveIterator_opaque {}
395 pub type ArchiveIteratorRef = *mut ArchiveIterator_opaque;
396 pub enum ArchiveChild_opaque {}
397 pub type ArchiveChildRef = *mut ArchiveChild_opaque;
398 #[allow(missing_copy_implementations)]
399 pub enum Twine_opaque {}
400 pub type TwineRef = *mut Twine_opaque;
401 #[allow(missing_copy_implementations)]
402 pub enum DiagnosticInfo_opaque {}
403 pub type DiagnosticInfoRef = *mut DiagnosticInfo_opaque;
404 #[allow(missing_copy_implementations)]
405 pub enum DebugLoc_opaque {}
406 pub type DebugLocRef = *mut DebugLoc_opaque;
407 #[allow(missing_copy_implementations)]
408 pub enum SMDiagnostic_opaque {}
409 pub type SMDiagnosticRef = *mut SMDiagnostic_opaque;
410 #[allow(missing_copy_implementations)]
411 pub enum RustArchiveMember_opaque {}
412 pub type RustArchiveMemberRef = *mut RustArchiveMember_opaque;
413 #[allow(missing_copy_implementations)]
414 pub enum OperandBundleDef_opaque {}
415 pub type OperandBundleDefRef = *mut OperandBundleDef_opaque;
417 pub type DiagnosticHandler = unsafe extern "C" fn(DiagnosticInfoRef, *mut c_void);
418 pub type InlineAsmDiagHandler = unsafe extern "C" fn(SMDiagnosticRef, *const c_void, c_uint);
422 use super::MetadataRef;
424 #[allow(missing_copy_implementations)]
425 pub enum DIBuilder_opaque {}
426 pub type DIBuilderRef = *mut DIBuilder_opaque;
428 pub type DIDescriptor = MetadataRef;
429 pub type DIScope = DIDescriptor;
430 pub type DILocation = DIDescriptor;
431 pub type DIFile = DIScope;
432 pub type DILexicalBlock = DIScope;
433 pub type DISubprogram = DIScope;
434 pub type DINameSpace = DIScope;
435 pub type DIType = DIDescriptor;
436 pub type DIBasicType = DIType;
437 pub type DIDerivedType = DIType;
438 pub type DICompositeType = DIDerivedType;
439 pub type DIVariable = DIDescriptor;
440 pub type DIGlobalVariable = DIDescriptor;
441 pub type DIArray = DIDescriptor;
442 pub type DISubrange = DIDescriptor;
443 pub type DIEnumerator = DIDescriptor;
444 pub type DITemplateTypeParameter = DIDescriptor;
446 // These values **must** match with LLVMRustDIFlags!!
449 #[derive(Debug, Default)]
450 flags DIFlags: ::libc::uint32_t {
452 const FlagPrivate = 1,
453 const FlagProtected = 2,
454 const FlagPublic = 3,
455 const FlagFwdDecl = (1 << 2),
456 const FlagAppleBlock = (1 << 3),
457 const FlagBlockByrefStruct = (1 << 4),
458 const FlagVirtual = (1 << 5),
459 const FlagArtificial = (1 << 6),
460 const FlagExplicit = (1 << 7),
461 const FlagPrototyped = (1 << 8),
462 const FlagObjcClassComplete = (1 << 9),
463 const FlagObjectPointer = (1 << 10),
464 const FlagVector = (1 << 11),
465 const FlagStaticMember = (1 << 12),
466 const FlagLValueReference = (1 << 13),
467 const FlagRValueReference = (1 << 14),
473 // Link to our native llvm bindings (things that we need to use the C++ api
474 // for) and because llvm is written in C++ we need to link against libstdc++
476 // You'll probably notice that there is an omission of all LLVM libraries
477 // from this location. This is because the set of LLVM libraries that we
478 // link to is mostly defined by LLVM, and the `llvm-config` tool is used to
479 // figure out the exact set of libraries. To do this, the build system
480 // generates an llvmdeps.rs file next to this one which will be
481 // automatically updated whenever LLVM is updated to include an up-to-date
482 // set of the libraries we need to link to LLVM for.
483 #[link(name = "rustllvm", kind = "static")] // not quite true but good enough
485 // Create and destroy contexts.
486 pub fn LLVMContextCreate() -> ContextRef;
487 pub fn LLVMContextDispose(C: ContextRef);
488 pub fn LLVMGetMDKindIDInContext(C: ContextRef, Name: *const c_char, SLen: c_uint) -> c_uint;
490 // Create and destroy modules.
491 pub fn LLVMModuleCreateWithNameInContext(ModuleID: *const c_char, C: ContextRef) -> ModuleRef;
492 pub fn LLVMGetModuleContext(M: ModuleRef) -> ContextRef;
493 pub fn LLVMCloneModule(M: ModuleRef) -> ModuleRef;
494 pub fn LLVMDisposeModule(M: ModuleRef);
496 /// Data layout. See Module::getDataLayout.
497 pub fn LLVMGetDataLayout(M: ModuleRef) -> *const c_char;
498 pub fn LLVMSetDataLayout(M: ModuleRef, Triple: *const c_char);
500 /// See Module::dump.
501 pub fn LLVMDumpModule(M: ModuleRef);
503 /// See Module::setModuleInlineAsm.
504 pub fn LLVMSetModuleInlineAsm(M: ModuleRef, Asm: *const c_char);
506 /// See llvm::LLVMTypeKind::getTypeID.
507 pub fn LLVMRustGetTypeKind(Ty: TypeRef) -> TypeKind;
509 /// See llvm::Value::getContext
510 pub fn LLVMRustGetValueContext(V: ValueRef) -> ContextRef;
512 // Operations on integer types
513 pub fn LLVMInt1TypeInContext(C: ContextRef) -> TypeRef;
514 pub fn LLVMInt8TypeInContext(C: ContextRef) -> TypeRef;
515 pub fn LLVMInt16TypeInContext(C: ContextRef) -> TypeRef;
516 pub fn LLVMInt32TypeInContext(C: ContextRef) -> TypeRef;
517 pub fn LLVMInt64TypeInContext(C: ContextRef) -> TypeRef;
518 pub fn LLVMIntTypeInContext(C: ContextRef, NumBits: c_uint) -> TypeRef;
520 pub fn LLVMGetIntTypeWidth(IntegerTy: TypeRef) -> c_uint;
522 // Operations on real types
523 pub fn LLVMFloatTypeInContext(C: ContextRef) -> TypeRef;
524 pub fn LLVMDoubleTypeInContext(C: ContextRef) -> TypeRef;
526 // Operations on function types
527 pub fn LLVMFunctionType(ReturnType: TypeRef,
528 ParamTypes: *const TypeRef,
532 pub fn LLVMGetReturnType(FunctionTy: TypeRef) -> TypeRef;
533 pub fn LLVMCountParamTypes(FunctionTy: TypeRef) -> c_uint;
534 pub fn LLVMGetParamTypes(FunctionTy: TypeRef, Dest: *mut TypeRef);
536 // Operations on struct types
537 pub fn LLVMStructTypeInContext(C: ContextRef,
538 ElementTypes: *const TypeRef,
539 ElementCount: c_uint,
542 pub fn LLVMCountStructElementTypes(StructTy: TypeRef) -> c_uint;
543 pub fn LLVMGetStructElementTypes(StructTy: TypeRef, Dest: *mut TypeRef);
544 pub fn LLVMIsPackedStruct(StructTy: TypeRef) -> Bool;
546 // Operations on array, pointer, and vector types (sequence types)
547 pub fn LLVMRustArrayType(ElementType: TypeRef, ElementCount: u64) -> TypeRef;
548 pub fn LLVMPointerType(ElementType: TypeRef, AddressSpace: c_uint) -> TypeRef;
549 pub fn LLVMVectorType(ElementType: TypeRef, ElementCount: c_uint) -> TypeRef;
551 pub fn LLVMGetElementType(Ty: TypeRef) -> TypeRef;
552 pub fn LLVMGetArrayLength(ArrayTy: TypeRef) -> c_uint;
553 pub fn LLVMGetVectorSize(VectorTy: TypeRef) -> c_uint;
555 // Operations on other types
556 pub fn LLVMVoidTypeInContext(C: ContextRef) -> TypeRef;
557 pub fn LLVMRustMetadataTypeInContext(C: ContextRef) -> TypeRef;
559 // Operations on all values
560 pub fn LLVMTypeOf(Val: ValueRef) -> TypeRef;
561 pub fn LLVMGetValueName(Val: ValueRef) -> *const c_char;
562 pub fn LLVMSetValueName(Val: ValueRef, Name: *const c_char);
563 pub fn LLVMReplaceAllUsesWith(OldVal: ValueRef, NewVal: ValueRef);
564 pub fn LLVMSetMetadata(Val: ValueRef, KindID: c_uint, Node: ValueRef);
566 // Operations on Uses
567 pub fn LLVMGetFirstUse(Val: ValueRef) -> UseRef;
568 pub fn LLVMGetNextUse(U: UseRef) -> UseRef;
569 pub fn LLVMGetUser(U: UseRef) -> ValueRef;
571 // Operations on Users
572 pub fn LLVMGetOperand(Val: ValueRef, Index: c_uint) -> ValueRef;
574 // Operations on constants of any type
575 pub fn LLVMConstNull(Ty: TypeRef) -> ValueRef;
576 pub fn LLVMConstICmp(Pred: IntPredicate, V1: ValueRef, V2: ValueRef) -> ValueRef;
577 pub fn LLVMConstFCmp(Pred: RealPredicate, V1: ValueRef, V2: ValueRef) -> ValueRef;
578 // only for isize/vector
579 pub fn LLVMGetUndef(Ty: TypeRef) -> ValueRef;
580 pub fn LLVMIsNull(Val: ValueRef) -> Bool;
581 pub fn LLVMIsUndef(Val: ValueRef) -> Bool;
583 // Operations on metadata
584 pub fn LLVMMDNodeInContext(C: ContextRef, Vals: *const ValueRef, Count: c_uint) -> ValueRef;
586 // Operations on scalar constants
587 pub fn LLVMConstInt(IntTy: TypeRef, N: c_ulonglong, SignExtend: Bool) -> ValueRef;
588 pub fn LLVMConstIntOfArbitraryPrecision(IntTy: TypeRef, Wn: c_uint, Ws: *const u64) -> ValueRef;
589 pub fn LLVMConstReal(RealTy: TypeRef, N: f64) -> ValueRef;
590 pub fn LLVMConstIntGetZExtValue(ConstantVal: ValueRef) -> c_ulonglong;
591 pub fn LLVMConstIntGetSExtValue(ConstantVal: ValueRef) -> c_longlong;
592 pub fn LLVMRustConstInt128Get(ConstantVal: ValueRef, SExt: bool,
593 high: *mut u64, low: *mut u64) -> bool;
596 // Operations on composite constants
597 pub fn LLVMConstStringInContext(C: ContextRef,
600 DontNullTerminate: Bool)
602 pub fn LLVMConstStructInContext(C: ContextRef,
603 ConstantVals: *const ValueRef,
608 pub fn LLVMConstArray(ElementTy: TypeRef,
609 ConstantVals: *const ValueRef,
612 pub fn LLVMConstVector(ScalarConstantVals: *const ValueRef, Size: c_uint) -> ValueRef;
614 // Constant expressions
615 pub fn LLVMSizeOf(Ty: TypeRef) -> ValueRef;
616 pub fn LLVMConstNeg(ConstantVal: ValueRef) -> ValueRef;
617 pub fn LLVMConstFNeg(ConstantVal: ValueRef) -> ValueRef;
618 pub fn LLVMConstNot(ConstantVal: ValueRef) -> ValueRef;
619 pub fn LLVMConstAdd(LHSConstant: ValueRef, RHSConstant: ValueRef) -> ValueRef;
620 pub fn LLVMConstFAdd(LHSConstant: ValueRef, RHSConstant: ValueRef) -> ValueRef;
621 pub fn LLVMConstSub(LHSConstant: ValueRef, RHSConstant: ValueRef) -> ValueRef;
622 pub fn LLVMConstFSub(LHSConstant: ValueRef, RHSConstant: ValueRef) -> ValueRef;
623 pub fn LLVMConstMul(LHSConstant: ValueRef, RHSConstant: ValueRef) -> ValueRef;
624 pub fn LLVMConstFMul(LHSConstant: ValueRef, RHSConstant: ValueRef) -> ValueRef;
625 pub fn LLVMConstUDiv(LHSConstant: ValueRef, RHSConstant: ValueRef) -> ValueRef;
626 pub fn LLVMConstSDiv(LHSConstant: ValueRef, RHSConstant: ValueRef) -> ValueRef;
627 pub fn LLVMConstFDiv(LHSConstant: ValueRef, RHSConstant: ValueRef) -> ValueRef;
628 pub fn LLVMConstURem(LHSConstant: ValueRef, RHSConstant: ValueRef) -> ValueRef;
629 pub fn LLVMConstSRem(LHSConstant: ValueRef, RHSConstant: ValueRef) -> ValueRef;
630 pub fn LLVMConstFRem(LHSConstant: ValueRef, RHSConstant: ValueRef) -> ValueRef;
631 pub fn LLVMConstAnd(LHSConstant: ValueRef, RHSConstant: ValueRef) -> ValueRef;
632 pub fn LLVMConstOr(LHSConstant: ValueRef, RHSConstant: ValueRef) -> ValueRef;
633 pub fn LLVMConstXor(LHSConstant: ValueRef, RHSConstant: ValueRef) -> ValueRef;
634 pub fn LLVMConstShl(LHSConstant: ValueRef, RHSConstant: ValueRef) -> ValueRef;
635 pub fn LLVMConstLShr(LHSConstant: ValueRef, RHSConstant: ValueRef) -> ValueRef;
636 pub fn LLVMConstAShr(LHSConstant: ValueRef, RHSConstant: ValueRef) -> ValueRef;
637 pub fn LLVMConstTrunc(ConstantVal: ValueRef, ToType: TypeRef) -> ValueRef;
638 pub fn LLVMConstZExt(ConstantVal: ValueRef, ToType: TypeRef) -> ValueRef;
639 pub fn LLVMConstUIToFP(ConstantVal: ValueRef, ToType: TypeRef) -> ValueRef;
640 pub fn LLVMConstSIToFP(ConstantVal: ValueRef, ToType: TypeRef) -> ValueRef;
641 pub fn LLVMConstFPToUI(ConstantVal: ValueRef, ToType: TypeRef) -> ValueRef;
642 pub fn LLVMConstFPToSI(ConstantVal: ValueRef, ToType: TypeRef) -> ValueRef;
643 pub fn LLVMConstPtrToInt(ConstantVal: ValueRef, ToType: TypeRef) -> ValueRef;
644 pub fn LLVMConstIntToPtr(ConstantVal: ValueRef, ToType: TypeRef) -> ValueRef;
645 pub fn LLVMConstBitCast(ConstantVal: ValueRef, ToType: TypeRef) -> ValueRef;
646 pub fn LLVMConstPointerCast(ConstantVal: ValueRef, ToType: TypeRef) -> ValueRef;
647 pub fn LLVMConstIntCast(ConstantVal: ValueRef, ToType: TypeRef, isSigned: Bool) -> ValueRef;
648 pub fn LLVMConstFPCast(ConstantVal: ValueRef, ToType: TypeRef) -> ValueRef;
649 pub fn LLVMConstExtractValue(AggConstant: ValueRef,
650 IdxList: *const c_uint,
653 pub fn LLVMConstInlineAsm(Ty: TypeRef,
654 AsmString: *const c_char,
655 Constraints: *const c_char,
656 HasSideEffects: Bool,
661 // Operations on global variables, functions, and aliases (globals)
662 pub fn LLVMGetGlobalParent(Global: ValueRef) -> ModuleRef;
663 pub fn LLVMIsDeclaration(Global: ValueRef) -> Bool;
664 pub fn LLVMRustGetLinkage(Global: ValueRef) -> Linkage;
665 pub fn LLVMRustSetLinkage(Global: ValueRef, RustLinkage: Linkage);
666 pub fn LLVMGetSection(Global: ValueRef) -> *const c_char;
667 pub fn LLVMSetSection(Global: ValueRef, Section: *const c_char);
668 pub fn LLVMRustGetVisibility(Global: ValueRef) -> Visibility;
669 pub fn LLVMRustSetVisibility(Global: ValueRef, Viz: Visibility);
670 pub fn LLVMGetAlignment(Global: ValueRef) -> c_uint;
671 pub fn LLVMSetAlignment(Global: ValueRef, Bytes: c_uint);
672 pub fn LLVMSetDLLStorageClass(V: ValueRef, C: DLLStorageClass);
675 // Operations on global variables
676 pub fn LLVMIsAGlobalVariable(GlobalVar: ValueRef) -> ValueRef;
677 pub fn LLVMAddGlobal(M: ModuleRef, Ty: TypeRef, Name: *const c_char) -> ValueRef;
678 pub fn LLVMGetNamedGlobal(M: ModuleRef, Name: *const c_char) -> ValueRef;
679 pub fn LLVMRustGetOrInsertGlobal(M: ModuleRef, Name: *const c_char, T: TypeRef) -> ValueRef;
680 pub fn LLVMGetFirstGlobal(M: ModuleRef) -> ValueRef;
681 pub fn LLVMGetNextGlobal(GlobalVar: ValueRef) -> ValueRef;
682 pub fn LLVMDeleteGlobal(GlobalVar: ValueRef);
683 pub fn LLVMGetInitializer(GlobalVar: ValueRef) -> ValueRef;
684 pub fn LLVMSetInitializer(GlobalVar: ValueRef, ConstantVal: ValueRef);
685 pub fn LLVMSetThreadLocal(GlobalVar: ValueRef, IsThreadLocal: Bool);
686 pub fn LLVMIsGlobalConstant(GlobalVar: ValueRef) -> Bool;
687 pub fn LLVMSetGlobalConstant(GlobalVar: ValueRef, IsConstant: Bool);
688 pub fn LLVMRustGetNamedValue(M: ModuleRef, Name: *const c_char) -> ValueRef;
690 // Operations on functions
691 pub fn LLVMAddFunction(M: ModuleRef, Name: *const c_char, FunctionTy: TypeRef) -> ValueRef;
692 pub fn LLVMGetNamedFunction(M: ModuleRef, Name: *const c_char) -> ValueRef;
693 pub fn LLVMGetFirstFunction(M: ModuleRef) -> ValueRef;
694 pub fn LLVMGetNextFunction(Fn: ValueRef) -> ValueRef;
695 pub fn LLVMRustGetOrInsertFunction(M: ModuleRef,
699 pub fn LLVMSetFunctionCallConv(Fn: ValueRef, CC: c_uint);
700 pub fn LLVMRustAddDereferenceableAttr(Fn: ValueRef, index: c_uint, bytes: u64);
701 pub fn LLVMRustAddFunctionAttribute(Fn: ValueRef, index: c_uint, attr: Attribute);
702 pub fn LLVMRustAddFunctionAttrStringValue(Fn: ValueRef,
705 Value: *const c_char);
706 pub fn LLVMRustRemoveFunctionAttributes(Fn: ValueRef, index: c_uint, attr: Attribute);
708 // Operations on parameters
709 pub fn LLVMCountParams(Fn: ValueRef) -> c_uint;
710 pub fn LLVMGetParam(Fn: ValueRef, Index: c_uint) -> ValueRef;
712 // Operations on basic blocks
713 pub fn LLVMBasicBlockAsValue(BB: BasicBlockRef) -> ValueRef;
714 pub fn LLVMGetBasicBlockParent(BB: BasicBlockRef) -> ValueRef;
715 pub fn LLVMAppendBasicBlockInContext(C: ContextRef,
719 pub fn LLVMDeleteBasicBlock(BB: BasicBlockRef);
721 // Operations on instructions
722 pub fn LLVMGetInstructionParent(Inst: ValueRef) -> BasicBlockRef;
723 pub fn LLVMGetFirstBasicBlock(Fn: ValueRef) -> BasicBlockRef;
724 pub fn LLVMGetFirstInstruction(BB: BasicBlockRef) -> ValueRef;
725 pub fn LLVMInstructionEraseFromParent(Inst: ValueRef);
727 // Operations on call sites
728 pub fn LLVMSetInstructionCallConv(Instr: ValueRef, CC: c_uint);
729 pub fn LLVMRustAddCallSiteAttribute(Instr: ValueRef, index: c_uint, attr: Attribute);
730 pub fn LLVMRustAddDereferenceableCallSiteAttr(Instr: ValueRef, index: c_uint, bytes: u64);
732 // Operations on load/store instructions (only)
733 pub fn LLVMSetVolatile(MemoryAccessInst: ValueRef, volatile: Bool);
735 // Operations on phi nodes
736 pub fn LLVMAddIncoming(PhiNode: ValueRef,
737 IncomingValues: *const ValueRef,
738 IncomingBlocks: *const BasicBlockRef,
741 // Instruction builders
742 pub fn LLVMCreateBuilderInContext(C: ContextRef) -> BuilderRef;
743 pub fn LLVMPositionBuilder(Builder: BuilderRef, Block: BasicBlockRef, Instr: ValueRef);
744 pub fn LLVMPositionBuilderBefore(Builder: BuilderRef, Instr: ValueRef);
745 pub fn LLVMPositionBuilderAtEnd(Builder: BuilderRef, Block: BasicBlockRef);
746 pub fn LLVMGetInsertBlock(Builder: BuilderRef) -> BasicBlockRef;
747 pub fn LLVMDisposeBuilder(Builder: BuilderRef);
750 pub fn LLVMSetCurrentDebugLocation(Builder: BuilderRef, L: ValueRef);
751 pub fn LLVMGetCurrentDebugLocation(Builder: BuilderRef) -> ValueRef;
752 pub fn LLVMSetInstDebugLocation(Builder: BuilderRef, Inst: ValueRef);
755 pub fn LLVMBuildRetVoid(B: BuilderRef) -> ValueRef;
756 pub fn LLVMBuildRet(B: BuilderRef, V: ValueRef) -> ValueRef;
757 pub fn LLVMBuildAggregateRet(B: BuilderRef, RetVals: *const ValueRef, N: c_uint) -> ValueRef;
758 pub fn LLVMBuildBr(B: BuilderRef, Dest: BasicBlockRef) -> ValueRef;
759 pub fn LLVMBuildCondBr(B: BuilderRef,
764 pub fn LLVMBuildSwitch(B: BuilderRef,
769 pub fn LLVMBuildIndirectBr(B: BuilderRef, Addr: ValueRef, NumDests: c_uint) -> ValueRef;
770 pub fn LLVMRustBuildInvoke(B: BuilderRef,
772 Args: *const ValueRef,
775 Catch: BasicBlockRef,
776 Bundle: OperandBundleDefRef,
779 pub fn LLVMRustBuildLandingPad(B: BuilderRef,
786 pub fn LLVMBuildResume(B: BuilderRef, Exn: ValueRef) -> ValueRef;
787 pub fn LLVMBuildUnreachable(B: BuilderRef) -> ValueRef;
789 pub fn LLVMRustBuildCleanupPad(B: BuilderRef,
792 Args: *const ValueRef,
795 pub fn LLVMRustBuildCleanupRet(B: BuilderRef,
796 CleanupPad: ValueRef,
797 UnwindBB: BasicBlockRef)
799 pub fn LLVMRustBuildCatchPad(B: BuilderRef,
802 Args: *const ValueRef,
805 pub fn LLVMRustBuildCatchRet(B: BuilderRef, Pad: ValueRef, BB: BasicBlockRef) -> ValueRef;
806 pub fn LLVMRustBuildCatchSwitch(Builder: BuilderRef,
812 pub fn LLVMRustAddHandler(CatchSwitch: ValueRef, Handler: BasicBlockRef);
813 pub fn LLVMSetPersonalityFn(Func: ValueRef, Pers: ValueRef);
815 // Add a case to the switch instruction
816 pub fn LLVMAddCase(Switch: ValueRef, OnVal: ValueRef, Dest: BasicBlockRef);
818 // Add a clause to the landing pad instruction
819 pub fn LLVMAddClause(LandingPad: ValueRef, ClauseVal: ValueRef);
821 // Set the cleanup on a landing pad instruction
822 pub fn LLVMSetCleanup(LandingPad: ValueRef, Val: Bool);
825 pub fn LLVMBuildAdd(B: BuilderRef,
830 pub fn LLVMBuildNSWAdd(B: BuilderRef,
835 pub fn LLVMBuildNUWAdd(B: BuilderRef,
840 pub fn LLVMBuildFAdd(B: BuilderRef,
845 pub fn LLVMBuildSub(B: BuilderRef,
850 pub fn LLVMBuildNSWSub(B: BuilderRef,
855 pub fn LLVMBuildNUWSub(B: BuilderRef,
860 pub fn LLVMBuildFSub(B: BuilderRef,
865 pub fn LLVMBuildMul(B: BuilderRef,
870 pub fn LLVMBuildNSWMul(B: BuilderRef,
875 pub fn LLVMBuildNUWMul(B: BuilderRef,
880 pub fn LLVMBuildFMul(B: BuilderRef,
885 pub fn LLVMBuildUDiv(B: BuilderRef,
890 pub fn LLVMBuildSDiv(B: BuilderRef,
895 pub fn LLVMBuildExactSDiv(B: BuilderRef,
900 pub fn LLVMBuildFDiv(B: BuilderRef,
905 pub fn LLVMBuildURem(B: BuilderRef,
910 pub fn LLVMBuildSRem(B: BuilderRef,
915 pub fn LLVMBuildFRem(B: BuilderRef,
920 pub fn LLVMBuildShl(B: BuilderRef,
925 pub fn LLVMBuildLShr(B: BuilderRef,
930 pub fn LLVMBuildAShr(B: BuilderRef,
935 pub fn LLVMBuildAnd(B: BuilderRef,
940 pub fn LLVMBuildOr(B: BuilderRef,
945 pub fn LLVMBuildXor(B: BuilderRef,
950 pub fn LLVMBuildBinOp(B: BuilderRef,
956 pub fn LLVMBuildNeg(B: BuilderRef, V: ValueRef, Name: *const c_char) -> ValueRef;
957 pub fn LLVMBuildNSWNeg(B: BuilderRef, V: ValueRef, Name: *const c_char) -> ValueRef;
958 pub fn LLVMBuildNUWNeg(B: BuilderRef, V: ValueRef, Name: *const c_char) -> ValueRef;
959 pub fn LLVMBuildFNeg(B: BuilderRef, V: ValueRef, Name: *const c_char) -> ValueRef;
960 pub fn LLVMBuildNot(B: BuilderRef, V: ValueRef, Name: *const c_char) -> ValueRef;
961 pub fn LLVMRustSetHasUnsafeAlgebra(Instr: ValueRef);
964 pub fn LLVMBuildAlloca(B: BuilderRef, Ty: TypeRef, Name: *const c_char) -> ValueRef;
965 pub fn LLVMBuildFree(B: BuilderRef, PointerVal: ValueRef) -> ValueRef;
966 pub fn LLVMBuildLoad(B: BuilderRef, PointerVal: ValueRef, Name: *const c_char) -> ValueRef;
968 pub fn LLVMBuildStore(B: BuilderRef, Val: ValueRef, Ptr: ValueRef) -> ValueRef;
970 pub fn LLVMBuildGEP(B: BuilderRef,
972 Indices: *const ValueRef,
976 pub fn LLVMBuildInBoundsGEP(B: BuilderRef,
978 Indices: *const ValueRef,
982 pub fn LLVMBuildStructGEP(B: BuilderRef,
987 pub fn LLVMBuildGlobalString(B: BuilderRef,
991 pub fn LLVMBuildGlobalStringPtr(B: BuilderRef,
997 pub fn LLVMBuildTrunc(B: BuilderRef,
1000 Name: *const c_char)
1002 pub fn LLVMBuildZExt(B: BuilderRef,
1005 Name: *const c_char)
1007 pub fn LLVMBuildSExt(B: BuilderRef,
1010 Name: *const c_char)
1012 pub fn LLVMBuildFPToUI(B: BuilderRef,
1015 Name: *const c_char)
1017 pub fn LLVMBuildFPToSI(B: BuilderRef,
1020 Name: *const c_char)
1022 pub fn LLVMBuildUIToFP(B: BuilderRef,
1025 Name: *const c_char)
1027 pub fn LLVMBuildSIToFP(B: BuilderRef,
1030 Name: *const c_char)
1032 pub fn LLVMBuildFPTrunc(B: BuilderRef,
1035 Name: *const c_char)
1037 pub fn LLVMBuildFPExt(B: BuilderRef,
1040 Name: *const c_char)
1042 pub fn LLVMBuildPtrToInt(B: BuilderRef,
1045 Name: *const c_char)
1047 pub fn LLVMBuildIntToPtr(B: BuilderRef,
1050 Name: *const c_char)
1052 pub fn LLVMBuildBitCast(B: BuilderRef,
1055 Name: *const c_char)
1057 pub fn LLVMBuildZExtOrBitCast(B: BuilderRef,
1060 Name: *const c_char)
1062 pub fn LLVMBuildSExtOrBitCast(B: BuilderRef,
1065 Name: *const c_char)
1067 pub fn LLVMBuildTruncOrBitCast(B: BuilderRef,
1070 Name: *const c_char)
1072 pub fn LLVMBuildCast(B: BuilderRef,
1076 Name: *const c_char)
1078 pub fn LLVMBuildPointerCast(B: BuilderRef,
1081 Name: *const c_char)
1083 pub fn LLVMBuildIntCast(B: BuilderRef,
1086 Name: *const c_char)
1088 pub fn LLVMBuildFPCast(B: BuilderRef,
1091 Name: *const c_char)
1095 pub fn LLVMBuildICmp(B: BuilderRef,
1099 Name: *const c_char)
1101 pub fn LLVMBuildFCmp(B: BuilderRef,
1105 Name: *const c_char)
1108 // Miscellaneous instructions
1109 pub fn LLVMBuildPhi(B: BuilderRef, Ty: TypeRef, Name: *const c_char) -> ValueRef;
1110 pub fn LLVMRustBuildCall(B: BuilderRef,
1112 Args: *const ValueRef,
1114 Bundle: OperandBundleDefRef,
1115 Name: *const c_char)
1117 pub fn LLVMBuildSelect(B: BuilderRef,
1121 Name: *const c_char)
1123 pub fn LLVMBuildVAArg(B: BuilderRef,
1126 Name: *const c_char)
1128 pub fn LLVMBuildExtractElement(B: BuilderRef,
1131 Name: *const c_char)
1133 pub fn LLVMBuildInsertElement(B: BuilderRef,
1137 Name: *const c_char)
1139 pub fn LLVMBuildShuffleVector(B: BuilderRef,
1143 Name: *const c_char)
1145 pub fn LLVMBuildExtractValue(B: BuilderRef,
1148 Name: *const c_char)
1150 pub fn LLVMBuildInsertValue(B: BuilderRef,
1154 Name: *const c_char)
1157 pub fn LLVMBuildIsNull(B: BuilderRef, Val: ValueRef, Name: *const c_char) -> ValueRef;
1158 pub fn LLVMBuildIsNotNull(B: BuilderRef, Val: ValueRef, Name: *const c_char) -> ValueRef;
1159 pub fn LLVMBuildPtrDiff(B: BuilderRef,
1162 Name: *const c_char)
1165 // Atomic Operations
1166 pub fn LLVMRustBuildAtomicLoad(B: BuilderRef,
1167 PointerVal: ValueRef,
1168 Name: *const c_char,
1169 Order: AtomicOrdering,
1173 pub fn LLVMRustBuildAtomicStore(B: BuilderRef,
1176 Order: AtomicOrdering,
1180 pub fn LLVMRustBuildAtomicCmpXchg(B: BuilderRef,
1184 Order: AtomicOrdering,
1185 FailureOrder: AtomicOrdering,
1189 pub fn LLVMBuildAtomicRMW(B: BuilderRef,
1193 Order: AtomicOrdering,
1194 SingleThreaded: Bool)
1197 pub fn LLVMRustBuildAtomicFence(B: BuilderRef,
1198 Order: AtomicOrdering,
1199 Scope: SynchronizationScope);
1202 // Selected entries from the downcasts.
1203 pub fn LLVMIsATerminatorInst(Inst: ValueRef) -> ValueRef;
1204 pub fn LLVMIsAStoreInst(Inst: ValueRef) -> ValueRef;
1206 /// Writes a module to the specified path. Returns 0 on success.
1207 pub fn LLVMWriteBitcodeToFile(M: ModuleRef, Path: *const c_char) -> c_int;
1209 /// Creates target data from a target layout string.
1210 pub fn LLVMCreateTargetData(StringRep: *const c_char) -> TargetDataRef;
1211 /// Number of bytes clobbered when doing a Store to *T.
1212 pub fn LLVMSizeOfTypeInBits(TD: TargetDataRef, Ty: TypeRef) -> c_ulonglong;
1214 /// Distance between successive elements in an array of T. Includes ABI padding.
1215 pub fn LLVMABISizeOfType(TD: TargetDataRef, Ty: TypeRef) -> c_ulonglong;
1217 /// Returns the preferred alignment of a type.
1218 pub fn LLVMPreferredAlignmentOfType(TD: TargetDataRef, Ty: TypeRef) -> c_uint;
1219 /// Returns the minimum alignment of a type.
1220 pub fn LLVMABIAlignmentOfType(TD: TargetDataRef, Ty: TypeRef) -> c_uint;
1222 /// Computes the byte offset of the indexed struct element for a
1224 pub fn LLVMOffsetOfElement(TD: TargetDataRef,
1229 /// Disposes target data.
1230 pub fn LLVMDisposeTargetData(TD: TargetDataRef);
1232 /// Creates a pass manager.
1233 pub fn LLVMCreatePassManager() -> PassManagerRef;
1235 /// Creates a function-by-function pass manager
1236 pub fn LLVMCreateFunctionPassManagerForModule(M: ModuleRef) -> PassManagerRef;
1238 /// Disposes a pass manager.
1239 pub fn LLVMDisposePassManager(PM: PassManagerRef);
1241 /// Runs a pass manager on a module.
1242 pub fn LLVMRunPassManager(PM: PassManagerRef, M: ModuleRef) -> Bool;
1244 pub fn LLVMInitializePasses();
1246 pub fn LLVMPassManagerBuilderCreate() -> PassManagerBuilderRef;
1247 pub fn LLVMPassManagerBuilderDispose(PMB: PassManagerBuilderRef);
1248 pub fn LLVMPassManagerBuilderSetSizeLevel(PMB: PassManagerBuilderRef, Value: Bool);
1249 pub fn LLVMPassManagerBuilderSetDisableUnrollLoops(PMB: PassManagerBuilderRef, Value: Bool);
1250 pub fn LLVMPassManagerBuilderUseInlinerWithThreshold(PMB: PassManagerBuilderRef,
1252 pub fn LLVMPassManagerBuilderPopulateModulePassManager(PMB: PassManagerBuilderRef,
1253 PM: PassManagerRef);
1255 pub fn LLVMPassManagerBuilderPopulateFunctionPassManager(PMB: PassManagerBuilderRef,
1256 PM: PassManagerRef);
1257 pub fn LLVMPassManagerBuilderPopulateLTOPassManager(PMB: PassManagerBuilderRef,
1262 // Stuff that's in rustllvm/ because it's not upstream yet.
1264 /// Opens an object file.
1265 pub fn LLVMCreateObjectFile(MemBuf: MemoryBufferRef) -> ObjectFileRef;
1266 /// Closes an object file.
1267 pub fn LLVMDisposeObjectFile(ObjFile: ObjectFileRef);
1269 /// Enumerates the sections in an object file.
1270 pub fn LLVMGetSections(ObjFile: ObjectFileRef) -> SectionIteratorRef;
1271 /// Destroys a section iterator.
1272 pub fn LLVMDisposeSectionIterator(SI: SectionIteratorRef);
1273 /// Returns true if the section iterator is at the end of the section
1275 pub fn LLVMIsSectionIteratorAtEnd(ObjFile: ObjectFileRef, SI: SectionIteratorRef) -> Bool;
1276 /// Moves the section iterator to point to the next section.
1277 pub fn LLVMMoveToNextSection(SI: SectionIteratorRef);
1278 /// Returns the current section size.
1279 pub fn LLVMGetSectionSize(SI: SectionIteratorRef) -> c_ulonglong;
1280 /// Returns the current section contents as a string buffer.
1281 pub fn LLVMGetSectionContents(SI: SectionIteratorRef) -> *const c_char;
1283 /// Reads the given file and returns it as a memory buffer. Use
1284 /// LLVMDisposeMemoryBuffer() to get rid of it.
1285 pub fn LLVMRustCreateMemoryBufferWithContentsOfFile(Path: *const c_char) -> MemoryBufferRef;
1287 pub fn LLVMStartMultithreaded() -> Bool;
1289 /// Returns a string describing the last error caused by an LLVMRust* call.
1290 pub fn LLVMRustGetLastError() -> *const c_char;
1292 /// Print the pass timings since static dtors aren't picking them up.
1293 pub fn LLVMRustPrintPassTimings();
1295 pub fn LLVMStructCreateNamed(C: ContextRef, Name: *const c_char) -> TypeRef;
1297 pub fn LLVMStructSetBody(StructTy: TypeRef,
1298 ElementTypes: *const TypeRef,
1299 ElementCount: c_uint,
1302 pub fn LLVMConstNamedStruct(S: TypeRef,
1303 ConstantVals: *const ValueRef,
1307 /// Enables LLVM debug output.
1308 pub fn LLVMRustSetDebug(Enabled: c_int);
1310 /// Prepares inline assembly.
1311 pub fn LLVMRustInlineAsm(Ty: TypeRef,
1312 AsmString: *const c_char,
1313 Constraints: *const c_char,
1316 Dialect: AsmDialect)
1319 pub fn LLVMRustDebugMetadataVersion() -> u32;
1320 pub fn LLVMRustVersionMajor() -> u32;
1321 pub fn LLVMRustVersionMinor() -> u32;
1323 pub fn LLVMRustAddModuleFlag(M: ModuleRef, name: *const c_char, value: u32);
1325 pub fn LLVMRustDIBuilderCreate(M: ModuleRef) -> DIBuilderRef;
1327 pub fn LLVMRustDIBuilderDispose(Builder: DIBuilderRef);
1329 pub fn LLVMRustDIBuilderFinalize(Builder: DIBuilderRef);
1331 pub fn LLVMRustDIBuilderCreateCompileUnit(Builder: DIBuilderRef,
1333 File: *const c_char,
1335 Producer: *const c_char,
1337 Flags: *const c_char,
1339 SplitName: *const c_char)
1342 pub fn LLVMRustDIBuilderCreateFile(Builder: DIBuilderRef,
1343 Filename: *const c_char,
1344 Directory: *const c_char)
1347 pub fn LLVMRustDIBuilderCreateSubroutineType(Builder: DIBuilderRef,
1349 ParameterTypes: DIArray)
1352 pub fn LLVMRustDIBuilderCreateFunction(Builder: DIBuilderRef,
1353 Scope: DIDescriptor,
1354 Name: *const c_char,
1355 LinkageName: *const c_char,
1359 isLocalToUnit: bool,
1369 pub fn LLVMRustDIBuilderCreateBasicType(Builder: DIBuilderRef,
1370 Name: *const c_char,
1376 pub fn LLVMRustDIBuilderCreatePointerType(Builder: DIBuilderRef,
1380 Name: *const c_char)
1383 pub fn LLVMRustDIBuilderCreateStructType(Builder: DIBuilderRef,
1384 Scope: DIDescriptor,
1385 Name: *const c_char,
1391 DerivedFrom: DIType,
1393 RunTimeLang: c_uint,
1394 VTableHolder: DIType,
1395 UniqueId: *const c_char)
1398 pub fn LLVMRustDIBuilderCreateMemberType(Builder: DIBuilderRef,
1399 Scope: DIDescriptor,
1400 Name: *const c_char,
1410 pub fn LLVMRustDIBuilderCreateLexicalBlock(Builder: DIBuilderRef,
1417 pub fn LLVMRustDIBuilderCreateLexicalBlockFile(Builder: DIBuilderRef,
1422 pub fn LLVMRustDIBuilderCreateStaticVariable(Builder: DIBuilderRef,
1424 Name: *const c_char,
1425 LinkageName: *const c_char,
1429 isLocalToUnit: bool,
1433 -> DIGlobalVariable;
1435 pub fn LLVMRustDIBuilderCreateVariable(Builder: DIBuilderRef,
1437 Scope: DIDescriptor,
1438 Name: *const c_char,
1442 AlwaysPreserve: bool,
1448 pub fn LLVMRustDIBuilderCreateArrayType(Builder: DIBuilderRef,
1452 Subscripts: DIArray)
1455 pub fn LLVMRustDIBuilderCreateVectorType(Builder: DIBuilderRef,
1459 Subscripts: DIArray)
1462 pub fn LLVMRustDIBuilderGetOrCreateSubrange(Builder: DIBuilderRef,
1467 pub fn LLVMRustDIBuilderGetOrCreateArray(Builder: DIBuilderRef,
1468 Ptr: *const DIDescriptor,
1472 pub fn LLVMRustDIBuilderInsertDeclareAtEnd(Builder: DIBuilderRef,
1474 VarInfo: DIVariable,
1475 AddrOps: *const i64,
1476 AddrOpsCount: c_uint,
1478 InsertAtEnd: BasicBlockRef)
1481 pub fn LLVMRustDIBuilderCreateEnumerator(Builder: DIBuilderRef,
1482 Name: *const c_char,
1486 pub fn LLVMRustDIBuilderCreateEnumerationType(Builder: DIBuilderRef,
1488 Name: *const c_char,
1497 pub fn LLVMRustDIBuilderCreateUnionType(Builder: DIBuilderRef,
1499 Name: *const c_char,
1506 RunTimeLang: c_uint,
1507 UniqueId: *const c_char)
1510 pub fn LLVMSetUnnamedAddr(GlobalVar: ValueRef, UnnamedAddr: Bool);
1512 pub fn LLVMRustDIBuilderCreateTemplateTypeParameter(Builder: DIBuilderRef,
1514 Name: *const c_char,
1519 -> DITemplateTypeParameter;
1522 pub fn LLVMRustDIBuilderCreateNameSpace(Builder: DIBuilderRef,
1524 Name: *const c_char,
1528 pub fn LLVMRustDICompositeTypeSetTypeArray(Builder: DIBuilderRef,
1529 CompositeType: DIType,
1530 TypeArray: DIArray);
1533 pub fn LLVMRustDIBuilderCreateDebugLocation(Context: ContextRef,
1537 InlinedAt: MetadataRef)
1539 pub fn LLVMRustDIBuilderCreateOpDeref() -> i64;
1540 pub fn LLVMRustDIBuilderCreateOpPlus() -> i64;
1542 pub fn LLVMRustWriteTypeToString(Type: TypeRef, s: RustStringRef);
1543 pub fn LLVMRustWriteValueToString(value_ref: ValueRef, s: RustStringRef);
1545 pub fn LLVMIsAConstantInt(value_ref: ValueRef) -> ValueRef;
1547 pub fn LLVMRustPassKind(Pass: PassRef) -> PassKind;
1548 pub fn LLVMRustFindAndCreatePass(Pass: *const c_char) -> PassRef;
1549 pub fn LLVMRustAddPass(PM: PassManagerRef, Pass: PassRef);
1551 pub fn LLVMRustHasFeature(T: TargetMachineRef, s: *const c_char) -> bool;
1553 pub fn LLVMRustPrintTargetCPUs(T: TargetMachineRef);
1554 pub fn LLVMRustPrintTargetFeatures(T: TargetMachineRef);
1556 pub fn LLVMRustCreateTargetMachine(Triple: *const c_char,
1558 Features: *const c_char,
1561 Level: CodeGenOptLevel,
1563 PositionIndependentExecutable: bool,
1564 FunctionSections: bool,
1566 -> TargetMachineRef;
1567 pub fn LLVMRustDisposeTargetMachine(T: TargetMachineRef);
1568 pub fn LLVMRustAddAnalysisPasses(T: TargetMachineRef, PM: PassManagerRef, M: ModuleRef);
1569 pub fn LLVMRustAddBuilderLibraryInfo(PMB: PassManagerBuilderRef,
1571 DisableSimplifyLibCalls: bool);
1572 pub fn LLVMRustConfigurePassManagerBuilder(PMB: PassManagerBuilderRef,
1573 OptLevel: CodeGenOptLevel,
1574 MergeFunctions: bool,
1576 LoopVectorize: bool);
1577 pub fn LLVMRustAddLibraryInfo(PM: PassManagerRef,
1579 DisableSimplifyLibCalls: bool);
1580 pub fn LLVMRustRunFunctionPassManager(PM: PassManagerRef, M: ModuleRef);
1581 pub fn LLVMRustWriteOutputFile(T: TargetMachineRef,
1584 Output: *const c_char,
1587 pub fn LLVMRustPrintModule(PM: PassManagerRef, M: ModuleRef, Output: *const c_char);
1588 pub fn LLVMRustSetLLVMOptions(Argc: c_int, Argv: *const *const c_char);
1589 pub fn LLVMRustPrintPasses();
1590 pub fn LLVMRustSetNormalizedTarget(M: ModuleRef, triple: *const c_char);
1591 pub fn LLVMRustAddAlwaysInlinePass(P: PassManagerBuilderRef, AddLifetimes: bool);
1592 pub fn LLVMRustLinkInExternalBitcode(M: ModuleRef, bc: *const c_char, len: size_t) -> bool;
1593 pub fn LLVMRustRunRestrictionPass(M: ModuleRef, syms: *const *const c_char, len: size_t);
1594 pub fn LLVMRustMarkAllFunctionsNounwind(M: ModuleRef);
1596 pub fn LLVMRustOpenArchive(path: *const c_char) -> ArchiveRef;
1597 pub fn LLVMRustArchiveIteratorNew(AR: ArchiveRef) -> ArchiveIteratorRef;
1598 pub fn LLVMRustArchiveIteratorNext(AIR: ArchiveIteratorRef) -> ArchiveChildRef;
1599 pub fn LLVMRustArchiveChildName(ACR: ArchiveChildRef, size: *mut size_t) -> *const c_char;
1600 pub fn LLVMRustArchiveChildData(ACR: ArchiveChildRef, size: *mut size_t) -> *const c_char;
1601 pub fn LLVMRustArchiveChildFree(ACR: ArchiveChildRef);
1602 pub fn LLVMRustArchiveIteratorFree(AIR: ArchiveIteratorRef);
1603 pub fn LLVMRustDestroyArchive(AR: ArchiveRef);
1605 pub fn LLVMRustGetSectionName(SI: SectionIteratorRef, data: *mut *const c_char) -> size_t;
1607 pub fn LLVMRustWriteTwineToString(T: TwineRef, s: RustStringRef);
1609 pub fn LLVMContextSetDiagnosticHandler(C: ContextRef,
1610 Handler: DiagnosticHandler,
1611 DiagnosticContext: *mut c_void);
1613 pub fn LLVMRustUnpackOptimizationDiagnostic(DI: DiagnosticInfoRef,
1614 pass_name_out: RustStringRef,
1615 function_out: *mut ValueRef,
1616 debugloc_out: *mut DebugLocRef,
1617 message_out: RustStringRef);
1618 pub fn LLVMRustUnpackInlineAsmDiagnostic(DI: DiagnosticInfoRef,
1619 cookie_out: *mut c_uint,
1620 message_out: *mut TwineRef,
1621 instruction_out: *mut ValueRef);
1623 pub fn LLVMRustWriteDiagnosticInfoToString(DI: DiagnosticInfoRef, s: RustStringRef);
1624 pub fn LLVMRustGetDiagInfoKind(DI: DiagnosticInfoRef) -> DiagnosticKind;
1626 pub fn LLVMRustWriteDebugLocToString(C: ContextRef, DL: DebugLocRef, s: RustStringRef);
1628 pub fn LLVMRustSetInlineAsmDiagnosticHandler(C: ContextRef,
1629 H: InlineAsmDiagHandler,
1632 pub fn LLVMRustWriteSMDiagnosticToString(d: SMDiagnosticRef, s: RustStringRef);
1634 pub fn LLVMRustWriteArchive(Dst: *const c_char,
1636 Members: *const RustArchiveMemberRef,
1640 pub fn LLVMRustArchiveMemberNew(Filename: *const c_char,
1641 Name: *const c_char,
1642 Child: ArchiveChildRef)
1643 -> RustArchiveMemberRef;
1644 pub fn LLVMRustArchiveMemberFree(Member: RustArchiveMemberRef);
1646 pub fn LLVMRustSetDataLayoutFromTargetMachine(M: ModuleRef, TM: TargetMachineRef);
1647 pub fn LLVMRustGetModuleDataLayout(M: ModuleRef) -> TargetDataRef;
1649 pub fn LLVMRustBuildOperandBundleDef(Name: *const c_char,
1650 Inputs: *const ValueRef,
1652 -> OperandBundleDefRef;
1653 pub fn LLVMRustFreeOperandBundleDef(Bundle: OperandBundleDefRef);
1655 pub fn LLVMRustPositionBuilderAtStart(B: BuilderRef, BB: BasicBlockRef);
1657 pub fn LLVMRustSetComdat(M: ModuleRef, V: ValueRef, Name: *const c_char);
1658 pub fn LLVMRustUnsetComdat(V: ValueRef);
1659 pub fn LLVMRustSetModulePIELevel(M: ModuleRef);
1663 // LLVM requires symbols from this library, but apparently they're not printed
1664 // during llvm-config?
1666 #[link(name = "ole32")]