Skip to content

Commit 3096d9b

Browse files
committed
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.
1 parent 8e2e15f commit 3096d9b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+1698
-1698
lines changed

src/librustc/back/link.rs

Lines changed: 57 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ pub enum OutputType {
5656

5757
pub fn llvm_err(sess: &Session, msg: String) -> ! {
5858
unsafe {
59-
let cstr = llvm::llvm::LLVMRustGetLastError();
59+
let cstr = llvm::LLVMRustGetLastError();
6060
if cstr == ptr::null() {
6161
sess.fatal(msg.as_slice());
6262
} else {
@@ -78,7 +78,7 @@ pub fn write_output_file(
7878
file_type: llvm::FileType) {
7979
unsafe {
8080
output.with_c_str(|output| {
81-
let result = llvm::llvm::LLVMRustWriteOutputFile(
81+
let result = llvm::LLVMRustWriteOutputFile(
8282
target, pm, m, output, file_type);
8383
if !result {
8484
llvm_err(sess, "could not write output".to_string());
@@ -147,7 +147,7 @@ pub mod write {
147147

148148
if sess.opts.cg.save_temps {
149149
output.with_extension("no-opt.bc").with_c_str(|buf| {
150-
llvm::llvm::LLVMWriteBitcodeToFile(llmod, buf);
150+
llvm::LLVMWriteBitcodeToFile(llmod, buf);
151151
})
152152
}
153153

@@ -193,7 +193,7 @@ pub mod write {
193193
.with_c_str(|t| {
194194
sess.opts.cg.target_cpu.as_slice().with_c_str(|cpu| {
195195
target_feature(sess).with_c_str(|features| {
196-
llvm::llvm::LLVMRustCreateTargetMachine(
196+
llvm::LLVMRustCreateTargetMachine(
197197
t, cpu, features,
198198
llvm::CodeModelDefault,
199199
reloc_model,
@@ -212,26 +212,26 @@ pub mod write {
212212
// does, and are by populated by LLVM's default PassManagerBuilder.
213213
// Each manager has a different set of passes, but they also share
214214
// some common passes.
215-
let fpm = llvm::llvm::LLVMCreateFunctionPassManagerForModule(llmod);
216-
let mpm = llvm::llvm::LLVMCreatePassManager();
215+
let fpm = llvm::LLVMCreateFunctionPassManagerForModule(llmod);
216+
let mpm = llvm::LLVMCreatePassManager();
217217

218218
// If we're verifying or linting, add them to the function pass
219219
// manager.
220220
let addpass = |pass: &str| {
221-
pass.as_slice().with_c_str(|s| llvm::llvm::LLVMRustAddPass(fpm, s))
221+
pass.as_slice().with_c_str(|s| llvm::LLVMRustAddPass(fpm, s))
222222
};
223223
if !sess.no_verify() { assert!(addpass("verify")); }
224224

225225
if !sess.opts.cg.no_prepopulate_passes {
226-
llvm::llvm::LLVMRustAddAnalysisPasses(tm, fpm, llmod);
227-
llvm::llvm::LLVMRustAddAnalysisPasses(tm, mpm, llmod);
226+
llvm::LLVMRustAddAnalysisPasses(tm, fpm, llmod);
227+
llvm::LLVMRustAddAnalysisPasses(tm, mpm, llmod);
228228
populate_llvm_passes(fpm, mpm, llmod, opt_level,
229229
trans.no_builtins);
230230
}
231231

232232
for pass in sess.opts.cg.passes.iter() {
233233
pass.as_slice().with_c_str(|s| {
234-
if !llvm::llvm::LLVMRustAddPass(mpm, s) {
234+
if !llvm::LLVMRustAddPass(mpm, s) {
235235
sess.warn(format!("unknown pass {}, ignoring",
236236
*pass).as_slice());
237237
}
@@ -240,13 +240,13 @@ pub mod write {
240240

241241
// Finally, run the actual optimization passes
242242
time(sess.time_passes(), "llvm function passes", (), |()|
243-
llvm::llvm::LLVMRustRunFunctionPassManager(fpm, llmod));
243+
llvm::LLVMRustRunFunctionPassManager(fpm, llmod));
244244
time(sess.time_passes(), "llvm module passes", (), |()|
245-
llvm::llvm::LLVMRunPassManager(mpm, llmod));
245+
llvm::LLVMRunPassManager(mpm, llmod));
246246

247247
// Deallocate managers that we're now done with
248-
llvm::llvm::LLVMDisposePassManager(fpm);
249-
llvm::llvm::LLVMDisposePassManager(mpm);
248+
llvm::LLVMDisposePassManager(fpm);
249+
llvm::LLVMDisposePassManager(mpm);
250250

251251
// Emit the bytecode if we're either saving our temporaries or
252252
// emitting an rlib. Whenever an rlib is created, the bytecode is
@@ -255,7 +255,7 @@ pub mod write {
255255
(sess.crate_types.borrow().contains(&config::CrateTypeRlib) &&
256256
sess.opts.output_types.contains(&OutputTypeExe)) {
257257
output.temp_path(OutputTypeBitcode).with_c_str(|buf| {
258-
llvm::llvm::LLVMWriteBitcodeToFile(llmod, buf);
258+
llvm::LLVMWriteBitcodeToFile(llmod, buf);
259259
})
260260
}
261261

@@ -265,7 +265,7 @@ pub mod write {
265265

266266
if sess.opts.cg.save_temps {
267267
output.with_extension("lto.bc").with_c_str(|buf| {
268-
llvm::llvm::LLVMWriteBitcodeToFile(llmod, buf);
268+
llvm::LLVMWriteBitcodeToFile(llmod, buf);
269269
})
270270
}
271271
}
@@ -281,11 +281,11 @@ pub mod write {
281281
fn with_codegen(tm: TargetMachineRef, llmod: ModuleRef,
282282
no_builtins: bool, f: |PassManagerRef|) {
283283
unsafe {
284-
let cpm = llvm::llvm::LLVMCreatePassManager();
285-
llvm::llvm::LLVMRustAddAnalysisPasses(tm, cpm, llmod);
286-
llvm::llvm::LLVMRustAddLibraryInfo(cpm, llmod, no_builtins);
284+
let cpm = llvm::LLVMCreatePassManager();
285+
llvm::LLVMRustAddAnalysisPasses(tm, cpm, llmod);
286+
llvm::LLVMRustAddLibraryInfo(cpm, llmod, no_builtins);
287287
f(cpm);
288-
llvm::llvm::LLVMDisposePassManager(cpm);
288+
llvm::LLVMDisposePassManager(cpm);
289289
}
290290
}
291291

@@ -296,13 +296,13 @@ pub mod write {
296296
match *output_type {
297297
OutputTypeBitcode => {
298298
path.with_c_str(|buf| {
299-
llvm::llvm::LLVMWriteBitcodeToFile(llmod, buf);
299+
llvm::LLVMWriteBitcodeToFile(llmod, buf);
300300
})
301301
}
302302
OutputTypeLlvmAssembly => {
303303
path.with_c_str(|output| {
304304
with_codegen(tm, llmod, trans.no_builtins, |cpm| {
305-
llvm::llvm::LLVMRustPrintModule(cpm, llmod, output);
305+
llvm::LLVMRustPrintModule(cpm, llmod, output);
306306
})
307307
})
308308
}
@@ -355,11 +355,11 @@ pub mod write {
355355
}
356356
});
357357

358-
llvm::llvm::LLVMRustDisposeTargetMachine(tm);
359-
llvm::llvm::LLVMDisposeModule(trans.metadata_module);
360-
llvm::llvm::LLVMDisposeModule(llmod);
361-
llvm::llvm::LLVMContextDispose(llcx);
362-
if sess.time_llvm_passes() { llvm::llvm::LLVMRustPrintPassTimings(); }
358+
llvm::LLVMRustDisposeTargetMachine(tm);
359+
llvm::LLVMDisposeModule(trans.metadata_module);
360+
llvm::LLVMDisposeModule(llmod);
361+
llvm::LLVMContextDispose(llcx);
362+
if sess.time_llvm_passes() { llvm::LLVMRustPrintPassTimings(); }
363363
}
364364
}
365365

@@ -426,31 +426,31 @@ pub mod write {
426426
}
427427

428428
INIT.doit(|| {
429-
llvm::llvm::LLVMInitializePasses();
429+
llvm::LLVMInitializePasses();
430430

431431
// Only initialize the platforms supported by Rust here, because
432432
// using --llvm-root will have multiple platforms that rustllvm
433433
// doesn't actually link to and it's pointless to put target info
434434
// into the registry that Rust cannot generate machine code for.
435-
llvm::llvm::LLVMInitializeX86TargetInfo();
436-
llvm::llvm::LLVMInitializeX86Target();
437-
llvm::llvm::LLVMInitializeX86TargetMC();
438-
llvm::llvm::LLVMInitializeX86AsmPrinter();
439-
llvm::llvm::LLVMInitializeX86AsmParser();
440-
441-
llvm::llvm::LLVMInitializeARMTargetInfo();
442-
llvm::llvm::LLVMInitializeARMTarget();
443-
llvm::llvm::LLVMInitializeARMTargetMC();
444-
llvm::llvm::LLVMInitializeARMAsmPrinter();
445-
llvm::llvm::LLVMInitializeARMAsmParser();
446-
447-
llvm::llvm::LLVMInitializeMipsTargetInfo();
448-
llvm::llvm::LLVMInitializeMipsTarget();
449-
llvm::llvm::LLVMInitializeMipsTargetMC();
450-
llvm::llvm::LLVMInitializeMipsAsmPrinter();
451-
llvm::llvm::LLVMInitializeMipsAsmParser();
452-
453-
llvm::llvm::LLVMRustSetLLVMOptions(llvm_args.len() as c_int,
435+
llvm::LLVMInitializeX86TargetInfo();
436+
llvm::LLVMInitializeX86Target();
437+
llvm::LLVMInitializeX86TargetMC();
438+
llvm::LLVMInitializeX86AsmPrinter();
439+
llvm::LLVMInitializeX86AsmParser();
440+
441+
llvm::LLVMInitializeARMTargetInfo();
442+
llvm::LLVMInitializeARMTarget();
443+
llvm::LLVMInitializeARMTargetMC();
444+
llvm::LLVMInitializeARMAsmPrinter();
445+
llvm::LLVMInitializeARMAsmParser();
446+
447+
llvm::LLVMInitializeMipsTargetInfo();
448+
llvm::LLVMInitializeMipsTarget();
449+
llvm::LLVMInitializeMipsTargetMC();
450+
llvm::LLVMInitializeMipsAsmPrinter();
451+
llvm::LLVMInitializeMipsAsmParser();
452+
453+
llvm::LLVMRustSetLLVMOptions(llvm_args.len() as c_int,
454454
llvm_args.as_ptr());
455455
});
456456
}
@@ -463,32 +463,32 @@ pub mod write {
463463
// Create the PassManagerBuilder for LLVM. We configure it with
464464
// reasonable defaults and prepare it to actually populate the pass
465465
// manager.
466-
let builder = llvm::llvm::LLVMPassManagerBuilderCreate();
466+
let builder = llvm::LLVMPassManagerBuilderCreate();
467467
match opt {
468468
llvm::CodeGenLevelNone => {
469469
// Don't add lifetime intrinsics at O0
470-
llvm::llvm::LLVMRustAddAlwaysInlinePass(builder, false);
470+
llvm::LLVMRustAddAlwaysInlinePass(builder, false);
471471
}
472472
llvm::CodeGenLevelLess => {
473-
llvm::llvm::LLVMRustAddAlwaysInlinePass(builder, true);
473+
llvm::LLVMRustAddAlwaysInlinePass(builder, true);
474474
}
475475
// numeric values copied from clang
476476
llvm::CodeGenLevelDefault => {
477-
llvm::llvm::LLVMPassManagerBuilderUseInlinerWithThreshold(builder,
477+
llvm::LLVMPassManagerBuilderUseInlinerWithThreshold(builder,
478478
225);
479479
}
480480
llvm::CodeGenLevelAggressive => {
481-
llvm::llvm::LLVMPassManagerBuilderUseInlinerWithThreshold(builder,
481+
llvm::LLVMPassManagerBuilderUseInlinerWithThreshold(builder,
482482
275);
483483
}
484484
}
485-
llvm::llvm::LLVMPassManagerBuilderSetOptLevel(builder, opt as c_uint);
486-
llvm::llvm::LLVMRustAddBuilderLibraryInfo(builder, llmod, no_builtins);
485+
llvm::LLVMPassManagerBuilderSetOptLevel(builder, opt as c_uint);
486+
llvm::LLVMRustAddBuilderLibraryInfo(builder, llmod, no_builtins);
487487

488488
// Use the builder to populate the function/module pass managers.
489-
llvm::llvm::LLVMPassManagerBuilderPopulateFunctionPassManager(builder, fpm);
490-
llvm::llvm::LLVMPassManagerBuilderPopulateModulePassManager(builder, mpm);
491-
llvm::llvm::LLVMPassManagerBuilderDispose(builder);
489+
llvm::LLVMPassManagerBuilderPopulateFunctionPassManager(builder, fpm);
490+
llvm::LLVMPassManagerBuilderPopulateModulePassManager(builder, mpm);
491+
llvm::LLVMPassManagerBuilderDispose(builder);
492492
}
493493
}
494494

src/librustc/back/lto.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,9 @@
1111
use super::link;
1212
use driver::session;
1313
use driver::config;
14+
use llvm;
1415
use llvm::archive_ro::ArchiveRO;
15-
use llvm::{ModuleRef, TargetMachineRef, llvm, True, False};
16+
use llvm::{ModuleRef, TargetMachineRef, True, False};
1617
use metadata::cstore;
1718
use util::common::time;
1819

src/librustc/driver/config.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,10 @@ use syntax::parse::token::InternedString;
3333
use std::collections::{HashSet, HashMap};
3434
use getopts::{optopt, optmulti, optflag, optflagopt};
3535
use getopts;
36-
use lib::llvm::llvm;
3736
use std::cell::{RefCell};
3837
use std::fmt;
3938

39+
use llvm;
4040

4141
pub struct Config {
4242
pub os: abi::Os,

src/librustc/driver/driver.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ use driver::{config, PpMode};
1515
use driver::{PpmFlowGraph, PpmExpanded, PpmExpandedIdentified, PpmTyped};
1616
use driver::{PpmIdentified};
1717
use front;
18-
use lib::llvm::{ContextRef, ModuleRef};
1918
use lint;
19+
use llvm::{ContextRef, ModuleRef};
2020
use metadata::common::LinkMeta;
2121
use metadata::creader;
2222
use middle::cfg;

src/librustc/driver/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ pub fn handle_options(mut args: Vec<String>) -> Option<getopts::Matches> {
292292
}
293293

294294
if cg_flags.contains(&"passes=list".to_string()) {
295-
unsafe { ::lib::llvm::llvm::LLVMRustPrintPasses(); }
295+
unsafe { ::llvm::LLVMRustPrintPasses(); }
296296
return None;
297297
}
298298

src/librustc/metadata/loader.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -215,8 +215,9 @@
215215
use back::archive::{METADATA_FILENAME};
216216
use back::svh::Svh;
217217
use driver::session::Session;
218-
use lib::llvm::{False, llvm, ObjectFile, mk_section_iter};
219-
use lib::llvm::archive_ro::ArchiveRO;
218+
use llvm;
219+
use llvm::{False, ObjectFile, mk_section_iter};
220+
use llvm::archive_ro::ArchiveRO;
220221
use metadata::cstore::{MetadataBlob, MetadataVec, MetadataArchive};
221222
use metadata::decoder;
222223
use metadata::encoder;

src/librustc/middle/trans/_match.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,8 @@
190190

191191
use back::abi;
192192
use driver::config::FullDebugInfo;
193-
use lib::llvm::{llvm, ValueRef, BasicBlockRef};
193+
use llvm;
194+
use llvm::{ValueRef, BasicBlockRef};
194195
use middle::const_eval;
195196
use middle::def;
196197
use middle::check_match;

src/librustc/middle/trans/adt.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
use libc::c_ulonglong;
4949
use std::rc::Rc;
5050

51-
use lib::llvm::{ValueRef, True, IntEQ, IntNE};
51+
use llvm::{ValueRef, True, IntEQ, IntNE};
5252
use middle::subst;
5353
use middle::subst::Subst;
5454
use middle::trans::_match;

src/librustc/middle/trans/asm.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
# Translation of inline assembly.
1313
*/
1414

15-
use lib;
15+
use llvm;
1616
use middle::trans::build::*;
1717
use middle::trans::callee;
1818
use middle::trans::common::*;
@@ -99,8 +99,8 @@ pub fn trans_inline_asm<'a>(bcx: &'a Block<'a>, ia: &ast::InlineAsm)
9999
};
100100

101101
let dialect = match ia.dialect {
102-
ast::AsmAtt => lib::llvm::AD_ATT,
103-
ast::AsmIntel => lib::llvm::AD_Intel
102+
ast::AsmAtt => llvm::AD_ATT,
103+
ast::AsmIntel => llvm::AD_Intel
104104
};
105105

106106
let r = ia.asm.get().with_c_str(|a| {

0 commit comments

Comments
 (0)