rustc_llvm: Remove the inner llvm module

This makes it much saner for clients to use the library since
they don't have to worry about shadowing one llvm with another.
This commit is contained in:
Brian Anderson 2014-07-07 17:58:01 -07:00
parent 8e2e15f163
commit 3096d9bf94
42 changed files with 1652 additions and 1652 deletions

View file

@ -56,7 +56,7 @@ pub enum OutputType {
pub fn llvm_err(sess: &Session, msg: String) -> ! {
unsafe {
let cstr = llvm::llvm::LLVMRustGetLastError();
let cstr = llvm::LLVMRustGetLastError();
if cstr == ptr::null() {
sess.fatal(msg.as_slice());
} else {
@ -78,7 +78,7 @@ pub fn write_output_file(
file_type: llvm::FileType) {
unsafe {
output.with_c_str(|output| {
let result = llvm::llvm::LLVMRustWriteOutputFile(
let result = llvm::LLVMRustWriteOutputFile(
target, pm, m, output, file_type);
if !result {
llvm_err(sess, "could not write output".to_string());
@ -147,7 +147,7 @@ pub mod write {
if sess.opts.cg.save_temps {
output.with_extension("no-opt.bc").with_c_str(|buf| {
llvm::llvm::LLVMWriteBitcodeToFile(llmod, buf);
llvm::LLVMWriteBitcodeToFile(llmod, buf);
})
}
@ -193,7 +193,7 @@ pub mod write {
.with_c_str(|t| {
sess.opts.cg.target_cpu.as_slice().with_c_str(|cpu| {
target_feature(sess).with_c_str(|features| {
llvm::llvm::LLVMRustCreateTargetMachine(
llvm::LLVMRustCreateTargetMachine(
t, cpu, features,
llvm::CodeModelDefault,
reloc_model,
@ -212,26 +212,26 @@ pub mod write {
// does, and are by populated by LLVM's default PassManagerBuilder.
// Each manager has a different set of passes, but they also share
// some common passes.
let fpm = llvm::llvm::LLVMCreateFunctionPassManagerForModule(llmod);
let mpm = llvm::llvm::LLVMCreatePassManager();
let fpm = llvm::LLVMCreateFunctionPassManagerForModule(llmod);
let mpm = llvm::LLVMCreatePassManager();
// If we're verifying or linting, add them to the function pass
// manager.
let addpass = |pass: &str| {
pass.as_slice().with_c_str(|s| llvm::llvm::LLVMRustAddPass(fpm, s))
pass.as_slice().with_c_str(|s| llvm::LLVMRustAddPass(fpm, s))
};
if !sess.no_verify() { assert!(addpass("verify")); }
if !sess.opts.cg.no_prepopulate_passes {
llvm::llvm::LLVMRustAddAnalysisPasses(tm, fpm, llmod);
llvm::llvm::LLVMRustAddAnalysisPasses(tm, mpm, llmod);
llvm::LLVMRustAddAnalysisPasses(tm, fpm, llmod);
llvm::LLVMRustAddAnalysisPasses(tm, mpm, llmod);
populate_llvm_passes(fpm, mpm, llmod, opt_level,
trans.no_builtins);
}
for pass in sess.opts.cg.passes.iter() {
pass.as_slice().with_c_str(|s| {
if !llvm::llvm::LLVMRustAddPass(mpm, s) {
if !llvm::LLVMRustAddPass(mpm, s) {
sess.warn(format!("unknown pass {}, ignoring",
*pass).as_slice());
}
@ -240,13 +240,13 @@ pub mod write {
// Finally, run the actual optimization passes
time(sess.time_passes(), "llvm function passes", (), |()|
llvm::llvm::LLVMRustRunFunctionPassManager(fpm, llmod));
llvm::LLVMRustRunFunctionPassManager(fpm, llmod));
time(sess.time_passes(), "llvm module passes", (), |()|
llvm::llvm::LLVMRunPassManager(mpm, llmod));
llvm::LLVMRunPassManager(mpm, llmod));
// Deallocate managers that we're now done with
llvm::llvm::LLVMDisposePassManager(fpm);
llvm::llvm::LLVMDisposePassManager(mpm);
llvm::LLVMDisposePassManager(fpm);
llvm::LLVMDisposePassManager(mpm);
// Emit the bytecode if we're either saving our temporaries or
// emitting an rlib. Whenever an rlib is created, the bytecode is
@ -255,7 +255,7 @@ pub mod write {
(sess.crate_types.borrow().contains(&config::CrateTypeRlib) &&
sess.opts.output_types.contains(&OutputTypeExe)) {
output.temp_path(OutputTypeBitcode).with_c_str(|buf| {
llvm::llvm::LLVMWriteBitcodeToFile(llmod, buf);
llvm::LLVMWriteBitcodeToFile(llmod, buf);
})
}
@ -265,7 +265,7 @@ pub mod write {
if sess.opts.cg.save_temps {
output.with_extension("lto.bc").with_c_str(|buf| {
llvm::llvm::LLVMWriteBitcodeToFile(llmod, buf);
llvm::LLVMWriteBitcodeToFile(llmod, buf);
})
}
}
@ -281,11 +281,11 @@ pub mod write {
fn with_codegen(tm: TargetMachineRef, llmod: ModuleRef,
no_builtins: bool, f: |PassManagerRef|) {
unsafe {
let cpm = llvm::llvm::LLVMCreatePassManager();
llvm::llvm::LLVMRustAddAnalysisPasses(tm, cpm, llmod);
llvm::llvm::LLVMRustAddLibraryInfo(cpm, llmod, no_builtins);
let cpm = llvm::LLVMCreatePassManager();
llvm::LLVMRustAddAnalysisPasses(tm, cpm, llmod);
llvm::LLVMRustAddLibraryInfo(cpm, llmod, no_builtins);
f(cpm);
llvm::llvm::LLVMDisposePassManager(cpm);
llvm::LLVMDisposePassManager(cpm);
}
}
@ -296,13 +296,13 @@ pub mod write {
match *output_type {
OutputTypeBitcode => {
path.with_c_str(|buf| {
llvm::llvm::LLVMWriteBitcodeToFile(llmod, buf);
llvm::LLVMWriteBitcodeToFile(llmod, buf);
})
}
OutputTypeLlvmAssembly => {
path.with_c_str(|output| {
with_codegen(tm, llmod, trans.no_builtins, |cpm| {
llvm::llvm::LLVMRustPrintModule(cpm, llmod, output);
llvm::LLVMRustPrintModule(cpm, llmod, output);
})
})
}
@ -355,11 +355,11 @@ pub mod write {
}
});
llvm::llvm::LLVMRustDisposeTargetMachine(tm);
llvm::llvm::LLVMDisposeModule(trans.metadata_module);
llvm::llvm::LLVMDisposeModule(llmod);
llvm::llvm::LLVMContextDispose(llcx);
if sess.time_llvm_passes() { llvm::llvm::LLVMRustPrintPassTimings(); }
llvm::LLVMRustDisposeTargetMachine(tm);
llvm::LLVMDisposeModule(trans.metadata_module);
llvm::LLVMDisposeModule(llmod);
llvm::LLVMContextDispose(llcx);
if sess.time_llvm_passes() { llvm::LLVMRustPrintPassTimings(); }
}
}
@ -426,31 +426,31 @@ pub mod write {
}
INIT.doit(|| {
llvm::llvm::LLVMInitializePasses();
llvm::LLVMInitializePasses();
// Only initialize the platforms supported by Rust here, because
// using --llvm-root will have multiple platforms that rustllvm
// doesn't actually link to and it's pointless to put target info
// into the registry that Rust cannot generate machine code for.
llvm::llvm::LLVMInitializeX86TargetInfo();
llvm::llvm::LLVMInitializeX86Target();
llvm::llvm::LLVMInitializeX86TargetMC();
llvm::llvm::LLVMInitializeX86AsmPrinter();
llvm::llvm::LLVMInitializeX86AsmParser();
llvm::LLVMInitializeX86TargetInfo();
llvm::LLVMInitializeX86Target();
llvm::LLVMInitializeX86TargetMC();
llvm::LLVMInitializeX86AsmPrinter();
llvm::LLVMInitializeX86AsmParser();
llvm::llvm::LLVMInitializeARMTargetInfo();
llvm::llvm::LLVMInitializeARMTarget();
llvm::llvm::LLVMInitializeARMTargetMC();
llvm::llvm::LLVMInitializeARMAsmPrinter();
llvm::llvm::LLVMInitializeARMAsmParser();
llvm::LLVMInitializeARMTargetInfo();
llvm::LLVMInitializeARMTarget();
llvm::LLVMInitializeARMTargetMC();
llvm::LLVMInitializeARMAsmPrinter();
llvm::LLVMInitializeARMAsmParser();
llvm::llvm::LLVMInitializeMipsTargetInfo();
llvm::llvm::LLVMInitializeMipsTarget();
llvm::llvm::LLVMInitializeMipsTargetMC();
llvm::llvm::LLVMInitializeMipsAsmPrinter();
llvm::llvm::LLVMInitializeMipsAsmParser();
llvm::LLVMInitializeMipsTargetInfo();
llvm::LLVMInitializeMipsTarget();
llvm::LLVMInitializeMipsTargetMC();
llvm::LLVMInitializeMipsAsmPrinter();
llvm::LLVMInitializeMipsAsmParser();
llvm::llvm::LLVMRustSetLLVMOptions(llvm_args.len() as c_int,
llvm::LLVMRustSetLLVMOptions(llvm_args.len() as c_int,
llvm_args.as_ptr());
});
}
@ -463,32 +463,32 @@ pub mod write {
// Create the PassManagerBuilder for LLVM. We configure it with
// reasonable defaults and prepare it to actually populate the pass
// manager.
let builder = llvm::llvm::LLVMPassManagerBuilderCreate();
let builder = llvm::LLVMPassManagerBuilderCreate();
match opt {
llvm::CodeGenLevelNone => {
// Don't add lifetime intrinsics at O0
llvm::llvm::LLVMRustAddAlwaysInlinePass(builder, false);
llvm::LLVMRustAddAlwaysInlinePass(builder, false);
}
llvm::CodeGenLevelLess => {
llvm::llvm::LLVMRustAddAlwaysInlinePass(builder, true);
llvm::LLVMRustAddAlwaysInlinePass(builder, true);
}
// numeric values copied from clang
llvm::CodeGenLevelDefault => {
llvm::llvm::LLVMPassManagerBuilderUseInlinerWithThreshold(builder,
llvm::LLVMPassManagerBuilderUseInlinerWithThreshold(builder,
225);
}
llvm::CodeGenLevelAggressive => {
llvm::llvm::LLVMPassManagerBuilderUseInlinerWithThreshold(builder,
llvm::LLVMPassManagerBuilderUseInlinerWithThreshold(builder,
275);
}
}
llvm::llvm::LLVMPassManagerBuilderSetOptLevel(builder, opt as c_uint);
llvm::llvm::LLVMRustAddBuilderLibraryInfo(builder, llmod, no_builtins);
llvm::LLVMPassManagerBuilderSetOptLevel(builder, opt as c_uint);
llvm::LLVMRustAddBuilderLibraryInfo(builder, llmod, no_builtins);
// Use the builder to populate the function/module pass managers.
llvm::llvm::LLVMPassManagerBuilderPopulateFunctionPassManager(builder, fpm);
llvm::llvm::LLVMPassManagerBuilderPopulateModulePassManager(builder, mpm);
llvm::llvm::LLVMPassManagerBuilderDispose(builder);
llvm::LLVMPassManagerBuilderPopulateFunctionPassManager(builder, fpm);
llvm::LLVMPassManagerBuilderPopulateModulePassManager(builder, mpm);
llvm::LLVMPassManagerBuilderDispose(builder);
}
}

View file

@ -11,8 +11,9 @@
use super::link;
use driver::session;
use driver::config;
use llvm;
use llvm::archive_ro::ArchiveRO;
use llvm::{ModuleRef, TargetMachineRef, llvm, True, False};
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

@ -215,8 +215,9 @@
use back::archive::{METADATA_FILENAME};
use back::svh::Svh;
use driver::session::Session;
use lib::llvm::{False, llvm, ObjectFile, mk_section_iter};
use lib::llvm::archive_ro::ArchiveRO;
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};
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;

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

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, ValueRef};
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;

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

@ -12,7 +12,6 @@
use libc;
use ArchiveRef;
use llvm;
use std::raw;
use std::mem;
@ -31,7 +30,7 @@ impl ArchiveRO {
pub fn open(dst: &Path) -> Option<ArchiveRO> {
unsafe {
let ar = dst.with_c_str(|dst| {
llvm::LLVMRustOpenArchive(dst)
::LLVMRustOpenArchive(dst)
});
if ar.is_null() {
None
@ -46,7 +45,7 @@ impl ArchiveRO {
unsafe {
let mut size = 0 as libc::size_t;
let ptr = file.with_c_str(|file| {
llvm::LLVMRustArchiveReadSection(self.ptr, file, &mut size)
::LLVMRustArchiveReadSection(self.ptr, file, &mut size)
});
if ptr.is_null() {
None
@ -63,7 +62,7 @@ impl ArchiveRO {
impl Drop for ArchiveRO {
fn drop(&mut self) {
unsafe {
llvm::LLVMRustDestroyArchive(self.ptr);
::LLVMRustDestroyArchive(self.ptr);
}
}
}

File diff suppressed because it is too large Load diff