about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2014-07-15 04:16:20 +0000
committerbors <bors@rust-lang.org>2014-07-15 04:16:20 +0000
commit2eadfe42e58de0263286195e7560cb85337a3847 (patch)
treefad27715d3341c18b4707d83942143a71720bbf7 /src
parentb1ae09e52a712f34de7823de55aaa6ef142c6fe9 (diff)
parenta008fc84aaf429a1966c422297302cf809df796d (diff)
downloadrust-2eadfe42e58de0263286195e7560cb85337a3847.tar.gz
rust-2eadfe42e58de0263286195e7560cb85337a3847.zip
auto merge of #15511 : brson/rust/extract-rustc-back, r=alexcrichton
This was my weekend project, to start breaking up rustc. It first pulls out LLVM into `rustc_llvm`, then parts of `rustc::back` and `rustc::util` to `rustc_back`. The immediate intent is just to reduce the size of rustc, to reduce memory pressure when building rustc, but this is also a good starting point for further refactoring.

The `rustc_back` crate is definitely misnamed (`rustc::back` was never a very cohesive module anyway) - it's mostly just somewhere to stuff parts of rustc that don't have many deps. Right now it's main dep is `syntax`; it has no dep on `rustc_llvm`.

Some next steps might be to split `rustc_back` into `rustc_util` (with no `syntax` dep), and `rustc_syntax_util` (with a syntax dep); move the rest of `rustc::util` into `rustc_syntax_util`; move all of `rustc::front` to a new crate, `rustc_front`. At that point the refactoring necessary to keep extracting crates will get harder.
Diffstat (limited to 'src')
-rw-r--r--src/librustc/back/link.rs124
-rw-r--r--src/librustc/back/lto.rs7
-rw-r--r--src/librustc/driver/config.rs2
-rw-r--r--src/librustc/driver/driver.rs2
-rw-r--r--src/librustc/driver/mod.rs2
-rw-r--r--src/librustc/lib.rs42
-rw-r--r--src/librustc/lib/llvm.rs1983
-rw-r--r--src/librustc/lib/llvmdeps.rs64
-rw-r--r--src/librustc/metadata/loader.rs6
-rw-r--r--src/librustc/middle/trans/_match.rs3
-rw-r--r--src/librustc/middle/trans/adt.rs2
-rw-r--r--src/librustc/middle/trans/asm.rs6
-rw-r--r--src/librustc/middle/trans/base.rs160
-rw-r--r--src/librustc/middle/trans/basic_block.rs3
-rw-r--r--src/librustc/middle/trans/build.rs21
-rw-r--r--src/librustc/middle/trans/builder.rs29
-rw-r--r--src/librustc/middle/trans/cabi.rs2
-rw-r--r--src/librustc/middle/trans/cabi_arm.rs5
-rw-r--r--src/librustc/middle/trans/cabi_mips.rs5
-rw-r--r--src/librustc/middle/trans/cabi_x86.rs2
-rw-r--r--src/librustc/middle/trans/cabi_x86_64.rs7
-rw-r--r--src/librustc/middle/trans/callee.rs4
-rw-r--r--src/librustc/middle/trans/cleanup.rs2
-rw-r--r--src/librustc/middle/trans/closure.rs2
-rw-r--r--src/librustc/middle/trans/common.rs11
-rw-r--r--src/librustc/middle/trans/consts.rs5
-rw-r--r--src/librustc/middle/trans/context.rs9
-rw-r--r--src/librustc/middle/trans/controlflow.rs2
-rw-r--r--src/librustc/middle/trans/datum.rs2
-rw-r--r--src/librustc/middle/trans/debuginfo.rs6
-rw-r--r--src/librustc/middle/trans/expr.rs6
-rw-r--r--src/librustc/middle/trans/foreign.rs57
-rw-r--r--src/librustc/middle/trans/glue.rs8
-rw-r--r--src/librustc/middle/trans/inline.rs2
-rw-r--r--src/librustc/middle/trans/intrinsic.rs52
-rw-r--r--src/librustc/middle/trans/llrepr.rs2
-rw-r--r--src/librustc/middle/trans/machine.rs6
-rw-r--r--src/librustc/middle/trans/meth.rs9
-rw-r--r--src/librustc/middle/trans/monomorphize.rs2
-rw-r--r--src/librustc/middle/trans/reflect.rs3
-rw-r--r--src/librustc/middle/trans/tvec.rs8
-rw-r--r--src/librustc/middle/trans/type_.rs57
-rw-r--r--src/librustc/middle/trans/value.rs3
-rw-r--r--src/librustc_back/abi.rs (renamed from src/librustc/back/abi.rs)0
-rw-r--r--src/librustc_back/archive.rs (renamed from src/librustc/back/archive.rs)140
-rw-r--r--src/librustc_back/arm.rs (renamed from src/librustc/back/arm.rs)2
-rw-r--r--src/librustc_back/fs.rs (renamed from src/librustc/util/fs.rs)0
-rw-r--r--src/librustc_back/lib.rs56
-rw-r--r--src/librustc_back/mips.rs (renamed from src/librustc/back/mips.rs)2
-rw-r--r--src/librustc_back/mipsel.rs (renamed from src/librustc/back/mipsel.rs)2
-rw-r--r--src/librustc_back/rpath.rs (renamed from src/librustc/back/rpath.rs)142
-rw-r--r--src/librustc_back/sha2.rs (renamed from src/librustc/util/sha2.rs)2
-rw-r--r--src/librustc_back/svh.rs (renamed from src/librustc/back/svh.rs)6
-rw-r--r--src/librustc_back/target_strs.rs (renamed from src/librustc/back/target_strs.rs)0
-rw-r--r--src/librustc_back/x86.rs (renamed from src/librustc/back/x86.rs)2
-rw-r--r--src/librustc_back/x86_64.rs (renamed from src/librustc/back/x86_64.rs)2
-rw-r--r--src/librustc_llvm/archive_ro.rs68
-rw-r--r--src/librustc_llvm/lib.rs2003
58 files changed, 2709 insertions, 2453 deletions
diff --git a/src/librustc/back/link.rs b/src/librustc/back/link.rs
index a1df360a11b..cad164c9e20 100644
--- a/src/librustc/back/link.rs
+++ b/src/librustc/back/link.rs
@@ -8,16 +8,16 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-use back::archive::{Archive, METADATA_FILENAME};
-use back::rpath;
-use back::svh::Svh;
+use super::archive::{Archive, ArchiveConfig, METADATA_FILENAME};
+use super::rpath;
+use super::rpath::RPathConfig;
+use super::svh::Svh;
 use driver::driver::{CrateTranslation, OutputFilenames, Input, FileInput};
 use driver::config::NoDebugInfo;
 use driver::session::Session;
 use driver::config;
-use lib::llvm::llvm;
-use lib::llvm::ModuleRef;
-use lib;
+use llvm;
+use llvm::ModuleRef;
 use metadata::common::LinkMeta;
 use metadata::{encoder, cstore, filesearch, csearch, loader, creader};
 use middle::trans::context::CrateContext;
@@ -29,6 +29,7 @@ use util::sha2::{Digest, Sha256};
 
 use std::c_str::{ToCStr, CString};
 use std::char;
+use std::collections::HashSet;
 use std::io::{fs, TempDir, Command};
 use std::io;
 use std::ptr;
