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.
This commit is contained in:
bors 2014-07-15 04:16:20 +00:00
commit 2eadfe42e5
62 changed files with 2717 additions and 2458 deletions

2
.gitignore vendored
View file

@ -86,5 +86,5 @@ src/etc/dl
.settings/
/build
i686-pc-mingw32/
src/librustc/lib/llvmdeps.rs
src/librustc_llvm/llvmdeps.rs
*.pot

View file

@ -53,7 +53,8 @@ TARGET_CRATES := libc std green rustuv native flate arena glob term semver \
uuid serialize sync getopts collections num test time rand \
url log regex graphviz core rlibc alloc debug rustrt \
unicode
HOST_CRATES := syntax rustc rustdoc fourcc hexfloat regex_macros fmt_macros
HOST_CRATES := syntax rustc rustdoc fourcc hexfloat regex_macros fmt_macros \
rustc_llvm rustc_back
CRATES := $(TARGET_CRATES) $(HOST_CRATES)
TOOLS := compiletest rustdoc rustc
@ -70,8 +71,10 @@ DEPS_green := std native:context_switch
DEPS_rustuv := std native:uv native:uv_support
DEPS_native := std
DEPS_syntax := std term serialize log fmt_macros debug
DEPS_rustc := syntax native:rustllvm flate arena serialize getopts \
time log graphviz debug
DEPS_rustc := syntax flate arena serialize getopts \
time log graphviz debug rustc_llvm rustc_back
DEPS_rustc_llvm := native:rustllvm libc std
DEPS_rustc_back := std syntax rustc_llvm flate log libc
DEPS_rustdoc := rustc native:hoedown serialize getopts \
test time debug
DEPS_flate := std native:miniz

View file

@ -57,7 +57,7 @@ $(foreach host,$(CFG_HOST), \
$(foreach host,$(CFG_HOST), \
$(eval LLVM_CONFIGS := $(LLVM_CONFIGS) $(LLVM_CONFIG_$(host))))
$(S)src/librustc/lib/llvmdeps.rs: \
$(S)src/librustc_llvm/llvmdeps.rs: \
$(LLVM_CONFIGS) \
$(S)src/etc/mklldeps.py \
$(MKFILE_DEPS)

View file

@ -134,7 +134,7 @@ SNAPSHOT_RUSTC_POST_CLEANUP=$(HBIN0_H_$(CFG_BUILD))/rustc$(X_$(CFG_BUILD))
define TARGET_HOST_RULES
$$(TLIB$(1)_T_$(2)_H_$(3))/stamp.rustc: $(S)src/librustc/lib/llvmdeps.rs
$$(TLIB$(1)_T_$(2)_H_$(3))/stamp.rustc_llvm: $(S)src/librustc_llvm/llvmdeps.rs
$$(TBIN$(1)_T_$(2)_H_$(3))/:
mkdir -p $$@

View file

@ -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")) {

View file

@ -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;

View file

@ -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,

View file

@ -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;

View file

@ -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;
}

View file

@ -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)

File diff suppressed because it is too large Load diff

View file

@ -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 {}

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -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| {

View file

@ -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);

View file

@ -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};

View file

@ -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

View file

@ -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);
}
}

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -10,7 +10,7 @@
use syntax::abi::{OsWin32, OsMacos, OsiOS};
use lib::llvm::*;
use llvm::*;
use super::cabi::*;
use super::common::*;
use super::machine::*;

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -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)

View file

@ -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;

View file

@ -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};

View file

@ -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};

View file

@ -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;

View file

@ -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;

View file

@ -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,

View file

@ -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)

View file

@ -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);
}
};
}

View file

@ -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};

View file

@ -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")
};

View file

@ -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;

View file

@ -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;

View file

@ -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
}
}

View file

@ -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};

View file

@ -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::*;

View file

@ -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);

View file

@ -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()
}
}
}

View file

@ -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;

View file

@ -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 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 Archive<'a> {
sess: &'a Session,
handler: &'a ErrorHandler,
dst: Path,
lib_search_paths: Vec<Path>,
os: abi::Os,
maybe_ar_prog: Option<String>
}
pub struct ArchiveRO {
ptr: ArchiveRef,
}
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);
}
}
}

View file

@ -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 {

56
src/librustc_back/lib.rs Normal file
View file

@ -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;

View file

@ -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 {

View file

@ -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 {

View file

@ -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;
use syntax::ast;
fn not_win32(os: abi::Os) -> bool {
os != abi::OsWin32
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() {
@ -177,27 +158,6 @@ mod test {
"-Wl,-rpath,path2".to_string()));
}
#[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([
@ -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");
}
}

View file

@ -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};

View file

@ -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);
}

View file

@ -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)

View file

@ -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 {

View file

@ -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);
}
}
}

2003
src/librustc_llvm/lib.rs Normal file

File diff suppressed because it is too large Load diff