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, DIFile, DILexicalBlock, DISubprogram, DIType,
12 DIBasicType, DIDerivedType, DICompositeType, DIScope, DIVariable,
13 DIGlobalVariable, DIArray, DISubrange, DITemplateTypeParameter, DIEnumerator,
14 DINameSpace, DIFlags};
16 use libc::{c_uint, c_int, size_t, c_char};
17 use libc::{c_longlong, c_ulonglong, c_void};
21 pub type Opcode = u32;
22 pub type Bool = c_uint;
24 pub const True: Bool = 1 as Bool;
25 pub const False: Bool = 0 as Bool;
27 #[derive(Copy, Clone, PartialEq)]
29 pub enum LLVMRustResult {
33 // Consts for the LLVM CallConv type, pre-cast to usize.
35 /// LLVM CallingConv::ID. Should we wrap this?
36 #[derive(Copy, Clone, PartialEq, Debug)]
42 X86StdcallCallConv = 64,
43 X86FastcallCallConv = 65,
44 ArmAapcsCallConv = 67,
53 #[derive(Copy, Clone, PartialEq, Eq, Hash, Debug)]
57 AvailableExternallyLinkage = 1,
58 LinkOnceAnyLinkage = 2,
59 LinkOnceODRLinkage = 3,
65 ExternalWeakLinkage = 9,
70 #[derive(Copy, Clone, PartialEq, Eq, Hash, Debug)]
78 /// LLVMDiagnosticSeverity
79 #[derive(Copy, Clone, Debug)]
81 pub enum DiagnosticSeverity {
88 /// LLVMDLLStorageClass
89 #[derive(Copy, Clone)]
91 pub enum DLLStorageClass {
93 DllImport = 1, // Function to be imported from DLL.
94 DllExport = 2, // Function to be accessible from DLL.
97 /// Matches LLVMRustAttribute in rustllvm.h
98 /// Semantically a subset of the C++ enum llvm::Attribute::AttrKind,
99 /// though it is not ABI compatible (since it's a C++ enum)
101 #[derive(Copy, Clone, Debug)]
116 OptimizeForSize = 13,
126 #[derive(Copy, Clone)]
128 pub enum IntPredicate {
141 /// LLVMRealPredicate
142 #[derive(Copy, Clone)]
144 pub enum RealPredicate {
145 RealPredicateFalse = 0,
160 RealPredicateTrue = 15,
164 #[derive(Copy, Clone, PartialEq, Debug)]
186 /// LLVMAtomicRmwBinOp
187 #[derive(Copy, Clone)]
189 pub enum AtomicRmwBinOp {
203 /// LLVMAtomicOrdering
204 #[derive(Copy, Clone)]
206 pub enum AtomicOrdering {
210 // Consume = 3, // Not specified yet.
214 SequentiallyConsistent = 7,
217 /// LLVMRustSynchronizationScope
218 #[derive(Copy, Clone)]
220 pub enum SynchronizationScope {
227 #[derive(Copy, Clone)]
236 #[derive(Copy, Clone)]
238 pub enum MetadataType {
245 MD_invariant_load = 6,
249 MD_mem_parallel_loop_access = 10,
253 /// LLVMRustAsmDialect
254 #[derive(Copy, Clone)]
256 pub enum AsmDialect {
262 /// LLVMRustCodeGenOptLevel
263 #[derive(Copy, Clone, PartialEq)]
265 pub enum CodeGenOptLevel {
274 #[derive(Copy, Clone, PartialEq)]
283 /// LLVMRustCodeModel
284 #[derive(Copy, Clone)]
296 /// LLVMRustDiagnosticKind
297 #[derive(Copy, Clone)]
299 pub enum DiagnosticKind {
303 DebugMetadataVersion,
306 OptimizationRemarkMissed,
307 OptimizationRemarkAnalysis,
308 OptimizationRemarkAnalysisFPCommute,
309 OptimizationRemarkAnalysisAliasing,
310 OptimizationRemarkOther,
314 /// LLVMRustArchiveKind
315 #[derive(Copy, Clone)]
317 pub enum ArchiveKind {
326 #[derive(Copy, Clone, PartialEq, Debug)]
334 // Opaque pointer types
335 #[allow(missing_copy_implementations)]
336 pub enum Module_opaque {}
337 pub type ModuleRef = *mut Module_opaque;
338 #[allow(missing_copy_implementations)]
339 pub enum Context_opaque {}
340 pub type ContextRef = *mut Context_opaque;
341 #[allow(missing_copy_implementations)]
342 pub enum Type_opaque {}
343 pub type TypeRef = *mut Type_opaque;
344 #[allow(missing_copy_implementations)]
345 pub enum Value_opaque {}
346 pub type ValueRef = *mut Value_opaque;
347 #[allow(missing_copy_implementations)]
348 pub enum Metadata_opaque {}
349 pub type MetadataRef = *mut Metadata_opaque;
350 #[allow(missing_copy_implementations)]
351 pub enum BasicBlock_opaque {}
352 pub type BasicBlockRef = *mut BasicBlock_opaque;
353 #[allow(missing_copy_implementations)]
354 pub enum Builder_opaque {}
355 pub type BuilderRef = *mut Builder_opaque;
356 #[allow(missing_copy_implementations)]
357 pub enum ExecutionEngine_opaque {}
358 pub type ExecutionEngineRef = *mut ExecutionEngine_opaque;
359 #[allow(missing_copy_implementations)]
360 pub enum MemoryBuffer_opaque {}
361 pub type MemoryBufferRef = *mut MemoryBuffer_opaque;
362 #[allow(missing_copy_implementations)]
363 pub enum PassManager_opaque {}
364 pub type PassManagerRef = *mut PassManager_opaque;
365 #[allow(missing_copy_implementations)]
366 pub enum PassManagerBuilder_opaque {}
367 pub type PassManagerBuilderRef = *mut PassManagerBuilder_opaque;
368 #[allow(missing_copy_implementations)]
369 pub enum Use_opaque {}
370 pub type UseRef = *mut Use_opaque;
371 #[allow(missing_copy_implementations)]
372 pub enum TargetData_opaque {}
373 pub type TargetDataRef = *mut TargetData_opaque;
374 #[allow(missing_copy_implementations)]
375 pub enum ObjectFile_opaque {}
376 pub type ObjectFileRef = *mut ObjectFile_opaque;
377 #[allow(missing_copy_implementations)]
378 pub enum SectionIterator_opaque {}
379 pub type SectionIteratorRef = *mut SectionIterator_opaque;
380 #[allow(missing_copy_implementations)]
381 pub enum Pass_opaque {}
382 pub type PassRef = *mut Pass_opaque;
383 #[allow(missing_copy_implementations)]
384 pub enum TargetMachine_opaque {}
385 pub type TargetMachineRef = *mut TargetMachine_opaque;
386 pub enum Archive_opaque {}
387 pub type ArchiveRef = *mut Archive_opaque;
388 pub enum ArchiveIterator_opaque {}
389 pub type ArchiveIteratorRef = *mut ArchiveIterator_opaque;
390 pub enum ArchiveChild_opaque {}
391 pub type ArchiveChildRef = *mut ArchiveChild_opaque;
392 #[allow(missing_copy_implementations)]
393 pub enum Twine_opaque {}
394 pub type TwineRef = *mut Twine_opaque;
395 #[allow(missing_copy_implementations)]
396 pub enum DiagnosticInfo_opaque {}
397 pub type DiagnosticInfoRef = *mut DiagnosticInfo_opaque;
398 #[allow(missing_copy_implementations)]
399 pub enum DebugLoc_opaque {}
400 pub type DebugLocRef = *mut DebugLoc_opaque;
401 #[allow(missing_copy_implementations)]
402 pub enum SMDiagnostic_opaque {}
403 pub type SMDiagnosticRef = *mut SMDiagnostic_opaque;
404 #[allow(missing_copy_implementations)]
405 pub enum RustArchiveMember_opaque {}
406 pub type RustArchiveMemberRef = *mut RustArchiveMember_opaque;
407 #[allow(missing_copy_implementations)]
408 pub enum OperandBundleDef_opaque {}
409 pub type OperandBundleDefRef = *mut OperandBundleDef_opaque;
411 pub type DiagnosticHandler = unsafe extern "C" fn(DiagnosticInfoRef, *mut c_void);
412 pub type InlineAsmDiagHandler = unsafe extern "C" fn(SMDiagnosticRef, *const c_void, c_uint);
416 use super::MetadataRef;
418 #[allow(missing_copy_implementations)]
419 pub enum DIBuilder_opaque {}
420 pub type DIBuilderRef = *mut DIBuilder_opaque;
422 pub type DIDescriptor = MetadataRef;
423 pub type DIScope = DIDescriptor;
424 pub type DILocation = DIDescriptor;
425 pub type DIFile = DIScope;
426 pub type DILexicalBlock = DIScope;
427 pub type DISubprogram = DIScope;
428 pub type DINameSpace = DIScope;
429 pub type DIType = DIDescriptor;
430 pub type DIBasicType = DIType;
431 pub type DIDerivedType = DIType;
432 pub type DICompositeType = DIDerivedType;
433 pub type DIVariable = DIDescriptor;
434 pub type DIGlobalVariable = DIDescriptor;
435 pub type DIArray = DIDescriptor;
436 pub type DISubrange = DIDescriptor;
437 pub type DIEnumerator = DIDescriptor;
438 pub type DITemplateTypeParameter = DIDescriptor;
440 // These values **must** match with LLVMRustDIFlags!!
443 #[derive(Debug, Default)]
444 flags DIFlags: ::libc::uint32_t {
446 const FlagPrivate = 1,
447 const FlagProtected = 2,
448 const FlagPublic = 3,
449 const FlagFwdDecl = (1 << 2),
450 const FlagAppleBlock = (1 << 3),
451 const FlagBlockByrefStruct = (1 << 4),
452 const FlagVirtual = (1 << 5),
453 const FlagArtificial = (1 << 6),
454 const FlagExplicit = (1 << 7),
455 const FlagPrototyped = (1 << 8),
456 const FlagObjcClassComplete = (1 << 9),
457 const FlagObjectPointer = (1 << 10),
458 const FlagVector = (1 << 11),
459 const FlagStaticMember = (1 << 12),
460 const FlagLValueReference = (1 << 13),
461 const FlagRValueReference = (1 << 14),
467 // Link to our native llvm bindings (things that we need to use the C++ api
468 // for) and because llvm is written in C++ we need to link against libstdc++
470 // You'll probably notice that there is an omission of all LLVM libraries
471 // from this location. This is because the set of LLVM libraries that we
472 // link to is mostly defined by LLVM, and the `llvm-config` tool is used to
473 // figure out the exact set of libraries. To do this, the build system
474 // generates an llvmdeps.rs file next to this one which will be
475 // automatically updated whenever LLVM is updated to include an up-to-date
476 // set of the libraries we need to link to LLVM for.
477 #[link(name = "rustllvm", kind = "static")] // not quite true but good enough
479 // Create and destroy contexts.
480 pub fn LLVMContextCreate() -> ContextRef;
481 pub fn LLVMContextDispose(C: ContextRef);
482 pub fn LLVMGetMDKindIDInContext(C: ContextRef, Name: *const c_char, SLen: c_uint) -> c_uint;
484 // Create and destroy modules.
485 pub fn LLVMModuleCreateWithNameInContext(ModuleID: *const c_char, C: ContextRef) -> ModuleRef;
486 pub fn LLVMGetModuleContext(M: ModuleRef) -> ContextRef;
487 pub fn LLVMCloneModule(M: ModuleRef) -> ModuleRef;
488 pub fn LLVMDisposeModule(M: ModuleRef);
490 /// Data layout. See Module::getDataLayout.
491 pub fn LLVMGetDataLayout(M: ModuleRef) -> *const c_char;
492 pub fn LLVMSetDataLayout(M: ModuleRef, Triple: *const c_char);
494 /// See Module::dump.
495 pub fn LLVMDumpModule(M: ModuleRef);
497 /// See Module::setModuleInlineAsm.
498 pub fn LLVMSetModuleInlineAsm(M: ModuleRef, Asm: *const c_char);
500 /// See llvm::LLVMTypeKind::getTypeID.
501 pub fn LLVMRustGetTypeKind(Ty: TypeRef) -> TypeKind;
503 /// See llvm::Value::getContext
504 pub fn LLVMRustGetValueContext(V: ValueRef) -> ContextRef;
506 // Operations on integer types
507 pub fn LLVMInt1TypeInContext(C: ContextRef) -> TypeRef;
508 pub fn LLVMInt8TypeInContext(C: ContextRef) -> TypeRef;
509 pub fn LLVMInt16TypeInContext(C: ContextRef) -> TypeRef;
510 pub fn LLVMInt32TypeInContext(C: ContextRef) -> TypeRef;
511 pub fn LLVMInt64TypeInContext(C: ContextRef) -> TypeRef;
512 pub fn LLVMIntTypeInContext(C: ContextRef, NumBits: c_uint) -> TypeRef;
514 pub fn LLVMGetIntTypeWidth(IntegerTy: TypeRef) -> c_uint;
516 // Operations on real types
517 pub fn LLVMFloatTypeInContext(C: ContextRef) -> TypeRef;
518 pub fn LLVMDoubleTypeInContext(C: ContextRef) -> TypeRef;
520 // Operations on function types
521 pub fn LLVMFunctionType(ReturnType: TypeRef,
522 ParamTypes: *const TypeRef,
526 pub fn LLVMGetReturnType(FunctionTy: TypeRef) -> TypeRef;
527 pub fn LLVMCountParamTypes(FunctionTy: TypeRef) -> c_uint;
528 pub fn LLVMGetParamTypes(FunctionTy: TypeRef, Dest: *mut TypeRef);
530 // Operations on struct types
531 pub fn LLVMStructTypeInContext(C: ContextRef,
532 ElementTypes: *const TypeRef,
533 ElementCount: c_uint,
536 pub fn LLVMCountStructElementTypes(StructTy: TypeRef) -> c_uint;
537 pub fn LLVMGetStructElementTypes(StructTy: TypeRef, Dest: *mut TypeRef);
538 pub fn LLVMIsPackedStruct(StructTy: TypeRef) -> Bool;
540 // Operations on array, pointer, and vector types (sequence types)
541 pub fn LLVMRustArrayType(ElementType: TypeRef, ElementCount: u64) -> TypeRef;
542 pub fn LLVMPointerType(ElementType: TypeRef, AddressSpace: c_uint) -> TypeRef;
543 pub fn LLVMVectorType(ElementType: TypeRef, ElementCount: c_uint) -> TypeRef;
545 pub fn LLVMGetElementType(Ty: TypeRef) -> TypeRef;
546 pub fn LLVMGetArrayLength(ArrayTy: TypeRef) -> c_uint;
547 pub fn LLVMGetVectorSize(VectorTy: TypeRef) -> c_uint;
549 // Operations on other types
550 pub fn LLVMVoidTypeInContext(C: ContextRef) -> TypeRef;
551 pub fn LLVMRustMetadataTypeInContext(C: ContextRef) -> TypeRef;
553 // Operations on all values
554 pub fn LLVMTypeOf(Val: ValueRef) -> TypeRef;
555 pub fn LLVMGetValueName(Val: ValueRef) -> *const c_char;
556 pub fn LLVMSetValueName(Val: ValueRef, Name: *const c_char);
557 pub fn LLVMReplaceAllUsesWith(OldVal: ValueRef, NewVal: ValueRef);
558 pub fn LLVMSetMetadata(Val: ValueRef, KindID: c_uint, Node: ValueRef);
560 // Operations on Uses
561 pub fn LLVMGetFirstUse(Val: ValueRef) -> UseRef;
562 pub fn LLVMGetNextUse(U: UseRef) -> UseRef;
563 pub fn LLVMGetUser(U: UseRef) -> ValueRef;
565 // Operations on Users
566 pub fn LLVMGetOperand(Val: ValueRef, Index: c_uint) -> ValueRef;
568 // Operations on constants of any type
569 pub fn LLVMConstNull(Ty: TypeRef) -> ValueRef;
570 pub fn LLVMConstICmp(Pred: IntPredicate, V1: ValueRef, V2: ValueRef) -> ValueRef;
571 pub fn LLVMConstFCmp(Pred: RealPredicate, V1: ValueRef, V2: ValueRef) -> ValueRef;
572 // only for isize/vector
573 pub fn LLVMGetUndef(Ty: TypeRef) -> ValueRef;
574 pub fn LLVMIsNull(Val: ValueRef) -> Bool;
575 pub fn LLVMIsUndef(Val: ValueRef) -> Bool;
577 // Operations on metadata
578 pub fn LLVMMDNodeInContext(C: ContextRef, Vals: *const ValueRef, Count: c_uint) -> ValueRef;
580 // Operations on scalar constants
581 pub fn LLVMConstInt(IntTy: TypeRef, N: c_ulonglong, SignExtend: Bool) -> ValueRef;
582 pub fn LLVMConstIntOfArbitraryPrecision(IntTy: TypeRef, Wn: c_uint, Ws: *const u64) -> ValueRef;
583 pub fn LLVMConstReal(RealTy: TypeRef, N: f64) -> ValueRef;
584 pub fn LLVMConstIntGetZExtValue(ConstantVal: ValueRef) -> c_ulonglong;
585 pub fn LLVMConstIntGetSExtValue(ConstantVal: ValueRef) -> c_longlong;
586 pub fn LLVMRustConstInt128Get(ConstantVal: ValueRef, SExt: bool,
587 high: *mut u64, low: *mut u64) -> bool;
590 // Operations on composite constants
591 pub fn LLVMConstStringInContext(C: ContextRef,
594 DontNullTerminate: Bool)
596 pub fn LLVMConstStructInContext(C: ContextRef,
597 ConstantVals: *const ValueRef,
602 pub fn LLVMConstArray(ElementTy: TypeRef,
603 ConstantVals: *const ValueRef,
606 pub fn LLVMConstVector(ScalarConstantVals: *const ValueRef, Size: c_uint) -> ValueRef;
608 // Constant expressions
609 pub fn LLVMSizeOf(Ty: TypeRef) -> ValueRef;
610 pub fn LLVMConstNeg(ConstantVal: ValueRef) -> ValueRef;
611 pub fn LLVMConstFNeg(ConstantVal: ValueRef) -> ValueRef;
612 pub fn LLVMConstNot(ConstantVal: ValueRef) -> ValueRef;
613 pub fn LLVMConstAdd(LHSConstant: ValueRef, RHSConstant: ValueRef) -> ValueRef;
614 pub fn LLVMConstFAdd(LHSConstant: ValueRef, RHSConstant: ValueRef) -> ValueRef;
615 pub fn LLVMConstSub(LHSConstant: ValueRef, RHSConstant: ValueRef) -> ValueRef;
616 pub fn LLVMConstFSub(LHSConstant: ValueRef, RHSConstant: ValueRef) -> ValueRef;
617 pub fn LLVMConstMul(LHSConstant: ValueRef, RHSConstant: ValueRef) -> ValueRef;
618 pub fn LLVMConstFMul(LHSConstant: ValueRef, RHSConstant: ValueRef) -> ValueRef;
619 pub fn LLVMConstUDiv(LHSConstant: ValueRef, RHSConstant: ValueRef) -> ValueRef;
620 pub fn LLVMConstSDiv(LHSConstant: ValueRef, RHSConstant: ValueRef) -> ValueRef;
621 pub fn LLVMConstFDiv(LHSConstant: ValueRef, RHSConstant: ValueRef) -> ValueRef;
622 pub fn LLVMConstURem(LHSConstant: ValueRef, RHSConstant: ValueRef) -> ValueRef;
623 pub fn LLVMConstSRem(LHSConstant: ValueRef, RHSConstant: ValueRef) -> ValueRef;
624 pub fn LLVMConstFRem(LHSConstant: ValueRef, RHSConstant: ValueRef) -> ValueRef;
625 pub fn LLVMConstAnd(LHSConstant: ValueRef, RHSConstant: ValueRef) -> ValueRef;
626 pub fn LLVMConstOr(LHSConstant: ValueRef, RHSConstant: ValueRef) -> ValueRef;
627 pub fn LLVMConstXor(LHSConstant: ValueRef, RHSConstant: ValueRef) -> ValueRef;
628 pub fn LLVMConstShl(LHSConstant: ValueRef, RHSConstant: ValueRef) -> ValueRef;
629 pub fn LLVMConstLShr(LHSConstant: ValueRef, RHSConstant: ValueRef) -> ValueRef;
630 pub fn LLVMConstAShr(LHSConstant: ValueRef, RHSConstant: ValueRef) -> ValueRef;
631 pub fn LLVMConstTrunc(ConstantVal: ValueRef, ToType: TypeRef) -> ValueRef;
632 pub fn LLVMConstZExt(ConstantVal: ValueRef, ToType: TypeRef) -> ValueRef;
633 pub fn LLVMConstUIToFP(ConstantVal: ValueRef, ToType: TypeRef) -> ValueRef;
634 pub fn LLVMConstSIToFP(ConstantVal: ValueRef, ToType: TypeRef) -> ValueRef;
635 pub fn LLVMConstFPToUI(ConstantVal: ValueRef, ToType: TypeRef) -> ValueRef;
636 pub fn LLVMConstFPToSI(ConstantVal: ValueRef, ToType: TypeRef) -> ValueRef;
637 pub fn LLVMConstPtrToInt(ConstantVal: ValueRef, ToType: TypeRef) -> ValueRef;
638 pub fn LLVMConstIntToPtr(ConstantVal: ValueRef, ToType: TypeRef) -> ValueRef;
639 pub fn LLVMConstBitCast(ConstantVal: ValueRef, ToType: TypeRef) -> ValueRef;
640 pub fn LLVMConstPointerCast(ConstantVal: ValueRef, ToType: TypeRef) -> ValueRef;
641 pub fn LLVMConstIntCast(ConstantVal: ValueRef, ToType: TypeRef, isSigned: Bool) -> ValueRef;
642 pub fn LLVMConstFPCast(ConstantVal: ValueRef, ToType: TypeRef) -> ValueRef;
643 pub fn LLVMConstExtractValue(AggConstant: ValueRef,
644 IdxList: *const c_uint,
647 pub fn LLVMConstInlineAsm(Ty: TypeRef,
648 AsmString: *const c_char,
649 Constraints: *const c_char,
650 HasSideEffects: Bool,
655 // Operations on global variables, functions, and aliases (globals)
656 pub fn LLVMGetGlobalParent(Global: ValueRef) -> ModuleRef;
657 pub fn LLVMIsDeclaration(Global: ValueRef) -> Bool;
658 pub fn LLVMRustGetLinkage(Global: ValueRef) -> Linkage;
659 pub fn LLVMRustSetLinkage(Global: ValueRef, RustLinkage: Linkage);
660 pub fn LLVMGetSection(Global: ValueRef) -> *const c_char;
661 pub fn LLVMSetSection(Global: ValueRef, Section: *const c_char);
662 pub fn LLVMRustGetVisibility(Global: ValueRef) -> Visibility;
663 pub fn LLVMRustSetVisibility(Global: ValueRef, Viz: Visibility);
664 pub fn LLVMGetAlignment(Global: ValueRef) -> c_uint;
665 pub fn LLVMSetAlignment(Global: ValueRef, Bytes: c_uint);
666 pub fn LLVMSetDLLStorageClass(V: ValueRef, C: DLLStorageClass);
669 // Operations on global variables
670 pub fn LLVMIsAGlobalVariable(GlobalVar: ValueRef) -> ValueRef;
671 pub fn LLVMAddGlobal(M: ModuleRef, Ty: TypeRef, Name: *const c_char) -> ValueRef;
672 pub fn LLVMGetNamedGlobal(M: ModuleRef, Name: *const c_char) -> ValueRef;
673 pub fn LLVMRustGetOrInsertGlobal(M: ModuleRef, Name: *const c_char, T: TypeRef) -> ValueRef;
674 pub fn LLVMGetFirstGlobal(M: ModuleRef) -> ValueRef;
675 pub fn LLVMGetNextGlobal(GlobalVar: ValueRef) -> ValueRef;
676 pub fn LLVMDeleteGlobal(GlobalVar: ValueRef);
677 pub fn LLVMGetInitializer(GlobalVar: ValueRef) -> ValueRef;
678 pub fn LLVMSetInitializer(GlobalVar: ValueRef, ConstantVal: ValueRef);
679 pub fn LLVMSetThreadLocal(GlobalVar: ValueRef, IsThreadLocal: Bool);
680 pub fn LLVMIsGlobalConstant(GlobalVar: ValueRef) -> Bool;
681 pub fn LLVMSetGlobalConstant(GlobalVar: ValueRef, IsConstant: Bool);
682 pub fn LLVMRustGetNamedValue(M: ModuleRef, Name: *const c_char) -> ValueRef;
684 // Operations on functions
685 pub fn LLVMAddFunction(M: ModuleRef, Name: *const c_char, FunctionTy: TypeRef) -> ValueRef;
686 pub fn LLVMGetNamedFunction(M: ModuleRef, Name: *const c_char) -> ValueRef;
687 pub fn LLVMGetFirstFunction(M: ModuleRef) -> ValueRef;
688 pub fn LLVMGetNextFunction(Fn: ValueRef) -> ValueRef;
689 pub fn LLVMRustGetOrInsertFunction(M: ModuleRef,
693 pub fn LLVMSetFunctionCallConv(Fn: ValueRef, CC: c_uint);
694 pub fn LLVMRustAddDereferenceableAttr(Fn: ValueRef, index: c_uint, bytes: u64);
695 pub fn LLVMRustAddFunctionAttribute(Fn: ValueRef, index: c_uint, attr: Attribute);
696 pub fn LLVMRustAddFunctionAttrStringValue(Fn: ValueRef,
699 Value: *const c_char);
700 pub fn LLVMRustRemoveFunctionAttributes(Fn: ValueRef, index: c_uint, attr: Attribute);
702 // Operations on parameters
703 pub fn LLVMCountParams(Fn: ValueRef) -> c_uint;
704 pub fn LLVMGetParam(Fn: ValueRef, Index: c_uint) -> ValueRef;
706 // Operations on basic blocks
707 pub fn LLVMBasicBlockAsValue(BB: BasicBlockRef) -> ValueRef;
708 pub fn LLVMGetBasicBlockParent(BB: BasicBlockRef) -> ValueRef;
709 pub fn LLVMAppendBasicBlockInContext(C: ContextRef,
713 pub fn LLVMDeleteBasicBlock(BB: BasicBlockRef);
715 // Operations on instructions
716 pub fn LLVMGetInstructionParent(Inst: ValueRef) -> BasicBlockRef;
717 pub fn LLVMGetFirstBasicBlock(Fn: ValueRef) -> BasicBlockRef;
718 pub fn LLVMGetFirstInstruction(BB: BasicBlockRef) -> ValueRef;
719 pub fn LLVMInstructionEraseFromParent(Inst: ValueRef);
721 // Operations on call sites
722 pub fn LLVMSetInstructionCallConv(Instr: ValueRef, CC: c_uint);
723 pub fn LLVMRustAddCallSiteAttribute(Instr: ValueRef, index: c_uint, attr: Attribute);
724 pub fn LLVMRustAddDereferenceableCallSiteAttr(Instr: ValueRef, index: c_uint, bytes: u64);
726 // Operations on load/store instructions (only)
727 pub fn LLVMSetVolatile(MemoryAccessInst: ValueRef, volatile: Bool);
729 // Operations on phi nodes
730 pub fn LLVMAddIncoming(PhiNode: ValueRef,
731 IncomingValues: *const ValueRef,
732 IncomingBlocks: *const BasicBlockRef,
735 // Instruction builders
736 pub fn LLVMCreateBuilderInContext(C: ContextRef) -> BuilderRef;
737 pub fn LLVMPositionBuilder(Builder: BuilderRef, Block: BasicBlockRef, Instr: ValueRef);
738 pub fn LLVMPositionBuilderBefore(Builder: BuilderRef, Instr: ValueRef);
739 pub fn LLVMPositionBuilderAtEnd(Builder: BuilderRef, Block: BasicBlockRef);
740 pub fn LLVMGetInsertBlock(Builder: BuilderRef) -> BasicBlockRef;
741 pub fn LLVMDisposeBuilder(Builder: BuilderRef);
744 pub fn LLVMSetCurrentDebugLocation(Builder: BuilderRef, L: ValueRef);
745 pub fn LLVMGetCurrentDebugLocation(Builder: BuilderRef) -> ValueRef;
746 pub fn LLVMSetInstDebugLocation(Builder: BuilderRef, Inst: ValueRef);
749 pub fn LLVMBuildRetVoid(B: BuilderRef) -> ValueRef;
750 pub fn LLVMBuildRet(B: BuilderRef, V: ValueRef) -> ValueRef;
751 pub fn LLVMBuildAggregateRet(B: BuilderRef, RetVals: *const ValueRef, N: c_uint) -> ValueRef;
752 pub fn LLVMBuildBr(B: BuilderRef, Dest: BasicBlockRef) -> ValueRef;
753 pub fn LLVMBuildCondBr(B: BuilderRef,
758 pub fn LLVMBuildSwitch(B: BuilderRef,
763 pub fn LLVMBuildIndirectBr(B: BuilderRef, Addr: ValueRef, NumDests: c_uint) -> ValueRef;
764 pub fn LLVMRustBuildInvoke(B: BuilderRef,
766 Args: *const ValueRef,
769 Catch: BasicBlockRef,
770 Bundle: OperandBundleDefRef,
773 pub fn LLVMRustBuildLandingPad(B: BuilderRef,
780 pub fn LLVMBuildResume(B: BuilderRef, Exn: ValueRef) -> ValueRef;
781 pub fn LLVMBuildUnreachable(B: BuilderRef) -> ValueRef;
783 pub fn LLVMRustBuildCleanupPad(B: BuilderRef,
786 Args: *const ValueRef,
789 pub fn LLVMRustBuildCleanupRet(B: BuilderRef,
790 CleanupPad: ValueRef,
791 UnwindBB: BasicBlockRef)
793 pub fn LLVMRustBuildCatchPad(B: BuilderRef,
796 Args: *const ValueRef,
799 pub fn LLVMRustBuildCatchRet(B: BuilderRef, Pad: ValueRef, BB: BasicBlockRef) -> ValueRef;
800 pub fn LLVMRustBuildCatchSwitch(Builder: BuilderRef,
806 pub fn LLVMRustAddHandler(CatchSwitch: ValueRef, Handler: BasicBlockRef);
807 pub fn LLVMSetPersonalityFn(Func: ValueRef, Pers: ValueRef);
809 // Add a case to the switch instruction
810 pub fn LLVMAddCase(Switch: ValueRef, OnVal: ValueRef, Dest: BasicBlockRef);
812 // Add a clause to the landing pad instruction
813 pub fn LLVMAddClause(LandingPad: ValueRef, ClauseVal: ValueRef);
815 // Set the cleanup on a landing pad instruction
816 pub fn LLVMSetCleanup(LandingPad: ValueRef, Val: Bool);
819 pub fn LLVMBuildAdd(B: BuilderRef,
824 pub fn LLVMBuildNSWAdd(B: BuilderRef,
829 pub fn LLVMBuildNUWAdd(B: BuilderRef,
834 pub fn LLVMBuildFAdd(B: BuilderRef,
839 pub fn LLVMBuildSub(B: BuilderRef,
844 pub fn LLVMBuildNSWSub(B: BuilderRef,
849 pub fn LLVMBuildNUWSub(B: BuilderRef,
854 pub fn LLVMBuildFSub(B: BuilderRef,
859 pub fn LLVMBuildMul(B: BuilderRef,
864 pub fn LLVMBuildNSWMul(B: BuilderRef,
869 pub fn LLVMBuildNUWMul(B: BuilderRef,
874 pub fn LLVMBuildFMul(B: BuilderRef,
879 pub fn LLVMBuildUDiv(B: BuilderRef,
884 pub fn LLVMBuildSDiv(B: BuilderRef,
889 pub fn LLVMBuildExactSDiv(B: BuilderRef,
894 pub fn LLVMBuildFDiv(B: BuilderRef,
899 pub fn LLVMBuildURem(B: BuilderRef,
904 pub fn LLVMBuildSRem(B: BuilderRef,
909 pub fn LLVMBuildFRem(B: BuilderRef,
914 pub fn LLVMBuildShl(B: BuilderRef,
919 pub fn LLVMBuildLShr(B: BuilderRef,
924 pub fn LLVMBuildAShr(B: BuilderRef,
929 pub fn LLVMBuildAnd(B: BuilderRef,
934 pub fn LLVMBuildOr(B: BuilderRef,
939 pub fn LLVMBuildXor(B: BuilderRef,
944 pub fn LLVMBuildBinOp(B: BuilderRef,
950 pub fn LLVMBuildNeg(B: BuilderRef, V: ValueRef, Name: *const c_char) -> ValueRef;
951 pub fn LLVMBuildNSWNeg(B: BuilderRef, V: ValueRef, Name: *const c_char) -> ValueRef;
952 pub fn LLVMBuildNUWNeg(B: BuilderRef, V: ValueRef, Name: *const c_char) -> ValueRef;
953 pub fn LLVMBuildFNeg(B: BuilderRef, V: ValueRef, Name: *const c_char) -> ValueRef;
954 pub fn LLVMBuildNot(B: BuilderRef, V: ValueRef, Name: *const c_char) -> ValueRef;
955 pub fn LLVMRustSetHasUnsafeAlgebra(Instr: ValueRef);
958 pub fn LLVMBuildAlloca(B: BuilderRef, Ty: TypeRef, Name: *const c_char) -> ValueRef;
959 pub fn LLVMBuildFree(B: BuilderRef, PointerVal: ValueRef) -> ValueRef;
960 pub fn LLVMBuildLoad(B: BuilderRef, PointerVal: ValueRef, Name: *const c_char) -> ValueRef;
962 pub fn LLVMBuildStore(B: BuilderRef, Val: ValueRef, Ptr: ValueRef) -> ValueRef;
964 pub fn LLVMBuildGEP(B: BuilderRef,
966 Indices: *const ValueRef,
970 pub fn LLVMBuildInBoundsGEP(B: BuilderRef,
972 Indices: *const ValueRef,
976 pub fn LLVMBuildStructGEP(B: BuilderRef,
981 pub fn LLVMBuildGlobalString(B: BuilderRef,
985 pub fn LLVMBuildGlobalStringPtr(B: BuilderRef,
991 pub fn LLVMBuildTrunc(B: BuilderRef,
996 pub fn LLVMBuildZExt(B: BuilderRef,
1001 pub fn LLVMBuildSExt(B: BuilderRef,
1004 Name: *const c_char)
1006 pub fn LLVMBuildFPToUI(B: BuilderRef,
1009 Name: *const c_char)
1011 pub fn LLVMBuildFPToSI(B: BuilderRef,
1014 Name: *const c_char)
1016 pub fn LLVMBuildUIToFP(B: BuilderRef,
1019 Name: *const c_char)
1021 pub fn LLVMBuildSIToFP(B: BuilderRef,
1024 Name: *const c_char)
1026 pub fn LLVMBuildFPTrunc(B: BuilderRef,
1029 Name: *const c_char)
1031 pub fn LLVMBuildFPExt(B: BuilderRef,
1034 Name: *const c_char)
1036 pub fn LLVMBuildPtrToInt(B: BuilderRef,
1039 Name: *const c_char)
1041 pub fn LLVMBuildIntToPtr(B: BuilderRef,
1044 Name: *const c_char)
1046 pub fn LLVMBuildBitCast(B: BuilderRef,
1049 Name: *const c_char)
1051 pub fn LLVMBuildZExtOrBitCast(B: BuilderRef,
1054 Name: *const c_char)
1056 pub fn LLVMBuildSExtOrBitCast(B: BuilderRef,
1059 Name: *const c_char)
1061 pub fn LLVMBuildTruncOrBitCast(B: BuilderRef,
1064 Name: *const c_char)
1066 pub fn LLVMBuildCast(B: BuilderRef,
1070 Name: *const c_char)
1072 pub fn LLVMBuildPointerCast(B: BuilderRef,
1075 Name: *const c_char)
1077 pub fn LLVMBuildIntCast(B: BuilderRef,
1080 Name: *const c_char)
1082 pub fn LLVMBuildFPCast(B: BuilderRef,
1085 Name: *const c_char)
1089 pub fn LLVMBuildICmp(B: BuilderRef,
1093 Name: *const c_char)
1095 pub fn LLVMBuildFCmp(B: BuilderRef,
1099 Name: *const c_char)
1102 // Miscellaneous instructions
1103 pub fn LLVMBuildPhi(B: BuilderRef, Ty: TypeRef, Name: *const c_char) -> ValueRef;
1104 pub fn LLVMRustBuildCall(B: BuilderRef,
1106 Args: *const ValueRef,
1108 Bundle: OperandBundleDefRef,
1109 Name: *const c_char)
1111 pub fn LLVMBuildSelect(B: BuilderRef,
1115 Name: *const c_char)
1117 pub fn LLVMBuildVAArg(B: BuilderRef,
1120 Name: *const c_char)
1122 pub fn LLVMBuildExtractElement(B: BuilderRef,
1125 Name: *const c_char)
1127 pub fn LLVMBuildInsertElement(B: BuilderRef,
1131 Name: *const c_char)
1133 pub fn LLVMBuildShuffleVector(B: BuilderRef,
1137 Name: *const c_char)
1139 pub fn LLVMBuildExtractValue(B: BuilderRef,
1142 Name: *const c_char)
1144 pub fn LLVMBuildInsertValue(B: BuilderRef,
1148 Name: *const c_char)
1151 pub fn LLVMBuildIsNull(B: BuilderRef, Val: ValueRef, Name: *const c_char) -> ValueRef;
1152 pub fn LLVMBuildIsNotNull(B: BuilderRef, Val: ValueRef, Name: *const c_char) -> ValueRef;
1153 pub fn LLVMBuildPtrDiff(B: BuilderRef,
1156 Name: *const c_char)
1159 // Atomic Operations
1160 pub fn LLVMRustBuildAtomicLoad(B: BuilderRef,
1161 PointerVal: ValueRef,
1162 Name: *const c_char,
1163 Order: AtomicOrdering,
1167 pub fn LLVMRustBuildAtomicStore(B: BuilderRef,
1170 Order: AtomicOrdering,
1174 pub fn LLVMRustBuildAtomicCmpXchg(B: BuilderRef,
1178 Order: AtomicOrdering,
1179 FailureOrder: AtomicOrdering,
1183 pub fn LLVMBuildAtomicRMW(B: BuilderRef,
1187 Order: AtomicOrdering,
1188 SingleThreaded: Bool)
1191 pub fn LLVMRustBuildAtomicFence(B: BuilderRef,
1192 Order: AtomicOrdering,
1193 Scope: SynchronizationScope);
1196 // Selected entries from the downcasts.
1197 pub fn LLVMIsATerminatorInst(Inst: ValueRef) -> ValueRef;
1198 pub fn LLVMIsAStoreInst(Inst: ValueRef) -> ValueRef;
1200 /// Writes a module to the specified path. Returns 0 on success.
1201 pub fn LLVMWriteBitcodeToFile(M: ModuleRef, Path: *const c_char) -> c_int;
1203 /// Creates target data from a target layout string.
1204 pub fn LLVMCreateTargetData(StringRep: *const c_char) -> TargetDataRef;
1205 /// Number of bytes clobbered when doing a Store to *T.
1206 pub fn LLVMSizeOfTypeInBits(TD: TargetDataRef, Ty: TypeRef) -> c_ulonglong;
1208 /// Distance between successive elements in an array of T. Includes ABI padding.
1209 pub fn LLVMABISizeOfType(TD: TargetDataRef, Ty: TypeRef) -> c_ulonglong;
1211 /// Returns the preferred alignment of a type.
1212 pub fn LLVMPreferredAlignmentOfType(TD: TargetDataRef, Ty: TypeRef) -> c_uint;
1213 /// Returns the minimum alignment of a type.
1214 pub fn LLVMABIAlignmentOfType(TD: TargetDataRef, Ty: TypeRef) -> c_uint;
1216 /// Computes the byte offset of the indexed struct element for a
1218 pub fn LLVMOffsetOfElement(TD: TargetDataRef,
1223 /// Disposes target data.
1224 pub fn LLVMDisposeTargetData(TD: TargetDataRef);
1226 /// Creates a pass manager.
1227 pub fn LLVMCreatePassManager() -> PassManagerRef;
1229 /// Creates a function-by-function pass manager
1230 pub fn LLVMCreateFunctionPassManagerForModule(M: ModuleRef) -> PassManagerRef;
1232 /// Disposes a pass manager.
1233 pub fn LLVMDisposePassManager(PM: PassManagerRef);
1235 /// Runs a pass manager on a module.
1236 pub fn LLVMRunPassManager(PM: PassManagerRef, M: ModuleRef) -> Bool;
1238 pub fn LLVMInitializePasses();
1240 pub fn LLVMPassManagerBuilderCreate() -> PassManagerBuilderRef;
1241 pub fn LLVMPassManagerBuilderDispose(PMB: PassManagerBuilderRef);
1242 pub fn LLVMPassManagerBuilderSetSizeLevel(PMB: PassManagerBuilderRef, Value: Bool);
1243 pub fn LLVMPassManagerBuilderSetDisableUnrollLoops(PMB: PassManagerBuilderRef, Value: Bool);
1244 pub fn LLVMPassManagerBuilderUseInlinerWithThreshold(PMB: PassManagerBuilderRef,
1246 pub fn LLVMPassManagerBuilderPopulateModulePassManager(PMB: PassManagerBuilderRef,
1247 PM: PassManagerRef);
1249 pub fn LLVMPassManagerBuilderPopulateFunctionPassManager(PMB: PassManagerBuilderRef,
1250 PM: PassManagerRef);
1251 pub fn LLVMPassManagerBuilderPopulateLTOPassManager(PMB: PassManagerBuilderRef,
1256 // Stuff that's in rustllvm/ because it's not upstream yet.
1258 /// Opens an object file.
1259 pub fn LLVMCreateObjectFile(MemBuf: MemoryBufferRef) -> ObjectFileRef;
1260 /// Closes an object file.
1261 pub fn LLVMDisposeObjectFile(ObjFile: ObjectFileRef);
1263 /// Enumerates the sections in an object file.
1264 pub fn LLVMGetSections(ObjFile: ObjectFileRef) -> SectionIteratorRef;
1265 /// Destroys a section iterator.
1266 pub fn LLVMDisposeSectionIterator(SI: SectionIteratorRef);
1267 /// Returns true if the section iterator is at the end of the section
1269 pub fn LLVMIsSectionIteratorAtEnd(ObjFile: ObjectFileRef, SI: SectionIteratorRef) -> Bool;
1270 /// Moves the section iterator to point to the next section.
1271 pub fn LLVMMoveToNextSection(SI: SectionIteratorRef);
1272 /// Returns the current section size.
1273 pub fn LLVMGetSectionSize(SI: SectionIteratorRef) -> c_ulonglong;
1274 /// Returns the current section contents as a string buffer.
1275 pub fn LLVMGetSectionContents(SI: SectionIteratorRef) -> *const c_char;
1277 /// Reads the given file and returns it as a memory buffer. Use
1278 /// LLVMDisposeMemoryBuffer() to get rid of it.
1279 pub fn LLVMRustCreateMemoryBufferWithContentsOfFile(Path: *const c_char) -> MemoryBufferRef;
1281 pub fn LLVMStartMultithreaded() -> Bool;
1283 /// Returns a string describing the last error caused by an LLVMRust* call.
1284 pub fn LLVMRustGetLastError() -> *const c_char;
1286 /// Print the pass timings since static dtors aren't picking them up.
1287 pub fn LLVMRustPrintPassTimings();
1289 pub fn LLVMStructCreateNamed(C: ContextRef, Name: *const c_char) -> TypeRef;
1291 pub fn LLVMStructSetBody(StructTy: TypeRef,
1292 ElementTypes: *const TypeRef,
1293 ElementCount: c_uint,
1296 pub fn LLVMConstNamedStruct(S: TypeRef,
1297 ConstantVals: *const ValueRef,
1301 /// Enables LLVM debug output.
1302 pub fn LLVMRustSetDebug(Enabled: c_int);
1304 /// Prepares inline assembly.
1305 pub fn LLVMRustInlineAsm(Ty: TypeRef,
1306 AsmString: *const c_char,
1307 Constraints: *const c_char,
1310 Dialect: AsmDialect)
1313 pub fn LLVMRustDebugMetadataVersion() -> u32;
1314 pub fn LLVMRustVersionMajor() -> u32;
1315 pub fn LLVMRustVersionMinor() -> u32;
1317 pub fn LLVMRustAddModuleFlag(M: ModuleRef, name: *const c_char, value: u32);
1319 pub fn LLVMRustDIBuilderCreate(M: ModuleRef) -> DIBuilderRef;
1321 pub fn LLVMRustDIBuilderDispose(Builder: DIBuilderRef);
1323 pub fn LLVMRustDIBuilderFinalize(Builder: DIBuilderRef);
1325 pub fn LLVMRustDIBuilderCreateCompileUnit(Builder: DIBuilderRef,
1327 File: *const c_char,
1329 Producer: *const c_char,
1331 Flags: *const c_char,
1333 SplitName: *const c_char)
1336 pub fn LLVMRustDIBuilderCreateFile(Builder: DIBuilderRef,
1337 Filename: *const c_char,
1338 Directory: *const c_char)
1341 pub fn LLVMRustDIBuilderCreateSubroutineType(Builder: DIBuilderRef,
1343 ParameterTypes: DIArray)
1346 pub fn LLVMRustDIBuilderCreateFunction(Builder: DIBuilderRef,
1347 Scope: DIDescriptor,
1348 Name: *const c_char,
1349 LinkageName: *const c_char,
1353 isLocalToUnit: bool,
1363 pub fn LLVMRustDIBuilderCreateBasicType(Builder: DIBuilderRef,
1364 Name: *const c_char,
1370 pub fn LLVMRustDIBuilderCreatePointerType(Builder: DIBuilderRef,
1374 Name: *const c_char)
1377 pub fn LLVMRustDIBuilderCreateStructType(Builder: DIBuilderRef,
1378 Scope: DIDescriptor,
1379 Name: *const c_char,
1385 DerivedFrom: DIType,
1387 RunTimeLang: c_uint,
1388 VTableHolder: DIType,
1389 UniqueId: *const c_char)
1392 pub fn LLVMRustDIBuilderCreateMemberType(Builder: DIBuilderRef,
1393 Scope: DIDescriptor,
1394 Name: *const c_char,
1404 pub fn LLVMRustDIBuilderCreateLexicalBlock(Builder: DIBuilderRef,
1411 pub fn LLVMRustDIBuilderCreateLexicalBlockFile(Builder: DIBuilderRef,
1416 pub fn LLVMRustDIBuilderCreateStaticVariable(Builder: DIBuilderRef,
1418 Name: *const c_char,
1419 LinkageName: *const c_char,
1423 isLocalToUnit: bool,
1427 -> DIGlobalVariable;
1429 pub fn LLVMRustDIBuilderCreateVariable(Builder: DIBuilderRef,
1431 Scope: DIDescriptor,
1432 Name: *const c_char,
1436 AlwaysPreserve: bool,
1442 pub fn LLVMRustDIBuilderCreateArrayType(Builder: DIBuilderRef,
1446 Subscripts: DIArray)
1449 pub fn LLVMRustDIBuilderCreateVectorType(Builder: DIBuilderRef,
1453 Subscripts: DIArray)
1456 pub fn LLVMRustDIBuilderGetOrCreateSubrange(Builder: DIBuilderRef,
1461 pub fn LLVMRustDIBuilderGetOrCreateArray(Builder: DIBuilderRef,
1462 Ptr: *const DIDescriptor,
1466 pub fn LLVMRustDIBuilderInsertDeclareAtEnd(Builder: DIBuilderRef,
1468 VarInfo: DIVariable,
1469 AddrOps: *const i64,
1470 AddrOpsCount: c_uint,
1472 InsertAtEnd: BasicBlockRef)
1475 pub fn LLVMRustDIBuilderCreateEnumerator(Builder: DIBuilderRef,
1476 Name: *const c_char,
1480 pub fn LLVMRustDIBuilderCreateEnumerationType(Builder: DIBuilderRef,
1482 Name: *const c_char,
1491 pub fn LLVMRustDIBuilderCreateUnionType(Builder: DIBuilderRef,
1493 Name: *const c_char,
1500 RunTimeLang: c_uint,
1501 UniqueId: *const c_char)
1504 pub fn LLVMSetUnnamedAddr(GlobalVar: ValueRef, UnnamedAddr: Bool);
1506 pub fn LLVMRustDIBuilderCreateTemplateTypeParameter(Builder: DIBuilderRef,
1508 Name: *const c_char,
1513 -> DITemplateTypeParameter;
1516 pub fn LLVMRustDIBuilderCreateNameSpace(Builder: DIBuilderRef,
1518 Name: *const c_char,
1522 pub fn LLVMRustDICompositeTypeSetTypeArray(Builder: DIBuilderRef,
1523 CompositeType: DIType,
1524 TypeArray: DIArray);
1527 pub fn LLVMRustDIBuilderCreateDebugLocation(Context: ContextRef,
1531 InlinedAt: MetadataRef)
1533 pub fn LLVMRustDIBuilderCreateOpDeref() -> i64;
1534 pub fn LLVMRustDIBuilderCreateOpPlus() -> i64;
1536 pub fn LLVMRustWriteTypeToString(Type: TypeRef, s: RustStringRef);
1537 pub fn LLVMRustWriteValueToString(value_ref: ValueRef, s: RustStringRef);
1539 pub fn LLVMIsAConstantInt(value_ref: ValueRef) -> ValueRef;
1541 pub fn LLVMRustPassKind(Pass: PassRef) -> PassKind;
1542 pub fn LLVMRustFindAndCreatePass(Pass: *const c_char) -> PassRef;
1543 pub fn LLVMRustAddPass(PM: PassManagerRef, Pass: PassRef);
1545 pub fn LLVMRustHasFeature(T: TargetMachineRef, s: *const c_char) -> bool;
1547 pub fn LLVMRustPrintTargetCPUs(T: TargetMachineRef);
1548 pub fn LLVMRustPrintTargetFeatures(T: TargetMachineRef);
1550 pub fn LLVMRustCreateTargetMachine(Triple: *const c_char,
1552 Features: *const c_char,
1555 Level: CodeGenOptLevel,
1557 PositionIndependentExecutable: bool,
1558 FunctionSections: bool,
1560 -> TargetMachineRef;
1561 pub fn LLVMRustDisposeTargetMachine(T: TargetMachineRef);
1562 pub fn LLVMRustAddAnalysisPasses(T: TargetMachineRef, PM: PassManagerRef, M: ModuleRef);
1563 pub fn LLVMRustAddBuilderLibraryInfo(PMB: PassManagerBuilderRef,
1565 DisableSimplifyLibCalls: bool);
1566 pub fn LLVMRustConfigurePassManagerBuilder(PMB: PassManagerBuilderRef,
1567 OptLevel: CodeGenOptLevel,
1568 MergeFunctions: bool,
1570 LoopVectorize: bool);
1571 pub fn LLVMRustAddLibraryInfo(PM: PassManagerRef,
1573 DisableSimplifyLibCalls: bool);
1574 pub fn LLVMRustRunFunctionPassManager(PM: PassManagerRef, M: ModuleRef);
1575 pub fn LLVMRustWriteOutputFile(T: TargetMachineRef,
1578 Output: *const c_char,
1581 pub fn LLVMRustPrintModule(PM: PassManagerRef, M: ModuleRef, Output: *const c_char);
1582 pub fn LLVMRustSetLLVMOptions(Argc: c_int, Argv: *const *const c_char);
1583 pub fn LLVMRustPrintPasses();
1584 pub fn LLVMRustSetNormalizedTarget(M: ModuleRef, triple: *const c_char);
1585 pub fn LLVMRustAddAlwaysInlinePass(P: PassManagerBuilderRef, AddLifetimes: bool);
1586 pub fn LLVMRustLinkInExternalBitcode(M: ModuleRef, bc: *const c_char, len: size_t) -> bool;
1587 pub fn LLVMRustRunRestrictionPass(M: ModuleRef, syms: *const *const c_char, len: size_t);
1588 pub fn LLVMRustMarkAllFunctionsNounwind(M: ModuleRef);
1590 pub fn LLVMRustOpenArchive(path: *const c_char) -> ArchiveRef;
1591 pub fn LLVMRustArchiveIteratorNew(AR: ArchiveRef) -> ArchiveIteratorRef;
1592 pub fn LLVMRustArchiveIteratorNext(AIR: ArchiveIteratorRef) -> ArchiveChildRef;
1593 pub fn LLVMRustArchiveChildName(ACR: ArchiveChildRef, size: *mut size_t) -> *const c_char;
1594 pub fn LLVMRustArchiveChildData(ACR: ArchiveChildRef, size: *mut size_t) -> *const c_char;
1595 pub fn LLVMRustArchiveChildFree(ACR: ArchiveChildRef);
1596 pub fn LLVMRustArchiveIteratorFree(AIR: ArchiveIteratorRef);
1597 pub fn LLVMRustDestroyArchive(AR: ArchiveRef);
1599 pub fn LLVMRustGetSectionName(SI: SectionIteratorRef, data: *mut *const c_char) -> size_t;
1601 pub fn LLVMRustWriteTwineToString(T: TwineRef, s: RustStringRef);
1603 pub fn LLVMContextSetDiagnosticHandler(C: ContextRef,
1604 Handler: DiagnosticHandler,
1605 DiagnosticContext: *mut c_void);
1607 pub fn LLVMRustUnpackOptimizationDiagnostic(DI: DiagnosticInfoRef,
1608 pass_name_out: RustStringRef,
1609 function_out: *mut ValueRef,
1610 debugloc_out: *mut DebugLocRef,
1611 message_out: RustStringRef);
1612 pub fn LLVMRustUnpackInlineAsmDiagnostic(DI: DiagnosticInfoRef,
1613 cookie_out: *mut c_uint,
1614 message_out: *mut TwineRef,
1615 instruction_out: *mut ValueRef);
1617 pub fn LLVMRustWriteDiagnosticInfoToString(DI: DiagnosticInfoRef, s: RustStringRef);
1618 pub fn LLVMRustGetDiagInfoKind(DI: DiagnosticInfoRef) -> DiagnosticKind;
1620 pub fn LLVMRustWriteDebugLocToString(C: ContextRef, DL: DebugLocRef, s: RustStringRef);
1622 pub fn LLVMRustSetInlineAsmDiagnosticHandler(C: ContextRef,
1623 H: InlineAsmDiagHandler,
1626 pub fn LLVMRustWriteSMDiagnosticToString(d: SMDiagnosticRef, s: RustStringRef);
1628 pub fn LLVMRustWriteArchive(Dst: *const c_char,
1630 Members: *const RustArchiveMemberRef,
1634 pub fn LLVMRustArchiveMemberNew(Filename: *const c_char,
1635 Name: *const c_char,
1636 Child: ArchiveChildRef)
1637 -> RustArchiveMemberRef;
1638 pub fn LLVMRustArchiveMemberFree(Member: RustArchiveMemberRef);
1640 pub fn LLVMRustSetDataLayoutFromTargetMachine(M: ModuleRef, TM: TargetMachineRef);
1641 pub fn LLVMRustGetModuleDataLayout(M: ModuleRef) -> TargetDataRef;
1643 pub fn LLVMRustBuildOperandBundleDef(Name: *const c_char,
1644 Inputs: *const ValueRef,
1646 -> OperandBundleDefRef;
1647 pub fn LLVMRustFreeOperandBundleDef(Bundle: OperandBundleDefRef);
1649 pub fn LLVMRustPositionBuilderAtStart(B: BuilderRef, BB: BasicBlockRef);
1651 pub fn LLVMRustSetComdat(M: ModuleRef, V: ValueRef, Name: *const c_char);
1652 pub fn LLVMRustUnsetComdat(V: ValueRef);
1653 pub fn LLVMRustSetModulePIELevel(M: ModuleRef);
1657 // LLVM requires symbols from this library, but apparently they're not printed
1658 // during llvm-config?
1660 #[link(name = "ole32")]