@@ -70,11 +71,11 @@ pub fn llvm_err(sess: &Session, msg: String) -> ! {
 
 pub fn write_output_file(
         sess: &Session,
-        target: lib::llvm::TargetMachineRef,
-        pm: lib::llvm::PassManagerRef,
+        target: llvm::TargetMachineRef,
+        pm: llvm::PassManagerRef,
         m: ModuleRef,
         output: &Path,
-        file_type: lib::llvm::FileType) {
+        file_type: llvm::FileType) {
     unsafe {
         output.with_c_str(|output| {
             let result = llvm::LLVMRustWriteOutputFile(
@@ -88,18 +89,17 @@ pub fn write_output_file(
 
 pub mod write {
 
-    use back::lto;
-    use back::link::{write_output_file, OutputType};
-    use back::link::{OutputTypeAssembly, OutputTypeBitcode};
-    use back::link::{OutputTypeExe, OutputTypeLlvmAssembly};
-    use back::link::{OutputTypeObject};
+    use super::super::lto;
+    use super::{write_output_file, OutputType};
+    use super::{OutputTypeAssembly, OutputTypeBitcode};
+    use super::{OutputTypeExe, OutputTypeLlvmAssembly};
+    use super::{OutputTypeObject};
     use driver::driver::{CrateTranslation, OutputFilenames};
     use driver::config::NoDebugInfo;
     use driver::session::Session;
     use driver::config;
-    use lib::llvm::llvm;
-    use lib::llvm::{ModuleRef, TargetMachineRef, PassManagerRef};
-    use lib;
+    use llvm;
+    use llvm::{ModuleRef, TargetMachineRef, PassManagerRef};
     use util::common::time;
     use syntax::abi;
 
@@ -152,10 +152,10 @@ pub mod write {
             }
 
             let opt_level = match sess.opts.optimize {
-              config::No => lib::llvm::CodeGenLevelNone,
-              config::Less => lib::llvm::CodeGenLevelLess,
-              config::Default => lib::llvm::CodeGenLevelDefault,
-              config::Aggressive => lib::llvm::CodeGenLevelAggressive,
+              config::No => llvm::CodeGenLevelNone,
+              config::Less => llvm::CodeGenLevelLess,
+              config::Default => llvm::CodeGenLevelDefault,
+              config::Aggressive => llvm::CodeGenLevelAggressive,
             };
             let use_softfp = sess.opts.cg.soft_float;
 
@@ -172,10 +172,10 @@ pub mod write {
             let fdata_sections = ffunction_sections;
 
             let reloc_model = match sess.opts.cg.relocation_model.as_slice() {
-                "pic" => lib::llvm::RelocPIC,
-                "static" => lib::llvm::RelocStatic,
-                "default" => lib::llvm::RelocDefault,
-                "dynamic-no-pic" => lib::llvm::RelocDynamicNoPic,
+                "pic" => llvm::RelocPIC,
+                "static" => llvm::RelocStatic,
+                "default" => llvm::RelocDefault,
+                "dynamic-no-pic" => llvm::RelocDynamicNoPic,
                 _ => {
                     sess.err(format!("{} is not a valid relocation mode",
                                      sess.opts
@@ -195,7 +195,7 @@ pub mod write {
                     target_feature(sess).with_c_str(|features| {
                         llvm::LLVMRustCreateTargetMachine(
                             t, cpu, features,
-                            lib::llvm::CodeModelDefault,
+                            llvm::CodeModelDefault,
                             reloc_model,
                             opt_level,
                             true /* EnableSegstk */,
@@ -320,7 +320,7 @@ pub mod write {
                         };
                         with_codegen(tm, llmod, trans.no_builtins, |cpm| {
                             write_output_file(sess, tm, cpm, llmod, &path,
-                                            lib::llvm::AssemblyFile);
+                                            llvm::AssemblyFile);
                         });
                     }
                     OutputTypeObject => {
@@ -338,7 +338,7 @@ pub mod write {
                     Some(ref path) => {
                         with_codegen(tm, llmod, trans.no_builtins, |cpm| {
                             write_output_file(sess, tm, cpm, llmod, path,
-                                            lib::llvm::ObjectFile);
+                                            llvm::ObjectFile);
                         });
                     }
                     None => {}
@@ -350,7 +350,7 @@ pub mod write {
                                         .with_extension("metadata.o");
                         write_output_file(sess, tm, cpm,
                                         trans.metadata_module, &out,
-                                        lib::llvm::ObjectFile);
+                                        llvm::ObjectFile);
                     })
                 }
             });
@@ -455,29 +455,29 @@ pub mod write {
         });
     }
 
-    unsafe fn populate_llvm_passes(fpm: lib::llvm::PassManagerRef,
-                                   mpm: lib::llvm::PassManagerRef,
+    unsafe fn populate_llvm_passes(fpm: llvm::PassManagerRef,
+                                   mpm: llvm::PassManagerRef,
                                    llmod: ModuleRef,
-                                   opt: lib::llvm::CodeGenOptLevel,
+                                   opt: llvm::CodeGenOptLevel,
                                    no_builtins: bool) {
         // Create the PassManagerBuilder for LLVM. We configure it with
         // reasonable defaults and prepare it to actually populate the pass
         // manager.
         let builder = llvm::LLVMPassManagerBuilderCreate();
         match opt {
-            lib::llvm::CodeGenLevelNone => {
+            llvm::CodeGenLevelNone => {
                 // Don't add lifetime intrinsics at O0
                 llvm::LLVMRustAddAlwaysInlinePass(builder, false);
             }
-            lib::llvm::CodeGenLevelLess => {
+            llvm::CodeGenLevelLess => {
                 llvm::LLVMRustAddAlwaysInlinePass(builder, true);
             }
             // numeric values copied from clang
-            lib::llvm::CodeGenLevelDefault => {
+            llvm::CodeGenLevelDefault => {
                 llvm::LLVMPassManagerBuilderUseInlinerWithThreshold(builder,
                                                                     225);
             }
-            lib::llvm::CodeGenLevelAggressive => {
+            llvm::CodeGenLevelAggressive => {
                 llvm::LLVMPassManagerBuilderUseInlinerWithThreshold(builder,
                                                                     275);
             }
@@ -611,7 +611,7 @@ pub fn build_link_meta(sess: &Session, krate: &ast::Crate,
                        name: String) -> LinkMeta {
     let r = LinkMeta {
         crate_name: name,
-        crate_hash: Svh::calculate(sess, krate),
+        crate_hash: Svh::calculate(&sess.opts.cg.metadata, krate),
     };
     info!("{}", r);
     return r;
@@ -963,6 +963,17 @@ fn link_binary_output(sess: &Session,
     out_filename
 }
 
+fn archive_search_paths(sess: &Session) -> Vec<Path> {
+    let mut rustpath = filesearch::rust_path();
+    rustpath.push(sess.target_filesearch().get_lib_path());
+    // FIXME: Addl lib search paths are an unordered HashSet?
+    // Shouldn't this search be done in some order?
+    let addl_lib_paths: HashSet<Path> = sess.opts.addl_lib_search_paths.borrow().clone();
+    let mut search: Vec<Path> = addl_lib_paths.move_iter().collect();
+    search.push_all(rustpath.as_slice());
+    return search;
+}
+
 // Create an 'rlib'
 //
 // An rlib in its current incarnation is essentially a renamed .a file. The
@@ -973,7 +984,15 @@ fn link_rlib<'a>(sess: &'a Session,
                  trans: Option<&CrateTranslation>, // None == no metadata/bytecode
                  obj_filename: &Path,
                  out_filename: &Path) -> Archive<'a> {
-    let mut a = Archive::create(sess, out_filename, obj_filename);
+    let handler = &sess.diagnostic().handler;
+    let config = ArchiveConfig {
+        handler: handler,
+        dst: out_filename.clone(),
+        lib_search_paths: archive_search_paths(sess),
+        os: sess.targ_cfg.os,
+        maybe_ar_prog: sess.opts.cg.ar.clone()
+    };
+    let mut a = Archive::create(config, obj_filename);
 
     for &(ref l, kind) in sess.cstore.get_used_libraries().borrow().iter() {
         match kind {
@@ -1387,7 +1406,24 @@ fn link_args(cmd: &mut Command,
     // where extern libraries might live, based on the
     // addl_lib_search_paths
     if sess.opts.cg.rpath {
-        cmd.args(rpath::get_rpath_flags(sess, out_filename).as_slice());
+        let sysroot = sess.sysroot();
+        let target_triple = sess.opts.target_triple.as_slice();
+        let get_install_prefix_lib_path = || {
+            let install_prefix = option_env!("CFG_PREFIX").expect("CFG_PREFIX");
+            let tlib = filesearch::relative_target_lib_path(sysroot, target_triple);
+            let mut path = Path::new(install_prefix);
+            path.push(&tlib);
+
+            path
+        };
+        let rpath_config = RPathConfig {
+            os: sess.targ_cfg.os,
+            used_crates: sess.cstore.get_used_crates(cstore::RequireDynamic),
+            out_filename: out_filename.clone(),
+            get_install_prefix_lib_path: get_install_prefix_lib_path,
+            realpath: ::util::fs::realpath
+        };
+        cmd.args(rpath::get_rpath_flags(rpath_config).as_slice());
     }
 
     // compiler-rt contains implementations of low-level LLVM helpers. This is
@@ -1545,7 +1581,15 @@ fn add_upstream_rust_crates(cmd: &mut Command, sess: &Session,
                         sess.abort_if_errors();
                     }
                 }
-                let mut archive = Archive::open(sess, dst.clone());
+                let handler = &sess.diagnostic().handler;
+                let config = ArchiveConfig {
+                    handler: handler,
+                    dst: dst.clone(),
+                    lib_search_paths: archive_search_paths(sess),
+                    os: sess.targ_cfg.os,
+                    maybe_ar_prog: sess.opts.cg.ar.clone()
+                };
+                let mut archive = Archive::open(config);
                 archive.remove_file(format!("{}.o", name).as_slice());
                 let files = archive.files();
                 if files.iter().any(|s| s.as_slice().ends_with(".o")) {
diff --git a/src/librustc/back/lto.rs b/src/librustc/back/lto.rs
index b9ae9530f8e..6184ea4591f 100644
--- a/src/librustc/back/lto.rs
+++ b/src/librustc/back/lto.rs
@@ -8,11 +8,12 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-use back::archive::ArchiveRO;
-use back::link;
+use super::link;
 use driver::session;
 use driver::config;
-use lib::llvm::{ModuleRef, TargetMachineRef, llvm, True, False};
+use llvm;
+use llvm::archive_ro::ArchiveRO;
+use llvm::{ModuleRef, TargetMachineRef, True, False};
 use metadata::cstore;
 use util::common::time;
 
diff --git a/src/librustc/driver/config.rs b/src/librustc/driver/config.rs
index b726c50afe9..232a1252f59 100644
--- a/src/librustc/driver/config.rs
+++ b/src/librustc/driver/config.rs
@@ -33,10 +33,10 @@ use syntax::parse::token::InternedString;
 use std::collections::{HashSet, HashMap};
 use getopts::{optopt, optmulti, optflag, optflagopt};
 use getopts;
-use lib::llvm::llvm;
 use std::cell::{RefCell};
 use std::fmt;
 
+use llvm;
 
 pub struct Config {
     pub os: abi::Os,
diff --git a/src/librustc/driver/driver.rs b/src/librustc/driver/driver.rs
index d03bf3593fa..2149504a67a 100644
--- a/src/librustc/driver/driver.rs
+++ b/src/librustc/driver/driver.rs
@@ -15,8 +15,8 @@ use driver::{config, PpMode};
 use driver::{PpmFlowGraph, PpmExpanded, PpmExpandedIdentified, PpmTyped};
 use driver::{PpmIdentified};
 use front;
-use lib::llvm::{ContextRef, ModuleRef};
 use lint;
+use llvm::{ContextRef, ModuleRef};
 use metadata::common::LinkMeta;
 use metadata::creader;
 use middle::cfg;
diff --git a/src/librustc/driver/mod.rs b/src/librustc/driver/mod.rs
index 2614c9ebf98..e850b71dda8 100644
--- a/src/librustc/driver/mod.rs
+++ b/src/librustc/driver/mod.rs
@@ -292,7 +292,7 @@ pub fn handle_options(mut args: Vec<String>) -> Option<getopts::Matches> {
     }
 
     if cg_flags.contains(&"passes=list".to_string()) {
-        unsafe { ::lib::llvm::llvm::LLVMRustPrintPasses(); }
+        unsafe { ::llvm::LLVMRustPrintPasses(); }
         return None;
     }
 
diff --git a/src/librustc/lib.rs b/src/librustc/lib.rs
index 63fba0fd4b4..92d1c176a1b 100644
--- a/src/librustc/lib.rs
+++ b/src/librustc/lib.rs
@@ -41,6 +41,8 @@ extern crate flate;
 extern crate getopts;
 extern crate graphviz;
 extern crate libc;
+extern crate llvm = "rustc_llvm";
+extern crate rustc_back = "rustc_back";
 extern crate serialize;
 extern crate time;
 #[phase(plugin, link)] extern crate log;
@@ -48,6 +50,23 @@ extern crate time;
 
 mod diagnostics;
 
+pub mod back {
+    pub use rustc_back::abi;
+    pub use rustc_back::archive;
+    pub use rustc_back::arm;
+    pub use rustc_back::mips;
+    pub use rustc_back::mipsel;
+    pub use rustc_back::rpath;
+    pub use rustc_back::svh;
+    pub use rustc_back::target_strs;
+    pub use rustc_back::x86;
+    pub use rustc_back::x86_64;
+
+    pub mod link;
+    pub mod lto;
+
+}
+
 pub mod middle {
     pub mod def;
     pub mod trans;
@@ -96,21 +115,6 @@ pub mod front {
     pub mod show_span;
 }
 
-pub mod back {
-    pub mod abi;
-    pub mod archive;
-    pub mod arm;
-    pub mod link;
-    pub mod lto;
-    pub mod mips;
-    pub mod mipsel;
-    pub mod rpath;
-    pub mod svh;
-    pub mod target_strs;
-    pub mod x86;
-    pub mod x86_64;
-}
-
 pub mod metadata;
 
 pub mod driver;
@@ -120,16 +124,16 @@ pub mod plugin;
 pub mod lint;
 
 pub mod util {
+    pub use rustc_back::fs;
+    pub use rustc_back::sha2;
+
     pub mod common;
     pub mod ppaux;
-    pub mod sha2;
     pub mod nodemap;
-    pub mod fs;
 }
 
 pub mod lib {
-    pub mod llvm;
-    pub mod llvmdeps;
+    pub use llvm;
 }
 
 __build_diagnostic_array!(DIAGNOSTICS)
diff --git a/src/librustc/lib/llvm.rs b/src/librustc/lib/llvm.rs
deleted file mode 100644
index a4425183cde..00000000000
--- a/src/librustc/lib/llvm.rs
+++ /dev/null
@@ -1,1983 +0,0 @@
-// Copyright 2012-2014 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.
-
-#![allow(non_uppercase_pattern_statics)]
-#![allow(non_camel_case_types)]
-#![allow(non_snake_case_functions)]
-#![allow(dead_code)]
-
-use std::c_str::ToCStr;
-use std::cell::RefCell;
-use std::collections::HashMap;
-use libc::{c_uint, c_ushort, c_void, free, uint64_t};
-use std::str::raw::from_c_str;
-
-use middle::trans::type_::Type;
-
-pub type Opcode = u32;
-pub type Bool = c_uint;
-
-pub static True: Bool = 1 as Bool;
-pub static False: Bool = 0 as Bool;
-
-// Consts for the LLVM CallConv type, pre-cast to uint.
-
-#[deriving(PartialEq)]
-pub enum CallConv {
-    CCallConv = 0,
-    FastCallConv = 8,
-    ColdCallConv = 9,
-    X86StdcallCallConv = 64,
-    X86FastcallCallConv = 65,
-    X86_64_Win64 = 79,
-}
-
-pub enum Visibility {
-    LLVMDefaultVisibility = 0,
-    HiddenVisibility = 1,
-    ProtectedVisibility = 2,
-}
-
-// 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.
-pub enum Linkage {
-    ExternalLinkage = 0,
-    AvailableExternallyLinkage = 1,
-    LinkOnceAnyLinkage = 2,
-    LinkOnceODRLinkage = 3,
-    WeakAnyLinkage = 5,
-    WeakODRLinkage = 6,
-    AppendingLinkage = 7,
-    InternalLinkage = 8,
-    PrivateLinkage = 9,
-    ExternalWeakLinkage = 12,
-    CommonLinkage = 14,
-}
-
-#[deriving(Clone)]
-pub enum Attribute {
-    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,
-}
-
-#[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
-}
-
-// enum for the LLVM IntPredicate type
-pub enum IntPredicate {
-    IntEQ = 32,
-    IntNE = 33,
-    IntUGT = 34,
-    IntUGE = 35,
-    IntULT = 36,
-    IntULE = 37,
-    IntSGT = 38,
-    IntSGE = 39,
-    IntSLT = 40,
-    IntSLE = 41,
-}
-
-// enum for the LLVM RealPredicate type
-pub enum RealPredicate {
-    RealPredicateFalse = 0,
-    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,
-    RealPredicateTrue = 15,
-}
-
-// The LLVM TypeKind type - must stay in sync with the def of
-// LLVMTypeKind in llvm/include/llvm-c/Core.h
-#[deriving(PartialEq)]
-#[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,
-}
-
-#[repr(C)]
-pub enum AtomicBinOp {
-    Xchg = 0,
-    Add  = 1,
-    Sub  = 2,
-    And  = 3,
-    Nand = 4,
-    Or   = 5,
-    Xor  = 6,
-    Max  = 7,
-    Min  = 8,
-    UMax = 9,
-    UMin = 10,
-}
-
-#[repr(C)]
-pub enum AtomicOrdering {
-    NotAtomic = 0,
-    Unordered = 1,
-    Monotonic = 2,
-    // Consume = 3,  // Not specified yet.
-    Acquire = 4,
-    Release = 5,
-    AcquireRelease = 6,
-    SequentiallyConsistent = 7
-}
-
-// Consts for the LLVMCodeGenFileType type (in include/llvm/c/TargetMachine.h)
-#[repr(C)]
-pub enum FileType {
-    AssemblyFile = 0,
-    ObjectFile = 1
-}
-
-pub enum Metadata {
-    MD_dbg = 0,
-    MD_tbaa = 1,
-    MD_prof = 2,
-    MD_fpmath = 3,
-    MD_range = 4,
-    MD_tbaa_struct = 5
-}
-
-// Inline Asm Dialect
-pub enum AsmDialect {
-    AD_ATT   = 0,
-    AD_Intel = 1
-}
-
-#[deriving(PartialEq)]
-#[repr(C)]
-pub enum CodeGenOptLevel {
-    CodeGenLevelNone = 0,
-    CodeGenLevelLess = 1,
-    CodeGenLevelDefault = 2,
-    CodeGenLevelAggressive = 3,
-}
-
-#[repr(C)]
-pub enum RelocMode {
-    RelocDefault = 0,
-    RelocStatic = 1,
-    RelocPIC = 2,
-    RelocDynamicNoPic = 3,
-}
-
-#[repr(C)]
-pub enum CodeGenModel {
-    CodeModelDefault = 0,
-    CodeModelJITDefault = 1,
-    CodeModelSmall = 2,
-    CodeModelKernel = 3,
-    CodeModelMedium = 4,
-    CodeModelLarge = 5,
-}
-
-// Opaque pointer types
-pub enum Module_opaque {}
-pub type ModuleRef = *mut Module_opaque;
-pub enum Context_opaque {}
-pub type ContextRef = *mut Context_opaque;
-pub enum Type_opaque {}
-pub type TypeRef = *mut Type_opaque;
-pub enum Value_opaque {}
-pub type ValueRef = *mut Value_opaque;
-pub enum BasicBlock_opaque {}
-pub type BasicBlockRef = *mut BasicBlock_opaque;
-pub enum Builder_opaque {}
-pub type BuilderRef = *mut Builder_opaque;
-pub enum ExecutionEngine_opaque {}
-pub type ExecutionEngineRef = *mut ExecutionEngine_opaque;
-pub enum MemoryBuffer_opaque {}
-pub type MemoryBufferRef = *mut MemoryBuffer_opaque;
-pub enum PassManager_opaque {}
-pub type PassManagerRef = *mut PassManager_opaque;
-pub enum PassManagerBuilder_opaque {}
-pub type PassManagerBuilderRef = *mut PassManagerBuilder_opaque;
-pub enum Use_opaque {}
-pub type UseRef = *mut Use_opaque;
-pub enum TargetData_opaque {}
-pub type TargetDataRef = *mut TargetData_opaque;
-pub enum ObjectFile_opaque {}
-pub type ObjectFileRef = *mut ObjectFile_opaque;
-pub enum SectionIterator_opaque {}
-pub type SectionIteratorRef = *mut SectionIterator_opaque;
-pub enum Pass_opaque {}
-pub type PassRef = *mut Pass_opaque;
-pub enum TargetMachine_opaque {}
-pub type TargetMachineRef = *mut TargetMachine_opaque;
-pub enum Archive_opaque {}
-pub type ArchiveRef = *mut Archive_opaque;
-
-pub mod debuginfo {
-    use super::{ValueRef};
-
-    pub enum DIBuilder_opaque {}
-    pub type DIBuilderRef = *mut DIBuilder_opaque;
-
-    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;
-    pub type DIGlobalVariable = DIDescriptor;
-    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
-    }
-}
-
-pub mod llvm {
-    use super::{AtomicBinOp, AtomicOrdering, BasicBlockRef, ExecutionEngineRef};
-    use super::{Bool, BuilderRef, ContextRef, MemoryBufferRef, ModuleRef};
-    use super::{ObjectFileRef, Opcode, PassManagerRef, PassManagerBuilderRef};
-    use super::{SectionIteratorRef, TargetDataRef, TypeKind, TypeRef, UseRef};
-    use super::{ValueRef, TargetMachineRef, FileType, ArchiveRef};
-    use super::{CodeGenModel, RelocMode, CodeGenOptLevel};
-    use super::debuginfo::*;
-    use libc::{c_char, c_int, c_longlong, c_ushort, c_uint, c_ulonglong,
-               size_t, uint64_t};
-
-    // 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")]
-    extern {
-        /* Create and destroy contexts. */
-        pub fn LLVMContextCreate() -> ContextRef;
-        pub fn LLVMContextDispose(C: ContextRef);
-        pub fn LLVMGetMDKindIDInContext(C: ContextRef,
-                                        Name: *const c_char,
-                                        SLen: c_uint)
-                                        -> c_uint;
-
-        /* Create and destroy modules. */
-        pub fn LLVMModuleCreateWithNameInContext(ModuleID: *const c_char,
-                                                 C: ContextRef)
-                                                 -> ModuleRef;
-        pub fn LLVMGetModuleContext(M: ModuleRef) -> ContextRef;
-        pub fn LLVMDisposeModule(M: ModuleRef);
-
-        /** Data layout. See Module::getDataLayout. */
-        pub fn LLVMGetDataLayout(M: ModuleRef) -> *const c_char;
-        pub fn LLVMSetDataLayout(M: ModuleRef, Triple: *const c_char);
-
-        /** Target triple. See Module::getTargetTriple. */
-        pub fn LLVMGetTarget(M: ModuleRef) -> *const c_char;
-        pub fn LLVMSetTarget(M: ModuleRef, Triple: *const c_char);
-
-        /** See Module::dump. */
-        pub fn LLVMDumpModule(M: ModuleRef);
-
-        /** See Module::setModuleInlineAsm. */
-        pub fn LLVMSetModuleInlineAsm(M: ModuleRef, Asm: *const c_char);
-
-        /** See llvm::LLVMTypeKind::getTypeID. */
-        pub fn LLVMGetTypeKind(Ty: TypeRef) -> TypeKind;
-
-        /** See llvm::LLVMType::getContext. */
-        pub fn LLVMGetTypeContext(Ty: TypeRef) -> ContextRef;
-
-        /* Operations on integer types */
-        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;
-
-        pub fn LLVMGetIntTypeWidth(IntegerTy: TypeRef) -> c_uint;
-
-        /* Operations on real types */
-        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;
-
-        /* Operations on function types */
-        pub fn LLVMFunctionType(ReturnType: TypeRef,
-                                ParamTypes: *const 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: *const TypeRef);
-
-        /* Operations on struct types */
-        pub fn LLVMStructTypeInContext(C: ContextRef,
-                                       ElementTypes: *const 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;
-
-        /* Operations on array, pointer, and vector types (sequence types) */
-        pub fn LLVMRustArrayType(ElementType: TypeRef, ElementCount: u64) -> TypeRef;
-        pub fn LLVMPointerType(ElementType: TypeRef, AddressSpace: c_uint)
-                               -> TypeRef;
-        pub fn LLVMVectorType(ElementType: TypeRef, ElementCount: c_uint)
-                              -> TypeRef;
-
-        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)
-                                      -> *const ();
-        pub fn LLVMGetVectorSize(VectorTy: TypeRef) -> c_uint;
-
-        /* Operations on other types */
-        pub fn LLVMVoidTypeInContext(C: ContextRef) -> TypeRef;
-        pub fn LLVMLabelTypeInContext(C: ContextRef) -> TypeRef;
-        pub fn LLVMMetadataTypeInContext(C: ContextRef) -> TypeRef;
-
-        /* Operations on all values */
-        pub fn LLVMTypeOf(Val: ValueRef) -> TypeRef;
-        pub fn LLVMGetValueName(Val: ValueRef) -> *const c_char;
-        pub fn LLVMSetValueName(Val: ValueRef, Name: *const 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);
-
-        /* Operations on Uses */
-        pub fn LLVMGetFirstUse(Val: ValueRef) -> UseRef;
-        pub fn LLVMGetNextUse(U: UseRef) -> UseRef;
-        pub fn LLVMGetUser(U: UseRef) -> ValueRef;
-        pub fn LLVMGetUsedValue(U: UseRef) -> ValueRef;
-
-        /* Operations on Users */
-        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);
-
-        /* Operations on constants of any type */
-        pub fn LLVMConstNull(Ty: TypeRef) -> ValueRef;
-        /* all zeroes */
-        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;
-        /* only for int/vector */
-        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;
-
-        /* Operations on metadata */
-        pub fn LLVMMDStringInContext(C: ContextRef,
-                                     Str: *const c_char,
-                                     SLen: c_uint)
-                                     -> ValueRef;
-        pub fn LLVMMDNodeInContext(C: ContextRef,
-                                   Vals: *const ValueRef,
-                                   Count: c_uint)
-                                   -> ValueRef;
-        pub fn LLVMAddNamedMetadataOperand(M: ModuleRef,
-                                           Str: *const c_char,
-                                           Val: ValueRef);
-
-        /* Operations on scalar constants */
-        pub fn LLVMConstInt(IntTy: TypeRef, N: c_ulonglong, SignExtend: Bool)
-                            -> ValueRef;
-        pub fn LLVMConstIntOfString(IntTy: TypeRef, Text: *const c_char, Radix: u8)
-                                    -> ValueRef;
-        pub fn LLVMConstIntOfStringAndSize(IntTy: TypeRef,
-                                           Text: *const c_char,
-                                           SLen: c_uint,
-                                           Radix: u8)
-                                           -> ValueRef;
-        pub fn LLVMConstReal(RealTy: TypeRef, N: f64) -> ValueRef;
-        pub fn LLVMConstRealOfString(RealTy: TypeRef, Text: *const c_char)
-                                     -> ValueRef;
-        pub fn LLVMConstRealOfStringAndSize(RealTy: TypeRef,
-                                            Text: *const c_char,
-                                            SLen: c_uint)
-                                            -> ValueRef;
-        pub fn LLVMConstIntGetZExtValue(ConstantVal: ValueRef) -> c_ulonglong;
-        pub fn LLVMConstIntGetSExtValue(ConstantVal: ValueRef) -> c_longlong;
-
-
-        /* Operations on composite constants */
-        pub fn LLVMConstStringInContext(C: ContextRef,
-                                        Str: *const c_char,
-                                        Length: c_uint,
-                                        DontNullTerminate: Bool)
-                                        -> ValueRef;
-        pub fn LLVMConstStructInContext(C: ContextRef,
-                                        ConstantVals: *const ValueRef,
-                                        Count: c_uint,
-                                        Packed: Bool)
-                                        -> ValueRef;
-
-        pub fn LLVMConstArray(ElementTy: TypeRef,
-                              ConstantVals: *const ValueRef,
-                              Length: c_uint)
-                              -> ValueRef;
-        pub fn LLVMConstVector(ScalarConstantVals: *const ValueRef, Size: c_uint)
-                               -> ValueRef;
-
-        /* Constant expressions */
-        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)
-                               -> ValueRef;
-        pub fn LLVMConstNUWAdd(LHSConstant: ValueRef, RHSConstant: ValueRef)
-                               -> ValueRef;
-        pub fn LLVMConstFAdd(LHSConstant: ValueRef, RHSConstant: ValueRef)
-                             -> ValueRef;
-        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)
-                            -> ValueRef;
-        pub fn LLVMConstNSWMul(LHSConstant: ValueRef, RHSConstant: ValueRef)
-                               -> ValueRef;
-        pub fn LLVMConstNUWMul(LHSConstant: ValueRef, RHSConstant: ValueRef)
-                               -> ValueRef;
-        pub fn LLVMConstFMul(LHSConstant: ValueRef, RHSConstant: ValueRef)
-                             -> ValueRef;
-        pub fn LLVMConstUDiv(LHSConstant: ValueRef, RHSConstant: ValueRef)
-                             -> ValueRef;
-        pub fn LLVMConstSDiv(LHSConstant: ValueRef, RHSConstant: ValueRef)
-                             -> ValueRef;
-        pub fn LLVMConstExactSDiv(LHSConstant: ValueRef,
-                                  RHSConstant: ValueRef)
-                                  -> ValueRef;
-        pub fn LLVMConstFDiv(LHSConstant: ValueRef, RHSConstant: ValueRef)
-                             -> ValueRef;
-        pub fn LLVMConstURem(LHSConstant: ValueRef, RHSConstant: ValueRef)
-                             -> ValueRef;
-        pub fn LLVMConstSRem(LHSConstant: ValueRef, RHSConstant: ValueRef)
-                             -> ValueRef;
-        pub fn LLVMConstFRem(LHSConstant: ValueRef, RHSConstant: ValueRef)
-                             -> ValueRef;
-        pub fn LLVMConstAnd(LHSConstant: ValueRef, RHSConstant: ValueRef)
-                            -> ValueRef;
-        pub fn LLVMConstOr(LHSConstant: ValueRef, RHSConstant: ValueRef)
-                           -> ValueRef;
-        pub fn LLVMConstXor(LHSConstant: ValueRef, RHSConstant: ValueRef)
-                            -> ValueRef;
-        pub fn LLVMConstShl(LHSConstant: ValueRef, RHSConstant: ValueRef)
-                            -> ValueRef;
-        pub fn LLVMConstLShr(LHSConstant: ValueRef, RHSConstant: ValueRef)
-                             -> ValueRef;
-        pub fn LLVMConstAShr(LHSConstant: ValueRef, RHSConstant: ValueRef)
-                             -> ValueRef;
-        pub fn LLVMConstGEP(ConstantVal: ValueRef,
-                            ConstantIndices: *const ValueRef,
-                            NumIndices: c_uint)
-                            -> ValueRef;
-        pub fn LLVMConstInBoundsGEP(ConstantVal: ValueRef,
-                                    ConstantIndices: *const ValueRef,
-                                    NumIndices: c_uint)
-                                    -> ValueRef;
-        pub fn LLVMConstTrunc(ConstantVal: ValueRef, ToType: TypeRef)
-                              -> ValueRef;
-        pub fn LLVMConstSExt(ConstantVal: ValueRef, ToType: TypeRef)
-                             -> ValueRef;
-        pub fn LLVMConstZExt(ConstantVal: ValueRef, ToType: TypeRef)
-                             -> ValueRef;
-        pub fn LLVMConstFPTrunc(ConstantVal: ValueRef, ToType: TypeRef)
-                                -> ValueRef;
-        pub fn LLVMConstFPExt(ConstantVal: ValueRef, ToType: TypeRef)
-                              -> ValueRef;
-        pub fn LLVMConstUIToFP(ConstantVal: ValueRef, ToType: TypeRef)
-                               -> ValueRef;
-        pub fn LLVMConstSIToFP(ConstantVal: ValueRef, ToType: TypeRef)
-                               -> ValueRef;
-        pub fn LLVMConstFPToUI(ConstantVal: ValueRef, ToType: TypeRef)
-                               -> ValueRef;
-        pub fn LLVMConstFPToSI(ConstantVal: ValueRef, ToType: TypeRef)
-                               -> ValueRef;
-        pub fn LLVMConstPtrToInt(ConstantVal: ValueRef, ToType: TypeRef)
-                                 -> ValueRef;
-        pub fn LLVMConstIntToPtr(ConstantVal: ValueRef, ToType: TypeRef)
-                                 -> ValueRef;
-        pub fn LLVMConstBitCast(ConstantVal: ValueRef, ToType: TypeRef)
-                                -> ValueRef;
-        pub fn LLVMConstZExtOrBitCast(ConstantVal: ValueRef, ToType: TypeRef)
-                                      -> ValueRef;
-        pub fn LLVMConstSExtOrBitCast(ConstantVal: ValueRef, ToType: TypeRef)
-                                      -> ValueRef;
-        pub fn LLVMConstTruncOrBitCast(ConstantVal: ValueRef, ToType: TypeRef)
-                                       -> ValueRef;
-        pub fn LLVMConstPointerCast(ConstantVal: ValueRef, ToType: TypeRef)
-                                    -> ValueRef;
-        pub fn LLVMConstIntCast(ConstantVal: ValueRef,
-                                ToType: TypeRef,
-                                isSigned: Bool)
-                                -> ValueRef;
-        pub fn LLVMConstFPCast(ConstantVal: ValueRef, ToType: TypeRef)
-                               -> ValueRef;
-        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: *const c_uint,
-                                     NumIdx: c_uint)
-                                     -> ValueRef;
-        pub fn LLVMConstInsertValue(AggConstant: ValueRef,
-                                    ElementValueConstant: ValueRef,
-                                    IdxList: *const c_uint,
-                                    NumIdx: c_uint)
-                                    -> ValueRef;
-        pub fn LLVMConstInlineAsm(Ty: TypeRef,
-                                  AsmString: *const c_char,
-                                  Constraints: *const c_char,
-                                  HasSideEffects: Bool,
-                                  IsAlignStack: Bool)
-                                  -> ValueRef;
-        pub fn LLVMBlockAddress(F: ValueRef, BB: BasicBlockRef) -> ValueRef;
-
-
-
-        /* Operations on global variables, functions, and aliases (globals) */
-        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) -> *const c_char;
-        pub fn LLVMSetSection(Global: ValueRef, Section: *const 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);
-
-
-        /* Operations on global variables */
-        pub fn LLVMAddGlobal(M: ModuleRef, Ty: TypeRef, Name: *const c_char)
-                             -> ValueRef;
-        pub fn LLVMAddGlobalInAddressSpace(M: ModuleRef,
-                                           Ty: TypeRef,
-                                           Name: *const c_char,
-                                           AddressSpace: c_uint)
-                                           -> ValueRef;
-        pub fn LLVMGetNamedGlobal(M: ModuleRef, Name: *const 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,
-                                         ConstantVal: ValueRef);
-        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);
-
-        /* Operations on aliases */
-        pub fn LLVMAddAlias(M: ModuleRef,
-                            Ty: TypeRef,
-                            Aliasee: ValueRef,
-                            Name: *const c_char)
-                            -> ValueRef;
-
-        /* Operations on functions */
-        pub fn LLVMAddFunction(M: ModuleRef,
-                               Name: *const c_char,
-                               FunctionTy: TypeRef)
-                               -> ValueRef;
-        pub fn LLVMGetNamedFunction(M: ModuleRef, Name: *const 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: *const 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) -> *const c_char;
-        pub fn LLVMSetGC(Fn: ValueRef, Name: *const c_char);
-        pub fn LLVMAddFunctionAttribute(Fn: ValueRef, index: c_uint, PA: uint64_t);
-        pub fn LLVMAddFunctionAttrString(Fn: ValueRef, index: c_uint, Name: *const c_char);
-        pub fn LLVMRemoveFunctionAttrString(Fn: ValueRef, index: c_uint, Name: *const c_char);
-        pub fn LLVMGetFunctionAttr(Fn: ValueRef) -> c_ulonglong;
-
-        /* Operations on parameters */
-        pub fn LLVMCountParams(Fn: ValueRef) -> c_uint;
-        pub fn LLVMGetParams(Fn: ValueRef, Params: *const 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);
-
-        /* Operations on basic blocks */
-        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: *const 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;
-
-        pub fn LLVMAppendBasicBlockInContext(C: ContextRef,
-                                             Fn: ValueRef,
-                                             Name: *const c_char)
-                                             -> BasicBlockRef;
-        pub fn LLVMInsertBasicBlockInContext(C: ContextRef,
-                                             BB: BasicBlockRef,
-                                             Name: *const c_char)
-                                             -> BasicBlockRef;
-        pub fn LLVMDeleteBasicBlock(BB: BasicBlockRef);
-
-        pub fn LLVMMoveBasicBlockAfter(BB: BasicBlockRef,
-                                       MoveAfter: BasicBlockRef);
-
-        pub fn LLVMMoveBasicBlockBefore(BB: BasicBlockRef,
-                                        MoveBefore: BasicBlockRef);
-
-        /* Operations on instructions */
-        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);
-
-        /* Operations on call sites */
-        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);
-        pub fn LLVMAddCallSiteAttribute(Instr: ValueRef,
-                                        index: c_uint,
-                                        Val: uint64_t);
-
-        /* Operations on call instructions (only) */
-        pub fn LLVMIsTailCall(CallInst: ValueRef) -> Bool;
-        pub fn LLVMSetTailCall(CallInst: ValueRef, IsTailCall: Bool);
-
-        /* Operations on load/store instructions (only) */
-        pub fn LLVMGetVolatile(MemoryAccessInst: ValueRef) -> Bool;
-        pub fn LLVMSetVolatile(MemoryAccessInst: ValueRef, volatile: Bool);
-
-        /* Operations on phi nodes */
-        pub fn LLVMAddIncoming(PhiNode: ValueRef,
-                               IncomingValues: *const ValueRef,
-                               IncomingBlocks: *const BasicBlockRef,
-                               Count: c_uint);
-        pub fn LLVMCountIncoming(PhiNode: ValueRef) -> c_uint;
-        pub fn LLVMGetIncomingValue(PhiNode: ValueRef, Index: c_uint)
-                                    -> ValueRef;
-        pub fn LLVMGetIncomingBlock(PhiNode: ValueRef, Index: c_uint)
-                                    -> BasicBlockRef;
-
-        /* Instruction builders */
-        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: *const c_char);
-        pub fn LLVMDisposeBuilder(Builder: BuilderRef);
-        pub fn LLVMDisposeExecutionEngine(EE: ExecutionEngineRef);
-
-        /* Metadata */
-        pub fn LLVMSetCurrentDebugLocation(Builder: BuilderRef, L: ValueRef);
-        pub fn LLVMGetCurrentDebugLocation(Builder: BuilderRef) -> ValueRef;
-        pub fn LLVMSetInstDebugLocation(Builder: BuilderRef, Inst: ValueRef);
-
-        /* Terminators */
-        pub fn LLVMBuildRetVoid(B: BuilderRef) -> ValueRef;
-        pub fn LLVMBuildRet(B: BuilderRef, V: ValueRef) -> ValueRef;
-        pub fn LLVMBuildAggregateRet(B: BuilderRef,
-                                     RetVals: *const ValueRef,
-                                     N: c_uint)
-                                     -> ValueRef;
-        pub fn LLVMBuildBr(B: BuilderRef, Dest: BasicBlockRef) -> ValueRef;
-        pub fn LLVMBuildCondBr(B: BuilderRef,
-                               If: ValueRef,
-                               Then: BasicBlockRef,
-                               Else: BasicBlockRef)
-                               -> ValueRef;
-        pub fn LLVMBuildSwitch(B: BuilderRef,
-                               V: ValueRef,
-                               Else: BasicBlockRef,
-                               NumCases: c_uint)
-                               -> ValueRef;
-        pub fn LLVMBuildIndirectBr(B: BuilderRef,
-                                   Addr: ValueRef,
-                                   NumDests: c_uint)
-                                   -> ValueRef;
-        pub fn LLVMBuildInvoke(B: BuilderRef,
-                               Fn: ValueRef,
-                               Args: *const ValueRef,
-                               NumArgs: c_uint,
-                               Then: BasicBlockRef,
-                               Catch: BasicBlockRef,
-                               Name: *const c_char)
-                               -> ValueRef;
-        pub fn LLVMBuildLandingPad(B: BuilderRef,
-                                   Ty: TypeRef,
-                                   PersFn: ValueRef,
-                                   NumClauses: c_uint,
-                                   Name: *const c_char)
-                                   -> ValueRef;
-        pub fn LLVMBuildResume(B: BuilderRef, Exn: ValueRef) -> ValueRef;
-        pub fn LLVMBuildUnreachable(B: BuilderRef) -> ValueRef;
-
-        /* Add a case to the switch instruction */
-        pub fn LLVMAddCase(Switch: ValueRef,
-                           OnVal: ValueRef,
-                           Dest: BasicBlockRef);
-
-        /* Add a destination to the indirectbr instruction */
-        pub fn LLVMAddDestination(IndirectBr: ValueRef, Dest: BasicBlockRef);
-
-        /* Add a clause to the landing pad instruction */
-        pub fn LLVMAddClause(LandingPad: ValueRef, ClauseVal: ValueRef);
-
-        /* Set the cleanup on a landing pad instruction */
-        pub fn LLVMSetCleanup(LandingPad: ValueRef, Val: Bool);
-
-        /* Arithmetic */
-        pub fn LLVMBuildAdd(B: BuilderRef,
-                            LHS: ValueRef,
-                            RHS: ValueRef,
-                            Name: *const c_char)
-                            -> ValueRef;
-        pub fn LLVMBuildNSWAdd(B: BuilderRef,
-                               LHS: ValueRef,
-                               RHS: ValueRef,
-                               Name: *const c_char)
-                               -> ValueRef;
-        pub fn LLVMBuildNUWAdd(B: BuilderRef,
-                               LHS: ValueRef,
-                               RHS: ValueRef,
-                               Name: *const c_char)
-                               -> ValueRef;
-        pub fn LLVMBuildFAdd(B: BuilderRef,
-                             LHS: ValueRef,
-                             RHS: ValueRef,
-                             Name: *const c_char)
-                             -> ValueRef;
-        pub fn LLVMBuildSub(B: BuilderRef,
-                            LHS: ValueRef,
-                            RHS: ValueRef,
-                            Name: *const c_char)
-                            -> ValueRef;
-        pub fn LLVMBuildNSWSub(B: BuilderRef,
-                               LHS: ValueRef,
-                               RHS: ValueRef,
-                               Name: *const c_char)
-                               -> ValueRef;
-        pub fn LLVMBuildNUWSub(B: BuilderRef,
-                               LHS: ValueRef,
-                               RHS: ValueRef,
-                               Name: *const c_char)
-                               -> ValueRef;
-        pub fn LLVMBuildFSub(B: BuilderRef,
-                             LHS: ValueRef,
-                             RHS: ValueRef,
-                             Name: *const c_char)
-                             -> ValueRef;
-        pub fn LLVMBuildMul(B: BuilderRef,
-                            LHS: ValueRef,
-                            RHS: ValueRef,
-                            Name: *const c_char)
-                            -> ValueRef;
-        pub fn LLVMBuildNSWMul(B: BuilderRef,
-                               LHS: ValueRef,
-                               RHS: ValueRef,
-                               Name: *const c_char)
-                               -> ValueRef;
-        pub fn LLVMBuildNUWMul(B: BuilderRef,
-                               LHS: ValueRef,
-                               RHS: ValueRef,
-                               Name: *const c_char)
-                               -> ValueRef;
-        pub fn LLVMBuildFMul(B: BuilderRef,
-                             LHS: ValueRef,
-                             RHS: ValueRef,
-                             Name: *const c_char)
-                             -> ValueRef;
-        pub fn LLVMBuildUDiv(B: BuilderRef,
-                             LHS: ValueRef,
-                             RHS: ValueRef,
-                             Name: *const c_char)
-                             -> ValueRef;
-        pub fn LLVMBuildSDiv(B: BuilderRef,
-                             LHS: ValueRef,
-                             RHS: ValueRef,
-                             Name: *const c_char)
-                             -> ValueRef;
-        pub fn LLVMBuildExactSDiv(B: BuilderRef,
-                                  LHS: ValueRef,
-                                  RHS: ValueRef,
-                                  Name: *const c_char)
-                                  -> ValueRef;
-        pub fn LLVMBuildFDiv(B: BuilderRef,
-                             LHS: ValueRef,
-                             RHS: ValueRef,
-                             Name: *const c_char)
-                             -> ValueRef;
-        pub fn LLVMBuildURem(B: BuilderRef,
-                             LHS: ValueRef,
-                             RHS: ValueRef,
-                             Name: *const c_char)
-                             -> ValueRef;
-        pub fn LLVMBuildSRem(B: BuilderRef,
-                             LHS: ValueRef,
-                             RHS: ValueRef,
-                             Name: *const c_char)
-                             -> ValueRef;
-        pub fn LLVMBuildFRem(B: BuilderRef,
-                             LHS: ValueRef,
-                             RHS: ValueRef,
-                             Name: *const c_char)
-                             -> ValueRef;
-        pub fn LLVMBuildShl(B: BuilderRef,
-                            LHS: ValueRef,
-                            RHS: ValueRef,
-                            Name: *const c_char)
-                            -> ValueRef;
-        pub fn LLVMBuildLShr(B: BuilderRef,
-                             LHS: ValueRef,
-                             RHS: ValueRef,
-                             Name: *const c_char)
-                             -> ValueRef;
-        pub fn LLVMBuildAShr(B: BuilderRef,
-                             LHS: ValueRef,
-                             RHS: ValueRef,
-                             Name: *const c_char)
-                             -> ValueRef;
-        pub fn LLVMBuildAnd(B: BuilderRef,
-                            LHS: ValueRef,
-                            RHS: ValueRef,
-                            Name: *const c_char)
-                            -> ValueRef;
-        pub fn LLVMBuildOr(B: BuilderRef,
-                           LHS: ValueRef,
-                           RHS: ValueRef,
-                           Name: *const c_char)
-                           -> ValueRef;
-        pub fn LLVMBuildXor(B: BuilderRef,
-                            LHS: ValueRef,
-                            RHS: ValueRef,
-                            Name: *const c_char)
-                            -> ValueRef;
-        pub fn LLVMBuildBinOp(B: BuilderRef,
-                              Op: Opcode,
-                              LHS: ValueRef,
-                              RHS: ValueRef,
-                              Name: *const c_char)
-                              -> ValueRef;
-        pub fn LLVMBuildNeg(B: BuilderRef, V: ValueRef, Name: *const c_char)
-                            -> ValueRef;
-        pub fn LLVMBuildNSWNeg(B: BuilderRef, V: ValueRef, Name: *const c_char)
-                               -> ValueRef;
-        pub fn LLVMBuildNUWNeg(B: BuilderRef, V: ValueRef, Name: *const c_char)
-                               -> ValueRef;
-        pub fn LLVMBuildFNeg(B: BuilderRef, V: ValueRef, Name: *const c_char)
-                             -> ValueRef;
-        pub fn LLVMBuildNot(B: BuilderRef, V: ValueRef, Name: *const c_char)
-                            -> ValueRef;
-
-        /* Memory */
-        pub fn LLVMBuildMalloc(B: BuilderRef, Ty: TypeRef, Name: *const c_char)
-                               -> ValueRef;
-        pub fn LLVMBuildArrayMalloc(B: BuilderRef,
-                                    Ty: TypeRef,
-                                    Val: ValueRef,
-                                    Name: *const c_char)
-                                    -> ValueRef;
-        pub fn LLVMBuildAlloca(B: BuilderRef, Ty: TypeRef, Name: *const c_char)
-                               -> ValueRef;
-        pub fn LLVMBuildArrayAlloca(B: BuilderRef,
-                                    Ty: TypeRef,
-                                    Val: ValueRef,
-                                    Name: *const c_char)
-                                    -> ValueRef;
-        pub fn LLVMBuildFree(B: BuilderRef, PointerVal: ValueRef) -> ValueRef;
-        pub fn LLVMBuildLoad(B: BuilderRef,
-                             PointerVal: ValueRef,
-                             Name: *const c_char)
-                             -> ValueRef;
-
-        pub fn LLVMBuildStore(B: BuilderRef, Val: ValueRef, Ptr: ValueRef)
-                              -> ValueRef;
-
-        pub fn LLVMBuildGEP(B: BuilderRef,
-                            Pointer: ValueRef,
-                            Indices: *const ValueRef,
-                            NumIndices: c_uint,
-                            Name: *const c_char)
-                            -> ValueRef;
-        pub fn LLVMBuildInBoundsGEP(B: BuilderRef,
-                                    Pointer: ValueRef,
-                                    Indices: *const ValueRef,
-                                    NumIndices: c_uint,
-                                    Name: *const c_char)
-                                    -> ValueRef;
-        pub fn LLVMBuildStructGEP(B: BuilderRef,
-                                  Pointer: ValueRef,
-                                  Idx: c_uint,
-                                  Name: *const c_char)
-                                  -> ValueRef;
-        pub fn LLVMBuildGlobalString(B: BuilderRef,
-                                     Str: *const c_char,
-                                     Name: *const c_char)
-                                     -> ValueRef;
-        pub fn LLVMBuildGlobalStringPtr(B: BuilderRef,
-                                        Str: *const c_char,
-                                        Name: *const c_char)
-                                        -> ValueRef;
-
-        /* Casts */
-        pub fn LLVMBuildTrunc(B: BuilderRef,
-                              Val: ValueRef,
-                              DestTy: TypeRef,
-                              Name: *const c_char)
-                              -> ValueRef;
-        pub fn LLVMBuildZExt(B: BuilderRef,
-                             Val: ValueRef,
-                             DestTy: TypeRef,
-                             Name: *const c_char)
-                             -> ValueRef;
-        pub fn LLVMBuildSExt(B: BuilderRef,
-                             Val: ValueRef,
-                             DestTy: TypeRef,
-                             Name: *const c_char)
-                             -> ValueRef;
-        pub fn LLVMBuildFPToUI(B: BuilderRef,
-                               Val: ValueRef,
-                               DestTy: TypeRef,
-                               Name: *const c_char)
-                               -> ValueRef;
-        pub fn LLVMBuildFPToSI(B: BuilderRef,
-                               Val: ValueRef,
-                               DestTy: TypeRef,
-                               Name: *const c_char)
-                               -> ValueRef;
-        pub fn LLVMBuildUIToFP(B: BuilderRef,
-                               Val: ValueRef,
-                               DestTy: TypeRef,
-                               Name: *const c_char)
-                               -> ValueRef;
-        pub fn LLVMBuildSIToFP(B: BuilderRef,
-                               Val: ValueRef,
-                               DestTy: TypeRef,
-                               Name: *const c_char)
-                               -> ValueRef;
-        pub fn LLVMBuildFPTrunc(B: BuilderRef,
-                                Val: ValueRef,
-                                DestTy: TypeRef,
-                                Name: *const c_char)
-                                -> ValueRef;
-        pub fn LLVMBuildFPExt(B: BuilderRef,
-                              Val: ValueRef,
-                              DestTy: TypeRef,
-                              Name: *const c_char)
-                              -> ValueRef;
-        pub fn LLVMBuildPtrToInt(B: BuilderRef,
-                                 Val: ValueRef,
-                                 DestTy: TypeRef,
-                                 Name: *const c_char)
-                                 -> ValueRef;
-        pub fn LLVMBuildIntToPtr(B: BuilderRef,
-                                 Val: ValueRef,
-                                 DestTy: TypeRef,
-                                 Name: *const c_char)
-                                 -> ValueRef;
-        pub fn LLVMBuildBitCast(B: BuilderRef,
-                                Val: ValueRef,
-                                DestTy: TypeRef,
-                                Name: *const c_char)
-                                -> ValueRef;
-        pub fn LLVMBuildZExtOrBitCast(B: BuilderRef,
-                                      Val: ValueRef,
-                                      DestTy: TypeRef,
-                                      Name: *const c_char)
-                                      -> ValueRef;
-        pub fn LLVMBuildSExtOrBitCast(B: BuilderRef,
-                                      Val: ValueRef,
-                                      DestTy: TypeRef,
-                                      Name: *const c_char)
-                                      -> ValueRef;
-        pub fn LLVMBuildTruncOrBitCast(B: BuilderRef,
-                                       Val: ValueRef,
-                                       DestTy: TypeRef,
-                                       Name: *const c_char)
-                                       -> ValueRef;
-        pub fn LLVMBuildCast(B: BuilderRef,
-                             Op: Opcode,
-                             Val: ValueRef,
-                             DestTy: TypeRef,
-                             Name: *const c_char) -> ValueRef;
-        pub fn LLVMBuildPointerCast(B: BuilderRef,
-                                    Val: ValueRef,
-                                    DestTy: TypeRef,
-                                    Name: *const c_char)
-                                    -> ValueRef;
-        pub fn LLVMBuildIntCast(B: BuilderRef,
-                                Val: ValueRef,
-                                DestTy: TypeRef,
-                                Name: *const c_char)
-                                -> ValueRef;
-        pub fn LLVMBuildFPCast(B: BuilderRef,
-                               Val: ValueRef,
-                               DestTy: TypeRef,
-                               Name: *const c_char)
-                               -> ValueRef;
-
-        /* Comparisons */
-        pub fn LLVMBuildICmp(B: BuilderRef,
-                             Op: c_uint,
-                             LHS: ValueRef,
-                             RHS: ValueRef,
-                             Name: *const c_char)
-                             -> ValueRef;
-        pub fn LLVMBuildFCmp(B: BuilderRef,
-                             Op: c_uint,
-                             LHS: ValueRef,
-                             RHS: ValueRef,
-                             Name: *const c_char)
-                             -> ValueRef;
-
-        /* Miscellaneous instructions */
-        pub fn LLVMBuildPhi(B: BuilderRef, Ty: TypeRef, Name: *const c_char)
-                            -> ValueRef;
-        pub fn LLVMBuildCall(B: BuilderRef,
-                             Fn: ValueRef,
-                             Args: *const ValueRef,
-                             NumArgs: c_uint,
-                             Name: *const c_char)
-                             -> ValueRef;
-        pub fn LLVMBuildSelect(B: BuilderRef,
-                               If: ValueRef,
-                               Then: ValueRef,
-                               Else: ValueRef,
-                               Name: *const c_char)
-                               -> ValueRef;
-        pub fn LLVMBuildVAArg(B: BuilderRef,
-                              list: ValueRef,
-                              Ty: TypeRef,
-                              Name: *const c_char)
-                              -> ValueRef;
-        pub fn LLVMBuildExtractElement(B: BuilderRef,
-                                       VecVal: ValueRef,
-                                       Index: ValueRef,
-                                       Name: *const c_char)
-                                       -> ValueRef;
-        pub fn LLVMBuildInsertElement(B: BuilderRef,
-                                      VecVal: ValueRef,
-                                      EltVal: ValueRef,
-                                      Index: ValueRef,
-                                      Name: *const c_char)
-                                      -> ValueRef;
-        pub fn LLVMBuildShuffleVector(B: BuilderRef,
-                                      V1: ValueRef,
-                                      V2: ValueRef,
-                                      Mask: ValueRef,
-                                      Name: *const c_char)
-                                      -> ValueRef;
-        pub fn LLVMBuildExtractValue(B: BuilderRef,
-                                     AggVal: ValueRef,
-                                     Index: c_uint,
-                                     Name: *const c_char)
-                                     -> ValueRef;
-        pub fn LLVMBuildInsertValue(B: BuilderRef,
-                                    AggVal: ValueRef,
-                                    EltVal: ValueRef,
-                                    Index: c_uint,
-                                    Name: *const c_char)
-                                    -> ValueRef;
-
-        pub fn LLVMBuildIsNull(B: BuilderRef, Val: ValueRef, Name: *const c_char)
-                               -> ValueRef;
-        pub fn LLVMBuildIsNotNull(B: BuilderRef, Val: ValueRef, Name: *const c_char)
-                                  -> ValueRef;
-        pub fn LLVMBuildPtrDiff(B: BuilderRef,
-                                LHS: ValueRef,
-                                RHS: ValueRef,
-                                Name: *const c_char)
-                                -> ValueRef;
-
-        /* Atomic Operations */
-        pub fn LLVMBuildAtomicLoad(B: BuilderRef,
-                                   PointerVal: ValueRef,
-                                   Name: *const c_char,
-                                   Order: AtomicOrdering,
-                                   Alignment: c_uint)
-                                   -> ValueRef;
-
-        pub fn LLVMBuildAtomicStore(B: BuilderRef,
-                                    Val: ValueRef,
-                                    Ptr: ValueRef,
-                                    Order: AtomicOrdering,
-                                    Alignment: c_uint)
-                                    -> ValueRef;
-
-        pub fn LLVMBuildAtomicCmpXchg(B: BuilderRef,
-                                      LHS: ValueRef,
-                                      CMP: ValueRef,
-                                      RHS: ValueRef,
-                                      Order: AtomicOrdering,
-                                      FailureOrder: AtomicOrdering)
-                                      -> ValueRef;
-        pub fn LLVMBuildAtomicRMW(B: BuilderRef,
-                                  Op: AtomicBinOp,
-                                  LHS: ValueRef,
-                                  RHS: ValueRef,
-                                  Order: AtomicOrdering,
-                                  SingleThreaded: Bool)
-                                  -> ValueRef;
-
-        pub fn LLVMBuildAtomicFence(B: BuilderRef, Order: AtomicOrdering);
-
-
-        /* Selected entries from the downcasts. */
-        pub fn LLVMIsATerminatorInst(Inst: ValueRef) -> ValueRef;
-        pub fn LLVMIsAStoreInst(Inst: ValueRef) -> ValueRef;
-
-        /** Writes a module to the specified path. Returns 0 on success. */
-        pub fn LLVMWriteBitcodeToFile(M: ModuleRef, Path: *const c_char) -> c_int;
-
-        /** Creates target data from a target layout string. */
-        pub fn LLVMCreateTargetData(StringRep: *const 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);
-        /** Number of bytes clobbered when doing a Store to *T. */
-        pub fn LLVMStoreSizeOfType(TD: TargetDataRef, Ty: TypeRef)
-                                   -> c_ulonglong;
-
-        /** Number of bytes clobbered when doing a Store to *T. */
-        pub fn LLVMSizeOfTypeInBits(TD: TargetDataRef, Ty: TypeRef)
-                                    -> c_ulonglong;
-
-        /** Distance between successive elements in an array of T.
-        Includes ABI padding. */
-        pub fn LLVMABISizeOfType(TD: TargetDataRef, Ty: TypeRef) -> c_uint;
-
-        /** Returns the preferred alignment of a type. */
-        pub fn LLVMPreferredAlignmentOfType(TD: TargetDataRef, Ty: TypeRef)
-                                            -> c_uint;
-        /** Returns the minimum alignment of a type. */
-        pub fn LLVMABIAlignmentOfType(TD: TargetDataRef, Ty: TypeRef)
-                                      -> c_uint;
-
-        /// Computes the byte offset of the indexed struct element for a
-        /// target.
-        pub fn LLVMOffsetOfElement(TD: TargetDataRef,
-                                   StructTy: TypeRef,
-                                   Element: c_uint)
-                                   -> c_ulonglong;
-
-        /**
-         * Returns the minimum alignment of a type when part of a call frame.
-         */
-        pub fn LLVMCallFrameAlignmentOfType(TD: TargetDataRef, Ty: TypeRef)
-                                            -> c_uint;
-
-        /** Disposes target data. */
-        pub fn LLVMDisposeTargetData(TD: TargetDataRef);
-
-        /** Creates a pass manager. */
-        pub fn LLVMCreatePassManager() -> PassManagerRef;
-
-        /** Creates a function-by-function pass manager */
-        pub fn LLVMCreateFunctionPassManagerForModule(M: ModuleRef)
-                                                      -> PassManagerRef;
-
-        /** Disposes a pass manager. */
-        pub fn LLVMDisposePassManager(PM: PassManagerRef);
-
-        /** Runs a pass manager on a module. */
-        pub fn LLVMRunPassManager(PM: PassManagerRef, M: ModuleRef) -> Bool;
-
-        /** Runs the function passes on the provided function. */
-        pub fn LLVMRunFunctionPassManager(FPM: PassManagerRef, F: ValueRef)
-                                          -> Bool;
-
-        /** Initializes all the function passes scheduled in the manager */
-        pub fn LLVMInitializeFunctionPassManager(FPM: PassManagerRef) -> Bool;
-
-        /** Finalizes all the function passes scheduled in the manager */
-        pub fn LLVMFinalizeFunctionPassManager(FPM: PassManagerRef) -> Bool;
-
-        pub fn LLVMInitializePasses();
-
-        /** Adds a verification pass. */
-        pub fn LLVMAddVerifierPass(PM: PassManagerRef);
-
-        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);
-
-        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);
-
-        pub fn LLVMPassManagerBuilderPopulateFunctionPassManager(
-            PMB: PassManagerBuilderRef,
-            PM: PassManagerRef);
-        pub fn LLVMPassManagerBuilderPopulateLTOPassManager(
-            PMB: PassManagerBuilderRef,
-            PM: PassManagerRef,
-            Internalize: Bool,
-            RunInliner: Bool);
-
-        /** Destroys a memory buffer. */
-        pub fn LLVMDisposeMemoryBuffer(MemBuf: MemoryBufferRef);
-
-
-        /* Stuff that's in rustllvm/ because it's not upstream yet. */
-
-        /** Opens an object file. */
-        pub fn LLVMCreateObjectFile(MemBuf: MemoryBufferRef) -> ObjectFileRef;
-        /** Closes an object file. */
-        pub fn LLVMDisposeObjectFile(ObjFile: ObjectFileRef);
-
-        /** Enumerates the sections in an object file. */
-        pub fn LLVMGetSections(ObjFile: ObjectFileRef) -> SectionIteratorRef;
-        /** Destroys a section iterator. */
-        pub fn LLVMDisposeSectionIterator(SI: SectionIteratorRef);
-        /** Returns true if the section iterator is at the end of the section
-            list: */
-        pub fn LLVMIsSectionIteratorAtEnd(ObjFile: ObjectFileRef,
-                                          SI: SectionIteratorRef)
-                                          -> Bool;
-        /** Moves the section iterator to point to the next section. */
-        pub fn LLVMMoveToNextSection(SI: SectionIteratorRef);
-        /** Returns the current section size. */
-        pub fn LLVMGetSectionSize(SI: SectionIteratorRef) -> c_ulonglong;
-        /** Returns the current section contents as a string buffer. */
-        pub fn LLVMGetSectionContents(SI: SectionIteratorRef) -> *const c_char;
-
-        /** Reads the given file and returns it as a memory buffer. Use
-            LLVMDisposeMemoryBuffer() to get rid of it. */
-        pub fn LLVMRustCreateMemoryBufferWithContentsOfFile(Path: *const c_char)
-            -> MemoryBufferRef;
-        /** Borrows the contents of the memory buffer (doesn't copy it) */
-        pub fn LLVMCreateMemoryBufferWithMemoryRange(InputData: *const c_char,
-                                                     InputDataLength: size_t,
-                                                     BufferName: *const c_char,
-                                                     RequiresNull: Bool)
-            -> MemoryBufferRef;
-        pub fn LLVMCreateMemoryBufferWithMemoryRangeCopy(InputData: *const c_char,
-                                                         InputDataLength: size_t,
-                                                         BufferName: *const c_char)
-            -> MemoryBufferRef;
-
-        pub fn LLVMIsMultithreaded() -> Bool;
-        pub fn LLVMStartMultithreaded() -> Bool;
-
-        /** Returns a string describing the last error caused by an LLVMRust*
-            call. */
-        pub fn LLVMRustGetLastError() -> *const c_char;
-
-        /// Print the pass timings since static dtors aren't picking them up.
-        pub fn LLVMRustPrintPassTimings();
-
-        pub fn LLVMStructCreateNamed(C: ContextRef, Name: *const c_char) -> TypeRef;
-
-        pub fn LLVMStructSetBody(StructTy: TypeRef,
-                                 ElementTypes: *const TypeRef,
-                                 ElementCount: c_uint,
-                                 Packed: Bool);
-
-        pub fn LLVMConstNamedStruct(S: TypeRef,
-                                    ConstantVals: *const ValueRef,
-                                    Count: c_uint)
-                                    -> ValueRef;
-
-        /** Enables LLVM debug output. */
-        pub fn LLVMSetDebug(Enabled: c_int);
-
-        /** Prepares inline assembly. */
-        pub fn LLVMInlineAsm(Ty: TypeRef,
-                             AsmString: *const c_char,
-                             Constraints: *const c_char,
-                             SideEffects: Bool,
-                             AlignStack: Bool,
-                             Dialect: c_uint)
-                             -> ValueRef;
-
-        pub static LLVMRustDebugMetadataVersion: u32;
-
-        pub fn LLVMRustAddModuleFlag(M: ModuleRef,
-                                     name: *const c_char,
-                                     value: u32);
-
-        pub fn LLVMDIBuilderCreate(M: ModuleRef) -> DIBuilderRef;
-
-        pub fn LLVMDIBuilderDispose(Builder: DIBuilderRef);
-
-        pub fn LLVMDIBuilderFinalize(Builder: DIBuilderRef);
-
-        pub fn LLVMDIBuilderCreateCompileUnit(Builder: DIBuilderRef,
-                                              Lang: c_uint,
-                                              File: *const c_char,
-                                              Dir: *const c_char,
-                                              Producer: *const c_char,
-                                              isOptimized: bool,
-                                              Flags: *const c_char,
-                                              RuntimeVer: c_uint,
-                                              SplitName: *const c_char);
-
-        pub fn LLVMDIBuilderCreateFile(Builder: DIBuilderRef,
-                                       Filename: *const c_char,
-                                       Directory: *const c_char)
-                                       -> DIFile;
-
-        pub fn LLVMDIBuilderCreateSubroutineType(Builder: DIBuilderRef,
-                                                 File: DIFile,
-                                                 ParameterTypes: DIArray)
-                                                 -> DICompositeType;
-
-        pub fn LLVMDIBuilderCreateFunction(Builder: DIBuilderRef,
-                                           Scope: DIDescriptor,
-                                           Name: *const c_char,
-                                           LinkageName: *const 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: *const 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: *const c_char)
-                                              -> DIDerivedType;
-
-        pub fn LLVMDIBuilderCreateStructType(Builder: DIBuilderRef,
-                                             Scope: DIDescriptor,
-                                             Name: *const c_char,
-                                             File: DIFile,
-                                             LineNumber: c_uint,
-                                             SizeInBits: c_ulonglong,
-                                             AlignInBits: c_ulonglong,
-                                             Flags: c_uint,
-                                             DerivedFrom: DIType,
-                                             Elements: DIArray,
-                                             RunTimeLang: c_uint,
-                                             VTableHolder: ValueRef,
-                                             UniqueId: *const c_char)
-                                             -> DICompositeType;
-
-        pub fn LLVMDIBuilderCreateMemberType(Builder: DIBuilderRef,
-                                             Scope: DIDescriptor,
-                                             Name: *const 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,
-                                               Col: c_uint,
-                                               Discriminator: c_uint)
-                                               -> DILexicalBlock;
-
-        pub fn LLVMDIBuilderCreateStaticVariable(Builder: DIBuilderRef,
-                                                 Context: DIDescriptor,
-                                                 Name: *const c_char,
-                                                 LinkageName: *const c_char,
-                                                 File: DIFile,
-                                                 LineNo: c_uint,
-                                                 Ty: DIType,
-                                                 isLocalToUnit: bool,
-                                                 Val: ValueRef,
-                                                 Decl: ValueRef)
-                                                 -> DIGlobalVariable;
-
-        pub fn LLVMDIBuilderCreateLocalVariable(Builder: DIBuilderRef,
-                                                Tag: c_uint,
-                                                Scope: DIDescriptor,
-                                                Name: *const 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: *const DIDescriptor,
-                                             Count: c_uint)
-                                             -> DIArray;
-
-        pub fn LLVMDIBuilderInsertDeclareAtEnd(Builder: DIBuilderRef,
-                                               Val: ValueRef,
-                                               VarInfo: DIVariable,
-                                               InsertAtEnd: BasicBlockRef)
-                                               -> ValueRef;
-
-        pub fn LLVMDIBuilderInsertDeclareBefore(Builder: DIBuilderRef,
-                                                Val: ValueRef,
-                                                VarInfo: DIVariable,
-                                                InsertBefore: ValueRef)
-                                                -> ValueRef;
-
-        pub fn LLVMDIBuilderCreateEnumerator(Builder: DIBuilderRef,
-                                             Name: *const c_char,
-                                             Val: c_ulonglong)
-                                             -> ValueRef;
-
-        pub fn LLVMDIBuilderCreateEnumerationType(Builder: DIBuilderRef,
-                                                  Scope: ValueRef,
-                                                  Name: *const 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: *const c_char,
-                                            File: ValueRef,
-                                            LineNumber: c_uint,
-                                            SizeInBits: c_ulonglong,
-                                            AlignInBits: c_ulonglong,
-                                            Flags: c_uint,
-                                            Elements: ValueRef,
-                                            RunTimeLang: c_uint,
-                                            UniqueId: *const c_char)
-                                            -> ValueRef;
-
-        pub fn LLVMSetUnnamedAddr(GlobalVar: ValueRef, UnnamedAddr: Bool);
-
-        pub fn LLVMDIBuilderCreateTemplateTypeParameter(Builder: DIBuilderRef,
-                                                        Scope: ValueRef,
-                                                        Name: *const c_char,
-                                                        Ty: ValueRef,
-                                                        File: ValueRef,
-                                                        LineNo: c_uint,
-                                                        ColumnNo: c_uint)
-                                                        -> ValueRef;
-
-        pub fn LLVMDIBuilderCreateOpDeref(IntType: TypeRef) -> ValueRef;
-
-        pub fn LLVMDIBuilderCreateOpPlus(IntType: TypeRef) -> ValueRef;
-
-        pub fn LLVMDIBuilderCreateComplexVariable(Builder: DIBuilderRef,
-            Tag: c_uint,
-            Scope: ValueRef,
-            Name: *const c_char,
-            File: ValueRef,
-            LineNo: c_uint,
-            Ty: ValueRef,
-            AddrOps: *const ValueRef,
-            AddrOpsCount: c_uint,
-            ArgNo: c_uint)
-            -> ValueRef;
-
-        pub fn LLVMDIBuilderCreateNameSpace(Builder: DIBuilderRef,
-                                            Scope: ValueRef,
-                                            Name: *const c_char,
-                                            File: ValueRef,
-                                            LineNo: c_uint)
-                                            -> ValueRef;
-
-        pub fn LLVMDICompositeTypeSetTypeArray(CompositeType: ValueRef, TypeArray: ValueRef);
-        pub fn LLVMTypeToString(Type: TypeRef) -> *const c_char;
-        pub fn LLVMValueToString(value_ref: ValueRef) -> *const c_char;
-
-        pub fn LLVMIsAArgument(value_ref: ValueRef) -> ValueRef;
-
-        pub fn LLVMIsAAllocaInst(value_ref: ValueRef) -> ValueRef;
-
-        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: *const c_char) -> bool;
-        pub fn LLVMRustCreateTargetMachine(Triple: *const c_char,
-                                           CPU: *const c_char,
-                                           Features: *const c_char,
-                                           Model: CodeGenModel,
-                                           Reloc: RelocMode,
-                                           Level: CodeGenOptLevel,
-                                           EnableSegstk: bool,
-                                           UseSoftFP: bool,
-                                           NoFramePointerElim: bool,
-                                           FunctionSections: bool,
-                                           DataSections: bool) -> TargetMachineRef;
-        pub fn LLVMRustDisposeTargetMachine(T: TargetMachineRef);
-        pub fn LLVMRustAddAnalysisPasses(T: TargetMachineRef,
-                                         PM: PassManagerRef,
-                                         M: ModuleRef);
-        pub fn LLVMRustAddBuilderLibraryInfo(PMB: PassManagerBuilderRef,
-                                             M: ModuleRef,
-                                             DisableSimplifyLibCalls: bool);
-        pub fn LLVMRustAddLibraryInfo(PM: PassManagerRef, M: ModuleRef,
-                                      DisableSimplifyLibCalls: bool);
-        pub fn LLVMRustRunFunctionPassManager(PM: PassManagerRef, M: ModuleRef);
-        pub fn LLVMRustWriteOutputFile(T: TargetMachineRef,
-                                       PM: PassManagerRef,
-                                       M: ModuleRef,
-                                       Output: *const c_char,
-                                       FileType: FileType) -> bool;
-        pub fn LLVMRustPrintModule(PM: PassManagerRef,
-                                   M: ModuleRef,
-                                   Output: *const c_char);
-        pub fn LLVMRustSetLLVMOptions(Argc: c_int, Argv: *const *const c_char);
-        pub fn LLVMRustPrintPasses();
-        pub fn LLVMRustSetNormalizedTarget(M: ModuleRef, triple: *const c_char);
-        pub fn LLVMRustAddAlwaysInlinePass(P: PassManagerBuilderRef,
-                                           AddLifetimes: bool);
-        pub fn LLVMRustLinkInExternalBitcode(M: ModuleRef,
-                                             bc: *const c_char,
-                                             len: size_t) -> bool;
-        pub fn LLVMRustRunRestrictionPass(M: ModuleRef,
-                                          syms: *const *const c_char,
-                                          len: size_t);
-        pub fn LLVMRustMarkAllFunctionsNounwind(M: ModuleRef);
-
-        pub fn LLVMRustOpenArchive(path: *const c_char) -> ArchiveRef;
-        pub fn LLVMRustArchiveReadSection(AR: ArchiveRef, name: *const c_char,
-                                          out_len: *mut size_t) -> *const c_char;
-        pub fn LLVMRustDestroyArchive(AR: ArchiveRef);
-
-        pub fn LLVMRustSetDLLExportStorageClass(V: ValueRef);
-        pub fn LLVMVersionMajor() -> c_int;
-        pub fn LLVMVersionMinor() -> c_int;
-
-        pub fn LLVMRustGetSectionName(SI: SectionIteratorRef,
-                                      data: *mut *const c_char) -> c_int;
-    }
-}
-
-pub fn SetInstructionCallConv(instr: ValueRef, cc: CallConv) {
-    unsafe {
-        llvm::LLVMSetInstructionCallConv(instr, cc as c_uint);
-    }
-}
-pub fn SetFunctionCallConv(fn_: ValueRef, cc: CallConv) {
-    unsafe {
-        llvm::LLVMSetFunctionCallConv(fn_, cc as c_uint);
-    }
-}
-pub fn SetLinkage(global: ValueRef, link: Linkage) {
-    unsafe {
-        llvm::LLVMSetLinkage(global, link as c_uint);
-    }
-}
-
-pub fn SetUnnamedAddr(global: ValueRef, unnamed: bool) {
-    unsafe {
-        llvm::LLVMSetUnnamedAddr(global, unnamed as Bool);
-    }
-}
-
-pub fn set_thread_local(global: ValueRef, is_thread_local: bool) {
-    unsafe {
-        llvm::LLVMSetThreadLocal(global, is_thread_local as Bool);
-    }
-}
-
-pub fn ConstICmp(pred: IntPredicate, v1: ValueRef, v2: ValueRef) -> ValueRef {
-    unsafe {
-        llvm::LLVMConstICmp(pred as c_ushort, v1, v2)
-    }
-}
-pub fn ConstFCmp(pred: RealPredicate, v1: ValueRef, v2: ValueRef) -> ValueRef {
-    unsafe {
-        llvm::LLVMConstFCmp(pred as c_ushort, v1, v2)
-    }
-}
-
-pub fn SetFunctionAttribute(fn_: ValueRef, attr: Attribute) {
-    unsafe {
-        llvm::LLVMAddFunctionAttribute(fn_, FunctionIndex as c_uint, attr as uint64_t)
-    }
-}
-/* Memory-managed object interface to type handles. */
-
-pub struct TypeNames {
-    named_types: RefCell<HashMap<String, TypeRef>>,
-}
-
-impl TypeNames {
-    pub fn new() -> TypeNames {
-        TypeNames {
-            named_types: RefCell::new(HashMap::new())
-        }
-    }
-
-    pub fn associate_type(&self, s: &str, t: &Type) {
-        assert!(self.named_types.borrow_mut().insert(s.to_string(),
-                                                     t.to_ref()));
-    }
-
-    pub fn find_type(&self, s: &str) -> Option<Type> {
-        self.named_types.borrow().find_equiv(&s).map(|x| Type::from_ref(*x))
-    }
-
-    pub fn type_to_string(&self, ty: Type) -> String {
-        unsafe {
-            let s = llvm::LLVMTypeToString(ty.to_ref());
-            let ret = from_c_str(s);
-            free(s as *mut c_void);
-            ret.to_string()
-        }
-    }
-
-    pub fn types_to_str(&self, tys: &[Type]) -> String {
-        let strs: Vec<String> = tys.iter().map(|t| self.type_to_string(*t)).collect();
-        format!("[{}]", strs.connect(","))
-    }
-
-    pub fn val_to_string(&self, val: ValueRef) -> String {
-        unsafe {
-            let s = llvm::LLVMValueToString(val);
-            let ret = from_c_str(s);
-            free(s as *mut c_void);
-            ret.to_string()
-        }
-    }
-}
-
-/* Memory-managed interface to target data. */
-
-pub struct TargetData {
-    pub lltd: TargetDataRef
-}
-
-impl Drop for TargetData {
-    fn drop(&mut self) {
-        unsafe {
-            llvm::LLVMDisposeTargetData(self.lltd);
-        }
-    }
-}
-
-pub fn mk_target_data(string_rep: &str) -> TargetData {
-    TargetData {
-        lltd: string_rep.with_c_str(|buf| {
-            unsafe { llvm::LLVMCreateTargetData(buf) }
-        })
-    }
-}
-
-/* Memory-managed interface to object files. */
-
-pub struct ObjectFile {
-    pub llof: ObjectFileRef,
-}
-
-impl ObjectFile {
-    // This will take ownership of llmb
-    pub fn new(llmb: MemoryBufferRef) -> Option<ObjectFile> {
-        unsafe {
-            let llof = llvm::LLVMCreateObjectFile(llmb);
-            if llof as int == 0 {
-                // LLVMCreateObjectFile took ownership of llmb
-                return None
-            }
-
-            Some(ObjectFile {
-                llof: llof,
-            })
-        }
-    }
-}
-
-impl Drop for ObjectFile {
-    fn drop(&mut self) {
-        unsafe {
-            llvm::LLVMDisposeObjectFile(self.llof);
-        }
-    }
-}
-
-/* Memory-managed interface to section iterators. */
-
-pub struct SectionIter {
-    pub llsi: SectionIteratorRef
-}
-
-impl Drop for SectionIter {
-    fn drop(&mut self) {
-        unsafe {
-            llvm::LLVMDisposeSectionIterator(self.llsi);
-        }
-    }
-}
-
-pub fn mk_section_iter(llof: ObjectFileRef) -> SectionIter {
-    unsafe {
-        SectionIter {
-            llsi: llvm::LLVMGetSections(llof)
-        }
-    }
-}
diff --git a/src/librustc/lib/llvmdeps.rs b/src/librustc/lib/llvmdeps.rs
new file mode 100644
index 00000000000..05e5e585a63
--- /dev/null
+++ b/src/librustc/lib/llvmdeps.rs
@@ -0,0 +1,64 @@
+// Copyright 2013 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.
+
+// WARNING: THIS IS A GENERATED FILE, DO NOT MODIFY
+//          take a look at src/etc/mklldeps.py if you're interested
+
+#[cfg(target_arch = "x86_64", target_os = "linux")]
+#[link(name = "LLVMInstrumentation", kind = "static")]
+#[link(name = "LLVMInterpreter", kind = "static")]
+#[link(name = "LLVMMCJIT", kind = "static")]
+#[link(name = "LLVMRuntimeDyld", kind = "static")]
+#[link(name = "LLVMJIT", kind = "static")]
+#[link(name = "LLVMExecutionEngine", kind = "static")]
+#[link(name = "LLVMAsmParser", kind = "static")]
+#[link(name = "LLVMLinker", kind = "static")]
+#[link(name = "LLVMBitWriter", kind = "static")]
+#[link(name = "LLVMipo", kind = "static")]
+#[link(name = "LLVMVectorize", kind = "static")]
+#[link(name = "LLVMMipsDisassembler", kind = "static")]
+#[link(name = "LLVMMipsCodeGen", kind = "static")]
+#[link(name = "LLVMMipsAsmParser", kind = "static")]
+#[link(name = "LLVMMipsDesc", kind = "static")]
+#[link(name = "LLVMMipsInfo", kind = "static")]
+#[link(name = "LLVMMipsAsmPrinter", kind = "static")]
+#[link(name = "LLVMARMDisassembler", kind = "static")]
+#[link(name = "LLVMARMCodeGen", kind = "static")]
+#[link(name = "LLVMARMAsmParser", kind = "static")]
+#[link(name = "LLVMARMDesc", kind = "static")]
+#[link(name = "LLVMARMInfo", kind = "static")]
+#[link(name = "LLVMARMAsmPrinter", kind = "static")]
+#[link(name = "LLVMX86Disassembler", kind = "static")]
+#[link(name = "LLVMX86AsmParser", kind = "static")]
+#[link(name = "LLVMX86CodeGen", kind = "static")]
+#[link(name = "LLVMSelectionDAG", kind = "static")]
+#[link(name = "LLVMAsmPrinter", kind = "static")]
+#[link(name = "LLVMMCParser", kind = "static")]
+#[link(name = "LLVMCodeGen", kind = "static")]
+#[link(name = "LLVMScalarOpts", kind = "static")]
+#[link(name = "LLVMInstCombine", kind = "static")]
+#[link(name = "LLVMTransformUtils", kind = "static")]
+#[link(name = "LLVMipa", kind = "static")]
+#[link(name = "LLVMAnalysis", kind = "static")]
+#[link(name = "LLVMTarget", kind = "static")]
+#[link(name = "LLVMX86Desc", kind = "static")]
+#[link(name = "LLVMX86Info", kind = "static")]
+#[link(name = "LLVMX86AsmPrinter", kind = "static")]
+#[link(name = "LLVMMC", kind = "static")]
+#[link(name = "LLVMObject", kind = "static")]
+#[link(name = "LLVMBitReader", kind = "static")]
+#[link(name = "LLVMCore", kind = "static")]
+#[link(name = "LLVMX86Utils", kind = "static")]
+#[link(name = "LLVMSupport", kind = "static")]
+#[link(name = "pthread")]
+#[link(name = "dl")]
+#[link(name = "m")]
+#[link(name = "stdc++")]
+extern {}
diff --git a/src/librustc/metadata/loader.rs b/src/librustc/metadata/loader.rs
index 1b2349a271e..e7d52ef3b3d 100644
--- a/src/librustc/metadata/loader.rs
+++ b/src/librustc/metadata/loader.rs
@@ -212,10 +212,12 @@
 //! no means all of the necessary details. Take a look at the rest of
 //! metadata::loader or metadata::creader for all the juicy details!
 
-use back::archive::{ArchiveRO, METADATA_FILENAME};
+use back::archive::{METADATA_FILENAME};
 use back::svh::Svh;
 use driver::session::Session;
-use lib::llvm::{False, llvm, ObjectFile, mk_section_iter};
+use llvm;
+use llvm::{False, ObjectFile, mk_section_iter};
+use llvm::archive_ro::ArchiveRO;
 use metadata::cstore::{MetadataBlob, MetadataVec, MetadataArchive};
 use metadata::decoder;
 use metadata::encoder;
diff --git a/src/librustc/middle/trans/_match.rs b/src/librustc/middle/trans/_match.rs
index 3cfd1aaee8f..958d2cd3774 100644
--- a/src/librustc/middle/trans/_match.rs
+++ b/src/librustc/middle/trans/_match.rs
@@ -190,7 +190,8 @@
 
 use back::abi;
 use driver::config::FullDebugInfo;
-use lib::llvm::{llvm, ValueRef, BasicBlockRef};
+use llvm;
+use llvm::{ValueRef, BasicBlockRef};
 use middle::const_eval;
 use middle::def;
 use middle::check_match;
diff --git a/src/librustc/middle/trans/adt.rs b/src/librustc/middle/trans/adt.rs
index 898cb036ea5..3ee61b1d675 100644
--- a/src/librustc/middle/trans/adt.rs
+++ b/src/librustc/middle/trans/adt.rs
@@ -48,7 +48,7 @@
 use libc::c_ulonglong;
 use std::rc::Rc;
 
-use lib::llvm::{ValueRef, True, IntEQ, IntNE};
+use llvm::{ValueRef, True, IntEQ, IntNE};
 use middle::subst;
 use middle::subst::Subst;
 use middle::trans::_match;
diff --git a/src/librustc/middle/trans/asm.rs b/src/librustc/middle/trans/asm.rs
index 81bb50a83af..9760ef07a40 100644
--- a/src/librustc/middle/trans/asm.rs
+++ b/src/librustc/middle/trans/asm.rs
@@ -12,7 +12,7 @@
 # Translation of inline assembly.
 */
 
-use lib;
+use llvm;
 use middle::trans::build::*;
 use middle::trans::callee;
 use middle::trans::common::*;
@@ -99,8 +99,8 @@ pub fn trans_inline_asm<'a>(bcx: &'a Block<'a>, ia: &ast::InlineAsm)
     };
 
     let dialect = match ia.dialect {
-        ast::AsmAtt   => lib::llvm::AD_ATT,
-        ast::AsmIntel => lib::llvm::AD_Intel
+        ast::AsmAtt   => llvm::AD_ATT,
+        ast::AsmIntel => llvm::AD_Intel
     };
 
     let r = ia.asm.get().with_c_str(|a| {
diff --git a/src/librustc/middle/trans/base.rs b/src/librustc/middle/trans/base.rs
index 4d329ebd2a0..6bcc9b9b745 100644
--- a/src/librustc/middle/trans/base.rs
+++ b/src/librustc/middle/trans/base.rs
@@ -31,9 +31,9 @@ use driver::config;
 use driver::config::{NoDebugInfo, FullDebugInfo};
 use driver::session::Session;
 use driver::driver::{CrateAnalysis, CrateTranslation};
-use lib::llvm::{ModuleRef, ValueRef, BasicBlockRef};
-use lib::llvm::{llvm, Vector};
-use lib;
+use llvm;
+use llvm::{ModuleRef, ValueRef, BasicBlockRef};
+use llvm::{Vector};
 use metadata::{csearch, encoder, loader};
 use lint;
 use middle::astencode;
@@ -172,7 +172,7 @@ impl<'a> Drop for StatRecorder<'a> {
 }
 
 // only use this for foreign function ABIs and glue, use `decl_rust_fn` for Rust functions
-fn decl_fn(ccx: &CrateContext, name: &str, cc: lib::llvm::CallConv,
+fn decl_fn(ccx: &CrateContext, name: &str, cc: llvm::CallConv,
            ty: Type, output: ty::t) -> ValueRef {
 
     let llfn: ValueRef = name.with_c_str(|buf| {
@@ -186,16 +186,16 @@ fn decl_fn(ccx: &CrateContext, name: &str, cc: lib::llvm::CallConv,
         ty::ty_bot => {
             unsafe {
                 llvm::LLVMAddFunctionAttribute(llfn,
-                                               lib::llvm::FunctionIndex as c_uint,
-                                               lib::llvm::NoReturnAttribute as uint64_t)
+                                               llvm::FunctionIndex as c_uint,
+                                               llvm::NoReturnAttribute as uint64_t)
             }
         }
         _ => {}
     }
 
-    lib::llvm::SetFunctionCallConv(llfn, cc);
+    llvm::SetFunctionCallConv(llfn, cc);
     // Function addresses in Rust are never significant, allowing functions to be merged.
-    lib::llvm::SetUnnamedAddr(llfn, true);
+    llvm::SetUnnamedAddr(llfn, true);
 
     if ccx.is_split_stack_supported() {
         set_split_stack(llfn);
@@ -209,14 +209,14 @@ pub fn decl_cdecl_fn(ccx: &CrateContext,
                      name: &str,
                      ty: Type,
                      output: ty::t) -> ValueRef {
-    decl_fn(ccx, name, lib::llvm::CCallConv, ty, output)
+    decl_fn(ccx, name, llvm::CCallConv, ty, output)
 }
 
 // only use this for foreign function ABIs and glue, use `get_extern_rust_fn` for Rust functions
 pub fn get_extern_fn(ccx: &CrateContext,
                      externs: &mut ExternMap,
                      name: &str,
-                     cc: lib::llvm::CallConv,
+                     cc: llvm::CallConv,
                      ty: Type,
                      output: ty::t)
                      -> ValueRef {
@@ -253,7 +253,7 @@ pub fn decl_rust_fn(ccx: &CrateContext, fn_ty: ty::t, name: &str) -> ValueRef {
     };
 
     let llfty = type_of_rust_fn(ccx, has_env, inputs.as_slice(), output);
-    let llfn = decl_fn(ccx, name, lib::llvm::CCallConv, llfty, output);
+    let llfn = decl_fn(ccx, name, llvm::CCallConv, llfty, output);
     let attrs = get_fn_llvm_attributes(ccx, fn_ty);
     for &(idx, attr) in attrs.iter() {
         unsafe {
@@ -266,7 +266,7 @@ pub fn decl_rust_fn(ccx: &CrateContext, fn_ty: ty::t, name: &str) -> ValueRef {
 
 pub fn decl_internal_rust_fn(ccx: &CrateContext, fn_ty: ty::t, name: &str) -> ValueRef {
     let llfn = decl_rust_fn(ccx, fn_ty, name);
-    lib::llvm::SetLinkage(llfn, lib::llvm::InternalLinkage);
+    llvm::SetLinkage(llfn, llvm::InternalLinkage);
     llfn
 }
 
@@ -375,26 +375,26 @@ pub fn get_tydesc(ccx: &CrateContext, t: ty::t) -> Rc<tydesc_info> {
 
 #[allow(dead_code)] // useful
 pub fn set_optimize_for_size(f: ValueRef) {
-    lib::llvm::SetFunctionAttribute(f, lib::llvm::OptimizeForSizeAttribute)
+    llvm::SetFunctionAttribute(f, llvm::OptimizeForSizeAttribute)
 }
 
 pub fn set_no_inline(f: ValueRef) {
-    lib::llvm::SetFunctionAttribute(f, lib::llvm::NoInlineAttribute)
+    llvm::SetFunctionAttribute(f, llvm::NoInlineAttribute)
 }
 
 #[allow(dead_code)] // useful
 pub fn set_no_unwind(f: ValueRef) {
-    lib::llvm::SetFunctionAttribute(f, lib::llvm::NoUnwindAttribute)
+    llvm::SetFunctionAttribute(f, llvm::NoUnwindAttribute)
 }
 
 // Tell LLVM to emit the information necessary to unwind the stack for the
 // function f.
 pub fn set_uwtable(f: ValueRef) {
-    lib::llvm::SetFunctionAttribute(f, lib::llvm::UWTableAttribute)
+    llvm::SetFunctionAttribute(f, llvm::UWTableAttribute)
 }
 
 pub fn set_inline_hint(f: ValueRef) {
-    lib::llvm::SetFunctionAttribute(f, lib::llvm::InlineHintAttribute)
+    llvm::SetFunctionAttribute(f, llvm::InlineHintAttribute)
 }
 
 pub fn set_llvm_fn_attrs(attrs: &[ast::Attribute], llfn: ValueRef) {
@@ -415,25 +415,25 @@ pub fn set_llvm_fn_attrs(attrs: &[ast::Attribute], llfn: ValueRef) {
     if contains_name(attrs, "cold") {
         unsafe {
             llvm::LLVMAddFunctionAttribute(llfn,
-                                           lib::llvm::FunctionIndex as c_uint,
-                                           lib::llvm::ColdAttribute as uint64_t)
+                                           llvm::FunctionIndex as c_uint,
+                                           llvm::ColdAttribute as uint64_t)
         }
     }
 }
 
 pub fn set_always_inline(f: ValueRef) {
-    lib::llvm::SetFunctionAttribute(f, lib::llvm::AlwaysInlineAttribute)
+    llvm::SetFunctionAttribute(f, llvm::AlwaysInlineAttribute)
 }
 
 pub fn set_split_stack(f: ValueRef) {
     "split-stack".with_c_str(|buf| {
-        unsafe { llvm::LLVMAddFunctionAttrString(f, lib::llvm::FunctionIndex as c_uint, buf); }
+        unsafe { llvm::LLVMAddFunctionAttrString(f, llvm::FunctionIndex as c_uint, buf); }
     })
 }
 
 pub fn unset_split_stack(f: ValueRef) {
     "split-stack".with_c_str(|buf| {
-        unsafe { llvm::LLVMRemoveFunctionAttrString(f, lib::llvm::FunctionIndex as c_uint, buf); }
+        unsafe { llvm::LLVMRemoveFunctionAttrString(f, llvm::FunctionIndex as c_uint, buf); }
     })
 }
 
@@ -479,7 +479,7 @@ pub fn get_res_dtor(ccx: &CrateContext,
         get_extern_fn(ccx,
                       &mut *ccx.externs.borrow_mut(),
                       name.as_slice(),
-                      lib::llvm::CCallConv,
+                      llvm::CCallConv,
                       llty,
                       dtor_ty)
     }
@@ -546,36 +546,36 @@ pub fn compare_scalar_values<'a>(
       }
       floating_point => {
         let cmp = match op {
-          ast::BiEq => lib::llvm::RealOEQ,
-          ast::BiNe => lib::llvm::RealUNE,
-          ast::BiLt => lib::llvm::RealOLT,
-          ast::BiLe => lib::llvm::RealOLE,
-          ast::BiGt => lib::llvm::RealOGT,
-          ast::BiGe => lib::llvm::RealOGE,
+          ast::BiEq => llvm::RealOEQ,
+          ast::BiNe => llvm::RealUNE,
+          ast::BiLt => llvm::RealOLT,
+          ast::BiLe => llvm::RealOLE,
+          ast::BiGt => llvm::RealOGT,
+          ast::BiGe => llvm::RealOGE,
           _ => die(cx)
         };
         return FCmp(cx, cmp, lhs, rhs);
       }
       signed_int => {
         let cmp = match op {
-          ast::BiEq => lib::llvm::IntEQ,
-          ast::BiNe => lib::llvm::IntNE,
-          ast::BiLt => lib::llvm::IntSLT,
-          ast::BiLe => lib::llvm::IntSLE,
-          ast::BiGt => lib::llvm::IntSGT,
-          ast::BiGe => lib::llvm::IntSGE,
+          ast::BiEq => llvm::IntEQ,
+          ast::BiNe => llvm::IntNE,
+          ast::BiLt => llvm::IntSLT,
+          ast::BiLe => llvm::IntSLE,
+          ast::BiGt => llvm::IntSGT,
+          ast::BiGe => llvm::IntSGE,
           _ => die(cx)
         };
         return ICmp(cx, cmp, lhs, rhs);
       }
       unsigned_int => {
         let cmp = match op {
-          ast::BiEq => lib::llvm::IntEQ,
-          ast::BiNe => lib::llvm::IntNE,
-          ast::BiLt => lib::llvm::IntULT,
-          ast::BiLe => lib::llvm::IntULE,
-          ast::BiGt => lib::llvm::IntUGT,
-          ast::BiGe => lib::llvm::IntUGE,
+          ast::BiEq => llvm::IntEQ,
+          ast::BiNe => llvm::IntNE,
+          ast::BiLt => llvm::IntULT,
+          ast::BiLe => llvm::IntULE,
+          ast::BiGt => llvm::IntUGT,
+          ast::BiGe => llvm::IntUGE,
           _ => die(cx)
         };
         return ICmp(cx, cmp, lhs, rhs);
@@ -602,12 +602,12 @@ pub fn compare_simd_types(
         },
         ty::ty_uint(_) | ty::ty_int(_) => {
             let cmp = match op {
-                ast::BiEq => lib::llvm::IntEQ,
-                ast::BiNe => lib::llvm::IntNE,
-                ast::BiLt => lib::llvm::IntSLT,
-                ast::BiLe => lib::llvm::IntSLE,
-                ast::BiGt => lib::llvm::IntSGT,
-                ast::BiGe => lib::llvm::IntSGE,
+                ast::BiEq => llvm::IntEQ,
+                ast::BiNe => llvm::IntNE,
+                ast::BiLt => llvm::IntSLT,
+                ast::BiLe => llvm::IntSLE,
+                ast::BiGt => llvm::IntSGT,
+                ast::BiGe => llvm::IntSGE,
                 _ => cx.sess().bug("compare_simd_types: must be a comparison operator"),
             };
             let return_ty = Type::vector(&type_of(cx.ccx(), t), size as u64);
@@ -801,11 +801,11 @@ pub fn fail_if_zero_or_overflows<'a>(
     let (is_zero, is_signed) = match ty::get(rhs_t).sty {
         ty::ty_int(t) => {
             let zero = C_integral(Type::int_from_ty(cx.ccx(), t), 0u64, false);
-            (ICmp(cx, lib::llvm::IntEQ, rhs, zero), true)
+            (ICmp(cx, llvm::IntEQ, rhs, zero), true)
         }
         ty::ty_uint(t) => {
             let zero = C_integral(Type::uint_from_ty(cx.ccx(), t), 0u64, false);
-            (ICmp(cx, lib::llvm::IntEQ, rhs, zero), false)
+            (ICmp(cx, llvm::IntEQ, rhs, zero), false)
         }
         _ => {
             cx.sess().bug(format!("fail-if-zero on unexpected type: {}",
@@ -841,10 +841,10 @@ pub fn fail_if_zero_or_overflows<'a>(
             }
             _ => unreachable!(),
         };
-        let minus_one = ICmp(bcx, lib::llvm::IntEQ, rhs,
+        let minus_one = ICmp(bcx, llvm::IntEQ, rhs,
                              C_integral(llty, -1, false));
         with_cond(bcx, minus_one, |bcx| {
-            let is_min = ICmp(bcx, lib::llvm::IntEQ, lhs,
+            let is_min = ICmp(bcx, llvm::IntEQ, lhs,
                               C_integral(llty, min, true));
             with_cond(bcx, is_min, |bcx| {
                 controlflow::trans_fail(bcx, span,
@@ -975,11 +975,11 @@ pub fn load_ty(cx: &Block, ptr: ValueRef, t: ty::t) -> ValueRef {
     if type_is_zero_size(cx.ccx(), t) {
         C_undef(type_of::type_of(cx.ccx(), t))
     } else if ty::type_is_bool(t) {
-        Trunc(cx, LoadRangeAssert(cx, ptr, 0, 2, lib::llvm::False), Type::i1(cx.ccx()))
+        Trunc(cx, LoadRangeAssert(cx, ptr, 0, 2, llvm::False), Type::i1(cx.ccx()))
     } else if ty::type_is_char(t) {
         // a char is a unicode codepoint, and so takes values from 0
         // to 0x10FFFF inclusive only.
-        LoadRangeAssert(cx, ptr, 0, 0x10FFFF + 1, lib::llvm::False)
+        LoadRangeAssert(cx, ptr, 0, 0x10FFFF + 1, llvm::False)
     } else {
         Load(cx, ptr)
     }
@@ -1755,7 +1755,7 @@ fn finish_register_fn(ccx: &CrateContext, sp: Span, sym: String, node_id: ast::N
     ccx.item_symbols.borrow_mut().insert(node_id, sym);
 
     if !ccx.reachable.contains(&node_id) {
-        lib::llvm::SetLinkage(llfn, lib::llvm::InternalLinkage);
+        llvm::SetLinkage(llfn, llvm::InternalLinkage);
     }
 
     // The stack exhaustion lang item shouldn't have a split stack because
@@ -1764,10 +1764,10 @@ fn finish_register_fn(ccx: &CrateContext, sp: Span, sym: String, node_id: ast::N
     let def = ast_util::local_def(node_id);
     if ccx.tcx.lang_items.stack_exhausted() == Some(def) {
         unset_split_stack(llfn);
-        lib::llvm::SetLinkage(llfn, lib::llvm::ExternalLinkage);
+        llvm::SetLinkage(llfn, llvm::ExternalLinkage);
     }
     if ccx.tcx.lang_items.eh_personality() == Some(def) {
-        lib::llvm::SetLinkage(llfn, lib::llvm::ExternalLinkage);
+        llvm::SetLinkage(llfn, llvm::ExternalLinkage);
     }
 
 
@@ -1814,13 +1814,13 @@ pub fn get_fn_llvm_attributes(ccx: &CrateContext, fn_ty: ty::t) -> Vec<(uint, u6
     // implications directly to the call instruction. Right now,
     // the only attribute we need to worry about is `sret`.
     if type_of::return_uses_outptr(ccx, ret_ty) {
-        attrs.push((1, lib::llvm::StructRetAttribute as u64));
+        attrs.push((1, llvm::StructRetAttribute as u64));
 
         // The outptr can be noalias and nocapture because it's entirely
         // invisible to the program. We can also mark it as nonnull
-        attrs.push((1, lib::llvm::NoAliasAttribute as u64));
-        attrs.push((1, lib::llvm::NoCaptureAttribute as u64));
-        attrs.push((1, lib::llvm::NonNullAttribute as u64));
+        attrs.push((1, llvm::NoAliasAttribute as u64));
+        attrs.push((1, llvm::NoCaptureAttribute as u64));
+        attrs.push((1, llvm::NonNullAttribute as u64));
 
         // Add one more since there's an outptr
         first_arg_offset += 1;
@@ -1834,7 +1834,7 @@ pub fn get_fn_llvm_attributes(ccx: &CrateContext, fn_ty: ty::t) -> Vec<(uint, u6
                 ty::ty_str | ty::ty_vec(..) | ty::ty_trait(..) => true, _ => false
             } => {}
             ty::ty_uniq(_) => {
-                attrs.push((lib::llvm::ReturnIndex as uint, lib::llvm::NoAliasAttribute as u64));
+                attrs.push((llvm::ReturnIndex as uint, llvm::NoAliasAttribute as u64));
             }
             _ => {}
         }
@@ -1847,14 +1847,14 @@ pub fn get_fn_llvm_attributes(ccx: &CrateContext, fn_ty: ty::t) -> Vec<(uint, u6
                 ty::ty_str | ty::ty_vec(..) | ty::ty_trait(..) => true, _ => false
             } => {}
             ty::ty_uniq(_) | ty::ty_rptr(_, _) => {
-                attrs.push((lib::llvm::ReturnIndex as uint, lib::llvm::NonNullAttribute as u64));
+                attrs.push((llvm::ReturnIndex as uint, llvm::NonNullAttribute as u64));
             }
             _ => {}
         }
 
         match ty::get(ret_ty).sty {
             ty::ty_bool => {
-                attrs.push((lib::llvm::ReturnIndex as uint, lib::llvm::ZExtAttribute as u64));
+                attrs.push((llvm::ReturnIndex as uint, llvm::ZExtAttribute as u64));
             }
             _ => {}
         }
@@ -1867,25 +1867,25 @@ pub fn get_fn_llvm_attributes(ccx: &CrateContext, fn_ty: ty::t) -> Vec<(uint, u6
                 // For non-immediate arguments the callee gets its own copy of
                 // the value on the stack, so there are no aliases. It's also
                 // program-invisible so can't possibly capture
-                attrs.push((idx, lib::llvm::NoAliasAttribute as u64));
-                attrs.push((idx, lib::llvm::NoCaptureAttribute as u64));
-                attrs.push((idx, lib::llvm::NonNullAttribute as u64));
+                attrs.push((idx, llvm::NoAliasAttribute as u64));
+                attrs.push((idx, llvm::NoCaptureAttribute as u64));
+                attrs.push((idx, llvm::NonNullAttribute as u64));
             }
             ty::ty_bool => {
-                attrs.push((idx, lib::llvm::ZExtAttribute as u64));
+                attrs.push((idx, llvm::ZExtAttribute as u64));
             }
             // `~` pointer parameters never alias because ownership is transferred
             ty::ty_uniq(_) => {
-                attrs.push((idx, lib::llvm::NoAliasAttribute as u64));
-                attrs.push((idx, lib::llvm::NonNullAttribute as u64));
+                attrs.push((idx, llvm::NoAliasAttribute as u64));
+                attrs.push((idx, llvm::NonNullAttribute as u64));
             }
             // `&mut` pointer parameters never alias other parameters, or mutable global data
             ty::ty_rptr(b, mt) if mt.mutbl == ast::MutMutable => {
-                attrs.push((idx, lib::llvm::NoAliasAttribute as u64));
-                attrs.push((idx, lib::llvm::NonNullAttribute as u64));
+                attrs.push((idx, llvm::NoAliasAttribute as u64));
+                attrs.push((idx, llvm::NonNullAttribute as u64));
                 match b {
                     ReLateBound(_, BrAnon(_)) => {
-                        attrs.push((idx, lib::llvm::NoCaptureAttribute as u64));
+                        attrs.push((idx, llvm::NoCaptureAttribute as u64));
                     }
                     _ => {}
                 }
@@ -1893,12 +1893,12 @@ pub fn get_fn_llvm_attributes(ccx: &CrateContext, fn_ty: ty::t) -> Vec<(uint, u6
             // When a reference in an argument has no named lifetime, it's impossible for that
             // reference to escape this function (returned or stored beyond the call by a closure).
             ty::ty_rptr(ReLateBound(_, BrAnon(_)), _) => {
-                attrs.push((idx, lib::llvm::NoCaptureAttribute as u64));
-                attrs.push((idx, lib::llvm::NonNullAttribute as u64));
+                attrs.push((idx, llvm::NoCaptureAttribute as u64));
+                attrs.push((idx, llvm::NonNullAttribute as u64));
             }
             // & pointer parameters are never null
             ty::ty_rptr(_, _) => {
-                attrs.push((idx, lib::llvm::NonNullAttribute as u64));
+                attrs.push((idx, llvm::NonNullAttribute as u64));
             }
             _ => ()
         }
@@ -1912,7 +1912,7 @@ pub fn register_fn_llvmty(ccx: &CrateContext,
                           sp: Span,
                           sym: String,
                           node_id: ast::NodeId,
-                          cc: lib::llvm::CallConv,
+                          cc: llvm::CallConv,
                           llfty: Type) -> ValueRef {
     debug!("register_fn_llvmty id={} sym={}", node_id, sym);
 
@@ -2073,7 +2073,7 @@ pub fn get_item_val(ccx: &CrateContext, id: ast::NodeId) -> ValueRef {
                         });
 
                         if !ccx.reachable.contains(&id) {
-                            lib::llvm::SetLinkage(g, lib::llvm::InternalLinkage);
+                            llvm::SetLinkage(g, llvm::InternalLinkage);
                         }
 
                         // Apply the `unnamed_addr` attribute if
@@ -2081,7 +2081,7 @@ pub fn get_item_val(ccx: &CrateContext, id: ast::NodeId) -> ValueRef {
                         if !ast_util::static_has_significant_address(
                                 mutbl,
                                 i.attrs.as_slice()) {
-                            lib::llvm::SetUnnamedAddr(g, true);
+                            llvm::SetUnnamedAddr(g, true);
 
                             // This is a curious case where we must make
                             // all of these statics inlineable. If a
@@ -2103,7 +2103,7 @@ pub fn get_item_val(ccx: &CrateContext, id: ast::NodeId) -> ValueRef {
 
                         if attr::contains_name(i.attrs.as_slice(),
                                                "thread_local") {
-                            lib::llvm::set_thread_local(g, true);
+                            llvm::set_thread_local(g, true);
                         }
 
                         if !inlineable {
@@ -2241,7 +2241,7 @@ pub fn get_item_val(ccx: &CrateContext, id: ast::NodeId) -> ValueRef {
     // linkage b/c that doesn't quite make sense. Otherwise items can
     // have internal linkage if they're not reachable.
     if !foreign && !ccx.reachable.contains(&id) {
-        lib::llvm::SetLinkage(val, lib::llvm::InternalLinkage);
+        llvm::SetLinkage(val, llvm::InternalLinkage);
     }
 
     ccx.item_vals.borrow_mut().insert(id, val);
diff --git a/src/librustc/middle/trans/basic_block.rs b/src/librustc/middle/trans/basic_block.rs
index 303ad5fbce2..13b8ed4df6b 100644
--- a/src/librustc/middle/trans/basic_block.rs
+++ b/src/librustc/middle/trans/basic_block.rs
@@ -8,7 +8,8 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-use lib::llvm::{llvm, BasicBlockRef};
+use llvm;
+use llvm::{BasicBlockRef};
 use middle::trans::value::{Users, Value};
 use std::iter::{Filter, Map};
 
diff --git a/src/librustc/middle/trans/build.rs b/src/librustc/middle/trans/build.rs
index ce11cd24f7b..995ad16b59f 100644
--- a/src/librustc/middle/trans/build.rs
+++ b/src/librustc/middle/trans/build.rs
@@ -11,11 +11,10 @@
 #![allow(dead_code)] // FFI wrappers
 #![allow(non_snake_case_functions)]
 
-use lib::llvm::llvm;
-use lib::llvm::{CallConv, AtomicBinOp, AtomicOrdering, AsmDialect};
-use lib::llvm::{Opcode, IntPredicate, RealPredicate};
-use lib::llvm::{ValueRef, BasicBlockRef};
-use lib;
+use llvm;
+use llvm::{CallConv, AtomicBinOp, AtomicOrdering, AsmDialect};
+use llvm::{Opcode, IntPredicate, RealPredicate};
+use llvm::{ValueRef, BasicBlockRef};
 use middle::trans::common::*;
 use syntax::codemap::Span;
 
@@ -97,7 +96,7 @@ pub fn Switch(cx: &Block, v: ValueRef, else_: BasicBlockRef, num_cases: uint)
 
 pub fn AddCase(s: ValueRef, on_val: ValueRef, dest: BasicBlockRef) {
     unsafe {
-        if llvm::LLVMIsUndef(s) == lib::llvm::True { return; }
+        if llvm::LLVMIsUndef(s) == llvm::True { return; }
         llvm::LLVMAddCase(s, on_val, dest);
     }
 }
@@ -350,7 +349,7 @@ pub fn Load(cx: &Block, pointer_val: ValueRef) -> ValueRef {
         let ccx = cx.fcx.ccx;
         if cx.unreachable.get() {
             let ty = val_ty(pointer_val);
-            let eltty = if ty.kind() == lib::llvm::Array {
+            let eltty = if ty.kind() == llvm::Array {
                 ty.element_type()
             } else {
                 ccx.int_type
@@ -382,11 +381,11 @@ pub fn AtomicLoad(cx: &Block, pointer_val: ValueRef, order: AtomicOrdering) -> V
 
 
 pub fn LoadRangeAssert(cx: &Block, pointer_val: ValueRef, lo: c_ulonglong,
-                       hi: c_ulonglong, signed: lib::llvm::Bool) -> ValueRef {
+                       hi: c_ulonglong, signed: llvm::Bool) -> ValueRef {
     if cx.unreachable.get() {
         let ccx = cx.fcx.ccx;
         let ty = val_ty(pointer_val);
-        let eltty = if ty.kind() == lib::llvm::Array {
+        let eltty = if ty.kind() == llvm::Array {
             ty.element_type()
         } else {
             ccx.int_type
@@ -647,7 +646,7 @@ pub fn Phi(cx: &Block, ty: Type, vals: &[ValueRef],
 
 pub fn AddIncomingToPhi(phi: ValueRef, val: ValueRef, bb: BasicBlockRef) {
     unsafe {
-        if llvm::LLVMIsUndef(phi) == lib::llvm::True { return; }
+        if llvm::LLVMIsUndef(phi) == llvm::True { return; }
         llvm::LLVMAddIncoming(phi, &val, &bb, 1 as c_uint);
     }
 }
@@ -656,7 +655,7 @@ pub fn _UndefReturn(cx: &Block, fn_: ValueRef) -> ValueRef {
     unsafe {
         let ccx = cx.fcx.ccx;
         let ty = val_ty(fn_);
-        let retty = if ty.kind() == lib::llvm::Integer {
+        let retty = if ty.kind() == llvm::Integer {
             ty.return_type()
         } else {
             ccx.int_type
diff --git a/src/librustc/middle/trans/builder.rs b/src/librustc/middle/trans/builder.rs
index 3a9e3e4cf9b..32e91c337f0 100644
--- a/src/librustc/middle/trans/builder.rs
+++ b/src/librustc/middle/trans/builder.rs
@@ -10,11 +10,10 @@
 
 #![allow(dead_code)] // FFI wrappers
 
-use lib;
-use lib::llvm::llvm;
-use lib::llvm::{CallConv, AtomicBinOp, AtomicOrdering, AsmDialect};
-use lib::llvm::{Opcode, IntPredicate, RealPredicate, False};
-use lib::llvm::{ValueRef, BasicBlockRef, BuilderRef, ModuleRef};
+use llvm;
+use llvm::{CallConv, AtomicBinOp, AtomicOrdering, AsmDialect};
+use llvm::{Opcode, IntPredicate, RealPredicate, False};
+use llvm::{ValueRef, BasicBlockRef, BuilderRef, ModuleRef};
 use middle::trans::base;
 use middle::trans::common::*;
 use middle::trans::machine::llalign_of_pref;
@@ -460,7 +459,7 @@ impl<'a> Builder<'a> {
         self.count_insn("load.volatile");
         unsafe {
             let insn = llvm::LLVMBuildLoad(self.llbuilder, ptr, noname());
-            llvm::LLVMSetVolatile(insn, lib::llvm::True);
+            llvm::LLVMSetVolatile(insn, llvm::True);
             insn
         }
     }
@@ -477,7 +476,7 @@ impl<'a> Builder<'a> {
 
 
     pub fn load_range_assert(&self, ptr: ValueRef, lo: c_ulonglong,
-                           hi: c_ulonglong, signed: lib::llvm::Bool) -> ValueRef {
+                           hi: c_ulonglong, signed: llvm::Bool) -> ValueRef {
         let value = self.load(ptr);
 
         unsafe {
@@ -487,7 +486,7 @@ impl<'a> Builder<'a> {
 
             let v = [min, max];
 
-            llvm::LLVMSetMetadata(value, lib::llvm::MD_range as c_uint,
+            llvm::LLVMSetMetadata(value, llvm::MD_range as c_uint,
                                   llvm::LLVMMDNodeInContext(self.ccx.llcx,
                                                             v.as_ptr(), v.len() as c_uint));
         }
@@ -514,7 +513,7 @@ impl<'a> Builder<'a> {
         self.count_insn("store.volatile");
         unsafe {
             let insn = llvm::LLVMBuildStore(self.llbuilder, val, ptr);
-            llvm::LLVMSetVolatile(insn, lib::llvm::True);
+            llvm::LLVMSetVolatile(insn, llvm::True);
         }
     }
 
@@ -788,10 +787,10 @@ impl<'a> Builder<'a> {
                          dia: AsmDialect) -> ValueRef {
         self.count_insn("inlineasm");
 
-        let volatile = if volatile { lib::llvm::True }
-                       else        { lib::llvm::False };
-        let alignstack = if alignstack { lib::llvm::True }
-                         else          { lib::llvm::False };
+        let volatile = if volatile { llvm::True }
+                       else        { llvm::False };
+        let alignstack = if alignstack { llvm::True }
+                         else          { llvm::False };
 
         let argtys = inputs.iter().map(|v| {
             debug!("Asm Input Type: {:?}", self.ccx.tn.val_to_string(*v));
@@ -832,7 +831,7 @@ impl<'a> Builder<'a> {
                           conv: CallConv, attributes: &[(uint, u64)]) -> ValueRef {
         self.count_insn("callwithconv");
         let v = self.call(llfn, args, attributes);
-        lib::llvm::SetInstructionCallConv(v, conv);
+        llvm::SetInstructionCallConv(v, conv);
         v
     }
 
@@ -945,7 +944,7 @@ impl<'a> Builder<'a> {
     pub fn set_cleanup(&self, landing_pad: ValueRef) {
         self.count_insn("setcleanup");
         unsafe {
-            llvm::LLVMSetCleanup(landing_pad, lib::llvm::True);
+            llvm::LLVMSetCleanup(landing_pad, llvm::True);
         }
     }
 
diff --git a/src/librustc/middle/trans/cabi.rs b/src/librustc/middle/trans/cabi.rs
index df1347f6d8f..0a10fb8b172 100644
--- a/src/librustc/middle/trans/cabi.rs
+++ b/src/librustc/middle/trans/cabi.rs
@@ -8,7 +8,7 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-use lib::llvm::Attribute;
+use llvm::Attribute;
 use std::option;
 use middle::trans::context::CrateContext;
 use middle::trans::cabi_x86;
diff --git a/src/librustc/middle/trans/cabi_arm.rs b/src/librustc/middle/trans/cabi_arm.rs
index c44a4e02ad4..0e2bf2104fd 100644
--- a/src/librustc/middle/trans/cabi_arm.rs
+++ b/src/librustc/middle/trans/cabi_arm.rs
@@ -10,8 +10,9 @@
 
 #![allow(non_uppercase_pattern_statics)]
 
-use lib::llvm::{llvm, Integer, Pointer, Float, Double, Struct, Array};
-use lib::llvm::{StructRetAttribute, ZExtAttribute};
+use llvm;
+use llvm::{Integer, Pointer, Float, Double, Struct, Array};
+use llvm::{StructRetAttribute, ZExtAttribute};
 use middle::trans::cabi::{FnType, ArgType};
 use middle::trans::context::CrateContext;
 use middle::trans::type_::Type;
diff --git a/src/librustc/middle/trans/cabi_mips.rs b/src/librustc/middle/trans/cabi_mips.rs
index 9e5b38d2f7d..d0709068687 100644
--- a/src/librustc/middle/trans/cabi_mips.rs
+++ b/src/librustc/middle/trans/cabi_mips.rs
@@ -12,8 +12,9 @@
 
 use libc::c_uint;
 use std::cmp;
-use lib::llvm::{llvm, Integer, Pointer, Float, Double, Struct, Array};
-use lib::llvm::{StructRetAttribute, ZExtAttribute};
+use llvm;
+use llvm::{Integer, Pointer, Float, Double, Struct, Array};
+use llvm::{StructRetAttribute, ZExtAttribute};
 use middle::trans::context::CrateContext;
 use middle::trans::cabi::*;
 use middle::trans::type_::Type;
diff --git a/src/librustc/middle/trans/cabi_x86.rs b/src/librustc/middle/trans/cabi_x86.rs
index 0d88c611cba..6bb3d992f50 100644
--- a/src/librustc/middle/trans/cabi_x86.rs
+++ b/src/librustc/middle/trans/cabi_x86.rs
@@ -10,7 +10,7 @@
 
 
 use syntax::abi::{OsWin32, OsMacos, OsiOS};
-use lib::llvm::*;
+use llvm::*;
 use super::cabi::*;
 use super::common::*;
 use super::machine::*;
diff --git a/src/librustc/middle/trans/cabi_x86_64.rs b/src/librustc/middle/trans/cabi_x86_64.rs
index 5b8ddfe1be7..493aca0ddf0 100644
--- a/src/librustc/middle/trans/cabi_x86_64.rs
+++ b/src/librustc/middle/trans/cabi_x86_64.rs
@@ -13,9 +13,10 @@
 
 #![allow(non_uppercase_pattern_statics)]
 
-use lib::llvm::{llvm, Integer, Pointer, Float, Double};
-use lib::llvm::{Struct, Array, Attribute};
-use lib::llvm::{StructRetAttribute, ByValAttribute, ZExtAttribute};
+use llvm;
+use llvm::{Integer, Pointer, Float, Double};
+use llvm::{Struct, Array, Attribute};
+use llvm::{StructRetAttribute, ByValAttribute, ZExtAttribute};
 use middle::trans::cabi::*;
 use middle::trans::context::CrateContext;
 use middle::trans::type_::Type;
diff --git a/src/librustc/middle/trans/callee.rs b/src/librustc/middle/trans/callee.rs
index 15415620c5b..db2d17c85db 100644
--- a/src/librustc/middle/trans/callee.rs
+++ b/src/librustc/middle/trans/callee.rs
@@ -19,8 +19,8 @@
 use arena::TypedArena;
 use back::abi;
 use back::link;
-use lib::llvm::ValueRef;
-use lib::llvm::llvm;
+use llvm;
+use llvm::ValueRef;
 use metadata::csearch;
 use middle::def;
 use middle::subst;
diff --git a/src/librustc/middle/trans/cleanup.rs b/src/librustc/middle/trans/cleanup.rs
index 0485b100446..6e40445d8f9 100644
--- a/src/librustc/middle/trans/cleanup.rs
+++ b/src/librustc/middle/trans/cleanup.rs
@@ -13,7 +13,7 @@
  * drop glue. See discussion in `doc.rs` for a high-level summary.
  */
 
-use lib::llvm::{BasicBlockRef, ValueRef};
+use llvm::{BasicBlockRef, ValueRef};
 use middle::trans::base;
 use middle::trans::build;
 use middle::trans::callee;
diff --git a/src/librustc/middle/trans/closure.rs b/src/librustc/middle/trans/closure.rs
index ef147eb22b5..f2400f6bfef 100644
--- a/src/librustc/middle/trans/closure.rs
+++ b/src/librustc/middle/trans/closure.rs
@@ -12,7 +12,7 @@
 use back::abi;
 use back::link::mangle_internal_name_by_path_and_seq;
 use driver::config::FullDebugInfo;
-use lib::llvm::ValueRef;
+use llvm::ValueRef;
 use middle::def;
 use middle::freevars;
 use middle::lang_items::ClosureExchangeMallocFnLangItem;
diff --git a/src/librustc/middle/trans/common.rs b/src/librustc/middle/trans/common.rs
index 23a391cb86d..945185f5953 100644
--- a/src/librustc/middle/trans/common.rs
+++ b/src/librustc/middle/trans/common.rs
@@ -13,10 +13,9 @@
 //! Code that is useful in various trans modules.
 
 use driver::session::Session;
-use lib::llvm::{ValueRef, BasicBlockRef, BuilderRef};
-use lib::llvm::{True, False, Bool};
-use lib::llvm::llvm;
-use lib;
+use llvm;
+use llvm::{ValueRef, BasicBlockRef, BuilderRef};
+use llvm::{True, False, Bool};
 use middle::def;
 use middle::lang_items::LangItem;
 use middle::subst;
@@ -570,7 +569,7 @@ pub fn C_cstr(cx: &CrateContext, s: InternedString, null_terminated: bool) -> Va
         });
         llvm::LLVMSetInitializer(g, sc);
         llvm::LLVMSetGlobalConstant(g, True);
-        lib::llvm::SetLinkage(g, lib::llvm::InternalLinkage);
+        llvm::SetLinkage(g, llvm::InternalLinkage);
 
         cx.const_cstr_cache.borrow_mut().insert(s, g);
         g
@@ -599,7 +598,7 @@ pub fn C_binary_slice(cx: &CrateContext, data: &[u8]) -> ValueRef {
         });
         llvm::LLVMSetInitializer(g, lldata);
         llvm::LLVMSetGlobalConstant(g, True);
-        lib::llvm::SetLinkage(g, lib::llvm::InternalLinkage);
+        llvm::SetLinkage(g, llvm::InternalLinkage);
 
         let cs = llvm::LLVMConstPointerCast(g, Type::i8p(cx).to_ref());
         C_struct(cx, [cs, C_uint(cx, len)], false)
diff --git a/src/librustc/middle/trans/consts.rs b/src/librustc/middle/trans/consts.rs
index 11a8207f8c4..2fd468d8fda 100644
--- a/src/librustc/middle/trans/consts.rs
+++ b/src/librustc/middle/trans/consts.rs
@@ -10,9 +10,10 @@
 
 
 use back::abi;
-use lib::llvm::{llvm, ConstFCmp, ConstICmp, SetLinkage, PrivateLinkage, ValueRef, Bool, True,
+use llvm;
+use llvm::{ConstFCmp, ConstICmp, SetLinkage, PrivateLinkage, ValueRef, Bool, True,
     False};
-use lib::llvm::{IntEQ, IntNE, IntUGT, IntUGE, IntULT, IntULE, IntSGT, IntSGE, IntSLT, IntSLE,
+use llvm::{IntEQ, IntNE, IntUGT, IntUGE, IntULT, IntULE, IntSGT, IntSGE, IntSLT, IntSLE,
     RealOEQ, RealOGT, RealOGE, RealOLT, RealOLE, RealONE};
 
 use metadata::csearch;
diff --git a/src/librustc/middle/trans/context.rs b/src/librustc/middle/trans/context.rs
index 6387ec791ba..8c55f33a0d4 100644
--- a/src/librustc/middle/trans/context.rs
+++ b/src/librustc/middle/trans/context.rs
@@ -10,9 +10,10 @@
 
 use driver::config::NoDebugInfo;
 use driver::session::Session;
-use lib::llvm::{ContextRef, ModuleRef, ValueRef};
-use lib::llvm::{llvm, TargetData, TypeNames};
-use lib::llvm::mk_target_data;
+use llvm;
+use llvm::{ContextRef, ModuleRef, ValueRef};
+use llvm::{TargetData};
+use llvm::mk_target_data;
 use metadata::common::LinkMeta;
 use middle::resolve;
 use middle::trans::adt;
@@ -21,7 +22,7 @@ use middle::trans::builder::Builder;
 use middle::trans::common::{ExternMap,tydesc_info,BuilderRef_res};
 use middle::trans::debuginfo;
 use middle::trans::monomorphize::MonoId;
-use middle::trans::type_::Type;
+use middle::trans::type_::{Type, TypeNames};
 use middle::ty;
 use util::sha2::Sha256;
 use util::nodemap::{NodeMap, NodeSet, DefIdMap};
diff --git a/src/librustc/middle/trans/controlflow.rs b/src/librustc/middle/trans/controlflow.rs
index acc44d08d3c..845684bb037 100644
--- a/src/librustc/middle/trans/controlflow.rs
+++ b/src/librustc/middle/trans/controlflow.rs
@@ -8,7 +8,7 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-use lib::llvm::*;
+use llvm::*;
 use driver::config::FullDebugInfo;
 use middle::def;
 use middle::lang_items::{FailFnLangItem, FailBoundsCheckFnLangItem};
diff --git a/src/librustc/middle/trans/datum.rs b/src/librustc/middle/trans/datum.rs
index b65f5a5c7d6..d4b2b04745b 100644
--- a/src/librustc/middle/trans/datum.rs
+++ b/src/librustc/middle/trans/datum.rs
@@ -13,7 +13,7 @@
  * Datums are and how they are intended to be used.
  */
 
-use lib::llvm::ValueRef;
+use llvm::ValueRef;
 use middle::trans::base::*;
 use middle::trans::common::*;
 use middle::trans::cleanup;
diff --git a/src/librustc/middle/trans/debuginfo.rs b/src/librustc/middle/trans/debuginfo.rs
index e3af8f93ead..6e81c10c4a0 100644
--- a/src/librustc/middle/trans/debuginfo.rs
+++ b/src/librustc/middle/trans/debuginfo.rs
@@ -180,9 +180,9 @@ seen before (which is most of the time). */
 
 use driver::config;
 use driver::config::{FullDebugInfo, LimitedDebugInfo, NoDebugInfo};
-use lib::llvm::llvm;
-use lib::llvm::{ModuleRef, ContextRef, ValueRef};
-use lib::llvm::debuginfo::*;
+use llvm;
+use llvm::{ModuleRef, ContextRef, ValueRef};
+use llvm::debuginfo::*;
 use metadata::csearch;
 use middle::subst;
 use middle::trans::adt;
diff --git a/src/librustc/middle/trans/expr.rs b/src/librustc/middle/trans/expr.rs
index 516c46564cd..60bf80191cb 100644
--- a/src/librustc/middle/trans/expr.rs
+++ b/src/librustc/middle/trans/expr.rs
@@ -34,8 +34,8 @@
 #![allow(non_camel_case_types)]
 
 use back::abi;
-use lib::llvm::{ValueRef, llvm};
-use lib;
+use llvm;
+use llvm::{ValueRef};
 use metadata::csearch;
 use middle::def;
 use middle::lang_items::MallocFnLangItem;
@@ -548,7 +548,7 @@ fn trans_index<'a>(bcx: &'a Block<'a>,
             debug!("trans_index: base {}", bcx.val_to_string(base));
             debug!("trans_index: len {}", bcx.val_to_string(len));
 
-            let bounds_check = ICmp(bcx, lib::llvm::IntUGE, ix_val, len);
+            let bounds_check = ICmp(bcx, llvm::IntUGE, ix_val, len);
             let expect = ccx.get_intrinsic(&("llvm.expect.i1"));
             let expected = Call(bcx,
                                 expect,
diff --git a/src/librustc/middle/trans/foreign.rs b/src/librustc/middle/trans/foreign.rs
index f73984d3b36..56fbccefede 100644
--- a/src/librustc/middle/trans/foreign.rs
+++ b/src/librustc/middle/trans/foreign.rs
@@ -10,9 +10,8 @@
 
 
 use back::{link};
-use lib::llvm::llvm;
-use lib::llvm::{ValueRef, CallConv, Linkage};
-use lib;
+use llvm;
+use llvm::{ValueRef, CallConv, Linkage};
 use middle::weak_lang_items;
 use middle::trans::base::push_ctxt;
 use middle::trans::base;
@@ -88,14 +87,14 @@ pub fn llvm_calling_convention(ccx: &CrateContext,
             // It's the ABI's job to select this, not us.
             System => ccx.sess().bug("system abi should be selected elsewhere"),
 
-            Stdcall => lib::llvm::X86StdcallCallConv,
-            Fastcall => lib::llvm::X86FastcallCallConv,
-            C => lib::llvm::CCallConv,
-            Win64 => lib::llvm::X86_64_Win64,
+            Stdcall => llvm::X86StdcallCallConv,
+            Fastcall => llvm::X86FastcallCallConv,
+            C => llvm::CCallConv,
+            Win64 => llvm::X86_64_Win64,
 
             // These API constants ought to be more specific...
-            Cdecl => lib::llvm::CCallConv,
-            Aapcs => lib::llvm::CCallConv,
+            Cdecl => llvm::CCallConv,
+            Aapcs => llvm::CCallConv,
         }
     })
 }
@@ -110,17 +109,17 @@ pub fn llvm_linkage_by_name(name: &str) -> Option<Linkage> {
     // ghost, dllimport, dllexport and linkonce_odr_autohide are not supported
     // and don't have to be, LLVM treats them as no-ops.
     match name {
-        "appending" => Some(lib::llvm::AppendingLinkage),
-        "available_externally" => Some(lib::llvm::AvailableExternallyLinkage),
-        "common" => Some(lib::llvm::CommonLinkage),
-        "extern_weak" => Some(lib::llvm::ExternalWeakLinkage),
-        "external" => Some(lib::llvm::ExternalLinkage),
-        "internal" => Some(lib::llvm::InternalLinkage),
-        "linkonce" => Some(lib::llvm::LinkOnceAnyLinkage),
-        "linkonce_odr" => Some(lib::llvm::LinkOnceODRLinkage),
-        "private" => Some(lib::llvm::PrivateLinkage),
-        "weak" => Some(lib::llvm::WeakAnyLinkage),
-        "weak_odr" => Some(lib::llvm::WeakODRLinkage),
+        "appending" => Some(llvm::AppendingLinkage),
+        "available_externally" => Some(llvm::AvailableExternallyLinkage),
+        "common" => Some(llvm::CommonLinkage),
+        "extern_weak" => Some(llvm::ExternalWeakLinkage),
+        "external" => Some(llvm::ExternalLinkage),
+        "internal" => Some(llvm::InternalLinkage),
+        "linkonce" => Some(llvm::LinkOnceAnyLinkage),
+        "linkonce_odr" => Some(llvm::LinkOnceODRLinkage),
+        "private" => Some(llvm::PrivateLinkage),
+        "weak" => Some(llvm::WeakAnyLinkage),
+        "weak_odr" => Some(llvm::WeakODRLinkage),
         _ => None,
     }
 }
@@ -157,14 +156,14 @@ pub fn register_static(ccx: &CrateContext,
                 let g1 = ident.get().with_c_str(|buf| {
                     llvm::LLVMAddGlobal(ccx.llmod, llty2.to_ref(), buf)
                 });
-                lib::llvm::SetLinkage(g1, linkage);
+                llvm::SetLinkage(g1, linkage);
 
                 let mut real_name = "_rust_extern_with_linkage_".to_string();
                 real_name.push_str(ident.get());
                 let g2 = real_name.with_c_str(|buf| {
                     llvm::LLVMAddGlobal(ccx.llmod, llty.to_ref(), buf)
                 });
-                lib::llvm::SetLinkage(g2, lib::llvm::InternalLinkage);
+                llvm::SetLinkage(g2, llvm::InternalLinkage);
                 llvm::LLVMSetInitializer(g2, g1);
                 g2
             }
@@ -217,7 +216,7 @@ pub fn register_foreign_item_fn(ccx: &CrateContext, abi: Abi, fty: ty::t,
     // Make sure the calling convention is right for variadic functions
     // (should've been caught if not in typeck)
     if tys.fn_sig.variadic {
-        assert!(cc == lib::llvm::CCallConv);
+        assert!(cc == llvm::CCallConv);
     }
 
     // Create the LLVM value for the C extern fn
@@ -347,7 +346,7 @@ pub fn trans_native_call<'a>(
             llarg_rust
         } else {
             if ty::type_is_bool(*passed_arg_tys.get(i)) {
-                let val = LoadRangeAssert(bcx, llarg_rust, 0, 2, lib::llvm::False);
+                let val = LoadRangeAssert(bcx, llarg_rust, 0, 2, llvm::False);
                 Trunc(bcx, val, Type::i1(bcx.ccx()))
             } else {
                 Load(bcx, llarg_rust)
@@ -384,9 +383,9 @@ pub fn trans_native_call<'a>(
     if fn_type.ret_ty.is_indirect() {
         // The outptr can be noalias and nocapture because it's entirely
         // invisible to the program. We can also mark it as nonnull
-        attrs.push((1, lib::llvm::NoAliasAttribute as u64));
-        attrs.push((1, lib::llvm::NoCaptureAttribute as u64));
-        attrs.push((1, lib::llvm::NonNullAttribute as u64));
+        attrs.push((1, llvm::NoAliasAttribute as u64));
+        attrs.push((1, llvm::NoCaptureAttribute as u64));
+        attrs.push((1, llvm::NonNullAttribute as u64));
     };
 
     // Add attributes that depend on the concrete foreign ABI
@@ -531,7 +530,7 @@ pub fn register_rust_fn_with_foreign_abi(ccx: &CrateContext,
     let cconv = match ty::get(t).sty {
         ty::ty_bare_fn(ref fn_ty) => {
             let c = llvm_calling_convention(ccx, fn_ty.abi);
-            c.unwrap_or(lib::llvm::CCallConv)
+            c.unwrap_or(llvm::CCallConv)
         }
         _ => fail!("expected bare fn in register_rust_fn_with_foreign_abi")
     };
@@ -743,7 +742,7 @@ pub fn trans_rust_fn_with_foreign_abi(ccx: &CrateContext,
                 llforeign_arg
             } else {
                 if ty::type_is_bool(rust_ty) {
-                    let tmp = builder.load_range_assert(llforeign_arg, 0, 2, lib::llvm::False);
+                    let tmp = builder.load_range_assert(llforeign_arg, 0, 2, llvm::False);
                     builder.trunc(tmp, Type::i1(ccx))
                 } else {
                     builder.load(llforeign_arg)
diff --git a/src/librustc/middle/trans/glue.rs b/src/librustc/middle/trans/glue.rs
index 4d9f004e3dc..40065d0bc50 100644
--- a/src/librustc/middle/trans/glue.rs
+++ b/src/librustc/middle/trans/glue.rs
@@ -15,8 +15,8 @@
 
 use back::abi;
 use back::link::*;
-use lib::llvm::{llvm, ValueRef, True};
-use lib;
+use llvm;
+use llvm::{ValueRef, True};
 use middle::lang_items::{FreeFnLangItem, ExchangeFreeFnLangItem};
 use middle::subst;
 use middle::trans::adt;
@@ -492,7 +492,7 @@ fn make_generic_glue(ccx: &CrateContext,
 
     let bcx = init_function(&fcx, false, ty::mk_nil());
 
-    lib::llvm::SetLinkage(llfn, lib::llvm::InternalLinkage);
+    llvm::SetLinkage(llfn, llvm::InternalLinkage);
     ccx.stats.n_glues_created.set(ccx.stats.n_glues_created.get() + 1u);
     // All glue functions take values passed *by alias*; this is a
     // requirement since in many contexts glue is invoked indirectly and
@@ -550,7 +550,7 @@ pub fn emit_tydescs(ccx: &CrateContext) {
             let gvar = ti.tydesc;
             llvm::LLVMSetInitializer(gvar, tydesc);
             llvm::LLVMSetGlobalConstant(gvar, True);
-            lib::llvm::SetLinkage(gvar, lib::llvm::InternalLinkage);
+            llvm::SetLinkage(gvar, llvm::InternalLinkage);
         }
     };
 }
diff --git a/src/librustc/middle/trans/inline.rs b/src/librustc/middle/trans/inline.rs
index f11577482b6..d64eeb727e7 100644
--- a/src/librustc/middle/trans/inline.rs
+++ b/src/librustc/middle/trans/inline.rs
@@ -8,7 +8,7 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-use lib::llvm::{AvailableExternallyLinkage, SetLinkage};
+use llvm::{AvailableExternallyLinkage, SetLinkage};
 use metadata::csearch;
 use middle::astencode;
 use middle::trans::base::{push_ctxt, trans_item, get_item_val, trans_fn};
diff --git a/src/librustc/middle/trans/intrinsic.rs b/src/librustc/middle/trans/intrinsic.rs
index 309c700bfe8..bb33a5e4f8d 100644
--- a/src/librustc/middle/trans/intrinsic.rs
+++ b/src/librustc/middle/trans/intrinsic.rs
@@ -10,8 +10,8 @@
 
 #![allow(non_uppercase_pattern_statics)]
 
-use lib::llvm::{SequentiallyConsistent, Acquire, Release, Xchg, ValueRef};
-use lib;
+use llvm;
+use llvm::{SequentiallyConsistent, Acquire, Release, Xchg, ValueRef};
 use middle::subst;
 use middle::subst::FnSpace;
 use middle::trans::base::*;
@@ -426,13 +426,13 @@ pub fn trans_intrinsic_call<'a>(mut bcx: &'a Block<'a>, node: ast::NodeId,
             assert!(split.len() >= 2, "Atomic intrinsic not correct format");
 
             let order = if split.len() == 2 {
-                lib::llvm::SequentiallyConsistent
+                llvm::SequentiallyConsistent
             } else {
                 match *split.get(2) {
-                    "relaxed" => lib::llvm::Monotonic,
-                    "acq"     => lib::llvm::Acquire,
-                    "rel"     => lib::llvm::Release,
-                    "acqrel"  => lib::llvm::AcquireRelease,
+                    "relaxed" => llvm::Monotonic,
+                    "acq"     => llvm::Acquire,
+                    "rel"     => llvm::Release,
+                    "acqrel"  => llvm::AcquireRelease,
                     _ => ccx.sess().fatal("unknown ordering in atomic intrinsic")
                 }
             };
@@ -443,23 +443,23 @@ pub fn trans_intrinsic_call<'a>(mut bcx: &'a Block<'a>, node: ast::NodeId,
                     // of this, I assume that it's good enough for us to use for
                     // now.
                     let strongest_failure_ordering = match order {
-                        lib::llvm::NotAtomic | lib::llvm::Unordered =>
+                        llvm::NotAtomic | llvm::Unordered =>
                             ccx.sess().fatal("cmpxchg must be atomic"),
 
-                        lib::llvm::Monotonic | lib::llvm::Release =>
-                            lib::llvm::Monotonic,
+                        llvm::Monotonic | llvm::Release =>
+                            llvm::Monotonic,
 
-                        lib::llvm::Acquire | lib::llvm::AcquireRelease =>
-                            lib::llvm::Acquire,
+                        llvm::Acquire | llvm::AcquireRelease =>
+                            llvm::Acquire,
 
-                        lib::llvm::SequentiallyConsistent =>
-                            lib::llvm::SequentiallyConsistent
+                        llvm::SequentiallyConsistent =>
+                            llvm::SequentiallyConsistent
                     };
 
                     let res = AtomicCmpXchg(bcx, *llargs.get(0), *llargs.get(1),
                                             *llargs.get(2), order,
                                             strongest_failure_ordering);
-                    if unsafe { lib::llvm::llvm::LLVMVersionMinor() >= 5 } {
+                    if unsafe { llvm::LLVMVersionMinor() >= 5 } {
                         ExtractValue(bcx, res, 0)
                     } else {
                         res
@@ -482,17 +482,17 @@ pub fn trans_intrinsic_call<'a>(mut bcx: &'a Block<'a>, node: ast::NodeId,
                 // These are all AtomicRMW ops
                 op => {
                     let atom_op = match op {
-                        "xchg"  => lib::llvm::Xchg,
-                        "xadd"  => lib::llvm::Add,
-                        "xsub"  => lib::llvm::Sub,
-                        "and"   => lib::llvm::And,
-                        "nand"  => lib::llvm::Nand,
-                        "or"    => lib::llvm::Or,
-                        "xor"   => lib::llvm::Xor,
-                        "max"   => lib::llvm::Max,
-                        "min"   => lib::llvm::Min,
-                        "umax"  => lib::llvm::UMax,
-                        "umin"  => lib::llvm::UMin,
+                        "xchg"  => llvm::Xchg,
+                        "xadd"  => llvm::Add,
+                        "xsub"  => llvm::Sub,
+                        "and"   => llvm::And,
+                        "nand"  => llvm::Nand,
+                        "or"    => llvm::Or,
+                        "xor"   => llvm::Xor,
+                        "max"   => llvm::Max,
+                        "min"   => llvm::Min,
+                        "umax"  => llvm::UMax,
+                        "umin"  => llvm::UMin,
                         _ => ccx.sess().fatal("unknown atomic operation")
                     };
 
diff --git a/src/librustc/middle/trans/llrepr.rs b/src/librustc/middle/trans/llrepr.rs
index f7884ca5643..2740e5695be 100644
--- a/src/librustc/middle/trans/llrepr.rs
+++ b/src/librustc/middle/trans/llrepr.rs
@@ -10,7 +10,7 @@
 
 use middle::trans::context::CrateContext;
 use middle::trans::type_::Type;
-use lib::llvm::ValueRef;
+use llvm::ValueRef;
 
 pub trait LlvmRepr {
     fn llrepr(&self, ccx: &CrateContext) -> String;
diff --git a/src/librustc/middle/trans/machine.rs b/src/librustc/middle/trans/machine.rs
index 7a7e3a9b759..15bbc5ae845 100644
--- a/src/librustc/middle/trans/machine.rs
+++ b/src/librustc/middle/trans/machine.rs
@@ -10,9 +10,9 @@
 
 // Information concerning the machine representation of various types.
 
-use lib::llvm::{ValueRef};
-use lib::llvm::False;
-use lib::llvm::llvm;
+use llvm;
+use llvm::{ValueRef};
+use llvm::False;
 use middle::trans::common::*;
 
 use middle::trans::type_::Type;
diff --git a/src/librustc/middle/trans/meth.rs b/src/librustc/middle/trans/meth.rs
index 6b54556bbe0..092a524e48a 100644
--- a/src/librustc/middle/trans/meth.rs
+++ b/src/librustc/middle/trans/meth.rs
@@ -10,9 +10,8 @@
 
 
 use back::abi;
-use lib::llvm::llvm;
-use lib::llvm::ValueRef;
-use lib;
+use llvm;
+use llvm::ValueRef;
 use metadata::csearch;
 use middle::subst;
 use middle::trans::base::*;
@@ -460,8 +459,8 @@ pub fn make_vtable<I: Iterator<ValueRef>>(ccx: &CrateContext,
             llvm::LLVMAddGlobal(ccx.llmod, val_ty(tbl).to_ref(), buf)
         });
         llvm::LLVMSetInitializer(vt_gvar, tbl);
-        llvm::LLVMSetGlobalConstant(vt_gvar, lib::llvm::True);
-        lib::llvm::SetLinkage(vt_gvar, lib::llvm::InternalLinkage);
+        llvm::LLVMSetGlobalConstant(vt_gvar, llvm::True);
+        llvm::SetLinkage(vt_gvar, llvm::InternalLinkage);
         vt_gvar
     }
 }
diff --git a/src/librustc/middle/trans/monomorphize.rs b/src/librustc/middle/trans/monomorphize.rs
index 01544214ccf..7687e82654a 100644
--- a/src/librustc/middle/trans/monomorphize.rs
+++ b/src/librustc/middle/trans/monomorphize.rs
@@ -10,7 +10,7 @@
 
 use back::link::exported_name;
 use driver::session;
-use lib::llvm::ValueRef;
+use llvm::ValueRef;
 use middle::subst;
 use middle::subst::Subst;
 use middle::trans::base::{set_llvm_fn_attrs, set_inline_hint};
diff --git a/src/librustc/middle/trans/reflect.rs b/src/librustc/middle/trans/reflect.rs
index e50eb8f0be9..bc156fc3791 100644
--- a/src/librustc/middle/trans/reflect.rs
+++ b/src/librustc/middle/trans/reflect.rs
@@ -9,7 +9,8 @@
 // except according to those terms.
 
 use back::link::mangle_internal_name_by_path_and_seq;
-use lib::llvm::{ValueRef, llvm};
+use llvm;
+use llvm::{ValueRef};
 use middle::trans::adt;
 use middle::trans::base::*;
 use middle::trans::build::*;
diff --git a/src/librustc/middle/trans/tvec.rs b/src/librustc/middle/trans/tvec.rs
index a6e554039e7..07571b2f4c4 100644
--- a/src/librustc/middle/trans/tvec.rs
+++ b/src/librustc/middle/trans/tvec.rs
@@ -11,8 +11,8 @@
 #![allow(non_camel_case_types)]
 
 use back::abi;
-use lib;
-use lib::llvm::{llvm, ValueRef};
+use llvm;
+use llvm::{ValueRef};
 use middle::lang_items::StrDupUniqFnLangItem;
 use middle::trans::base::*;
 use middle::trans::base;
@@ -543,7 +543,7 @@ pub fn iter_vec_loop<'r,
     { // i < count
         let lhs = Load(cond_bcx, loop_counter);
         let rhs = count;
-        let cond_val = ICmp(cond_bcx, lib::llvm::IntULT, lhs, rhs);
+        let cond_val = ICmp(cond_bcx, llvm::IntULT, lhs, rhs);
 
         CondBr(cond_bcx, cond_val, body_bcx.llbb, next_bcx.llbb);
     }
@@ -599,7 +599,7 @@ pub fn iter_vec_raw<'r,
         let data_ptr =
             Phi(header_bcx, val_ty(data_ptr), [data_ptr], [bcx.llbb]);
         let not_yet_at_end =
-            ICmp(header_bcx, lib::llvm::IntULT, data_ptr, data_end_ptr);
+            ICmp(header_bcx, llvm::IntULT, data_ptr, data_end_ptr);
         let body_bcx = fcx.new_temp_block("iter_vec_loop_body");
         let next_bcx = fcx.new_temp_block("iter_vec_next");
         CondBr(header_bcx, not_yet_at_end, body_bcx.llbb, next_bcx.llbb);
diff --git a/src/librustc/middle/trans/type_.rs b/src/librustc/middle/trans/type_.rs
index b10f6eda880..573965108ad 100644
--- a/src/librustc/middle/trans/type_.rs
+++ b/src/librustc/middle/trans/type_.rs
@@ -10,8 +10,9 @@
 
 #![allow(non_uppercase_pattern_statics)]
 
-use lib::llvm::{llvm, TypeRef, Bool, False, True, TypeKind};
-use lib::llvm::{Float, Double, X86_FP80, PPC_FP128, FP128};
+use llvm;
+use llvm::{TypeRef, Bool, False, True, TypeKind, ValueRef};
+use llvm::{Float, Double, X86_FP80, PPC_FP128, FP128};
 
 use middle::trans::context::CrateContext;
 
@@ -20,8 +21,11 @@ use syntax::abi::{X86, X86_64, Arm, Mips, Mipsel};
 
 use std::c_str::ToCStr;
 use std::mem;
+use std::cell::RefCell;
+use std::collections::HashMap;
+use std::str::raw::from_c_str;
 
-use libc::{c_uint};
+use libc::{c_uint, c_void, free};
 
 #[deriving(Clone, PartialEq, Show)]
 pub struct Type {
@@ -303,3 +307,50 @@ impl Type {
         }
     }
 }
+
+
+/* Memory-managed object interface to type handles. */
+
+pub struct TypeNames {
+    named_types: RefCell<HashMap<String, TypeRef>>,
+}
+
+impl TypeNames {
+    pub fn new() -> TypeNames {
+        TypeNames {
+            named_types: RefCell::new(HashMap::new())
+        }
+    }
+
+    pub fn associate_type(&self, s: &str, t: &Type) {
+        assert!(self.named_types.borrow_mut().insert(s.to_string(),
+                                                     t.to_ref()));
+    }
+
+    pub fn find_type(&self, s: &str) -> Option<Type> {
+        self.named_types.borrow().find_equiv(&s).map(|x| Type::from_ref(*x))
+    }
+
+    pub fn type_to_string(&self, ty: Type) -> String {
+        unsafe {
+            let s = llvm::LLVMTypeToString(ty.to_ref());
+            let ret = from_c_str(s);
+            free(s as *mut c_void);
+            ret.to_string()
+        }
+    }
+
+    pub fn types_to_str(&self, tys: &[Type]) -> String {
+        let strs: Vec<String> = tys.iter().map(|t| self.type_to_string(*t)).collect();
+        format!("[{}]", strs.connect(","))
+    }
+
+    pub fn val_to_string(&self, val: ValueRef) -> String {
+        unsafe {
+            let s = llvm::LLVMValueToString(val);
+            let ret = from_c_str(s);
+            free(s as *mut c_void);
+            ret.to_string()
+        }
+    }
+}
diff --git a/src/librustc/middle/trans/value.rs b/src/librustc/middle/trans/value.rs
index e627b859f42..2db6a87a9dc 100644
--- a/src/librustc/middle/trans/value.rs
+++ b/src/librustc/middle/trans/value.rs
@@ -8,7 +8,8 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-use lib::llvm::{llvm, UseRef, ValueRef};
+use llvm;
+use llvm::{UseRef, ValueRef};
 use middle::trans::basic_block::BasicBlock;
 use middle::trans::common::Block;
 use libc::c_uint;
diff --git a/src/librustc/back/abi.rs b/src/librustc_back/abi.rs
index c722beb43ae..c722beb43ae 100644
--- a/src/librustc/back/abi.rs
+++ b/src/librustc_back/abi.rs
diff --git a/src/librustc/back/archive.rs b/src/librustc_back/archive.rs
index 4d921fb97dc..c4a9d9c80ef 100644
--- a/src/librustc/back/archive.rs
+++ b/src/librustc_back/archive.rs
@@ -10,36 +10,40 @@
 
 //! A helper class for dealing with static archives
 
-use back::link::{get_ar_prog};
-use driver::session::Session;
-use metadata::filesearch;
-use lib::llvm::{ArchiveRef, llvm};
-
-use libc;
 use std::io::process::{Command, ProcessOutput};
 use std::io::{fs, TempDir};
 use std::io;
-use std::mem;
 use std::os;
-use std::raw;
 use std::str;
 use syntax::abi;
+use ErrorHandler = syntax::diagnostic::Handler;
 
 pub static METADATA_FILENAME: &'static str = "rust.metadata.bin";
 
-pub struct Archive<'a> {
-    sess: &'a Session,
-    dst: Path,
+pub struct ArchiveConfig<'a> {
+    pub handler: &'a ErrorHandler,
+    pub dst: Path,
+    pub lib_search_paths: Vec<Path>,
+    pub os: abi::Os,
+    pub maybe_ar_prog: Option<String>
 }
 
-pub struct ArchiveRO {
-    ptr: ArchiveRef,
+pub struct Archive<'a> {
+    handler: &'a ErrorHandler,
+    dst: Path,
+    lib_search_paths: Vec<Path>,
+    os: abi::Os,
+    maybe_ar_prog: Option<String>
 }
 
-fn run_ar(sess: &Session, args: &str, cwd: Option<&Path>,
+fn run_ar(handler: &ErrorHandler, maybe_ar_prog: &Option<String>,
+          args: &str, cwd: Option<&Path>,
           paths: &[&Path]) -> ProcessOutput {
-    let ar = get_ar_prog(sess);
-    let mut cmd = Command::new(ar.as_slice());
+    let ar = match *maybe_ar_prog {
+        Some(ref ar) => ar.as_slice(),
+        None => "ar"
+    };
+    let mut cmd = Command::new(ar);
 
     cmd.arg(args).args(paths);
     debug!("{}", cmd);
@@ -56,25 +60,25 @@ fn run_ar(sess: &Session, args: &str, cwd: Option<&Path>,
         Ok(prog) => {
             let o = prog.wait_with_output().unwrap();
             if !o.status.success() {
-                sess.err(format!("{} failed with: {}",
+                handler.err(format!("{} failed with: {}",
                                  cmd,
                                  o.status).as_slice());
-                sess.note(format!("stdout ---\n{}",
+                handler.note(format!("stdout ---\n{}",
                                   str::from_utf8(o.output
                                                   .as_slice()).unwrap())
                           .as_slice());
-                sess.note(format!("stderr ---\n{}",
+                handler.note(format!("stderr ---\n{}",
                                   str::from_utf8(o.error
                                                   .as_slice()).unwrap())
                           .as_slice());
-                sess.abort_if_errors();
+                handler.abort_if_errors();
             }
             o
         },
         Err(e) => {
-            sess.err(format!("could not exec `{}`: {}", ar.as_slice(),
+            handler.err(format!("could not exec `{}`: {}", ar.as_slice(),
                              e).as_slice());
-            sess.abort_if_errors();
+            handler.abort_if_errors();
             fail!("rustc::back::archive::run_ar() should not reach this point");
         }
     }
@@ -82,16 +86,29 @@ fn run_ar(sess: &Session, args: &str, cwd: Option<&Path>,
 
 impl<'a> Archive<'a> {
     /// Initializes a new static archive with the given object file
-    pub fn create<'b>(sess: &'a Session, dst: &'b Path,
-                      initial_object: &'b Path) -> Archive<'a> {
-        run_ar(sess, "crus", None, [dst, initial_object]);
-        Archive { sess: sess, dst: dst.clone() }
+    pub fn create<'b>(config: ArchiveConfig<'a>, initial_object: &'b Path) -> Archive<'a> {
+        let ArchiveConfig { handler, dst, lib_search_paths, os, maybe_ar_prog } = config;
+        run_ar(handler, &maybe_ar_prog, "crus", None, [&dst, initial_object]);
+        Archive {
+            handler: handler,
+            dst: dst,
+            lib_search_paths: lib_search_paths,
+            os: os,
+            maybe_ar_prog: maybe_ar_prog
+        }
     }
 
     /// Opens an existing static archive
-    pub fn open(sess: &'a Session, dst: Path) -> Archive<'a> {
+    pub fn open(config: ArchiveConfig<'a>) -> Archive<'a> {
+        let ArchiveConfig { handler, dst, lib_search_paths, os, maybe_ar_prog } = config;
         assert!(dst.exists());
-        Archive { sess: sess, dst: dst }
+        Archive {
+            handler: handler,
+            dst: dst,
+            lib_search_paths: lib_search_paths,
+            os: os,
+            maybe_ar_prog: maybe_ar_prog
+        }
     }
 
     /// Adds all of the contents of a native library to this archive. This will
@@ -120,22 +137,22 @@ impl<'a> Archive<'a> {
     /// Adds an arbitrary file to this archive
     pub fn add_file(&mut self, file: &Path, has_symbols: bool) {
         let cmd = if has_symbols {"r"} else {"rS"};
-        run_ar(self.sess, cmd, None, [&self.dst, file]);
+        run_ar(self.handler, &self.maybe_ar_prog, cmd, None, [&self.dst, file]);
     }
 
     /// Removes a file from this archive
     pub fn remove_file(&mut self, file: &str) {
-        run_ar(self.sess, "d", None, [&self.dst, &Path::new(file)]);
+        run_ar(self.handler, &self.maybe_ar_prog, "d", None, [&self.dst, &Path::new(file)]);
     }
 
     /// Updates all symbols in the archive (runs 'ar s' over it)
     pub fn update_symbols(&mut self) {
-        run_ar(self.sess, "s", None, [&self.dst]);
+        run_ar(self.handler, &self.maybe_ar_prog, "s", None, [&self.dst]);
     }
 
     /// Lists all files in an archive
     pub fn files(&self) -> Vec<String> {
-        let output = run_ar(self.sess, "t", None, [&self.dst]);
+        let output = run_ar(self.handler, &self.maybe_ar_prog, "t", None, [&self.dst]);
         let output = str::from_utf8(output.output.as_slice()).unwrap();
         // use lines_any because windows delimits output with `\r\n` instead of
         // just `\n`
@@ -148,7 +165,7 @@ impl<'a> Archive<'a> {
 
         // First, extract the contents of the archive to a temporary directory
         let archive = os::make_absolute(archive);
-        run_ar(self.sess, "x", Some(loc.path()), [&archive]);
+        run_ar(self.handler, &self.maybe_ar_prog, "x", Some(loc.path()), [&archive]);
 
         // Next, we must rename all of the inputs to "guaranteed unique names".
         // The reason for this is that archives are keyed off the name of the
@@ -184,12 +201,12 @@ impl<'a> Archive<'a> {
         // Finally, add all the renamed files to this archive
         let mut args = vec!(&self.dst);
         args.extend(inputs.iter());
-        run_ar(self.sess, "r", None, args.as_slice());
+        run_ar(self.handler, &self.maybe_ar_prog, "r", None, args.as_slice());
         Ok(())
     }
 
     fn find_library(&self, name: &str) -> Path {
-        let (osprefix, osext) = match self.sess.targ_cfg.os {
+        let (osprefix, osext) = match self.os {
             abi::OsWin32 => ("", "lib"), _ => ("lib", "a"),
         };
         // On Windows, static libraries sometimes show up as libfoo.a and other
@@ -197,10 +214,7 @@ impl<'a> Archive<'a> {
         let oslibname = format!("{}{}.{}", osprefix, name, osext);
         let unixlibname = format!("lib{}.a", name);
 
-        let mut rustpath = filesearch::rust_path();
-        rustpath.push(self.sess.target_filesearch().get_lib_path());
-        let search = self.sess.opts.addl_lib_search_paths.borrow();
-        for path in search.iter().chain(rustpath.iter()) {
+        for path in self.lib_search_paths.iter() {
             debug!("looking for {} inside {}", name, path.display());
             let test = path.join(oslibname.as_slice());
             if test.exists() { return test }
@@ -209,55 +223,9 @@ impl<'a> Archive<'a> {
                 if test.exists() { return test }
             }
         }
-        self.sess.fatal(format!("could not find native static library `{}`, \
+        self.handler.fatal(format!("could not find native static library `{}`, \
                                  perhaps an -L flag is missing?",
                                 name).as_slice());
     }
 }
 
-impl ArchiveRO {
-    /// Opens a static archive for read-only purposes. This is more optimized
-    /// than the `open` method because it uses LLVM's internal `Archive` class
-    /// rather than shelling out to `ar` for everything.
-    ///
-    /// If this archive is used with a mutable method, then an error will be
-    /// raised.
-    pub fn open(dst: &Path) -> Option<ArchiveRO> {
-        unsafe {
-            let ar = dst.with_c_str(|dst| {
-                llvm::LLVMRustOpenArchive(dst)
-            });
-            if ar.is_null() {
-                None
-            } else {
-                Some(ArchiveRO { ptr: ar })
-            }
-        }
-    }
-
-    /// Reads a file in the archive
-    pub fn read<'a>(&'a self, file: &str) -> Option<&'a [u8]> {
-        unsafe {
-            let mut size = 0 as libc::size_t;
-            let ptr = file.with_c_str(|file| {
-                llvm::LLVMRustArchiveReadSection(self.ptr, file, &mut size)
-            });
-            if ptr.is_null() {
-                None
-            } else {
-                Some(mem::transmute(raw::Slice {
-                    data: ptr,
-                    len: size as uint,
-                }))
-            }
-        }
-    }
-}
-
-impl Drop for ArchiveRO {
-    fn drop(&mut self) {
-        unsafe {
-            llvm::LLVMRustDestroyArchive(self.ptr);
-        }
-    }
-}
diff --git a/src/librustc/back/arm.rs b/src/librustc_back/arm.rs
index 7a7d248a4cb..a0730360ec7 100644
--- a/src/librustc/back/arm.rs
+++ b/src/librustc_back/arm.rs
@@ -8,7 +8,7 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-use back::target_strs;
+use target_strs;
 use syntax::abi;
 
 pub fn get_target_strs(target_triple: String, target_os: abi::Os) -> target_strs::t {
diff --git a/src/librustc/util/fs.rs b/src/librustc_back/fs.rs
index c051b8e60cd..c051b8e60cd 100644
--- a/src/librustc/util/fs.rs
+++ b/src/librustc_back/fs.rs
diff --git a/src/librustc_back/lib.rs b/src/librustc_back/lib.rs
new file mode 100644
index 00000000000..8ec74f4d6ef
--- /dev/null
+++ b/src/librustc_back/lib.rs
@@ -0,0 +1,56 @@
+// Copyright 2012-2013 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.
+
+//! Some stuff used by rustc that doesn't have many dependencies
+//!
+//! Originally extracted from rustc::back, which was nominally the
+//! compiler 'backend', though LLVM is rustc's backend, so rustc_back
+//! is really just odds-and-ends relating to code gen and linking.
+//! This crate mostly exists to make rustc smaller, so we might put
+//! more 'stuff' here in the future.  It does not have a dependency on
+//! rustc_llvm.
+//!
+//! FIXME: Split this into two crates: one that has deps on syntax, and
+//! one that doesn't; the one that doesn't might get decent parallel
+//! build speedups.
+
+#![crate_id = "rustc_back#0.11.0-pre"]
+#![crate_name = "rustc_back"]
+#![experimental]
+#![comment = "The Rust compiler minimal-dependency dumping-ground"]
+#![license = "MIT/ASL2"]
+#![crate_type = "dylib"]
+#![crate_type = "rlib"]
+#![doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
+      html_favicon_url = "http://www.rust-lang.org/favicon.ico",
+      html_root_url = "http://doc.rust-lang.org/")]
+
+#![feature(globs, phase, macro_rules)]
+#![allow(unused_attribute)] // NOTE: remove after stage0
+
+#[phase(plugin, link)]
+extern crate log;
+extern crate syntax;
+extern crate libc;
+extern crate flate;
+extern crate serialize;
+
+pub mod abi;
+pub mod archive;
+pub mod arm;
+pub mod fs;
+pub mod mips;
+pub mod mipsel;
+pub mod rpath;
+pub mod sha2;
+pub mod svh;
+pub mod target_strs;
+pub mod x86;
+pub mod x86_64;
diff --git a/src/librustc/back/mips.rs b/src/librustc_back/mips.rs
index 8f3da03e825..4176d0e9a6f 100644
--- a/src/librustc/back/mips.rs
+++ b/src/librustc_back/mips.rs
@@ -8,7 +8,7 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-use back::target_strs;
+use target_strs;
 use syntax::abi;
 
 pub fn get_target_strs(target_triple: String, target_os: abi::Os) -> target_strs::t {
diff --git a/src/librustc/back/mipsel.rs b/src/librustc_back/mipsel.rs
index c2c48a41e8f..d3ea9d3aa72 100644
--- a/src/librustc/back/mipsel.rs
+++ b/src/librustc_back/mipsel.rs
@@ -8,7 +8,7 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-use back::target_strs;
+use target_strs;
 use syntax::abi;
 
 pub fn get_target_strs(target_triple: String, target_os: abi::Os) -> target_strs::t {
diff --git a/src/librustc/back/rpath.rs b/src/librustc_back/rpath.rs
index a458cf22a5b..e298e1dbfe9 100644
--- a/src/librustc/back/rpath.rs
+++ b/src/librustc_back/rpath.rs
@@ -9,30 +9,30 @@
 // except according to those terms.
 
 
-use driver::session::Session;
-use metadata::cstore;
-use metadata::filesearch;
-use util::fs;
-
 use std::collections::HashSet;
 use std::os;
+use std::io::IoError;
 use syntax::abi;
-
-fn not_win32(os: abi::Os) -> bool {
-  os != abi::OsWin32
+use syntax::ast;
+
+pub struct RPathConfig<'a> {
+    pub os: abi::Os,
+    pub used_crates: Vec<(ast::CrateNum, Option<Path>)>,
+    pub out_filename: Path,
+    pub get_install_prefix_lib_path: ||:'a -> Path,
+    pub realpath: |&Path|:'a -> Result<Path, IoError>
 }
 
-pub fn get_rpath_flags(sess: &Session, out_filename: &Path) -> Vec<String> {
-    let os = sess.targ_cfg.os;
+pub fn get_rpath_flags(config: RPathConfig) -> Vec<String> {
 
     // No rpath on windows
-    if os == abi::OsWin32 {
+    if config.os == abi::OsWin32 {
         return Vec::new();
     }
 
     let mut flags = Vec::new();
 
-    if sess.targ_cfg.os == abi::OsFreebsd {
+    if config.os == abi::OsFreebsd {
         flags.push_all(["-Wl,-rpath,/usr/local/lib/gcc46".to_string(),
                         "-Wl,-rpath,/usr/local/lib/gcc44".to_string(),
                         "-Wl,-z,origin".to_string()]);
@@ -40,23 +40,17 @@ pub fn get_rpath_flags(sess: &Session, out_filename: &Path) -> Vec<String> {
 
     debug!("preparing the RPATH!");
 
-    let sysroot = sess.sysroot();
-    let output = out_filename;
-    let libs = sess.cstore.get_used_crates(cstore::RequireDynamic);
+    let libs = config.used_crates.clone();
     let libs = libs.move_iter().filter_map(|(_, l)| {
         l.map(|p| p.clone())
     }).collect::<Vec<_>>();
 
-    let rpaths = get_rpaths(os,
-                            sysroot,
-                            output,
-                            libs.as_slice(),
-                            sess.opts.target_triple.as_slice());
+    let rpaths = get_rpaths(config, libs.as_slice());
     flags.push_all(rpaths_to_flags(rpaths.as_slice()).as_slice());
     flags
 }
 
-pub fn rpaths_to_flags(rpaths: &[String]) -> Vec<String> {
+fn rpaths_to_flags(rpaths: &[String]) -> Vec<String> {
     let mut ret = Vec::new();
     for rpath in rpaths.iter() {
         ret.push(format!("-Wl,-rpath,{}", (*rpath).as_slice()));
@@ -64,26 +58,21 @@ pub fn rpaths_to_flags(rpaths: &[String]) -> Vec<String> {
     return ret;
 }
 
-fn get_rpaths(os: abi::Os,
-              sysroot: &Path,
-              output: &Path,
-              libs: &[Path],
-              target_triple: &str) -> Vec<String> {
-    debug!("sysroot: {}", sysroot.display());
-    debug!("output: {}", output.display());
+fn get_rpaths(mut config: RPathConfig,
+              libs: &[Path]) -> Vec<String> {
+    debug!("output: {}", config.out_filename.display());
     debug!("libs:");
     for libpath in libs.iter() {
         debug!("    {}", libpath.display());
     }
-    debug!("target_triple: {}", target_triple);
 
     // Use relative paths to the libraries. Binaries can be moved
     // as long as they maintain the relative relationship to the
     // crates they depend on.
-    let rel_rpaths = get_rpaths_relative_to_output(os, output, libs);
+    let rel_rpaths = get_rpaths_relative_to_output(&mut config, libs);
 
     // And a final backup rpath to the global library location.
-    let fallback_rpaths = vec!(get_install_prefix_rpath(sysroot, target_triple));
+    let fallback_rpaths = vec!(get_install_prefix_rpath(config));
 
     fn log_rpaths(desc: &str, rpaths: &[String]) {
         debug!("{} rpaths:", desc);
@@ -103,31 +92,28 @@ fn get_rpaths(os: abi::Os,
     return rpaths;
 }
 
-fn get_rpaths_relative_to_output(os: abi::Os,
-                                 output: &Path,
+fn get_rpaths_relative_to_output(config: &mut RPathConfig,
                                  libs: &[Path]) -> Vec<String> {
-    libs.iter().map(|a| get_rpath_relative_to_output(os, output, a)).collect()
+    libs.iter().map(|a| get_rpath_relative_to_output(config, a)).collect()
 }
 
-pub fn get_rpath_relative_to_output(os: abi::Os,
-                                    output: &Path,
-                                    lib: &Path)
-                                 -> String {
+fn get_rpath_relative_to_output(config: &mut RPathConfig,
+                                lib: &Path) -> String {
     use std::os;
 
-    assert!(not_win32(os));
+    assert!(config.os != abi::OsWin32);
 
     // Mac doesn't appear to support $ORIGIN
-    let prefix = match os {
+    let prefix = match config.os {
         abi::OsAndroid | abi::OsLinux | abi::OsFreebsd
                           => "$ORIGIN",
         abi::OsMacos => "@loader_path",
         abi::OsWin32 | abi::OsiOS => unreachable!()
     };
 
-    let mut lib = fs::realpath(&os::make_absolute(lib)).unwrap();
+    let mut lib = (config.realpath)(&os::make_absolute(lib)).unwrap();
     lib.pop();
-    let mut output = fs::realpath(&os::make_absolute(output)).unwrap();
+    let mut output = (config.realpath)(&os::make_absolute(&config.out_filename)).unwrap();
     output.pop();
     let relative = lib.path_relative_from(&output);
     let relative = relative.expect("could not create rpath relative to output");
@@ -137,18 +123,14 @@ pub fn get_rpath_relative_to_output(os: abi::Os,
             relative.as_str().expect("non-utf8 component in path"))
 }
 
-pub fn get_install_prefix_rpath(sysroot: &Path, target_triple: &str) -> String {
-    let install_prefix = option_env!("CFG_PREFIX").expect("CFG_PREFIX");
-
-    let tlib = filesearch::relative_target_lib_path(sysroot, target_triple);
-    let mut path = Path::new(install_prefix);
-    path.push(&tlib);
+fn get_install_prefix_rpath(config: RPathConfig) -> String {
+    let path = (config.get_install_prefix_lib_path)();
     let path = os::make_absolute(&path);
     // FIXME (#9639): This needs to handle non-utf8 paths
     path.as_str().expect("non-utf8 component in rpath").to_string()
 }
 
-pub fn minimize_rpaths(rpaths: &[String]) -> Vec<String> {
+fn minimize_rpaths(rpaths: &[String]) -> Vec<String> {
     let mut set = HashSet::new();
     let mut minimized = Vec::new();
     for rpath in rpaths.iter() {
@@ -161,10 +143,9 @@ pub fn minimize_rpaths(rpaths: &[String]) -> Vec<String> {
 
 #[cfg(unix, test)]
 mod test {
-    use back::rpath::get_install_prefix_rpath;
-    use back::rpath::{minimize_rpaths, rpaths_to_flags, get_rpath_relative_to_output};
+    use super::{RPathConfig};
+    use super::{minimize_rpaths, rpaths_to_flags, get_rpath_relative_to_output};
     use syntax::abi;
-    use metadata::filesearch;
 
     #[test]
     fn test_rpaths_to_flags() {
@@ -178,27 +159,6 @@ mod test {
     }
 
     #[test]
-    fn test_prefix_rpath() {
-        let sysroot = filesearch::get_or_default_sysroot();
-        let res = get_install_prefix_rpath(&sysroot, "triple");
-        let mut d = Path::new((option_env!("CFG_PREFIX")).expect("CFG_PREFIX"));
-        d.push("lib");
-        d.push(filesearch::rustlibdir());
-        d.push("triple/lib");
-        debug!("test_prefix_path: {} vs. {}",
-               res,
-               d.display());
-        assert!(res.as_bytes().ends_with(d.as_vec()));
-    }
-
-    #[test]
-    fn test_prefix_rpath_abs() {
-        let sysroot = filesearch::get_or_default_sysroot();
-        let res = get_install_prefix_rpath(&sysroot, "triple");
-        assert!(Path::new(res).is_absolute());
-    }
-
-    #[test]
     fn test_minimize1() {
         let res = minimize_rpaths([
             "rpath1".to_string(),
@@ -237,28 +197,42 @@ mod test {
     #[cfg(target_os = "linux")]
     #[cfg(target_os = "android")]
     fn test_rpath_relative() {
-      let o = abi::OsLinux;
-      let res = get_rpath_relative_to_output(o,
-            &Path::new("bin/rustc"), &Path::new("lib/libstd.so"));
-      assert_eq!(res.as_slice(), "$ORIGIN/../lib");
+        let config = &mut RPathConfig {
+            os: abi::OsLinux,
+            used_crates: Vec::new(),
+            out_filename: Path::new("bin/rustc"),
+            get_install_prefix_lib_path: || fail!(),
+            realpath: |p| Ok(p.clone())
+        };
+        let res = get_rpath_relative_to_output(config, &Path::new("lib/libstd.so"));
+        assert_eq!(res.as_slice(), "$ORIGIN/../lib");
     }
 
     #[test]
     #[cfg(target_os = "freebsd")]
     fn test_rpath_relative() {
-        let o = abi::OsFreebsd;
-        let res = get_rpath_relative_to_output(o,
-            &Path::new("bin/rustc"), &Path::new("lib/libstd.so"));
+        let config = &mut RPathConfig {
+            os: abi::OsFreebsd,
+            used_crates: Vec::new(),
+            out_filename: Path::new("bin/rustc"),
+            get_install_prefix_lib_path: || fail!(),
+            realpath: |p| Ok(p.clone())
+        };
+        let res = get_rpath_relative_to_output(config, &Path::new("lib/libstd.so"));
         assert_eq!(res.as_slice(), "$ORIGIN/../lib");
     }
 
     #[test]
     #[cfg(target_os = "macos")]
     fn test_rpath_relative() {
-        let o = abi::OsMacos;
-        let res = get_rpath_relative_to_output(o,
-                                               &Path::new("bin/rustc"),
-                                               &Path::new("lib/libstd.so"));
+        let config = &mut RPathConfig {
+            os: abi::OsMacos,
+            used_crates: Vec::new(),
+            out_filename: Path::new("bin/rustc"),
+            get_install_prefix_lib_path: || fail!(),
+            realpath: |p| Ok(p.clone())
+        };
+        let res = get_rpath_relative_to_output(config, &Path::new("lib/libstd.so"));
         assert_eq!(res.as_slice(), "@loader_path/../lib");
     }
 }
diff --git a/src/librustc/util/sha2.rs b/src/librustc_back/sha2.rs
index bfd3deb0f2d..681de6a6626 100644
--- a/src/librustc/util/sha2.rs
+++ b/src/librustc_back/sha2.rs
@@ -12,6 +12,8 @@
 //! use. This implementation is not intended for external use or for any use where security is
 //! important.
 
+#![allow(deprecated)] // to_be32
+
 use std::iter::range_step;
 use std::num::Zero;
 use std::slice::bytes::{MutableByteVector, copy_memory};
diff --git a/src/librustc/back/svh.rs b/src/librustc_back/svh.rs
index 324ed3b567e..66bc8c740c4 100644
--- a/src/librustc/back/svh.rs
+++ b/src/librustc_back/svh.rs
@@ -53,8 +53,6 @@ use std::iter::range_step;
 use syntax::ast;
 use syntax::visit;
 
-use driver::session::Session;
-
 #[deriving(Clone, PartialEq)]
 pub struct Svh {
     hash: String,
@@ -70,7 +68,7 @@ impl Svh {
         self.hash.as_slice()
     }
 
-    pub fn calculate(sess: &Session, krate: &ast::Crate) -> Svh {
+    pub fn calculate(metadata: &Vec<String>, krate: &ast::Crate) -> Svh {
         // FIXME (#14132): This is better than it used to be, but it still not
         // ideal. We now attempt to hash only the relevant portions of the
         // Crate AST as well as the top-level crate attributes. (However,
@@ -82,7 +80,7 @@ impl Svh {
         //        avoid collisions.
         let mut state = SipState::new();
 
-        for data in sess.opts.cg.metadata.iter() {
+        for data in metadata.iter() {
             data.hash(&mut state);
         }
 
diff --git a/src/librustc/back/target_strs.rs b/src/librustc_back/target_strs.rs
index 7928f3d8db0..7928f3d8db0 100644
--- a/src/librustc/back/target_strs.rs
+++ b/src/librustc_back/target_strs.rs
diff --git a/src/librustc/back/x86.rs b/src/librustc_back/x86.rs
index d2dac03267d..b4d67bc98d2 100644
--- a/src/librustc/back/x86.rs
+++ b/src/librustc_back/x86.rs
@@ -9,7 +9,7 @@
 // except according to those terms.
 
 
-use back::target_strs;
+use target_strs;
 use syntax::abi;
 
 pub fn get_target_strs(target_triple: String, target_os: abi::Os)
diff --git a/src/librustc/back/x86_64.rs b/src/librustc_back/x86_64.rs
index c2eae18737b..70807edc996 100644
--- a/src/librustc/back/x86_64.rs
+++ b/src/librustc_back/x86_64.rs
@@ -9,7 +9,7 @@
 // except according to those terms.
 
 
-use back::target_strs;
+use target_strs;
 use syntax::abi;
 
 pub fn get_target_strs(target_triple: String, target_os: abi::Os) -> target_strs::t {
diff --git a/src/librustc_llvm/archive_ro.rs b/src/librustc_llvm/archive_ro.rs
new file mode 100644
index 00000000000..6c3778787e2
--- /dev/null
+++ b/src/librustc_llvm/archive_ro.rs
@@ -0,0 +1,68 @@
+// Copyright 2013-2014 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.
+
+//! A wrapper around LLVM's archive (.a) code
+
+use libc;
+use ArchiveRef;
+
+use std::raw;
+use std::mem;
+
+pub struct ArchiveRO {
+    ptr: ArchiveRef,
+}
+
+impl ArchiveRO {
+    /// Opens a static archive for read-only purposes. This is more optimized
+    /// than the `open` method because it uses LLVM's internal `Archive` class
+    /// rather than shelling out to `ar` for everything.
+    ///
+    /// If this archive is used with a mutable method, then an error will be
+    /// raised.
+    pub fn open(dst: &Path) -> Option<ArchiveRO> {
+        unsafe {
+            let ar = dst.with_c_str(|dst| {
+                ::LLVMRustOpenArchive(dst)
+            });
+            if ar.is_null() {
+                None
+            } else {
+                Some(ArchiveRO { ptr: ar })
+            }
+        }
+    }
+
+    /// Reads a file in the archive
+    pub fn read<'a>(&'a self, file: &str) -> Option<&'a [u8]> {
+        unsafe {
+            let mut size = 0 as libc::size_t;
+            let ptr = file.with_c_str(|file| {
+                ::LLVMRustArchiveReadSection(self.ptr, file, &mut size)
+            });
+            if ptr.is_null() {
+                None
+            } else {
+                Some(mem::transmute(raw::Slice {
+                    data: ptr,
+                    len: size as uint,
+                }))
+            }
+        }
+    }
+}
+
+impl Drop for ArchiveRO {
+    fn drop(&mut self) {
+        unsafe {
+            ::LLVMRustDestroyArchive(self.ptr);
+        }
+    }
+}
diff --git a/src/librustc_llvm/lib.rs b/src/librustc_llvm/lib.rs
new file mode 100644
index 00000000000..9ee8fa98c74
--- /dev/null
+++ b/src/librustc_llvm/lib.rs
@@ -0,0 +1,2003 @@
+// Copyright 2012-2014 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.
+
+#![allow(non_uppercase_pattern_statics)]
+#![allow(non_camel_case_types)]
+#![allow(non_snake_case_functions)]
+#![allow(dead_code)]
+
+#![crate_id = "rustc_llvm#0.11.0"]
+#![crate_name = "rustc_llvm"]
+#![experimental]
+#![license = "MIT/ASL2"]
+#![crate_type = "dylib"]
+#![crate_type = "rlib"]
+#![doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
+       html_favicon_url = "http://www.rust-lang.org/favicon.ico",
+       html_root_url = "http://doc.rust-lang.org/")]
+
+#![feature(globs)]
+#![feature(link_args)]
+#![allow(unused_attribute)] // NOTE: remove after stage0
+
+extern crate libc;
+
+use std::c_str::ToCStr;
+use libc::{c_uint, c_ushort, uint64_t, c_int, size_t, c_char};
+use libc::{c_longlong, c_ulonglong};
+use debuginfo::{DIBuilderRef, DIDescriptor,
+                DIFile, DILexicalBlock, DISubprogram, DIType,
+                DIBasicType, DIDerivedType, DICompositeType,
+                DIVariable, DIGlobalVariable, DIArray, DISubrange};
+
+pub mod archive_ro;
+
+pub type Opcode = u32;
+pub type Bool = c_uint;
+
+pub static True: Bool = 1 as Bool;
+pub static False: Bool = 0 as Bool;
+
+// Consts for the LLVM CallConv type, pre-cast to uint.
+
+#[deriving(PartialEq)]
+pub enum CallConv {
+    CCallConv = 0,
+    FastCallConv = 8,
+    ColdCallConv = 9,
+    X86StdcallCallConv = 64,
+    X86FastcallCallConv = 65,
+    X86_64_Win64 = 79,
+}
+
+pub enum Visibility {
+    LLVMDefaultVisibility = 0,
+    HiddenVisibility = 1,
+    ProtectedVisibility = 2,
+}
+
+// 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.
+pub enum Linkage {
+    ExternalLinkage = 0,
+    AvailableExternallyLinkage = 1,
+    LinkOnceAnyLinkage = 2,
+    LinkOnceODRLinkage = 3,
+    WeakAnyLinkage = 5,
+    WeakODRLinkage = 6,
+    AppendingLinkage = 7,
+    InternalLinkage = 8,
+    PrivateLinkage = 9,
+    ExternalWeakLinkage = 12,
+    CommonLinkage = 14,
+}
+
+#[deriving(Clone)]
+pub enum Attribute {
+    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,
+}
+
+#[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
+}
+
+// enum for the LLVM IntPredicate type
+pub enum IntPredicate {
+    IntEQ = 32,
+    IntNE = 33,
+    IntUGT = 34,
+    IntUGE = 35,
+    IntULT = 36,
+    IntULE = 37,
+    IntSGT = 38,
+    IntSGE = 39,
+    IntSLT = 40,
+    IntSLE = 41,
+}
+
+// enum for the LLVM RealPredicate type
+pub enum RealPredicate {
+    RealPredicateFalse = 0,
+    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,
+    RealPredicateTrue = 15,
+}
+
+// The LLVM TypeKind type - must stay in sync with the def of
+// LLVMTypeKind in llvm/include/llvm-c/Core.h
+#[deriving(PartialEq)]
+#[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,
+}
+
+#[repr(C)]
+pub enum AtomicBinOp {
+    Xchg = 0,
+    Add  = 1,
+    Sub  = 2,
+    And  = 3,
+    Nand = 4,
+    Or   = 5,
+    Xor  = 6,
+    Max  = 7,
+    Min  = 8,
+    UMax = 9,
+    UMin = 10,
+}
+
+#[repr(C)]
+pub enum AtomicOrdering {
+    NotAtomic = 0,
+    Unordered = 1,
+    Monotonic = 2,
+    // Consume = 3,  // Not specified yet.
+    Acquire = 4,
+    Release = 5,
+    AcquireRelease = 6,
+    SequentiallyConsistent = 7
+}
+
+// Consts for the LLVMCodeGenFileType type (in include/llvm/c/TargetMachine.h)
+#[repr(C)]
+pub enum FileType {
+    AssemblyFile = 0,
+    ObjectFile = 1
+}
+
+pub enum Metadata {
+    MD_dbg = 0,
+    MD_tbaa = 1,
+    MD_prof = 2,
+    MD_fpmath = 3,
+    MD_range = 4,
+    MD_tbaa_struct = 5
+}
+
+// Inline Asm Dialect
+pub enum AsmDialect {
+    AD_ATT   = 0,
+    AD_Intel = 1
+}
+
+#[deriving(PartialEq)]
+#[repr(C)]
+pub enum CodeGenOptLevel {
+    CodeGenLevelNone = 0,
+    CodeGenLevelLess = 1,
+    CodeGenLevelDefault = 2,
+    CodeGenLevelAggressive = 3,
+}
+
+#[repr(C)]
+pub enum RelocMode {
+    RelocDefault = 0,
+    RelocStatic = 1,
+    RelocPIC = 2,
+    RelocDynamicNoPic = 3,
+}
+
+#[repr(C)]
+pub enum CodeGenModel {
+    CodeModelDefault = 0,
+    CodeModelJITDefault = 1,
+    CodeModelSmall = 2,
+    CodeModelKernel = 3,
+    CodeModelMedium = 4,
+    CodeModelLarge = 5,
+}
+
+// Opaque pointer types
+pub enum Module_opaque {}
+pub type ModuleRef = *mut Module_opaque;
+pub enum Context_opaque {}
+pub type ContextRef = *mut Context_opaque;
+pub enum Type_opaque {}
+pub type TypeRef = *mut Type_opaque;
+pub enum Value_opaque {}
+pub type ValueRef = *mut Value_opaque;
+pub enum BasicBlock_opaque {}
+pub type BasicBlockRef = *mut BasicBlock_opaque;
+pub enum Builder_opaque {}
+pub type BuilderRef = *mut Builder_opaque;
+pub enum ExecutionEngine_opaque {}
+pub type ExecutionEngineRef = *mut ExecutionEngine_opaque;
+pub enum MemoryBuffer_opaque {}
+pub type MemoryBufferRef = *mut MemoryBuffer_opaque;
+pub enum PassManager_opaque {}
+pub type PassManagerRef = *mut PassManager_opaque;
+pub enum PassManagerBuilder_opaque {}
+pub type PassManagerBuilderRef = *mut PassManagerBuilder_opaque;
+pub enum Use_opaque {}
+pub type UseRef = *mut Use_opaque;
+pub enum TargetData_opaque {}
+pub type TargetDataRef = *mut TargetData_opaque;
+pub enum ObjectFile_opaque {}
+pub type ObjectFileRef = *mut ObjectFile_opaque;
+pub enum SectionIterator_opaque {}
+pub type SectionIteratorRef = *mut SectionIterator_opaque;
+pub enum Pass_opaque {}
+pub type PassRef = *mut Pass_opaque;
+pub enum TargetMachine_opaque {}
+pub type TargetMachineRef = *mut TargetMachine_opaque;
+pub enum Archive_opaque {}
+pub type ArchiveRef = *mut Archive_opaque;
+
+pub mod debuginfo {
+    use super::{ValueRef};
+
+    pub enum DIBuilder_opaque {}
+    pub type DIBuilderRef = *mut DIBuilder_opaque;
+
+    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;
+    pub type DIGlobalVariable = DIDescriptor;
+    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
+    }
+}
+
+
+// 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")]
+extern {
+    /* Create and destroy contexts. */
+    pub fn LLVMContextCreate() -> ContextRef;
+    pub fn LLVMContextDispose(C: ContextRef);
+    pub fn LLVMGetMDKindIDInContext(C: ContextRef,
+                                    Name: *const c_char,
+                                    SLen: c_uint)
+                                    -> c_uint;
+
+    /* Create and destroy modules. */
+    pub fn LLVMModuleCreateWithNameInContext(ModuleID: *const c_char,
+                                             C: ContextRef)
+                                             -> ModuleRef;
+    pub fn LLVMGetModuleContext(M: ModuleRef) -> ContextRef;
+    pub fn LLVMDisposeModule(M: ModuleRef);
+
+    /** Data layout. See Module::getDataLayout. */
+    pub fn LLVMGetDataLayout(M: ModuleRef) -> *const c_char;
+    pub fn LLVMSetDataLayout(M: ModuleRef, Triple: *const c_char);
+
+    /** Target triple. See Module::getTargetTriple. */
+    pub fn LLVMGetTarget(M: ModuleRef) -> *const c_char;
+    pub fn LLVMSetTarget(M: ModuleRef, Triple: *const c_char);
+
+    /** See Module::dump. */
+    pub fn LLVMDumpModule(M: ModuleRef);
+
+    /** See Module::setModuleInlineAsm. */
+    pub fn LLVMSetModuleInlineAsm(M: ModuleRef, Asm: *const c_char);
+
+    /** See llvm::LLVMTypeKind::getTypeID. */
+    pub fn LLVMGetTypeKind(Ty: TypeRef) -> TypeKind;
+
+    /** See llvm::LLVMType::getContext. */
+    pub fn LLVMGetTypeContext(Ty: TypeRef) -> ContextRef;
+
+    /* Operations on integer types */
+    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;
+
+    pub fn LLVMGetIntTypeWidth(IntegerTy: TypeRef) -> c_uint;
+
+    /* Operations on real types */
+    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;
+
+    /* Operations on function types */
+    pub fn LLVMFunctionType(ReturnType: TypeRef,
+                            ParamTypes: *const 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: *const TypeRef);
+
+    /* Operations on struct types */
+    pub fn LLVMStructTypeInContext(C: ContextRef,
+                                   ElementTypes: *const 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;
+
+    /* Operations on array, pointer, and vector types (sequence types) */
+    pub fn LLVMRustArrayType(ElementType: TypeRef, ElementCount: u64) -> TypeRef;
+    pub fn LLVMPointerType(ElementType: TypeRef, AddressSpace: c_uint)
+                           -> TypeRef;
+    pub fn LLVMVectorType(ElementType: TypeRef, ElementCount: c_uint)
+                          -> TypeRef;
+
+    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)
+                                  -> *const ();
+    pub fn LLVMGetVectorSize(VectorTy: TypeRef) -> c_uint;
+
+    /* Operations on other types */
+    pub fn LLVMVoidTypeInContext(C: ContextRef) -> TypeRef;
+    pub fn LLVMLabelTypeInContext(C: ContextRef) -> TypeRef;
+    pub fn LLVMMetadataTypeInContext(C: ContextRef) -> TypeRef;
+
+    /* Operations on all values */
+    pub fn LLVMTypeOf(Val: ValueRef) -> TypeRef;
+    pub fn LLVMGetValueName(Val: ValueRef) -> *const c_char;
+    pub fn LLVMSetValueName(Val: ValueRef, Name: *const 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);
+
+    /* Operations on Uses */
+    pub fn LLVMGetFirstUse(Val: ValueRef) -> UseRef;
+    pub fn LLVMGetNextUse(U: UseRef) -> UseRef;
+    pub fn LLVMGetUser(U: UseRef) -> ValueRef;
+    pub fn LLVMGetUsedValue(U: UseRef) -> ValueRef;
+
+    /* Operations on Users */
+    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);
+
+    /* Operations on constants of any type */
+    pub fn LLVMConstNull(Ty: TypeRef) -> ValueRef;
+    /* all zeroes */
+    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;
+    /* only for int/vector */
+    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;
+
+    /* Operations on metadata */
+    pub fn LLVMMDStringInContext(C: ContextRef,
+                                 Str: *const c_char,
+                                 SLen: c_uint)
+                                 -> ValueRef;
+    pub fn LLVMMDNodeInContext(C: ContextRef,
+                               Vals: *const ValueRef,
+                               Count: c_uint)
+                               -> ValueRef;
+    pub fn LLVMAddNamedMetadataOperand(M: ModuleRef,
+                                       Str: *const c_char,
+                                       Val: ValueRef);
+
+    /* Operations on scalar constants */
+    pub fn LLVMConstInt(IntTy: TypeRef, N: c_ulonglong, SignExtend: Bool)
+                        -> ValueRef;
+    pub fn LLVMConstIntOfString(IntTy: TypeRef, Text: *const c_char, Radix: u8)
+                                -> ValueRef;
+    pub fn LLVMConstIntOfStringAndSize(IntTy: TypeRef,
+                                       Text: *const c_char,
+                                       SLen: c_uint,
+                                       Radix: u8)
+                                       -> ValueRef;
+    pub fn LLVMConstReal(RealTy: TypeRef, N: f64) -> ValueRef;
+    pub fn LLVMConstRealOfString(RealTy: TypeRef, Text: *const c_char)
+                                 -> ValueRef;
+    pub fn LLVMConstRealOfStringAndSize(RealTy: TypeRef,
+                                        Text: *const c_char,
+                                        SLen: c_uint)
+                                        -> ValueRef;
+    pub fn LLVMConstIntGetZExtValue(ConstantVal: ValueRef) -> c_ulonglong;
+    pub fn LLVMConstIntGetSExtValue(ConstantVal: ValueRef) -> c_longlong;
+
+
+    /* Operations on composite constants */
+    pub fn LLVMConstStringInContext(C: ContextRef,
+                                    Str: *const c_char,
+                                    Length: c_uint,
+                                    DontNullTerminate: Bool)
+                                    -> ValueRef;
+    pub fn LLVMConstStructInContext(C: ContextRef,
+                                    ConstantVals: *const ValueRef,
+                                    Count: c_uint,
+                                    Packed: Bool)
+                                    -> ValueRef;
+
+    pub fn LLVMConstArray(ElementTy: TypeRef,
+                          ConstantVals: *const ValueRef,
+                          Length: c_uint)
+                          -> ValueRef;
+    pub fn LLVMConstVector(ScalarConstantVals: *const ValueRef, Size: c_uint)
+                           -> ValueRef;
+
+    /* Constant expressions */
+    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)
+                           -> ValueRef;
+    pub fn LLVMConstNUWAdd(LHSConstant: ValueRef, RHSConstant: ValueRef)
+                           -> ValueRef;
+    pub fn LLVMConstFAdd(LHSConstant: ValueRef, RHSConstant: ValueRef)
+                         -> ValueRef;
+    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)
+                        -> ValueRef;
+    pub fn LLVMConstNSWMul(LHSConstant: ValueRef, RHSConstant: ValueRef)
+                           -> ValueRef;
+    pub fn LLVMConstNUWMul(LHSConstant: ValueRef, RHSConstant: ValueRef)
+                           -> ValueRef;
+    pub fn LLVMConstFMul(LHSConstant: ValueRef, RHSConstant: ValueRef)
+                         -> ValueRef;
+    pub fn LLVMConstUDiv(LHSConstant: ValueRef, RHSConstant: ValueRef)
+                         -> ValueRef;
+    pub fn LLVMConstSDiv(LHSConstant: ValueRef, RHSConstant: ValueRef)
+                         -> ValueRef;
+    pub fn LLVMConstExactSDiv(LHSConstant: ValueRef,
+                              RHSConstant: ValueRef)
+                              -> ValueRef;
+    pub fn LLVMConstFDiv(LHSConstant: ValueRef, RHSConstant: ValueRef)
+                         -> ValueRef;
+    pub fn LLVMConstURem(LHSConstant: ValueRef, RHSConstant: ValueRef)
+                         -> ValueRef;
+    pub fn LLVMConstSRem(LHSConstant: ValueRef, RHSConstant: ValueRef)
+                         -> ValueRef;
+    pub fn LLVMConstFRem(LHSConstant: ValueRef, RHSConstant: ValueRef)
+                         -> ValueRef;
+    pub fn LLVMConstAnd(LHSConstant: ValueRef, RHSConstant: ValueRef)
+                        -> ValueRef;
+    pub fn LLVMConstOr(LHSConstant: ValueRef, RHSConstant: ValueRef)
+                       -> ValueRef;
+    pub fn LLVMConstXor(LHSConstant: ValueRef, RHSConstant: ValueRef)
+                        -> ValueRef;
+    pub fn LLVMConstShl(LHSConstant: ValueRef, RHSConstant: ValueRef)
+                        -> ValueRef;
+    pub fn LLVMConstLShr(LHSConstant: ValueRef, RHSConstant: ValueRef)
+                         -> ValueRef;
+    pub fn LLVMConstAShr(LHSConstant: ValueRef, RHSConstant: ValueRef)
+                         -> ValueRef;
+    pub fn LLVMConstGEP(ConstantVal: ValueRef,
+                        ConstantIndices: *const ValueRef,
+                        NumIndices: c_uint)
+                        -> ValueRef;
+    pub fn LLVMConstInBoundsGEP(ConstantVal: ValueRef,
+                                ConstantIndices: *const ValueRef,
+                                NumIndices: c_uint)
+                                -> ValueRef;
+    pub fn LLVMConstTrunc(ConstantVal: ValueRef, ToType: TypeRef)
+                          -> ValueRef;
+    pub fn LLVMConstSExt(ConstantVal: ValueRef, ToType: TypeRef)
+                         -> ValueRef;
+    pub fn LLVMConstZExt(ConstantVal: ValueRef, ToType: TypeRef)
+                         -> ValueRef;
+    pub fn LLVMConstFPTrunc(ConstantVal: ValueRef, ToType: TypeRef)
+                            -> ValueRef;
+    pub fn LLVMConstFPExt(ConstantVal: ValueRef, ToType: TypeRef)
+                          -> ValueRef;
+    pub fn LLVMConstUIToFP(ConstantVal: ValueRef, ToType: TypeRef)
+                           -> ValueRef;
+    pub fn LLVMConstSIToFP(ConstantVal: ValueRef, ToType: TypeRef)
+                           -> ValueRef;
+    pub fn LLVMConstFPToUI(ConstantVal: ValueRef, ToType: TypeRef)
+                           -> ValueRef;
+    pub fn LLVMConstFPToSI(ConstantVal: ValueRef, ToType: TypeRef)
+                           -> ValueRef;
+    pub fn LLVMConstPtrToInt(ConstantVal: ValueRef, ToType: TypeRef)
+                             -> ValueRef;
+    pub fn LLVMConstIntToPtr(ConstantVal: ValueRef, ToType: TypeRef)
+                             -> ValueRef;
+    pub fn LLVMConstBitCast(ConstantVal: ValueRef, ToType: TypeRef)
+                            -> ValueRef;
+    pub fn LLVMConstZExtOrBitCast(ConstantVal: ValueRef, ToType: TypeRef)
+                                  -> ValueRef;
+    pub fn LLVMConstSExtOrBitCast(ConstantVal: ValueRef, ToType: TypeRef)
+                                  -> ValueRef;
+    pub fn LLVMConstTruncOrBitCast(ConstantVal: ValueRef, ToType: TypeRef)
+                                   -> ValueRef;
+    pub fn LLVMConstPointerCast(ConstantVal: ValueRef, ToType: TypeRef)
+                                -> ValueRef;
+    pub fn LLVMConstIntCast(ConstantVal: ValueRef,
+                            ToType: TypeRef,
+                            isSigned: Bool)
+                            -> ValueRef;
+    pub fn LLVMConstFPCast(ConstantVal: ValueRef, ToType: TypeRef)
+                           -> ValueRef;
+    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: *const c_uint,
+                                 NumIdx: c_uint)
+                                 -> ValueRef;
+    pub fn LLVMConstInsertValue(AggConstant: ValueRef,
+                                ElementValueConstant: ValueRef,
+                                IdxList: *const c_uint,
+                                NumIdx: c_uint)
+                                -> ValueRef;
+    pub fn LLVMConstInlineAsm(Ty: TypeRef,
+                              AsmString: *const c_char,
+                              Constraints: *const c_char,
+                              HasSideEffects: Bool,
+                              IsAlignStack: Bool)
+                              -> ValueRef;
+    pub fn LLVMBlockAddress(F: ValueRef, BB: BasicBlockRef) -> ValueRef;
+
+
+
+    /* Operations on global variables, functions, and aliases (globals) */
+    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) -> *const c_char;
+    pub fn LLVMSetSection(Global: ValueRef, Section: *const 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);
+
+
+    /* Operations on global variables */
+    pub fn LLVMAddGlobal(M: ModuleRef, Ty: TypeRef, Name: *const c_char)
+                         -> ValueRef;
+    pub fn LLVMAddGlobalInAddressSpace(M: ModuleRef,
+                                       Ty: TypeRef,
+                                       Name: *const c_char,
+                                       AddressSpace: c_uint)
+                                       -> ValueRef;
+    pub fn LLVMGetNamedGlobal(M: ModuleRef, Name: *const 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,
+                              ConstantVal: ValueRef);
+    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);
+
+    /* Operations on aliases */
+    pub fn LLVMAddAlias(M: ModuleRef,
+                        Ty: TypeRef,
+                        Aliasee: ValueRef,
+                        Name: *const c_char)
+                        -> ValueRef;
+
+    /* Operations on functions */
+    pub fn LLVMAddFunction(M: ModuleRef,
+                           Name: *const c_char,
+                           FunctionTy: TypeRef)
+                           -> ValueRef;
+    pub fn LLVMGetNamedFunction(M: ModuleRef, Name: *const 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: *const 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) -> *const c_char;
+    pub fn LLVMSetGC(Fn: ValueRef, Name: *const c_char);
+    pub fn LLVMAddFunctionAttribute(Fn: ValueRef, index: c_uint, PA: uint64_t);
+    pub fn LLVMAddFunctionAttrString(Fn: ValueRef, index: c_uint, Name: *const c_char);
+    pub fn LLVMRemoveFunctionAttrString(Fn: ValueRef, index: c_uint, Name: *const c_char);
+    pub fn LLVMGetFunctionAttr(Fn: ValueRef) -> c_ulonglong;
+
+    /* Operations on parameters */
+    pub fn LLVMCountParams(Fn: ValueRef) -> c_uint;
+    pub fn LLVMGetParams(Fn: ValueRef, Params: *const 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);
+
+    /* Operations on basic blocks */
+    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: *const 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;
+
+    pub fn LLVMAppendBasicBlockInContext(C: ContextRef,
+                                         Fn: ValueRef,
+                                         Name: *const c_char)
+                                         -> BasicBlockRef;
+    pub fn LLVMInsertBasicBlockInContext(C: ContextRef,
+                                         BB: BasicBlockRef,
+                                         Name: *const c_char)
+                                         -> BasicBlockRef;
+    pub fn LLVMDeleteBasicBlock(BB: BasicBlockRef);
+
+    pub fn LLVMMoveBasicBlockAfter(BB: BasicBlockRef,
+                                   MoveAfter: BasicBlockRef);
+
+    pub fn LLVMMoveBasicBlockBefore(BB: BasicBlockRef,
+                                    MoveBefore: BasicBlockRef);
+
+    /* Operations on instructions */
+    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);
+
+    /* Operations on call sites */
+    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);
+    pub fn LLVMAddCallSiteAttribute(Instr: ValueRef,
+                                    index: c_uint,
+                                    Val: uint64_t);
+
+    /* Operations on call instructions (only) */
+    pub fn LLVMIsTailCall(CallInst: ValueRef) -> Bool;
+    pub fn LLVMSetTailCall(CallInst: ValueRef, IsTailCall: Bool);
+
+    /* Operations on load/store instructions (only) */
+    pub fn LLVMGetVolatile(MemoryAccessInst: ValueRef) -> Bool;
+    pub fn LLVMSetVolatile(MemoryAccessInst: ValueRef, volatile: Bool);
+
+    /* Operations on phi nodes */
+    pub fn LLVMAddIncoming(PhiNode: ValueRef,
+                           IncomingValues: *const ValueRef,
+                           IncomingBlocks: *const BasicBlockRef,
+                           Count: c_uint);
+    pub fn LLVMCountIncoming(PhiNode: ValueRef) -> c_uint;
+    pub fn LLVMGetIncomingValue(PhiNode: ValueRef, Index: c_uint)
+                                -> ValueRef;
+    pub fn LLVMGetIncomingBlock(PhiNode: ValueRef, Index: c_uint)
+                                -> BasicBlockRef;
+
+    /* Instruction builders */
+    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: *const c_char);
+    pub fn LLVMDisposeBuilder(Builder: BuilderRef);
+    pub fn LLVMDisposeExecutionEngine(EE: ExecutionEngineRef);
+
+    /* Metadata */
+    pub fn LLVMSetCurrentDebugLocation(Builder: BuilderRef, L: ValueRef);
+    pub fn LLVMGetCurrentDebugLocation(Builder: BuilderRef) -> ValueRef;
+    pub fn LLVMSetInstDebugLocation(Builder: BuilderRef, Inst: ValueRef);
+
+    /* Terminators */
+    pub fn LLVMBuildRetVoid(B: BuilderRef) -> ValueRef;
+    pub fn LLVMBuildRet(B: BuilderRef, V: ValueRef) -> ValueRef;
+    pub fn LLVMBuildAggregateRet(B: BuilderRef,
+                                 RetVals: *const ValueRef,
+                                 N: c_uint)
+                                 -> ValueRef;
+    pub fn LLVMBuildBr(B: BuilderRef, Dest: BasicBlockRef) -> ValueRef;
+    pub fn LLVMBuildCondBr(B: BuilderRef,
+                           If: ValueRef,
+                           Then: BasicBlockRef,
+                           Else: BasicBlockRef)
+                           -> ValueRef;
+    pub fn LLVMBuildSwitch(B: BuilderRef,
+                           V: ValueRef,
+                           Else: BasicBlockRef,
+                           NumCases: c_uint)
+                           -> ValueRef;
+    pub fn LLVMBuildIndirectBr(B: BuilderRef,
+                               Addr: ValueRef,
+                               NumDests: c_uint)
+                               -> ValueRef;
+    pub fn LLVMBuildInvoke(B: BuilderRef,
+                           Fn: ValueRef,
+                           Args: *const ValueRef,
+                           NumArgs: c_uint,
+                           Then: BasicBlockRef,
+                           Catch: BasicBlockRef,
+                           Name: *const c_char)
+                           -> ValueRef;
+    pub fn LLVMBuildLandingPad(B: BuilderRef,
+                               Ty: TypeRef,
+                               PersFn: ValueRef,
+                               NumClauses: c_uint,
+                               Name: *const c_char)
+                               -> ValueRef;
+    pub fn LLVMBuildResume(B: BuilderRef, Exn: ValueRef) -> ValueRef;
+    pub fn LLVMBuildUnreachable(B: BuilderRef) -> ValueRef;
+
+    /* Add a case to the switch instruction */
+    pub fn LLVMAddCase(Switch: ValueRef,
+                       OnVal: ValueRef,
+                       Dest: BasicBlockRef);
+
+    /* Add a destination to the indirectbr instruction */
+    pub fn LLVMAddDestination(IndirectBr: ValueRef, Dest: BasicBlockRef);
+
+    /* Add a clause to the landing pad instruction */
+    pub fn LLVMAddClause(LandingPad: ValueRef, ClauseVal: ValueRef);
+
+    /* Set the cleanup on a landing pad instruction */
+    pub fn LLVMSetCleanup(LandingPad: ValueRef, Val: Bool);
+
+    /* Arithmetic */
+    pub fn LLVMBuildAdd(B: BuilderRef,
+                        LHS: ValueRef,
+                        RHS: ValueRef,
+                        Name: *const c_char)
+                        -> ValueRef;
+    pub fn LLVMBuildNSWAdd(B: BuilderRef,
+                           LHS: ValueRef,
+                           RHS: ValueRef,
+                           Name: *const c_char)
+                           -> ValueRef;
+    pub fn LLVMBuildNUWAdd(B: BuilderRef,
+                           LHS: ValueRef,
+                           RHS: ValueRef,
+                           Name: *const c_char)
+                           -> ValueRef;
+    pub fn LLVMBuildFAdd(B: BuilderRef,
+                         LHS: ValueRef,
+                         RHS: ValueRef,
+                         Name: *const c_char)
+                         -> ValueRef;
+    pub fn LLVMBuildSub(B: BuilderRef,
+                        LHS: ValueRef,
+                        RHS: ValueRef,
+                        Name: *const c_char)
+                        -> ValueRef;
+    pub fn LLVMBuildNSWSub(B: BuilderRef,
+                           LHS: ValueRef,
+                           RHS: ValueRef,
+                           Name: *const c_char)
+                           -> ValueRef;
+    pub fn LLVMBuildNUWSub(B: BuilderRef,
+                           LHS: ValueRef,
+                           RHS: ValueRef,
+                           Name: *const c_char)
+                           -> ValueRef;
+    pub fn LLVMBuildFSub(B: BuilderRef,
+                         LHS: ValueRef,
+                         RHS: ValueRef,
+                         Name: *const c_char)
+                         -> ValueRef;
+    pub fn LLVMBuildMul(B: BuilderRef,
+                        LHS: ValueRef,
+                        RHS: ValueRef,
+                        Name: *const c_char)
+                        -> ValueRef;
+    pub fn LLVMBuildNSWMul(B: BuilderRef,
+                           LHS: ValueRef,
+                           RHS: ValueRef,
+                           Name: *const c_char)
+                           -> ValueRef;
+    pub fn LLVMBuildNUWMul(B: BuilderRef,
+                           LHS: ValueRef,
+                           RHS: ValueRef,
+                           Name: *const c_char)
+                           -> ValueRef;
+    pub fn LLVMBuildFMul(B: BuilderRef,
+                         LHS: ValueRef,
+                         RHS: ValueRef,
+                         Name: *const c_char)
+                         -> ValueRef;
+    pub fn LLVMBuildUDiv(B: BuilderRef,
+                         LHS: ValueRef,
+                         RHS: ValueRef,
+                         Name: *const c_char)
+                         -> ValueRef;
+    pub fn LLVMBuildSDiv(B: BuilderRef,
+                         LHS: ValueRef,
+                         RHS: ValueRef,
+                         Name: *const c_char)
+                         -> ValueRef;
+    pub fn LLVMBuildExactSDiv(B: BuilderRef,
+                              LHS: ValueRef,
+                              RHS: ValueRef,
+                              Name: *const c_char)
+                              -> ValueRef;
+    pub fn LLVMBuildFDiv(B: BuilderRef,
+                         LHS: ValueRef,
+                         RHS: ValueRef,
+                         Name: *const c_char)
+                         -> ValueRef;
+    pub fn LLVMBuildURem(B: BuilderRef,
+                         LHS: ValueRef,
+                         RHS: ValueRef,
+                         Name: *const c_char)
+                         -> ValueRef;
+    pub fn LLVMBuildSRem(B: BuilderRef,
+                         LHS: ValueRef,
+                         RHS: ValueRef,
+                         Name: *const c_char)
+                         -> ValueRef;
+    pub fn LLVMBuildFRem(B: BuilderRef,
+                         LHS: ValueRef,
+                         RHS: ValueRef,
+                         Name: *const c_char)
+                         -> ValueRef;
+    pub fn LLVMBuildShl(B: BuilderRef,
+                        LHS: ValueRef,
+                        RHS: ValueRef,
+                        Name: *const c_char)
+                        -> ValueRef;
+    pub fn LLVMBuildLShr(B: BuilderRef,
+                         LHS: ValueRef,
+                         RHS: ValueRef,
+                         Name: *const c_char)
+                         -> ValueRef;
+    pub fn LLVMBuildAShr(B: BuilderRef,
+                         LHS: ValueRef,
+                         RHS: ValueRef,
+                         Name: *const c_char)
+                         -> ValueRef;
+    pub fn LLVMBuildAnd(B: BuilderRef,
+                        LHS: ValueRef,
+                        RHS: ValueRef,
+                        Name: *const c_char)
+                        -> ValueRef;
+    pub fn LLVMBuildOr(B: BuilderRef,
+                       LHS: ValueRef,
+                       RHS: ValueRef,
+                       Name: *const c_char)
+                           -> ValueRef;
+    pub fn LLVMBuildXor(B: BuilderRef,
+                        LHS: ValueRef,
+                        RHS: ValueRef,
+                        Name: *const c_char)
+                        -> ValueRef;
+    pub fn LLVMBuildBinOp(B: BuilderRef,
+                          Op: Opcode,
+                          LHS: ValueRef,
+                          RHS: ValueRef,
+                          Name: *const c_char)
+                          -> ValueRef;
+    pub fn LLVMBuildNeg(B: BuilderRef, V: ValueRef, Name: *const c_char)
+                        -> ValueRef;
+    pub fn LLVMBuildNSWNeg(B: BuilderRef, V: ValueRef, Name: *const c_char)
+                           -> ValueRef;
+    pub fn LLVMBuildNUWNeg(B: BuilderRef, V: ValueRef, Name: *const c_char)
+                           -> ValueRef;
+    pub fn LLVMBuildFNeg(B: BuilderRef, V: ValueRef, Name: *const c_char)
+                         -> ValueRef;
+    pub fn LLVMBuildNot(B: BuilderRef, V: ValueRef, Name: *const c_char)
+                        -> ValueRef;
+
+    /* Memory */
+    pub fn LLVMBuildMalloc(B: BuilderRef, Ty: TypeRef, Name: *const c_char)
+                           -> ValueRef;
+    pub fn LLVMBuildArrayMalloc(B: BuilderRef,
+                                Ty: TypeRef,
+                                Val: ValueRef,
+                                Name: *const c_char)
+                                -> ValueRef;
+    pub fn LLVMBuildAlloca(B: BuilderRef, Ty: TypeRef, Name: *const c_char)
+                           -> ValueRef;
+    pub fn LLVMBuildArrayAlloca(B: BuilderRef,
+                                Ty: TypeRef,
+                                Val: ValueRef,
+                                Name: *const c_char)
+                                -> ValueRef;
+    pub fn LLVMBuildFree(B: BuilderRef, PointerVal: ValueRef) -> ValueRef;
+    pub fn LLVMBuildLoad(B: BuilderRef,
+                         PointerVal: ValueRef,
+                         Name: *const c_char)
+                         -> ValueRef;
+
+    pub fn LLVMBuildStore(B: BuilderRef, Val: ValueRef, Ptr: ValueRef)
+                          -> ValueRef;
+
+    pub fn LLVMBuildGEP(B: BuilderRef,
+                        Pointer: ValueRef,
+                        Indices: *const ValueRef,
+                        NumIndices: c_uint,
+                        Name: *const c_char)
+                        -> ValueRef;
+    pub fn LLVMBuildInBoundsGEP(B: BuilderRef,
+                                Pointer: ValueRef,
+                                Indices: *const ValueRef,
+                                NumIndices: c_uint,
+                                Name: *const c_char)
+                                -> ValueRef;
+    pub fn LLVMBuildStructGEP(B: BuilderRef,
+                              Pointer: ValueRef,
+                              Idx: c_uint,
+                              Name: *const c_char)
+                              -> ValueRef;
+    pub fn LLVMBuildGlobalString(B: BuilderRef,
+                                 Str: *const c_char,
+                                 Name: *const c_char)
+                                 -> ValueRef;
+    pub fn LLVMBuildGlobalStringPtr(B: BuilderRef,
+                                    Str: *const c_char,
+                                    Name: *const c_char)
+                                    -> ValueRef;
+
+    /* Casts */
+    pub fn LLVMBuildTrunc(B: BuilderRef,
+                          Val: ValueRef,
+                          DestTy: TypeRef,
+                          Name: *const c_char)
+                          -> ValueRef;
+    pub fn LLVMBuildZExt(B: BuilderRef,
+                         Val: ValueRef,
+                         DestTy: TypeRef,
+                         Name: *const c_char)
+                         -> ValueRef;
+    pub fn LLVMBuildSExt(B: BuilderRef,
+                         Val: ValueRef,
+                         DestTy: TypeRef,
+                         Name: *const c_char)
+                         -> ValueRef;
+    pub fn LLVMBuildFPToUI(B: BuilderRef,
+                           Val: ValueRef,
+                           DestTy: TypeRef,
+                           Name: *const c_char)
+                           -> ValueRef;
+    pub fn LLVMBuildFPToSI(B: BuilderRef,
+                           Val: ValueRef,
+                           DestTy: TypeRef,
+                           Name: *const c_char)
+                           -> ValueRef;
+    pub fn LLVMBuildUIToFP(B: BuilderRef,
+                           Val: ValueRef,
+                           DestTy: TypeRef,
+                           Name: *const c_char)
+                           -> ValueRef;
+    pub fn LLVMBuildSIToFP(B: BuilderRef,
+                           Val: ValueRef,
+                           DestTy: TypeRef,
+                           Name: *const c_char)
+                           -> ValueRef;
+    pub fn LLVMBuildFPTrunc(B: BuilderRef,
+                            Val: ValueRef,
+                            DestTy: TypeRef,
+                            Name: *const c_char)
+                            -> ValueRef;
+    pub fn LLVMBuildFPExt(B: BuilderRef,
+                          Val: ValueRef,
+                          DestTy: TypeRef,
+                          Name: *const c_char)
+                          -> ValueRef;
+    pub fn LLVMBuildPtrToInt(B: BuilderRef,
+                             Val: ValueRef,
+                             DestTy: TypeRef,
+                             Name: *const c_char)
+                             -> ValueRef;
+    pub fn LLVMBuildIntToPtr(B: BuilderRef,
+                             Val: ValueRef,
+                             DestTy: TypeRef,
+                             Name: *const c_char)
+                             -> ValueRef;
+    pub fn LLVMBuildBitCast(B: BuilderRef,
+                            Val: ValueRef,
+                            DestTy: TypeRef,
+                            Name: *const c_char)
+                            -> ValueRef;
+    pub fn LLVMBuildZExtOrBitCast(B: BuilderRef,
+                                  Val: ValueRef,
+                                  DestTy: TypeRef,
+                                  Name: *const c_char)
+                                  -> ValueRef;
+    pub fn LLVMBuildSExtOrBitCast(B: BuilderRef,
+                                  Val: ValueRef,
+                                  DestTy: TypeRef,
+                                  Name: *const c_char)
+                                  -> ValueRef;
+    pub fn LLVMBuildTruncOrBitCast(B: BuilderRef,
+                                   Val: ValueRef,
+                                   DestTy: TypeRef,
+                                   Name: *const c_char)
+                                   -> ValueRef;
+    pub fn LLVMBuildCast(B: BuilderRef,
+                         Op: Opcode,
+                         Val: ValueRef,
+                         DestTy: TypeRef,
+                         Name: *const c_char) -> ValueRef;
+    pub fn LLVMBuildPointerCast(B: BuilderRef,
+                                Val: ValueRef,
+                                DestTy: TypeRef,
+                                Name: *const c_char)
+                                -> ValueRef;
+    pub fn LLVMBuildIntCast(B: BuilderRef,
+                            Val: ValueRef,
+                            DestTy: TypeRef,
+                            Name: *const c_char)
+                            -> ValueRef;
+    pub fn LLVMBuildFPCast(B: BuilderRef,
+                           Val: ValueRef,
+                           DestTy: TypeRef,
+                           Name: *const c_char)
+                           -> ValueRef;
+
+    /* Comparisons */
+    pub fn LLVMBuildICmp(B: BuilderRef,
+                         Op: c_uint,
+                         LHS: ValueRef,
+                         RHS: ValueRef,
+                         Name: *const c_char)
+                         -> ValueRef;
+    pub fn LLVMBuildFCmp(B: BuilderRef,
+                         Op: c_uint,
+                         LHS: ValueRef,
+                         RHS: ValueRef,
+                         Name: *const c_char)
+                         -> ValueRef;
+
+    /* Miscellaneous instructions */
+    pub fn LLVMBuildPhi(B: BuilderRef, Ty: TypeRef, Name: *const c_char)
+                        -> ValueRef;
+    pub fn LLVMBuildCall(B: BuilderRef,
+                         Fn: ValueRef,
+                         Args: *const ValueRef,
+                         NumArgs: c_uint,
+                         Name: *const c_char)
+                         -> ValueRef;
+    pub fn LLVMBuildSelect(B: BuilderRef,
+                           If: ValueRef,
+                           Then: ValueRef,
+                           Else: ValueRef,
+                           Name: *const c_char)
+                           -> ValueRef;
+    pub fn LLVMBuildVAArg(B: BuilderRef,
+                          list: ValueRef,
+                          Ty: TypeRef,
+                          Name: *const c_char)
+                          -> ValueRef;
+    pub fn LLVMBuildExtractElement(B: BuilderRef,
+                                   VecVal: ValueRef,
+                                   Index: ValueRef,
+                                   Name: *const c_char)
+                                   -> ValueRef;
+    pub fn LLVMBuildInsertElement(B: BuilderRef,
+                                  VecVal: ValueRef,
+                                  EltVal: ValueRef,
+                                  Index: ValueRef,
+                                  Name: *const c_char)
+                                  -> ValueRef;
+    pub fn LLVMBuildShuffleVector(B: BuilderRef,
+                                  V1: ValueRef,
+                                  V2: ValueRef,
+                                  Mask: ValueRef,
+                                  Name: *const c_char)
+                                  -> ValueRef;
+    pub fn LLVMBuildExtractValue(B: BuilderRef,
+                                 AggVal: ValueRef,
+                                 Index: c_uint,
+                                 Name: *const c_char)
+                                 -> ValueRef;
+    pub fn LLVMBuildInsertValue(B: BuilderRef,
+                                AggVal: ValueRef,
+                                EltVal: ValueRef,
+                                Index: c_uint,
+                                Name: *const c_char)
+                                -> ValueRef;
+
+    pub fn LLVMBuildIsNull(B: BuilderRef, Val: ValueRef, Name: *const c_char)
+                           -> ValueRef;
+    pub fn LLVMBuildIsNotNull(B: BuilderRef, Val: ValueRef, Name: *const c_char)
+                              -> ValueRef;
+    pub fn LLVMBuildPtrDiff(B: BuilderRef,
+                            LHS: ValueRef,
+                            RHS: ValueRef,
+                            Name: *const c_char)
+                            -> ValueRef;
+
+    /* Atomic Operations */
+    pub fn LLVMBuildAtomicLoad(B: BuilderRef,
+                               PointerVal: ValueRef,
+                               Name: *const c_char,
+                               Order: AtomicOrdering,
+                               Alignment: c_uint)
+                               -> ValueRef;
+
+    pub fn LLVMBuildAtomicStore(B: BuilderRef,
+                                Val: ValueRef,
+                                Ptr: ValueRef,
+                                Order: AtomicOrdering,
+                                Alignment: c_uint)
+                                -> ValueRef;
+
+    pub fn LLVMBuildAtomicCmpXchg(B: BuilderRef,
+                                  LHS: ValueRef,
+                                  CMP: ValueRef,
+                                  RHS: ValueRef,
+                                  Order: AtomicOrdering,
+                                  FailureOrder: AtomicOrdering)
+                                  -> ValueRef;
+    pub fn LLVMBuildAtomicRMW(B: BuilderRef,
+                              Op: AtomicBinOp,
+                              LHS: ValueRef,
+                              RHS: ValueRef,
+                              Order: AtomicOrdering,
+                              SingleThreaded: Bool)
+                              -> ValueRef;
+
+    pub fn LLVMBuildAtomicFence(B: BuilderRef, Order: AtomicOrdering);
+
+
+    /* Selected entries from the downcasts. */
+    pub fn LLVMIsATerminatorInst(Inst: ValueRef) -> ValueRef;
+    pub fn LLVMIsAStoreInst(Inst: ValueRef) -> ValueRef;
+
+    /** Writes a module to the specified path. Returns 0 on success. */
+    pub fn LLVMWriteBitcodeToFile(M: ModuleRef, Path: *const c_char) -> c_int;
+
+    /** Creates target data from a target layout string. */
+    pub fn LLVMCreateTargetData(StringRep: *const 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);
+    /** Number of bytes clobbered when doing a Store to *T. */
+    pub fn LLVMStoreSizeOfType(TD: TargetDataRef, Ty: TypeRef)
+                               -> c_ulonglong;
+
+    /** Number of bytes clobbered when doing a Store to *T. */
+    pub fn LLVMSizeOfTypeInBits(TD: TargetDataRef, Ty: TypeRef)
+                                -> c_ulonglong;
+
+    /** Distance between successive elements in an array of T.
+    Includes ABI padding. */
+    pub fn LLVMABISizeOfType(TD: TargetDataRef, Ty: TypeRef) -> c_uint;
+
+    /** Returns the preferred alignment of a type. */
+    pub fn LLVMPreferredAlignmentOfType(TD: TargetDataRef, Ty: TypeRef)
+                                        -> c_uint;
+    /** Returns the minimum alignment of a type. */
+    pub fn LLVMABIAlignmentOfType(TD: TargetDataRef, Ty: TypeRef)
+                                  -> c_uint;
+
+    /// Computes the byte offset of the indexed struct element for a
+    /// target.
+    pub fn LLVMOffsetOfElement(TD: TargetDataRef,
+                               StructTy: TypeRef,
+                               Element: c_uint)
+                               -> c_ulonglong;
+
+    /**
+     * Returns the minimum alignment of a type when part of a call frame.
+     */
+    pub fn LLVMCallFrameAlignmentOfType(TD: TargetDataRef, Ty: TypeRef)
+                                        -> c_uint;
+
+    /** Disposes target data. */
+    pub fn LLVMDisposeTargetData(TD: TargetDataRef);
+
+    /** Creates a pass manager. */
+    pub fn LLVMCreatePassManager() -> PassManagerRef;
+
+    /** Creates a function-by-function pass manager */
+    pub fn LLVMCreateFunctionPassManagerForModule(M: ModuleRef)
+                                                  -> PassManagerRef;
+
+    /** Disposes a pass manager. */
+    pub fn LLVMDisposePassManager(PM: PassManagerRef);
+
+    /** Runs a pass manager on a module. */
+    pub fn LLVMRunPassManager(PM: PassManagerRef, M: ModuleRef) -> Bool;
+
+    /** Runs the function passes on the provided function. */
+    pub fn LLVMRunFunctionPassManager(FPM: PassManagerRef, F: ValueRef)
+                                      -> Bool;
+
+    /** Initializes all the function passes scheduled in the manager */
+    pub fn LLVMInitializeFunctionPassManager(FPM: PassManagerRef) -> Bool;
+
+    /** Finalizes all the function passes scheduled in the manager */
+    pub fn LLVMFinalizeFunctionPassManager(FPM: PassManagerRef) -> Bool;
+
+    pub fn LLVMInitializePasses();
+
+    /** Adds a verification pass. */
+    pub fn LLVMAddVerifierPass(PM: PassManagerRef);
+
+    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);
+
+    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);
+
+    pub fn LLVMPassManagerBuilderPopulateFunctionPassManager(
+        PMB: PassManagerBuilderRef,
+        PM: PassManagerRef);
+    pub fn LLVMPassManagerBuilderPopulateLTOPassManager(
+        PMB: PassManagerBuilderRef,
+        PM: PassManagerRef,
+        Internalize: Bool,
+        RunInliner: Bool);
+
+    /** Destroys a memory buffer. */
+    pub fn LLVMDisposeMemoryBuffer(MemBuf: MemoryBufferRef);
+
+
+    /* Stuff that's in rustllvm/ because it's not upstream yet. */
+
+    /** Opens an object file. */
+    pub fn LLVMCreateObjectFile(MemBuf: MemoryBufferRef) -> ObjectFileRef;
+    /** Closes an object file. */
+    pub fn LLVMDisposeObjectFile(ObjFile: ObjectFileRef);
+
+    /** Enumerates the sections in an object file. */
+    pub fn LLVMGetSections(ObjFile: ObjectFileRef) -> SectionIteratorRef;
+    /** Destroys a section iterator. */
+    pub fn LLVMDisposeSectionIterator(SI: SectionIteratorRef);
+    /** Returns true if the section iterator is at the end of the section
+    list: */
+    pub fn LLVMIsSectionIteratorAtEnd(ObjFile: ObjectFileRef,
+                                      SI: SectionIteratorRef)
+                                      -> Bool;
+    /** Moves the section iterator to point to the next section. */
+    pub fn LLVMMoveToNextSection(SI: SectionIteratorRef);
+    /** Returns the current section size. */
+    pub fn LLVMGetSectionSize(SI: SectionIteratorRef) -> c_ulonglong;
+    /** Returns the current section contents as a string buffer. */
+    pub fn LLVMGetSectionContents(SI: SectionIteratorRef) -> *const c_char;
+
+    /** Reads the given file and returns it as a memory buffer. Use
+    LLVMDisposeMemoryBuffer() to get rid of it. */
+    pub fn LLVMRustCreateMemoryBufferWithContentsOfFile(Path: *const c_char)
+                                                        -> MemoryBufferRef;
+    /** Borrows the contents of the memory buffer (doesn't copy it) */
+    pub fn LLVMCreateMemoryBufferWithMemoryRange(InputData: *const c_char,
+                                                 InputDataLength: size_t,
+                                                 BufferName: *const c_char,
+                                                 RequiresNull: Bool)
+                                                 -> MemoryBufferRef;
+    pub fn LLVMCreateMemoryBufferWithMemoryRangeCopy(InputData: *const c_char,
+                                                     InputDataLength: size_t,
+                                                     BufferName: *const c_char)
+                                                     -> MemoryBufferRef;
+
+    pub fn LLVMIsMultithreaded() -> Bool;
+    pub fn LLVMStartMultithreaded() -> Bool;
+
+    /** Returns a string describing the last error caused by an LLVMRust*
+    call. */
+    pub fn LLVMRustGetLastError() -> *const c_char;
+
+    /// Print the pass timings since static dtors aren't picking them up.
+    pub fn LLVMRustPrintPassTimings();
+
+    pub fn LLVMStructCreateNamed(C: ContextRef, Name: *const c_char) -> TypeRef;
+
+    pub fn LLVMStructSetBody(StructTy: TypeRef,
+                             ElementTypes: *const TypeRef,
+                             ElementCount: c_uint,
+                             Packed: Bool);
+
+    pub fn LLVMConstNamedStruct(S: TypeRef,
+                                ConstantVals: *const ValueRef,
+                                Count: c_uint)
+                                -> ValueRef;
+
+    /** Enables LLVM debug output. */
+    pub fn LLVMSetDebug(Enabled: c_int);
+
+    /** Prepares inline assembly. */
+    pub fn LLVMInlineAsm(Ty: TypeRef,
+                         AsmString: *const c_char,
+                         Constraints: *const c_char,
+                         SideEffects: Bool,
+                         AlignStack: Bool,
+                         Dialect: c_uint)
+                         -> ValueRef;
+
+    pub static LLVMRustDebugMetadataVersion: u32;
+
+    pub fn LLVMRustAddModuleFlag(M: ModuleRef,
+                                 name: *const c_char,
+                                 value: u32);
+
+    pub fn LLVMDIBuilderCreate(M: ModuleRef) -> DIBuilderRef;
+
+    pub fn LLVMDIBuilderDispose(Builder: DIBuilderRef);
+
+    pub fn LLVMDIBuilderFinalize(Builder: DIBuilderRef);
+
+    pub fn LLVMDIBuilderCreateCompileUnit(Builder: DIBuilderRef,
+                                          Lang: c_uint,
+                                          File: *const c_char,
+                                          Dir: *const c_char,
+                                          Producer: *const c_char,
+                                          isOptimized: bool,
+                                          Flags: *const c_char,
+                                          RuntimeVer: c_uint,
+                                          SplitName: *const c_char);
+
+    pub fn LLVMDIBuilderCreateFile(Builder: DIBuilderRef,
+                                   Filename: *const c_char,
+                                   Directory: *const c_char)
+                                   -> DIFile;
+
+    pub fn LLVMDIBuilderCreateSubroutineType(Builder: DIBuilderRef,
+                                             File: DIFile,
+                                             ParameterTypes: DIArray)
+                                             -> DICompositeType;
+
+    pub fn LLVMDIBuilderCreateFunction(Builder: DIBuilderRef,
+                                       Scope: DIDescriptor,
+                                       Name: *const c_char,
+                                       LinkageName: *const 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: *const 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: *const c_char)
+                                          -> DIDerivedType;
+
+    pub fn LLVMDIBuilderCreateStructType(Builder: DIBuilderRef,
+                                         Scope: DIDescriptor,
+                                         Name: *const c_char,
+                                         File: DIFile,
+                                         LineNumber: c_uint,
+                                         SizeInBits: c_ulonglong,
+                                         AlignInBits: c_ulonglong,
+                                         Flags: c_uint,
+                                         DerivedFrom: DIType,
+                                         Elements: DIArray,
+                                         RunTimeLang: c_uint,
+                                         VTableHolder: ValueRef,
+                                         UniqueId: *const c_char)
+                                         -> DICompositeType;
+
+    pub fn LLVMDIBuilderCreateMemberType(Builder: DIBuilderRef,
+                                         Scope: DIDescriptor,
+                                         Name: *const 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,
+                                           Col: c_uint,
+                                           Discriminator: c_uint)
+                                           -> DILexicalBlock;
+
+    pub fn LLVMDIBuilderCreateStaticVariable(Builder: DIBuilderRef,
+                                             Context: DIDescriptor,
+                                             Name: *const c_char,
+                                             LinkageName: *const c_char,
+                                             File: DIFile,
+                                             LineNo: c_uint,
+                                             Ty: DIType,
+                                             isLocalToUnit: bool,
+                                             Val: ValueRef,
+                                             Decl: ValueRef)
+                                             -> DIGlobalVariable;
+
+    pub fn LLVMDIBuilderCreateLocalVariable(Builder: DIBuilderRef,
+                                            Tag: c_uint,
+                                            Scope: DIDescriptor,
+                                            Name: *const 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: *const DIDescriptor,
+                                         Count: c_uint)
+                                         -> DIArray;
+
+    pub fn LLVMDIBuilderInsertDeclareAtEnd(Builder: DIBuilderRef,
+                                           Val: ValueRef,
+                                           VarInfo: DIVariable,
+                                           InsertAtEnd: BasicBlockRef)
+                                           -> ValueRef;
+
+    pub fn LLVMDIBuilderInsertDeclareBefore(Builder: DIBuilderRef,
+                                            Val: ValueRef,
+                                            VarInfo: DIVariable,
+                                            InsertBefore: ValueRef)
+                                            -> ValueRef;
+
+    pub fn LLVMDIBuilderCreateEnumerator(Builder: DIBuilderRef,
+                                         Name: *const c_char,
+                                         Val: c_ulonglong)
+                                         -> ValueRef;
+
+    pub fn LLVMDIBuilderCreateEnumerationType(Builder: DIBuilderRef,
+                                              Scope: ValueRef,
+                                              Name: *const 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: *const c_char,
+                                        File: ValueRef,
+                                        LineNumber: c_uint,
+                                        SizeInBits: c_ulonglong,
+                                        AlignInBits: c_ulonglong,
+                                        Flags: c_uint,
+                                        Elements: ValueRef,
+                                        RunTimeLang: c_uint,
+                                        UniqueId: *const c_char)
+                                        -> ValueRef;
+
+    pub fn LLVMSetUnnamedAddr(GlobalVar: ValueRef, UnnamedAddr: Bool);
+
+    pub fn LLVMDIBuilderCreateTemplateTypeParameter(Builder: DIBuilderRef,
+                                                    Scope: ValueRef,
+                                                    Name: *const c_char,
+                                                    Ty: ValueRef,
+                                                    File: ValueRef,
+                                                    LineNo: c_uint,
+                                                    ColumnNo: c_uint)
+                                                    -> ValueRef;
+
+    pub fn LLVMDIBuilderCreateOpDeref(IntType: TypeRef) -> ValueRef;
+
+    pub fn LLVMDIBuilderCreateOpPlus(IntType: TypeRef) -> ValueRef;
+
+    pub fn LLVMDIBuilderCreateComplexVariable(Builder: DIBuilderRef,
+                                              Tag: c_uint,
+                                              Scope: ValueRef,
+                                              Name: *const c_char,
+                                              File: ValueRef,
+                                              LineNo: c_uint,
+                                              Ty: ValueRef,
+                                              AddrOps: *const ValueRef,
+                                              AddrOpsCount: c_uint,
+                                              ArgNo: c_uint)
+                                              -> ValueRef;
+
+    pub fn LLVMDIBuilderCreateNameSpace(Builder: DIBuilderRef,
+                                        Scope: ValueRef,
+                                        Name: *const c_char,
+                                        File: ValueRef,
+                                        LineNo: c_uint)
+                                        -> ValueRef;
+
+    pub fn LLVMDICompositeTypeSetTypeArray(CompositeType: ValueRef, TypeArray: ValueRef);
+    pub fn LLVMTypeToString(Type: TypeRef) -> *const c_char;
+    pub fn LLVMValueToString(value_ref: ValueRef) -> *const c_char;
+
+    pub fn LLVMIsAArgument(value_ref: ValueRef) -> ValueRef;
+
+    pub fn LLVMIsAAllocaInst(value_ref: ValueRef) -> ValueRef;
+
+    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: *const c_char) -> bool;
+    pub fn LLVMRustCreateTargetMachine(Triple: *const c_char,
+                                       CPU: *const c_char,
+                                       Features: *const c_char,
+                                       Model: CodeGenModel,
+                                       Reloc: RelocMode,
+                                       Level: CodeGenOptLevel,
+                                       EnableSegstk: bool,
+                                       UseSoftFP: bool,
+                                       NoFramePointerElim: bool,
+                                       FunctionSections: bool,
+                                       DataSections: bool) -> TargetMachineRef;
+    pub fn LLVMRustDisposeTargetMachine(T: TargetMachineRef);
+    pub fn LLVMRustAddAnalysisPasses(T: TargetMachineRef,
+                                     PM: PassManagerRef,
+                                     M: ModuleRef);
+    pub fn LLVMRustAddBuilderLibraryInfo(PMB: PassManagerBuilderRef,
+                                         M: ModuleRef,
+                                         DisableSimplifyLibCalls: bool);
+    pub fn LLVMRustAddLibraryInfo(PM: PassManagerRef, M: ModuleRef,
+                                  DisableSimplifyLibCalls: bool);
+    pub fn LLVMRustRunFunctionPassManager(PM: PassManagerRef, M: ModuleRef);
+    pub fn LLVMRustWriteOutputFile(T: TargetMachineRef,
+                                   PM: PassManagerRef,
+                                   M: ModuleRef,
+                                   Output: *const c_char,
+                                   FileType: FileType) -> bool;
+    pub fn LLVMRustPrintModule(PM: PassManagerRef,
+                               M: ModuleRef,
+                               Output: *const c_char);
+    pub fn LLVMRustSetLLVMOptions(Argc: c_int, Argv: *const *const c_char);
+    pub fn LLVMRustPrintPasses();
+    pub fn LLVMRustSetNormalizedTarget(M: ModuleRef, triple: *const c_char);
+    pub fn LLVMRustAddAlwaysInlinePass(P: PassManagerBuilderRef,
+                                       AddLifetimes: bool);
+    pub fn LLVMRustLinkInExternalBitcode(M: ModuleRef,
+                                         bc: *const c_char,
+                                         len: size_t) -> bool;
+    pub fn LLVMRustRunRestrictionPass(M: ModuleRef,
+                                      syms: *const *const c_char,
+                                      len: size_t);
+    pub fn LLVMRustMarkAllFunctionsNounwind(M: ModuleRef);
+
+    pub fn LLVMRustOpenArchive(path: *const c_char) -> ArchiveRef;
+    pub fn LLVMRustArchiveReadSection(AR: ArchiveRef, name: *const c_char,
+                                      out_len: *mut size_t) -> *const c_char;
+    pub fn LLVMRustDestroyArchive(AR: ArchiveRef);
+
+    pub fn LLVMRustSetDLLExportStorageClass(V: ValueRef);
+    pub fn LLVMVersionMajor() -> c_int;
+    pub fn LLVMVersionMinor() -> c_int;
+
+    pub fn LLVMRustGetSectionName(SI: SectionIteratorRef,
+                                  data: *mut *const c_char) -> c_int;
+}
+
+pub fn SetInstructionCallConv(instr: ValueRef, cc: CallConv) {
+    unsafe {
+        LLVMSetInstructionCallConv(instr, cc as c_uint);
+    }
+}
+pub fn SetFunctionCallConv(fn_: ValueRef, cc: CallConv) {
+    unsafe {
+        LLVMSetFunctionCallConv(fn_, cc as c_uint);
+    }
+}
+pub fn SetLinkage(global: ValueRef, link: Linkage) {
+    unsafe {
+        LLVMSetLinkage(global, link as c_uint);
+    }
+}
+
+pub fn SetUnnamedAddr(global: ValueRef, unnamed: bool) {
+    unsafe {
+        LLVMSetUnnamedAddr(global, unnamed as Bool);
+    }
+}
+
+pub fn set_thread_local(global: ValueRef, is_thread_local: bool) {
+    unsafe {
+        LLVMSetThreadLocal(global, is_thread_local as Bool);
+    }
+}
+
+pub fn ConstICmp(pred: IntPredicate, v1: ValueRef, v2: ValueRef) -> ValueRef {
+    unsafe {
+        LLVMConstICmp(pred as c_ushort, v1, v2)
+    }
+}
+pub fn ConstFCmp(pred: RealPredicate, v1: ValueRef, v2: ValueRef) -> ValueRef {
+    unsafe {
+        LLVMConstFCmp(pred as c_ushort, v1, v2)
+    }
+}
+
+pub fn SetFunctionAttribute(fn_: ValueRef, attr: Attribute) {
+    unsafe {
+        LLVMAddFunctionAttribute(fn_, FunctionIndex as c_uint, attr as uint64_t)
+    }
+}
+
+/* Memory-managed interface to target data. */
+
+pub struct TargetData {
+    pub lltd: TargetDataRef
+}
+
+impl Drop for TargetData {
+    fn drop(&mut self) {
+        unsafe {
+            LLVMDisposeTargetData(self.lltd);
+        }
+    }
+}
+
+pub fn mk_target_data(string_rep: &str) -> TargetData {
+    TargetData {
+        lltd: string_rep.with_c_str(|buf| {
+            unsafe { LLVMCreateTargetData(buf) }
+        })
+    }
+}
+
+/* Memory-managed interface to object files. */
+
+pub struct ObjectFile {
+    pub llof: ObjectFileRef,
+}
+
+impl ObjectFile {
+    // This will take ownership of llmb
+    pub fn new(llmb: MemoryBufferRef) -> Option<ObjectFile> {
+        unsafe {
+            let llof = LLVMCreateObjectFile(llmb);
+            if llof as int == 0 {
+                // LLVMCreateObjectFile took ownership of llmb
+                return None
+            }
+
+            Some(ObjectFile {
+                llof: llof,
+            })
+        }
+    }
+}
+
+impl Drop for ObjectFile {
+    fn drop(&mut self) {
+        unsafe {
+            LLVMDisposeObjectFile(self.llof);
+        }
+    }
+}
+
+/* Memory-managed interface to section iterators. */
+
+pub struct SectionIter {
+    pub llsi: SectionIteratorRef
+}
+
+impl Drop for SectionIter {
+    fn drop(&mut self) {
+        unsafe {
+            LLVMDisposeSectionIterator(self.llsi);
+        }
+    }
+}
+
+pub fn mk_section_iter(llof: ObjectFileRef) -> SectionIter {
+    unsafe {
+        SectionIter {
+            llsi: LLVMGetSections(llof)
+        }
+    }
+}
+
+// FIXME #15460 - create a public function that actually calls our
+// static LLVM symbols. Otherwise the linker will just throw llvm
+// away.  We're just calling lots of stuff until we transitively get
+// all of LLVM. This is worse than anything.
+pub unsafe fn static_link_hack_this_sucks() {
+    LLVMInitializePasses();
+
+    LLVMInitializeX86TargetInfo();
+    LLVMInitializeX86Target();
+    LLVMInitializeX86TargetMC();
+    LLVMInitializeX86AsmPrinter();
+    LLVMInitializeX86AsmParser();
+
+    LLVMInitializeARMTargetInfo();
+    LLVMInitializeARMTarget();
+    LLVMInitializeARMTargetMC();
+    LLVMInitializeARMAsmPrinter();
+    LLVMInitializeARMAsmParser();
+
+    LLVMInitializeMipsTargetInfo();
+    LLVMInitializeMipsTarget();
+    LLVMInitializeMipsTargetMC();
+    LLVMInitializeMipsAsmPrinter();
+    LLVMInitializeMipsAsmParser();
+
+    LLVMRustSetLLVMOptions(0 as c_int,
+                                       0 as *const _);
+
+    LLVMPassManagerBuilderPopulateModulePassManager(0 as *mut _, 0 as *mut _);
+    LLVMPassManagerBuilderPopulateLTOPassManager(0 as *mut _, 0 as *mut _, False, False);
+    LLVMPassManagerBuilderPopulateFunctionPassManager(0 as *mut _, 0 as *mut _);
+    LLVMPassManagerBuilderSetOptLevel(0 as *mut _, 0 as c_uint);
+    LLVMPassManagerBuilderUseInlinerWithThreshold(0 as *mut _, 0 as c_uint);
+    LLVMWriteBitcodeToFile(0 as *mut _, 0 as *const _);
+    LLVMPassManagerBuilderCreate();
+    LLVMPassManagerBuilderDispose(0 as *mut _);
+
+    LLVMRustLinkInExternalBitcode(0 as *mut _, 0 as *const _, 0 as size_t);
+
+    LLVMLinkInJIT();
+    LLVMLinkInMCJIT();
+    LLVMLinkInInterpreter();
+
+    extern {
+        fn LLVMLinkInJIT();
+        fn LLVMLinkInMCJIT();
+        fn LLVMLinkInInterpreter();
+    }
+}
+
+// The module containing the native LLVM dependencies, generated by the build system
+// Note that this must come after the rustllvm extern declaration so that
+// parts of LLVM that rustllvm depends on aren't thrown away by the linker.
+// Works to the above fix for #15460 to ensure LLVM dependencies that
+// are only used by rustllvm don't get stripped by the linker.
+mod llvmdeps;
+