Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dereference modules with : instead of . #365

Merged
merged 4 commits into from
May 12, 2011
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
94 changes: 47 additions & 47 deletions src/comp/back/Link.rs
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import driver.session;
import lib.llvm.llvm;
import middle.trans;
import std.Str;
import std.FS;

import lib.llvm.llvm.ModuleRef;
import lib.llvm.llvm.ValueRef;
import lib.llvm.mk_pass_manager;
import lib.llvm.mk_target_data;
import lib.llvm.mk_type_names;
import lib.llvm.False;
import lib.llvm.True;
import driver::session;
import lib::llvm::llvm;
import middle::trans;
import std::_str;
import std::fs;

import lib::llvm::llvm::ModuleRef;
import lib::llvm::llvm::ValueRef;
import lib::llvm::mk_pass_manager;
import lib::llvm::mk_target_data;
import lib::llvm::mk_type_names;
import lib::llvm::False;
import lib::llvm::True;

tag output_type {
output_type_none;
Expand All @@ -19,32 +19,32 @@ tag output_type {
output_type_object;
}

fn llvm_err(session.session sess, str msg) {
auto buf = llvm.LLVMRustGetLastError();
fn llvm_err(session::session sess, str msg) {
auto buf = llvm::LLVMRustGetLastError();
if ((buf as uint) == 0u) {
sess.err(msg);
} else {
sess.err(msg + ": " + Str.str_from_cstr(buf));
sess.err(msg + ": " + _str::str_from_cstr(buf));
}
fail;
}

fn link_intrinsics(session.session sess, ModuleRef llmod) {
auto path = FS.connect(sess.get_opts().sysroot, "intrinsics.bc");
fn link_intrinsics(session::session sess, ModuleRef llmod) {
auto path = fs::connect(sess.get_opts().sysroot, "intrinsics.bc");
auto membuf =
llvm.LLVMRustCreateMemoryBufferWithContentsOfFile(Str.buf(path));
llvm::LLVMRustCreateMemoryBufferWithContentsOfFile(_str::buf(path));
if ((membuf as uint) == 0u) {
llvm_err(sess, "installation problem: couldn't open intrinstics.bc");
fail;
}

auto llintrinsicsmod = llvm.LLVMRustParseBitcode(membuf);
auto llintrinsicsmod = llvm::LLVMRustParseBitcode(membuf);
if ((llintrinsicsmod as uint) == 0u) {
llvm_err(sess, "installation problem: couldn't parse intrinstics.bc");
fail;
}

if (llvm.LLVMLinkModules(llmod, llintrinsicsmod) == False) {
if (llvm::LLVMLinkModules(llmod, llintrinsicsmod) == False) {
llvm_err(sess, "couldn't link the module with the intrinsics");
fail;
}
Expand All @@ -64,29 +64,29 @@ mod Write {
// Decides what to call an intermediate file, given the name of the output
// and the extension to use.
fn mk_intermediate_name(str output_path, str extension) -> str {
auto dot_pos = Str.index(output_path, '.' as u8);
auto dot_pos = _str::index(output_path, '.' as u8);
auto stem;
if (dot_pos < 0) {
stem = output_path;
} else {
stem = Str.substr(output_path, 0u, dot_pos as uint);
stem = _str::substr(output_path, 0u, dot_pos as uint);
}
ret stem + "." + extension;
}

fn run_passes(session.session sess, ModuleRef llmod, str output) {
fn run_passes(session::session sess, ModuleRef llmod, str output) {

auto opts = sess.get_opts();

if (opts.time_llvm_passes) {
llvm.LLVMRustEnableTimePasses();
llvm::LLVMRustEnableTimePasses();
}

link_intrinsics(sess, llmod);

auto pm = mk_pass_manager();
auto td = mk_target_data(x86.get_data_layout());
llvm.LLVMAddTargetData(td.lltd, pm.llpm);
auto td = mk_target_data(x86::get_data_layout());
llvm::LLVMAddTargetData(td.lltd, pm.llpm);

// TODO: run the linter here also, once there are llvm-c bindings for
// it.
Expand All @@ -99,13 +99,13 @@ mod Write {
if (opts.optimize) {
auto filename = mk_intermediate_name(output,
"no-opt.bc");
llvm.LLVMWriteBitcodeToFile(llmod,
Str.buf(filename));
llvm::LLVMWriteBitcodeToFile(llmod,
_str::buf(filename));
}
}
case (_) {
auto filename = mk_intermediate_name(output, "bc");
llvm.LLVMWriteBitcodeToFile(llmod, Str.buf(filename));
llvm::LLVMWriteBitcodeToFile(llmod, _str::buf(filename));
}
}
}
Expand All @@ -118,13 +118,13 @@ mod Write {
// tool?
if (opts.optimize) {
auto fpm = mk_pass_manager();
llvm.LLVMAddTargetData(td.lltd, fpm.llpm);
llvm.LLVMAddStandardFunctionPasses(fpm.llpm, 2u);
llvm.LLVMRunPassManager(fpm.llpm, llmod);
llvm::LLVMAddTargetData(td.lltd, fpm.llpm);
llvm::LLVMAddStandardFunctionPasses(fpm.llpm, 2u);
llvm::LLVMRunPassManager(fpm.llpm, llmod);

// TODO: On -O3, use 275 instead of 225 for the inlining
// threshold.
llvm.LLVMAddStandardModulePasses(pm.llpm,
llvm::LLVMAddStandardModulePasses(pm.llpm,
2u, // optimization level
False, // optimize for size
True, // unit-at-a-time
Expand All @@ -135,7 +135,7 @@ mod Write {
}

if (opts.verify) {
llvm.LLVMAddVerifierPass(pm.llpm);
llvm::LLVMAddVerifierPass(pm.llpm);
}

// TODO: Write .s if -c was specified and -save-temps was on.
Expand All @@ -157,32 +157,32 @@ mod Write {
case (_) {
auto filename = mk_intermediate_name(output,
"opt.bc");
llvm.LLVMRunPassManager(pm.llpm, llmod);
llvm.LLVMWriteBitcodeToFile(llmod,
Str.buf(filename));
llvm::LLVMRunPassManager(pm.llpm, llmod);
llvm::LLVMWriteBitcodeToFile(llmod,
_str::buf(filename));
pm = mk_pass_manager();
}
}
}

llvm.LLVMRustWriteOutputFile(pm.llpm, llmod,
Str.buf(x86.get_target_triple()),
Str.buf(output),
llvm::LLVMRustWriteOutputFile(pm.llpm, llmod,
_str::buf(x86::get_target_triple()),
_str::buf(output),
FileType);
llvm.LLVMDisposeModule(llmod);
llvm::LLVMDisposeModule(llmod);
if (opts.time_llvm_passes) {
llvm.LLVMRustPrintPassTimings();
llvm::LLVMRustPrintPassTimings();
}
ret;
}

llvm.LLVMRunPassManager(pm.llpm, llmod);
llvm::LLVMRunPassManager(pm.llpm, llmod);

llvm.LLVMWriteBitcodeToFile(llmod, Str.buf(output));
llvm.LLVMDisposeModule(llmod);
llvm::LLVMWriteBitcodeToFile(llmod, _str::buf(output));
llvm::LLVMDisposeModule(llmod);

if (opts.time_llvm_passes) {
llvm.LLVMRustPrintPassTimings();
llvm::LLVMRustPrintPassTimings();
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/comp/back/abi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

const int rc_base_field_refcnt = 0;

// FIXME: import from std.dbg when imported consts work.
// FIXME: import from std::dbg when imported consts work.
const uint const_refcount = 0x7bad_face_u;

const int task_field_refcnt = 0;
Expand Down Expand Up @@ -97,7 +97,7 @@ fn native_glue_name(int n, native_glue_type ngt) -> str {
case (ngt_pure_rust) { prefix = "rust_native_pure_rust_"; }
case (ngt_cdecl) { prefix = "rust_native_cdecl_"; }
}
ret prefix + util.common.istr(n);
ret prefix + util::common::istr(n);
}

fn activate_glue_name() -> str {
Expand Down
48 changes: 24 additions & 24 deletions src/comp/back/upcall.rs
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
import middle.trans;
import middle::trans;

import trans.decl_cdecl_fn;
import trans.type_names;
import trans.ModuleRef;
import trans.TypeRef;
import trans.ValueRef;
import trans::decl_cdecl_fn;
import trans::type_names;
import trans::ModuleRef;
import trans::TypeRef;
import trans::ValueRef;

import trans.T_crate;
import trans.T_f32;
import trans.T_f64;
import trans.T_fn;
import trans.T_i8;
import trans.T_i32;
import trans.T_int;
import trans.T_opaque_chan_ptr;
import trans.T_opaque_port_ptr;
import trans.T_opaque_vec_ptr;
import trans.T_ptr;
import trans.T_size_t;
import trans.T_str;
import trans.T_taskptr;
import trans.T_tydesc;
import trans.T_void;
import trans::T_crate;
import trans::T_f32;
import trans::T_f64;
import trans::T_fn;
import trans::T_i8;
import trans::T_i32;
import trans::T_int;
import trans::T_opaque_chan_ptr;
import trans::T_opaque_port_ptr;
import trans::T_opaque_vec_ptr;
import trans::T_ptr;
import trans::T_size_t;
import trans::T_str;
import trans::T_taskptr;
import trans::T_tydesc;
import trans::T_void;

type upcalls = rec(
ValueRef grow_task,
Expand Down Expand Up @@ -66,13 +66,13 @@ fn declare_upcalls(type_names tn, ModuleRef llmod) -> @upcalls {
let vec[TypeRef] arg_tys = vec(T_taskptr(tn));
for (TypeRef t in tys) { arg_tys += vec(t); }
auto fn_ty = T_fn(arg_tys, rv);
ret trans.decl_cdecl_fn(llmod, "upcall_" + name, fn_ty);
ret trans::decl_cdecl_fn(llmod, "upcall_" + name, fn_ty);
}

auto dv = bind decl(tn, llmod, _, _, T_void());
auto d = bind decl(tn, llmod, _, _, _);

// FIXME: Sigh... remove this when I fix the typechecker pushdown.
// FIXME: Sigh:.. remove this when I fix the typechecker pushdown.
// --pcwalton
let vec[TypeRef] empty_vec = vec();

Expand Down
Loading