2012-12-03 16:48:01 -08:00
|
|
|
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
|
|
|
|
// file at the top-level directory of this distribution and at
|
|
|
|
// http://rust-lang.org/COPYRIGHT.
|
|
|
|
//
|
|
|
|
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
|
|
|
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
|
|
|
// option. This file may not be copied, modified, or distributed
|
|
|
|
// except according to those terms.
|
|
|
|
|
2014-03-21 18:05:05 -07:00
|
|
|
#![allow(non_uppercase_pattern_statics)]
|
|
|
|
#![allow(non_camel_case_types)]
|
2014-04-01 10:17:18 -04:00
|
|
|
#![allow(dead_code)]
|
2013-08-14 21:41:40 -04:00
|
|
|
|
2013-08-03 17:13:14 -07:00
|
|
|
use std::c_str::ToCStr;
|
2013-12-19 16:22:26 -08:00
|
|
|
use std::cell::RefCell;
|
2014-02-19 19:29:58 -08:00
|
|
|
use collections::HashMap;
|
2014-05-21 15:07:48 -04:00
|
|
|
use libc::{c_uint, c_ushort, c_void, free, uint64_t};
|
2013-10-11 19:56:11 -04:00
|
|
|
use std::str::raw::from_c_str;
|
2011-05-12 17:24:54 +02:00
|
|
|
|
2013-06-15 22:16:47 +12:00
|
|
|
use middle::trans::type_::Type;
|
|
|
|
|
2013-01-29 15:48:50 -08:00
|
|
|
pub type Opcode = u32;
|
|
|
|
pub type Bool = c_uint;
|
2012-12-23 17:41:37 -05:00
|
|
|
|
2013-03-22 14:00:15 -07:00
|
|
|
pub static True: Bool = 1 as Bool;
|
|
|
|
pub static False: Bool = 0 as Bool;
|
2010-07-12 17:47:40 -07:00
|
|
|
|
2012-02-01 11:04:56 +01:00
|
|
|
// Consts for the LLVM CallConv type, pre-cast to uint.
|
2010-09-23 17:16:34 -07:00
|
|
|
|
2013-10-25 01:56:34 -04:00
|
|
|
#[deriving(Eq)]
|
2013-01-29 15:48:50 -08:00
|
|
|
pub enum CallConv {
|
2012-02-01 11:04:56 +01:00
|
|
|
CCallConv = 0,
|
|
|
|
FastCallConv = 8,
|
|
|
|
ColdCallConv = 9,
|
|
|
|
X86StdcallCallConv = 64,
|
|
|
|
X86FastcallCallConv = 65,
|
2013-11-16 18:25:56 -05:00
|
|
|
X86_64_Win64 = 79,
|
2012-02-01 11:04:56 +01:00
|
|
|
}
|
2010-09-23 17:16:34 -07:00
|
|
|
|
2013-01-29 15:48:50 -08:00
|
|
|
pub enum Visibility {
|
2012-02-01 11:04:56 +01:00
|
|
|
LLVMDefaultVisibility = 0,
|
|
|
|
HiddenVisibility = 1,
|
|
|
|
ProtectedVisibility = 2,
|
|
|
|
}
|
|
|
|
|
2014-03-17 16:37:23 +01:00
|
|
|
// This enum omits the obsolete (and no-op) linkage types DLLImportLinkage,
|
|
|
|
// DLLExportLinkage, GhostLinkage and LinkOnceODRAutoHideLinkage.
|
|
|
|
// LinkerPrivateLinkage and LinkerPrivateWeakLinkage are not included either;
|
|
|
|
// they've been removed in upstream LLVM commit r203866.
|
2013-01-29 15:48:50 -08:00
|
|
|
pub enum Linkage {
|
2012-02-01 11:04:56 +01:00
|
|
|
ExternalLinkage = 0,
|
|
|
|
AvailableExternallyLinkage = 1,
|
|
|
|
LinkOnceAnyLinkage = 2,
|
|
|
|
LinkOnceODRLinkage = 3,
|
2012-09-28 23:43:00 -07:00
|
|
|
WeakAnyLinkage = 5,
|
|
|
|
WeakODRLinkage = 6,
|
|
|
|
AppendingLinkage = 7,
|
|
|
|
InternalLinkage = 8,
|
|
|
|
PrivateLinkage = 9,
|
|
|
|
ExternalWeakLinkage = 12,
|
|
|
|
CommonLinkage = 14,
|
2012-02-01 11:04:56 +01:00
|
|
|
}
|
2011-07-27 14:19:39 +02:00
|
|
|
|
2013-07-02 12:47:32 -07:00
|
|
|
#[deriving(Clone)]
|
2013-01-29 15:48:50 -08:00
|
|
|
pub enum Attribute {
|
2013-05-25 21:26:08 -05:00
|
|
|
ZExtAttribute = 1 << 0,
|
|
|
|
SExtAttribute = 1 << 1,
|
|
|
|
NoReturnAttribute = 1 << 2,
|
|
|
|
InRegAttribute = 1 << 3,
|
|
|
|
StructRetAttribute = 1 << 4,
|
|
|
|
NoUnwindAttribute = 1 << 5,
|
|
|
|
NoAliasAttribute = 1 << 6,
|
|
|
|
ByValAttribute = 1 << 7,
|
|
|
|
NestAttribute = 1 << 8,
|
|
|
|
ReadNoneAttribute = 1 << 9,
|
|
|
|
ReadOnlyAttribute = 1 << 10,
|
|
|
|
NoInlineAttribute = 1 << 11,
|
|
|
|
AlwaysInlineAttribute = 1 << 12,
|
|
|
|
OptimizeForSizeAttribute = 1 << 13,
|
|
|
|
StackProtectAttribute = 1 << 14,
|
|
|
|
StackProtectReqAttribute = 1 << 15,
|
|
|
|
AlignmentAttribute = 31 << 16,
|
|
|
|
NoCaptureAttribute = 1 << 21,
|
|
|
|
NoRedZoneAttribute = 1 << 22,
|
|
|
|
NoImplicitFloatAttribute = 1 << 23,
|
|
|
|
NakedAttribute = 1 << 24,
|
|
|
|
InlineHintAttribute = 1 << 25,
|
|
|
|
StackAttribute = 7 << 26,
|
|
|
|
ReturnsTwiceAttribute = 1 << 29,
|
|
|
|
UWTableAttribute = 1 << 30,
|
|
|
|
NonLazyBindAttribute = 1 << 31,
|
2012-02-01 11:04:56 +01:00
|
|
|
}
|
2011-07-27 14:19:39 +02:00
|
|
|
|
2014-05-21 15:07:48 -04:00
|
|
|
#[repr(u64)]
|
|
|
|
pub enum OtherAttribute {
|
|
|
|
// The following are not really exposed in
|
|
|
|
// the LLVM c api so instead to add these
|
|
|
|
// we call a wrapper function in RustWrapper
|
|
|
|
// that uses the C++ api.
|
|
|
|
SanitizeAddressAttribute = 1 << 32,
|
|
|
|
MinSizeAttribute = 1 << 33,
|
|
|
|
NoDuplicateAttribute = 1 << 34,
|
|
|
|
StackProtectStrongAttribute = 1 << 35,
|
|
|
|
SanitizeThreadAttribute = 1 << 36,
|
|
|
|
SanitizeMemoryAttribute = 1 << 37,
|
|
|
|
NoBuiltinAttribute = 1 << 38,
|
|
|
|
ReturnedAttribute = 1 << 39,
|
|
|
|
ColdAttribute = 1 << 40,
|
|
|
|
BuiltinAttribute = 1 << 41,
|
|
|
|
OptimizeNoneAttribute = 1 << 42,
|
|
|
|
InAllocaAttribute = 1 << 43,
|
|
|
|
NonNullAttribute = 1 << 44,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[repr(C)]
|
|
|
|
pub enum AttributeSet {
|
|
|
|
ReturnIndex = 0,
|
|
|
|
FunctionIndex = !0
|
|
|
|
}
|
|
|
|
|
2012-05-17 16:17:11 -07:00
|
|
|
// enum for the LLVM IntPredicate type
|
2013-01-29 15:48:50 -08:00
|
|
|
pub enum IntPredicate {
|
2012-02-01 11:04:56 +01:00
|
|
|
IntEQ = 32,
|
|
|
|
IntNE = 33,
|
|
|
|
IntUGT = 34,
|
|
|
|
IntUGE = 35,
|
|
|
|
IntULT = 36,
|
|
|
|
IntULE = 37,
|
|
|
|
IntSGT = 38,
|
|
|
|
IntSGE = 39,
|
|
|
|
IntSLT = 40,
|
|
|
|
IntSLE = 41,
|
|
|
|
}
|
2010-09-28 14:01:21 -07:00
|
|
|
|
2012-05-17 16:17:11 -07:00
|
|
|
// enum for the LLVM RealPredicate type
|
2013-01-29 15:48:50 -08:00
|
|
|
pub enum RealPredicate {
|
2012-09-28 23:43:00 -07:00
|
|
|
RealPredicateFalse = 0,
|
2012-02-01 11:04:56 +01:00
|
|
|
RealOEQ = 1,
|
|
|
|
RealOGT = 2,
|
|
|
|
RealOGE = 3,
|
|
|
|
RealOLT = 4,
|
|
|
|
RealOLE = 5,
|
|
|
|
RealONE = 6,
|
|
|
|
RealORD = 7,
|
|
|
|
RealUNO = 8,
|
|
|
|
RealUEQ = 9,
|
|
|
|
RealUGT = 10,
|
|
|
|
RealUGE = 11,
|
|
|
|
RealULT = 12,
|
|
|
|
RealULE = 13,
|
|
|
|
RealUNE = 14,
|
2012-09-28 23:43:00 -07:00
|
|
|
RealPredicateTrue = 15,
|
2012-02-01 11:04:56 +01:00
|
|
|
}
|
|
|
|
|
2013-04-01 17:47:38 -07:00
|
|
|
// The LLVM TypeKind type - must stay in sync with the def of
|
2012-05-17 16:17:11 -07:00
|
|
|
// LLVMTypeKind in llvm/include/llvm-c/Core.h
|
2013-11-26 10:54:20 -08:00
|
|
|
#[deriving(Eq)]
|
|
|
|
#[repr(C)]
|
|
|
|
pub enum TypeKind {
|
|
|
|
Void = 0,
|
|
|
|
Half = 1,
|
|
|
|
Float = 2,
|
|
|
|
Double = 3,
|
|
|
|
X86_FP80 = 4,
|
|
|
|
FP128 = 5,
|
|
|
|
PPC_FP128 = 6,
|
|
|
|
Label = 7,
|
|
|
|
Integer = 8,
|
|
|
|
Function = 9,
|
|
|
|
Struct = 10,
|
|
|
|
Array = 11,
|
|
|
|
Pointer = 12,
|
|
|
|
Vector = 13,
|
|
|
|
Metadata = 14,
|
|
|
|
X86_MMX = 15,
|
|
|
|
}
|
|
|
|
|
2013-08-28 18:21:04 -07:00
|
|
|
#[repr(C)]
|
2013-01-29 15:48:50 -08:00
|
|
|
pub enum AtomicBinOp {
|
2012-06-21 15:01:32 -07:00
|
|
|
Xchg = 0,
|
|
|
|
Add = 1,
|
|
|
|
Sub = 2,
|
|
|
|
And = 3,
|
|
|
|
Nand = 4,
|
|
|
|
Or = 5,
|
|
|
|
Xor = 6,
|
|
|
|
Max = 7,
|
|
|
|
Min = 8,
|
|
|
|
UMax = 9,
|
|
|
|
UMin = 10,
|
|
|
|
}
|
|
|
|
|
2013-08-28 18:21:04 -07:00
|
|
|
#[repr(C)]
|
2013-01-29 15:48:50 -08:00
|
|
|
pub enum AtomicOrdering {
|
2012-06-21 15:01:32 -07:00
|
|
|
NotAtomic = 0,
|
|
|
|
Unordered = 1,
|
|
|
|
Monotonic = 2,
|
|
|
|
// Consume = 3, // Not specified yet.
|
|
|
|
Acquire = 4,
|
|
|
|
Release = 5,
|
|
|
|
AcquireRelease = 6,
|
|
|
|
SequentiallyConsistent = 7
|
|
|
|
}
|
|
|
|
|
2012-05-17 16:17:11 -07:00
|
|
|
// Consts for the LLVMCodeGenFileType type (in include/llvm/c/TargetMachine.h)
|
2013-08-28 18:21:04 -07:00
|
|
|
#[repr(C)]
|
2013-01-29 15:48:50 -08:00
|
|
|
pub enum FileType {
|
2012-05-17 16:17:11 -07:00
|
|
|
AssemblyFile = 0,
|
|
|
|
ObjectFile = 1
|
|
|
|
}
|
|
|
|
|
2013-02-19 14:55:40 -05:00
|
|
|
pub enum Metadata {
|
|
|
|
MD_dbg = 0,
|
|
|
|
MD_tbaa = 1,
|
|
|
|
MD_prof = 2,
|
|
|
|
MD_fpmath = 3,
|
|
|
|
MD_range = 4,
|
|
|
|
MD_tbaa_struct = 5
|
|
|
|
}
|
|
|
|
|
2013-03-10 00:38:29 -08:00
|
|
|
// Inline Asm Dialect
|
|
|
|
pub enum AsmDialect {
|
|
|
|
AD_ATT = 0,
|
|
|
|
AD_Intel = 1
|
|
|
|
}
|
|
|
|
|
2013-08-30 17:56:04 -07:00
|
|
|
#[deriving(Eq)]
|
2013-08-28 18:21:04 -07:00
|
|
|
#[repr(C)]
|
2013-08-22 20:58:42 -07:00
|
|
|
pub enum CodeGenOptLevel {
|
|
|
|
CodeGenLevelNone = 0,
|
|
|
|
CodeGenLevelLess = 1,
|
|
|
|
CodeGenLevelDefault = 2,
|
|
|
|
CodeGenLevelAggressive = 3,
|
|
|
|
}
|
|
|
|
|
2013-08-28 18:21:04 -07:00
|
|
|
#[repr(C)]
|
2013-08-22 20:58:42 -07:00
|
|
|
pub enum RelocMode {
|
|
|
|
RelocDefault = 0,
|
|
|
|
RelocStatic = 1,
|
|
|
|
RelocPIC = 2,
|
|
|
|
RelocDynamicNoPic = 3,
|
|
|
|
}
|
|
|
|
|
2013-08-28 18:21:04 -07:00
|
|
|
#[repr(C)]
|
2013-08-22 20:58:42 -07:00
|
|
|
pub enum CodeGenModel {
|
|
|
|
CodeModelDefault = 0,
|
|
|
|
CodeModelJITDefault = 1,
|
|
|
|
CodeModelSmall = 2,
|
|
|
|
CodeModelKernel = 3,
|
|
|
|
CodeModelMedium = 4,
|
|
|
|
CodeModelLarge = 5,
|
|
|
|
}
|
|
|
|
|
2012-02-01 11:04:56 +01:00
|
|
|
// Opaque pointer types
|
2013-01-29 15:48:50 -08:00
|
|
|
pub enum Module_opaque {}
|
|
|
|
pub type ModuleRef = *Module_opaque;
|
|
|
|
pub enum Context_opaque {}
|
|
|
|
pub type ContextRef = *Context_opaque;
|
|
|
|
pub enum Type_opaque {}
|
|
|
|
pub type TypeRef = *Type_opaque;
|
|
|
|
pub enum Value_opaque {}
|
|
|
|
pub type ValueRef = *Value_opaque;
|
|
|
|
pub enum BasicBlock_opaque {}
|
|
|
|
pub type BasicBlockRef = *BasicBlock_opaque;
|
|
|
|
pub enum Builder_opaque {}
|
|
|
|
pub type BuilderRef = *Builder_opaque;
|
2013-06-13 21:25:18 -07:00
|
|
|
pub enum ExecutionEngine_opaque {}
|
|
|
|
pub type ExecutionEngineRef = *ExecutionEngine_opaque;
|
2013-01-29 15:48:50 -08:00
|
|
|
pub enum MemoryBuffer_opaque {}
|
|
|
|
pub type MemoryBufferRef = *MemoryBuffer_opaque;
|
|
|
|
pub enum PassManager_opaque {}
|
|
|
|
pub type PassManagerRef = *PassManager_opaque;
|
|
|
|
pub enum PassManagerBuilder_opaque {}
|
|
|
|
pub type PassManagerBuilderRef = *PassManagerBuilder_opaque;
|
|
|
|
pub enum Use_opaque {}
|
|
|
|
pub type UseRef = *Use_opaque;
|
|
|
|
pub enum TargetData_opaque {}
|
|
|
|
pub type TargetDataRef = *TargetData_opaque;
|
|
|
|
pub enum ObjectFile_opaque {}
|
|
|
|
pub type ObjectFileRef = *ObjectFile_opaque;
|
|
|
|
pub enum SectionIterator_opaque {}
|
|
|
|
pub type SectionIteratorRef = *SectionIterator_opaque;
|
2013-05-28 11:15:31 +12:00
|
|
|
pub enum Pass_opaque {}
|
|
|
|
pub type PassRef = *Pass_opaque;
|
2013-08-22 20:58:42 -07:00
|
|
|
pub enum TargetMachine_opaque {}
|
|
|
|
pub type TargetMachineRef = *TargetMachine_opaque;
|
2013-12-16 20:58:21 -08:00
|
|
|
pub enum Archive_opaque {}
|
|
|
|
pub type ArchiveRef = *Archive_opaque;
|
2011-02-28 16:36:08 -08:00
|
|
|
|
2013-06-14 11:38:29 -07:00
|
|
|
pub mod debuginfo {
|
|
|
|
use super::{ValueRef};
|
2013-06-14 11:59:49 -07:00
|
|
|
|
2013-06-14 11:38:29 -07:00
|
|
|
pub enum DIBuilder_opaque {}
|
|
|
|
pub type DIBuilderRef = *DIBuilder_opaque;
|
2013-06-14 11:59:49 -07:00
|
|
|
|
2013-06-14 11:38:29 -07:00
|
|
|
pub type DIDescriptor = ValueRef;
|
|
|
|
pub type DIScope = DIDescriptor;
|
|
|
|
pub type DILocation = DIDescriptor;
|
|
|
|
pub type DIFile = DIScope;
|
|
|
|
pub type DILexicalBlock = DIScope;
|
|
|
|
pub type DISubprogram = DIScope;
|
|
|
|
pub type DIType = DIDescriptor;
|
|
|
|
pub type DIBasicType = DIType;
|
|
|
|
pub type DIDerivedType = DIType;
|
|
|
|
pub type DICompositeType = DIDerivedType;
|
|
|
|
pub type DIVariable = DIDescriptor;
|
2014-02-20 20:44:29 -05:00
|
|
|
pub type DIGlobalVariable = DIDescriptor;
|
2013-06-14 11:38:29 -07:00
|
|
|
pub type DIArray = DIDescriptor;
|
|
|
|
pub type DISubrange = DIDescriptor;
|
|
|
|
|
|
|
|
pub enum DIDescriptorFlags {
|
|
|
|
FlagPrivate = 1 << 0,
|
|
|
|
FlagProtected = 1 << 1,
|
|
|
|
FlagFwdDecl = 1 << 2,
|
|
|
|
FlagAppleBlock = 1 << 3,
|
|
|
|
FlagBlockByrefStruct = 1 << 4,
|
|
|
|
FlagVirtual = 1 << 5,
|
|
|
|
FlagArtificial = 1 << 6,
|
|
|
|
FlagExplicit = 1 << 7,
|
|
|
|
FlagPrototyped = 1 << 8,
|
|
|
|
FlagObjcClassComplete = 1 << 9,
|
|
|
|
FlagObjectPointer = 1 << 10,
|
|
|
|
FlagVector = 1 << 11,
|
|
|
|
FlagStaticMember = 1 << 12
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-03-05 14:42:58 -08:00
|
|
|
pub mod llvm {
|
2013-06-13 21:25:18 -07:00
|
|
|
use super::{AtomicBinOp, AtomicOrdering, BasicBlockRef, ExecutionEngineRef};
|
2013-03-10 00:38:29 -08:00
|
|
|
use super::{Bool, BuilderRef, ContextRef, MemoryBufferRef, ModuleRef};
|
|
|
|
use super::{ObjectFileRef, Opcode, PassManagerRef, PassManagerBuilderRef};
|
2013-03-05 14:42:58 -08:00
|
|
|
use super::{SectionIteratorRef, TargetDataRef, TypeKind, TypeRef, UseRef};
|
2013-12-16 20:58:21 -08:00
|
|
|
use super::{ValueRef, TargetMachineRef, FileType, ArchiveRef};
|
2013-08-22 20:58:42 -07:00
|
|
|
use super::{CodeGenModel, RelocMode, CodeGenOptLevel};
|
2013-06-14 11:38:29 -07:00
|
|
|
use super::debuginfo::*;
|
2014-02-26 12:58:41 -05:00
|
|
|
use libc::{c_char, c_int, c_longlong, c_ushort, c_uint, c_ulonglong,
|
2014-05-21 15:07:48 -04:00
|
|
|
size_t, uint64_t};
|
2013-03-05 14:42:58 -08:00
|
|
|
|
2013-11-30 20:52:21 -08:00
|
|
|
// Link to our native llvm bindings (things that we need to use the C++ api
|
|
|
|
// for) and because llvm is written in C++ we need to link against libstdc++
|
|
|
|
//
|
|
|
|
// You'll probably notice that there is an omission of all LLVM libraries
|
|
|
|
// from this location. This is because the set of LLVM libraries that we
|
|
|
|
// link to is mostly defined by LLVM, and the `llvm-config` tool is used to
|
|
|
|
// figure out the exact set of libraries. To do this, the build system
|
|
|
|
// generates an llvmdeps.rs file next to this one which will be
|
|
|
|
// automatically updated whenever LLVM is updated to include an up-to-date
|
|
|
|
// set of the libraries we need to link to LLVM for.
|
|
|
|
#[link(name = "rustllvm", kind = "static")]
|
2013-10-14 14:33:05 +02:00
|
|
|
extern {
|
2013-03-05 14:42:58 -08:00
|
|
|
/* Create and destroy contexts. */
|
2013-08-02 14:30:00 -07:00
|
|
|
pub fn LLVMContextCreate() -> ContextRef;
|
|
|
|
pub fn LLVMContextDispose(C: ContextRef);
|
|
|
|
pub fn LLVMGetMDKindIDInContext(C: ContextRef,
|
|
|
|
Name: *c_char,
|
|
|
|
SLen: c_uint)
|
2013-03-05 14:42:58 -08:00
|
|
|
-> c_uint;
|
|
|
|
|
|
|
|
/* Create and destroy modules. */
|
2013-08-02 14:30:00 -07:00
|
|
|
pub fn LLVMModuleCreateWithNameInContext(ModuleID: *c_char,
|
|
|
|
C: ContextRef)
|
2013-03-05 14:42:58 -08:00
|
|
|
-> ModuleRef;
|
2013-08-02 14:30:00 -07:00
|
|
|
pub fn LLVMGetModuleContext(M: ModuleRef) -> ContextRef;
|
|
|
|
pub fn LLVMDisposeModule(M: ModuleRef);
|
2013-03-05 14:42:58 -08:00
|
|
|
|
|
|
|
/** Data layout. See Module::getDataLayout. */
|
2013-08-02 14:30:00 -07:00
|
|
|
pub fn LLVMGetDataLayout(M: ModuleRef) -> *c_char;
|
|
|
|
pub fn LLVMSetDataLayout(M: ModuleRef, Triple: *c_char);
|
2013-03-05 14:42:58 -08:00
|
|
|
|
|
|
|
/** Target triple. See Module::getTargetTriple. */
|
2013-08-02 14:30:00 -07:00
|
|
|
pub fn LLVMGetTarget(M: ModuleRef) -> *c_char;
|
|
|
|
pub fn LLVMSetTarget(M: ModuleRef, Triple: *c_char);
|
2013-03-05 14:42:58 -08:00
|
|
|
|
|
|
|
/** See Module::dump. */
|
2013-08-02 14:30:00 -07:00
|
|
|
pub fn LLVMDumpModule(M: ModuleRef);
|
2013-03-05 14:42:58 -08:00
|
|
|
|
|
|
|
/** See Module::setModuleInlineAsm. */
|
2013-08-02 14:30:00 -07:00
|
|
|
pub fn LLVMSetModuleInlineAsm(M: ModuleRef, Asm: *c_char);
|
2013-03-05 14:42:58 -08:00
|
|
|
|
|
|
|
/** See llvm::LLVMTypeKind::getTypeID. */
|
2013-08-02 14:30:00 -07:00
|
|
|
pub fn LLVMGetTypeKind(Ty: TypeRef) -> TypeKind;
|
2013-03-05 14:42:58 -08:00
|
|
|
|
|
|
|
/** See llvm::LLVMType::getContext. */
|
2013-08-02 14:30:00 -07:00
|
|
|
pub fn LLVMGetTypeContext(Ty: TypeRef) -> ContextRef;
|
2013-03-05 14:42:58 -08:00
|
|
|
|
|
|
|
/* Operations on integer types */
|
2013-08-02 14:30:00 -07:00
|
|
|
pub fn LLVMInt1TypeInContext(C: ContextRef) -> TypeRef;
|
|
|
|
pub fn LLVMInt8TypeInContext(C: ContextRef) -> TypeRef;
|
|
|
|
pub fn LLVMInt16TypeInContext(C: ContextRef) -> TypeRef;
|
|
|
|
pub fn LLVMInt32TypeInContext(C: ContextRef) -> TypeRef;
|
|
|
|
pub fn LLVMInt64TypeInContext(C: ContextRef) -> TypeRef;
|
|
|
|
pub fn LLVMIntTypeInContext(C: ContextRef, NumBits: c_uint)
|
|
|
|
-> TypeRef;
|
2013-03-05 14:42:58 -08:00
|
|
|
|
2013-08-02 14:30:00 -07:00
|
|
|
pub fn LLVMGetIntTypeWidth(IntegerTy: TypeRef) -> c_uint;
|
2013-03-05 14:42:58 -08:00
|
|
|
|
|
|
|
/* Operations on real types */
|
2013-08-02 14:30:00 -07:00
|
|
|
pub fn LLVMFloatTypeInContext(C: ContextRef) -> TypeRef;
|
|
|
|
pub fn LLVMDoubleTypeInContext(C: ContextRef) -> TypeRef;
|
|
|
|
pub fn LLVMX86FP80TypeInContext(C: ContextRef) -> TypeRef;
|
|
|
|
pub fn LLVMFP128TypeInContext(C: ContextRef) -> TypeRef;
|
|
|
|
pub fn LLVMPPCFP128TypeInContext(C: ContextRef) -> TypeRef;
|
2013-03-05 14:42:58 -08:00
|
|
|
|
|
|
|
/* Operations on function types */
|
2013-08-02 14:30:00 -07:00
|
|
|
pub fn LLVMFunctionType(ReturnType: TypeRef,
|
|
|
|
ParamTypes: *TypeRef,
|
|
|
|
ParamCount: c_uint,
|
|
|
|
IsVarArg: Bool)
|
|
|
|
-> TypeRef;
|
|
|
|
pub fn LLVMIsFunctionVarArg(FunctionTy: TypeRef) -> Bool;
|
|
|
|
pub fn LLVMGetReturnType(FunctionTy: TypeRef) -> TypeRef;
|
|
|
|
pub fn LLVMCountParamTypes(FunctionTy: TypeRef) -> c_uint;
|
|
|
|
pub fn LLVMGetParamTypes(FunctionTy: TypeRef, Dest: *TypeRef);
|
2013-03-05 14:42:58 -08:00
|
|
|
|
|
|
|
/* Operations on struct types */
|
2013-08-02 14:30:00 -07:00
|
|
|
pub fn LLVMStructTypeInContext(C: ContextRef,
|
|
|
|
ElementTypes: *TypeRef,
|
|
|
|
ElementCount: c_uint,
|
|
|
|
Packed: Bool)
|
|
|
|
-> TypeRef;
|
|
|
|
pub fn LLVMCountStructElementTypes(StructTy: TypeRef) -> c_uint;
|
|
|
|
pub fn LLVMGetStructElementTypes(StructTy: TypeRef,
|
|
|
|
Dest: *mut TypeRef);
|
|
|
|
pub fn LLVMIsPackedStruct(StructTy: TypeRef) -> Bool;
|
2013-03-05 14:42:58 -08:00
|
|
|
|
|
|
|
/* Operations on array, pointer, and vector types (sequence types) */
|
2014-05-10 17:30:55 +09:00
|
|
|
pub fn LLVMRustArrayType(ElementType: TypeRef, ElementCount: u64) -> TypeRef;
|
2013-08-02 14:30:00 -07:00
|
|
|
pub fn LLVMPointerType(ElementType: TypeRef, AddressSpace: c_uint)
|
|
|
|
-> TypeRef;
|
|
|
|
pub fn LLVMVectorType(ElementType: TypeRef, ElementCount: c_uint)
|
|
|
|
-> TypeRef;
|
2013-03-05 14:42:58 -08:00
|
|
|
|
2013-08-02 14:30:00 -07:00
|
|
|
pub fn LLVMGetElementType(Ty: TypeRef) -> TypeRef;
|
|
|
|
pub fn LLVMGetArrayLength(ArrayTy: TypeRef) -> c_uint;
|
|
|
|
pub fn LLVMGetPointerAddressSpace(PointerTy: TypeRef) -> c_uint;
|
|
|
|
pub fn LLVMGetPointerToGlobal(EE: ExecutionEngineRef, V: ValueRef)
|
|
|
|
-> *();
|
|
|
|
pub fn LLVMGetVectorSize(VectorTy: TypeRef) -> c_uint;
|
2013-03-05 14:42:58 -08:00
|
|
|
|
|
|
|
/* Operations on other types */
|
2013-08-02 14:30:00 -07:00
|
|
|
pub fn LLVMVoidTypeInContext(C: ContextRef) -> TypeRef;
|
|
|
|
pub fn LLVMLabelTypeInContext(C: ContextRef) -> TypeRef;
|
|
|
|
pub fn LLVMMetadataTypeInContext(C: ContextRef) -> TypeRef;
|
2013-03-05 14:42:58 -08:00
|
|
|
|
|
|
|
/* Operations on all values */
|
2013-08-02 14:30:00 -07:00
|
|
|
pub fn LLVMTypeOf(Val: ValueRef) -> TypeRef;
|
|
|
|
pub fn LLVMGetValueName(Val: ValueRef) -> *c_char;
|
|
|
|
pub fn LLVMSetValueName(Val: ValueRef, Name: *c_char);
|
|
|
|
pub fn LLVMDumpValue(Val: ValueRef);
|
|
|
|
pub fn LLVMReplaceAllUsesWith(OldVal: ValueRef, NewVal: ValueRef);
|
|
|
|
pub fn LLVMHasMetadata(Val: ValueRef) -> c_int;
|
|
|
|
pub fn LLVMGetMetadata(Val: ValueRef, KindID: c_uint) -> ValueRef;
|
|
|
|
pub fn LLVMSetMetadata(Val: ValueRef, KindID: c_uint, Node: ValueRef);
|
2013-03-05 14:42:58 -08:00
|
|
|
|
|
|
|
/* Operations on Uses */
|
2013-08-02 14:30:00 -07:00
|
|
|
pub fn LLVMGetFirstUse(Val: ValueRef) -> UseRef;
|
|
|
|
pub fn LLVMGetNextUse(U: UseRef) -> UseRef;
|
|
|
|
pub fn LLVMGetUser(U: UseRef) -> ValueRef;
|
|
|
|
pub fn LLVMGetUsedValue(U: UseRef) -> ValueRef;
|
2013-03-05 14:42:58 -08:00
|
|
|
|
|
|
|
/* Operations on Users */
|
2013-08-02 14:30:00 -07:00
|
|
|
pub fn LLVMGetNumOperands(Val: ValueRef) -> c_int;
|
|
|
|
pub fn LLVMGetOperand(Val: ValueRef, Index: c_uint) -> ValueRef;
|
|
|
|
pub fn LLVMSetOperand(Val: ValueRef, Index: c_uint, Op: ValueRef);
|
2013-03-05 14:42:58 -08:00
|
|
|
|
|
|
|
/* Operations on constants of any type */
|
2013-08-02 14:30:00 -07:00
|
|
|
pub fn LLVMConstNull(Ty: TypeRef) -> ValueRef;
|
2013-03-05 14:42:58 -08:00
|
|
|
/* all zeroes */
|
2013-08-02 14:30:00 -07:00
|
|
|
pub fn LLVMConstAllOnes(Ty: TypeRef) -> ValueRef;
|
|
|
|
pub fn LLVMConstICmp(Pred: c_ushort, V1: ValueRef, V2: ValueRef)
|
|
|
|
-> ValueRef;
|
|
|
|
pub fn LLVMConstFCmp(Pred: c_ushort, V1: ValueRef, V2: ValueRef)
|
|
|
|
-> ValueRef;
|
2013-03-05 14:42:58 -08:00
|
|
|
/* only for int/vector */
|
2013-08-02 14:30:00 -07:00
|
|
|
pub fn LLVMGetUndef(Ty: TypeRef) -> ValueRef;
|
|
|
|
pub fn LLVMIsConstant(Val: ValueRef) -> Bool;
|
|
|
|
pub fn LLVMIsNull(Val: ValueRef) -> Bool;
|
|
|
|
pub fn LLVMIsUndef(Val: ValueRef) -> Bool;
|
|
|
|
pub fn LLVMConstPointerNull(Ty: TypeRef) -> ValueRef;
|
2013-03-05 14:42:58 -08:00
|
|
|
|
|
|
|
/* Operations on metadata */
|
2013-08-02 14:30:00 -07:00
|
|
|
pub fn LLVMMDStringInContext(C: ContextRef,
|
|
|
|
Str: *c_char,
|
|
|
|
SLen: c_uint)
|
2013-03-05 14:42:58 -08:00
|
|
|
-> ValueRef;
|
2013-08-02 14:30:00 -07:00
|
|
|
pub fn LLVMMDNodeInContext(C: ContextRef,
|
|
|
|
Vals: *ValueRef,
|
|
|
|
Count: c_uint)
|
2013-03-05 14:42:58 -08:00
|
|
|
-> ValueRef;
|
2013-08-02 14:30:00 -07:00
|
|
|
pub fn LLVMAddNamedMetadataOperand(M: ModuleRef,
|
|
|
|
Str: *c_char,
|
|
|
|
Val: ValueRef);
|
2013-03-05 14:42:58 -08:00
|
|
|
|
|
|
|
/* Operations on scalar constants */
|
2013-08-02 14:30:00 -07:00
|
|
|
pub fn LLVMConstInt(IntTy: TypeRef, N: c_ulonglong, SignExtend: Bool)
|
2013-03-05 14:42:58 -08:00
|
|
|
-> ValueRef;
|
2013-08-02 14:30:00 -07:00
|
|
|
pub fn LLVMConstIntOfString(IntTy: TypeRef, Text: *c_char, Radix: u8)
|
2013-03-05 14:42:58 -08:00
|
|
|
-> ValueRef;
|
2013-08-02 14:30:00 -07:00
|
|
|
pub fn LLVMConstIntOfStringAndSize(IntTy: TypeRef,
|
|
|
|
Text: *c_char,
|
|
|
|
SLen: c_uint,
|
|
|
|
Radix: u8)
|
|
|
|
-> ValueRef;
|
|
|
|
pub fn LLVMConstReal(RealTy: TypeRef, N: f64) -> ValueRef;
|
|
|
|
pub fn LLVMConstRealOfString(RealTy: TypeRef, Text: *c_char)
|
2013-03-05 14:42:58 -08:00
|
|
|
-> ValueRef;
|
2013-08-02 14:30:00 -07:00
|
|
|
pub fn LLVMConstRealOfStringAndSize(RealTy: TypeRef,
|
|
|
|
Text: *c_char,
|
|
|
|
SLen: c_uint)
|
|
|
|
-> ValueRef;
|
|
|
|
pub fn LLVMConstIntGetZExtValue(ConstantVal: ValueRef) -> c_ulonglong;
|
|
|
|
pub fn LLVMConstIntGetSExtValue(ConstantVal: ValueRef) -> c_longlong;
|
2013-03-05 14:42:58 -08:00
|
|
|
|
|
|
|
|
|
|
|
/* Operations on composite constants */
|
2013-08-02 14:30:00 -07:00
|
|
|
pub fn LLVMConstStringInContext(C: ContextRef,
|
|
|
|
Str: *c_char,
|
|
|
|
Length: c_uint,
|
|
|
|
DontNullTerminate: Bool)
|
2013-03-05 14:42:58 -08:00
|
|
|
-> ValueRef;
|
2013-08-02 14:30:00 -07:00
|
|
|
pub fn LLVMConstStructInContext(C: ContextRef,
|
|
|
|
ConstantVals: *ValueRef,
|
|
|
|
Count: c_uint,
|
|
|
|
Packed: Bool)
|
|
|
|
-> ValueRef;
|
2013-03-05 14:42:58 -08:00
|
|
|
|
2013-08-02 14:30:00 -07:00
|
|
|
pub fn LLVMConstArray(ElementTy: TypeRef,
|
|
|
|
ConstantVals: *ValueRef,
|
|
|
|
Length: c_uint)
|
|
|
|
-> ValueRef;
|
|
|
|
pub fn LLVMConstVector(ScalarConstantVals: *ValueRef, Size: c_uint)
|
|
|
|
-> ValueRef;
|
2013-03-05 14:42:58 -08:00
|
|
|
|
|
|
|
/* Constant expressions */
|
2013-08-02 14:30:00 -07:00
|
|
|
pub fn LLVMAlignOf(Ty: TypeRef) -> ValueRef;
|
|
|
|
pub fn LLVMSizeOf(Ty: TypeRef) -> ValueRef;
|
|
|
|
pub fn LLVMConstNeg(ConstantVal: ValueRef) -> ValueRef;
|
|
|
|
pub fn LLVMConstNSWNeg(ConstantVal: ValueRef) -> ValueRef;
|
|
|
|
pub fn LLVMConstNUWNeg(ConstantVal: ValueRef) -> ValueRef;
|
|
|
|
pub fn LLVMConstFNeg(ConstantVal: ValueRef) -> ValueRef;
|
|
|
|
pub fn LLVMConstNot(ConstantVal: ValueRef) -> ValueRef;
|
|
|
|
pub fn LLVMConstAdd(LHSConstant: ValueRef, RHSConstant: ValueRef)
|
|
|
|
-> ValueRef;
|
|
|
|
pub fn LLVMConstNSWAdd(LHSConstant: ValueRef, RHSConstant: ValueRef)
|
2013-03-05 14:42:58 -08:00
|
|
|
-> ValueRef;
|
2013-08-02 14:30:00 -07:00
|
|
|
pub fn LLVMConstNUWAdd(LHSConstant: ValueRef, RHSConstant: ValueRef)
|
2013-01-10 21:23:07 -08:00
|
|
|
-> ValueRef;
|
2013-08-02 14:30:00 -07:00
|
|
|
pub fn LLVMConstFAdd(LHSConstant: ValueRef, RHSConstant: ValueRef)
|
2013-03-05 14:42:58 -08:00
|
|
|
-> ValueRef;
|
2013-08-02 14:30:00 -07:00
|
|
|
pub fn LLVMConstSub(LHSConstant: ValueRef, RHSConstant: ValueRef)
|
|
|
|
-> ValueRef;
|
|
|
|
pub fn LLVMConstNSWSub(LHSConstant: ValueRef, RHSConstant: ValueRef)
|
|
|
|
-> ValueRef;
|
|
|
|
pub fn LLVMConstNUWSub(LHSConstant: ValueRef, RHSConstant: ValueRef)
|
|
|
|
-> ValueRef;
|
|
|
|
pub fn LLVMConstFSub(LHSConstant: ValueRef, RHSConstant: ValueRef)
|
|
|
|
-> ValueRef;
|
|
|
|
pub fn LLVMConstMul(LHSConstant: ValueRef, RHSConstant: ValueRef)
|
2013-02-06 15:37:34 -08:00
|
|
|
-> ValueRef;
|
2013-08-02 14:30:00 -07:00
|
|
|
pub fn LLVMConstNSWMul(LHSConstant: ValueRef, RHSConstant: ValueRef)
|
2013-02-06 15:37:34 -08:00
|
|
|
-> ValueRef;
|
2013-08-02 14:30:00 -07:00
|
|
|
pub fn LLVMConstNUWMul(LHSConstant: ValueRef, RHSConstant: ValueRef)
|
2013-02-06 15:37:34 -08:00
|
|
|
-> ValueRef;
|
2013-08-02 14:30:00 -07:00
|
|
|
pub fn LLVMConstFMul(LHSConstant: ValueRef, RHSConstant: ValueRef)
|
2013-01-29 15:48:50 -08:00
|
|
|
-> ValueRef;
|
2013-08-02 14:30:00 -07:00
|
|
|
pub fn LLVMConstUDiv(LHSConstant: ValueRef, RHSConstant: ValueRef)
|
2013-03-05 14:42:58 -08:00
|
|
|
-> ValueRef;
|
2013-08-02 14:30:00 -07:00
|
|
|
pub fn LLVMConstSDiv(LHSConstant: ValueRef, RHSConstant: ValueRef)
|
2013-03-05 14:42:58 -08:00
|
|
|
-> ValueRef;
|
2013-08-02 14:30:00 -07:00
|
|
|
pub fn LLVMConstExactSDiv(LHSConstant: ValueRef,
|
|
|
|
RHSConstant: ValueRef)
|
2013-03-05 14:42:58 -08:00
|
|
|
-> ValueRef;
|
2013-08-02 14:30:00 -07:00
|
|
|
pub fn LLVMConstFDiv(LHSConstant: ValueRef, RHSConstant: ValueRef)
|
2013-03-05 14:42:58 -08:00
|
|
|
-> ValueRef;
|
2013-08-02 14:30:00 -07:00
|
|
|
pub fn LLVMConstURem(LHSConstant: ValueRef, RHSConstant: ValueRef)
|
2013-03-05 14:42:58 -08:00
|
|
|
-> ValueRef;
|
2013-08-02 14:30:00 -07:00
|
|
|
pub fn LLVMConstSRem(LHSConstant: ValueRef, RHSConstant: ValueRef)
|
2013-03-05 14:42:58 -08:00
|
|
|
-> ValueRef;
|
2013-08-02 14:30:00 -07:00
|
|
|
pub fn LLVMConstFRem(LHSConstant: ValueRef, RHSConstant: ValueRef)
|
2013-03-05 14:42:58 -08:00
|
|
|
-> ValueRef;
|
2013-08-02 14:30:00 -07:00
|
|
|
pub fn LLVMConstAnd(LHSConstant: ValueRef, RHSConstant: ValueRef)
|
2013-03-05 14:42:58 -08:00
|
|
|
-> ValueRef;
|
2013-08-02 14:30:00 -07:00
|
|
|
pub fn LLVMConstOr(LHSConstant: ValueRef, RHSConstant: ValueRef)
|
2013-01-10 21:23:07 -08:00
|
|
|
-> ValueRef;
|
2013-08-02 14:30:00 -07:00
|
|
|
pub fn LLVMConstXor(LHSConstant: ValueRef, RHSConstant: ValueRef)
|
2013-01-10 21:23:07 -08:00
|
|
|
-> ValueRef;
|
2013-08-02 14:30:00 -07:00
|
|
|
pub fn LLVMConstShl(LHSConstant: ValueRef, RHSConstant: ValueRef)
|
2013-03-05 14:42:58 -08:00
|
|
|
-> ValueRef;
|
2013-08-02 14:30:00 -07:00
|
|
|
pub fn LLVMConstLShr(LHSConstant: ValueRef, RHSConstant: ValueRef)
|
|
|
|
-> ValueRef;
|
|
|
|
pub fn LLVMConstAShr(LHSConstant: ValueRef, RHSConstant: ValueRef)
|
|
|
|
-> ValueRef;
|
|
|
|
pub fn LLVMConstGEP(ConstantVal: ValueRef,
|
|
|
|
ConstantIndices: *ValueRef,
|
|
|
|
NumIndices: c_uint)
|
|
|
|
-> ValueRef;
|
|
|
|
pub fn LLVMConstInBoundsGEP(ConstantVal: ValueRef,
|
|
|
|
ConstantIndices: *ValueRef,
|
|
|
|
NumIndices: c_uint)
|
2013-03-05 14:42:58 -08:00
|
|
|
-> ValueRef;
|
2013-08-02 14:30:00 -07:00
|
|
|
pub fn LLVMConstTrunc(ConstantVal: ValueRef, ToType: TypeRef)
|
2013-03-05 14:42:58 -08:00
|
|
|
-> ValueRef;
|
2013-08-02 14:30:00 -07:00
|
|
|
pub fn LLVMConstSExt(ConstantVal: ValueRef, ToType: TypeRef)
|
2013-01-10 21:23:07 -08:00
|
|
|
-> ValueRef;
|
2013-08-02 14:30:00 -07:00
|
|
|
pub fn LLVMConstZExt(ConstantVal: ValueRef, ToType: TypeRef)
|
2013-01-10 21:23:07 -08:00
|
|
|
-> ValueRef;
|
2013-08-02 14:30:00 -07:00
|
|
|
pub fn LLVMConstFPTrunc(ConstantVal: ValueRef, ToType: TypeRef)
|
2013-01-10 21:23:07 -08:00
|
|
|
-> ValueRef;
|
2013-08-02 14:30:00 -07:00
|
|
|
pub fn LLVMConstFPExt(ConstantVal: ValueRef, ToType: TypeRef)
|
2013-03-05 14:42:58 -08:00
|
|
|
-> ValueRef;
|
2013-08-02 14:30:00 -07:00
|
|
|
pub fn LLVMConstUIToFP(ConstantVal: ValueRef, ToType: TypeRef)
|
2013-03-05 14:42:58 -08:00
|
|
|
-> ValueRef;
|
2013-08-02 14:30:00 -07:00
|
|
|
pub fn LLVMConstSIToFP(ConstantVal: ValueRef, ToType: TypeRef)
|
2013-03-05 14:42:58 -08:00
|
|
|
-> ValueRef;
|
2013-08-02 14:30:00 -07:00
|
|
|
pub fn LLVMConstFPToUI(ConstantVal: ValueRef, ToType: TypeRef)
|
2013-03-05 14:42:58 -08:00
|
|
|
-> ValueRef;
|
2013-08-02 14:30:00 -07:00
|
|
|
pub fn LLVMConstFPToSI(ConstantVal: ValueRef, ToType: TypeRef)
|
2013-03-05 14:42:58 -08:00
|
|
|
-> ValueRef;
|
2013-08-02 14:30:00 -07:00
|
|
|
pub fn LLVMConstPtrToInt(ConstantVal: ValueRef, ToType: TypeRef)
|
2013-03-05 14:42:58 -08:00
|
|
|
-> ValueRef;
|
2013-08-02 14:30:00 -07:00
|
|
|
pub fn LLVMConstIntToPtr(ConstantVal: ValueRef, ToType: TypeRef)
|
2013-03-05 14:42:58 -08:00
|
|
|
-> ValueRef;
|
2013-08-02 14:30:00 -07:00
|
|
|
pub fn LLVMConstBitCast(ConstantVal: ValueRef, ToType: TypeRef)
|
2013-01-29 15:48:50 -08:00
|
|
|
-> ValueRef;
|
2013-08-02 14:30:00 -07:00
|
|
|
pub fn LLVMConstZExtOrBitCast(ConstantVal: ValueRef, ToType: TypeRef)
|
2013-03-05 14:42:58 -08:00
|
|
|
-> ValueRef;
|
2013-08-02 14:30:00 -07:00
|
|
|
pub fn LLVMConstSExtOrBitCast(ConstantVal: ValueRef, ToType: TypeRef)
|
2013-03-05 14:42:58 -08:00
|
|
|
-> ValueRef;
|
2013-08-02 14:30:00 -07:00
|
|
|
pub fn LLVMConstTruncOrBitCast(ConstantVal: ValueRef, ToType: TypeRef)
|
2013-03-05 14:42:58 -08:00
|
|
|
-> ValueRef;
|
2013-08-02 14:30:00 -07:00
|
|
|
pub fn LLVMConstPointerCast(ConstantVal: ValueRef, ToType: TypeRef)
|
2013-03-05 14:42:58 -08:00
|
|
|
-> ValueRef;
|
2013-08-02 14:30:00 -07:00
|
|
|
pub fn LLVMConstIntCast(ConstantVal: ValueRef,
|
|
|
|
ToType: TypeRef,
|
|
|
|
isSigned: Bool)
|
|
|
|
-> ValueRef;
|
|
|
|
pub fn LLVMConstFPCast(ConstantVal: ValueRef, ToType: TypeRef)
|
2013-03-05 14:42:58 -08:00
|
|
|
-> ValueRef;
|
2013-08-02 14:30:00 -07:00
|
|
|
pub fn LLVMConstSelect(ConstantCondition: ValueRef,
|
|
|
|
ConstantIfTrue: ValueRef,
|
|
|
|
ConstantIfFalse: ValueRef)
|
|
|
|
-> ValueRef;
|
|
|
|
pub fn LLVMConstExtractElement(VectorConstant: ValueRef,
|
|
|
|
IndexConstant: ValueRef)
|
|
|
|
-> ValueRef;
|
|
|
|
pub fn LLVMConstInsertElement(VectorConstant: ValueRef,
|
|
|
|
ElementValueConstant: ValueRef,
|
|
|
|
IndexConstant: ValueRef)
|
|
|
|
-> ValueRef;
|
|
|
|
pub fn LLVMConstShuffleVector(VectorAConstant: ValueRef,
|
|
|
|
VectorBConstant: ValueRef,
|
|
|
|
MaskConstant: ValueRef)
|
|
|
|
-> ValueRef;
|
|
|
|
pub fn LLVMConstExtractValue(AggConstant: ValueRef,
|
|
|
|
IdxList: *c_uint,
|
|
|
|
NumIdx: c_uint)
|
|
|
|
-> ValueRef;
|
|
|
|
pub fn LLVMConstInsertValue(AggConstant: ValueRef,
|
|
|
|
ElementValueConstant: ValueRef,
|
|
|
|
IdxList: *c_uint,
|
|
|
|
NumIdx: c_uint)
|
|
|
|
-> ValueRef;
|
|
|
|
pub fn LLVMConstInlineAsm(Ty: TypeRef,
|
|
|
|
AsmString: *c_char,
|
|
|
|
Constraints: *c_char,
|
|
|
|
HasSideEffects: Bool,
|
|
|
|
IsAlignStack: Bool)
|
|
|
|
-> ValueRef;
|
|
|
|
pub fn LLVMBlockAddress(F: ValueRef, BB: BasicBlockRef) -> ValueRef;
|
2010-08-18 00:19:25 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
2013-03-05 14:42:58 -08:00
|
|
|
/* Operations on global variables, functions, and aliases (globals) */
|
2013-08-02 14:30:00 -07:00
|
|
|
pub fn LLVMGetGlobalParent(Global: ValueRef) -> ModuleRef;
|
|
|
|
pub fn LLVMIsDeclaration(Global: ValueRef) -> Bool;
|
|
|
|
pub fn LLVMGetLinkage(Global: ValueRef) -> c_uint;
|
|
|
|
pub fn LLVMSetLinkage(Global: ValueRef, Link: c_uint);
|
|
|
|
pub fn LLVMGetSection(Global: ValueRef) -> *c_char;
|
|
|
|
pub fn LLVMSetSection(Global: ValueRef, Section: *c_char);
|
|
|
|
pub fn LLVMGetVisibility(Global: ValueRef) -> c_uint;
|
|
|
|
pub fn LLVMSetVisibility(Global: ValueRef, Viz: c_uint);
|
|
|
|
pub fn LLVMGetAlignment(Global: ValueRef) -> c_uint;
|
|
|
|
pub fn LLVMSetAlignment(Global: ValueRef, Bytes: c_uint);
|
2013-01-29 15:48:50 -08:00
|
|
|
|
2011-07-27 14:19:39 +02:00
|
|
|
|
2013-03-05 14:42:58 -08:00
|
|
|
/* Operations on global variables */
|
2013-08-02 14:30:00 -07:00
|
|
|
pub fn LLVMAddGlobal(M: ModuleRef, Ty: TypeRef, Name: *c_char)
|
2013-03-05 14:42:58 -08:00
|
|
|
-> ValueRef;
|
2013-08-02 14:30:00 -07:00
|
|
|
pub fn LLVMAddGlobalInAddressSpace(M: ModuleRef,
|
|
|
|
Ty: TypeRef,
|
|
|
|
Name: *c_char,
|
|
|
|
AddressSpace: c_uint)
|
2013-03-05 14:42:58 -08:00
|
|
|
-> ValueRef;
|
2013-08-02 14:30:00 -07:00
|
|
|
pub fn LLVMGetNamedGlobal(M: ModuleRef, Name: *c_char) -> ValueRef;
|
|
|
|
pub fn LLVMGetFirstGlobal(M: ModuleRef) -> ValueRef;
|
|
|
|
pub fn LLVMGetLastGlobal(M: ModuleRef) -> ValueRef;
|
|
|
|
pub fn LLVMGetNextGlobal(GlobalVar: ValueRef) -> ValueRef;
|
|
|
|
pub fn LLVMGetPreviousGlobal(GlobalVar: ValueRef) -> ValueRef;
|
|
|
|
pub fn LLVMDeleteGlobal(GlobalVar: ValueRef);
|
|
|
|
pub fn LLVMGetInitializer(GlobalVar: ValueRef) -> ValueRef;
|
|
|
|
pub fn LLVMSetInitializer(GlobalVar: ValueRef,
|
2013-03-05 14:42:58 -08:00
|
|
|
ConstantVal: ValueRef);
|
2013-08-02 14:30:00 -07:00
|
|
|
pub fn LLVMIsThreadLocal(GlobalVar: ValueRef) -> Bool;
|
|
|
|
pub fn LLVMSetThreadLocal(GlobalVar: ValueRef, IsThreadLocal: Bool);
|
|
|
|
pub fn LLVMIsGlobalConstant(GlobalVar: ValueRef) -> Bool;
|
|
|
|
pub fn LLVMSetGlobalConstant(GlobalVar: ValueRef, IsConstant: Bool);
|
2013-03-05 14:42:58 -08:00
|
|
|
|
|
|
|
/* Operations on aliases */
|
2013-08-02 14:30:00 -07:00
|
|
|
pub fn LLVMAddAlias(M: ModuleRef,
|
|
|
|
Ty: TypeRef,
|
|
|
|
Aliasee: ValueRef,
|
|
|
|
Name: *c_char)
|
|
|
|
-> ValueRef;
|
2013-03-05 14:42:58 -08:00
|
|
|
|
|
|
|
/* Operations on functions */
|
2013-08-02 14:30:00 -07:00
|
|
|
pub fn LLVMAddFunction(M: ModuleRef,
|
|
|
|
Name: *c_char,
|
|
|
|
FunctionTy: TypeRef)
|
2013-03-05 14:42:58 -08:00
|
|
|
-> ValueRef;
|
2013-08-02 14:30:00 -07:00
|
|
|
pub fn LLVMGetNamedFunction(M: ModuleRef, Name: *c_char) -> ValueRef;
|
|
|
|
pub fn LLVMGetFirstFunction(M: ModuleRef) -> ValueRef;
|
|
|
|
pub fn LLVMGetLastFunction(M: ModuleRef) -> ValueRef;
|
|
|
|
pub fn LLVMGetNextFunction(Fn: ValueRef) -> ValueRef;
|
|
|
|
pub fn LLVMGetPreviousFunction(Fn: ValueRef) -> ValueRef;
|
|
|
|
pub fn LLVMDeleteFunction(Fn: ValueRef);
|
|
|
|
pub fn LLVMGetOrInsertFunction(M: ModuleRef,
|
|
|
|
Name: *c_char,
|
|
|
|
FunctionTy: TypeRef)
|
|
|
|
-> ValueRef;
|
|
|
|
pub fn LLVMGetIntrinsicID(Fn: ValueRef) -> c_uint;
|
|
|
|
pub fn LLVMGetFunctionCallConv(Fn: ValueRef) -> c_uint;
|
|
|
|
pub fn LLVMSetFunctionCallConv(Fn: ValueRef, CC: c_uint);
|
|
|
|
pub fn LLVMGetGC(Fn: ValueRef) -> *c_char;
|
|
|
|
pub fn LLVMSetGC(Fn: ValueRef, Name: *c_char);
|
2014-05-21 15:07:48 -04:00
|
|
|
pub fn LLVMAddFunctionAttribute(Fn: ValueRef, index: c_uint, PA: uint64_t);
|
|
|
|
pub fn LLVMAddFunctionAttrString(Fn: ValueRef, index: c_uint, Name: *c_char);
|
|
|
|
pub fn LLVMRemoveFunctionAttrString(Fn: ValueRef, index: c_uint, Name: *c_char);
|
2013-08-02 14:30:00 -07:00
|
|
|
pub fn LLVMGetFunctionAttr(Fn: ValueRef) -> c_ulonglong;
|
2013-09-09 02:32:30 -04:00
|
|
|
|
2013-03-05 14:42:58 -08:00
|
|
|
/* Operations on parameters */
|
2013-08-02 14:30:00 -07:00
|
|
|
pub fn LLVMCountParams(Fn: ValueRef) -> c_uint;
|
|
|
|
pub fn LLVMGetParams(Fn: ValueRef, Params: *ValueRef);
|
|
|
|
pub fn LLVMGetParam(Fn: ValueRef, Index: c_uint) -> ValueRef;
|
|
|
|
pub fn LLVMGetParamParent(Inst: ValueRef) -> ValueRef;
|
|
|
|
pub fn LLVMGetFirstParam(Fn: ValueRef) -> ValueRef;
|
|
|
|
pub fn LLVMGetLastParam(Fn: ValueRef) -> ValueRef;
|
|
|
|
pub fn LLVMGetNextParam(Arg: ValueRef) -> ValueRef;
|
|
|
|
pub fn LLVMGetPreviousParam(Arg: ValueRef) -> ValueRef;
|
|
|
|
pub fn LLVMAddAttribute(Arg: ValueRef, PA: c_uint);
|
|
|
|
pub fn LLVMRemoveAttribute(Arg: ValueRef, PA: c_uint);
|
|
|
|
pub fn LLVMGetAttribute(Arg: ValueRef) -> c_uint;
|
|
|
|
pub fn LLVMSetParamAlignment(Arg: ValueRef, align: c_uint);
|
2013-03-05 14:42:58 -08:00
|
|
|
|
|
|
|
/* Operations on basic blocks */
|
2013-08-02 14:30:00 -07:00
|
|
|
pub fn LLVMBasicBlockAsValue(BB: BasicBlockRef) -> ValueRef;
|
|
|
|
pub fn LLVMValueIsBasicBlock(Val: ValueRef) -> Bool;
|
|
|
|
pub fn LLVMValueAsBasicBlock(Val: ValueRef) -> BasicBlockRef;
|
|
|
|
pub fn LLVMGetBasicBlockParent(BB: BasicBlockRef) -> ValueRef;
|
|
|
|
pub fn LLVMCountBasicBlocks(Fn: ValueRef) -> c_uint;
|
|
|
|
pub fn LLVMGetBasicBlocks(Fn: ValueRef, BasicBlocks: *ValueRef);
|
|
|
|
pub fn LLVMGetFirstBasicBlock(Fn: ValueRef) -> BasicBlockRef;
|
|
|
|
pub fn LLVMGetLastBasicBlock(Fn: ValueRef) -> BasicBlockRef;
|
|
|
|
pub fn LLVMGetNextBasicBlock(BB: BasicBlockRef) -> BasicBlockRef;
|
|
|
|
pub fn LLVMGetPreviousBasicBlock(BB: BasicBlockRef) -> BasicBlockRef;
|
|
|
|
pub fn LLVMGetEntryBasicBlock(Fn: ValueRef) -> BasicBlockRef;
|
2013-03-05 14:42:58 -08:00
|
|
|
|
2013-08-02 14:30:00 -07:00
|
|
|
pub fn LLVMAppendBasicBlockInContext(C: ContextRef,
|
|
|
|
Fn: ValueRef,
|
|
|
|
Name: *c_char)
|
|
|
|
-> BasicBlockRef;
|
|
|
|
pub fn LLVMInsertBasicBlockInContext(C: ContextRef,
|
|
|
|
BB: BasicBlockRef,
|
|
|
|
Name: *c_char)
|
|
|
|
-> BasicBlockRef;
|
|
|
|
pub fn LLVMDeleteBasicBlock(BB: BasicBlockRef);
|
2013-06-11 12:41:09 -07:00
|
|
|
|
2013-08-02 14:30:00 -07:00
|
|
|
pub fn LLVMMoveBasicBlockAfter(BB: BasicBlockRef,
|
|
|
|
MoveAfter: BasicBlockRef);
|
2013-06-11 12:41:09 -07:00
|
|
|
|
2013-08-02 14:30:00 -07:00
|
|
|
pub fn LLVMMoveBasicBlockBefore(BB: BasicBlockRef,
|
|
|
|
MoveBefore: BasicBlockRef);
|
2013-03-05 14:42:58 -08:00
|
|
|
|
|
|
|
/* Operations on instructions */
|
2013-08-02 14:30:00 -07:00
|
|
|
pub fn LLVMGetInstructionParent(Inst: ValueRef) -> BasicBlockRef;
|
|
|
|
pub fn LLVMGetFirstInstruction(BB: BasicBlockRef) -> ValueRef;
|
|
|
|
pub fn LLVMGetLastInstruction(BB: BasicBlockRef) -> ValueRef;
|
|
|
|
pub fn LLVMGetNextInstruction(Inst: ValueRef) -> ValueRef;
|
|
|
|
pub fn LLVMGetPreviousInstruction(Inst: ValueRef) -> ValueRef;
|
|
|
|
pub fn LLVMInstructionEraseFromParent(Inst: ValueRef);
|
2013-03-05 14:42:58 -08:00
|
|
|
|
|
|
|
/* Operations on call sites */
|
2013-08-02 14:30:00 -07:00
|
|
|
pub fn LLVMSetInstructionCallConv(Instr: ValueRef, CC: c_uint);
|
|
|
|
pub fn LLVMGetInstructionCallConv(Instr: ValueRef) -> c_uint;
|
|
|
|
pub fn LLVMAddInstrAttribute(Instr: ValueRef,
|
|
|
|
index: c_uint,
|
|
|
|
IA: c_uint);
|
|
|
|
pub fn LLVMRemoveInstrAttribute(Instr: ValueRef,
|
|
|
|
index: c_uint,
|
|
|
|
IA: c_uint);
|
|
|
|
pub fn LLVMSetInstrParamAlignment(Instr: ValueRef,
|
|
|
|
index: c_uint,
|
|
|
|
align: c_uint);
|
2014-05-21 15:07:48 -04:00
|
|
|
pub fn LLVMAddCallSiteAttribute(Instr: ValueRef,
|
|
|
|
index: c_uint,
|
|
|
|
Val: uint64_t);
|
2013-03-05 14:42:58 -08:00
|
|
|
|
|
|
|
/* Operations on call instructions (only) */
|
2013-08-02 14:30:00 -07:00
|
|
|
pub fn LLVMIsTailCall(CallInst: ValueRef) -> Bool;
|
|
|
|
pub fn LLVMSetTailCall(CallInst: ValueRef, IsTailCall: Bool);
|
2013-03-05 14:42:58 -08:00
|
|
|
|
2013-12-28 18:01:53 +04:00
|
|
|
/* Operations on load/store instructions (only) */
|
|
|
|
pub fn LLVMGetVolatile(MemoryAccessInst: ValueRef) -> Bool;
|
|
|
|
pub fn LLVMSetVolatile(MemoryAccessInst: ValueRef, volatile: Bool);
|
|
|
|
|
2013-03-05 14:42:58 -08:00
|
|
|
/* Operations on phi nodes */
|
2013-08-02 14:30:00 -07:00
|
|
|
pub fn LLVMAddIncoming(PhiNode: ValueRef,
|
|
|
|
IncomingValues: *ValueRef,
|
|
|
|
IncomingBlocks: *BasicBlockRef,
|
|
|
|
Count: c_uint);
|
|
|
|
pub fn LLVMCountIncoming(PhiNode: ValueRef) -> c_uint;
|
|
|
|
pub fn LLVMGetIncomingValue(PhiNode: ValueRef, Index: c_uint)
|
2013-03-05 14:42:58 -08:00
|
|
|
-> ValueRef;
|
2013-08-02 14:30:00 -07:00
|
|
|
pub fn LLVMGetIncomingBlock(PhiNode: ValueRef, Index: c_uint)
|
|
|
|
-> BasicBlockRef;
|
2013-03-05 14:42:58 -08:00
|
|
|
|
|
|
|
/* Instruction builders */
|
2013-08-02 14:30:00 -07:00
|
|
|
pub fn LLVMCreateBuilderInContext(C: ContextRef) -> BuilderRef;
|
|
|
|
pub fn LLVMPositionBuilder(Builder: BuilderRef,
|
|
|
|
Block: BasicBlockRef,
|
|
|
|
Instr: ValueRef);
|
|
|
|
pub fn LLVMPositionBuilderBefore(Builder: BuilderRef,
|
|
|
|
Instr: ValueRef);
|
|
|
|
pub fn LLVMPositionBuilderAtEnd(Builder: BuilderRef,
|
|
|
|
Block: BasicBlockRef);
|
|
|
|
pub fn LLVMGetInsertBlock(Builder: BuilderRef) -> BasicBlockRef;
|
|
|
|
pub fn LLVMClearInsertionPosition(Builder: BuilderRef);
|
|
|
|
pub fn LLVMInsertIntoBuilder(Builder: BuilderRef, Instr: ValueRef);
|
|
|
|
pub fn LLVMInsertIntoBuilderWithName(Builder: BuilderRef,
|
|
|
|
Instr: ValueRef,
|
|
|
|
Name: *c_char);
|
|
|
|
pub fn LLVMDisposeBuilder(Builder: BuilderRef);
|
|
|
|
pub fn LLVMDisposeExecutionEngine(EE: ExecutionEngineRef);
|
2013-03-05 14:42:58 -08:00
|
|
|
|
|
|
|
/* Metadata */
|
2013-08-02 14:30:00 -07:00
|
|
|
pub fn LLVMSetCurrentDebugLocation(Builder: BuilderRef, L: ValueRef);
|
|
|
|
pub fn LLVMGetCurrentDebugLocation(Builder: BuilderRef) -> ValueRef;
|
|
|
|
pub fn LLVMSetInstDebugLocation(Builder: BuilderRef, Inst: ValueRef);
|
2013-03-05 14:42:58 -08:00
|
|
|
|
|
|
|
/* Terminators */
|
2013-08-02 14:30:00 -07:00
|
|
|
pub fn LLVMBuildRetVoid(B: BuilderRef) -> ValueRef;
|
|
|
|
pub fn LLVMBuildRet(B: BuilderRef, V: ValueRef) -> ValueRef;
|
|
|
|
pub fn LLVMBuildAggregateRet(B: BuilderRef,
|
|
|
|
RetVals: *ValueRef,
|
|
|
|
N: c_uint)
|
|
|
|
-> ValueRef;
|
|
|
|
pub fn LLVMBuildBr(B: BuilderRef, Dest: BasicBlockRef) -> ValueRef;
|
|
|
|
pub fn LLVMBuildCondBr(B: BuilderRef,
|
|
|
|
If: ValueRef,
|
|
|
|
Then: BasicBlockRef,
|
|
|
|
Else: BasicBlockRef)
|
2013-01-29 15:48:50 -08:00
|
|
|
-> ValueRef;
|
2013-08-02 14:30:00 -07:00
|
|
|
pub fn LLVMBuildSwitch(B: BuilderRef,
|
|
|
|
V: ValueRef,
|
|
|
|
Else: BasicBlockRef,
|
|
|
|
NumCases: c_uint)
|
2013-01-10 21:23:07 -08:00
|
|
|
-> ValueRef;
|
2013-08-02 14:30:00 -07:00
|
|
|
pub fn LLVMBuildIndirectBr(B: BuilderRef,
|
|
|
|
Addr: ValueRef,
|
|
|
|
NumDests: c_uint)
|
2013-03-05 14:42:58 -08:00
|
|
|
-> ValueRef;
|
2013-08-02 14:30:00 -07:00
|
|
|
pub fn LLVMBuildInvoke(B: BuilderRef,
|
|
|
|
Fn: ValueRef,
|
|
|
|
Args: *ValueRef,
|
|
|
|
NumArgs: c_uint,
|
|
|
|
Then: BasicBlockRef,
|
|
|
|
Catch: BasicBlockRef,
|
|
|
|
Name: *c_char)
|
|
|
|
-> ValueRef;
|
|
|
|
pub fn LLVMBuildLandingPad(B: BuilderRef,
|
|
|
|
Ty: TypeRef,
|
|
|
|
PersFn: ValueRef,
|
|
|
|
NumClauses: c_uint,
|
|
|
|
Name: *c_char)
|
2013-03-05 14:42:58 -08:00
|
|
|
-> ValueRef;
|
2013-08-02 14:30:00 -07:00
|
|
|
pub fn LLVMBuildResume(B: BuilderRef, Exn: ValueRef) -> ValueRef;
|
|
|
|
pub fn LLVMBuildUnreachable(B: BuilderRef) -> ValueRef;
|
2013-03-05 14:42:58 -08:00
|
|
|
|
|
|
|
/* Add a case to the switch instruction */
|
2013-08-02 14:30:00 -07:00
|
|
|
pub fn LLVMAddCase(Switch: ValueRef,
|
|
|
|
OnVal: ValueRef,
|
|
|
|
Dest: BasicBlockRef);
|
2013-03-05 14:42:58 -08:00
|
|
|
|
|
|
|
/* Add a destination to the indirectbr instruction */
|
2013-08-02 14:30:00 -07:00
|
|
|
pub fn LLVMAddDestination(IndirectBr: ValueRef, Dest: BasicBlockRef);
|
2013-03-05 14:42:58 -08:00
|
|
|
|
|
|
|
/* Add a clause to the landing pad instruction */
|
2013-08-02 14:30:00 -07:00
|
|
|
pub fn LLVMAddClause(LandingPad: ValueRef, ClauseVal: ValueRef);
|
2013-03-05 14:42:58 -08:00
|
|
|
|
|
|
|
/* Set the cleanup on a landing pad instruction */
|
2013-08-02 14:30:00 -07:00
|
|
|
pub fn LLVMSetCleanup(LandingPad: ValueRef, Val: Bool);
|
2013-03-05 14:42:58 -08:00
|
|
|
|
|
|
|
/* Arithmetic */
|
2013-08-02 14:30:00 -07:00
|
|
|
pub fn LLVMBuildAdd(B: BuilderRef,
|
|
|
|
LHS: ValueRef,
|
|
|
|
RHS: ValueRef,
|
|
|
|
Name: *c_char)
|
|
|
|
-> ValueRef;
|
|
|
|
pub fn LLVMBuildNSWAdd(B: BuilderRef,
|
|
|
|
LHS: ValueRef,
|
|
|
|
RHS: ValueRef,
|
|
|
|
Name: *c_char)
|
|
|
|
-> ValueRef;
|
|
|
|
pub fn LLVMBuildNUWAdd(B: BuilderRef,
|
|
|
|
LHS: ValueRef,
|
|
|
|
RHS: ValueRef,
|
|
|
|
Name: *c_char)
|
|
|
|
-> ValueRef;
|
|
|
|
pub fn LLVMBuildFAdd(B: BuilderRef,
|
|
|
|
LHS: ValueRef,
|
|
|
|
RHS: ValueRef,
|
|
|
|
Name: *c_char)
|
|
|
|
-> ValueRef;
|
|
|
|
pub fn LLVMBuildSub(B: BuilderRef,
|
|
|
|
LHS: ValueRef,
|
|
|
|
RHS: ValueRef,
|
|
|
|
Name: *c_char)
|
|
|
|
-> ValueRef;
|
|
|
|
pub fn LLVMBuildNSWSub(B: BuilderRef,
|
|
|
|
LHS: ValueRef,
|
|
|
|
RHS: ValueRef,
|
|
|
|
Name: *c_char)
|
|
|
|
-> ValueRef;
|
|
|
|
pub fn LLVMBuildNUWSub(B: BuilderRef,
|
|
|
|
LHS: ValueRef,
|
|
|
|
RHS: ValueRef,
|
|
|
|
Name: *c_char)
|
|
|
|
-> ValueRef;
|
|
|
|
pub fn LLVMBuildFSub(B: BuilderRef,
|
|
|
|
LHS: ValueRef,
|
|
|
|
RHS: ValueRef,
|
|
|
|
Name: *c_char)
|
|
|
|
-> ValueRef;
|
|
|
|
pub fn LLVMBuildMul(B: BuilderRef,
|
|
|
|
LHS: ValueRef,
|
|
|
|
RHS: ValueRef,
|
|
|
|
Name: *c_char)
|
|
|
|
-> ValueRef;
|
|
|
|
pub fn LLVMBuildNSWMul(B: BuilderRef,
|
|
|
|
LHS: ValueRef,
|
|
|
|
RHS: ValueRef,
|
|
|
|
Name: *c_char)
|
|
|
|
-> ValueRef;
|
|
|
|
pub fn LLVMBuildNUWMul(B: BuilderRef,
|
|
|
|
LHS: ValueRef,
|
|
|
|
RHS: ValueRef,
|
|
|
|
Name: *c_char)
|
|
|
|
-> ValueRef;
|
|
|
|
pub fn LLVMBuildFMul(B: BuilderRef,
|
|
|
|
LHS: ValueRef,
|
|
|
|
RHS: ValueRef,
|
|
|
|
Name: *c_char)
|
|
|
|
-> ValueRef;
|
|
|
|
pub fn LLVMBuildUDiv(B: BuilderRef,
|
|
|
|
LHS: ValueRef,
|
|
|
|
RHS: ValueRef,
|
|
|
|
Name: *c_char)
|
|
|
|
-> ValueRef;
|
|
|
|
pub fn LLVMBuildSDiv(B: BuilderRef,
|
|
|
|
LHS: ValueRef,
|
|
|
|
RHS: ValueRef,
|
|
|
|
Name: *c_char)
|
|
|
|
-> ValueRef;
|
|
|
|
pub fn LLVMBuildExactSDiv(B: BuilderRef,
|
|
|
|
LHS: ValueRef,
|
|
|
|
RHS: ValueRef,
|
|
|
|
Name: *c_char)
|
|
|
|
-> ValueRef;
|
|
|
|
pub fn LLVMBuildFDiv(B: BuilderRef,
|
|
|
|
LHS: ValueRef,
|
|
|
|
RHS: ValueRef,
|
|
|
|
Name: *c_char)
|
|
|
|
-> ValueRef;
|
|
|
|
pub fn LLVMBuildURem(B: BuilderRef,
|
|
|
|
LHS: ValueRef,
|
|
|
|
RHS: ValueRef,
|
|
|
|
Name: *c_char)
|
|
|
|
-> ValueRef;
|
|
|
|
pub fn LLVMBuildSRem(B: BuilderRef,
|
|
|
|
LHS: ValueRef,
|
|
|
|
RHS: ValueRef,
|
|
|
|
Name: *c_char)
|
|
|
|
-> ValueRef;
|
|
|
|
pub fn LLVMBuildFRem(B: BuilderRef,
|
|
|
|
LHS: ValueRef,
|
|
|
|
RHS: ValueRef,
|
|
|
|
Name: *c_char)
|
|
|
|
-> ValueRef;
|
|
|
|
pub fn LLVMBuildShl(B: BuilderRef,
|
|
|
|
LHS: ValueRef,
|
|
|
|
RHS: ValueRef,
|
|
|
|
Name: *c_char)
|
|
|
|
-> ValueRef;
|
|
|
|
pub fn LLVMBuildLShr(B: BuilderRef,
|
|
|
|
LHS: ValueRef,
|
|
|
|
RHS: ValueRef,
|
|
|
|
Name: *c_char)
|
|
|
|
-> ValueRef;
|
|
|
|
pub fn LLVMBuildAShr(B: BuilderRef,
|
|
|
|
LHS: ValueRef,
|
|
|
|
RHS: ValueRef,
|
|
|
|
Name: *c_char)
|
|
|
|
-> ValueRef;
|
|
|
|
pub fn LLVMBuildAnd(B: BuilderRef,
|
|
|
|
LHS: ValueRef,
|
|
|
|
RHS: ValueRef,
|
|
|
|
Name: *c_char)
|
|
|
|
-> ValueRef;
|
|
|
|
pub fn LLVMBuildOr(B: BuilderRef,
|
|
|
|
LHS: ValueRef,
|
|
|
|
RHS: ValueRef,
|
|
|
|
Name: *c_char)
|
|
|
|
-> ValueRef;
|
|
|
|
pub fn LLVMBuildXor(B: BuilderRef,
|
|
|
|
LHS: ValueRef,
|
|
|
|
RHS: ValueRef,
|
|
|
|
Name: *c_char)
|
|
|
|
-> ValueRef;
|
|
|
|
pub fn LLVMBuildBinOp(B: BuilderRef,
|
|
|
|
Op: Opcode,
|
|
|
|
LHS: ValueRef,
|
|
|
|
RHS: ValueRef,
|
|
|
|
Name: *c_char)
|
2013-01-10 21:23:07 -08:00
|
|
|
-> ValueRef;
|
2013-08-02 14:30:00 -07:00
|
|
|
pub fn LLVMBuildNeg(B: BuilderRef, V: ValueRef, Name: *c_char)
|
2013-03-05 14:42:58 -08:00
|
|
|
-> ValueRef;
|
2013-08-02 14:30:00 -07:00
|
|
|
pub fn LLVMBuildNSWNeg(B: BuilderRef, V: ValueRef, Name: *c_char)
|
2013-03-05 14:42:58 -08:00
|
|
|
-> ValueRef;
|
2013-08-02 14:30:00 -07:00
|
|
|
pub fn LLVMBuildNUWNeg(B: BuilderRef, V: ValueRef, Name: *c_char)
|
2013-03-05 14:42:58 -08:00
|
|
|
-> ValueRef;
|
2013-08-02 14:30:00 -07:00
|
|
|
pub fn LLVMBuildFNeg(B: BuilderRef, V: ValueRef, Name: *c_char)
|
2013-03-05 14:42:58 -08:00
|
|
|
-> ValueRef;
|
2013-08-02 14:30:00 -07:00
|
|
|
pub fn LLVMBuildNot(B: BuilderRef, V: ValueRef, Name: *c_char)
|
2013-03-05 14:42:58 -08:00
|
|
|
-> ValueRef;
|
2010-08-18 00:19:25 -07:00
|
|
|
|
2013-03-05 14:42:58 -08:00
|
|
|
/* Memory */
|
2013-08-02 14:30:00 -07:00
|
|
|
pub fn LLVMBuildMalloc(B: BuilderRef, Ty: TypeRef, Name: *c_char)
|
|
|
|
-> ValueRef;
|
|
|
|
pub fn LLVMBuildArrayMalloc(B: BuilderRef,
|
|
|
|
Ty: TypeRef,
|
|
|
|
Val: ValueRef,
|
|
|
|
Name: *c_char)
|
|
|
|
-> ValueRef;
|
|
|
|
pub fn LLVMBuildAlloca(B: BuilderRef, Ty: TypeRef, Name: *c_char)
|
2013-03-05 14:42:58 -08:00
|
|
|
-> ValueRef;
|
2013-08-02 14:30:00 -07:00
|
|
|
pub fn LLVMBuildArrayAlloca(B: BuilderRef,
|
|
|
|
Ty: TypeRef,
|
|
|
|
Val: ValueRef,
|
|
|
|
Name: *c_char)
|
|
|
|
-> ValueRef;
|
|
|
|
pub fn LLVMBuildFree(B: BuilderRef, PointerVal: ValueRef) -> ValueRef;
|
|
|
|
pub fn LLVMBuildLoad(B: BuilderRef,
|
|
|
|
PointerVal: ValueRef,
|
|
|
|
Name: *c_char)
|
|
|
|
-> ValueRef;
|
2013-05-12 21:22:20 +02:00
|
|
|
|
2013-08-02 14:30:00 -07:00
|
|
|
pub fn LLVMBuildStore(B: BuilderRef, Val: ValueRef, Ptr: ValueRef)
|
|
|
|
-> ValueRef;
|
2013-05-12 21:22:20 +02:00
|
|
|
|
2013-08-02 14:30:00 -07:00
|
|
|
pub fn LLVMBuildGEP(B: BuilderRef,
|
|
|
|
Pointer: ValueRef,
|
|
|
|
Indices: *ValueRef,
|
|
|
|
NumIndices: c_uint,
|
|
|
|
Name: *c_char)
|
2013-03-05 14:42:58 -08:00
|
|
|
-> ValueRef;
|
2013-08-02 14:30:00 -07:00
|
|
|
pub fn LLVMBuildInBoundsGEP(B: BuilderRef,
|
|
|
|
Pointer: ValueRef,
|
|
|
|
Indices: *ValueRef,
|
|
|
|
NumIndices: c_uint,
|
|
|
|
Name: *c_char)
|
|
|
|
-> ValueRef;
|
|
|
|
pub fn LLVMBuildStructGEP(B: BuilderRef,
|
|
|
|
Pointer: ValueRef,
|
|
|
|
Idx: c_uint,
|
|
|
|
Name: *c_char)
|
2013-03-05 14:42:58 -08:00
|
|
|
-> ValueRef;
|
2013-08-02 14:30:00 -07:00
|
|
|
pub fn LLVMBuildGlobalString(B: BuilderRef,
|
|
|
|
Str: *c_char,
|
|
|
|
Name: *c_char)
|
2013-03-05 14:42:58 -08:00
|
|
|
-> ValueRef;
|
2013-08-02 14:30:00 -07:00
|
|
|
pub fn LLVMBuildGlobalStringPtr(B: BuilderRef,
|
|
|
|
Str: *c_char,
|
|
|
|
Name: *c_char)
|
2013-03-05 14:42:58 -08:00
|
|
|
-> ValueRef;
|
|
|
|
|
|
|
|
/* Casts */
|
2013-08-02 14:30:00 -07:00
|
|
|
pub fn LLVMBuildTrunc(B: BuilderRef,
|
|
|
|
Val: ValueRef,
|
|
|
|
DestTy: TypeRef,
|
|
|
|
Name: *c_char)
|
|
|
|
-> ValueRef;
|
|
|
|
pub fn LLVMBuildZExt(B: BuilderRef,
|
|
|
|
Val: ValueRef,
|
|
|
|
DestTy: TypeRef,
|
|
|
|
Name: *c_char)
|
|
|
|
-> ValueRef;
|
|
|
|
pub fn LLVMBuildSExt(B: BuilderRef,
|
|
|
|
Val: ValueRef,
|
|
|
|
DestTy: TypeRef,
|
|
|
|
Name: *c_char)
|
|
|
|
-> ValueRef;
|
|
|
|
pub fn LLVMBuildFPToUI(B: BuilderRef,
|
|
|
|
Val: ValueRef,
|
|
|
|
DestTy: TypeRef,
|
|
|
|
Name: *c_char)
|
|
|
|
-> ValueRef;
|
|
|
|
pub fn LLVMBuildFPToSI(B: BuilderRef,
|
|
|
|
Val: ValueRef,
|
|
|
|
DestTy: TypeRef,
|
|
|
|
Name: *c_char)
|
|
|
|
-> ValueRef;
|
|
|
|
pub fn LLVMBuildUIToFP(B: BuilderRef,
|
|
|
|
Val: ValueRef,
|
|
|
|
DestTy: TypeRef,
|
|
|
|
Name: *c_char)
|
|
|
|
-> ValueRef;
|
|
|
|
pub fn LLVMBuildSIToFP(B: BuilderRef,
|
|
|
|
Val: ValueRef,
|
|
|
|
DestTy: TypeRef,
|
|
|
|
Name: *c_char)
|
|
|
|
-> ValueRef;
|
|
|
|
pub fn LLVMBuildFPTrunc(B: BuilderRef,
|
|
|
|
Val: ValueRef,
|
|
|
|
DestTy: TypeRef,
|
|
|
|
Name: *c_char)
|
|
|
|
-> ValueRef;
|
|
|
|
pub fn LLVMBuildFPExt(B: BuilderRef,
|
|
|
|
Val: ValueRef,
|
|
|
|
DestTy: TypeRef,
|
|
|
|
Name: *c_char)
|
|
|
|
-> ValueRef;
|
|
|
|
pub fn LLVMBuildPtrToInt(B: BuilderRef,
|
|
|
|
Val: ValueRef,
|
|
|
|
DestTy: TypeRef,
|
|
|
|
Name: *c_char)
|
|
|
|
-> ValueRef;
|
|
|
|
pub fn LLVMBuildIntToPtr(B: BuilderRef,
|
|
|
|
Val: ValueRef,
|
|
|
|
DestTy: TypeRef,
|
|
|
|
Name: *c_char)
|
|
|
|
-> ValueRef;
|
|
|
|
pub fn LLVMBuildBitCast(B: BuilderRef,
|
|
|
|
Val: ValueRef,
|
|
|
|
DestTy: TypeRef,
|
|
|
|
Name: *c_char)
|
|
|
|
-> ValueRef;
|
|
|
|
pub fn LLVMBuildZExtOrBitCast(B: BuilderRef,
|
|
|
|
Val: ValueRef,
|
|
|
|
DestTy: TypeRef,
|
|
|
|
Name: *c_char)
|
2013-03-05 14:42:58 -08:00
|
|
|
-> ValueRef;
|
2013-08-02 14:30:00 -07:00
|
|
|
pub fn LLVMBuildSExtOrBitCast(B: BuilderRef,
|
|
|
|
Val: ValueRef,
|
|
|
|
DestTy: TypeRef,
|
|
|
|
Name: *c_char)
|
2013-03-05 14:42:58 -08:00
|
|
|
-> ValueRef;
|
2013-08-02 14:30:00 -07:00
|
|
|
pub fn LLVMBuildTruncOrBitCast(B: BuilderRef,
|
2013-03-05 14:42:58 -08:00
|
|
|
Val: ValueRef,
|
|
|
|
DestTy: TypeRef,
|
|
|
|
Name: *c_char)
|
2013-08-02 14:30:00 -07:00
|
|
|
-> ValueRef;
|
|
|
|
pub fn LLVMBuildCast(B: BuilderRef,
|
|
|
|
Op: Opcode,
|
|
|
|
Val: ValueRef,
|
|
|
|
DestTy: TypeRef,
|
|
|
|
Name: *c_char) -> ValueRef;
|
|
|
|
pub fn LLVMBuildPointerCast(B: BuilderRef,
|
|
|
|
Val: ValueRef,
|
|
|
|
DestTy: TypeRef,
|
|
|
|
Name: *c_char)
|
2013-03-05 14:42:58 -08:00
|
|
|
-> ValueRef;
|
2013-08-02 14:30:00 -07:00
|
|
|
pub fn LLVMBuildIntCast(B: BuilderRef,
|
|
|
|
Val: ValueRef,
|
|
|
|
DestTy: TypeRef,
|
|
|
|
Name: *c_char)
|
|
|
|
-> ValueRef;
|
|
|
|
pub fn LLVMBuildFPCast(B: BuilderRef,
|
|
|
|
Val: ValueRef,
|
|
|
|
DestTy: TypeRef,
|
|
|
|
Name: *c_char)
|
|
|
|
-> ValueRef;
|
2013-03-05 14:42:58 -08:00
|
|
|
|
|
|
|
/* Comparisons */
|
2013-08-02 14:30:00 -07:00
|
|
|
pub fn LLVMBuildICmp(B: BuilderRef,
|
|
|
|
Op: c_uint,
|
|
|
|
LHS: ValueRef,
|
|
|
|
RHS: ValueRef,
|
|
|
|
Name: *c_char)
|
|
|
|
-> ValueRef;
|
|
|
|
pub fn LLVMBuildFCmp(B: BuilderRef,
|
|
|
|
Op: c_uint,
|
|
|
|
LHS: ValueRef,
|
|
|
|
RHS: ValueRef,
|
|
|
|
Name: *c_char)
|
|
|
|
-> ValueRef;
|
2013-03-05 14:42:58 -08:00
|
|
|
|
|
|
|
/* Miscellaneous instructions */
|
2013-08-02 14:30:00 -07:00
|
|
|
pub fn LLVMBuildPhi(B: BuilderRef, Ty: TypeRef, Name: *c_char)
|
|
|
|
-> ValueRef;
|
|
|
|
pub fn LLVMBuildCall(B: BuilderRef,
|
|
|
|
Fn: ValueRef,
|
|
|
|
Args: *ValueRef,
|
|
|
|
NumArgs: c_uint,
|
|
|
|
Name: *c_char)
|
|
|
|
-> ValueRef;
|
|
|
|
pub fn LLVMBuildSelect(B: BuilderRef,
|
|
|
|
If: ValueRef,
|
|
|
|
Then: ValueRef,
|
|
|
|
Else: ValueRef,
|
|
|
|
Name: *c_char)
|
|
|
|
-> ValueRef;
|
|
|
|
pub fn LLVMBuildVAArg(B: BuilderRef,
|
|
|
|
list: ValueRef,
|
|
|
|
Ty: TypeRef,
|
|
|
|
Name: *c_char)
|
|
|
|
-> ValueRef;
|
|
|
|
pub fn LLVMBuildExtractElement(B: BuilderRef,
|
|
|
|
VecVal: ValueRef,
|
|
|
|
Index: ValueRef,
|
|
|
|
Name: *c_char)
|
2013-03-05 14:42:58 -08:00
|
|
|
-> ValueRef;
|
2013-08-02 14:30:00 -07:00
|
|
|
pub fn LLVMBuildInsertElement(B: BuilderRef,
|
|
|
|
VecVal: ValueRef,
|
|
|
|
EltVal: ValueRef,
|
|
|
|
Index: ValueRef,
|
|
|
|
Name: *c_char)
|
2013-03-05 14:42:58 -08:00
|
|
|
-> ValueRef;
|
2013-08-02 14:30:00 -07:00
|
|
|
pub fn LLVMBuildShuffleVector(B: BuilderRef,
|
|
|
|
V1: ValueRef,
|
|
|
|
V2: ValueRef,
|
|
|
|
Mask: ValueRef,
|
|
|
|
Name: *c_char)
|
2013-03-05 14:42:58 -08:00
|
|
|
-> ValueRef;
|
2013-08-02 14:30:00 -07:00
|
|
|
pub fn LLVMBuildExtractValue(B: BuilderRef,
|
|
|
|
AggVal: ValueRef,
|
|
|
|
Index: c_uint,
|
|
|
|
Name: *c_char)
|
2013-03-05 14:42:58 -08:00
|
|
|
-> ValueRef;
|
2013-08-02 14:30:00 -07:00
|
|
|
pub fn LLVMBuildInsertValue(B: BuilderRef,
|
|
|
|
AggVal: ValueRef,
|
|
|
|
EltVal: ValueRef,
|
|
|
|
Index: c_uint,
|
|
|
|
Name: *c_char)
|
2013-03-05 14:42:58 -08:00
|
|
|
-> ValueRef;
|
2013-01-10 21:23:07 -08:00
|
|
|
|
2013-08-02 14:30:00 -07:00
|
|
|
pub fn LLVMBuildIsNull(B: BuilderRef, Val: ValueRef, Name: *c_char)
|
|
|
|
-> ValueRef;
|
|
|
|
pub fn LLVMBuildIsNotNull(B: BuilderRef, Val: ValueRef, Name: *c_char)
|
|
|
|
-> ValueRef;
|
|
|
|
pub fn LLVMBuildPtrDiff(B: BuilderRef,
|
|
|
|
LHS: ValueRef,
|
|
|
|
RHS: ValueRef,
|
|
|
|
Name: *c_char)
|
|
|
|
-> ValueRef;
|
2010-08-12 12:10:36 -07:00
|
|
|
|
2013-03-05 14:42:58 -08:00
|
|
|
/* Atomic Operations */
|
2013-08-02 14:30:00 -07:00
|
|
|
pub fn LLVMBuildAtomicLoad(B: BuilderRef,
|
|
|
|
PointerVal: ValueRef,
|
|
|
|
Name: *c_char,
|
|
|
|
Order: AtomicOrdering,
|
|
|
|
Alignment: c_uint)
|
|
|
|
-> ValueRef;
|
2013-05-12 21:22:20 +02:00
|
|
|
|
2013-08-02 14:30:00 -07:00
|
|
|
pub fn LLVMBuildAtomicStore(B: BuilderRef,
|
|
|
|
Val: ValueRef,
|
|
|
|
Ptr: ValueRef,
|
|
|
|
Order: AtomicOrdering,
|
|
|
|
Alignment: c_uint)
|
|
|
|
-> ValueRef;
|
2013-05-13 13:33:34 +02:00
|
|
|
|
2013-08-02 14:30:00 -07:00
|
|
|
pub fn LLVMBuildAtomicCmpXchg(B: BuilderRef,
|
|
|
|
LHS: ValueRef,
|
|
|
|
CMP: ValueRef,
|
|
|
|
RHS: ValueRef,
|
2014-03-31 14:43:19 -07:00
|
|
|
Order: AtomicOrdering,
|
|
|
|
FailureOrder: AtomicOrdering)
|
2013-08-02 14:30:00 -07:00
|
|
|
-> ValueRef;
|
|
|
|
pub fn LLVMBuildAtomicRMW(B: BuilderRef,
|
|
|
|
Op: AtomicBinOp,
|
|
|
|
LHS: ValueRef,
|
|
|
|
RHS: ValueRef,
|
2013-05-25 17:23:12 -05:00
|
|
|
Order: AtomicOrdering,
|
|
|
|
SingleThreaded: Bool)
|
2013-08-02 14:30:00 -07:00
|
|
|
-> ValueRef;
|
2013-03-05 14:42:58 -08:00
|
|
|
|
2013-08-02 14:30:00 -07:00
|
|
|
pub fn LLVMBuildAtomicFence(B: BuilderRef, Order: AtomicOrdering);
|
2013-07-28 19:48:16 +12:00
|
|
|
|
|
|
|
|
2013-03-05 14:42:58 -08:00
|
|
|
/* Selected entries from the downcasts. */
|
2013-08-02 14:30:00 -07:00
|
|
|
pub fn LLVMIsATerminatorInst(Inst: ValueRef) -> ValueRef;
|
2013-07-28 16:40:35 +02:00
|
|
|
pub fn LLVMIsAStoreInst(Inst: ValueRef) -> ValueRef;
|
2013-03-05 14:42:58 -08:00
|
|
|
|
|
|
|
/** Writes a module to the specified path. Returns 0 on success. */
|
2013-08-02 14:30:00 -07:00
|
|
|
pub fn LLVMWriteBitcodeToFile(M: ModuleRef, Path: *c_char) -> c_int;
|
2013-03-05 14:42:58 -08:00
|
|
|
|
|
|
|
/** Creates target data from a target layout string. */
|
2013-08-02 14:30:00 -07:00
|
|
|
pub fn LLVMCreateTargetData(StringRep: *c_char) -> TargetDataRef;
|
|
|
|
/// Adds the target data to the given pass manager. The pass manager
|
|
|
|
/// references the target data only weakly.
|
|
|
|
pub fn LLVMAddTargetData(TD: TargetDataRef, PM: PassManagerRef);
|
2013-03-05 14:42:58 -08:00
|
|
|
/** Number of bytes clobbered when doing a Store to *T. */
|
2013-08-02 14:30:00 -07:00
|
|
|
pub fn LLVMStoreSizeOfType(TD: TargetDataRef, Ty: TypeRef)
|
|
|
|
-> c_ulonglong;
|
2013-03-05 14:42:58 -08:00
|
|
|
|
|
|
|
/** Number of bytes clobbered when doing a Store to *T. */
|
2013-08-02 14:30:00 -07:00
|
|
|
pub fn LLVMSizeOfTypeInBits(TD: TargetDataRef, Ty: TypeRef)
|
|
|
|
-> c_ulonglong;
|
2013-03-05 14:42:58 -08:00
|
|
|
|
|
|
|
/** Distance between successive elements in an array of T.
|
|
|
|
Includes ABI padding. */
|
2013-08-02 14:30:00 -07:00
|
|
|
pub fn LLVMABISizeOfType(TD: TargetDataRef, Ty: TypeRef) -> c_uint;
|
2013-03-05 14:42:58 -08:00
|
|
|
|
|
|
|
/** Returns the preferred alignment of a type. */
|
2013-08-02 14:30:00 -07:00
|
|
|
pub fn LLVMPreferredAlignmentOfType(TD: TargetDataRef, Ty: TypeRef)
|
|
|
|
-> c_uint;
|
2013-03-05 14:42:58 -08:00
|
|
|
/** Returns the minimum alignment of a type. */
|
2013-08-02 14:30:00 -07:00
|
|
|
pub fn LLVMABIAlignmentOfType(TD: TargetDataRef, Ty: TypeRef)
|
|
|
|
-> c_uint;
|
2013-06-26 16:00:42 +02:00
|
|
|
|
2013-08-02 14:30:00 -07:00
|
|
|
/// Computes the byte offset of the indexed struct element for a
|
|
|
|
/// target.
|
|
|
|
pub fn LLVMOffsetOfElement(TD: TargetDataRef,
|
|
|
|
StructTy: TypeRef,
|
|
|
|
Element: c_uint)
|
|
|
|
-> c_ulonglong;
|
2013-06-26 16:00:42 +02:00
|
|
|
|
2013-03-05 14:42:58 -08:00
|
|
|
/**
|
|
|
|
* Returns the minimum alignment of a type when part of a call frame.
|
|
|
|
*/
|
2013-08-02 14:30:00 -07:00
|
|
|
pub fn LLVMCallFrameAlignmentOfType(TD: TargetDataRef, Ty: TypeRef)
|
|
|
|
-> c_uint;
|
2013-03-05 14:42:58 -08:00
|
|
|
|
|
|
|
/** Disposes target data. */
|
2013-08-02 14:30:00 -07:00
|
|
|
pub fn LLVMDisposeTargetData(TD: TargetDataRef);
|
2013-03-05 14:42:58 -08:00
|
|
|
|
|
|
|
/** Creates a pass manager. */
|
2013-08-02 14:30:00 -07:00
|
|
|
pub fn LLVMCreatePassManager() -> PassManagerRef;
|
2013-08-22 20:58:42 -07:00
|
|
|
|
2013-05-28 11:15:31 +12:00
|
|
|
/** Creates a function-by-function pass manager */
|
2013-08-02 14:30:00 -07:00
|
|
|
pub fn LLVMCreateFunctionPassManagerForModule(M: ModuleRef)
|
|
|
|
-> PassManagerRef;
|
2013-05-28 11:15:31 +12:00
|
|
|
|
2013-03-05 14:42:58 -08:00
|
|
|
/** Disposes a pass manager. */
|
2013-08-02 14:30:00 -07:00
|
|
|
pub fn LLVMDisposePassManager(PM: PassManagerRef);
|
2013-05-28 11:15:31 +12:00
|
|
|
|
2013-03-05 14:42:58 -08:00
|
|
|
/** Runs a pass manager on a module. */
|
2013-08-02 14:30:00 -07:00
|
|
|
pub fn LLVMRunPassManager(PM: PassManagerRef, M: ModuleRef) -> Bool;
|
2013-03-05 14:42:58 -08:00
|
|
|
|
2013-05-28 11:15:31 +12:00
|
|
|
/** Runs the function passes on the provided function. */
|
2013-08-02 14:30:00 -07:00
|
|
|
pub fn LLVMRunFunctionPassManager(FPM: PassManagerRef, F: ValueRef)
|
|
|
|
-> Bool;
|
2013-05-28 11:15:31 +12:00
|
|
|
|
|
|
|
/** Initializes all the function passes scheduled in the manager */
|
2013-08-02 14:30:00 -07:00
|
|
|
pub fn LLVMInitializeFunctionPassManager(FPM: PassManagerRef) -> Bool;
|
2013-05-28 11:15:31 +12:00
|
|
|
|
|
|
|
/** Finalizes all the function passes scheduled in the manager */
|
2013-08-02 14:30:00 -07:00
|
|
|
pub fn LLVMFinalizeFunctionPassManager(FPM: PassManagerRef) -> Bool;
|
2013-05-28 11:15:31 +12:00
|
|
|
|
2013-08-02 14:30:00 -07:00
|
|
|
pub fn LLVMInitializePasses();
|
2013-05-29 20:08:20 +12:00
|
|
|
|
2013-03-05 14:42:58 -08:00
|
|
|
/** Adds a verification pass. */
|
2013-08-02 14:30:00 -07:00
|
|
|
pub fn LLVMAddVerifierPass(PM: PassManagerRef);
|
2013-03-05 14:42:58 -08:00
|
|
|
|
2013-08-02 14:30:00 -07:00
|
|
|
pub fn LLVMAddGlobalOptimizerPass(PM: PassManagerRef);
|
|
|
|
pub fn LLVMAddIPSCCPPass(PM: PassManagerRef);
|
|
|
|
pub fn LLVMAddDeadArgEliminationPass(PM: PassManagerRef);
|
|
|
|
pub fn LLVMAddInstructionCombiningPass(PM: PassManagerRef);
|
|
|
|
pub fn LLVMAddCFGSimplificationPass(PM: PassManagerRef);
|
|
|
|
pub fn LLVMAddFunctionInliningPass(PM: PassManagerRef);
|
|
|
|
pub fn LLVMAddFunctionAttrsPass(PM: PassManagerRef);
|
|
|
|
pub fn LLVMAddScalarReplAggregatesPass(PM: PassManagerRef);
|
|
|
|
pub fn LLVMAddScalarReplAggregatesPassSSA(PM: PassManagerRef);
|
|
|
|
pub fn LLVMAddJumpThreadingPass(PM: PassManagerRef);
|
|
|
|
pub fn LLVMAddConstantPropagationPass(PM: PassManagerRef);
|
|
|
|
pub fn LLVMAddReassociatePass(PM: PassManagerRef);
|
|
|
|
pub fn LLVMAddLoopRotatePass(PM: PassManagerRef);
|
|
|
|
pub fn LLVMAddLICMPass(PM: PassManagerRef);
|
|
|
|
pub fn LLVMAddLoopUnswitchPass(PM: PassManagerRef);
|
|
|
|
pub fn LLVMAddLoopDeletionPass(PM: PassManagerRef);
|
|
|
|
pub fn LLVMAddLoopUnrollPass(PM: PassManagerRef);
|
|
|
|
pub fn LLVMAddGVNPass(PM: PassManagerRef);
|
|
|
|
pub fn LLVMAddMemCpyOptPass(PM: PassManagerRef);
|
|
|
|
pub fn LLVMAddSCCPPass(PM: PassManagerRef);
|
|
|
|
pub fn LLVMAddDeadStoreEliminationPass(PM: PassManagerRef);
|
|
|
|
pub fn LLVMAddStripDeadPrototypesPass(PM: PassManagerRef);
|
|
|
|
pub fn LLVMAddConstantMergePass(PM: PassManagerRef);
|
|
|
|
pub fn LLVMAddArgumentPromotionPass(PM: PassManagerRef);
|
|
|
|
pub fn LLVMAddTailCallEliminationPass(PM: PassManagerRef);
|
|
|
|
pub fn LLVMAddIndVarSimplifyPass(PM: PassManagerRef);
|
|
|
|
pub fn LLVMAddAggressiveDCEPass(PM: PassManagerRef);
|
|
|
|
pub fn LLVMAddGlobalDCEPass(PM: PassManagerRef);
|
|
|
|
pub fn LLVMAddCorrelatedValuePropagationPass(PM: PassManagerRef);
|
|
|
|
pub fn LLVMAddPruneEHPass(PM: PassManagerRef);
|
|
|
|
pub fn LLVMAddSimplifyLibCallsPass(PM: PassManagerRef);
|
|
|
|
pub fn LLVMAddLoopIdiomPass(PM: PassManagerRef);
|
|
|
|
pub fn LLVMAddEarlyCSEPass(PM: PassManagerRef);
|
|
|
|
pub fn LLVMAddTypeBasedAliasAnalysisPass(PM: PassManagerRef);
|
|
|
|
pub fn LLVMAddBasicAliasAnalysisPass(PM: PassManagerRef);
|
2013-03-05 14:42:58 -08:00
|
|
|
|
2013-08-02 14:30:00 -07:00
|
|
|
pub fn LLVMPassManagerBuilderCreate() -> PassManagerBuilderRef;
|
|
|
|
pub fn LLVMPassManagerBuilderDispose(PMB: PassManagerBuilderRef);
|
|
|
|
pub fn LLVMPassManagerBuilderSetOptLevel(PMB: PassManagerBuilderRef,
|
|
|
|
OptimizationLevel: c_uint);
|
|
|
|
pub fn LLVMPassManagerBuilderSetSizeLevel(PMB: PassManagerBuilderRef,
|
|
|
|
Value: Bool);
|
|
|
|
pub fn LLVMPassManagerBuilderSetDisableUnitAtATime(
|
|
|
|
PMB: PassManagerBuilderRef,
|
|
|
|
Value: Bool);
|
|
|
|
pub fn LLVMPassManagerBuilderSetDisableUnrollLoops(
|
|
|
|
PMB: PassManagerBuilderRef,
|
|
|
|
Value: Bool);
|
|
|
|
pub fn LLVMPassManagerBuilderSetDisableSimplifyLibCalls(
|
|
|
|
PMB: PassManagerBuilderRef,
|
|
|
|
Value: Bool);
|
|
|
|
pub fn LLVMPassManagerBuilderUseInlinerWithThreshold(
|
|
|
|
PMB: PassManagerBuilderRef,
|
|
|
|
threshold: c_uint);
|
|
|
|
pub fn LLVMPassManagerBuilderPopulateModulePassManager(
|
|
|
|
PMB: PassManagerBuilderRef,
|
|
|
|
PM: PassManagerRef);
|
2013-03-05 14:42:58 -08:00
|
|
|
|
2013-08-02 14:30:00 -07:00
|
|
|
pub fn LLVMPassManagerBuilderPopulateFunctionPassManager(
|
|
|
|
PMB: PassManagerBuilderRef,
|
|
|
|
PM: PassManagerRef);
|
Implement LTO
This commit implements LTO for rust leveraging LLVM's passes. What this means
is:
* When compiling an rlib, in addition to insdering foo.o into the archive, also
insert foo.bc (the LLVM bytecode) of the optimized module.
* When the compiler detects the -Z lto option, it will attempt to perform LTO on
a staticlib or binary output. The compiler will emit an error if a dylib or
rlib output is being generated.
* The actual act of performing LTO is as follows:
1. Force all upstream libraries to have an rlib version available.
2. Load the bytecode of each upstream library from the rlib.
3. Link all this bytecode into the current LLVM module (just using llvm
apis)
4. Run an internalization pass which internalizes all symbols except those
found reachable for the local crate of compilation.
5. Run the LLVM LTO pass manager over this entire module
6a. If assembling an archive, then add all upstream rlibs into the output
archive. This ignores all of the object/bitcode/metadata files rust
generated and placed inside the rlibs.
6b. If linking a binary, create copies of all upstream rlibs, remove the
rust-generated object-file, and then link everything as usual.
As I have explained in #10741, this process is excruciatingly slow, so this is
*not* turned on by default, and it is also why I have decided to hide it behind
a -Z flag for now. The good news is that the binary sizes are about as small as
they can be as a result of LTO, so it's definitely working.
Closes #10741
Closes #10740
2013-12-02 23:19:29 -08:00
|
|
|
pub fn LLVMPassManagerBuilderPopulateLTOPassManager(
|
|
|
|
PMB: PassManagerBuilderRef,
|
|
|
|
PM: PassManagerRef,
|
|
|
|
Internalize: Bool,
|
|
|
|
RunInliner: Bool);
|
2013-03-05 14:42:58 -08:00
|
|
|
|
|
|
|
/** Destroys a memory buffer. */
|
2013-08-02 14:30:00 -07:00
|
|
|
pub fn LLVMDisposeMemoryBuffer(MemBuf: MemoryBufferRef);
|
2013-03-05 14:42:58 -08:00
|
|
|
|
|
|
|
|
|
|
|
/* Stuff that's in rustllvm/ because it's not upstream yet. */
|
|
|
|
|
|
|
|
/** Opens an object file. */
|
2013-08-02 14:30:00 -07:00
|
|
|
pub fn LLVMCreateObjectFile(MemBuf: MemoryBufferRef) -> ObjectFileRef;
|
2013-03-05 14:42:58 -08:00
|
|
|
/** Closes an object file. */
|
2013-08-02 14:30:00 -07:00
|
|
|
pub fn LLVMDisposeObjectFile(ObjFile: ObjectFileRef);
|
2013-03-05 14:42:58 -08:00
|
|
|
|
|
|
|
/** Enumerates the sections in an object file. */
|
2013-08-02 14:30:00 -07:00
|
|
|
pub fn LLVMGetSections(ObjFile: ObjectFileRef) -> SectionIteratorRef;
|
2013-03-05 14:42:58 -08:00
|
|
|
/** Destroys a section iterator. */
|
2013-08-02 14:30:00 -07:00
|
|
|
pub fn LLVMDisposeSectionIterator(SI: SectionIteratorRef);
|
2013-03-05 14:42:58 -08:00
|
|
|
/** Returns true if the section iterator is at the end of the section
|
|
|
|
list: */
|
2013-08-02 14:30:00 -07:00
|
|
|
pub fn LLVMIsSectionIteratorAtEnd(ObjFile: ObjectFileRef,
|
|
|
|
SI: SectionIteratorRef)
|
|
|
|
-> Bool;
|
2013-03-05 14:42:58 -08:00
|
|
|
/** Moves the section iterator to point to the next section. */
|
2013-08-02 14:30:00 -07:00
|
|
|
pub fn LLVMMoveToNextSection(SI: SectionIteratorRef);
|
2013-03-05 14:42:58 -08:00
|
|
|
/** Returns the current section size. */
|
2013-08-02 14:30:00 -07:00
|
|
|
pub fn LLVMGetSectionSize(SI: SectionIteratorRef) -> c_ulonglong;
|
2013-03-05 14:42:58 -08:00
|
|
|
/** Returns the current section contents as a string buffer. */
|
2013-08-02 14:30:00 -07:00
|
|
|
pub fn LLVMGetSectionContents(SI: SectionIteratorRef) -> *c_char;
|
2013-03-05 14:42:58 -08:00
|
|
|
|
|
|
|
/** Reads the given file and returns it as a memory buffer. Use
|
|
|
|
LLVMDisposeMemoryBuffer() to get rid of it. */
|
2013-08-02 14:30:00 -07:00
|
|
|
pub fn LLVMRustCreateMemoryBufferWithContentsOfFile(Path: *c_char)
|
|
|
|
-> MemoryBufferRef;
|
Add generation of static libraries to rustc
This commit implements the support necessary for generating both intermediate
and result static rust libraries. This is an implementation of my thoughts in
https://mail.mozilla.org/pipermail/rust-dev/2013-November/006686.html.
When compiling a library, we still retain the "lib" option, although now there
are "rlib", "staticlib", and "dylib" as options for crate_type (and these are
stackable). The idea of "lib" is to generate the "compiler default" instead of
having too choose (although all are interchangeable). For now I have left the
"complier default" to be a dynamic library for size reasons.
Of the rust libraries, lib{std,extra,rustuv} will bootstrap with an
rlib/dylib pair, but lib{rustc,syntax,rustdoc,rustpkg} will only be built as a
dynamic object. I chose this for size reasons, but also because you're probably
not going to be embedding the rustc compiler anywhere any time soon.
Other than the options outlined above, there are a few defaults/preferences that
are now opinionated in the compiler:
* If both a .dylib and .rlib are found for a rust library, the compiler will
prefer the .rlib variant. This is overridable via the -Z prefer-dynamic option
* If generating a "lib", the compiler will generate a dynamic library. This is
overridable by explicitly saying what flavor you'd like (rlib, staticlib,
dylib).
* If no options are passed to the command line, and no crate_type is found in
the destination crate, then an executable is generated
With this change, you can successfully build a rust program with 0 dynamic
dependencies on rust libraries. There is still a dynamic dependency on
librustrt, but I plan on removing that in a subsequent commit.
This change includes no tests just yet. Our current testing
infrastructure/harnesses aren't very amenable to doing flavorful things with
linking, so I'm planning on adding a new mode of testing which I believe belongs
as a separate commit.
Closes #552
2013-11-15 14:03:29 -08:00
|
|
|
/** Borrows the contents of the memory buffer (doesn't copy it) */
|
|
|
|
pub fn LLVMCreateMemoryBufferWithMemoryRange(InputData: *c_char,
|
|
|
|
InputDataLength: size_t,
|
|
|
|
BufferName: *c_char,
|
|
|
|
RequiresNull: Bool)
|
|
|
|
-> MemoryBufferRef;
|
|
|
|
pub fn LLVMCreateMemoryBufferWithMemoryRangeCopy(InputData: *c_char,
|
|
|
|
InputDataLength: size_t,
|
|
|
|
BufferName: *c_char)
|
|
|
|
-> MemoryBufferRef;
|
2013-03-05 14:42:58 -08:00
|
|
|
|
2013-12-28 19:44:52 -08:00
|
|
|
pub fn LLVMIsMultithreaded() -> Bool;
|
|
|
|
pub fn LLVMStartMultithreaded() -> Bool;
|
|
|
|
|
2013-03-05 14:42:58 -08:00
|
|
|
/** Returns a string describing the last error caused by an LLVMRust*
|
|
|
|
call. */
|
2013-08-02 14:30:00 -07:00
|
|
|
pub fn LLVMRustGetLastError() -> *c_char;
|
2013-03-05 14:42:58 -08:00
|
|
|
|
|
|
|
/// Print the pass timings since static dtors aren't picking them up.
|
2013-08-02 14:30:00 -07:00
|
|
|
pub fn LLVMRustPrintPassTimings();
|
2013-03-05 14:42:58 -08:00
|
|
|
|
2013-08-02 14:30:00 -07:00
|
|
|
pub fn LLVMStructCreateNamed(C: ContextRef, Name: *c_char) -> TypeRef;
|
2013-03-05 14:42:58 -08:00
|
|
|
|
2013-08-02 14:30:00 -07:00
|
|
|
pub fn LLVMStructSetBody(StructTy: TypeRef,
|
|
|
|
ElementTypes: *TypeRef,
|
|
|
|
ElementCount: c_uint,
|
|
|
|
Packed: Bool);
|
2013-03-05 14:42:58 -08:00
|
|
|
|
2013-08-02 14:30:00 -07:00
|
|
|
pub fn LLVMConstNamedStruct(S: TypeRef,
|
|
|
|
ConstantVals: *ValueRef,
|
|
|
|
Count: c_uint)
|
|
|
|
-> ValueRef;
|
2013-03-05 14:42:58 -08:00
|
|
|
|
|
|
|
/** Enables LLVM debug output. */
|
2013-08-02 14:30:00 -07:00
|
|
|
pub fn LLVMSetDebug(Enabled: c_int);
|
2013-03-09 22:37:50 -08:00
|
|
|
|
|
|
|
/** Prepares inline assembly. */
|
2013-08-02 14:30:00 -07:00
|
|
|
pub fn LLVMInlineAsm(Ty: TypeRef,
|
|
|
|
AsmString: *c_char,
|
|
|
|
Constraints: *c_char,
|
|
|
|
SideEffects: Bool,
|
|
|
|
AlignStack: Bool,
|
|
|
|
Dialect: c_uint)
|
|
|
|
-> ValueRef;
|
2013-05-28 11:15:31 +12:00
|
|
|
|
2014-01-28 00:05:33 -05:00
|
|
|
pub static LLVMRustDebugMetadataVersion: u32;
|
|
|
|
|
|
|
|
pub fn LLVMRustAddModuleFlag(M: ModuleRef,
|
|
|
|
name: *c_char,
|
|
|
|
value: u32);
|
2013-06-14 11:38:29 -07:00
|
|
|
|
2013-08-02 14:30:00 -07:00
|
|
|
pub fn LLVMDIBuilderCreate(M: ModuleRef) -> DIBuilderRef;
|
2013-06-14 11:38:29 -07:00
|
|
|
|
2013-08-02 14:30:00 -07:00
|
|
|
pub fn LLVMDIBuilderDispose(Builder: DIBuilderRef);
|
2013-06-14 11:38:29 -07:00
|
|
|
|
2013-08-02 14:30:00 -07:00
|
|
|
pub fn LLVMDIBuilderFinalize(Builder: DIBuilderRef);
|
2013-06-14 11:38:29 -07:00
|
|
|
|
2013-08-02 14:30:00 -07:00
|
|
|
pub fn LLVMDIBuilderCreateCompileUnit(Builder: DIBuilderRef,
|
|
|
|
Lang: c_uint,
|
|
|
|
File: *c_char,
|
|
|
|
Dir: *c_char,
|
|
|
|
Producer: *c_char,
|
|
|
|
isOptimized: bool,
|
|
|
|
Flags: *c_char,
|
|
|
|
RuntimeVer: c_uint,
|
|
|
|
SplitName: *c_char);
|
|
|
|
|
|
|
|
pub fn LLVMDIBuilderCreateFile(Builder: DIBuilderRef,
|
|
|
|
Filename: *c_char,
|
|
|
|
Directory: *c_char)
|
|
|
|
-> DIFile;
|
|
|
|
|
|
|
|
pub fn LLVMDIBuilderCreateSubroutineType(Builder: DIBuilderRef,
|
|
|
|
File: DIFile,
|
|
|
|
ParameterTypes: DIArray)
|
|
|
|
-> DICompositeType;
|
2013-06-14 11:38:29 -07:00
|
|
|
|
2013-08-02 14:30:00 -07:00
|
|
|
pub fn LLVMDIBuilderCreateFunction(Builder: DIBuilderRef,
|
|
|
|
Scope: DIDescriptor,
|
|
|
|
Name: *c_char,
|
|
|
|
LinkageName: *c_char,
|
|
|
|
File: DIFile,
|
|
|
|
LineNo: c_uint,
|
|
|
|
Ty: DIType,
|
|
|
|
isLocalToUnit: bool,
|
|
|
|
isDefinition: bool,
|
|
|
|
ScopeLine: c_uint,
|
|
|
|
Flags: c_uint,
|
|
|
|
isOptimized: bool,
|
|
|
|
Fn: ValueRef,
|
|
|
|
TParam: ValueRef,
|
|
|
|
Decl: ValueRef)
|
|
|
|
-> DISubprogram;
|
|
|
|
|
|
|
|
pub fn LLVMDIBuilderCreateBasicType(Builder: DIBuilderRef,
|
|
|
|
Name: *c_char,
|
|
|
|
SizeInBits: c_ulonglong,
|
|
|
|
AlignInBits: c_ulonglong,
|
|
|
|
Encoding: c_uint)
|
|
|
|
-> DIBasicType;
|
|
|
|
|
|
|
|
pub fn LLVMDIBuilderCreatePointerType(Builder: DIBuilderRef,
|
|
|
|
PointeeTy: DIType,
|
|
|
|
SizeInBits: c_ulonglong,
|
|
|
|
AlignInBits: c_ulonglong,
|
|
|
|
Name: *c_char)
|
|
|
|
-> DIDerivedType;
|
|
|
|
|
|
|
|
pub fn LLVMDIBuilderCreateStructType(Builder: DIBuilderRef,
|
|
|
|
Scope: DIDescriptor,
|
|
|
|
Name: *c_char,
|
|
|
|
File: DIFile,
|
|
|
|
LineNumber: c_uint,
|
|
|
|
SizeInBits: c_ulonglong,
|
|
|
|
AlignInBits: c_ulonglong,
|
|
|
|
Flags: c_uint,
|
|
|
|
DerivedFrom: DIType,
|
|
|
|
Elements: DIArray,
|
|
|
|
RunTimeLang: c_uint,
|
2013-10-01 12:24:50 +02:00
|
|
|
VTableHolder: ValueRef,
|
|
|
|
UniqueId: *c_char)
|
2013-08-02 14:30:00 -07:00
|
|
|
-> DICompositeType;
|
|
|
|
|
|
|
|
pub fn LLVMDIBuilderCreateMemberType(Builder: DIBuilderRef,
|
|
|
|
Scope: DIDescriptor,
|
|
|
|
Name: *c_char,
|
|
|
|
File: DIFile,
|
|
|
|
LineNo: c_uint,
|
|
|
|
SizeInBits: c_ulonglong,
|
|
|
|
AlignInBits: c_ulonglong,
|
|
|
|
OffsetInBits: c_ulonglong,
|
|
|
|
Flags: c_uint,
|
|
|
|
Ty: DIType)
|
|
|
|
-> DIDerivedType;
|
|
|
|
|
|
|
|
pub fn LLVMDIBuilderCreateLexicalBlock(Builder: DIBuilderRef,
|
|
|
|
Scope: DIDescriptor,
|
|
|
|
File: DIFile,
|
|
|
|
Line: c_uint,
|
2014-03-31 14:43:19 -07:00
|
|
|
Col: c_uint,
|
|
|
|
Discriminator: c_uint)
|
2013-08-02 14:30:00 -07:00
|
|
|
-> DILexicalBlock;
|
|
|
|
|
2014-02-20 20:44:29 -05:00
|
|
|
pub fn LLVMDIBuilderCreateStaticVariable(Builder: DIBuilderRef,
|
|
|
|
Context: DIDescriptor,
|
|
|
|
Name: *c_char,
|
|
|
|
LinkageName: *c_char,
|
|
|
|
File: DIFile,
|
|
|
|
LineNo: c_uint,
|
|
|
|
Ty: DIType,
|
|
|
|
isLocalToUnit: bool,
|
|
|
|
Val: ValueRef,
|
|
|
|
Decl: ValueRef)
|
|
|
|
-> DIGlobalVariable;
|
|
|
|
|
2013-08-02 14:30:00 -07:00
|
|
|
pub fn LLVMDIBuilderCreateLocalVariable(Builder: DIBuilderRef,
|
|
|
|
Tag: c_uint,
|
|
|
|
Scope: DIDescriptor,
|
|
|
|
Name: *c_char,
|
|
|
|
File: DIFile,
|
|
|
|
LineNo: c_uint,
|
|
|
|
Ty: DIType,
|
|
|
|
AlwaysPreserve: bool,
|
|
|
|
Flags: c_uint,
|
|
|
|
ArgNo: c_uint)
|
|
|
|
-> DIVariable;
|
|
|
|
|
|
|
|
pub fn LLVMDIBuilderCreateArrayType(Builder: DIBuilderRef,
|
|
|
|
Size: c_ulonglong,
|
|
|
|
AlignInBits: c_ulonglong,
|
|
|
|
Ty: DIType,
|
|
|
|
Subscripts: DIArray)
|
|
|
|
-> DIType;
|
|
|
|
|
|
|
|
pub fn LLVMDIBuilderCreateVectorType(Builder: DIBuilderRef,
|
|
|
|
Size: c_ulonglong,
|
|
|
|
AlignInBits: c_ulonglong,
|
|
|
|
Ty: DIType,
|
|
|
|
Subscripts: DIArray)
|
|
|
|
-> DIType;
|
|
|
|
|
|
|
|
pub fn LLVMDIBuilderGetOrCreateSubrange(Builder: DIBuilderRef,
|
|
|
|
Lo: c_longlong,
|
|
|
|
Count: c_longlong)
|
|
|
|
-> DISubrange;
|
|
|
|
|
|
|
|
pub fn LLVMDIBuilderGetOrCreateArray(Builder: DIBuilderRef,
|
|
|
|
Ptr: *DIDescriptor,
|
|
|
|
Count: c_uint)
|
|
|
|
-> DIArray;
|
|
|
|
|
|
|
|
pub fn LLVMDIBuilderInsertDeclareAtEnd(Builder: DIBuilderRef,
|
|
|
|
Val: ValueRef,
|
|
|
|
VarInfo: DIVariable,
|
|
|
|
InsertAtEnd: BasicBlockRef)
|
|
|
|
-> ValueRef;
|
2013-06-14 11:38:29 -07:00
|
|
|
|
2013-08-02 14:30:00 -07:00
|
|
|
pub fn LLVMDIBuilderInsertDeclareBefore(Builder: DIBuilderRef,
|
|
|
|
Val: ValueRef,
|
|
|
|
VarInfo: DIVariable,
|
|
|
|
InsertBefore: ValueRef)
|
|
|
|
-> ValueRef;
|
2013-06-14 11:38:29 -07:00
|
|
|
|
2013-08-02 14:30:00 -07:00
|
|
|
pub fn LLVMDIBuilderCreateEnumerator(Builder: DIBuilderRef,
|
|
|
|
Name: *c_char,
|
|
|
|
Val: c_ulonglong)
|
|
|
|
-> ValueRef;
|
2013-06-14 11:38:29 -07:00
|
|
|
|
2013-08-02 14:30:00 -07:00
|
|
|
pub fn LLVMDIBuilderCreateEnumerationType(Builder: DIBuilderRef,
|
|
|
|
Scope: ValueRef,
|
|
|
|
Name: *c_char,
|
|
|
|
File: ValueRef,
|
|
|
|
LineNumber: c_uint,
|
|
|
|
SizeInBits: c_ulonglong,
|
|
|
|
AlignInBits: c_ulonglong,
|
|
|
|
Elements: ValueRef,
|
|
|
|
ClassType: ValueRef)
|
|
|
|
-> ValueRef;
|
|
|
|
|
|
|
|
pub fn LLVMDIBuilderCreateUnionType(Builder: DIBuilderRef,
|
|
|
|
Scope: ValueRef,
|
|
|
|
Name: *c_char,
|
|
|
|
File: ValueRef,
|
|
|
|
LineNumber: c_uint,
|
|
|
|
SizeInBits: c_ulonglong,
|
|
|
|
AlignInBits: c_ulonglong,
|
|
|
|
Flags: c_uint,
|
|
|
|
Elements: ValueRef,
|
2014-01-02 15:20:43 +01:00
|
|
|
RunTimeLang: c_uint,
|
|
|
|
UniqueId: *c_char)
|
2013-08-02 14:30:00 -07:00
|
|
|
-> ValueRef;
|
2013-08-09 13:47:00 -07:00
|
|
|
|
|
|
|
pub fn LLVMSetUnnamedAddr(GlobalVar: ValueRef, UnnamedAddr: Bool);
|
2013-08-08 18:33:06 +02:00
|
|
|
|
|
|
|
pub fn LLVMDIBuilderCreateTemplateTypeParameter(Builder: DIBuilderRef,
|
|
|
|
Scope: ValueRef,
|
|
|
|
Name: *c_char,
|
|
|
|
Ty: ValueRef,
|
|
|
|
File: ValueRef,
|
|
|
|
LineNo: c_uint,
|
|
|
|
ColumnNo: c_uint)
|
|
|
|
-> ValueRef;
|
2013-08-22 20:58:42 -07:00
|
|
|
|
2013-08-23 18:45:02 +02:00
|
|
|
pub fn LLVMDIBuilderCreateOpDeref(IntType: TypeRef) -> ValueRef;
|
|
|
|
|
|
|
|
pub fn LLVMDIBuilderCreateOpPlus(IntType: TypeRef) -> ValueRef;
|
|
|
|
|
|
|
|
pub fn LLVMDIBuilderCreateComplexVariable(Builder: DIBuilderRef,
|
|
|
|
Tag: c_uint,
|
|
|
|
Scope: ValueRef,
|
|
|
|
Name: *c_char,
|
|
|
|
File: ValueRef,
|
|
|
|
LineNo: c_uint,
|
|
|
|
Ty: ValueRef,
|
|
|
|
AddrOps: *ValueRef,
|
|
|
|
AddrOpsCount: c_uint,
|
|
|
|
ArgNo: c_uint)
|
|
|
|
-> ValueRef;
|
|
|
|
|
2013-09-05 13:29:30 +02:00
|
|
|
pub fn LLVMDIBuilderCreateNameSpace(Builder: DIBuilderRef,
|
|
|
|
Scope: ValueRef,
|
|
|
|
Name: *c_char,
|
|
|
|
File: ValueRef,
|
|
|
|
LineNo: c_uint)
|
|
|
|
-> ValueRef;
|
|
|
|
|
2013-09-11 16:37:43 +02:00
|
|
|
pub fn LLVMDICompositeTypeSetTypeArray(CompositeType: ValueRef, TypeArray: ValueRef);
|
2013-10-11 19:56:11 -04:00
|
|
|
pub fn LLVMTypeToString(Type: TypeRef) -> *c_char;
|
2014-01-15 14:39:08 -05:00
|
|
|
pub fn LLVMValueToString(value_ref: ValueRef) -> *c_char;
|
2013-09-11 16:37:43 +02:00
|
|
|
|
2013-08-28 17:47:31 +02:00
|
|
|
pub fn LLVMIsAArgument(value_ref: ValueRef) -> ValueRef;
|
|
|
|
|
|
|
|
pub fn LLVMIsAAllocaInst(value_ref: ValueRef) -> ValueRef;
|
|
|
|
|
2013-08-22 20:58:42 -07:00
|
|
|
pub fn LLVMInitializeX86TargetInfo();
|
|
|
|
pub fn LLVMInitializeX86Target();
|
|
|
|
pub fn LLVMInitializeX86TargetMC();
|
|
|
|
pub fn LLVMInitializeX86AsmPrinter();
|
|
|
|
pub fn LLVMInitializeX86AsmParser();
|
|
|
|
pub fn LLVMInitializeARMTargetInfo();
|
|
|
|
pub fn LLVMInitializeARMTarget();
|
|
|
|
pub fn LLVMInitializeARMTargetMC();
|
|
|
|
pub fn LLVMInitializeARMAsmPrinter();
|
|
|
|
pub fn LLVMInitializeARMAsmParser();
|
|
|
|
pub fn LLVMInitializeMipsTargetInfo();
|
|
|
|
pub fn LLVMInitializeMipsTarget();
|
|
|
|
pub fn LLVMInitializeMipsTargetMC();
|
|
|
|
pub fn LLVMInitializeMipsAsmPrinter();
|
|
|
|
pub fn LLVMInitializeMipsAsmParser();
|
|
|
|
|
|
|
|
pub fn LLVMRustAddPass(PM: PassManagerRef, Pass: *c_char) -> bool;
|
|
|
|
pub fn LLVMRustCreateTargetMachine(Triple: *c_char,
|
|
|
|
CPU: *c_char,
|
|
|
|
Features: *c_char,
|
|
|
|
Model: CodeGenModel,
|
|
|
|
Reloc: RelocMode,
|
|
|
|
Level: CodeGenOptLevel,
|
2013-09-30 13:20:52 +08:00
|
|
|
EnableSegstk: bool,
|
2014-01-28 14:59:28 -05:00
|
|
|
UseSoftFP: bool,
|
rustc: Enable -f{function,data}-sections
The compiler has previously been producing binaries on the order of 1.8MB for
hello world programs "fn main() {}". This is largely a result of the compilation
model used by compiling entire libraries into a single object file and because
static linking is favored by default.
When linking, linkers will pull in the entire contents of an object file if any
symbol from the object file is used. This means that if any symbol from a rust
library is used, the entire library is pulled in unconditionally, regardless of
whether the library is used or not.
Traditional C/C++ projects do not normally encounter these large executable
problems because their archives (rust's rlibs) are composed of many objects.
Because of this, linkers can eliminate entire objects from being in the final
executable. With rustc, however, the linker does not have the opportunity to
leave out entire object files.
In order to get similar benefits from dead code stripping at link time, this
commit enables the -ffunction-sections and -fdata-sections flags in LLVM, as
well as passing --gc-sections to the linker *by default*. This means that each
function and each global will be placed into its own section, allowing the
linker to GC all unused functions and data symbols.
By enabling these flags, rust is able to generate much smaller binaries default.
On linux, a hello world binary went from 1.8MB to 597K (a 67% reduction in
size). The output size of dynamic libraries remained constant, but the output
size of rlibs increased, as seen below:
libarena - 2.27% bigger ( 292872 => 299508)
libcollections - 0.64% bigger ( 6765884 => 6809076)
libflate - 0.83% bigger ( 186516 => 188060)
libfourcc - 14.71% bigger ( 307290 => 352498)
libgetopts - 4.42% bigger ( 761468 => 795102)
libglob - 2.73% bigger ( 899932 => 924542)
libgreen - 9.63% bigger ( 1281718 => 1405124)
libhexfloat - 13.88% bigger ( 333738 => 380060)
liblibc - 10.79% bigger ( 551280 => 610736)
liblog - 10.93% bigger ( 218208 => 242060)
libnative - 8.26% bigger ( 1362096 => 1474658)
libnum - 2.34% bigger ( 2583400 => 2643916)
librand - 1.72% bigger ( 1608684 => 1636394)
libregex - 6.50% bigger ( 1747768 => 1861398)
librustc - 4.21% bigger (151820192 => 158218924)
librustdoc - 8.96% bigger ( 13142604 => 14320544)
librustuv - 4.13% bigger ( 4366896 => 4547304)
libsemver - 2.66% bigger ( 396166 => 406686)
libserialize - 1.91% bigger ( 6878396 => 7009822)
libstd - 3.59% bigger ( 39485286 => 40902218)
libsync - 3.95% bigger ( 1386390 => 1441204)
libsyntax - 4.96% bigger ( 35757202 => 37530798)
libterm - 13.99% bigger ( 924580 => 1053902)
libtest - 6.04% bigger ( 2455720 => 2604092)
libtime - 2.84% bigger ( 1075708 => 1106242)
liburl - 6.53% bigger ( 590458 => 629004)
libuuid - 4.63% bigger ( 326350 => 341466)
libworkcache - 8.45% bigger ( 1230702 => 1334750)
This increase in size is a result of encoding many more section names into each
object file (rlib). These increases are moderate enough that this change seems
worthwhile to me, due to the drastic improvements seen in the final artifacts.
The overall increase of the stage2 target folder (not the size of an install)
went from 337MB to 348MB (3% increase).
Additionally, linking is generally slower when executed with all these new
sections plus the --gc-sections flag. The stage0 compiler takes 1.4s to link the
`rustc` binary, where the stage1 compiler takes 1.9s to link the binary. Three
megabytes are shaved off the binary. I found this increase in link time to be
acceptable relative to the benefits of code size gained.
This commit only enables --gc-sections for *executables*, not dynamic libraries.
LLVM does all the heavy lifting when producing an object file for a dynamic
library, so there is little else for the linker to do (remember that we only
have one object file).
I conducted similar experiments by putting a *module's* functions and data
symbols into its own section (granularity moved to a module level instead of a
function/static level). The size benefits of a hello world were seen to be on
the order of 400K rather than 1.2MB. It seemed that enough benefit was gained
using ffunction-sections that this route was less desirable, despite the lesser
increases in binary rlib size.
2014-04-28 17:17:18 -07:00
|
|
|
NoFramePointerElim: bool,
|
|
|
|
FunctionSections: bool,
|
|
|
|
DataSections: bool) -> TargetMachineRef;
|
2013-08-22 20:58:42 -07:00
|
|
|
pub fn LLVMRustDisposeTargetMachine(T: TargetMachineRef);
|
|
|
|
pub fn LLVMRustAddAnalysisPasses(T: TargetMachineRef,
|
|
|
|
PM: PassManagerRef,
|
|
|
|
M: ModuleRef);
|
|
|
|
pub fn LLVMRustAddBuilderLibraryInfo(PMB: PassManagerBuilderRef,
|
2014-05-14 11:24:12 -07:00
|
|
|
M: ModuleRef,
|
|
|
|
DisableSimplifyLibCalls: bool);
|
|
|
|
pub fn LLVMRustAddLibraryInfo(PM: PassManagerRef, M: ModuleRef,
|
|
|
|
DisableSimplifyLibCalls: bool);
|
2013-08-22 20:58:42 -07:00
|
|
|
pub fn LLVMRustRunFunctionPassManager(PM: PassManagerRef, M: ModuleRef);
|
|
|
|
pub fn LLVMRustWriteOutputFile(T: TargetMachineRef,
|
|
|
|
PM: PassManagerRef,
|
|
|
|
M: ModuleRef,
|
|
|
|
Output: *c_char,
|
|
|
|
FileType: FileType) -> bool;
|
|
|
|
pub fn LLVMRustPrintModule(PM: PassManagerRef,
|
|
|
|
M: ModuleRef,
|
|
|
|
Output: *c_char);
|
2013-08-30 17:56:04 -07:00
|
|
|
pub fn LLVMRustSetLLVMOptions(Argc: c_int, Argv: **c_char);
|
2013-08-22 20:58:42 -07:00
|
|
|
pub fn LLVMRustPrintPasses();
|
|
|
|
pub fn LLVMRustSetNormalizedTarget(M: ModuleRef, triple: *c_char);
|
|
|
|
pub fn LLVMRustAddAlwaysInlinePass(P: PassManagerBuilderRef,
|
|
|
|
AddLifetimes: bool);
|
Implement LTO
This commit implements LTO for rust leveraging LLVM's passes. What this means
is:
* When compiling an rlib, in addition to insdering foo.o into the archive, also
insert foo.bc (the LLVM bytecode) of the optimized module.
* When the compiler detects the -Z lto option, it will attempt to perform LTO on
a staticlib or binary output. The compiler will emit an error if a dylib or
rlib output is being generated.
* The actual act of performing LTO is as follows:
1. Force all upstream libraries to have an rlib version available.
2. Load the bytecode of each upstream library from the rlib.
3. Link all this bytecode into the current LLVM module (just using llvm
apis)
4. Run an internalization pass which internalizes all symbols except those
found reachable for the local crate of compilation.
5. Run the LLVM LTO pass manager over this entire module
6a. If assembling an archive, then add all upstream rlibs into the output
archive. This ignores all of the object/bitcode/metadata files rust
generated and placed inside the rlibs.
6b. If linking a binary, create copies of all upstream rlibs, remove the
rust-generated object-file, and then link everything as usual.
As I have explained in #10741, this process is excruciatingly slow, so this is
*not* turned on by default, and it is also why I have decided to hide it behind
a -Z flag for now. The good news is that the binary sizes are about as small as
they can be as a result of LTO, so it's definitely working.
Closes #10741
Closes #10740
2013-12-02 23:19:29 -08:00
|
|
|
pub fn LLVMRustLinkInExternalBitcode(M: ModuleRef,
|
|
|
|
bc: *c_char,
|
|
|
|
len: size_t) -> bool;
|
|
|
|
pub fn LLVMRustRunRestrictionPass(M: ModuleRef,
|
|
|
|
syms: **c_char,
|
|
|
|
len: size_t);
|
2013-12-10 23:27:15 -08:00
|
|
|
pub fn LLVMRustMarkAllFunctionsNounwind(M: ModuleRef);
|
2013-12-16 20:58:21 -08:00
|
|
|
|
|
|
|
pub fn LLVMRustOpenArchive(path: *c_char) -> ArchiveRef;
|
|
|
|
pub fn LLVMRustArchiveReadSection(AR: ArchiveRef, name: *c_char,
|
|
|
|
out_len: *mut size_t) -> *c_char;
|
|
|
|
pub fn LLVMRustDestroyArchive(AR: ArchiveRef);
|
2014-01-27 12:45:48 -08:00
|
|
|
|
|
|
|
pub fn LLVMRustSetDLLExportStorageClass(V: ValueRef);
|
2014-03-05 15:14:16 -08:00
|
|
|
pub fn LLVMVersionMinor() -> c_int;
|
2014-04-03 10:45:36 -07:00
|
|
|
|
|
|
|
pub fn LLVMRustGetSectionName(SI: SectionIteratorRef,
|
|
|
|
data: *mut *c_char) -> c_int;
|
2013-07-02 18:10:24 +02:00
|
|
|
}
|
|
|
|
}
|
2011-03-25 18:44:52 -07:00
|
|
|
|
2014-02-15 16:15:03 -05:00
|
|
|
pub fn SetInstructionCallConv(instr: ValueRef, cc: CallConv) {
|
2013-01-10 21:23:07 -08:00
|
|
|
unsafe {
|
2014-02-15 16:15:03 -05:00
|
|
|
llvm::LLVMSetInstructionCallConv(instr, cc as c_uint);
|
2013-01-10 21:23:07 -08:00
|
|
|
}
|
2012-02-01 11:04:56 +01:00
|
|
|
}
|
2014-02-15 16:15:03 -05:00
|
|
|
pub fn SetFunctionCallConv(fn_: ValueRef, cc: CallConv) {
|
2013-01-10 21:23:07 -08:00
|
|
|
unsafe {
|
2014-02-15 16:15:03 -05:00
|
|
|
llvm::LLVMSetFunctionCallConv(fn_, cc as c_uint);
|
2013-01-10 21:23:07 -08:00
|
|
|
}
|
2012-02-01 11:04:56 +01:00
|
|
|
}
|
2014-02-15 16:15:03 -05:00
|
|
|
pub fn SetLinkage(global: ValueRef, link: Linkage) {
|
2013-01-10 21:23:07 -08:00
|
|
|
unsafe {
|
2014-02-15 16:15:03 -05:00
|
|
|
llvm::LLVMSetLinkage(global, link as c_uint);
|
2013-01-10 21:23:07 -08:00
|
|
|
}
|
2012-02-01 11:04:56 +01:00
|
|
|
}
|
|
|
|
|
2014-02-15 16:15:03 -05:00
|
|
|
pub fn SetUnnamedAddr(global: ValueRef, unnamed: bool) {
|
2013-08-09 13:47:00 -07:00
|
|
|
unsafe {
|
2014-02-15 16:15:03 -05:00
|
|
|
llvm::LLVMSetUnnamedAddr(global, unnamed as Bool);
|
2013-08-09 13:47:00 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-11-06 00:38:08 -05:00
|
|
|
pub fn set_thread_local(global: ValueRef, is_thread_local: bool) {
|
|
|
|
unsafe {
|
|
|
|
llvm::LLVMSetThreadLocal(global, is_thread_local as Bool);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-02-15 16:15:03 -05:00
|
|
|
pub fn ConstICmp(pred: IntPredicate, v1: ValueRef, v2: ValueRef) -> ValueRef {
|
2013-05-19 20:18:56 -04:00
|
|
|
unsafe {
|
2014-02-15 16:15:03 -05:00
|
|
|
llvm::LLVMConstICmp(pred as c_ushort, v1, v2)
|
2013-05-19 20:18:56 -04:00
|
|
|
}
|
|
|
|
}
|
2014-02-15 16:15:03 -05:00
|
|
|
pub fn ConstFCmp(pred: RealPredicate, v1: ValueRef, v2: ValueRef) -> ValueRef {
|
2013-05-19 20:18:56 -04:00
|
|
|
unsafe {
|
2014-02-15 16:15:03 -05:00
|
|
|
llvm::LLVMConstFCmp(pred as c_ushort, v1, v2)
|
2013-05-19 20:18:56 -04:00
|
|
|
}
|
|
|
|
}
|
2013-05-25 21:26:08 -05:00
|
|
|
|
2014-02-15 16:15:03 -05:00
|
|
|
pub fn SetFunctionAttribute(fn_: ValueRef, attr: Attribute) {
|
2013-05-25 21:26:08 -05:00
|
|
|
unsafe {
|
2014-05-21 15:07:48 -04:00
|
|
|
llvm::LLVMAddFunctionAttribute(fn_, FunctionIndex as c_uint, attr as uint64_t)
|
2013-08-02 00:55:49 -07:00
|
|
|
}
|
2013-08-01 15:47:09 -07:00
|
|
|
}
|
2010-12-01 19:03:47 -08:00
|
|
|
/* Memory-managed object interface to type handles. */
|
|
|
|
|
2013-02-19 02:40:42 -05:00
|
|
|
pub struct TypeNames {
|
2014-05-22 16:57:53 -07:00
|
|
|
named_types: RefCell<HashMap<String, TypeRef>>,
|
2013-02-19 02:40:42 -05:00
|
|
|
}
|
2011-02-17 18:16:51 -08:00
|
|
|
|
2013-06-15 14:31:52 +12:00
|
|
|
impl TypeNames {
|
|
|
|
pub fn new() -> TypeNames {
|
|
|
|
TypeNames {
|
2013-12-19 16:22:26 -08:00
|
|
|
named_types: RefCell::new(HashMap::new())
|
2013-06-15 14:31:52 +12:00
|
|
|
}
|
2013-02-19 02:40:42 -05:00
|
|
|
}
|
2011-02-17 18:16:51 -08:00
|
|
|
|
2013-12-19 16:22:26 -08:00
|
|
|
pub fn associate_type(&self, s: &str, t: &Type) {
|
2014-05-09 18:45:36 -07:00
|
|
|
assert!(self.named_types.borrow_mut().insert(s.to_strbuf(),
|
|
|
|
t.to_ref()));
|
2013-06-15 14:31:52 +12:00
|
|
|
}
|
2010-12-23 17:05:27 -08:00
|
|
|
|
2013-06-15 22:16:47 +12:00
|
|
|
pub fn find_type(&self, s: &str) -> Option<Type> {
|
2014-03-20 19:49:20 -07:00
|
|
|
self.named_types.borrow().find_equiv(&s).map(|x| Type::from_ref(*x))
|
2013-06-15 14:31:52 +12:00
|
|
|
}
|
2010-09-24 14:56:04 -07:00
|
|
|
|
2014-05-22 16:57:53 -07:00
|
|
|
pub fn type_to_str(&self, ty: Type) -> String {
|
2013-06-15 14:31:52 +12:00
|
|
|
unsafe {
|
2013-10-11 19:56:11 -04:00
|
|
|
let s = llvm::LLVMTypeToString(ty.to_ref());
|
|
|
|
let ret = from_c_str(s);
|
2014-01-21 09:31:32 -05:00
|
|
|
free(s as *mut c_void);
|
2014-05-09 18:45:36 -07:00
|
|
|
ret.to_strbuf()
|
2013-01-10 21:23:07 -08:00
|
|
|
}
|
2010-09-24 14:56:04 -07:00
|
|
|
}
|
2013-06-15 15:16:03 +12:00
|
|
|
|
2014-05-22 16:57:53 -07:00
|
|
|
pub fn types_to_str(&self, tys: &[Type]) -> String {
|
|
|
|
let strs: Vec<String> = tys.iter().map(|t| self.type_to_str(*t)).collect();
|
2014-05-09 18:45:36 -07:00
|
|
|
format_strbuf!("[{}]", strs.connect(",").to_strbuf())
|
2013-05-21 15:25:44 -04:00
|
|
|
}
|
|
|
|
|
2014-05-22 16:57:53 -07:00
|
|
|
pub fn val_to_str(&self, val: ValueRef) -> String {
|
2013-06-15 15:16:03 +12:00
|
|
|
unsafe {
|
2014-01-15 14:39:08 -05:00
|
|
|
let s = llvm::LLVMValueToString(val);
|
|
|
|
let ret = from_c_str(s);
|
2014-01-21 09:31:32 -05:00
|
|
|
free(s as *mut c_void);
|
2014-05-09 18:45:36 -07:00
|
|
|
ret.to_strbuf()
|
2013-06-15 15:16:03 +12:00
|
|
|
}
|
|
|
|
}
|
2010-09-24 14:56:04 -07:00
|
|
|
}
|
|
|
|
|
2010-12-03 16:55:59 -08:00
|
|
|
/* Memory-managed interface to target data. */
|
|
|
|
|
2014-04-22 03:53:51 +03:00
|
|
|
pub struct TargetData {
|
|
|
|
pub lltd: TargetDataRef
|
2013-02-27 19:13:53 -05:00
|
|
|
}
|
|
|
|
|
2014-04-22 03:53:51 +03:00
|
|
|
impl Drop for TargetData {
|
2013-09-16 21:18:07 -04:00
|
|
|
fn drop(&mut self) {
|
2013-01-10 21:23:07 -08:00
|
|
|
unsafe {
|
2014-04-22 03:53:51 +03:00
|
|
|
llvm::LLVMDisposeTargetData(self.lltd);
|
2013-01-10 21:23:07 -08:00
|
|
|
}
|
|
|
|
}
|
2010-12-03 16:55:59 -08:00
|
|
|
}
|
|
|
|
|
2013-03-20 01:17:42 -04:00
|
|
|
pub fn mk_target_data(string_rep: &str) -> TargetData {
|
2013-02-19 02:40:42 -05:00
|
|
|
TargetData {
|
2014-04-22 03:53:51 +03:00
|
|
|
lltd: string_rep.with_c_str(|buf| {
|
|
|
|
unsafe { llvm::LLVMCreateTargetData(buf) }
|
|
|
|
})
|
2013-02-19 02:40:42 -05:00
|
|
|
}
|
2010-12-03 16:55:59 -08:00
|
|
|
}
|
|
|
|
|
2011-03-15 12:27:15 -07:00
|
|
|
/* Memory-managed interface to object files. */
|
|
|
|
|
Add generation of static libraries to rustc
This commit implements the support necessary for generating both intermediate
and result static rust libraries. This is an implementation of my thoughts in
https://mail.mozilla.org/pipermail/rust-dev/2013-November/006686.html.
When compiling a library, we still retain the "lib" option, although now there
are "rlib", "staticlib", and "dylib" as options for crate_type (and these are
stackable). The idea of "lib" is to generate the "compiler default" instead of
having too choose (although all are interchangeable). For now I have left the
"complier default" to be a dynamic library for size reasons.
Of the rust libraries, lib{std,extra,rustuv} will bootstrap with an
rlib/dylib pair, but lib{rustc,syntax,rustdoc,rustpkg} will only be built as a
dynamic object. I chose this for size reasons, but also because you're probably
not going to be embedding the rustc compiler anywhere any time soon.
Other than the options outlined above, there are a few defaults/preferences that
are now opinionated in the compiler:
* If both a .dylib and .rlib are found for a rust library, the compiler will
prefer the .rlib variant. This is overridable via the -Z prefer-dynamic option
* If generating a "lib", the compiler will generate a dynamic library. This is
overridable by explicitly saying what flavor you'd like (rlib, staticlib,
dylib).
* If no options are passed to the command line, and no crate_type is found in
the destination crate, then an executable is generated
With this change, you can successfully build a rust program with 0 dynamic
dependencies on rust libraries. There is still a dynamic dependency on
librustrt, but I plan on removing that in a subsequent commit.
This change includes no tests just yet. Our current testing
infrastructure/harnesses aren't very amenable to doing flavorful things with
linking, so I'm planning on adding a new mode of testing which I believe belongs
as a separate commit.
Closes #552
2013-11-15 14:03:29 -08:00
|
|
|
pub struct ObjectFile {
|
2014-03-28 10:05:27 -07:00
|
|
|
pub llof: ObjectFileRef,
|
2013-02-27 19:13:53 -05:00
|
|
|
}
|
|
|
|
|
Add generation of static libraries to rustc
This commit implements the support necessary for generating both intermediate
and result static rust libraries. This is an implementation of my thoughts in
https://mail.mozilla.org/pipermail/rust-dev/2013-November/006686.html.
When compiling a library, we still retain the "lib" option, although now there
are "rlib", "staticlib", and "dylib" as options for crate_type (and these are
stackable). The idea of "lib" is to generate the "compiler default" instead of
having too choose (although all are interchangeable). For now I have left the
"complier default" to be a dynamic library for size reasons.
Of the rust libraries, lib{std,extra,rustuv} will bootstrap with an
rlib/dylib pair, but lib{rustc,syntax,rustdoc,rustpkg} will only be built as a
dynamic object. I chose this for size reasons, but also because you're probably
not going to be embedding the rustc compiler anywhere any time soon.
Other than the options outlined above, there are a few defaults/preferences that
are now opinionated in the compiler:
* If both a .dylib and .rlib are found for a rust library, the compiler will
prefer the .rlib variant. This is overridable via the -Z prefer-dynamic option
* If generating a "lib", the compiler will generate a dynamic library. This is
overridable by explicitly saying what flavor you'd like (rlib, staticlib,
dylib).
* If no options are passed to the command line, and no crate_type is found in
the destination crate, then an executable is generated
With this change, you can successfully build a rust program with 0 dynamic
dependencies on rust libraries. There is still a dynamic dependency on
librustrt, but I plan on removing that in a subsequent commit.
This change includes no tests just yet. Our current testing
infrastructure/harnesses aren't very amenable to doing flavorful things with
linking, so I'm planning on adding a new mode of testing which I believe belongs
as a separate commit.
Closes #552
2013-11-15 14:03:29 -08:00
|
|
|
impl ObjectFile {
|
|
|
|
// This will take ownership of llmb
|
|
|
|
pub fn new(llmb: MemoryBufferRef) -> Option<ObjectFile> {
|
2013-01-10 21:23:07 -08:00
|
|
|
unsafe {
|
Add generation of static libraries to rustc
This commit implements the support necessary for generating both intermediate
and result static rust libraries. This is an implementation of my thoughts in
https://mail.mozilla.org/pipermail/rust-dev/2013-November/006686.html.
When compiling a library, we still retain the "lib" option, although now there
are "rlib", "staticlib", and "dylib" as options for crate_type (and these are
stackable). The idea of "lib" is to generate the "compiler default" instead of
having too choose (although all are interchangeable). For now I have left the
"complier default" to be a dynamic library for size reasons.
Of the rust libraries, lib{std,extra,rustuv} will bootstrap with an
rlib/dylib pair, but lib{rustc,syntax,rustdoc,rustpkg} will only be built as a
dynamic object. I chose this for size reasons, but also because you're probably
not going to be embedding the rustc compiler anywhere any time soon.
Other than the options outlined above, there are a few defaults/preferences that
are now opinionated in the compiler:
* If both a .dylib and .rlib are found for a rust library, the compiler will
prefer the .rlib variant. This is overridable via the -Z prefer-dynamic option
* If generating a "lib", the compiler will generate a dynamic library. This is
overridable by explicitly saying what flavor you'd like (rlib, staticlib,
dylib).
* If no options are passed to the command line, and no crate_type is found in
the destination crate, then an executable is generated
With this change, you can successfully build a rust program with 0 dynamic
dependencies on rust libraries. There is still a dynamic dependency on
librustrt, but I plan on removing that in a subsequent commit.
This change includes no tests just yet. Our current testing
infrastructure/harnesses aren't very amenable to doing flavorful things with
linking, so I'm planning on adding a new mode of testing which I believe belongs
as a separate commit.
Closes #552
2013-11-15 14:03:29 -08:00
|
|
|
let llof = llvm::LLVMCreateObjectFile(llmb);
|
|
|
|
if llof as int == 0 {
|
2014-01-01 13:03:26 -08:00
|
|
|
// LLVMCreateObjectFile took ownership of llmb
|
Add generation of static libraries to rustc
This commit implements the support necessary for generating both intermediate
and result static rust libraries. This is an implementation of my thoughts in
https://mail.mozilla.org/pipermail/rust-dev/2013-November/006686.html.
When compiling a library, we still retain the "lib" option, although now there
are "rlib", "staticlib", and "dylib" as options for crate_type (and these are
stackable). The idea of "lib" is to generate the "compiler default" instead of
having too choose (although all are interchangeable). For now I have left the
"complier default" to be a dynamic library for size reasons.
Of the rust libraries, lib{std,extra,rustuv} will bootstrap with an
rlib/dylib pair, but lib{rustc,syntax,rustdoc,rustpkg} will only be built as a
dynamic object. I chose this for size reasons, but also because you're probably
not going to be embedding the rustc compiler anywhere any time soon.
Other than the options outlined above, there are a few defaults/preferences that
are now opinionated in the compiler:
* If both a .dylib and .rlib are found for a rust library, the compiler will
prefer the .rlib variant. This is overridable via the -Z prefer-dynamic option
* If generating a "lib", the compiler will generate a dynamic library. This is
overridable by explicitly saying what flavor you'd like (rlib, staticlib,
dylib).
* If no options are passed to the command line, and no crate_type is found in
the destination crate, then an executable is generated
With this change, you can successfully build a rust program with 0 dynamic
dependencies on rust libraries. There is still a dynamic dependency on
librustrt, but I plan on removing that in a subsequent commit.
This change includes no tests just yet. Our current testing
infrastructure/harnesses aren't very amenable to doing flavorful things with
linking, so I'm planning on adding a new mode of testing which I believe belongs
as a separate commit.
Closes #552
2013-11-15 14:03:29 -08:00
|
|
|
return None
|
|
|
|
}
|
|
|
|
|
|
|
|
Some(ObjectFile {
|
|
|
|
llof: llof,
|
|
|
|
})
|
2013-01-10 21:23:07 -08:00
|
|
|
}
|
|
|
|
}
|
2011-03-15 12:27:15 -07:00
|
|
|
}
|
|
|
|
|
Add generation of static libraries to rustc
This commit implements the support necessary for generating both intermediate
and result static rust libraries. This is an implementation of my thoughts in
https://mail.mozilla.org/pipermail/rust-dev/2013-November/006686.html.
When compiling a library, we still retain the "lib" option, although now there
are "rlib", "staticlib", and "dylib" as options for crate_type (and these are
stackable). The idea of "lib" is to generate the "compiler default" instead of
having too choose (although all are interchangeable). For now I have left the
"complier default" to be a dynamic library for size reasons.
Of the rust libraries, lib{std,extra,rustuv} will bootstrap with an
rlib/dylib pair, but lib{rustc,syntax,rustdoc,rustpkg} will only be built as a
dynamic object. I chose this for size reasons, but also because you're probably
not going to be embedding the rustc compiler anywhere any time soon.
Other than the options outlined above, there are a few defaults/preferences that
are now opinionated in the compiler:
* If both a .dylib and .rlib are found for a rust library, the compiler will
prefer the .rlib variant. This is overridable via the -Z prefer-dynamic option
* If generating a "lib", the compiler will generate a dynamic library. This is
overridable by explicitly saying what flavor you'd like (rlib, staticlib,
dylib).
* If no options are passed to the command line, and no crate_type is found in
the destination crate, then an executable is generated
With this change, you can successfully build a rust program with 0 dynamic
dependencies on rust libraries. There is still a dynamic dependency on
librustrt, but I plan on removing that in a subsequent commit.
This change includes no tests just yet. Our current testing
infrastructure/harnesses aren't very amenable to doing flavorful things with
linking, so I'm planning on adding a new mode of testing which I believe belongs
as a separate commit.
Closes #552
2013-11-15 14:03:29 -08:00
|
|
|
impl Drop for ObjectFile {
|
|
|
|
fn drop(&mut self) {
|
|
|
|
unsafe {
|
|
|
|
llvm::LLVMDisposeObjectFile(self.llof);
|
|
|
|
}
|
2013-01-10 21:23:07 -08:00
|
|
|
}
|
2011-03-15 12:27:15 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Memory-managed interface to section iterators. */
|
|
|
|
|
2014-04-22 03:53:51 +03:00
|
|
|
pub struct SectionIter {
|
|
|
|
pub llsi: SectionIteratorRef
|
2013-02-27 19:13:53 -05:00
|
|
|
}
|
|
|
|
|
2014-04-22 03:53:51 +03:00
|
|
|
impl Drop for SectionIter {
|
2013-09-16 21:18:07 -04:00
|
|
|
fn drop(&mut self) {
|
2013-01-10 21:23:07 -08:00
|
|
|
unsafe {
|
2014-04-22 03:53:51 +03:00
|
|
|
llvm::LLVMDisposeSectionIterator(self.llsi);
|
2013-01-10 21:23:07 -08:00
|
|
|
}
|
|
|
|
}
|
2011-03-15 12:27:15 -07:00
|
|
|
}
|
|
|
|
|
2013-02-19 02:40:42 -05:00
|
|
|
pub fn mk_section_iter(llof: ObjectFileRef) -> SectionIter {
|
2013-01-10 21:23:07 -08:00
|
|
|
unsafe {
|
2013-02-19 02:40:42 -05:00
|
|
|
SectionIter {
|
2014-04-22 03:53:51 +03:00
|
|
|
llsi: llvm::LLVMGetSections(llof)
|
2013-02-19 02:40:42 -05:00
|
|
|
}
|
2013-01-10 21:23:07 -08:00
|
|
|
}
|
2011-03-15 12:27:15 -07:00
|
|
|
}
|