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)]
42 X86StdcallCallConv = 64,
43 X86FastcallCallConv = 65,
44 ArmAapcsCallConv = 67,
52 #[derive(Copy, Clone, PartialEq, Eq, Hash, Debug)]
56 AvailableExternallyLinkage = 1,
57 LinkOnceAnyLinkage = 2,
58 LinkOnceODRLinkage = 3,
64 ExternalWeakLinkage = 9,
69 #[derive(Copy, Clone, PartialEq, Eq, Hash, Debug)]
77 /// LLVMDiagnosticSeverity
78 #[derive(Copy, Clone, Debug)]
80 pub enum DiagnosticSeverity {
87 /// LLVMDLLStorageClass
88 #[derive(Copy, Clone)]
90 pub enum DLLStorageClass {
92 DllImport = 1, // Function to be imported from DLL.
93 DllExport = 2, // Function to be accessible from DLL.
96 /// Matches LLVMRustAttribute in rustllvm.h
97 /// Semantically a subset of the C++ enum llvm::Attribute::AttrKind,
98 /// though it is not ABI compatible (since it's a C++ enum)
100 #[derive(Copy, Clone, Debug)]
115 OptimizeForSize = 13,
125 #[derive(Copy, Clone)]
127 pub enum IntPredicate {
140 /// LLVMRealPredicate
141 #[derive(Copy, Clone)]
143 pub enum RealPredicate {
144 RealPredicateFalse = 0,
159 RealPredicateTrue = 15,
163 #[derive(Copy, Clone, PartialEq, Debug)]
185 /// LLVMAtomicRmwBinOp
186 #[derive(Copy, Clone)]
188 pub enum AtomicRmwBinOp {
202 /// LLVMAtomicOrdering
203 #[derive(Copy, Clone)]
205 pub enum AtomicOrdering {
209 // Consume = 3, // Not specified yet.
213 SequentiallyConsistent = 7,
216 /// LLVMRustSynchronizationScope
217 #[derive(Copy, Clone)]
219 pub enum SynchronizationScope {
226 #[derive(Copy, Clone)]
235 #[derive(Copy, Clone)]
237 pub enum MetadataType {
244 MD_invariant_load = 6,
248 MD_mem_parallel_loop_access = 10,
252 /// LLVMRustAsmDialect
253 #[derive(Copy, Clone)]
255 pub enum AsmDialect {
261 /// LLVMRustCodeGenOptLevel
262 #[derive(Copy, Clone, PartialEq)]
264 pub enum CodeGenOptLevel {
273 #[derive(Copy, Clone, PartialEq)]
282 /// LLVMRustCodeModel
283 #[derive(Copy, Clone)]
295 /// LLVMRustDiagnosticKind
296 #[derive(Copy, Clone)]
298 pub enum DiagnosticKind {
302 DebugMetadataVersion,
305 OptimizationRemarkMissed,
306 OptimizationRemarkAnalysis,
307 OptimizationRemarkAnalysisFPCommute,
308 OptimizationRemarkAnalysisAliasing,
309 OptimizationRemarkOther,
313 /// LLVMRustArchiveKind
314 #[derive(Copy, Clone)]
316 pub enum ArchiveKind {
325 #[derive(Copy, Clone, PartialEq, Debug)]
333 // Opaque pointer types
334 #[allow(missing_copy_implementations)]
335 pub enum Module_opaque {}
336 pub type ModuleRef = *mut Module_opaque;
337 #[allow(missing_copy_implementations)]
338 pub enum Context_opaque {}
339 pub type ContextRef = *mut Context_opaque;
340 #[allow(missing_copy_implementations)]
341 pub enum Type_opaque {}
342 pub type TypeRef = *mut Type_opaque;
343 #[allow(missing_copy_implementations)]
344 pub enum Value_opaque {}
345 pub type ValueRef = *mut Value_opaque;
346 #[allow(missing_copy_implementations)]
347 pub enum Metadata_opaque {}
348 pub type MetadataRef = *mut Metadata_opaque;
349 #[allow(missing_copy_implementations)]
350 pub enum BasicBlock_opaque {}
351 pub type BasicBlockRef = *mut BasicBlock_opaque;
352 #[allow(missing_copy_implementations)]
353 pub enum Builder_opaque {}
354 pub type BuilderRef = *mut Builder_opaque;
355 #[allow(missing_copy_implementations)]
356 pub enum ExecutionEngine_opaque {}
357 pub type ExecutionEngineRef = *mut ExecutionEngine_opaque;
358 #[allow(missing_copy_implementations)]
359 pub enum MemoryBuffer_opaque {}
360 pub type MemoryBufferRef = *mut MemoryBuffer_opaque;
361 #[allow(missing_copy_implementations)]
362 pub enum PassManager_opaque {}
363 pub type PassManagerRef = *mut PassManager_opaque;
364 #[allow(missing_copy_implementations)]
365 pub enum PassManagerBuilder_opaque {}
366 pub type PassManagerBuilderRef = *mut PassManagerBuilder_opaque;
367 #[allow(missing_copy_implementations)]
368 pub enum Use_opaque {}
369 pub type UseRef = *mut Use_opaque;
370 #[allow(missing_copy_implementations)]
371 pub enum TargetData_opaque {}
372 pub type TargetDataRef = *mut TargetData_opaque;
373 #[allow(missing_copy_implementations)]
374 pub enum ObjectFile_opaque {}
375 pub type ObjectFileRef = *mut ObjectFile_opaque;
376 #[allow(missing_copy_implementations)]
377 pub enum SectionIterator_opaque {}
378 pub type SectionIteratorRef = *mut SectionIterator_opaque;
379 #[allow(missing_copy_implementations)]
380 pub enum Pass_opaque {}
381 pub type PassRef = *mut Pass_opaque;
382 #[allow(missing_copy_implementations)]
383 pub enum TargetMachine_opaque {}
384 pub type TargetMachineRef = *mut TargetMachine_opaque;
385 pub enum Archive_opaque {}
386 pub type ArchiveRef = *mut Archive_opaque;
387 pub enum ArchiveIterator_opaque {}
388 pub type ArchiveIteratorRef = *mut ArchiveIterator_opaque;
389 pub enum ArchiveChild_opaque {}
390 pub type ArchiveChildRef = *mut ArchiveChild_opaque;
391 #[allow(missing_copy_implementations)]
392 pub enum Twine_opaque {}
393 pub type TwineRef = *mut Twine_opaque;
394 #[allow(missing_copy_implementations)]
395 pub enum DiagnosticInfo_opaque {}
396 pub type DiagnosticInfoRef = *mut DiagnosticInfo_opaque;
397 #[allow(missing_copy_implementations)]
398 pub enum DebugLoc_opaque {}
399 pub type DebugLocRef = *mut DebugLoc_opaque;
400 #[allow(missing_copy_implementations)]
401 pub enum SMDiagnostic_opaque {}
402 pub type SMDiagnosticRef = *mut SMDiagnostic_opaque;
403 #[allow(missing_copy_implementations)]
404 pub enum RustArchiveMember_opaque {}
405 pub type RustArchiveMemberRef = *mut RustArchiveMember_opaque;
406 #[allow(missing_copy_implementations)]
407 pub enum OperandBundleDef_opaque {}
408 pub type OperandBundleDefRef = *mut OperandBundleDef_opaque;
410 pub type DiagnosticHandler = unsafe extern "C" fn(DiagnosticInfoRef, *mut c_void);
411 pub type InlineAsmDiagHandler = unsafe extern "C" fn(SMDiagnosticRef, *const c_void, c_uint);
415 use super::MetadataRef;
417 #[allow(missing_copy_implementations)]
418 pub enum DIBuilder_opaque {}
419 pub type DIBuilderRef = *mut DIBuilder_opaque;
421 pub type DIDescriptor = MetadataRef;
422 pub type DIScope = DIDescriptor;
423 pub type DILocation = DIDescriptor;
424 pub type DIFile = DIScope;
425 pub type DILexicalBlock = DIScope;
426 pub type DISubprogram = DIScope;
427 pub type DINameSpace = DIScope;
428 pub type DIType = DIDescriptor;
429 pub type DIBasicType = DIType;
430 pub type DIDerivedType = DIType;
431 pub type DICompositeType = DIDerivedType;
432 pub type DIVariable = DIDescriptor;
433 pub type DIGlobalVariable = DIDescriptor;
434 pub type DIArray = DIDescriptor;
435 pub type DISubrange = DIDescriptor;
436 pub type DIEnumerator = DIDescriptor;
437 pub type DITemplateTypeParameter = DIDescriptor;
439 // These values **must** match with LLVMRustDIFlags!!
442 #[derive(Debug, Default)]
443 flags DIFlags: ::libc::uint32_t {
445 const FlagPrivate = 1,
446 const FlagProtected = 2,
447 const FlagPublic = 3,
448 const FlagFwdDecl = (1 << 2),
449 const FlagAppleBlock = (1 << 3),
450 const FlagBlockByrefStruct = (1 << 4),
451 const FlagVirtual = (1 << 5),
452 const FlagArtificial = (1 << 6),
453 const FlagExplicit = (1 << 7),
454 const FlagPrototyped = (1 << 8),
455 const FlagObjcClassComplete = (1 << 9),
456 const FlagObjectPointer = (1 << 10),
457 const FlagVector = (1 << 11),
458 const FlagStaticMember = (1 << 12),
459 const FlagLValueReference = (1 << 13),
460 const FlagRValueReference = (1 << 14),
466 // Link to our native llvm bindings (things that we need to use the C++ api
467 // for) and because llvm is written in C++ we need to link against libstdc++
469 // You'll probably notice that there is an omission of all LLVM libraries
470 // from this location. This is because the set of LLVM libraries that we
471 // link to is mostly defined by LLVM, and the `llvm-config` tool is used to
472 // figure out the exact set of libraries. To do this, the build system
473 // generates an llvmdeps.rs file next to this one which will be
474 // automatically updated whenever LLVM is updated to include an up-to-date
475 // set of the libraries we need to link to LLVM for.
476 #[link(name = "rustllvm", kind = "static")] // not quite true but good enough
478 // Create and destroy contexts.
479 pub fn LLVMContextCreate() -> ContextRef;
480 pub fn LLVMContextDispose(C: ContextRef);
481 pub fn LLVMGetMDKindIDInContext(C: ContextRef, Name: *const c_char, SLen: c_uint) -> c_uint;
483 // Create and destroy modules.
484 pub fn LLVMModuleCreateWithNameInContext(ModuleID: *const c_char, C: ContextRef) -> ModuleRef;
485 pub fn LLVMGetModuleContext(M: ModuleRef) -> ContextRef;
486 pub fn LLVMCloneModule(M: ModuleRef) -> ModuleRef;
487 pub fn LLVMDisposeModule(M: ModuleRef);
489 /// Data layout. See Module::getDataLayout.
490 pub fn LLVMGetDataLayout(M: ModuleRef) -> *const c_char;
491 pub fn LLVMSetDataLayout(M: ModuleRef, Triple: *const c_char);
493 /// See Module::dump.
494 pub fn LLVMDumpModule(M: ModuleRef);
496 /// See Module::setModuleInlineAsm.
497 pub fn LLVMSetModuleInlineAsm(M: ModuleRef, Asm: *const c_char);
499 /// See llvm::LLVMTypeKind::getTypeID.
500 pub fn LLVMRustGetTypeKind(Ty: TypeRef) -> TypeKind;
502 /// See llvm::Value::getContext
503 pub fn LLVMRustGetValueContext(V: ValueRef) -> ContextRef;
505 // Operations on integer types
506 pub fn LLVMInt1TypeInContext(C: ContextRef) -> TypeRef;
507 pub fn LLVMInt8TypeInContext(C: ContextRef) -> TypeRef;
508 pub fn LLVMInt16TypeInContext(C: ContextRef) -> TypeRef;
509 pub fn LLVMInt32TypeInContext(C: ContextRef) -> TypeRef;
510 pub fn LLVMInt64TypeInContext(C: ContextRef) -> TypeRef;
511 pub fn LLVMIntTypeInContext(C: ContextRef, NumBits: c_uint) -> TypeRef;
513 pub fn LLVMGetIntTypeWidth(IntegerTy: TypeRef) -> c_uint;
515 // Operations on real types
516 pub fn LLVMFloatTypeInContext(C: ContextRef) -> TypeRef;
517 pub fn LLVMDoubleTypeInContext(C: ContextRef) -> TypeRef;
519 // Operations on function types
520 pub fn LLVMFunctionType(ReturnType: TypeRef,
521 ParamTypes: *const TypeRef,
525 pub fn LLVMGetReturnType(FunctionTy: TypeRef) -> TypeRef;
526 pub fn LLVMCountParamTypes(FunctionTy: TypeRef) -> c_uint;
527 pub fn LLVMGetParamTypes(FunctionTy: TypeRef, Dest: *mut TypeRef);
529 // Operations on struct types
530 pub fn LLVMStructTypeInContext(C: ContextRef,
531 ElementTypes: *const TypeRef,
532 ElementCount: c_uint,
535 pub fn LLVMCountStructElementTypes(StructTy: TypeRef) -> c_uint;
536 pub fn LLVMGetStructElementTypes(StructTy: TypeRef, Dest: *mut TypeRef);
537 pub fn LLVMIsPackedStruct(StructTy: TypeRef) -> Bool;
539 // Operations on array, pointer, and vector types (sequence types)
540 pub fn LLVMRustArrayType(ElementType: TypeRef, ElementCount: u64) -> TypeRef;
541 pub fn LLVMPointerType(ElementType: TypeRef, AddressSpace: c_uint) -> TypeRef;
542 pub fn LLVMVectorType(ElementType: TypeRef, ElementCount: c_uint) -> TypeRef;
544 pub fn LLVMGetElementType(Ty: TypeRef) -> TypeRef;
545 pub fn LLVMGetArrayLength(ArrayTy: TypeRef) -> c_uint;
546 pub fn LLVMGetVectorSize(VectorTy: TypeRef) -> c_uint;
548 // Operations on other types
549 pub fn LLVMVoidTypeInContext(C: ContextRef) -> TypeRef;
550 pub fn LLVMRustMetadataTypeInContext(C: ContextRef) -> TypeRef;
552 // Operations on all values
553 pub fn LLVMTypeOf(Val: ValueRef) -> TypeRef;
554 pub fn LLVMGetValueName(Val: ValueRef) -> *const c_char;
555 pub fn LLVMSetValueName(Val: ValueRef, Name: *const c_char);
556 pub fn LLVMReplaceAllUsesWith(OldVal: ValueRef, NewVal: ValueRef);
557 pub fn LLVMSetMetadata(Val: ValueRef, KindID: c_uint, Node: ValueRef);
559 // Operations on Uses
560 pub fn LLVMGetFirstUse(Val: ValueRef) -> UseRef;
561 pub fn LLVMGetNextUse(U: UseRef) -> UseRef;
562 pub fn LLVMGetUser(U: UseRef) -> ValueRef;
564 // Operations on Users
565 pub fn LLVMGetOperand(Val: ValueRef, Index: c_uint) -> ValueRef;
567 // Operations on constants of any type
568 pub fn LLVMConstNull(Ty: TypeRef) -> ValueRef;
569 pub fn LLVMConstICmp(Pred: IntPredicate, V1: ValueRef, V2: ValueRef) -> ValueRef;
570 pub fn LLVMConstFCmp(Pred: RealPredicate, V1: ValueRef, V2: ValueRef) -> ValueRef;
571 // only for isize/vector
572 pub fn LLVMGetUndef(Ty: TypeRef) -> ValueRef;
573 pub fn LLVMIsNull(Val: ValueRef) -> Bool;
574 pub fn LLVMIsUndef(Val: ValueRef) -> Bool;
576 // Operations on metadata
577 pub fn LLVMMDNodeInContext(C: ContextRef, Vals: *const ValueRef, Count: c_uint) -> ValueRef;
579 // Operations on scalar constants
580 pub fn LLVMConstInt(IntTy: TypeRef, N: c_ulonglong, SignExtend: Bool) -> ValueRef;
581 pub fn LLVMConstReal(RealTy: TypeRef, N: f64) -> ValueRef;
582 pub fn LLVMConstIntGetZExtValue(ConstantVal: ValueRef) -> c_ulonglong;
583 pub fn LLVMConstIntGetSExtValue(ConstantVal: ValueRef) -> c_longlong;
586 // Operations on composite constants
587 pub fn LLVMConstStringInContext(C: ContextRef,
590 DontNullTerminate: Bool)
592 pub fn LLVMConstStructInContext(C: ContextRef,
593 ConstantVals: *const ValueRef,
598 pub fn LLVMConstArray(ElementTy: TypeRef,
599 ConstantVals: *const ValueRef,
602 pub fn LLVMConstVector(ScalarConstantVals: *const ValueRef, Size: c_uint) -> ValueRef;
604 // Constant expressions
605 pub fn LLVMSizeOf(Ty: TypeRef) -> ValueRef;
606 pub fn LLVMConstNeg(ConstantVal: ValueRef) -> ValueRef;
607 pub fn LLVMConstFNeg(ConstantVal: ValueRef) -> ValueRef;
608 pub fn LLVMConstNot(ConstantVal: ValueRef) -> ValueRef;
609 pub fn LLVMConstAdd(LHSConstant: ValueRef, RHSConstant: ValueRef) -> ValueRef;
610 pub fn LLVMConstFAdd(LHSConstant: ValueRef, RHSConstant: ValueRef) -> ValueRef;
611 pub fn LLVMConstSub(LHSConstant: ValueRef, RHSConstant: ValueRef) -> ValueRef;
612 pub fn LLVMConstFSub(LHSConstant: ValueRef, RHSConstant: ValueRef) -> ValueRef;
613 pub fn LLVMConstMul(LHSConstant: ValueRef, RHSConstant: ValueRef) -> ValueRef;
614 pub fn LLVMConstFMul(LHSConstant: ValueRef, RHSConstant: ValueRef) -> ValueRef;
615 pub fn LLVMConstUDiv(LHSConstant: ValueRef, RHSConstant: ValueRef) -> ValueRef;
616 pub fn LLVMConstSDiv(LHSConstant: ValueRef, RHSConstant: ValueRef) -> ValueRef;
617 pub fn LLVMConstFDiv(LHSConstant: ValueRef, RHSConstant: ValueRef) -> ValueRef;
618 pub fn LLVMConstURem(LHSConstant: ValueRef, RHSConstant: ValueRef) -> ValueRef;
619 pub fn LLVMConstSRem(LHSConstant: ValueRef, RHSConstant: ValueRef) -> ValueRef;
620 pub fn LLVMConstFRem(LHSConstant: ValueRef, RHSConstant: ValueRef) -> ValueRef;
621 pub fn LLVMConstAnd(LHSConstant: ValueRef, RHSConstant: ValueRef) -> ValueRef;
622 pub fn LLVMConstOr(LHSConstant: ValueRef, RHSConstant: ValueRef) -> ValueRef;
623 pub fn LLVMConstXor(LHSConstant: ValueRef, RHSConstant: ValueRef) -> ValueRef;
624 pub fn LLVMConstShl(LHSConstant: ValueRef, RHSConstant: ValueRef) -> ValueRef;
625 pub fn LLVMConstLShr(LHSConstant: ValueRef, RHSConstant: ValueRef) -> ValueRef;
626 pub fn LLVMConstAShr(LHSConstant: ValueRef, RHSConstant: ValueRef) -> ValueRef;
627 pub fn LLVMConstTrunc(ConstantVal: ValueRef, ToType: TypeRef) -> ValueRef;
628 pub fn LLVMConstZExt(ConstantVal: ValueRef, ToType: TypeRef) -> ValueRef;
629 pub fn LLVMConstUIToFP(ConstantVal: ValueRef, ToType: TypeRef) -> ValueRef;
630 pub fn LLVMConstSIToFP(ConstantVal: ValueRef, ToType: TypeRef) -> ValueRef;
631 pub fn LLVMConstFPToUI(ConstantVal: ValueRef, ToType: TypeRef) -> ValueRef;
632 pub fn LLVMConstFPToSI(ConstantVal: ValueRef, ToType: TypeRef) -> ValueRef;
633 pub fn LLVMConstPtrToInt(ConstantVal: ValueRef, ToType: TypeRef) -> ValueRef;
634 pub fn LLVMConstIntToPtr(ConstantVal: ValueRef, ToType: TypeRef) -> ValueRef;
635 pub fn LLVMConstBitCast(ConstantVal: ValueRef, ToType: TypeRef) -> ValueRef;
636 pub fn LLVMConstPointerCast(ConstantVal: ValueRef, ToType: TypeRef) -> ValueRef;
637 pub fn LLVMConstIntCast(ConstantVal: ValueRef, ToType: TypeRef, isSigned: Bool) -> ValueRef;
638 pub fn LLVMConstFPCast(ConstantVal: ValueRef, ToType: TypeRef) -> ValueRef;
639 pub fn LLVMConstExtractValue(AggConstant: ValueRef,
640 IdxList: *const c_uint,
643 pub fn LLVMConstInlineAsm(Ty: TypeRef,
644 AsmString: *const c_char,
645 Constraints: *const c_char,
646 HasSideEffects: Bool,
651 // Operations on global variables, functions, and aliases (globals)
652 pub fn LLVMGetGlobalParent(Global: ValueRef) -> ModuleRef;
653 pub fn LLVMIsDeclaration(Global: ValueRef) -> Bool;
654 pub fn LLVMRustGetLinkage(Global: ValueRef) -> Linkage;
655 pub fn LLVMRustSetLinkage(Global: ValueRef, RustLinkage: Linkage);
656 pub fn LLVMGetSection(Global: ValueRef) -> *const c_char;
657 pub fn LLVMSetSection(Global: ValueRef, Section: *const c_char);
658 pub fn LLVMRustGetVisibility(Global: ValueRef) -> Visibility;
659 pub fn LLVMRustSetVisibility(Global: ValueRef, Viz: Visibility);
660 pub fn LLVMGetAlignment(Global: ValueRef) -> c_uint;
661 pub fn LLVMSetAlignment(Global: ValueRef, Bytes: c_uint);
662 pub fn LLVMSetDLLStorageClass(V: ValueRef, C: DLLStorageClass);
665 // Operations on global variables
666 pub fn LLVMIsAGlobalVariable(GlobalVar: ValueRef) -> ValueRef;
667 pub fn LLVMAddGlobal(M: ModuleRef, Ty: TypeRef, Name: *const c_char) -> ValueRef;
668 pub fn LLVMGetNamedGlobal(M: ModuleRef, Name: *const c_char) -> ValueRef;
669 pub fn LLVMRustGetOrInsertGlobal(M: ModuleRef, Name: *const c_char, T: TypeRef) -> ValueRef;
670 pub fn LLVMGetFirstGlobal(M: ModuleRef) -> ValueRef;
671 pub fn LLVMGetNextGlobal(GlobalVar: ValueRef) -> ValueRef;
672 pub fn LLVMDeleteGlobal(GlobalVar: ValueRef);
673 pub fn LLVMGetInitializer(GlobalVar: ValueRef) -> ValueRef;
674 pub fn LLVMSetInitializer(GlobalVar: ValueRef, ConstantVal: ValueRef);
675 pub fn LLVMSetThreadLocal(GlobalVar: ValueRef, IsThreadLocal: Bool);
676 pub fn LLVMIsGlobalConstant(GlobalVar: ValueRef) -> Bool;
677 pub fn LLVMSetGlobalConstant(GlobalVar: ValueRef, IsConstant: Bool);
678 pub fn LLVMRustGetNamedValue(M: ModuleRef, Name: *const c_char) -> ValueRef;
680 // Operations on functions
681 pub fn LLVMAddFunction(M: ModuleRef, Name: *const c_char, FunctionTy: TypeRef) -> ValueRef;
682 pub fn LLVMGetNamedFunction(M: ModuleRef, Name: *const c_char) -> ValueRef;
683 pub fn LLVMGetFirstFunction(M: ModuleRef) -> ValueRef;
684 pub fn LLVMGetNextFunction(Fn: ValueRef) -> ValueRef;
685 pub fn LLVMRustGetOrInsertFunction(M: ModuleRef,
689 pub fn LLVMSetFunctionCallConv(Fn: ValueRef, CC: c_uint);
690 pub fn LLVMRustAddDereferenceableAttr(Fn: ValueRef, index: c_uint, bytes: u64);
691 pub fn LLVMRustAddFunctionAttribute(Fn: ValueRef, index: c_uint, attr: Attribute);
692 pub fn LLVMRustAddFunctionAttrStringValue(Fn: ValueRef,
695 Value: *const c_char);
696 pub fn LLVMRustRemoveFunctionAttributes(Fn: ValueRef, index: c_uint, attr: Attribute);
698 // Operations on parameters
699 pub fn LLVMCountParams(Fn: ValueRef) -> c_uint;
700 pub fn LLVMGetParam(Fn: ValueRef, Index: c_uint) -> ValueRef;
702 // Operations on basic blocks
703 pub fn LLVMBasicBlockAsValue(BB: BasicBlockRef) -> ValueRef;
704 pub fn LLVMGetBasicBlockParent(BB: BasicBlockRef) -> ValueRef;
705 pub fn LLVMAppendBasicBlockInContext(C: ContextRef,
709 pub fn LLVMDeleteBasicBlock(BB: BasicBlockRef);
711 // Operations on instructions
712 pub fn LLVMGetInstructionParent(Inst: ValueRef) -> BasicBlockRef;
713 pub fn LLVMGetFirstBasicBlock(Fn: ValueRef) -> BasicBlockRef;
714 pub fn LLVMGetFirstInstruction(BB: BasicBlockRef) -> ValueRef;
715 pub fn LLVMInstructionEraseFromParent(Inst: ValueRef);
717 // Operations on call sites
718 pub fn LLVMSetInstructionCallConv(Instr: ValueRef, CC: c_uint);
719 pub fn LLVMRustAddCallSiteAttribute(Instr: ValueRef, index: c_uint, attr: Attribute);
720 pub fn LLVMRustAddDereferenceableCallSiteAttr(Instr: ValueRef, index: c_uint, bytes: u64);
722 // Operations on load/store instructions (only)
723 pub fn LLVMSetVolatile(MemoryAccessInst: ValueRef, volatile: Bool);
725 // Operations on phi nodes
726 pub fn LLVMAddIncoming(PhiNode: ValueRef,
727 IncomingValues: *const ValueRef,
728 IncomingBlocks: *const BasicBlockRef,
731 // Instruction builders
732 pub fn LLVMCreateBuilderInContext(C: ContextRef) -> BuilderRef;
733 pub fn LLVMPositionBuilder(Builder: BuilderRef, Block: BasicBlockRef, Instr: ValueRef);
734 pub fn LLVMPositionBuilderBefore(Builder: BuilderRef, Instr: ValueRef);
735 pub fn LLVMPositionBuilderAtEnd(Builder: BuilderRef, Block: BasicBlockRef);
736 pub fn LLVMGetInsertBlock(Builder: BuilderRef) -> BasicBlockRef;
737 pub fn LLVMDisposeBuilder(Builder: BuilderRef);
740 pub fn LLVMSetCurrentDebugLocation(Builder: BuilderRef, L: ValueRef);
741 pub fn LLVMGetCurrentDebugLocation(Builder: BuilderRef) -> ValueRef;
742 pub fn LLVMSetInstDebugLocation(Builder: BuilderRef, Inst: ValueRef);
745 pub fn LLVMBuildRetVoid(B: BuilderRef) -> ValueRef;
746 pub fn LLVMBuildRet(B: BuilderRef, V: ValueRef) -> ValueRef;
747 pub fn LLVMBuildAggregateRet(B: BuilderRef, RetVals: *const ValueRef, N: c_uint) -> ValueRef;
748 pub fn LLVMBuildBr(B: BuilderRef, Dest: BasicBlockRef) -> ValueRef;
749 pub fn LLVMBuildCondBr(B: BuilderRef,
754 pub fn LLVMBuildSwitch(B: BuilderRef,
759 pub fn LLVMBuildIndirectBr(B: BuilderRef, Addr: ValueRef, NumDests: c_uint) -> ValueRef;
760 pub fn LLVMRustBuildInvoke(B: BuilderRef,
762 Args: *const ValueRef,
765 Catch: BasicBlockRef,
766 Bundle: OperandBundleDefRef,
769 pub fn LLVMRustBuildLandingPad(B: BuilderRef,
776 pub fn LLVMBuildResume(B: BuilderRef, Exn: ValueRef) -> ValueRef;
777 pub fn LLVMBuildUnreachable(B: BuilderRef) -> ValueRef;
779 pub fn LLVMRustBuildCleanupPad(B: BuilderRef,
782 Args: *const ValueRef,
785 pub fn LLVMRustBuildCleanupRet(B: BuilderRef,
786 CleanupPad: ValueRef,
787 UnwindBB: BasicBlockRef)
789 pub fn LLVMRustBuildCatchPad(B: BuilderRef,
792 Args: *const ValueRef,
795 pub fn LLVMRustBuildCatchRet(B: BuilderRef, Pad: ValueRef, BB: BasicBlockRef) -> ValueRef;
796 pub fn LLVMRustBuildCatchSwitch(Builder: BuilderRef,
802 pub fn LLVMRustAddHandler(CatchSwitch: ValueRef, Handler: BasicBlockRef);
803 pub fn LLVMRustSetPersonalityFn(B: BuilderRef, Pers: ValueRef);
805 // Add a case to the switch instruction
806 pub fn LLVMAddCase(Switch: ValueRef, OnVal: ValueRef, Dest: BasicBlockRef);
808 // Add a clause to the landing pad instruction
809 pub fn LLVMAddClause(LandingPad: ValueRef, ClauseVal: ValueRef);
811 // Set the cleanup on a landing pad instruction
812 pub fn LLVMSetCleanup(LandingPad: ValueRef, Val: Bool);
815 pub fn LLVMBuildAdd(B: BuilderRef,
820 pub fn LLVMBuildNSWAdd(B: BuilderRef,
825 pub fn LLVMBuildNUWAdd(B: BuilderRef,
830 pub fn LLVMBuildFAdd(B: BuilderRef,
835 pub fn LLVMBuildSub(B: BuilderRef,
840 pub fn LLVMBuildNSWSub(B: BuilderRef,
845 pub fn LLVMBuildNUWSub(B: BuilderRef,
850 pub fn LLVMBuildFSub(B: BuilderRef,
855 pub fn LLVMBuildMul(B: BuilderRef,
860 pub fn LLVMBuildNSWMul(B: BuilderRef,
865 pub fn LLVMBuildNUWMul(B: BuilderRef,
870 pub fn LLVMBuildFMul(B: BuilderRef,
875 pub fn LLVMBuildUDiv(B: BuilderRef,
880 pub fn LLVMBuildSDiv(B: BuilderRef,
885 pub fn LLVMBuildExactSDiv(B: BuilderRef,
890 pub fn LLVMBuildFDiv(B: BuilderRef,
895 pub fn LLVMBuildURem(B: BuilderRef,
900 pub fn LLVMBuildSRem(B: BuilderRef,
905 pub fn LLVMBuildFRem(B: BuilderRef,
910 pub fn LLVMBuildShl(B: BuilderRef,
915 pub fn LLVMBuildLShr(B: BuilderRef,
920 pub fn LLVMBuildAShr(B: BuilderRef,
925 pub fn LLVMBuildAnd(B: BuilderRef,
930 pub fn LLVMBuildOr(B: BuilderRef,
935 pub fn LLVMBuildXor(B: BuilderRef,
940 pub fn LLVMBuildBinOp(B: BuilderRef,
946 pub fn LLVMBuildNeg(B: BuilderRef, V: ValueRef, Name: *const c_char) -> ValueRef;
947 pub fn LLVMBuildNSWNeg(B: BuilderRef, V: ValueRef, Name: *const c_char) -> ValueRef;
948 pub fn LLVMBuildNUWNeg(B: BuilderRef, V: ValueRef, Name: *const c_char) -> ValueRef;
949 pub fn LLVMBuildFNeg(B: BuilderRef, V: ValueRef, Name: *const c_char) -> ValueRef;
950 pub fn LLVMBuildNot(B: BuilderRef, V: ValueRef, Name: *const c_char) -> ValueRef;
951 pub fn LLVMRustSetHasUnsafeAlgebra(Instr: ValueRef);
954 pub fn LLVMBuildAlloca(B: BuilderRef, Ty: TypeRef, Name: *const c_char) -> ValueRef;
955 pub fn LLVMBuildFree(B: BuilderRef, PointerVal: ValueRef) -> ValueRef;
956 pub fn LLVMBuildLoad(B: BuilderRef, PointerVal: ValueRef, Name: *const c_char) -> ValueRef;
958 pub fn LLVMBuildStore(B: BuilderRef, Val: ValueRef, Ptr: ValueRef) -> ValueRef;
960 pub fn LLVMBuildGEP(B: BuilderRef,
962 Indices: *const ValueRef,
966 pub fn LLVMBuildInBoundsGEP(B: BuilderRef,
968 Indices: *const ValueRef,
972 pub fn LLVMBuildStructGEP(B: BuilderRef,
977 pub fn LLVMBuildGlobalString(B: BuilderRef,
981 pub fn LLVMBuildGlobalStringPtr(B: BuilderRef,
987 pub fn LLVMBuildTrunc(B: BuilderRef,
992 pub fn LLVMBuildZExt(B: BuilderRef,
997 pub fn LLVMBuildSExt(B: BuilderRef,
1000 Name: *const c_char)
1002 pub fn LLVMBuildFPToUI(B: BuilderRef,
1005 Name: *const c_char)
1007 pub fn LLVMBuildFPToSI(B: BuilderRef,
1010 Name: *const c_char)
1012 pub fn LLVMBuildUIToFP(B: BuilderRef,
1015 Name: *const c_char)
1017 pub fn LLVMBuildSIToFP(B: BuilderRef,
1020 Name: *const c_char)
1022 pub fn LLVMBuildFPTrunc(B: BuilderRef,
1025 Name: *const c_char)
1027 pub fn LLVMBuildFPExt(B: BuilderRef,
1030 Name: *const c_char)
1032 pub fn LLVMBuildPtrToInt(B: BuilderRef,
1035 Name: *const c_char)
1037 pub fn LLVMBuildIntToPtr(B: BuilderRef,
1040 Name: *const c_char)
1042 pub fn LLVMBuildBitCast(B: BuilderRef,
1045 Name: *const c_char)
1047 pub fn LLVMBuildZExtOrBitCast(B: BuilderRef,
1050 Name: *const c_char)
1052 pub fn LLVMBuildSExtOrBitCast(B: BuilderRef,
1055 Name: *const c_char)
1057 pub fn LLVMBuildTruncOrBitCast(B: BuilderRef,
1060 Name: *const c_char)
1062 pub fn LLVMBuildCast(B: BuilderRef,
1066 Name: *const c_char)
1068 pub fn LLVMBuildPointerCast(B: BuilderRef,
1071 Name: *const c_char)
1073 pub fn LLVMBuildIntCast(B: BuilderRef,
1076 Name: *const c_char)
1078 pub fn LLVMBuildFPCast(B: BuilderRef,
1081 Name: *const c_char)
1085 pub fn LLVMBuildICmp(B: BuilderRef,
1089 Name: *const c_char)
1091 pub fn LLVMBuildFCmp(B: BuilderRef,
1095 Name: *const c_char)
1098 // Miscellaneous instructions
1099 pub fn LLVMBuildPhi(B: BuilderRef, Ty: TypeRef, Name: *const c_char) -> ValueRef;
1100 pub fn LLVMRustBuildCall(B: BuilderRef,
1102 Args: *const ValueRef,
1104 Bundle: OperandBundleDefRef,
1105 Name: *const c_char)
1107 pub fn LLVMBuildSelect(B: BuilderRef,
1111 Name: *const c_char)
1113 pub fn LLVMBuildVAArg(B: BuilderRef,
1116 Name: *const c_char)
1118 pub fn LLVMBuildExtractElement(B: BuilderRef,
1121 Name: *const c_char)
1123 pub fn LLVMBuildInsertElement(B: BuilderRef,
1127 Name: *const c_char)
1129 pub fn LLVMBuildShuffleVector(B: BuilderRef,
1133 Name: *const c_char)
1135 pub fn LLVMBuildExtractValue(B: BuilderRef,
1138 Name: *const c_char)
1140 pub fn LLVMBuildInsertValue(B: BuilderRef,
1144 Name: *const c_char)
1147 pub fn LLVMBuildIsNull(B: BuilderRef, Val: ValueRef, Name: *const c_char) -> ValueRef;
1148 pub fn LLVMBuildIsNotNull(B: BuilderRef, Val: ValueRef, Name: *const c_char) -> ValueRef;
1149 pub fn LLVMBuildPtrDiff(B: BuilderRef,
1152 Name: *const c_char)
1155 // Atomic Operations
1156 pub fn LLVMRustBuildAtomicLoad(B: BuilderRef,
1157 PointerVal: ValueRef,
1158 Name: *const c_char,
1159 Order: AtomicOrdering,
1163 pub fn LLVMRustBuildAtomicStore(B: BuilderRef,
1166 Order: AtomicOrdering,
1170 pub fn LLVMRustBuildAtomicCmpXchg(B: BuilderRef,
1174 Order: AtomicOrdering,
1175 FailureOrder: AtomicOrdering,
1179 pub fn LLVMBuildAtomicRMW(B: BuilderRef,
1183 Order: AtomicOrdering,
1184 SingleThreaded: Bool)
1187 pub fn LLVMRustBuildAtomicFence(B: BuilderRef,
1188 Order: AtomicOrdering,
1189 Scope: SynchronizationScope);
1192 // Selected entries from the downcasts.
1193 pub fn LLVMIsATerminatorInst(Inst: ValueRef) -> ValueRef;
1194 pub fn LLVMIsAStoreInst(Inst: ValueRef) -> ValueRef;
1196 /// Writes a module to the specified path. Returns 0 on success.
1197 pub fn LLVMWriteBitcodeToFile(M: ModuleRef, Path: *const c_char) -> c_int;
1199 /// Creates target data from a target layout string.
1200 pub fn LLVMCreateTargetData(StringRep: *const c_char) -> TargetDataRef;
1201 /// Number of bytes clobbered when doing a Store to *T.
1202 pub fn LLVMSizeOfTypeInBits(TD: TargetDataRef, Ty: TypeRef) -> c_ulonglong;
1204 /// Distance between successive elements in an array of T. Includes ABI padding.
1205 pub fn LLVMABISizeOfType(TD: TargetDataRef, Ty: TypeRef) -> c_ulonglong;
1207 /// Returns the preferred alignment of a type.
1208 pub fn LLVMPreferredAlignmentOfType(TD: TargetDataRef, Ty: TypeRef) -> c_uint;
1209 /// Returns the minimum alignment of a type.
1210 pub fn LLVMABIAlignmentOfType(TD: TargetDataRef, Ty: TypeRef) -> c_uint;
1212 /// Computes the byte offset of the indexed struct element for a
1214 pub fn LLVMOffsetOfElement(TD: TargetDataRef,
1219 /// Disposes target data.
1220 pub fn LLVMDisposeTargetData(TD: TargetDataRef);
1222 /// Creates a pass manager.
1223 pub fn LLVMCreatePassManager() -> PassManagerRef;
1225 /// Creates a function-by-function pass manager
1226 pub fn LLVMCreateFunctionPassManagerForModule(M: ModuleRef) -> PassManagerRef;
1228 /// Disposes a pass manager.
1229 pub fn LLVMDisposePassManager(PM: PassManagerRef);
1231 /// Runs a pass manager on a module.
1232 pub fn LLVMRunPassManager(PM: PassManagerRef, M: ModuleRef) -> Bool;
1234 pub fn LLVMInitializePasses();
1236 pub fn LLVMPassManagerBuilderCreate() -> PassManagerBuilderRef;
1237 pub fn LLVMPassManagerBuilderDispose(PMB: PassManagerBuilderRef);
1238 pub fn LLVMPassManagerBuilderSetSizeLevel(PMB: PassManagerBuilderRef, Value: Bool);
1239 pub fn LLVMPassManagerBuilderSetDisableUnrollLoops(PMB: PassManagerBuilderRef, Value: Bool);
1240 pub fn LLVMPassManagerBuilderUseInlinerWithThreshold(PMB: PassManagerBuilderRef,
1242 pub fn LLVMPassManagerBuilderPopulateModulePassManager(PMB: PassManagerBuilderRef,
1243 PM: PassManagerRef);
1245 pub fn LLVMPassManagerBuilderPopulateFunctionPassManager(PMB: PassManagerBuilderRef,
1246 PM: PassManagerRef);
1247 pub fn LLVMPassManagerBuilderPopulateLTOPassManager(PMB: PassManagerBuilderRef,
1252 // Stuff that's in rustllvm/ because it's not upstream yet.
1254 /// Opens an object file.
1255 pub fn LLVMCreateObjectFile(MemBuf: MemoryBufferRef) -> ObjectFileRef;
1256 /// Closes an object file.
1257 pub fn LLVMDisposeObjectFile(ObjFile: ObjectFileRef);
1259 /// Enumerates the sections in an object file.
1260 pub fn LLVMGetSections(ObjFile: ObjectFileRef) -> SectionIteratorRef;
1261 /// Destroys a section iterator.
1262 pub fn LLVMDisposeSectionIterator(SI: SectionIteratorRef);
1263 /// Returns true if the section iterator is at the end of the section
1265 pub fn LLVMIsSectionIteratorAtEnd(ObjFile: ObjectFileRef, SI: SectionIteratorRef) -> Bool;
1266 /// Moves the section iterator to point to the next section.
1267 pub fn LLVMMoveToNextSection(SI: SectionIteratorRef);
1268 /// Returns the current section size.
1269 pub fn LLVMGetSectionSize(SI: SectionIteratorRef) -> c_ulonglong;
1270 /// Returns the current section contents as a string buffer.
1271 pub fn LLVMGetSectionContents(SI: SectionIteratorRef) -> *const c_char;
1273 /// Reads the given file and returns it as a memory buffer. Use
1274 /// LLVMDisposeMemoryBuffer() to get rid of it.
1275 pub fn LLVMRustCreateMemoryBufferWithContentsOfFile(Path: *const c_char) -> MemoryBufferRef;
1277 pub fn LLVMStartMultithreaded() -> Bool;
1279 /// Returns a string describing the last error caused by an LLVMRust* call.
1280 pub fn LLVMRustGetLastError() -> *const c_char;
1282 /// Print the pass timings since static dtors aren't picking them up.
1283 pub fn LLVMRustPrintPassTimings();
1285 pub fn LLVMStructCreateNamed(C: ContextRef, Name: *const c_char) -> TypeRef;
1287 pub fn LLVMStructSetBody(StructTy: TypeRef,
1288 ElementTypes: *const TypeRef,
1289 ElementCount: c_uint,
1292 pub fn LLVMConstNamedStruct(S: TypeRef,
1293 ConstantVals: *const ValueRef,
1297 /// Enables LLVM debug output.
1298 pub fn LLVMRustSetDebug(Enabled: c_int);
1300 /// Prepares inline assembly.
1301 pub fn LLVMRustInlineAsm(Ty: TypeRef,
1302 AsmString: *const c_char,
1303 Constraints: *const c_char,
1306 Dialect: AsmDialect)
1309 pub fn LLVMRustDebugMetadataVersion() -> u32;
1310 pub fn LLVMRustVersionMajor() -> u32;
1311 pub fn LLVMRustVersionMinor() -> u32;
1313 pub fn LLVMRustAddModuleFlag(M: ModuleRef, name: *const c_char, value: u32);
1315 pub fn LLVMRustDIBuilderCreate(M: ModuleRef) -> DIBuilderRef;
1317 pub fn LLVMRustDIBuilderDispose(Builder: DIBuilderRef);
1319 pub fn LLVMRustDIBuilderFinalize(Builder: DIBuilderRef);
1321 pub fn LLVMRustDIBuilderCreateCompileUnit(Builder: DIBuilderRef,
1323 File: *const c_char,
1325 Producer: *const c_char,
1327 Flags: *const c_char,
1329 SplitName: *const c_char)
1332 pub fn LLVMRustDIBuilderCreateFile(Builder: DIBuilderRef,
1333 Filename: *const c_char,
1334 Directory: *const c_char)
1337 pub fn LLVMRustDIBuilderCreateSubroutineType(Builder: DIBuilderRef,
1339 ParameterTypes: DIArray)
1342 pub fn LLVMRustDIBuilderCreateFunction(Builder: DIBuilderRef,
1343 Scope: DIDescriptor,
1344 Name: *const c_char,
1345 LinkageName: *const c_char,
1349 isLocalToUnit: bool,
1359 pub fn LLVMRustDIBuilderCreateBasicType(Builder: DIBuilderRef,
1360 Name: *const c_char,
1366 pub fn LLVMRustDIBuilderCreatePointerType(Builder: DIBuilderRef,
1370 Name: *const c_char)
1373 pub fn LLVMRustDIBuilderCreateStructType(Builder: DIBuilderRef,
1374 Scope: DIDescriptor,
1375 Name: *const c_char,
1381 DerivedFrom: DIType,
1383 RunTimeLang: c_uint,
1384 VTableHolder: DIType,
1385 UniqueId: *const c_char)
1388 pub fn LLVMRustDIBuilderCreateMemberType(Builder: DIBuilderRef,
1389 Scope: DIDescriptor,
1390 Name: *const c_char,
1400 pub fn LLVMRustDIBuilderCreateLexicalBlock(Builder: DIBuilderRef,
1407 pub fn LLVMRustDIBuilderCreateLexicalBlockFile(Builder: DIBuilderRef,
1412 pub fn LLVMRustDIBuilderCreateStaticVariable(Builder: DIBuilderRef,
1414 Name: *const c_char,
1415 LinkageName: *const c_char,
1419 isLocalToUnit: bool,
1423 -> DIGlobalVariable;
1425 pub fn LLVMRustDIBuilderCreateVariable(Builder: DIBuilderRef,
1427 Scope: DIDescriptor,
1428 Name: *const c_char,
1432 AlwaysPreserve: bool,
1438 pub fn LLVMRustDIBuilderCreateArrayType(Builder: DIBuilderRef,
1442 Subscripts: DIArray)
1445 pub fn LLVMRustDIBuilderCreateVectorType(Builder: DIBuilderRef,
1449 Subscripts: DIArray)
1452 pub fn LLVMRustDIBuilderGetOrCreateSubrange(Builder: DIBuilderRef,
1457 pub fn LLVMRustDIBuilderGetOrCreateArray(Builder: DIBuilderRef,
1458 Ptr: *const DIDescriptor,
1462 pub fn LLVMRustDIBuilderInsertDeclareAtEnd(Builder: DIBuilderRef,
1464 VarInfo: DIVariable,
1465 AddrOps: *const i64,
1466 AddrOpsCount: c_uint,
1468 InsertAtEnd: BasicBlockRef)
1471 pub fn LLVMRustDIBuilderCreateEnumerator(Builder: DIBuilderRef,
1472 Name: *const c_char,
1476 pub fn LLVMRustDIBuilderCreateEnumerationType(Builder: DIBuilderRef,
1478 Name: *const c_char,
1487 pub fn LLVMRustDIBuilderCreateUnionType(Builder: DIBuilderRef,
1489 Name: *const c_char,
1496 RunTimeLang: c_uint,
1497 UniqueId: *const c_char)
1500 pub fn LLVMSetUnnamedAddr(GlobalVar: ValueRef, UnnamedAddr: Bool);
1502 pub fn LLVMRustDIBuilderCreateTemplateTypeParameter(Builder: DIBuilderRef,
1504 Name: *const c_char,
1509 -> DITemplateTypeParameter;
1512 pub fn LLVMRustDIBuilderCreateNameSpace(Builder: DIBuilderRef,
1514 Name: *const c_char,
1518 pub fn LLVMRustDICompositeTypeSetTypeArray(Builder: DIBuilderRef,
1519 CompositeType: DIType,
1520 TypeArray: DIArray);
1523 pub fn LLVMRustDIBuilderCreateDebugLocation(Context: ContextRef,
1527 InlinedAt: MetadataRef)
1529 pub fn LLVMRustDIBuilderCreateOpDeref() -> i64;
1530 pub fn LLVMRustDIBuilderCreateOpPlus() -> i64;
1532 pub fn LLVMRustWriteTypeToString(Type: TypeRef, s: RustStringRef);
1533 pub fn LLVMRustWriteValueToString(value_ref: ValueRef, s: RustStringRef);
1535 pub fn LLVMIsAConstantInt(value_ref: ValueRef) -> ValueRef;
1537 pub fn LLVMRustPassKind(Pass: PassRef) -> PassKind;
1538 pub fn LLVMRustFindAndCreatePass(Pass: *const c_char) -> PassRef;
1539 pub fn LLVMRustAddPass(PM: PassManagerRef, Pass: PassRef);
1541 pub fn LLVMRustHasFeature(T: TargetMachineRef, s: *const c_char) -> bool;
1543 pub fn LLVMRustPrintTargetCPUs(T: TargetMachineRef);
1544 pub fn LLVMRustPrintTargetFeatures(T: TargetMachineRef);
1546 pub fn LLVMRustCreateTargetMachine(Triple: *const c_char,
1548 Features: *const c_char,
1551 Level: CodeGenOptLevel,
1553 PositionIndependentExecutable: bool,
1554 FunctionSections: bool,
1556 -> TargetMachineRef;
1557 pub fn LLVMRustDisposeTargetMachine(T: TargetMachineRef);
1558 pub fn LLVMRustAddAnalysisPasses(T: TargetMachineRef, PM: PassManagerRef, M: ModuleRef);
1559 pub fn LLVMRustAddBuilderLibraryInfo(PMB: PassManagerBuilderRef,
1561 DisableSimplifyLibCalls: bool);
1562 pub fn LLVMRustConfigurePassManagerBuilder(PMB: PassManagerBuilderRef,
1563 OptLevel: CodeGenOptLevel,
1564 MergeFunctions: bool,
1566 LoopVectorize: bool);
1567 pub fn LLVMRustAddLibraryInfo(PM: PassManagerRef,
1569 DisableSimplifyLibCalls: bool);
1570 pub fn LLVMRustRunFunctionPassManager(PM: PassManagerRef, M: ModuleRef);
1571 pub fn LLVMRustWriteOutputFile(T: TargetMachineRef,
1574 Output: *const c_char,
1577 pub fn LLVMRustPrintModule(PM: PassManagerRef, M: ModuleRef, Output: *const c_char);
1578 pub fn LLVMRustSetLLVMOptions(Argc: c_int, Argv: *const *const c_char);
1579 pub fn LLVMRustPrintPasses();
1580 pub fn LLVMRustSetNormalizedTarget(M: ModuleRef, triple: *const c_char);
1581 pub fn LLVMRustAddAlwaysInlinePass(P: PassManagerBuilderRef, AddLifetimes: bool);
1582 pub fn LLVMRustLinkInExternalBitcode(M: ModuleRef, bc: *const c_char, len: size_t) -> bool;
1583 pub fn LLVMRustRunRestrictionPass(M: ModuleRef, syms: *const *const c_char, len: size_t);
1584 pub fn LLVMRustMarkAllFunctionsNounwind(M: ModuleRef);
1586 pub fn LLVMRustOpenArchive(path: *const c_char) -> ArchiveRef;
1587 pub fn LLVMRustArchiveIteratorNew(AR: ArchiveRef) -> ArchiveIteratorRef;
1588 pub fn LLVMRustArchiveIteratorNext(AIR: ArchiveIteratorRef) -> ArchiveChildRef;
1589 pub fn LLVMRustArchiveChildName(ACR: ArchiveChildRef, size: *mut size_t) -> *const c_char;
1590 pub fn LLVMRustArchiveChildData(ACR: ArchiveChildRef, size: *mut size_t) -> *const c_char;
1591 pub fn LLVMRustArchiveChildFree(ACR: ArchiveChildRef);
1592 pub fn LLVMRustArchiveIteratorFree(AIR: ArchiveIteratorRef);
1593 pub fn LLVMRustDestroyArchive(AR: ArchiveRef);
1595 pub fn LLVMRustGetSectionName(SI: SectionIteratorRef, data: *mut *const c_char) -> size_t;
1597 pub fn LLVMRustWriteTwineToString(T: TwineRef, s: RustStringRef);
1599 pub fn LLVMContextSetDiagnosticHandler(C: ContextRef,
1600 Handler: DiagnosticHandler,
1601 DiagnosticContext: *mut c_void);
1603 pub fn LLVMRustUnpackOptimizationDiagnostic(DI: DiagnosticInfoRef,
1604 pass_name_out: RustStringRef,
1605 function_out: *mut ValueRef,
1606 debugloc_out: *mut DebugLocRef,
1607 message_out: RustStringRef);
1608 pub fn LLVMRustUnpackInlineAsmDiagnostic(DI: DiagnosticInfoRef,
1609 cookie_out: *mut c_uint,
1610 message_out: *mut TwineRef,
1611 instruction_out: *mut ValueRef);
1613 pub fn LLVMRustWriteDiagnosticInfoToString(DI: DiagnosticInfoRef, s: RustStringRef);
1614 pub fn LLVMRustGetDiagInfoKind(DI: DiagnosticInfoRef) -> DiagnosticKind;
1616 pub fn LLVMRustWriteDebugLocToString(C: ContextRef, DL: DebugLocRef, s: RustStringRef);
1618 pub fn LLVMRustSetInlineAsmDiagnosticHandler(C: ContextRef,
1619 H: InlineAsmDiagHandler,
1622 pub fn LLVMRustWriteSMDiagnosticToString(d: SMDiagnosticRef, s: RustStringRef);
1624 pub fn LLVMRustWriteArchive(Dst: *const c_char,
1626 Members: *const RustArchiveMemberRef,
1630 pub fn LLVMRustArchiveMemberNew(Filename: *const c_char,
1631 Name: *const c_char,
1632 Child: ArchiveChildRef)
1633 -> RustArchiveMemberRef;
1634 pub fn LLVMRustArchiveMemberFree(Member: RustArchiveMemberRef);
1636 pub fn LLVMRustSetDataLayoutFromTargetMachine(M: ModuleRef, TM: TargetMachineRef);
1637 pub fn LLVMRustGetModuleDataLayout(M: ModuleRef) -> TargetDataRef;
1639 pub fn LLVMRustBuildOperandBundleDef(Name: *const c_char,
1640 Inputs: *const ValueRef,
1642 -> OperandBundleDefRef;
1643 pub fn LLVMRustFreeOperandBundleDef(Bundle: OperandBundleDefRef);
1645 pub fn LLVMRustPositionBuilderAtStart(B: BuilderRef, BB: BasicBlockRef);
1647 pub fn LLVMRustSetComdat(M: ModuleRef, V: ValueRef, Name: *const c_char);
1648 pub fn LLVMRustUnsetComdat(V: ValueRef);
1649 pub fn LLVMRustSetModulePIELevel(M: ModuleRef);
1653 // LLVM requires symbols from this library, but apparently they're not printed
1654 // during llvm-config?
1656 #[link(name = "ole32")]