1 // Copyright 2012-2014 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 #![allow(non_uppercase_statics)]
12 #![allow(non_camel_case_types)]
13 #![allow(non_snake_case)]
16 #![crate_name = "rustc_llvm"]
18 #![license = "MIT/ASL2"]
19 #![crate_type = "dylib"]
20 #![crate_type = "rlib"]
21 #![doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
22 html_favicon_url = "http://www.rust-lang.org/favicon.ico",
23 html_root_url = "http://doc.rust-lang.org/")]
26 #![feature(link_args)]
30 use std::c_str::ToCStr;
31 use std::cell::RefCell;
33 use libc::{c_uint, c_ushort, uint64_t, c_int, size_t, c_char};
34 use libc::{c_longlong, c_ulonglong, c_void};
35 use debuginfo::{DIBuilderRef, DIDescriptor,
36 DIFile, DILexicalBlock, DISubprogram, DIType,
37 DIBasicType, DIDerivedType, DICompositeType,
38 DIVariable, DIGlobalVariable, DIArray, DISubrange};
43 pub type Opcode = u32;
44 pub type Bool = c_uint;
46 pub static True: Bool = 1 as Bool;
47 pub static False: Bool = 0 as Bool;
49 // Consts for the LLVM CallConv type, pre-cast to uint.
51 #[deriving(PartialEq)]
56 X86StdcallCallConv = 64,
57 X86FastcallCallConv = 65,
62 LLVMDefaultVisibility = 0,
64 ProtectedVisibility = 2,
67 // This enum omits the obsolete (and no-op) linkage types DLLImportLinkage,
68 // DLLExportLinkage, GhostLinkage and LinkOnceODRAutoHideLinkage.
69 // LinkerPrivateLinkage and LinkerPrivateWeakLinkage are not included either;
70 // they've been removed in upstream LLVM commit r203866.
73 AvailableExternallyLinkage = 1,
74 LinkOnceAnyLinkage = 2,
75 LinkOnceODRLinkage = 3,
81 ExternalWeakLinkage = 12,
87 pub enum DiagnosticSeverity {
96 ZExtAttribute = 1 << 0,
97 SExtAttribute = 1 << 1,
98 NoReturnAttribute = 1 << 2,
99 InRegAttribute = 1 << 3,
100 StructRetAttribute = 1 << 4,
101 NoUnwindAttribute = 1 << 5,
102 NoAliasAttribute = 1 << 6,
103 ByValAttribute = 1 << 7,
104 NestAttribute = 1 << 8,
105 ReadNoneAttribute = 1 << 9,
106 ReadOnlyAttribute = 1 << 10,
107 NoInlineAttribute = 1 << 11,
108 AlwaysInlineAttribute = 1 << 12,
109 OptimizeForSizeAttribute = 1 << 13,
110 StackProtectAttribute = 1 << 14,
111 StackProtectReqAttribute = 1 << 15,
112 AlignmentAttribute = 31 << 16,
113 NoCaptureAttribute = 1 << 21,
114 NoRedZoneAttribute = 1 << 22,
115 NoImplicitFloatAttribute = 1 << 23,
116 NakedAttribute = 1 << 24,
117 InlineHintAttribute = 1 << 25,
118 StackAttribute = 7 << 26,
119 ReturnsTwiceAttribute = 1 << 29,
120 UWTableAttribute = 1 << 30,
121 NonLazyBindAttribute = 1 << 31,
125 pub enum OtherAttribute {
126 // The following are not really exposed in
127 // the LLVM c api so instead to add these
128 // we call a wrapper function in RustWrapper
129 // that uses the C++ api.
130 SanitizeAddressAttribute = 1 << 32,
131 MinSizeAttribute = 1 << 33,
132 NoDuplicateAttribute = 1 << 34,
133 StackProtectStrongAttribute = 1 << 35,
134 SanitizeThreadAttribute = 1 << 36,
135 SanitizeMemoryAttribute = 1 << 37,
136 NoBuiltinAttribute = 1 << 38,
137 ReturnedAttribute = 1 << 39,
138 ColdAttribute = 1 << 40,
139 BuiltinAttribute = 1 << 41,
140 OptimizeNoneAttribute = 1 << 42,
141 InAllocaAttribute = 1 << 43,
142 NonNullAttribute = 1 << 44,
145 pub enum SpecialAttribute {
146 DereferenceableAttribute(u64)
150 pub enum AttributeSet {
156 fn apply_llfn(&self, idx: c_uint, llfn: ValueRef);
157 fn apply_callsite(&self, idx: c_uint, callsite: ValueRef);
160 impl AttrHelper for Attribute {
161 fn apply_llfn(&self, idx: c_uint, llfn: ValueRef) {
163 LLVMAddFunctionAttribute(llfn, idx, *self as uint64_t);
167 fn apply_callsite(&self, idx: c_uint, callsite: ValueRef) {
169 LLVMAddCallSiteAttribute(callsite, idx, *self as uint64_t);
174 impl AttrHelper for OtherAttribute {
175 fn apply_llfn(&self, idx: c_uint, llfn: ValueRef) {
177 LLVMAddFunctionAttribute(llfn, idx, *self as uint64_t);
181 fn apply_callsite(&self, idx: c_uint, callsite: ValueRef) {
183 LLVMAddCallSiteAttribute(callsite, idx, *self as uint64_t);
188 impl AttrHelper for SpecialAttribute {
189 fn apply_llfn(&self, idx: c_uint, llfn: ValueRef) {
191 DereferenceableAttribute(bytes) => unsafe {
192 LLVMAddDereferenceableAttr(llfn, idx, bytes as uint64_t);
197 fn apply_callsite(&self, idx: c_uint, callsite: ValueRef) {
199 DereferenceableAttribute(bytes) => unsafe {
200 LLVMAddDereferenceableCallSiteAttr(callsite, idx, bytes as uint64_t);
206 pub struct AttrBuilder {
207 attrs: Vec<(uint, Box<AttrHelper+'static>)>
211 pub fn new() -> AttrBuilder {
217 pub fn arg<'a, T: AttrHelper + 'static>(&'a mut self, idx: uint, a: T) -> &'a mut AttrBuilder {
218 self.attrs.push((idx, box a as Box<AttrHelper+'static>));
222 pub fn ret<'a, T: AttrHelper + 'static>(&'a mut self, a: T) -> &'a mut AttrBuilder {
223 self.attrs.push((ReturnIndex as uint, box a as Box<AttrHelper+'static>));
227 pub fn apply_llfn(&self, llfn: ValueRef) {
228 for &(idx, ref attr) in self.attrs.iter() {
229 attr.apply_llfn(idx as c_uint, llfn);
233 pub fn apply_callsite(&self, callsite: ValueRef) {
234 for &(idx, ref attr) in self.attrs.iter() {
235 attr.apply_callsite(idx as c_uint, callsite);
240 // enum for the LLVM IntPredicate type
241 pub enum IntPredicate {
254 // enum for the LLVM RealPredicate type
255 pub enum RealPredicate {
256 RealPredicateFalse = 0,
271 RealPredicateTrue = 15,
274 // The LLVM TypeKind type - must stay in sync with the def of
275 // LLVMTypeKind in llvm/include/llvm-c/Core.h
276 #[deriving(PartialEq)]
298 pub enum AtomicBinOp {
313 pub enum AtomicOrdering {
317 // Consume = 3, // Not specified yet.
321 SequentiallyConsistent = 7
324 // Consts for the LLVMCodeGenFileType type (in include/llvm/c/TargetMachine.h)
340 // Inline Asm Dialect
341 pub enum AsmDialect {
346 #[deriving(PartialEq, Clone)]
348 pub enum CodeGenOptLevel {
349 CodeGenLevelNone = 0,
350 CodeGenLevelLess = 1,
351 CodeGenLevelDefault = 2,
352 CodeGenLevelAggressive = 3,
360 RelocDynamicNoPic = 3,
364 pub enum CodeGenModel {
365 CodeModelDefault = 0,
366 CodeModelJITDefault = 1,
374 pub enum DiagnosticKind {
377 DK_DebugMetadataVersion,
379 DK_OptimizationRemark,
380 DK_OptimizationRemarkMissed,
381 DK_OptimizationRemarkAnalysis,
382 DK_OptimizationFailure,
385 // Opaque pointer types
386 pub enum Module_opaque {}
387 pub type ModuleRef = *mut Module_opaque;
388 pub enum Context_opaque {}
389 pub type ContextRef = *mut Context_opaque;
390 pub enum Type_opaque {}
391 pub type TypeRef = *mut Type_opaque;
392 pub enum Value_opaque {}
393 pub type ValueRef = *mut Value_opaque;
394 pub enum BasicBlock_opaque {}
395 pub type BasicBlockRef = *mut BasicBlock_opaque;
396 pub enum Builder_opaque {}
397 pub type BuilderRef = *mut Builder_opaque;
398 pub enum ExecutionEngine_opaque {}
399 pub type ExecutionEngineRef = *mut ExecutionEngine_opaque;
400 pub enum MemoryBuffer_opaque {}
401 pub type MemoryBufferRef = *mut MemoryBuffer_opaque;
402 pub enum PassManager_opaque {}
403 pub type PassManagerRef = *mut PassManager_opaque;
404 pub enum PassManagerBuilder_opaque {}
405 pub type PassManagerBuilderRef = *mut PassManagerBuilder_opaque;
406 pub enum Use_opaque {}
407 pub type UseRef = *mut Use_opaque;
408 pub enum TargetData_opaque {}
409 pub type TargetDataRef = *mut TargetData_opaque;
410 pub enum ObjectFile_opaque {}
411 pub type ObjectFileRef = *mut ObjectFile_opaque;
412 pub enum SectionIterator_opaque {}
413 pub type SectionIteratorRef = *mut SectionIterator_opaque;
414 pub enum Pass_opaque {}
415 pub type PassRef = *mut Pass_opaque;
416 pub enum TargetMachine_opaque {}
417 pub type TargetMachineRef = *mut TargetMachine_opaque;
418 pub enum Archive_opaque {}
419 pub type ArchiveRef = *mut Archive_opaque;
420 pub enum Twine_opaque {}
421 pub type TwineRef = *mut Twine_opaque;
422 pub enum DiagnosticInfo_opaque {}
423 pub type DiagnosticInfoRef = *mut DiagnosticInfo_opaque;
424 pub enum DebugLoc_opaque {}
425 pub type DebugLocRef = *mut DebugLoc_opaque;
427 pub type DiagnosticHandler = unsafe extern "C" fn(DiagnosticInfoRef, *mut c_void);
430 use super::{ValueRef};
432 pub enum DIBuilder_opaque {}
433 pub type DIBuilderRef = *mut DIBuilder_opaque;
435 pub type DIDescriptor = ValueRef;
436 pub type DIScope = DIDescriptor;
437 pub type DILocation = DIDescriptor;
438 pub type DIFile = DIScope;
439 pub type DILexicalBlock = DIScope;
440 pub type DISubprogram = DIScope;
441 pub type DIType = DIDescriptor;
442 pub type DIBasicType = DIType;
443 pub type DIDerivedType = DIType;
444 pub type DICompositeType = DIDerivedType;
445 pub type DIVariable = DIDescriptor;
446 pub type DIGlobalVariable = DIDescriptor;
447 pub type DIArray = DIDescriptor;
448 pub type DISubrange = DIDescriptor;
450 pub enum DIDescriptorFlags {
451 FlagPrivate = 1 << 0,
452 FlagProtected = 1 << 1,
453 FlagFwdDecl = 1 << 2,
454 FlagAppleBlock = 1 << 3,
455 FlagBlockByrefStruct = 1 << 4,
456 FlagVirtual = 1 << 5,
457 FlagArtificial = 1 << 6,
458 FlagExplicit = 1 << 7,
459 FlagPrototyped = 1 << 8,
460 FlagObjcClassComplete = 1 << 9,
461 FlagObjectPointer = 1 << 10,
462 FlagVector = 1 << 11,
463 FlagStaticMember = 1 << 12,
464 FlagIndirectVariable = 1 << 13,
465 FlagLValueReference = 1 << 14,
466 FlagRValueReference = 1 << 15
471 // Link to our native llvm bindings (things that we need to use the C++ api
472 // for) and because llvm is written in C++ we need to link against libstdc++
474 // You'll probably notice that there is an omission of all LLVM libraries
475 // from this location. This is because the set of LLVM libraries that we
476 // link to is mostly defined by LLVM, and the `llvm-config` tool is used to
477 // figure out the exact set of libraries. To do this, the build system
478 // generates an llvmdeps.rs file next to this one which will be
479 // automatically updated whenever LLVM is updated to include an up-to-date
480 // set of the libraries we need to link to LLVM for.
481 #[link(name = "rustllvm", kind = "static")]
483 /* Create and destroy contexts. */
484 pub fn LLVMContextCreate() -> ContextRef;
485 pub fn LLVMContextDispose(C: ContextRef);
486 pub fn LLVMGetMDKindIDInContext(C: ContextRef,
491 /* Create and destroy modules. */
492 pub fn LLVMModuleCreateWithNameInContext(ModuleID: *const c_char,
495 pub fn LLVMGetModuleContext(M: ModuleRef) -> ContextRef;
496 pub fn LLVMDisposeModule(M: ModuleRef);
498 /** Data layout. See Module::getDataLayout. */
499 pub fn LLVMGetDataLayout(M: ModuleRef) -> *const c_char;
500 pub fn LLVMSetDataLayout(M: ModuleRef, Triple: *const c_char);
502 /** Target triple. See Module::getTargetTriple. */
503 pub fn LLVMGetTarget(M: ModuleRef) -> *const c_char;
504 pub fn LLVMSetTarget(M: ModuleRef, Triple: *const c_char);
506 /** See Module::dump. */
507 pub fn LLVMDumpModule(M: ModuleRef);
509 /** See Module::setModuleInlineAsm. */
510 pub fn LLVMSetModuleInlineAsm(M: ModuleRef, Asm: *const c_char);
512 /** See llvm::LLVMTypeKind::getTypeID. */
513 pub fn LLVMGetTypeKind(Ty: TypeRef) -> TypeKind;
515 /** See llvm::LLVMType::getContext. */
516 pub fn LLVMGetTypeContext(Ty: TypeRef) -> ContextRef;
518 /* Operations on integer types */
519 pub fn LLVMInt1TypeInContext(C: ContextRef) -> TypeRef;
520 pub fn LLVMInt8TypeInContext(C: ContextRef) -> TypeRef;
521 pub fn LLVMInt16TypeInContext(C: ContextRef) -> TypeRef;
522 pub fn LLVMInt32TypeInContext(C: ContextRef) -> TypeRef;
523 pub fn LLVMInt64TypeInContext(C: ContextRef) -> TypeRef;
524 pub fn LLVMIntTypeInContext(C: ContextRef, NumBits: c_uint)
527 pub fn LLVMGetIntTypeWidth(IntegerTy: TypeRef) -> c_uint;
529 /* Operations on real types */
530 pub fn LLVMFloatTypeInContext(C: ContextRef) -> TypeRef;
531 pub fn LLVMDoubleTypeInContext(C: ContextRef) -> TypeRef;
532 pub fn LLVMX86FP80TypeInContext(C: ContextRef) -> TypeRef;
533 pub fn LLVMFP128TypeInContext(C: ContextRef) -> TypeRef;
534 pub fn LLVMPPCFP128TypeInContext(C: ContextRef) -> TypeRef;
536 /* Operations on function types */
537 pub fn LLVMFunctionType(ReturnType: TypeRef,
538 ParamTypes: *const TypeRef,
542 pub fn LLVMIsFunctionVarArg(FunctionTy: TypeRef) -> Bool;
543 pub fn LLVMGetReturnType(FunctionTy: TypeRef) -> TypeRef;
544 pub fn LLVMCountParamTypes(FunctionTy: TypeRef) -> c_uint;
545 pub fn LLVMGetParamTypes(FunctionTy: TypeRef, Dest: *const TypeRef);
547 /* Operations on struct types */
548 pub fn LLVMStructTypeInContext(C: ContextRef,
549 ElementTypes: *const TypeRef,
550 ElementCount: c_uint,
553 pub fn LLVMCountStructElementTypes(StructTy: TypeRef) -> c_uint;
554 pub fn LLVMGetStructElementTypes(StructTy: TypeRef,
556 pub fn LLVMIsPackedStruct(StructTy: TypeRef) -> Bool;
558 /* Operations on array, pointer, and vector types (sequence types) */
559 pub fn LLVMRustArrayType(ElementType: TypeRef, ElementCount: u64) -> TypeRef;
560 pub fn LLVMPointerType(ElementType: TypeRef, AddressSpace: c_uint)
562 pub fn LLVMVectorType(ElementType: TypeRef, ElementCount: c_uint)
565 pub fn LLVMGetElementType(Ty: TypeRef) -> TypeRef;
566 pub fn LLVMGetArrayLength(ArrayTy: TypeRef) -> c_uint;
567 pub fn LLVMGetPointerAddressSpace(PointerTy: TypeRef) -> c_uint;
568 pub fn LLVMGetPointerToGlobal(EE: ExecutionEngineRef, V: ValueRef)
570 pub fn LLVMGetVectorSize(VectorTy: TypeRef) -> c_uint;
572 /* Operations on other types */
573 pub fn LLVMVoidTypeInContext(C: ContextRef) -> TypeRef;
574 pub fn LLVMLabelTypeInContext(C: ContextRef) -> TypeRef;
575 pub fn LLVMMetadataTypeInContext(C: ContextRef) -> TypeRef;
577 /* Operations on all values */
578 pub fn LLVMTypeOf(Val: ValueRef) -> TypeRef;
579 pub fn LLVMGetValueName(Val: ValueRef) -> *const c_char;
580 pub fn LLVMSetValueName(Val: ValueRef, Name: *const c_char);
581 pub fn LLVMDumpValue(Val: ValueRef);
582 pub fn LLVMReplaceAllUsesWith(OldVal: ValueRef, NewVal: ValueRef);
583 pub fn LLVMHasMetadata(Val: ValueRef) -> c_int;
584 pub fn LLVMGetMetadata(Val: ValueRef, KindID: c_uint) -> ValueRef;
585 pub fn LLVMSetMetadata(Val: ValueRef, KindID: c_uint, Node: ValueRef);
587 /* Operations on Uses */
588 pub fn LLVMGetFirstUse(Val: ValueRef) -> UseRef;
589 pub fn LLVMGetNextUse(U: UseRef) -> UseRef;
590 pub fn LLVMGetUser(U: UseRef) -> ValueRef;
591 pub fn LLVMGetUsedValue(U: UseRef) -> ValueRef;
593 /* Operations on Users */
594 pub fn LLVMGetNumOperands(Val: ValueRef) -> c_int;
595 pub fn LLVMGetOperand(Val: ValueRef, Index: c_uint) -> ValueRef;
596 pub fn LLVMSetOperand(Val: ValueRef, Index: c_uint, Op: ValueRef);
598 /* Operations on constants of any type */
599 pub fn LLVMConstNull(Ty: TypeRef) -> ValueRef;
601 pub fn LLVMConstAllOnes(Ty: TypeRef) -> ValueRef;
602 pub fn LLVMConstICmp(Pred: c_ushort, V1: ValueRef, V2: ValueRef)
604 pub fn LLVMConstFCmp(Pred: c_ushort, V1: ValueRef, V2: ValueRef)
606 /* only for int/vector */
607 pub fn LLVMGetUndef(Ty: TypeRef) -> ValueRef;
608 pub fn LLVMIsConstant(Val: ValueRef) -> Bool;
609 pub fn LLVMIsNull(Val: ValueRef) -> Bool;
610 pub fn LLVMIsUndef(Val: ValueRef) -> Bool;
611 pub fn LLVMConstPointerNull(Ty: TypeRef) -> ValueRef;
613 /* Operations on metadata */
614 pub fn LLVMMDStringInContext(C: ContextRef,
618 pub fn LLVMMDNodeInContext(C: ContextRef,
619 Vals: *const ValueRef,
622 pub fn LLVMAddNamedMetadataOperand(M: ModuleRef,
626 /* Operations on scalar constants */
627 pub fn LLVMConstInt(IntTy: TypeRef, N: c_ulonglong, SignExtend: Bool)
629 pub fn LLVMConstIntOfString(IntTy: TypeRef, Text: *const c_char, Radix: u8)
631 pub fn LLVMConstIntOfStringAndSize(IntTy: TypeRef,
636 pub fn LLVMConstReal(RealTy: TypeRef, N: f64) -> ValueRef;
637 pub fn LLVMConstRealOfString(RealTy: TypeRef, Text: *const c_char)
639 pub fn LLVMConstRealOfStringAndSize(RealTy: TypeRef,
643 pub fn LLVMConstIntGetZExtValue(ConstantVal: ValueRef) -> c_ulonglong;
644 pub fn LLVMConstIntGetSExtValue(ConstantVal: ValueRef) -> c_longlong;
647 /* Operations on composite constants */
648 pub fn LLVMConstStringInContext(C: ContextRef,
651 DontNullTerminate: Bool)
653 pub fn LLVMConstStructInContext(C: ContextRef,
654 ConstantVals: *const ValueRef,
659 pub fn LLVMConstArray(ElementTy: TypeRef,
660 ConstantVals: *const ValueRef,
663 pub fn LLVMConstVector(ScalarConstantVals: *const ValueRef, Size: c_uint)
666 /* Constant expressions */
667 pub fn LLVMAlignOf(Ty: TypeRef) -> ValueRef;
668 pub fn LLVMSizeOf(Ty: TypeRef) -> ValueRef;
669 pub fn LLVMConstNeg(ConstantVal: ValueRef) -> ValueRef;
670 pub fn LLVMConstNSWNeg(ConstantVal: ValueRef) -> ValueRef;
671 pub fn LLVMConstNUWNeg(ConstantVal: ValueRef) -> ValueRef;
672 pub fn LLVMConstFNeg(ConstantVal: ValueRef) -> ValueRef;
673 pub fn LLVMConstNot(ConstantVal: ValueRef) -> ValueRef;
674 pub fn LLVMConstAdd(LHSConstant: ValueRef, RHSConstant: ValueRef)
676 pub fn LLVMConstNSWAdd(LHSConstant: ValueRef, RHSConstant: ValueRef)
678 pub fn LLVMConstNUWAdd(LHSConstant: ValueRef, RHSConstant: ValueRef)
680 pub fn LLVMConstFAdd(LHSConstant: ValueRef, RHSConstant: ValueRef)
682 pub fn LLVMConstSub(LHSConstant: ValueRef, RHSConstant: ValueRef)
684 pub fn LLVMConstNSWSub(LHSConstant: ValueRef, RHSConstant: ValueRef)
686 pub fn LLVMConstNUWSub(LHSConstant: ValueRef, RHSConstant: ValueRef)
688 pub fn LLVMConstFSub(LHSConstant: ValueRef, RHSConstant: ValueRef)
690 pub fn LLVMConstMul(LHSConstant: ValueRef, RHSConstant: ValueRef)
692 pub fn LLVMConstNSWMul(LHSConstant: ValueRef, RHSConstant: ValueRef)
694 pub fn LLVMConstNUWMul(LHSConstant: ValueRef, RHSConstant: ValueRef)
696 pub fn LLVMConstFMul(LHSConstant: ValueRef, RHSConstant: ValueRef)
698 pub fn LLVMConstUDiv(LHSConstant: ValueRef, RHSConstant: ValueRef)
700 pub fn LLVMConstSDiv(LHSConstant: ValueRef, RHSConstant: ValueRef)
702 pub fn LLVMConstExactSDiv(LHSConstant: ValueRef,
703 RHSConstant: ValueRef)
705 pub fn LLVMConstFDiv(LHSConstant: ValueRef, RHSConstant: ValueRef)
707 pub fn LLVMConstURem(LHSConstant: ValueRef, RHSConstant: ValueRef)
709 pub fn LLVMConstSRem(LHSConstant: ValueRef, RHSConstant: ValueRef)
711 pub fn LLVMConstFRem(LHSConstant: ValueRef, RHSConstant: ValueRef)
713 pub fn LLVMConstAnd(LHSConstant: ValueRef, RHSConstant: ValueRef)
715 pub fn LLVMConstOr(LHSConstant: ValueRef, RHSConstant: ValueRef)
717 pub fn LLVMConstXor(LHSConstant: ValueRef, RHSConstant: ValueRef)
719 pub fn LLVMConstShl(LHSConstant: ValueRef, RHSConstant: ValueRef)
721 pub fn LLVMConstLShr(LHSConstant: ValueRef, RHSConstant: ValueRef)
723 pub fn LLVMConstAShr(LHSConstant: ValueRef, RHSConstant: ValueRef)
725 pub fn LLVMConstGEP(ConstantVal: ValueRef,
726 ConstantIndices: *const ValueRef,
729 pub fn LLVMConstInBoundsGEP(ConstantVal: ValueRef,
730 ConstantIndices: *const ValueRef,
733 pub fn LLVMConstTrunc(ConstantVal: ValueRef, ToType: TypeRef)
735 pub fn LLVMConstSExt(ConstantVal: ValueRef, ToType: TypeRef)
737 pub fn LLVMConstZExt(ConstantVal: ValueRef, ToType: TypeRef)
739 pub fn LLVMConstFPTrunc(ConstantVal: ValueRef, ToType: TypeRef)
741 pub fn LLVMConstFPExt(ConstantVal: ValueRef, ToType: TypeRef)
743 pub fn LLVMConstUIToFP(ConstantVal: ValueRef, ToType: TypeRef)
745 pub fn LLVMConstSIToFP(ConstantVal: ValueRef, ToType: TypeRef)
747 pub fn LLVMConstFPToUI(ConstantVal: ValueRef, ToType: TypeRef)
749 pub fn LLVMConstFPToSI(ConstantVal: ValueRef, ToType: TypeRef)
751 pub fn LLVMConstPtrToInt(ConstantVal: ValueRef, ToType: TypeRef)
753 pub fn LLVMConstIntToPtr(ConstantVal: ValueRef, ToType: TypeRef)
755 pub fn LLVMConstBitCast(ConstantVal: ValueRef, ToType: TypeRef)
757 pub fn LLVMConstZExtOrBitCast(ConstantVal: ValueRef, ToType: TypeRef)
759 pub fn LLVMConstSExtOrBitCast(ConstantVal: ValueRef, ToType: TypeRef)
761 pub fn LLVMConstTruncOrBitCast(ConstantVal: ValueRef, ToType: TypeRef)
763 pub fn LLVMConstPointerCast(ConstantVal: ValueRef, ToType: TypeRef)
765 pub fn LLVMConstIntCast(ConstantVal: ValueRef,
769 pub fn LLVMConstFPCast(ConstantVal: ValueRef, ToType: TypeRef)
771 pub fn LLVMConstSelect(ConstantCondition: ValueRef,
772 ConstantIfTrue: ValueRef,
773 ConstantIfFalse: ValueRef)
775 pub fn LLVMConstExtractElement(VectorConstant: ValueRef,
776 IndexConstant: ValueRef)
778 pub fn LLVMConstInsertElement(VectorConstant: ValueRef,
779 ElementValueConstant: ValueRef,
780 IndexConstant: ValueRef)
782 pub fn LLVMConstShuffleVector(VectorAConstant: ValueRef,
783 VectorBConstant: ValueRef,
784 MaskConstant: ValueRef)
786 pub fn LLVMConstExtractValue(AggConstant: ValueRef,
787 IdxList: *const c_uint,
790 pub fn LLVMConstInsertValue(AggConstant: ValueRef,
791 ElementValueConstant: ValueRef,
792 IdxList: *const c_uint,
795 pub fn LLVMConstInlineAsm(Ty: TypeRef,
796 AsmString: *const c_char,
797 Constraints: *const c_char,
798 HasSideEffects: Bool,
801 pub fn LLVMBlockAddress(F: ValueRef, BB: BasicBlockRef) -> ValueRef;
805 /* Operations on global variables, functions, and aliases (globals) */
806 pub fn LLVMGetGlobalParent(Global: ValueRef) -> ModuleRef;
807 pub fn LLVMIsDeclaration(Global: ValueRef) -> Bool;
808 pub fn LLVMGetLinkage(Global: ValueRef) -> c_uint;
809 pub fn LLVMSetLinkage(Global: ValueRef, Link: c_uint);
810 pub fn LLVMGetSection(Global: ValueRef) -> *const c_char;
811 pub fn LLVMSetSection(Global: ValueRef, Section: *const c_char);
812 pub fn LLVMGetVisibility(Global: ValueRef) -> c_uint;
813 pub fn LLVMSetVisibility(Global: ValueRef, Viz: c_uint);
814 pub fn LLVMGetAlignment(Global: ValueRef) -> c_uint;
815 pub fn LLVMSetAlignment(Global: ValueRef, Bytes: c_uint);
818 /* Operations on global variables */
819 pub fn LLVMAddGlobal(M: ModuleRef, Ty: TypeRef, Name: *const c_char)
821 pub fn LLVMAddGlobalInAddressSpace(M: ModuleRef,
824 AddressSpace: c_uint)
826 pub fn LLVMGetNamedGlobal(M: ModuleRef, Name: *const c_char) -> ValueRef;
827 pub fn LLVMGetFirstGlobal(M: ModuleRef) -> ValueRef;
828 pub fn LLVMGetLastGlobal(M: ModuleRef) -> ValueRef;
829 pub fn LLVMGetNextGlobal(GlobalVar: ValueRef) -> ValueRef;
830 pub fn LLVMGetPreviousGlobal(GlobalVar: ValueRef) -> ValueRef;
831 pub fn LLVMDeleteGlobal(GlobalVar: ValueRef);
832 pub fn LLVMGetInitializer(GlobalVar: ValueRef) -> ValueRef;
833 pub fn LLVMSetInitializer(GlobalVar: ValueRef,
834 ConstantVal: ValueRef);
835 pub fn LLVMIsThreadLocal(GlobalVar: ValueRef) -> Bool;
836 pub fn LLVMSetThreadLocal(GlobalVar: ValueRef, IsThreadLocal: Bool);
837 pub fn LLVMIsGlobalConstant(GlobalVar: ValueRef) -> Bool;
838 pub fn LLVMSetGlobalConstant(GlobalVar: ValueRef, IsConstant: Bool);
840 /* Operations on aliases */
841 pub fn LLVMAddAlias(M: ModuleRef,
847 /* Operations on functions */
848 pub fn LLVMAddFunction(M: ModuleRef,
852 pub fn LLVMGetNamedFunction(M: ModuleRef, Name: *const c_char) -> ValueRef;
853 pub fn LLVMGetFirstFunction(M: ModuleRef) -> ValueRef;
854 pub fn LLVMGetLastFunction(M: ModuleRef) -> ValueRef;
855 pub fn LLVMGetNextFunction(Fn: ValueRef) -> ValueRef;
856 pub fn LLVMGetPreviousFunction(Fn: ValueRef) -> ValueRef;
857 pub fn LLVMDeleteFunction(Fn: ValueRef);
858 pub fn LLVMGetOrInsertFunction(M: ModuleRef,
862 pub fn LLVMGetIntrinsicID(Fn: ValueRef) -> c_uint;
863 pub fn LLVMGetFunctionCallConv(Fn: ValueRef) -> c_uint;
864 pub fn LLVMSetFunctionCallConv(Fn: ValueRef, CC: c_uint);
865 pub fn LLVMGetGC(Fn: ValueRef) -> *const c_char;
866 pub fn LLVMSetGC(Fn: ValueRef, Name: *const c_char);
867 pub fn LLVMAddDereferenceableAttr(Fn: ValueRef, index: c_uint, bytes: uint64_t);
868 pub fn LLVMAddFunctionAttribute(Fn: ValueRef, index: c_uint, PA: uint64_t);
869 pub fn LLVMAddFunctionAttrString(Fn: ValueRef, index: c_uint, Name: *const c_char);
870 pub fn LLVMRemoveFunctionAttrString(Fn: ValueRef, index: c_uint, Name: *const c_char);
871 pub fn LLVMGetFunctionAttr(Fn: ValueRef) -> c_ulonglong;
873 /* Operations on parameters */
874 pub fn LLVMCountParams(Fn: ValueRef) -> c_uint;
875 pub fn LLVMGetParams(Fn: ValueRef, Params: *const ValueRef);
876 pub fn LLVMGetParam(Fn: ValueRef, Index: c_uint) -> ValueRef;
877 pub fn LLVMGetParamParent(Inst: ValueRef) -> ValueRef;
878 pub fn LLVMGetFirstParam(Fn: ValueRef) -> ValueRef;
879 pub fn LLVMGetLastParam(Fn: ValueRef) -> ValueRef;
880 pub fn LLVMGetNextParam(Arg: ValueRef) -> ValueRef;
881 pub fn LLVMGetPreviousParam(Arg: ValueRef) -> ValueRef;
882 pub fn LLVMAddAttribute(Arg: ValueRef, PA: c_uint);
883 pub fn LLVMRemoveAttribute(Arg: ValueRef, PA: c_uint);
884 pub fn LLVMGetAttribute(Arg: ValueRef) -> c_uint;
885 pub fn LLVMSetParamAlignment(Arg: ValueRef, align: c_uint);
887 /* Operations on basic blocks */
888 pub fn LLVMBasicBlockAsValue(BB: BasicBlockRef) -> ValueRef;
889 pub fn LLVMValueIsBasicBlock(Val: ValueRef) -> Bool;
890 pub fn LLVMValueAsBasicBlock(Val: ValueRef) -> BasicBlockRef;
891 pub fn LLVMGetBasicBlockParent(BB: BasicBlockRef) -> ValueRef;
892 pub fn LLVMCountBasicBlocks(Fn: ValueRef) -> c_uint;
893 pub fn LLVMGetBasicBlocks(Fn: ValueRef, BasicBlocks: *const ValueRef);
894 pub fn LLVMGetFirstBasicBlock(Fn: ValueRef) -> BasicBlockRef;
895 pub fn LLVMGetLastBasicBlock(Fn: ValueRef) -> BasicBlockRef;
896 pub fn LLVMGetNextBasicBlock(BB: BasicBlockRef) -> BasicBlockRef;
897 pub fn LLVMGetPreviousBasicBlock(BB: BasicBlockRef) -> BasicBlockRef;
898 pub fn LLVMGetEntryBasicBlock(Fn: ValueRef) -> BasicBlockRef;
900 pub fn LLVMAppendBasicBlockInContext(C: ContextRef,
904 pub fn LLVMInsertBasicBlockInContext(C: ContextRef,
908 pub fn LLVMDeleteBasicBlock(BB: BasicBlockRef);
910 pub fn LLVMMoveBasicBlockAfter(BB: BasicBlockRef,
911 MoveAfter: BasicBlockRef);
913 pub fn LLVMMoveBasicBlockBefore(BB: BasicBlockRef,
914 MoveBefore: BasicBlockRef);
916 /* Operations on instructions */
917 pub fn LLVMGetInstructionParent(Inst: ValueRef) -> BasicBlockRef;
918 pub fn LLVMGetFirstInstruction(BB: BasicBlockRef) -> ValueRef;
919 pub fn LLVMGetLastInstruction(BB: BasicBlockRef) -> ValueRef;
920 pub fn LLVMGetNextInstruction(Inst: ValueRef) -> ValueRef;
921 pub fn LLVMGetPreviousInstruction(Inst: ValueRef) -> ValueRef;
922 pub fn LLVMInstructionEraseFromParent(Inst: ValueRef);
924 /* Operations on call sites */
925 pub fn LLVMSetInstructionCallConv(Instr: ValueRef, CC: c_uint);
926 pub fn LLVMGetInstructionCallConv(Instr: ValueRef) -> c_uint;
927 pub fn LLVMAddInstrAttribute(Instr: ValueRef,
930 pub fn LLVMRemoveInstrAttribute(Instr: ValueRef,
933 pub fn LLVMSetInstrParamAlignment(Instr: ValueRef,
936 pub fn LLVMAddCallSiteAttribute(Instr: ValueRef,
939 pub fn LLVMAddDereferenceableCallSiteAttr(Instr: ValueRef,
943 /* Operations on call instructions (only) */
944 pub fn LLVMIsTailCall(CallInst: ValueRef) -> Bool;
945 pub fn LLVMSetTailCall(CallInst: ValueRef, IsTailCall: Bool);
947 /* Operations on load/store instructions (only) */
948 pub fn LLVMGetVolatile(MemoryAccessInst: ValueRef) -> Bool;
949 pub fn LLVMSetVolatile(MemoryAccessInst: ValueRef, volatile: Bool);
951 /* Operations on phi nodes */
952 pub fn LLVMAddIncoming(PhiNode: ValueRef,
953 IncomingValues: *const ValueRef,
954 IncomingBlocks: *const BasicBlockRef,
956 pub fn LLVMCountIncoming(PhiNode: ValueRef) -> c_uint;
957 pub fn LLVMGetIncomingValue(PhiNode: ValueRef, Index: c_uint)
959 pub fn LLVMGetIncomingBlock(PhiNode: ValueRef, Index: c_uint)
962 /* Instruction builders */
963 pub fn LLVMCreateBuilderInContext(C: ContextRef) -> BuilderRef;
964 pub fn LLVMPositionBuilder(Builder: BuilderRef,
965 Block: BasicBlockRef,
967 pub fn LLVMPositionBuilderBefore(Builder: BuilderRef,
969 pub fn LLVMPositionBuilderAtEnd(Builder: BuilderRef,
970 Block: BasicBlockRef);
971 pub fn LLVMGetInsertBlock(Builder: BuilderRef) -> BasicBlockRef;
972 pub fn LLVMClearInsertionPosition(Builder: BuilderRef);
973 pub fn LLVMInsertIntoBuilder(Builder: BuilderRef, Instr: ValueRef);
974 pub fn LLVMInsertIntoBuilderWithName(Builder: BuilderRef,
976 Name: *const c_char);
977 pub fn LLVMDisposeBuilder(Builder: BuilderRef);
978 pub fn LLVMDisposeExecutionEngine(EE: ExecutionEngineRef);
981 pub fn LLVMSetCurrentDebugLocation(Builder: BuilderRef, L: ValueRef);
982 pub fn LLVMGetCurrentDebugLocation(Builder: BuilderRef) -> ValueRef;
983 pub fn LLVMSetInstDebugLocation(Builder: BuilderRef, Inst: ValueRef);
986 pub fn LLVMBuildRetVoid(B: BuilderRef) -> ValueRef;
987 pub fn LLVMBuildRet(B: BuilderRef, V: ValueRef) -> ValueRef;
988 pub fn LLVMBuildAggregateRet(B: BuilderRef,
989 RetVals: *const ValueRef,
992 pub fn LLVMBuildBr(B: BuilderRef, Dest: BasicBlockRef) -> ValueRef;
993 pub fn LLVMBuildCondBr(B: BuilderRef,
998 pub fn LLVMBuildSwitch(B: BuilderRef,
1000 Else: BasicBlockRef,
1003 pub fn LLVMBuildIndirectBr(B: BuilderRef,
1007 pub fn LLVMBuildInvoke(B: BuilderRef,
1009 Args: *const ValueRef,
1011 Then: BasicBlockRef,
1012 Catch: BasicBlockRef,
1013 Name: *const c_char)
1015 pub fn LLVMBuildLandingPad(B: BuilderRef,
1019 Name: *const c_char)
1021 pub fn LLVMBuildResume(B: BuilderRef, Exn: ValueRef) -> ValueRef;
1022 pub fn LLVMBuildUnreachable(B: BuilderRef) -> ValueRef;
1024 /* Add a case to the switch instruction */
1025 pub fn LLVMAddCase(Switch: ValueRef,
1027 Dest: BasicBlockRef);
1029 /* Add a destination to the indirectbr instruction */
1030 pub fn LLVMAddDestination(IndirectBr: ValueRef, Dest: BasicBlockRef);
1032 /* Add a clause to the landing pad instruction */
1033 pub fn LLVMAddClause(LandingPad: ValueRef, ClauseVal: ValueRef);
1035 /* Set the cleanup on a landing pad instruction */
1036 pub fn LLVMSetCleanup(LandingPad: ValueRef, Val: Bool);
1039 pub fn LLVMBuildAdd(B: BuilderRef,
1042 Name: *const c_char)
1044 pub fn LLVMBuildNSWAdd(B: BuilderRef,
1047 Name: *const c_char)
1049 pub fn LLVMBuildNUWAdd(B: BuilderRef,
1052 Name: *const c_char)
1054 pub fn LLVMBuildFAdd(B: BuilderRef,
1057 Name: *const c_char)
1059 pub fn LLVMBuildSub(B: BuilderRef,
1062 Name: *const c_char)
1064 pub fn LLVMBuildNSWSub(B: BuilderRef,
1067 Name: *const c_char)
1069 pub fn LLVMBuildNUWSub(B: BuilderRef,
1072 Name: *const c_char)
1074 pub fn LLVMBuildFSub(B: BuilderRef,
1077 Name: *const c_char)
1079 pub fn LLVMBuildMul(B: BuilderRef,
1082 Name: *const c_char)
1084 pub fn LLVMBuildNSWMul(B: BuilderRef,
1087 Name: *const c_char)
1089 pub fn LLVMBuildNUWMul(B: BuilderRef,
1092 Name: *const c_char)
1094 pub fn LLVMBuildFMul(B: BuilderRef,
1097 Name: *const c_char)
1099 pub fn LLVMBuildUDiv(B: BuilderRef,
1102 Name: *const c_char)
1104 pub fn LLVMBuildSDiv(B: BuilderRef,
1107 Name: *const c_char)
1109 pub fn LLVMBuildExactSDiv(B: BuilderRef,
1112 Name: *const c_char)
1114 pub fn LLVMBuildFDiv(B: BuilderRef,
1117 Name: *const c_char)
1119 pub fn LLVMBuildURem(B: BuilderRef,
1122 Name: *const c_char)
1124 pub fn LLVMBuildSRem(B: BuilderRef,
1127 Name: *const c_char)
1129 pub fn LLVMBuildFRem(B: BuilderRef,
1132 Name: *const c_char)
1134 pub fn LLVMBuildShl(B: BuilderRef,
1137 Name: *const c_char)
1139 pub fn LLVMBuildLShr(B: BuilderRef,
1142 Name: *const c_char)
1144 pub fn LLVMBuildAShr(B: BuilderRef,
1147 Name: *const c_char)
1149 pub fn LLVMBuildAnd(B: BuilderRef,
1152 Name: *const c_char)
1154 pub fn LLVMBuildOr(B: BuilderRef,
1157 Name: *const c_char)
1159 pub fn LLVMBuildXor(B: BuilderRef,
1162 Name: *const c_char)
1164 pub fn LLVMBuildBinOp(B: BuilderRef,
1168 Name: *const c_char)
1170 pub fn LLVMBuildNeg(B: BuilderRef, V: ValueRef, Name: *const c_char)
1172 pub fn LLVMBuildNSWNeg(B: BuilderRef, V: ValueRef, Name: *const c_char)
1174 pub fn LLVMBuildNUWNeg(B: BuilderRef, V: ValueRef, Name: *const c_char)
1176 pub fn LLVMBuildFNeg(B: BuilderRef, V: ValueRef, Name: *const c_char)
1178 pub fn LLVMBuildNot(B: BuilderRef, V: ValueRef, Name: *const c_char)
1182 pub fn LLVMBuildMalloc(B: BuilderRef, Ty: TypeRef, Name: *const c_char)
1184 pub fn LLVMBuildArrayMalloc(B: BuilderRef,
1187 Name: *const c_char)
1189 pub fn LLVMBuildAlloca(B: BuilderRef, Ty: TypeRef, Name: *const c_char)
1191 pub fn LLVMBuildArrayAlloca(B: BuilderRef,
1194 Name: *const c_char)
1196 pub fn LLVMBuildFree(B: BuilderRef, PointerVal: ValueRef) -> ValueRef;
1197 pub fn LLVMBuildLoad(B: BuilderRef,
1198 PointerVal: ValueRef,
1199 Name: *const c_char)
1202 pub fn LLVMBuildStore(B: BuilderRef, Val: ValueRef, Ptr: ValueRef)
1205 pub fn LLVMBuildGEP(B: BuilderRef,
1207 Indices: *const ValueRef,
1209 Name: *const c_char)
1211 pub fn LLVMBuildInBoundsGEP(B: BuilderRef,
1213 Indices: *const ValueRef,
1215 Name: *const c_char)
1217 pub fn LLVMBuildStructGEP(B: BuilderRef,
1220 Name: *const c_char)
1222 pub fn LLVMBuildGlobalString(B: BuilderRef,
1224 Name: *const c_char)
1226 pub fn LLVMBuildGlobalStringPtr(B: BuilderRef,
1228 Name: *const c_char)
1232 pub fn LLVMBuildTrunc(B: BuilderRef,
1235 Name: *const c_char)
1237 pub fn LLVMBuildZExt(B: BuilderRef,
1240 Name: *const c_char)
1242 pub fn LLVMBuildSExt(B: BuilderRef,
1245 Name: *const c_char)
1247 pub fn LLVMBuildFPToUI(B: BuilderRef,
1250 Name: *const c_char)
1252 pub fn LLVMBuildFPToSI(B: BuilderRef,
1255 Name: *const c_char)
1257 pub fn LLVMBuildUIToFP(B: BuilderRef,
1260 Name: *const c_char)
1262 pub fn LLVMBuildSIToFP(B: BuilderRef,
1265 Name: *const c_char)
1267 pub fn LLVMBuildFPTrunc(B: BuilderRef,
1270 Name: *const c_char)
1272 pub fn LLVMBuildFPExt(B: BuilderRef,
1275 Name: *const c_char)
1277 pub fn LLVMBuildPtrToInt(B: BuilderRef,
1280 Name: *const c_char)
1282 pub fn LLVMBuildIntToPtr(B: BuilderRef,
1285 Name: *const c_char)
1287 pub fn LLVMBuildBitCast(B: BuilderRef,
1290 Name: *const c_char)
1292 pub fn LLVMBuildZExtOrBitCast(B: BuilderRef,
1295 Name: *const c_char)
1297 pub fn LLVMBuildSExtOrBitCast(B: BuilderRef,
1300 Name: *const c_char)
1302 pub fn LLVMBuildTruncOrBitCast(B: BuilderRef,
1305 Name: *const c_char)
1307 pub fn LLVMBuildCast(B: BuilderRef,
1311 Name: *const c_char) -> ValueRef;
1312 pub fn LLVMBuildPointerCast(B: BuilderRef,
1315 Name: *const c_char)
1317 pub fn LLVMBuildIntCast(B: BuilderRef,
1320 Name: *const c_char)
1322 pub fn LLVMBuildFPCast(B: BuilderRef,
1325 Name: *const c_char)
1329 pub fn LLVMBuildICmp(B: BuilderRef,
1333 Name: *const c_char)
1335 pub fn LLVMBuildFCmp(B: BuilderRef,
1339 Name: *const c_char)
1342 /* Miscellaneous instructions */
1343 pub fn LLVMBuildPhi(B: BuilderRef, Ty: TypeRef, Name: *const c_char)
1345 pub fn LLVMBuildCall(B: BuilderRef,
1347 Args: *const ValueRef,
1349 Name: *const c_char)
1351 pub fn LLVMBuildSelect(B: BuilderRef,
1355 Name: *const c_char)
1357 pub fn LLVMBuildVAArg(B: BuilderRef,
1360 Name: *const c_char)
1362 pub fn LLVMBuildExtractElement(B: BuilderRef,
1365 Name: *const c_char)
1367 pub fn LLVMBuildInsertElement(B: BuilderRef,
1371 Name: *const c_char)
1373 pub fn LLVMBuildShuffleVector(B: BuilderRef,
1377 Name: *const c_char)
1379 pub fn LLVMBuildExtractValue(B: BuilderRef,
1382 Name: *const c_char)
1384 pub fn LLVMBuildInsertValue(B: BuilderRef,
1388 Name: *const c_char)
1391 pub fn LLVMBuildIsNull(B: BuilderRef, Val: ValueRef, Name: *const c_char)
1393 pub fn LLVMBuildIsNotNull(B: BuilderRef, Val: ValueRef, Name: *const c_char)
1395 pub fn LLVMBuildPtrDiff(B: BuilderRef,
1398 Name: *const c_char)
1401 /* Atomic Operations */
1402 pub fn LLVMBuildAtomicLoad(B: BuilderRef,
1403 PointerVal: ValueRef,
1404 Name: *const c_char,
1405 Order: AtomicOrdering,
1409 pub fn LLVMBuildAtomicStore(B: BuilderRef,
1412 Order: AtomicOrdering,
1416 pub fn LLVMBuildAtomicCmpXchg(B: BuilderRef,
1420 Order: AtomicOrdering,
1421 FailureOrder: AtomicOrdering)
1423 pub fn LLVMBuildAtomicRMW(B: BuilderRef,
1427 Order: AtomicOrdering,
1428 SingleThreaded: Bool)
1431 pub fn LLVMBuildAtomicFence(B: BuilderRef, Order: AtomicOrdering);
1434 /* Selected entries from the downcasts. */
1435 pub fn LLVMIsATerminatorInst(Inst: ValueRef) -> ValueRef;
1436 pub fn LLVMIsAStoreInst(Inst: ValueRef) -> ValueRef;
1438 /** Writes a module to the specified path. Returns 0 on success. */
1439 pub fn LLVMWriteBitcodeToFile(M: ModuleRef, Path: *const c_char) -> c_int;
1441 /** Creates target data from a target layout string. */
1442 pub fn LLVMCreateTargetData(StringRep: *const c_char) -> TargetDataRef;
1443 /// Adds the target data to the given pass manager. The pass manager
1444 /// references the target data only weakly.
1445 pub fn LLVMAddTargetData(TD: TargetDataRef, PM: PassManagerRef);
1446 /** Number of bytes clobbered when doing a Store to *T. */
1447 pub fn LLVMStoreSizeOfType(TD: TargetDataRef, Ty: TypeRef)
1450 /** Number of bytes clobbered when doing a Store to *T. */
1451 pub fn LLVMSizeOfTypeInBits(TD: TargetDataRef, Ty: TypeRef)
1454 /** Distance between successive elements in an array of T.
1455 Includes ABI padding. */
1456 pub fn LLVMABISizeOfType(TD: TargetDataRef, Ty: TypeRef) -> c_uint;
1458 /** Returns the preferred alignment of a type. */
1459 pub fn LLVMPreferredAlignmentOfType(TD: TargetDataRef, Ty: TypeRef)
1461 /** Returns the minimum alignment of a type. */
1462 pub fn LLVMABIAlignmentOfType(TD: TargetDataRef, Ty: TypeRef)
1465 /// Computes the byte offset of the indexed struct element for a
1467 pub fn LLVMOffsetOfElement(TD: TargetDataRef,
1473 * Returns the minimum alignment of a type when part of a call frame.
1475 pub fn LLVMCallFrameAlignmentOfType(TD: TargetDataRef, Ty: TypeRef)
1478 /** Disposes target data. */
1479 pub fn LLVMDisposeTargetData(TD: TargetDataRef);
1481 /** Creates a pass manager. */
1482 pub fn LLVMCreatePassManager() -> PassManagerRef;
1484 /** Creates a function-by-function pass manager */
1485 pub fn LLVMCreateFunctionPassManagerForModule(M: ModuleRef)
1488 /** Disposes a pass manager. */
1489 pub fn LLVMDisposePassManager(PM: PassManagerRef);
1491 /** Runs a pass manager on a module. */
1492 pub fn LLVMRunPassManager(PM: PassManagerRef, M: ModuleRef) -> Bool;
1494 /** Runs the function passes on the provided function. */
1495 pub fn LLVMRunFunctionPassManager(FPM: PassManagerRef, F: ValueRef)
1498 /** Initializes all the function passes scheduled in the manager */
1499 pub fn LLVMInitializeFunctionPassManager(FPM: PassManagerRef) -> Bool;
1501 /** Finalizes all the function passes scheduled in the manager */
1502 pub fn LLVMFinalizeFunctionPassManager(FPM: PassManagerRef) -> Bool;
1504 pub fn LLVMInitializePasses();
1506 /** Adds a verification pass. */
1507 pub fn LLVMAddVerifierPass(PM: PassManagerRef);
1509 pub fn LLVMAddGlobalOptimizerPass(PM: PassManagerRef);
1510 pub fn LLVMAddIPSCCPPass(PM: PassManagerRef);
1511 pub fn LLVMAddDeadArgEliminationPass(PM: PassManagerRef);
1512 pub fn LLVMAddInstructionCombiningPass(PM: PassManagerRef);
1513 pub fn LLVMAddCFGSimplificationPass(PM: PassManagerRef);
1514 pub fn LLVMAddFunctionInliningPass(PM: PassManagerRef);
1515 pub fn LLVMAddFunctionAttrsPass(PM: PassManagerRef);
1516 pub fn LLVMAddScalarReplAggregatesPass(PM: PassManagerRef);
1517 pub fn LLVMAddScalarReplAggregatesPassSSA(PM: PassManagerRef);
1518 pub fn LLVMAddJumpThreadingPass(PM: PassManagerRef);
1519 pub fn LLVMAddConstantPropagationPass(PM: PassManagerRef);
1520 pub fn LLVMAddReassociatePass(PM: PassManagerRef);
1521 pub fn LLVMAddLoopRotatePass(PM: PassManagerRef);
1522 pub fn LLVMAddLICMPass(PM: PassManagerRef);
1523 pub fn LLVMAddLoopUnswitchPass(PM: PassManagerRef);
1524 pub fn LLVMAddLoopDeletionPass(PM: PassManagerRef);
1525 pub fn LLVMAddLoopUnrollPass(PM: PassManagerRef);
1526 pub fn LLVMAddGVNPass(PM: PassManagerRef);
1527 pub fn LLVMAddMemCpyOptPass(PM: PassManagerRef);
1528 pub fn LLVMAddSCCPPass(PM: PassManagerRef);
1529 pub fn LLVMAddDeadStoreEliminationPass(PM: PassManagerRef);
1530 pub fn LLVMAddStripDeadPrototypesPass(PM: PassManagerRef);
1531 pub fn LLVMAddConstantMergePass(PM: PassManagerRef);
1532 pub fn LLVMAddArgumentPromotionPass(PM: PassManagerRef);
1533 pub fn LLVMAddTailCallEliminationPass(PM: PassManagerRef);
1534 pub fn LLVMAddIndVarSimplifyPass(PM: PassManagerRef);
1535 pub fn LLVMAddAggressiveDCEPass(PM: PassManagerRef);
1536 pub fn LLVMAddGlobalDCEPass(PM: PassManagerRef);
1537 pub fn LLVMAddCorrelatedValuePropagationPass(PM: PassManagerRef);
1538 pub fn LLVMAddPruneEHPass(PM: PassManagerRef);
1539 pub fn LLVMAddSimplifyLibCallsPass(PM: PassManagerRef);
1540 pub fn LLVMAddLoopIdiomPass(PM: PassManagerRef);
1541 pub fn LLVMAddEarlyCSEPass(PM: PassManagerRef);
1542 pub fn LLVMAddTypeBasedAliasAnalysisPass(PM: PassManagerRef);
1543 pub fn LLVMAddBasicAliasAnalysisPass(PM: PassManagerRef);
1545 pub fn LLVMPassManagerBuilderCreate() -> PassManagerBuilderRef;
1546 pub fn LLVMPassManagerBuilderDispose(PMB: PassManagerBuilderRef);
1547 pub fn LLVMPassManagerBuilderSetOptLevel(PMB: PassManagerBuilderRef,
1548 OptimizationLevel: c_uint);
1549 pub fn LLVMPassManagerBuilderSetSizeLevel(PMB: PassManagerBuilderRef,
1551 pub fn LLVMPassManagerBuilderSetDisableUnitAtATime(
1552 PMB: PassManagerBuilderRef,
1554 pub fn LLVMPassManagerBuilderSetDisableUnrollLoops(
1555 PMB: PassManagerBuilderRef,
1557 pub fn LLVMPassManagerBuilderSetDisableSimplifyLibCalls(
1558 PMB: PassManagerBuilderRef,
1560 pub fn LLVMPassManagerBuilderUseInlinerWithThreshold(
1561 PMB: PassManagerBuilderRef,
1563 pub fn LLVMPassManagerBuilderPopulateModulePassManager(
1564 PMB: PassManagerBuilderRef,
1565 PM: PassManagerRef);
1567 pub fn LLVMPassManagerBuilderPopulateFunctionPassManager(
1568 PMB: PassManagerBuilderRef,
1569 PM: PassManagerRef);
1570 pub fn LLVMPassManagerBuilderPopulateLTOPassManager(
1571 PMB: PassManagerBuilderRef,
1576 /** Destroys a memory buffer. */
1577 pub fn LLVMDisposeMemoryBuffer(MemBuf: MemoryBufferRef);
1580 /* Stuff that's in rustllvm/ because it's not upstream yet. */
1582 /** Opens an object file. */
1583 pub fn LLVMCreateObjectFile(MemBuf: MemoryBufferRef) -> ObjectFileRef;
1584 /** Closes an object file. */
1585 pub fn LLVMDisposeObjectFile(ObjFile: ObjectFileRef);
1587 /** Enumerates the sections in an object file. */
1588 pub fn LLVMGetSections(ObjFile: ObjectFileRef) -> SectionIteratorRef;
1589 /** Destroys a section iterator. */
1590 pub fn LLVMDisposeSectionIterator(SI: SectionIteratorRef);
1591 /** Returns true if the section iterator is at the end of the section
1593 pub fn LLVMIsSectionIteratorAtEnd(ObjFile: ObjectFileRef,
1594 SI: SectionIteratorRef)
1596 /** Moves the section iterator to point to the next section. */
1597 pub fn LLVMMoveToNextSection(SI: SectionIteratorRef);
1598 /** Returns the current section size. */
1599 pub fn LLVMGetSectionSize(SI: SectionIteratorRef) -> c_ulonglong;
1600 /** Returns the current section contents as a string buffer. */
1601 pub fn LLVMGetSectionContents(SI: SectionIteratorRef) -> *const c_char;
1603 /** Reads the given file and returns it as a memory buffer. Use
1604 LLVMDisposeMemoryBuffer() to get rid of it. */
1605 pub fn LLVMRustCreateMemoryBufferWithContentsOfFile(Path: *const c_char)
1607 /** Borrows the contents of the memory buffer (doesn't copy it) */
1608 pub fn LLVMCreateMemoryBufferWithMemoryRange(InputData: *const c_char,
1609 InputDataLength: size_t,
1610 BufferName: *const c_char,
1613 pub fn LLVMCreateMemoryBufferWithMemoryRangeCopy(InputData: *const c_char,
1614 InputDataLength: size_t,
1615 BufferName: *const c_char)
1618 pub fn LLVMIsMultithreaded() -> Bool;
1619 pub fn LLVMStartMultithreaded() -> Bool;
1621 /** Returns a string describing the last error caused by an LLVMRust*
1623 pub fn LLVMRustGetLastError() -> *const c_char;
1625 /// Print the pass timings since static dtors aren't picking them up.
1626 pub fn LLVMRustPrintPassTimings();
1628 pub fn LLVMStructCreateNamed(C: ContextRef, Name: *const c_char) -> TypeRef;
1630 pub fn LLVMStructSetBody(StructTy: TypeRef,
1631 ElementTypes: *const TypeRef,
1632 ElementCount: c_uint,
1635 pub fn LLVMConstNamedStruct(S: TypeRef,
1636 ConstantVals: *const ValueRef,
1640 /** Enables LLVM debug output. */
1641 pub fn LLVMSetDebug(Enabled: c_int);
1643 /** Prepares inline assembly. */
1644 pub fn LLVMInlineAsm(Ty: TypeRef,
1645 AsmString: *const c_char,
1646 Constraints: *const c_char,
1652 pub static LLVMRustDebugMetadataVersion: u32;
1654 pub fn LLVMRustAddModuleFlag(M: ModuleRef,
1655 name: *const c_char,
1658 pub fn LLVMDIBuilderCreate(M: ModuleRef) -> DIBuilderRef;
1660 pub fn LLVMDIBuilderDispose(Builder: DIBuilderRef);
1662 pub fn LLVMDIBuilderFinalize(Builder: DIBuilderRef);
1664 pub fn LLVMDIBuilderCreateCompileUnit(Builder: DIBuilderRef,
1666 File: *const c_char,
1668 Producer: *const c_char,
1670 Flags: *const c_char,
1672 SplitName: *const c_char);
1674 pub fn LLVMDIBuilderCreateFile(Builder: DIBuilderRef,
1675 Filename: *const c_char,
1676 Directory: *const c_char)
1679 pub fn LLVMDIBuilderCreateSubroutineType(Builder: DIBuilderRef,
1681 ParameterTypes: DIArray)
1684 pub fn LLVMDIBuilderCreateFunction(Builder: DIBuilderRef,
1685 Scope: DIDescriptor,
1686 Name: *const c_char,
1687 LinkageName: *const c_char,
1691 isLocalToUnit: bool,
1701 pub fn LLVMDIBuilderCreateBasicType(Builder: DIBuilderRef,
1702 Name: *const c_char,
1703 SizeInBits: c_ulonglong,
1704 AlignInBits: c_ulonglong,
1708 pub fn LLVMDIBuilderCreatePointerType(Builder: DIBuilderRef,
1710 SizeInBits: c_ulonglong,
1711 AlignInBits: c_ulonglong,
1712 Name: *const c_char)
1715 pub fn LLVMDIBuilderCreateStructType(Builder: DIBuilderRef,
1716 Scope: DIDescriptor,
1717 Name: *const c_char,
1720 SizeInBits: c_ulonglong,
1721 AlignInBits: c_ulonglong,
1723 DerivedFrom: DIType,
1725 RunTimeLang: c_uint,
1726 VTableHolder: ValueRef,
1727 UniqueId: *const c_char)
1730 pub fn LLVMDIBuilderCreateMemberType(Builder: DIBuilderRef,
1731 Scope: DIDescriptor,
1732 Name: *const c_char,
1735 SizeInBits: c_ulonglong,
1736 AlignInBits: c_ulonglong,
1737 OffsetInBits: c_ulonglong,
1742 pub fn LLVMDIBuilderCreateLexicalBlock(Builder: DIBuilderRef,
1743 Scope: DIDescriptor,
1747 Discriminator: c_uint)
1750 pub fn LLVMDIBuilderCreateStaticVariable(Builder: DIBuilderRef,
1751 Context: DIDescriptor,
1752 Name: *const c_char,
1753 LinkageName: *const c_char,
1757 isLocalToUnit: bool,
1760 -> DIGlobalVariable;
1762 pub fn LLVMDIBuilderCreateLocalVariable(Builder: DIBuilderRef,
1764 Scope: DIDescriptor,
1765 Name: *const c_char,
1769 AlwaysPreserve: bool,
1774 pub fn LLVMDIBuilderCreateArrayType(Builder: DIBuilderRef,
1776 AlignInBits: c_ulonglong,
1778 Subscripts: DIArray)
1781 pub fn LLVMDIBuilderCreateVectorType(Builder: DIBuilderRef,
1783 AlignInBits: c_ulonglong,
1785 Subscripts: DIArray)
1788 pub fn LLVMDIBuilderGetOrCreateSubrange(Builder: DIBuilderRef,
1793 pub fn LLVMDIBuilderGetOrCreateArray(Builder: DIBuilderRef,
1794 Ptr: *const DIDescriptor,
1798 pub fn LLVMDIBuilderInsertDeclareAtEnd(Builder: DIBuilderRef,
1800 VarInfo: DIVariable,
1801 InsertAtEnd: BasicBlockRef)
1804 pub fn LLVMDIBuilderInsertDeclareBefore(Builder: DIBuilderRef,
1806 VarInfo: DIVariable,
1807 InsertBefore: ValueRef)
1810 pub fn LLVMDIBuilderCreateEnumerator(Builder: DIBuilderRef,
1811 Name: *const c_char,
1815 pub fn LLVMDIBuilderCreateEnumerationType(Builder: DIBuilderRef,
1817 Name: *const c_char,
1820 SizeInBits: c_ulonglong,
1821 AlignInBits: c_ulonglong,
1823 ClassType: ValueRef)
1826 pub fn LLVMDIBuilderCreateUnionType(Builder: DIBuilderRef,
1828 Name: *const c_char,
1831 SizeInBits: c_ulonglong,
1832 AlignInBits: c_ulonglong,
1835 RunTimeLang: c_uint,
1836 UniqueId: *const c_char)
1839 pub fn LLVMSetUnnamedAddr(GlobalVar: ValueRef, UnnamedAddr: Bool);
1841 pub fn LLVMDIBuilderCreateTemplateTypeParameter(Builder: DIBuilderRef,
1843 Name: *const c_char,
1850 pub fn LLVMDIBuilderCreateOpDeref(IntType: TypeRef) -> ValueRef;
1852 pub fn LLVMDIBuilderCreateOpPlus(IntType: TypeRef) -> ValueRef;
1854 pub fn LLVMDIBuilderCreateComplexVariable(Builder: DIBuilderRef,
1857 Name: *const c_char,
1861 AddrOps: *const ValueRef,
1862 AddrOpsCount: c_uint,
1866 pub fn LLVMDIBuilderCreateNameSpace(Builder: DIBuilderRef,
1868 Name: *const c_char,
1873 pub fn LLVMDICompositeTypeSetTypeArray(CompositeType: ValueRef, TypeArray: ValueRef);
1874 pub fn LLVMWriteTypeToString(Type: TypeRef, s: RustStringRef);
1875 pub fn LLVMWriteValueToString(value_ref: ValueRef, s: RustStringRef);
1877 pub fn LLVMIsAArgument(value_ref: ValueRef) -> ValueRef;
1879 pub fn LLVMIsAAllocaInst(value_ref: ValueRef) -> ValueRef;
1881 pub fn LLVMInitializeX86TargetInfo();
1882 pub fn LLVMInitializeX86Target();
1883 pub fn LLVMInitializeX86TargetMC();
1884 pub fn LLVMInitializeX86AsmPrinter();
1885 pub fn LLVMInitializeX86AsmParser();
1886 pub fn LLVMInitializeARMTargetInfo();
1887 pub fn LLVMInitializeARMTarget();
1888 pub fn LLVMInitializeARMTargetMC();
1889 pub fn LLVMInitializeARMAsmPrinter();
1890 pub fn LLVMInitializeARMAsmParser();
1891 pub fn LLVMInitializeMipsTargetInfo();
1892 pub fn LLVMInitializeMipsTarget();
1893 pub fn LLVMInitializeMipsTargetMC();
1894 pub fn LLVMInitializeMipsAsmPrinter();
1895 pub fn LLVMInitializeMipsAsmParser();
1897 pub fn LLVMRustAddPass(PM: PassManagerRef, Pass: *const c_char) -> bool;
1898 pub fn LLVMRustCreateTargetMachine(Triple: *const c_char,
1900 Features: *const c_char,
1901 Model: CodeGenModel,
1903 Level: CodeGenOptLevel,
1906 NoFramePointerElim: bool,
1907 FunctionSections: bool,
1908 DataSections: bool) -> TargetMachineRef;
1909 pub fn LLVMRustDisposeTargetMachine(T: TargetMachineRef);
1910 pub fn LLVMRustAddAnalysisPasses(T: TargetMachineRef,
1913 pub fn LLVMRustAddBuilderLibraryInfo(PMB: PassManagerBuilderRef,
1915 DisableSimplifyLibCalls: bool);
1916 pub fn LLVMRustAddLibraryInfo(PM: PassManagerRef, M: ModuleRef,
1917 DisableSimplifyLibCalls: bool);
1918 pub fn LLVMRustRunFunctionPassManager(PM: PassManagerRef, M: ModuleRef);
1919 pub fn LLVMRustWriteOutputFile(T: TargetMachineRef,
1922 Output: *const c_char,
1923 FileType: FileType) -> bool;
1924 pub fn LLVMRustPrintModule(PM: PassManagerRef,
1926 Output: *const c_char);
1927 pub fn LLVMRustSetLLVMOptions(Argc: c_int, Argv: *const *const c_char);
1928 pub fn LLVMRustPrintPasses();
1929 pub fn LLVMRustSetNormalizedTarget(M: ModuleRef, triple: *const c_char);
1930 pub fn LLVMRustAddAlwaysInlinePass(P: PassManagerBuilderRef,
1931 AddLifetimes: bool);
1932 pub fn LLVMRustLinkInExternalBitcode(M: ModuleRef,
1934 len: size_t) -> bool;
1935 pub fn LLVMRustRunRestrictionPass(M: ModuleRef,
1936 syms: *const *const c_char,
1938 pub fn LLVMRustMarkAllFunctionsNounwind(M: ModuleRef);
1940 pub fn LLVMRustOpenArchive(path: *const c_char) -> ArchiveRef;
1941 pub fn LLVMRustArchiveReadSection(AR: ArchiveRef, name: *const c_char,
1942 out_len: *mut size_t) -> *const c_char;
1943 pub fn LLVMRustDestroyArchive(AR: ArchiveRef);
1945 pub fn LLVMRustSetDLLExportStorageClass(V: ValueRef);
1946 pub fn LLVMVersionMajor() -> c_int;
1947 pub fn LLVMVersionMinor() -> c_int;
1949 pub fn LLVMRustGetSectionName(SI: SectionIteratorRef,
1950 data: *mut *const c_char) -> c_int;
1952 pub fn LLVMWriteTwineToString(T: TwineRef, s: RustStringRef);
1954 pub fn LLVMContextSetDiagnosticHandler(C: ContextRef,
1955 Handler: DiagnosticHandler,
1956 DiagnosticContext: *mut c_void);
1958 pub fn LLVMUnpackOptimizationDiagnostic(DI: DiagnosticInfoRef,
1959 pass_name_out: *mut *const c_char,
1960 function_out: *mut ValueRef,
1961 debugloc_out: *mut DebugLocRef,
1962 message_out: *mut TwineRef);
1964 pub fn LLVMWriteDiagnosticInfoToString(DI: DiagnosticInfoRef, s: RustStringRef);
1965 pub fn LLVMGetDiagInfoSeverity(DI: DiagnosticInfoRef) -> DiagnosticSeverity;
1966 pub fn LLVMGetDiagInfoKind(DI: DiagnosticInfoRef) -> DiagnosticKind;
1968 pub fn LLVMWriteDebugLocToString(C: ContextRef, DL: DebugLocRef, s: RustStringRef);
1971 pub fn SetInstructionCallConv(instr: ValueRef, cc: CallConv) {
1973 LLVMSetInstructionCallConv(instr, cc as c_uint);
1976 pub fn SetFunctionCallConv(fn_: ValueRef, cc: CallConv) {
1978 LLVMSetFunctionCallConv(fn_, cc as c_uint);
1981 pub fn SetLinkage(global: ValueRef, link: Linkage) {
1983 LLVMSetLinkage(global, link as c_uint);
1987 pub fn SetUnnamedAddr(global: ValueRef, unnamed: bool) {
1989 LLVMSetUnnamedAddr(global, unnamed as Bool);
1993 pub fn set_thread_local(global: ValueRef, is_thread_local: bool) {
1995 LLVMSetThreadLocal(global, is_thread_local as Bool);
1999 pub fn ConstICmp(pred: IntPredicate, v1: ValueRef, v2: ValueRef) -> ValueRef {
2001 LLVMConstICmp(pred as c_ushort, v1, v2)
2004 pub fn ConstFCmp(pred: RealPredicate, v1: ValueRef, v2: ValueRef) -> ValueRef {
2006 LLVMConstFCmp(pred as c_ushort, v1, v2)
2010 pub fn SetFunctionAttribute(fn_: ValueRef, attr: Attribute) {
2012 LLVMAddFunctionAttribute(fn_, FunctionIndex as c_uint, attr as uint64_t)
2016 /* Memory-managed interface to target data. */
2018 pub struct TargetData {
2019 pub lltd: TargetDataRef
2022 impl Drop for TargetData {
2023 fn drop(&mut self) {
2025 LLVMDisposeTargetData(self.lltd);
2030 pub fn mk_target_data(string_rep: &str) -> TargetData {
2032 lltd: string_rep.with_c_str(|buf| {
2033 unsafe { LLVMCreateTargetData(buf) }
2038 /* Memory-managed interface to object files. */
2040 pub struct ObjectFile {
2041 pub llof: ObjectFileRef,
2045 // This will take ownership of llmb
2046 pub fn new(llmb: MemoryBufferRef) -> Option<ObjectFile> {
2048 let llof = LLVMCreateObjectFile(llmb);
2049 if llof as int == 0 {
2050 // LLVMCreateObjectFile took ownership of llmb
2061 impl Drop for ObjectFile {
2062 fn drop(&mut self) {
2064 LLVMDisposeObjectFile(self.llof);
2069 /* Memory-managed interface to section iterators. */
2071 pub struct SectionIter {
2072 pub llsi: SectionIteratorRef
2075 impl Drop for SectionIter {
2076 fn drop(&mut self) {
2078 LLVMDisposeSectionIterator(self.llsi);
2083 pub fn mk_section_iter(llof: ObjectFileRef) -> SectionIter {
2086 llsi: LLVMGetSections(llof)
2091 /// Safe wrapper around `LLVMGetParam`, because segfaults are no fun.
2092 pub fn get_param(llfn: ValueRef, index: c_uint) -> ValueRef {
2094 assert!(index < LLVMCountParams(llfn));
2095 LLVMGetParam(llfn, index)
2099 pub enum RustString_opaque {}
2100 pub type RustStringRef = *mut RustString_opaque;
2101 type RustStringRepr = *mut RefCell<Vec<u8>>;
2103 /// Appending to a Rust string -- used by raw_rust_string_ostream.
2105 pub unsafe extern "C" fn rust_llvm_string_write_impl(sr: RustStringRef,
2108 let slice: &[u8] = mem::transmute(raw::Slice {
2109 data: ptr as *const u8,
2113 let sr: RustStringRepr = mem::transmute(sr);
2114 (*sr).borrow_mut().push_all(slice);
2117 pub fn build_string(f: |RustStringRef|) -> Option<String> {
2118 let mut buf = RefCell::new(Vec::new());
2119 f(&mut buf as RustStringRepr as RustStringRef);
2120 String::from_utf8(buf.unwrap()).ok()
2123 pub unsafe fn twine_to_string(tr: TwineRef) -> String {
2124 build_string(|s| LLVMWriteTwineToString(tr, s))
2125 .expect("got a non-UTF8 Twine from LLVM")
2128 pub unsafe fn debug_loc_to_string(c: ContextRef, tr: DebugLocRef) -> String {
2129 build_string(|s| LLVMWriteDebugLocToString(c, tr, s))
2130 .expect("got a non-UTF8 DebugLoc from LLVM")
2133 // FIXME #15460 - create a public function that actually calls our
2134 // static LLVM symbols. Otherwise the linker will just throw llvm
2135 // away. We're just calling lots of stuff until we transitively get
2136 // all of LLVM. This is worse than anything.
2137 pub unsafe fn static_link_hack_this_sucks() {
2138 LLVMInitializePasses();
2140 LLVMInitializeX86TargetInfo();
2141 LLVMInitializeX86Target();
2142 LLVMInitializeX86TargetMC();
2143 LLVMInitializeX86AsmPrinter();
2144 LLVMInitializeX86AsmParser();
2146 LLVMInitializeARMTargetInfo();
2147 LLVMInitializeARMTarget();
2148 LLVMInitializeARMTargetMC();
2149 LLVMInitializeARMAsmPrinter();
2150 LLVMInitializeARMAsmParser();
2152 LLVMInitializeMipsTargetInfo();
2153 LLVMInitializeMipsTarget();
2154 LLVMInitializeMipsTargetMC();
2155 LLVMInitializeMipsAsmPrinter();
2156 LLVMInitializeMipsAsmParser();
2158 LLVMRustSetLLVMOptions(0 as c_int,
2161 LLVMPassManagerBuilderPopulateModulePassManager(0 as *mut _, 0 as *mut _);
2162 LLVMPassManagerBuilderPopulateLTOPassManager(0 as *mut _, 0 as *mut _, False, False);
2163 LLVMPassManagerBuilderPopulateFunctionPassManager(0 as *mut _, 0 as *mut _);
2164 LLVMPassManagerBuilderSetOptLevel(0 as *mut _, 0 as c_uint);
2165 LLVMPassManagerBuilderUseInlinerWithThreshold(0 as *mut _, 0 as c_uint);
2166 LLVMWriteBitcodeToFile(0 as *mut _, 0 as *const _);
2167 LLVMPassManagerBuilderCreate();
2168 LLVMPassManagerBuilderDispose(0 as *mut _);
2170 LLVMRustLinkInExternalBitcode(0 as *mut _, 0 as *const _, 0 as size_t);
2174 LLVMLinkInInterpreter();
2178 fn LLVMLinkInMCJIT();
2179 fn LLVMLinkInInterpreter();
2183 // The module containing the native LLVM dependencies, generated by the build system
2184 // Note that this must come after the rustllvm extern declaration so that
2185 // parts of LLVM that rustllvm depends on aren't thrown away by the linker.
2186 // Works to the above fix for #15460 to ensure LLVM dependencies that
2187 // are only used by rustllvm don't get stripped by the linker.