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 {
95 flags Attribute : u32 {
96 static ZExtAttribute = 1 << 0,
97 static SExtAttribute = 1 << 1,
98 static NoReturnAttribute = 1 << 2,
99 static InRegAttribute = 1 << 3,
100 static StructRetAttribute = 1 << 4,
101 static NoUnwindAttribute = 1 << 5,
102 static NoAliasAttribute = 1 << 6,
103 static ByValAttribute = 1 << 7,
104 static NestAttribute = 1 << 8,
105 static ReadNoneAttribute = 1 << 9,
106 static ReadOnlyAttribute = 1 << 10,
107 static NoInlineAttribute = 1 << 11,
108 static AlwaysInlineAttribute = 1 << 12,
109 static OptimizeForSizeAttribute = 1 << 13,
110 static StackProtectAttribute = 1 << 14,
111 static StackProtectReqAttribute = 1 << 15,
112 static AlignmentAttribute = 31 << 16,
113 static NoCaptureAttribute = 1 << 21,
114 static NoRedZoneAttribute = 1 << 22,
115 static NoImplicitFloatAttribute = 1 << 23,
116 static NakedAttribute = 1 << 24,
117 static InlineHintAttribute = 1 << 25,
118 static StackAttribute = 7 << 26,
119 static ReturnsTwiceAttribute = 1 << 29,
120 static UWTableAttribute = 1 << 30,
121 static NonLazyBindAttribute = 1 << 31,
126 pub enum OtherAttribute {
127 // The following are not really exposed in
128 // the LLVM c api so instead to add these
129 // we call a wrapper function in RustWrapper
130 // that uses the C++ api.
131 SanitizeAddressAttribute = 1 << 32,
132 MinSizeAttribute = 1 << 33,
133 NoDuplicateAttribute = 1 << 34,
134 StackProtectStrongAttribute = 1 << 35,
135 SanitizeThreadAttribute = 1 << 36,
136 SanitizeMemoryAttribute = 1 << 37,
137 NoBuiltinAttribute = 1 << 38,
138 ReturnedAttribute = 1 << 39,
139 ColdAttribute = 1 << 40,
140 BuiltinAttribute = 1 << 41,
141 OptimizeNoneAttribute = 1 << 42,
142 InAllocaAttribute = 1 << 43,
143 NonNullAttribute = 1 << 44,
146 pub enum SpecialAttribute {
147 DereferenceableAttribute(u64)
151 pub enum AttributeSet {
157 fn apply_llfn(&self, idx: c_uint, llfn: ValueRef);
158 fn apply_callsite(&self, idx: c_uint, callsite: ValueRef);
161 impl AttrHelper for Attribute {
162 fn apply_llfn(&self, idx: c_uint, llfn: ValueRef) {
164 LLVMAddFunctionAttribute(llfn, idx, self.bits() as uint64_t);
168 fn apply_callsite(&self, idx: c_uint, callsite: ValueRef) {
170 LLVMAddCallSiteAttribute(callsite, idx, self.bits() as uint64_t);
175 impl AttrHelper for OtherAttribute {
176 fn apply_llfn(&self, idx: c_uint, llfn: ValueRef) {
178 LLVMAddFunctionAttribute(llfn, idx, *self as uint64_t);
182 fn apply_callsite(&self, idx: c_uint, callsite: ValueRef) {
184 LLVMAddCallSiteAttribute(callsite, idx, *self as uint64_t);
189 impl AttrHelper for SpecialAttribute {
190 fn apply_llfn(&self, idx: c_uint, llfn: ValueRef) {
192 DereferenceableAttribute(bytes) => unsafe {
193 LLVMAddDereferenceableAttr(llfn, idx, bytes as uint64_t);
198 fn apply_callsite(&self, idx: c_uint, callsite: ValueRef) {
200 DereferenceableAttribute(bytes) => unsafe {
201 LLVMAddDereferenceableCallSiteAttr(callsite, idx, bytes as uint64_t);
207 pub struct AttrBuilder {
208 attrs: Vec<(uint, Box<AttrHelper+'static>)>
212 pub fn new() -> AttrBuilder {
218 pub fn arg<'a, T: AttrHelper + 'static>(&'a mut self, idx: uint, a: T) -> &'a mut AttrBuilder {
219 self.attrs.push((idx, box a as Box<AttrHelper+'static>));
223 pub fn ret<'a, T: AttrHelper + 'static>(&'a mut self, a: T) -> &'a mut AttrBuilder {
224 self.attrs.push((ReturnIndex as uint, box a as Box<AttrHelper+'static>));
228 pub fn apply_llfn(&self, llfn: ValueRef) {
229 for &(idx, ref attr) in self.attrs.iter() {
230 attr.apply_llfn(idx as c_uint, llfn);
234 pub fn apply_callsite(&self, callsite: ValueRef) {
235 for &(idx, ref attr) in self.attrs.iter() {
236 attr.apply_callsite(idx as c_uint, callsite);
241 // enum for the LLVM IntPredicate type
242 pub enum IntPredicate {
255 // enum for the LLVM RealPredicate type
256 pub enum RealPredicate {
257 RealPredicateFalse = 0,
272 RealPredicateTrue = 15,
275 // The LLVM TypeKind type - must stay in sync with the def of
276 // LLVMTypeKind in llvm/include/llvm-c/Core.h
277 #[deriving(PartialEq)]
299 pub enum AtomicBinOp {
314 pub enum AtomicOrdering {
318 // Consume = 3, // Not specified yet.
322 SequentiallyConsistent = 7
325 // Consts for the LLVMCodeGenFileType type (in include/llvm/c/TargetMachine.h)
341 // Inline Asm Dialect
342 pub enum AsmDialect {
347 #[deriving(PartialEq, Clone)]
349 pub enum CodeGenOptLevel {
350 CodeGenLevelNone = 0,
351 CodeGenLevelLess = 1,
352 CodeGenLevelDefault = 2,
353 CodeGenLevelAggressive = 3,
361 RelocDynamicNoPic = 3,
365 pub enum CodeGenModel {
366 CodeModelDefault = 0,
367 CodeModelJITDefault = 1,
375 pub enum DiagnosticKind {
378 DK_DebugMetadataVersion,
380 DK_OptimizationRemark,
381 DK_OptimizationRemarkMissed,
382 DK_OptimizationRemarkAnalysis,
383 DK_OptimizationFailure,
386 // Opaque pointer types
387 pub enum Module_opaque {}
388 pub type ModuleRef = *mut Module_opaque;
389 pub enum Context_opaque {}
390 pub type ContextRef = *mut Context_opaque;
391 pub enum Type_opaque {}
392 pub type TypeRef = *mut Type_opaque;
393 pub enum Value_opaque {}
394 pub type ValueRef = *mut Value_opaque;
395 pub enum BasicBlock_opaque {}
396 pub type BasicBlockRef = *mut BasicBlock_opaque;
397 pub enum Builder_opaque {}
398 pub type BuilderRef = *mut Builder_opaque;
399 pub enum ExecutionEngine_opaque {}
400 pub type ExecutionEngineRef = *mut ExecutionEngine_opaque;
401 pub enum MemoryBuffer_opaque {}
402 pub type MemoryBufferRef = *mut MemoryBuffer_opaque;
403 pub enum PassManager_opaque {}
404 pub type PassManagerRef = *mut PassManager_opaque;
405 pub enum PassManagerBuilder_opaque {}
406 pub type PassManagerBuilderRef = *mut PassManagerBuilder_opaque;
407 pub enum Use_opaque {}
408 pub type UseRef = *mut Use_opaque;
409 pub enum TargetData_opaque {}
410 pub type TargetDataRef = *mut TargetData_opaque;
411 pub enum ObjectFile_opaque {}
412 pub type ObjectFileRef = *mut ObjectFile_opaque;
413 pub enum SectionIterator_opaque {}
414 pub type SectionIteratorRef = *mut SectionIterator_opaque;
415 pub enum Pass_opaque {}
416 pub type PassRef = *mut Pass_opaque;
417 pub enum TargetMachine_opaque {}
418 pub type TargetMachineRef = *mut TargetMachine_opaque;
419 pub enum Archive_opaque {}
420 pub type ArchiveRef = *mut Archive_opaque;
421 pub enum Twine_opaque {}
422 pub type TwineRef = *mut Twine_opaque;
423 pub enum DiagnosticInfo_opaque {}
424 pub type DiagnosticInfoRef = *mut DiagnosticInfo_opaque;
425 pub enum DebugLoc_opaque {}
426 pub type DebugLocRef = *mut DebugLoc_opaque;
428 pub type DiagnosticHandler = unsafe extern "C" fn(DiagnosticInfoRef, *mut c_void);
431 use super::{ValueRef};
433 pub enum DIBuilder_opaque {}
434 pub type DIBuilderRef = *mut DIBuilder_opaque;
436 pub type DIDescriptor = ValueRef;
437 pub type DIScope = DIDescriptor;
438 pub type DILocation = DIDescriptor;
439 pub type DIFile = DIScope;
440 pub type DILexicalBlock = DIScope;
441 pub type DISubprogram = DIScope;
442 pub type DIType = DIDescriptor;
443 pub type DIBasicType = DIType;
444 pub type DIDerivedType = DIType;
445 pub type DICompositeType = DIDerivedType;
446 pub type DIVariable = DIDescriptor;
447 pub type DIGlobalVariable = DIDescriptor;
448 pub type DIArray = DIDescriptor;
449 pub type DISubrange = DIDescriptor;
451 pub enum DIDescriptorFlags {
452 FlagPrivate = 1 << 0,
453 FlagProtected = 1 << 1,
454 FlagFwdDecl = 1 << 2,
455 FlagAppleBlock = 1 << 3,
456 FlagBlockByrefStruct = 1 << 4,
457 FlagVirtual = 1 << 5,
458 FlagArtificial = 1 << 6,
459 FlagExplicit = 1 << 7,
460 FlagPrototyped = 1 << 8,
461 FlagObjcClassComplete = 1 << 9,
462 FlagObjectPointer = 1 << 10,
463 FlagVector = 1 << 11,
464 FlagStaticMember = 1 << 12,
465 FlagIndirectVariable = 1 << 13,
466 FlagLValueReference = 1 << 14,
467 FlagRValueReference = 1 << 15
472 // Link to our native llvm bindings (things that we need to use the C++ api
473 // for) and because llvm is written in C++ we need to link against libstdc++
475 // You'll probably notice that there is an omission of all LLVM libraries
476 // from this location. This is because the set of LLVM libraries that we
477 // link to is mostly defined by LLVM, and the `llvm-config` tool is used to
478 // figure out the exact set of libraries. To do this, the build system
479 // generates an llvmdeps.rs file next to this one which will be
480 // automatically updated whenever LLVM is updated to include an up-to-date
481 // set of the libraries we need to link to LLVM for.
482 #[link(name = "rustllvm", kind = "static")]
484 /* Create and destroy contexts. */
485 pub fn LLVMContextCreate() -> ContextRef;
486 pub fn LLVMContextDispose(C: ContextRef);
487 pub fn LLVMGetMDKindIDInContext(C: ContextRef,
492 /* Create and destroy modules. */
493 pub fn LLVMModuleCreateWithNameInContext(ModuleID: *const c_char,
496 pub fn LLVMGetModuleContext(M: ModuleRef) -> ContextRef;
497 pub fn LLVMDisposeModule(M: ModuleRef);
499 /** Data layout. See Module::getDataLayout. */
500 pub fn LLVMGetDataLayout(M: ModuleRef) -> *const c_char;
501 pub fn LLVMSetDataLayout(M: ModuleRef, Triple: *const c_char);
503 /** Target triple. See Module::getTargetTriple. */
504 pub fn LLVMGetTarget(M: ModuleRef) -> *const c_char;
505 pub fn LLVMSetTarget(M: ModuleRef, Triple: *const c_char);
507 /** See Module::dump. */
508 pub fn LLVMDumpModule(M: ModuleRef);
510 /** See Module::setModuleInlineAsm. */
511 pub fn LLVMSetModuleInlineAsm(M: ModuleRef, Asm: *const c_char);
513 /** See llvm::LLVMTypeKind::getTypeID. */
514 pub fn LLVMGetTypeKind(Ty: TypeRef) -> TypeKind;
516 /** See llvm::LLVMType::getContext. */
517 pub fn LLVMGetTypeContext(Ty: TypeRef) -> ContextRef;
519 /* Operations on integer types */
520 pub fn LLVMInt1TypeInContext(C: ContextRef) -> TypeRef;
521 pub fn LLVMInt8TypeInContext(C: ContextRef) -> TypeRef;
522 pub fn LLVMInt16TypeInContext(C: ContextRef) -> TypeRef;
523 pub fn LLVMInt32TypeInContext(C: ContextRef) -> TypeRef;
524 pub fn LLVMInt64TypeInContext(C: ContextRef) -> TypeRef;
525 pub fn LLVMIntTypeInContext(C: ContextRef, NumBits: c_uint)
528 pub fn LLVMGetIntTypeWidth(IntegerTy: TypeRef) -> c_uint;
530 /* Operations on real types */
531 pub fn LLVMFloatTypeInContext(C: ContextRef) -> TypeRef;
532 pub fn LLVMDoubleTypeInContext(C: ContextRef) -> TypeRef;
533 pub fn LLVMX86FP80TypeInContext(C: ContextRef) -> TypeRef;
534 pub fn LLVMFP128TypeInContext(C: ContextRef) -> TypeRef;
535 pub fn LLVMPPCFP128TypeInContext(C: ContextRef) -> TypeRef;
537 /* Operations on function types */
538 pub fn LLVMFunctionType(ReturnType: TypeRef,
539 ParamTypes: *const TypeRef,
543 pub fn LLVMIsFunctionVarArg(FunctionTy: TypeRef) -> Bool;
544 pub fn LLVMGetReturnType(FunctionTy: TypeRef) -> TypeRef;
545 pub fn LLVMCountParamTypes(FunctionTy: TypeRef) -> c_uint;
546 pub fn LLVMGetParamTypes(FunctionTy: TypeRef, Dest: *const TypeRef);
548 /* Operations on struct types */
549 pub fn LLVMStructTypeInContext(C: ContextRef,
550 ElementTypes: *const TypeRef,
551 ElementCount: c_uint,
554 pub fn LLVMCountStructElementTypes(StructTy: TypeRef) -> c_uint;
555 pub fn LLVMGetStructElementTypes(StructTy: TypeRef,
557 pub fn LLVMIsPackedStruct(StructTy: TypeRef) -> Bool;
559 /* Operations on array, pointer, and vector types (sequence types) */
560 pub fn LLVMRustArrayType(ElementType: TypeRef, ElementCount: u64) -> TypeRef;
561 pub fn LLVMPointerType(ElementType: TypeRef, AddressSpace: c_uint)
563 pub fn LLVMVectorType(ElementType: TypeRef, ElementCount: c_uint)
566 pub fn LLVMGetElementType(Ty: TypeRef) -> TypeRef;
567 pub fn LLVMGetArrayLength(ArrayTy: TypeRef) -> c_uint;
568 pub fn LLVMGetPointerAddressSpace(PointerTy: TypeRef) -> c_uint;
569 pub fn LLVMGetPointerToGlobal(EE: ExecutionEngineRef, V: ValueRef)
571 pub fn LLVMGetVectorSize(VectorTy: TypeRef) -> c_uint;
573 /* Operations on other types */
574 pub fn LLVMVoidTypeInContext(C: ContextRef) -> TypeRef;
575 pub fn LLVMLabelTypeInContext(C: ContextRef) -> TypeRef;
576 pub fn LLVMMetadataTypeInContext(C: ContextRef) -> TypeRef;
578 /* Operations on all values */
579 pub fn LLVMTypeOf(Val: ValueRef) -> TypeRef;
580 pub fn LLVMGetValueName(Val: ValueRef) -> *const c_char;
581 pub fn LLVMSetValueName(Val: ValueRef, Name: *const c_char);
582 pub fn LLVMDumpValue(Val: ValueRef);
583 pub fn LLVMReplaceAllUsesWith(OldVal: ValueRef, NewVal: ValueRef);
584 pub fn LLVMHasMetadata(Val: ValueRef) -> c_int;
585 pub fn LLVMGetMetadata(Val: ValueRef, KindID: c_uint) -> ValueRef;
586 pub fn LLVMSetMetadata(Val: ValueRef, KindID: c_uint, Node: ValueRef);
588 /* Operations on Uses */
589 pub fn LLVMGetFirstUse(Val: ValueRef) -> UseRef;
590 pub fn LLVMGetNextUse(U: UseRef) -> UseRef;
591 pub fn LLVMGetUser(U: UseRef) -> ValueRef;
592 pub fn LLVMGetUsedValue(U: UseRef) -> ValueRef;
594 /* Operations on Users */
595 pub fn LLVMGetNumOperands(Val: ValueRef) -> c_int;
596 pub fn LLVMGetOperand(Val: ValueRef, Index: c_uint) -> ValueRef;
597 pub fn LLVMSetOperand(Val: ValueRef, Index: c_uint, Op: ValueRef);
599 /* Operations on constants of any type */
600 pub fn LLVMConstNull(Ty: TypeRef) -> ValueRef;
602 pub fn LLVMConstAllOnes(Ty: TypeRef) -> ValueRef;
603 pub fn LLVMConstICmp(Pred: c_ushort, V1: ValueRef, V2: ValueRef)
605 pub fn LLVMConstFCmp(Pred: c_ushort, V1: ValueRef, V2: ValueRef)
607 /* only for int/vector */
608 pub fn LLVMGetUndef(Ty: TypeRef) -> ValueRef;
609 pub fn LLVMIsConstant(Val: ValueRef) -> Bool;
610 pub fn LLVMIsNull(Val: ValueRef) -> Bool;
611 pub fn LLVMIsUndef(Val: ValueRef) -> Bool;
612 pub fn LLVMConstPointerNull(Ty: TypeRef) -> ValueRef;
614 /* Operations on metadata */
615 pub fn LLVMMDStringInContext(C: ContextRef,
619 pub fn LLVMMDNodeInContext(C: ContextRef,
620 Vals: *const ValueRef,
623 pub fn LLVMAddNamedMetadataOperand(M: ModuleRef,
627 /* Operations on scalar constants */
628 pub fn LLVMConstInt(IntTy: TypeRef, N: c_ulonglong, SignExtend: Bool)
630 pub fn LLVMConstIntOfString(IntTy: TypeRef, Text: *const c_char, Radix: u8)
632 pub fn LLVMConstIntOfStringAndSize(IntTy: TypeRef,
637 pub fn LLVMConstReal(RealTy: TypeRef, N: f64) -> ValueRef;
638 pub fn LLVMConstRealOfString(RealTy: TypeRef, Text: *const c_char)
640 pub fn LLVMConstRealOfStringAndSize(RealTy: TypeRef,
644 pub fn LLVMConstIntGetZExtValue(ConstantVal: ValueRef) -> c_ulonglong;
645 pub fn LLVMConstIntGetSExtValue(ConstantVal: ValueRef) -> c_longlong;
648 /* Operations on composite constants */
649 pub fn LLVMConstStringInContext(C: ContextRef,
652 DontNullTerminate: Bool)
654 pub fn LLVMConstStructInContext(C: ContextRef,
655 ConstantVals: *const ValueRef,
660 pub fn LLVMConstArray(ElementTy: TypeRef,
661 ConstantVals: *const ValueRef,
664 pub fn LLVMConstVector(ScalarConstantVals: *const ValueRef, Size: c_uint)
667 /* Constant expressions */
668 pub fn LLVMAlignOf(Ty: TypeRef) -> ValueRef;
669 pub fn LLVMSizeOf(Ty: TypeRef) -> ValueRef;
670 pub fn LLVMConstNeg(ConstantVal: ValueRef) -> ValueRef;
671 pub fn LLVMConstNSWNeg(ConstantVal: ValueRef) -> ValueRef;
672 pub fn LLVMConstNUWNeg(ConstantVal: ValueRef) -> ValueRef;
673 pub fn LLVMConstFNeg(ConstantVal: ValueRef) -> ValueRef;
674 pub fn LLVMConstNot(ConstantVal: ValueRef) -> ValueRef;
675 pub fn LLVMConstAdd(LHSConstant: ValueRef, RHSConstant: ValueRef)
677 pub fn LLVMConstNSWAdd(LHSConstant: ValueRef, RHSConstant: ValueRef)
679 pub fn LLVMConstNUWAdd(LHSConstant: ValueRef, RHSConstant: ValueRef)
681 pub fn LLVMConstFAdd(LHSConstant: ValueRef, RHSConstant: ValueRef)
683 pub fn LLVMConstSub(LHSConstant: ValueRef, RHSConstant: ValueRef)
685 pub fn LLVMConstNSWSub(LHSConstant: ValueRef, RHSConstant: ValueRef)
687 pub fn LLVMConstNUWSub(LHSConstant: ValueRef, RHSConstant: ValueRef)
689 pub fn LLVMConstFSub(LHSConstant: ValueRef, RHSConstant: ValueRef)
691 pub fn LLVMConstMul(LHSConstant: ValueRef, RHSConstant: ValueRef)
693 pub fn LLVMConstNSWMul(LHSConstant: ValueRef, RHSConstant: ValueRef)
695 pub fn LLVMConstNUWMul(LHSConstant: ValueRef, RHSConstant: ValueRef)
697 pub fn LLVMConstFMul(LHSConstant: ValueRef, RHSConstant: ValueRef)
699 pub fn LLVMConstUDiv(LHSConstant: ValueRef, RHSConstant: ValueRef)
701 pub fn LLVMConstSDiv(LHSConstant: ValueRef, RHSConstant: ValueRef)
703 pub fn LLVMConstExactSDiv(LHSConstant: ValueRef,
704 RHSConstant: ValueRef)
706 pub fn LLVMConstFDiv(LHSConstant: ValueRef, RHSConstant: ValueRef)
708 pub fn LLVMConstURem(LHSConstant: ValueRef, RHSConstant: ValueRef)
710 pub fn LLVMConstSRem(LHSConstant: ValueRef, RHSConstant: ValueRef)
712 pub fn LLVMConstFRem(LHSConstant: ValueRef, RHSConstant: ValueRef)
714 pub fn LLVMConstAnd(LHSConstant: ValueRef, RHSConstant: ValueRef)
716 pub fn LLVMConstOr(LHSConstant: ValueRef, RHSConstant: ValueRef)
718 pub fn LLVMConstXor(LHSConstant: ValueRef, RHSConstant: ValueRef)
720 pub fn LLVMConstShl(LHSConstant: ValueRef, RHSConstant: ValueRef)
722 pub fn LLVMConstLShr(LHSConstant: ValueRef, RHSConstant: ValueRef)
724 pub fn LLVMConstAShr(LHSConstant: ValueRef, RHSConstant: ValueRef)
726 pub fn LLVMConstGEP(ConstantVal: ValueRef,
727 ConstantIndices: *const ValueRef,
730 pub fn LLVMConstInBoundsGEP(ConstantVal: ValueRef,
731 ConstantIndices: *const ValueRef,
734 pub fn LLVMConstTrunc(ConstantVal: ValueRef, ToType: TypeRef)
736 pub fn LLVMConstSExt(ConstantVal: ValueRef, ToType: TypeRef)
738 pub fn LLVMConstZExt(ConstantVal: ValueRef, ToType: TypeRef)
740 pub fn LLVMConstFPTrunc(ConstantVal: ValueRef, ToType: TypeRef)
742 pub fn LLVMConstFPExt(ConstantVal: ValueRef, ToType: TypeRef)
744 pub fn LLVMConstUIToFP(ConstantVal: ValueRef, ToType: TypeRef)
746 pub fn LLVMConstSIToFP(ConstantVal: ValueRef, ToType: TypeRef)
748 pub fn LLVMConstFPToUI(ConstantVal: ValueRef, ToType: TypeRef)
750 pub fn LLVMConstFPToSI(ConstantVal: ValueRef, ToType: TypeRef)
752 pub fn LLVMConstPtrToInt(ConstantVal: ValueRef, ToType: TypeRef)
754 pub fn LLVMConstIntToPtr(ConstantVal: ValueRef, ToType: TypeRef)
756 pub fn LLVMConstBitCast(ConstantVal: ValueRef, ToType: TypeRef)
758 pub fn LLVMConstZExtOrBitCast(ConstantVal: ValueRef, ToType: TypeRef)
760 pub fn LLVMConstSExtOrBitCast(ConstantVal: ValueRef, ToType: TypeRef)
762 pub fn LLVMConstTruncOrBitCast(ConstantVal: ValueRef, ToType: TypeRef)
764 pub fn LLVMConstPointerCast(ConstantVal: ValueRef, ToType: TypeRef)
766 pub fn LLVMConstIntCast(ConstantVal: ValueRef,
770 pub fn LLVMConstFPCast(ConstantVal: ValueRef, ToType: TypeRef)
772 pub fn LLVMConstSelect(ConstantCondition: ValueRef,
773 ConstantIfTrue: ValueRef,
774 ConstantIfFalse: ValueRef)
776 pub fn LLVMConstExtractElement(VectorConstant: ValueRef,
777 IndexConstant: ValueRef)
779 pub fn LLVMConstInsertElement(VectorConstant: ValueRef,
780 ElementValueConstant: ValueRef,
781 IndexConstant: ValueRef)
783 pub fn LLVMConstShuffleVector(VectorAConstant: ValueRef,
784 VectorBConstant: ValueRef,
785 MaskConstant: ValueRef)
787 pub fn LLVMConstExtractValue(AggConstant: ValueRef,
788 IdxList: *const c_uint,
791 pub fn LLVMConstInsertValue(AggConstant: ValueRef,
792 ElementValueConstant: ValueRef,
793 IdxList: *const c_uint,
796 pub fn LLVMConstInlineAsm(Ty: TypeRef,
797 AsmString: *const c_char,
798 Constraints: *const c_char,
799 HasSideEffects: Bool,
802 pub fn LLVMBlockAddress(F: ValueRef, BB: BasicBlockRef) -> ValueRef;
806 /* Operations on global variables, functions, and aliases (globals) */
807 pub fn LLVMGetGlobalParent(Global: ValueRef) -> ModuleRef;
808 pub fn LLVMIsDeclaration(Global: ValueRef) -> Bool;
809 pub fn LLVMGetLinkage(Global: ValueRef) -> c_uint;
810 pub fn LLVMSetLinkage(Global: ValueRef, Link: c_uint);
811 pub fn LLVMGetSection(Global: ValueRef) -> *const c_char;
812 pub fn LLVMSetSection(Global: ValueRef, Section: *const c_char);
813 pub fn LLVMGetVisibility(Global: ValueRef) -> c_uint;
814 pub fn LLVMSetVisibility(Global: ValueRef, Viz: c_uint);
815 pub fn LLVMGetAlignment(Global: ValueRef) -> c_uint;
816 pub fn LLVMSetAlignment(Global: ValueRef, Bytes: c_uint);
819 /* Operations on global variables */
820 pub fn LLVMAddGlobal(M: ModuleRef, Ty: TypeRef, Name: *const c_char)
822 pub fn LLVMAddGlobalInAddressSpace(M: ModuleRef,
825 AddressSpace: c_uint)
827 pub fn LLVMGetNamedGlobal(M: ModuleRef, Name: *const c_char) -> ValueRef;
828 pub fn LLVMGetFirstGlobal(M: ModuleRef) -> ValueRef;
829 pub fn LLVMGetLastGlobal(M: ModuleRef) -> ValueRef;
830 pub fn LLVMGetNextGlobal(GlobalVar: ValueRef) -> ValueRef;
831 pub fn LLVMGetPreviousGlobal(GlobalVar: ValueRef) -> ValueRef;
832 pub fn LLVMDeleteGlobal(GlobalVar: ValueRef);
833 pub fn LLVMGetInitializer(GlobalVar: ValueRef) -> ValueRef;
834 pub fn LLVMSetInitializer(GlobalVar: ValueRef,
835 ConstantVal: ValueRef);
836 pub fn LLVMIsThreadLocal(GlobalVar: ValueRef) -> Bool;
837 pub fn LLVMSetThreadLocal(GlobalVar: ValueRef, IsThreadLocal: Bool);
838 pub fn LLVMIsGlobalConstant(GlobalVar: ValueRef) -> Bool;
839 pub fn LLVMSetGlobalConstant(GlobalVar: ValueRef, IsConstant: Bool);
841 /* Operations on aliases */
842 pub fn LLVMAddAlias(M: ModuleRef,
848 /* Operations on functions */
849 pub fn LLVMAddFunction(M: ModuleRef,
853 pub fn LLVMGetNamedFunction(M: ModuleRef, Name: *const c_char) -> ValueRef;
854 pub fn LLVMGetFirstFunction(M: ModuleRef) -> ValueRef;
855 pub fn LLVMGetLastFunction(M: ModuleRef) -> ValueRef;
856 pub fn LLVMGetNextFunction(Fn: ValueRef) -> ValueRef;
857 pub fn LLVMGetPreviousFunction(Fn: ValueRef) -> ValueRef;
858 pub fn LLVMDeleteFunction(Fn: ValueRef);
859 pub fn LLVMGetOrInsertFunction(M: ModuleRef,
863 pub fn LLVMGetIntrinsicID(Fn: ValueRef) -> c_uint;
864 pub fn LLVMGetFunctionCallConv(Fn: ValueRef) -> c_uint;
865 pub fn LLVMSetFunctionCallConv(Fn: ValueRef, CC: c_uint);
866 pub fn LLVMGetGC(Fn: ValueRef) -> *const c_char;
867 pub fn LLVMSetGC(Fn: ValueRef, Name: *const c_char);
868 pub fn LLVMAddDereferenceableAttr(Fn: ValueRef, index: c_uint, bytes: uint64_t);
869 pub fn LLVMAddFunctionAttribute(Fn: ValueRef, index: c_uint, PA: uint64_t);
870 pub fn LLVMAddFunctionAttrString(Fn: ValueRef, index: c_uint, Name: *const c_char);
871 pub fn LLVMRemoveFunctionAttrString(Fn: ValueRef, index: c_uint, Name: *const c_char);
872 pub fn LLVMGetFunctionAttr(Fn: ValueRef) -> c_ulonglong;
874 /* Operations on parameters */
875 pub fn LLVMCountParams(Fn: ValueRef) -> c_uint;
876 pub fn LLVMGetParams(Fn: ValueRef, Params: *const ValueRef);
877 pub fn LLVMGetParam(Fn: ValueRef, Index: c_uint) -> ValueRef;
878 pub fn LLVMGetParamParent(Inst: ValueRef) -> ValueRef;
879 pub fn LLVMGetFirstParam(Fn: ValueRef) -> ValueRef;
880 pub fn LLVMGetLastParam(Fn: ValueRef) -> ValueRef;
881 pub fn LLVMGetNextParam(Arg: ValueRef) -> ValueRef;
882 pub fn LLVMGetPreviousParam(Arg: ValueRef) -> ValueRef;
883 pub fn LLVMAddAttribute(Arg: ValueRef, PA: c_uint);
884 pub fn LLVMRemoveAttribute(Arg: ValueRef, PA: c_uint);
885 pub fn LLVMGetAttribute(Arg: ValueRef) -> c_uint;
886 pub fn LLVMSetParamAlignment(Arg: ValueRef, align: c_uint);
888 /* Operations on basic blocks */
889 pub fn LLVMBasicBlockAsValue(BB: BasicBlockRef) -> ValueRef;
890 pub fn LLVMValueIsBasicBlock(Val: ValueRef) -> Bool;
891 pub fn LLVMValueAsBasicBlock(Val: ValueRef) -> BasicBlockRef;
892 pub fn LLVMGetBasicBlockParent(BB: BasicBlockRef) -> ValueRef;
893 pub fn LLVMCountBasicBlocks(Fn: ValueRef) -> c_uint;
894 pub fn LLVMGetBasicBlocks(Fn: ValueRef, BasicBlocks: *const ValueRef);
895 pub fn LLVMGetFirstBasicBlock(Fn: ValueRef) -> BasicBlockRef;
896 pub fn LLVMGetLastBasicBlock(Fn: ValueRef) -> BasicBlockRef;
897 pub fn LLVMGetNextBasicBlock(BB: BasicBlockRef) -> BasicBlockRef;
898 pub fn LLVMGetPreviousBasicBlock(BB: BasicBlockRef) -> BasicBlockRef;
899 pub fn LLVMGetEntryBasicBlock(Fn: ValueRef) -> BasicBlockRef;
901 pub fn LLVMAppendBasicBlockInContext(C: ContextRef,
905 pub fn LLVMInsertBasicBlockInContext(C: ContextRef,
909 pub fn LLVMDeleteBasicBlock(BB: BasicBlockRef);
911 pub fn LLVMMoveBasicBlockAfter(BB: BasicBlockRef,
912 MoveAfter: BasicBlockRef);
914 pub fn LLVMMoveBasicBlockBefore(BB: BasicBlockRef,
915 MoveBefore: BasicBlockRef);
917 /* Operations on instructions */
918 pub fn LLVMGetInstructionParent(Inst: ValueRef) -> BasicBlockRef;
919 pub fn LLVMGetFirstInstruction(BB: BasicBlockRef) -> ValueRef;
920 pub fn LLVMGetLastInstruction(BB: BasicBlockRef) -> ValueRef;
921 pub fn LLVMGetNextInstruction(Inst: ValueRef) -> ValueRef;
922 pub fn LLVMGetPreviousInstruction(Inst: ValueRef) -> ValueRef;
923 pub fn LLVMInstructionEraseFromParent(Inst: ValueRef);
925 /* Operations on call sites */
926 pub fn LLVMSetInstructionCallConv(Instr: ValueRef, CC: c_uint);
927 pub fn LLVMGetInstructionCallConv(Instr: ValueRef) -> c_uint;
928 pub fn LLVMAddInstrAttribute(Instr: ValueRef,
931 pub fn LLVMRemoveInstrAttribute(Instr: ValueRef,
934 pub fn LLVMSetInstrParamAlignment(Instr: ValueRef,
937 pub fn LLVMAddCallSiteAttribute(Instr: ValueRef,
940 pub fn LLVMAddDereferenceableCallSiteAttr(Instr: ValueRef,
944 /* Operations on call instructions (only) */
945 pub fn LLVMIsTailCall(CallInst: ValueRef) -> Bool;
946 pub fn LLVMSetTailCall(CallInst: ValueRef, IsTailCall: Bool);
948 /* Operations on load/store instructions (only) */
949 pub fn LLVMGetVolatile(MemoryAccessInst: ValueRef) -> Bool;
950 pub fn LLVMSetVolatile(MemoryAccessInst: ValueRef, volatile: Bool);
952 /* Operations on phi nodes */
953 pub fn LLVMAddIncoming(PhiNode: ValueRef,
954 IncomingValues: *const ValueRef,
955 IncomingBlocks: *const BasicBlockRef,
957 pub fn LLVMCountIncoming(PhiNode: ValueRef) -> c_uint;
958 pub fn LLVMGetIncomingValue(PhiNode: ValueRef, Index: c_uint)
960 pub fn LLVMGetIncomingBlock(PhiNode: ValueRef, Index: c_uint)
963 /* Instruction builders */
964 pub fn LLVMCreateBuilderInContext(C: ContextRef) -> BuilderRef;
965 pub fn LLVMPositionBuilder(Builder: BuilderRef,
966 Block: BasicBlockRef,
968 pub fn LLVMPositionBuilderBefore(Builder: BuilderRef,
970 pub fn LLVMPositionBuilderAtEnd(Builder: BuilderRef,
971 Block: BasicBlockRef);
972 pub fn LLVMGetInsertBlock(Builder: BuilderRef) -> BasicBlockRef;
973 pub fn LLVMClearInsertionPosition(Builder: BuilderRef);
974 pub fn LLVMInsertIntoBuilder(Builder: BuilderRef, Instr: ValueRef);
975 pub fn LLVMInsertIntoBuilderWithName(Builder: BuilderRef,
977 Name: *const c_char);
978 pub fn LLVMDisposeBuilder(Builder: BuilderRef);
979 pub fn LLVMDisposeExecutionEngine(EE: ExecutionEngineRef);
982 pub fn LLVMSetCurrentDebugLocation(Builder: BuilderRef, L: ValueRef);
983 pub fn LLVMGetCurrentDebugLocation(Builder: BuilderRef) -> ValueRef;
984 pub fn LLVMSetInstDebugLocation(Builder: BuilderRef, Inst: ValueRef);
987 pub fn LLVMBuildRetVoid(B: BuilderRef) -> ValueRef;
988 pub fn LLVMBuildRet(B: BuilderRef, V: ValueRef) -> ValueRef;
989 pub fn LLVMBuildAggregateRet(B: BuilderRef,
990 RetVals: *const ValueRef,
993 pub fn LLVMBuildBr(B: BuilderRef, Dest: BasicBlockRef) -> ValueRef;
994 pub fn LLVMBuildCondBr(B: BuilderRef,
999 pub fn LLVMBuildSwitch(B: BuilderRef,
1001 Else: BasicBlockRef,
1004 pub fn LLVMBuildIndirectBr(B: BuilderRef,
1008 pub fn LLVMBuildInvoke(B: BuilderRef,
1010 Args: *const ValueRef,
1012 Then: BasicBlockRef,
1013 Catch: BasicBlockRef,
1014 Name: *const c_char)
1016 pub fn LLVMBuildLandingPad(B: BuilderRef,
1020 Name: *const c_char)
1022 pub fn LLVMBuildResume(B: BuilderRef, Exn: ValueRef) -> ValueRef;
1023 pub fn LLVMBuildUnreachable(B: BuilderRef) -> ValueRef;
1025 /* Add a case to the switch instruction */
1026 pub fn LLVMAddCase(Switch: ValueRef,
1028 Dest: BasicBlockRef);
1030 /* Add a destination to the indirectbr instruction */
1031 pub fn LLVMAddDestination(IndirectBr: ValueRef, Dest: BasicBlockRef);
1033 /* Add a clause to the landing pad instruction */
1034 pub fn LLVMAddClause(LandingPad: ValueRef, ClauseVal: ValueRef);
1036 /* Set the cleanup on a landing pad instruction */
1037 pub fn LLVMSetCleanup(LandingPad: ValueRef, Val: Bool);
1040 pub fn LLVMBuildAdd(B: BuilderRef,
1043 Name: *const c_char)
1045 pub fn LLVMBuildNSWAdd(B: BuilderRef,
1048 Name: *const c_char)
1050 pub fn LLVMBuildNUWAdd(B: BuilderRef,
1053 Name: *const c_char)
1055 pub fn LLVMBuildFAdd(B: BuilderRef,
1058 Name: *const c_char)
1060 pub fn LLVMBuildSub(B: BuilderRef,
1063 Name: *const c_char)
1065 pub fn LLVMBuildNSWSub(B: BuilderRef,
1068 Name: *const c_char)
1070 pub fn LLVMBuildNUWSub(B: BuilderRef,
1073 Name: *const c_char)
1075 pub fn LLVMBuildFSub(B: BuilderRef,
1078 Name: *const c_char)
1080 pub fn LLVMBuildMul(B: BuilderRef,
1083 Name: *const c_char)
1085 pub fn LLVMBuildNSWMul(B: BuilderRef,
1088 Name: *const c_char)
1090 pub fn LLVMBuildNUWMul(B: BuilderRef,
1093 Name: *const c_char)
1095 pub fn LLVMBuildFMul(B: BuilderRef,
1098 Name: *const c_char)
1100 pub fn LLVMBuildUDiv(B: BuilderRef,
1103 Name: *const c_char)
1105 pub fn LLVMBuildSDiv(B: BuilderRef,
1108 Name: *const c_char)
1110 pub fn LLVMBuildExactSDiv(B: BuilderRef,
1113 Name: *const c_char)
1115 pub fn LLVMBuildFDiv(B: BuilderRef,
1118 Name: *const c_char)
1120 pub fn LLVMBuildURem(B: BuilderRef,
1123 Name: *const c_char)
1125 pub fn LLVMBuildSRem(B: BuilderRef,
1128 Name: *const c_char)
1130 pub fn LLVMBuildFRem(B: BuilderRef,
1133 Name: *const c_char)
1135 pub fn LLVMBuildShl(B: BuilderRef,
1138 Name: *const c_char)
1140 pub fn LLVMBuildLShr(B: BuilderRef,
1143 Name: *const c_char)
1145 pub fn LLVMBuildAShr(B: BuilderRef,
1148 Name: *const c_char)
1150 pub fn LLVMBuildAnd(B: BuilderRef,
1153 Name: *const c_char)
1155 pub fn LLVMBuildOr(B: BuilderRef,
1158 Name: *const c_char)
1160 pub fn LLVMBuildXor(B: BuilderRef,
1163 Name: *const c_char)
1165 pub fn LLVMBuildBinOp(B: BuilderRef,
1169 Name: *const c_char)
1171 pub fn LLVMBuildNeg(B: BuilderRef, V: ValueRef, Name: *const c_char)
1173 pub fn LLVMBuildNSWNeg(B: BuilderRef, V: ValueRef, Name: *const c_char)
1175 pub fn LLVMBuildNUWNeg(B: BuilderRef, V: ValueRef, Name: *const c_char)
1177 pub fn LLVMBuildFNeg(B: BuilderRef, V: ValueRef, Name: *const c_char)
1179 pub fn LLVMBuildNot(B: BuilderRef, V: ValueRef, Name: *const c_char)
1183 pub fn LLVMBuildMalloc(B: BuilderRef, Ty: TypeRef, Name: *const c_char)
1185 pub fn LLVMBuildArrayMalloc(B: BuilderRef,
1188 Name: *const c_char)
1190 pub fn LLVMBuildAlloca(B: BuilderRef, Ty: TypeRef, Name: *const c_char)
1192 pub fn LLVMBuildArrayAlloca(B: BuilderRef,
1195 Name: *const c_char)
1197 pub fn LLVMBuildFree(B: BuilderRef, PointerVal: ValueRef) -> ValueRef;
1198 pub fn LLVMBuildLoad(B: BuilderRef,
1199 PointerVal: ValueRef,
1200 Name: *const c_char)
1203 pub fn LLVMBuildStore(B: BuilderRef, Val: ValueRef, Ptr: ValueRef)
1206 pub fn LLVMBuildGEP(B: BuilderRef,
1208 Indices: *const ValueRef,
1210 Name: *const c_char)
1212 pub fn LLVMBuildInBoundsGEP(B: BuilderRef,
1214 Indices: *const ValueRef,
1216 Name: *const c_char)
1218 pub fn LLVMBuildStructGEP(B: BuilderRef,
1221 Name: *const c_char)
1223 pub fn LLVMBuildGlobalString(B: BuilderRef,
1225 Name: *const c_char)
1227 pub fn LLVMBuildGlobalStringPtr(B: BuilderRef,
1229 Name: *const c_char)
1233 pub fn LLVMBuildTrunc(B: BuilderRef,
1236 Name: *const c_char)
1238 pub fn LLVMBuildZExt(B: BuilderRef,
1241 Name: *const c_char)
1243 pub fn LLVMBuildSExt(B: BuilderRef,
1246 Name: *const c_char)
1248 pub fn LLVMBuildFPToUI(B: BuilderRef,
1251 Name: *const c_char)
1253 pub fn LLVMBuildFPToSI(B: BuilderRef,
1256 Name: *const c_char)
1258 pub fn LLVMBuildUIToFP(B: BuilderRef,
1261 Name: *const c_char)
1263 pub fn LLVMBuildSIToFP(B: BuilderRef,
1266 Name: *const c_char)
1268 pub fn LLVMBuildFPTrunc(B: BuilderRef,
1271 Name: *const c_char)
1273 pub fn LLVMBuildFPExt(B: BuilderRef,
1276 Name: *const c_char)
1278 pub fn LLVMBuildPtrToInt(B: BuilderRef,
1281 Name: *const c_char)
1283 pub fn LLVMBuildIntToPtr(B: BuilderRef,
1286 Name: *const c_char)
1288 pub fn LLVMBuildBitCast(B: BuilderRef,
1291 Name: *const c_char)
1293 pub fn LLVMBuildZExtOrBitCast(B: BuilderRef,
1296 Name: *const c_char)
1298 pub fn LLVMBuildSExtOrBitCast(B: BuilderRef,
1301 Name: *const c_char)
1303 pub fn LLVMBuildTruncOrBitCast(B: BuilderRef,
1306 Name: *const c_char)
1308 pub fn LLVMBuildCast(B: BuilderRef,
1312 Name: *const c_char) -> ValueRef;
1313 pub fn LLVMBuildPointerCast(B: BuilderRef,
1316 Name: *const c_char)
1318 pub fn LLVMBuildIntCast(B: BuilderRef,
1321 Name: *const c_char)
1323 pub fn LLVMBuildFPCast(B: BuilderRef,
1326 Name: *const c_char)
1330 pub fn LLVMBuildICmp(B: BuilderRef,
1334 Name: *const c_char)
1336 pub fn LLVMBuildFCmp(B: BuilderRef,
1340 Name: *const c_char)
1343 /* Miscellaneous instructions */
1344 pub fn LLVMBuildPhi(B: BuilderRef, Ty: TypeRef, Name: *const c_char)
1346 pub fn LLVMBuildCall(B: BuilderRef,
1348 Args: *const ValueRef,
1350 Name: *const c_char)
1352 pub fn LLVMBuildSelect(B: BuilderRef,
1356 Name: *const c_char)
1358 pub fn LLVMBuildVAArg(B: BuilderRef,
1361 Name: *const c_char)
1363 pub fn LLVMBuildExtractElement(B: BuilderRef,
1366 Name: *const c_char)
1368 pub fn LLVMBuildInsertElement(B: BuilderRef,
1372 Name: *const c_char)
1374 pub fn LLVMBuildShuffleVector(B: BuilderRef,
1378 Name: *const c_char)
1380 pub fn LLVMBuildExtractValue(B: BuilderRef,
1383 Name: *const c_char)
1385 pub fn LLVMBuildInsertValue(B: BuilderRef,
1389 Name: *const c_char)
1392 pub fn LLVMBuildIsNull(B: BuilderRef, Val: ValueRef, Name: *const c_char)
1394 pub fn LLVMBuildIsNotNull(B: BuilderRef, Val: ValueRef, Name: *const c_char)
1396 pub fn LLVMBuildPtrDiff(B: BuilderRef,
1399 Name: *const c_char)
1402 /* Atomic Operations */
1403 pub fn LLVMBuildAtomicLoad(B: BuilderRef,
1404 PointerVal: ValueRef,
1405 Name: *const c_char,
1406 Order: AtomicOrdering,
1410 pub fn LLVMBuildAtomicStore(B: BuilderRef,
1413 Order: AtomicOrdering,
1417 pub fn LLVMBuildAtomicCmpXchg(B: BuilderRef,
1421 Order: AtomicOrdering,
1422 FailureOrder: AtomicOrdering)
1424 pub fn LLVMBuildAtomicRMW(B: BuilderRef,
1428 Order: AtomicOrdering,
1429 SingleThreaded: Bool)
1432 pub fn LLVMBuildAtomicFence(B: BuilderRef, Order: AtomicOrdering);
1435 /* Selected entries from the downcasts. */
1436 pub fn LLVMIsATerminatorInst(Inst: ValueRef) -> ValueRef;
1437 pub fn LLVMIsAStoreInst(Inst: ValueRef) -> ValueRef;
1439 /** Writes a module to the specified path. Returns 0 on success. */
1440 pub fn LLVMWriteBitcodeToFile(M: ModuleRef, Path: *const c_char) -> c_int;
1442 /** Creates target data from a target layout string. */
1443 pub fn LLVMCreateTargetData(StringRep: *const c_char) -> TargetDataRef;
1444 /// Adds the target data to the given pass manager. The pass manager
1445 /// references the target data only weakly.
1446 pub fn LLVMAddTargetData(TD: TargetDataRef, PM: PassManagerRef);
1447 /** Number of bytes clobbered when doing a Store to *T. */
1448 pub fn LLVMStoreSizeOfType(TD: TargetDataRef, Ty: TypeRef)
1451 /** Number of bytes clobbered when doing a Store to *T. */
1452 pub fn LLVMSizeOfTypeInBits(TD: TargetDataRef, Ty: TypeRef)
1455 /** Distance between successive elements in an array of T.
1456 Includes ABI padding. */
1457 pub fn LLVMABISizeOfType(TD: TargetDataRef, Ty: TypeRef) -> c_uint;
1459 /** Returns the preferred alignment of a type. */
1460 pub fn LLVMPreferredAlignmentOfType(TD: TargetDataRef, Ty: TypeRef)
1462 /** Returns the minimum alignment of a type. */
1463 pub fn LLVMABIAlignmentOfType(TD: TargetDataRef, Ty: TypeRef)
1466 /// Computes the byte offset of the indexed struct element for a
1468 pub fn LLVMOffsetOfElement(TD: TargetDataRef,
1474 * Returns the minimum alignment of a type when part of a call frame.
1476 pub fn LLVMCallFrameAlignmentOfType(TD: TargetDataRef, Ty: TypeRef)
1479 /** Disposes target data. */
1480 pub fn LLVMDisposeTargetData(TD: TargetDataRef);
1482 /** Creates a pass manager. */
1483 pub fn LLVMCreatePassManager() -> PassManagerRef;
1485 /** Creates a function-by-function pass manager */
1486 pub fn LLVMCreateFunctionPassManagerForModule(M: ModuleRef)
1489 /** Disposes a pass manager. */
1490 pub fn LLVMDisposePassManager(PM: PassManagerRef);
1492 /** Runs a pass manager on a module. */
1493 pub fn LLVMRunPassManager(PM: PassManagerRef, M: ModuleRef) -> Bool;
1495 /** Runs the function passes on the provided function. */
1496 pub fn LLVMRunFunctionPassManager(FPM: PassManagerRef, F: ValueRef)
1499 /** Initializes all the function passes scheduled in the manager */
1500 pub fn LLVMInitializeFunctionPassManager(FPM: PassManagerRef) -> Bool;
1502 /** Finalizes all the function passes scheduled in the manager */
1503 pub fn LLVMFinalizeFunctionPassManager(FPM: PassManagerRef) -> Bool;
1505 pub fn LLVMInitializePasses();
1507 /** Adds a verification pass. */
1508 pub fn LLVMAddVerifierPass(PM: PassManagerRef);
1510 pub fn LLVMAddGlobalOptimizerPass(PM: PassManagerRef);
1511 pub fn LLVMAddIPSCCPPass(PM: PassManagerRef);
1512 pub fn LLVMAddDeadArgEliminationPass(PM: PassManagerRef);
1513 pub fn LLVMAddInstructionCombiningPass(PM: PassManagerRef);
1514 pub fn LLVMAddCFGSimplificationPass(PM: PassManagerRef);
1515 pub fn LLVMAddFunctionInliningPass(PM: PassManagerRef);
1516 pub fn LLVMAddFunctionAttrsPass(PM: PassManagerRef);
1517 pub fn LLVMAddScalarReplAggregatesPass(PM: PassManagerRef);
1518 pub fn LLVMAddScalarReplAggregatesPassSSA(PM: PassManagerRef);
1519 pub fn LLVMAddJumpThreadingPass(PM: PassManagerRef);
1520 pub fn LLVMAddConstantPropagationPass(PM: PassManagerRef);
1521 pub fn LLVMAddReassociatePass(PM: PassManagerRef);
1522 pub fn LLVMAddLoopRotatePass(PM: PassManagerRef);
1523 pub fn LLVMAddLICMPass(PM: PassManagerRef);
1524 pub fn LLVMAddLoopUnswitchPass(PM: PassManagerRef);
1525 pub fn LLVMAddLoopDeletionPass(PM: PassManagerRef);
1526 pub fn LLVMAddLoopUnrollPass(PM: PassManagerRef);
1527 pub fn LLVMAddGVNPass(PM: PassManagerRef);
1528 pub fn LLVMAddMemCpyOptPass(PM: PassManagerRef);
1529 pub fn LLVMAddSCCPPass(PM: PassManagerRef);
1530 pub fn LLVMAddDeadStoreEliminationPass(PM: PassManagerRef);
1531 pub fn LLVMAddStripDeadPrototypesPass(PM: PassManagerRef);
1532 pub fn LLVMAddConstantMergePass(PM: PassManagerRef);
1533 pub fn LLVMAddArgumentPromotionPass(PM: PassManagerRef);
1534 pub fn LLVMAddTailCallEliminationPass(PM: PassManagerRef);
1535 pub fn LLVMAddIndVarSimplifyPass(PM: PassManagerRef);
1536 pub fn LLVMAddAggressiveDCEPass(PM: PassManagerRef);
1537 pub fn LLVMAddGlobalDCEPass(PM: PassManagerRef);
1538 pub fn LLVMAddCorrelatedValuePropagationPass(PM: PassManagerRef);
1539 pub fn LLVMAddPruneEHPass(PM: PassManagerRef);
1540 pub fn LLVMAddSimplifyLibCallsPass(PM: PassManagerRef);
1541 pub fn LLVMAddLoopIdiomPass(PM: PassManagerRef);
1542 pub fn LLVMAddEarlyCSEPass(PM: PassManagerRef);
1543 pub fn LLVMAddTypeBasedAliasAnalysisPass(PM: PassManagerRef);
1544 pub fn LLVMAddBasicAliasAnalysisPass(PM: PassManagerRef);
1546 pub fn LLVMPassManagerBuilderCreate() -> PassManagerBuilderRef;
1547 pub fn LLVMPassManagerBuilderDispose(PMB: PassManagerBuilderRef);
1548 pub fn LLVMPassManagerBuilderSetOptLevel(PMB: PassManagerBuilderRef,
1549 OptimizationLevel: c_uint);
1550 pub fn LLVMPassManagerBuilderSetSizeLevel(PMB: PassManagerBuilderRef,
1552 pub fn LLVMPassManagerBuilderSetDisableUnitAtATime(
1553 PMB: PassManagerBuilderRef,
1555 pub fn LLVMPassManagerBuilderSetDisableUnrollLoops(
1556 PMB: PassManagerBuilderRef,
1558 pub fn LLVMPassManagerBuilderSetDisableSimplifyLibCalls(
1559 PMB: PassManagerBuilderRef,
1561 pub fn LLVMPassManagerBuilderUseInlinerWithThreshold(
1562 PMB: PassManagerBuilderRef,
1564 pub fn LLVMPassManagerBuilderPopulateModulePassManager(
1565 PMB: PassManagerBuilderRef,
1566 PM: PassManagerRef);
1568 pub fn LLVMPassManagerBuilderPopulateFunctionPassManager(
1569 PMB: PassManagerBuilderRef,
1570 PM: PassManagerRef);
1571 pub fn LLVMPassManagerBuilderPopulateLTOPassManager(
1572 PMB: PassManagerBuilderRef,
1577 /** Destroys a memory buffer. */
1578 pub fn LLVMDisposeMemoryBuffer(MemBuf: MemoryBufferRef);
1581 /* Stuff that's in rustllvm/ because it's not upstream yet. */
1583 /** Opens an object file. */
1584 pub fn LLVMCreateObjectFile(MemBuf: MemoryBufferRef) -> ObjectFileRef;
1585 /** Closes an object file. */
1586 pub fn LLVMDisposeObjectFile(ObjFile: ObjectFileRef);
1588 /** Enumerates the sections in an object file. */
1589 pub fn LLVMGetSections(ObjFile: ObjectFileRef) -> SectionIteratorRef;
1590 /** Destroys a section iterator. */
1591 pub fn LLVMDisposeSectionIterator(SI: SectionIteratorRef);
1592 /** Returns true if the section iterator is at the end of the section
1594 pub fn LLVMIsSectionIteratorAtEnd(ObjFile: ObjectFileRef,
1595 SI: SectionIteratorRef)
1597 /** Moves the section iterator to point to the next section. */
1598 pub fn LLVMMoveToNextSection(SI: SectionIteratorRef);
1599 /** Returns the current section size. */
1600 pub fn LLVMGetSectionSize(SI: SectionIteratorRef) -> c_ulonglong;
1601 /** Returns the current section contents as a string buffer. */
1602 pub fn LLVMGetSectionContents(SI: SectionIteratorRef) -> *const c_char;
1604 /** Reads the given file and returns it as a memory buffer. Use
1605 LLVMDisposeMemoryBuffer() to get rid of it. */
1606 pub fn LLVMRustCreateMemoryBufferWithContentsOfFile(Path: *const c_char)
1608 /** Borrows the contents of the memory buffer (doesn't copy it) */
1609 pub fn LLVMCreateMemoryBufferWithMemoryRange(InputData: *const c_char,
1610 InputDataLength: size_t,
1611 BufferName: *const c_char,
1614 pub fn LLVMCreateMemoryBufferWithMemoryRangeCopy(InputData: *const c_char,
1615 InputDataLength: size_t,
1616 BufferName: *const c_char)
1619 pub fn LLVMIsMultithreaded() -> Bool;
1620 pub fn LLVMStartMultithreaded() -> Bool;
1622 /** Returns a string describing the last error caused by an LLVMRust*
1624 pub fn LLVMRustGetLastError() -> *const c_char;
1626 /// Print the pass timings since static dtors aren't picking them up.
1627 pub fn LLVMRustPrintPassTimings();
1629 pub fn LLVMStructCreateNamed(C: ContextRef, Name: *const c_char) -> TypeRef;
1631 pub fn LLVMStructSetBody(StructTy: TypeRef,
1632 ElementTypes: *const TypeRef,
1633 ElementCount: c_uint,
1636 pub fn LLVMConstNamedStruct(S: TypeRef,
1637 ConstantVals: *const ValueRef,
1641 /** Enables LLVM debug output. */
1642 pub fn LLVMSetDebug(Enabled: c_int);
1644 /** Prepares inline assembly. */
1645 pub fn LLVMInlineAsm(Ty: TypeRef,
1646 AsmString: *const c_char,
1647 Constraints: *const c_char,
1653 pub static LLVMRustDebugMetadataVersion: u32;
1655 pub fn LLVMRustAddModuleFlag(M: ModuleRef,
1656 name: *const c_char,
1659 pub fn LLVMDIBuilderCreate(M: ModuleRef) -> DIBuilderRef;
1661 pub fn LLVMDIBuilderDispose(Builder: DIBuilderRef);
1663 pub fn LLVMDIBuilderFinalize(Builder: DIBuilderRef);
1665 pub fn LLVMDIBuilderCreateCompileUnit(Builder: DIBuilderRef,
1667 File: *const c_char,
1669 Producer: *const c_char,
1671 Flags: *const c_char,
1673 SplitName: *const c_char);
1675 pub fn LLVMDIBuilderCreateFile(Builder: DIBuilderRef,
1676 Filename: *const c_char,
1677 Directory: *const c_char)
1680 pub fn LLVMDIBuilderCreateSubroutineType(Builder: DIBuilderRef,
1682 ParameterTypes: DIArray)
1685 pub fn LLVMDIBuilderCreateFunction(Builder: DIBuilderRef,
1686 Scope: DIDescriptor,
1687 Name: *const c_char,
1688 LinkageName: *const c_char,
1692 isLocalToUnit: bool,
1702 pub fn LLVMDIBuilderCreateBasicType(Builder: DIBuilderRef,
1703 Name: *const c_char,
1704 SizeInBits: c_ulonglong,
1705 AlignInBits: c_ulonglong,
1709 pub fn LLVMDIBuilderCreatePointerType(Builder: DIBuilderRef,
1711 SizeInBits: c_ulonglong,
1712 AlignInBits: c_ulonglong,
1713 Name: *const c_char)
1716 pub fn LLVMDIBuilderCreateStructType(Builder: DIBuilderRef,
1717 Scope: DIDescriptor,
1718 Name: *const c_char,
1721 SizeInBits: c_ulonglong,
1722 AlignInBits: c_ulonglong,
1724 DerivedFrom: DIType,
1726 RunTimeLang: c_uint,
1727 VTableHolder: ValueRef,
1728 UniqueId: *const c_char)
1731 pub fn LLVMDIBuilderCreateMemberType(Builder: DIBuilderRef,
1732 Scope: DIDescriptor,
1733 Name: *const c_char,
1736 SizeInBits: c_ulonglong,
1737 AlignInBits: c_ulonglong,
1738 OffsetInBits: c_ulonglong,
1743 pub fn LLVMDIBuilderCreateLexicalBlock(Builder: DIBuilderRef,
1744 Scope: DIDescriptor,
1748 Discriminator: c_uint)
1751 pub fn LLVMDIBuilderCreateStaticVariable(Builder: DIBuilderRef,
1752 Context: DIDescriptor,
1753 Name: *const c_char,
1754 LinkageName: *const c_char,
1758 isLocalToUnit: bool,
1761 -> DIGlobalVariable;
1763 pub fn LLVMDIBuilderCreateLocalVariable(Builder: DIBuilderRef,
1765 Scope: DIDescriptor,
1766 Name: *const c_char,
1770 AlwaysPreserve: bool,
1775 pub fn LLVMDIBuilderCreateArrayType(Builder: DIBuilderRef,
1777 AlignInBits: c_ulonglong,
1779 Subscripts: DIArray)
1782 pub fn LLVMDIBuilderCreateVectorType(Builder: DIBuilderRef,
1784 AlignInBits: c_ulonglong,
1786 Subscripts: DIArray)
1789 pub fn LLVMDIBuilderGetOrCreateSubrange(Builder: DIBuilderRef,
1794 pub fn LLVMDIBuilderGetOrCreateArray(Builder: DIBuilderRef,
1795 Ptr: *const DIDescriptor,
1799 pub fn LLVMDIBuilderInsertDeclareAtEnd(Builder: DIBuilderRef,
1801 VarInfo: DIVariable,
1802 InsertAtEnd: BasicBlockRef)
1805 pub fn LLVMDIBuilderInsertDeclareBefore(Builder: DIBuilderRef,
1807 VarInfo: DIVariable,
1808 InsertBefore: ValueRef)
1811 pub fn LLVMDIBuilderCreateEnumerator(Builder: DIBuilderRef,
1812 Name: *const c_char,
1816 pub fn LLVMDIBuilderCreateEnumerationType(Builder: DIBuilderRef,
1818 Name: *const c_char,
1821 SizeInBits: c_ulonglong,
1822 AlignInBits: c_ulonglong,
1824 ClassType: ValueRef)
1827 pub fn LLVMDIBuilderCreateUnionType(Builder: DIBuilderRef,
1829 Name: *const c_char,
1832 SizeInBits: c_ulonglong,
1833 AlignInBits: c_ulonglong,
1836 RunTimeLang: c_uint,
1837 UniqueId: *const c_char)
1840 pub fn LLVMSetUnnamedAddr(GlobalVar: ValueRef, UnnamedAddr: Bool);
1842 pub fn LLVMDIBuilderCreateTemplateTypeParameter(Builder: DIBuilderRef,
1844 Name: *const c_char,
1851 pub fn LLVMDIBuilderCreateOpDeref(IntType: TypeRef) -> ValueRef;
1853 pub fn LLVMDIBuilderCreateOpPlus(IntType: TypeRef) -> ValueRef;
1855 pub fn LLVMDIBuilderCreateComplexVariable(Builder: DIBuilderRef,
1858 Name: *const c_char,
1862 AddrOps: *const ValueRef,
1863 AddrOpsCount: c_uint,
1867 pub fn LLVMDIBuilderCreateNameSpace(Builder: DIBuilderRef,
1869 Name: *const c_char,
1874 pub fn LLVMDICompositeTypeSetTypeArray(CompositeType: ValueRef, TypeArray: ValueRef);
1875 pub fn LLVMWriteTypeToString(Type: TypeRef, s: RustStringRef);
1876 pub fn LLVMWriteValueToString(value_ref: ValueRef, s: RustStringRef);
1878 pub fn LLVMIsAArgument(value_ref: ValueRef) -> ValueRef;
1880 pub fn LLVMIsAAllocaInst(value_ref: ValueRef) -> ValueRef;
1882 pub fn LLVMInitializeX86TargetInfo();
1883 pub fn LLVMInitializeX86Target();
1884 pub fn LLVMInitializeX86TargetMC();
1885 pub fn LLVMInitializeX86AsmPrinter();
1886 pub fn LLVMInitializeX86AsmParser();
1887 pub fn LLVMInitializeARMTargetInfo();
1888 pub fn LLVMInitializeARMTarget();
1889 pub fn LLVMInitializeARMTargetMC();
1890 pub fn LLVMInitializeARMAsmPrinter();
1891 pub fn LLVMInitializeARMAsmParser();
1892 pub fn LLVMInitializeMipsTargetInfo();
1893 pub fn LLVMInitializeMipsTarget();
1894 pub fn LLVMInitializeMipsTargetMC();
1895 pub fn LLVMInitializeMipsAsmPrinter();
1896 pub fn LLVMInitializeMipsAsmParser();
1898 pub fn LLVMRustAddPass(PM: PassManagerRef, Pass: *const c_char) -> bool;
1899 pub fn LLVMRustCreateTargetMachine(Triple: *const c_char,
1901 Features: *const c_char,
1902 Model: CodeGenModel,
1904 Level: CodeGenOptLevel,
1907 NoFramePointerElim: bool,
1908 FunctionSections: bool,
1909 DataSections: bool) -> TargetMachineRef;
1910 pub fn LLVMRustDisposeTargetMachine(T: TargetMachineRef);
1911 pub fn LLVMRustAddAnalysisPasses(T: TargetMachineRef,
1914 pub fn LLVMRustAddBuilderLibraryInfo(PMB: PassManagerBuilderRef,
1916 DisableSimplifyLibCalls: bool);
1917 pub fn LLVMRustAddLibraryInfo(PM: PassManagerRef, M: ModuleRef,
1918 DisableSimplifyLibCalls: bool);
1919 pub fn LLVMRustRunFunctionPassManager(PM: PassManagerRef, M: ModuleRef);
1920 pub fn LLVMRustWriteOutputFile(T: TargetMachineRef,
1923 Output: *const c_char,
1924 FileType: FileType) -> bool;
1925 pub fn LLVMRustPrintModule(PM: PassManagerRef,
1927 Output: *const c_char);
1928 pub fn LLVMRustSetLLVMOptions(Argc: c_int, Argv: *const *const c_char);
1929 pub fn LLVMRustPrintPasses();
1930 pub fn LLVMRustSetNormalizedTarget(M: ModuleRef, triple: *const c_char);
1931 pub fn LLVMRustAddAlwaysInlinePass(P: PassManagerBuilderRef,
1932 AddLifetimes: bool);
1933 pub fn LLVMRustLinkInExternalBitcode(M: ModuleRef,
1935 len: size_t) -> bool;
1936 pub fn LLVMRustRunRestrictionPass(M: ModuleRef,
1937 syms: *const *const c_char,
1939 pub fn LLVMRustMarkAllFunctionsNounwind(M: ModuleRef);
1941 pub fn LLVMRustOpenArchive(path: *const c_char) -> ArchiveRef;
1942 pub fn LLVMRustArchiveReadSection(AR: ArchiveRef, name: *const c_char,
1943 out_len: *mut size_t) -> *const c_char;
1944 pub fn LLVMRustDestroyArchive(AR: ArchiveRef);
1946 pub fn LLVMRustSetDLLExportStorageClass(V: ValueRef);
1947 pub fn LLVMVersionMajor() -> c_int;
1948 pub fn LLVMVersionMinor() -> c_int;
1950 pub fn LLVMRustGetSectionName(SI: SectionIteratorRef,
1951 data: *mut *const c_char) -> c_int;
1953 pub fn LLVMWriteTwineToString(T: TwineRef, s: RustStringRef);
1955 pub fn LLVMContextSetDiagnosticHandler(C: ContextRef,
1956 Handler: DiagnosticHandler,
1957 DiagnosticContext: *mut c_void);
1959 pub fn LLVMUnpackOptimizationDiagnostic(DI: DiagnosticInfoRef,
1960 pass_name_out: *mut *const c_char,
1961 function_out: *mut ValueRef,
1962 debugloc_out: *mut DebugLocRef,
1963 message_out: *mut TwineRef);
1965 pub fn LLVMWriteDiagnosticInfoToString(DI: DiagnosticInfoRef, s: RustStringRef);
1966 pub fn LLVMGetDiagInfoSeverity(DI: DiagnosticInfoRef) -> DiagnosticSeverity;
1967 pub fn LLVMGetDiagInfoKind(DI: DiagnosticInfoRef) -> DiagnosticKind;
1969 pub fn LLVMWriteDebugLocToString(C: ContextRef, DL: DebugLocRef, s: RustStringRef);
1972 pub fn SetInstructionCallConv(instr: ValueRef, cc: CallConv) {
1974 LLVMSetInstructionCallConv(instr, cc as c_uint);
1977 pub fn SetFunctionCallConv(fn_: ValueRef, cc: CallConv) {
1979 LLVMSetFunctionCallConv(fn_, cc as c_uint);
1982 pub fn SetLinkage(global: ValueRef, link: Linkage) {
1984 LLVMSetLinkage(global, link as c_uint);
1988 pub fn SetUnnamedAddr(global: ValueRef, unnamed: bool) {
1990 LLVMSetUnnamedAddr(global, unnamed as Bool);
1994 pub fn set_thread_local(global: ValueRef, is_thread_local: bool) {
1996 LLVMSetThreadLocal(global, is_thread_local as Bool);
2000 pub fn ConstICmp(pred: IntPredicate, v1: ValueRef, v2: ValueRef) -> ValueRef {
2002 LLVMConstICmp(pred as c_ushort, v1, v2)
2005 pub fn ConstFCmp(pred: RealPredicate, v1: ValueRef, v2: ValueRef) -> ValueRef {
2007 LLVMConstFCmp(pred as c_ushort, v1, v2)
2011 pub fn SetFunctionAttribute(fn_: ValueRef, attr: Attribute) {
2013 LLVMAddFunctionAttribute(fn_, FunctionIndex as c_uint, attr.bits() as uint64_t)
2017 /* Memory-managed interface to target data. */
2019 pub struct TargetData {
2020 pub lltd: TargetDataRef
2023 impl Drop for TargetData {
2024 fn drop(&mut self) {
2026 LLVMDisposeTargetData(self.lltd);
2031 pub fn mk_target_data(string_rep: &str) -> TargetData {
2033 lltd: string_rep.with_c_str(|buf| {
2034 unsafe { LLVMCreateTargetData(buf) }
2039 /* Memory-managed interface to object files. */
2041 pub struct ObjectFile {
2042 pub llof: ObjectFileRef,
2046 // This will take ownership of llmb
2047 pub fn new(llmb: MemoryBufferRef) -> Option<ObjectFile> {
2049 let llof = LLVMCreateObjectFile(llmb);
2050 if llof as int == 0 {
2051 // LLVMCreateObjectFile took ownership of llmb
2062 impl Drop for ObjectFile {
2063 fn drop(&mut self) {
2065 LLVMDisposeObjectFile(self.llof);
2070 /* Memory-managed interface to section iterators. */
2072 pub struct SectionIter {
2073 pub llsi: SectionIteratorRef
2076 impl Drop for SectionIter {
2077 fn drop(&mut self) {
2079 LLVMDisposeSectionIterator(self.llsi);
2084 pub fn mk_section_iter(llof: ObjectFileRef) -> SectionIter {
2087 llsi: LLVMGetSections(llof)
2092 /// Safe wrapper around `LLVMGetParam`, because segfaults are no fun.
2093 pub fn get_param(llfn: ValueRef, index: c_uint) -> ValueRef {
2095 assert!(index < LLVMCountParams(llfn));
2096 LLVMGetParam(llfn, index)
2100 pub enum RustString_opaque {}
2101 pub type RustStringRef = *mut RustString_opaque;
2102 type RustStringRepr = *mut RefCell<Vec<u8>>;
2104 /// Appending to a Rust string -- used by raw_rust_string_ostream.
2106 pub unsafe extern "C" fn rust_llvm_string_write_impl(sr: RustStringRef,
2109 let slice: &[u8] = mem::transmute(raw::Slice {
2110 data: ptr as *const u8,
2114 let sr: RustStringRepr = mem::transmute(sr);
2115 (*sr).borrow_mut().push_all(slice);
2118 pub fn build_string(f: |RustStringRef|) -> Option<String> {
2119 let mut buf = RefCell::new(Vec::new());
2120 f(&mut buf as RustStringRepr as RustStringRef);
2121 String::from_utf8(buf.unwrap()).ok()
2124 pub unsafe fn twine_to_string(tr: TwineRef) -> String {
2125 build_string(|s| LLVMWriteTwineToString(tr, s))
2126 .expect("got a non-UTF8 Twine from LLVM")
2129 pub unsafe fn debug_loc_to_string(c: ContextRef, tr: DebugLocRef) -> String {
2130 build_string(|s| LLVMWriteDebugLocToString(c, tr, s))
2131 .expect("got a non-UTF8 DebugLoc from LLVM")
2134 // FIXME #15460 - create a public function that actually calls our
2135 // static LLVM symbols. Otherwise the linker will just throw llvm
2136 // away. We're just calling lots of stuff until we transitively get
2137 // all of LLVM. This is worse than anything.
2138 pub unsafe fn static_link_hack_this_sucks() {
2139 LLVMInitializePasses();
2141 LLVMInitializeX86TargetInfo();
2142 LLVMInitializeX86Target();
2143 LLVMInitializeX86TargetMC();
2144 LLVMInitializeX86AsmPrinter();
2145 LLVMInitializeX86AsmParser();
2147 LLVMInitializeARMTargetInfo();
2148 LLVMInitializeARMTarget();
2149 LLVMInitializeARMTargetMC();
2150 LLVMInitializeARMAsmPrinter();
2151 LLVMInitializeARMAsmParser();
2153 LLVMInitializeMipsTargetInfo();
2154 LLVMInitializeMipsTarget();
2155 LLVMInitializeMipsTargetMC();
2156 LLVMInitializeMipsAsmPrinter();
2157 LLVMInitializeMipsAsmParser();
2159 LLVMRustSetLLVMOptions(0 as c_int,
2162 LLVMPassManagerBuilderPopulateModulePassManager(0 as *mut _, 0 as *mut _);
2163 LLVMPassManagerBuilderPopulateLTOPassManager(0 as *mut _, 0 as *mut _, False, False);
2164 LLVMPassManagerBuilderPopulateFunctionPassManager(0 as *mut _, 0 as *mut _);
2165 LLVMPassManagerBuilderSetOptLevel(0 as *mut _, 0 as c_uint);
2166 LLVMPassManagerBuilderUseInlinerWithThreshold(0 as *mut _, 0 as c_uint);
2167 LLVMWriteBitcodeToFile(0 as *mut _, 0 as *const _);
2168 LLVMPassManagerBuilderCreate();
2169 LLVMPassManagerBuilderDispose(0 as *mut _);
2171 LLVMRustLinkInExternalBitcode(0 as *mut _, 0 as *const _, 0 as size_t);
2175 LLVMLinkInInterpreter();
2179 fn LLVMLinkInMCJIT();
2180 fn LLVMLinkInInterpreter();
2184 // The module containing the native LLVM dependencies, generated by the build system
2185 // Note that this must come after the rustllvm extern declaration so that
2186 // parts of LLVM that rustllvm depends on aren't thrown away by the linker.
2187 // Works to the above fix for #15460 to ensure LLVM dependencies that
2188 // are only used by rustllvm don't get stripped by the linker.