Convert the rest of rustc::back to istrs. Issue #855

This commit is contained in:
Brian Anderson 2011-08-25 21:08:32 -07:00
parent a58bfced3c
commit 6b3f0b21be
6 changed files with 71 additions and 59 deletions

View File

@ -114,13 +114,13 @@ const worst_case_glue_call_args: int = 7;
const abi_version: uint = 1u;
fn memcpy_glue_name() -> str { ret "rust_memcpy_glue"; }
fn memcpy_glue_name() -> istr { ret ~"rust_memcpy_glue"; }
fn bzero_glue_name() -> str { ret "rust_bzero_glue"; }
fn bzero_glue_name() -> istr { ret ~"rust_bzero_glue"; }
fn yield_glue_name() -> str { ret "rust_yield_glue"; }
fn yield_glue_name() -> istr { ret ~"rust_yield_glue"; }
fn no_op_type_glue_name() -> str { ret "rust_no_op_type_glue"; }
fn no_op_type_glue_name() -> istr { ret ~"rust_no_op_type_glue"; }
//
// Local Variables:
// mode: rust

View File

@ -91,7 +91,7 @@ mod write {
if opts.time_llvm_passes { llvm::LLVMRustEnableTimePasses(); }
link_intrinsics(sess, llmod);
let pm = mk_pass_manager();
let td = mk_target_data(x86::get_data_layout());
let td = mk_target_data(istr::to_estr(x86::get_data_layout()));
llvm::LLVMAddTargetData(td.lltd, pm.llpm);
// TODO: run the linter here also, once there are llvm-c bindings for
// it.
@ -190,7 +190,7 @@ mod write {
// Save the assembly file if -S is used
if opts.output_type == output_type_assembly {
let triple = x86::get_target_triple();
let triple = istr::to_estr(x86::get_target_triple());
let output = istr::to_estr(output);
llvm::LLVMRustWriteOutputFile(pm.llpm, llmod,
str::buf(triple),
@ -204,7 +204,7 @@ mod write {
// This .o is needed when an exe is built
if opts.output_type == output_type_object ||
opts.output_type == output_type_exe {
let triple = x86::get_target_triple();
let triple = istr::to_estr(x86::get_target_triple());
let output = istr::to_estr(output);
llvm::LLVMRustWriteOutputFile(pm.llpm, llmod,
str::buf(triple),
@ -216,7 +216,7 @@ mod write {
// If we aren't saving temps then just output the file
// type corresponding to the '-c' or '-S' flag used
let triple = x86::get_target_triple();
let triple = istr::to_estr(x86::get_target_triple());
let output = istr::to_estr(output);
llvm::LLVMRustWriteOutputFile(pm.llpm, llmod,
str::buf(triple),

View File

@ -1,4 +1,5 @@
import std::istr;
import middle::trans;
import trans::decl_cdecl_fn;
import middle::trans_common::T_f32;
@ -52,14 +53,16 @@ type upcalls =
fn declare_upcalls(_tn: type_names, tydesc_type: TypeRef,
taskptr_type: TypeRef, llmod: ModuleRef) -> @upcalls {
fn decl(llmod: ModuleRef, name: str, tys: [TypeRef], rv: TypeRef) ->
fn decl(llmod: ModuleRef, name: &istr, tys: [TypeRef], rv: TypeRef) ->
ValueRef {
let arg_tys: [TypeRef] = [];
for t: TypeRef in tys { arg_tys += [t]; }
let fn_ty = T_fn(arg_tys, rv);
ret trans::decl_cdecl_fn(llmod, "upcall_" + name, fn_ty);
ret trans::decl_cdecl_fn(llmod,
istr::to_estr(~"upcall_" + name), fn_ty);
}
fn decl_with_taskptr(taskptr_type: TypeRef, llmod: ModuleRef, name: str,
fn decl_with_taskptr(taskptr_type: TypeRef, llmod: ModuleRef,
name: &istr,
tys: [TypeRef], rv: TypeRef) -> ValueRef {
ret decl(llmod, name, [taskptr_type] + tys, rv);
}
@ -68,55 +71,55 @@ fn declare_upcalls(_tn: type_names, tydesc_type: TypeRef,
let dr = bind decl(llmod, _, _, _);
let empty_vec: [TypeRef] = [];
ret @{grow_task: dv("grow_task", [T_size_t()]),
_yield: dv("yield", empty_vec),
sleep: dv("sleep", [T_size_t()]),
_fail: dv("fail", [T_ptr(T_i8()), T_ptr(T_i8()), T_size_t()]),
kill: dv("kill", [taskptr_type]),
exit: dv("exit", empty_vec),
ret @{grow_task: dv(~"grow_task", [T_size_t()]),
_yield: dv(~"yield", empty_vec),
sleep: dv(~"sleep", [T_size_t()]),
_fail: dv(~"fail", [T_ptr(T_i8()), T_ptr(T_i8()), T_size_t()]),
kill: dv(~"kill", [taskptr_type]),
exit: dv(~"exit", empty_vec),
malloc:
d("malloc", [T_size_t(), T_ptr(tydesc_type)], T_ptr(T_i8())),
free: dv("free", [T_ptr(T_i8()), T_int()]),
d(~"malloc", [T_size_t(), T_ptr(tydesc_type)], T_ptr(T_i8())),
free: dv(~"free", [T_ptr(T_i8()), T_int()]),
shared_malloc:
d("shared_malloc", [T_size_t(), T_ptr(tydesc_type)],
d(~"shared_malloc", [T_size_t(), T_ptr(tydesc_type)],
T_ptr(T_i8())),
shared_free: dv("shared_free", [T_ptr(T_i8())]),
mark: d("mark", [T_ptr(T_i8())], T_int()),
new_str: d("new_str", [T_ptr(T_i8()), T_size_t()], T_ptr(T_str())),
shared_free: dv(~"shared_free", [T_ptr(T_i8())]),
mark: d(~"mark", [T_ptr(T_i8())], T_int()),
new_str: d(~"new_str", [T_ptr(T_i8()), T_size_t()], T_ptr(T_str())),
evec_append:
d("evec_append",
d(~"evec_append",
[T_ptr(tydesc_type), T_ptr(tydesc_type),
T_ptr(T_opaque_vec_ptr()), T_opaque_vec_ptr(), T_bool()],
T_void()),
get_type_desc:
d("get_type_desc",
d(~"get_type_desc",
[T_ptr(T_nil()), T_size_t(), T_size_t(), T_size_t(),
T_ptr(T_ptr(tydesc_type)), T_int()], T_ptr(tydesc_type)),
ivec_resize:
d("ivec_resize", [T_ptr(T_opaque_ivec()), T_int()], T_void()),
d(~"ivec_resize", [T_ptr(T_opaque_ivec()), T_int()], T_void()),
ivec_spill:
d("ivec_spill", [T_ptr(T_opaque_ivec()), T_int()], T_void()),
d(~"ivec_spill", [T_ptr(T_opaque_ivec()), T_int()], T_void()),
ivec_resize_shared:
d("ivec_resize_shared", [T_ptr(T_opaque_ivec()), T_int()],
d(~"ivec_resize_shared", [T_ptr(T_opaque_ivec()), T_int()],
T_void()),
ivec_spill_shared:
d("ivec_spill_shared", [T_ptr(T_opaque_ivec()), T_int()],
d(~"ivec_spill_shared", [T_ptr(T_opaque_ivec()), T_int()],
T_void()),
ivec_push:
d("ivec_push", [T_ptr(T_opaque_ivec()), T_ptr(tydesc_type),
d(~"ivec_push", [T_ptr(T_opaque_ivec()), T_ptr(tydesc_type),
T_ptr(T_i8())], T_void()),
cmp_type:
dr("cmp_type",
dr(~"cmp_type",
[T_ptr(T_i1()), taskptr_type, T_ptr(tydesc_type),
T_ptr(T_ptr(tydesc_type)), T_ptr(T_i8()), T_ptr(T_i8()),
T_i8()], T_void()),
log_type:
dr("log_type",
dr(~"log_type",
[taskptr_type, T_ptr(tydesc_type), T_ptr(T_i8()), T_i32()],
T_void()),
dynastack_mark: d("dynastack_mark", [], T_ptr(T_i8())),
dynastack_alloc: d("dynastack_alloc", [T_size_t()], T_ptr(T_i8())),
dynastack_free: d("dynastack_free", [T_ptr(T_i8())], T_void())};
dynastack_mark: d(~"dynastack_mark", [], T_ptr(T_i8())),
dynastack_alloc: d(~"dynastack_alloc", [T_size_t()], T_ptr(T_i8())),
dynastack_free: d(~"dynastack_free", [T_ptr(T_i8())], T_void())};
}
//
// Local Variables:

View File

@ -5,30 +5,32 @@ import std::str;
import std::istr;
import std::os::target_os;
fn get_module_asm() -> str { ret ""; }
fn get_module_asm() -> istr { ret ~""; }
fn get_meta_sect_name() -> str {
if istr::eq(target_os(), ~"macos") { ret "__DATA,__note.rustc"; }
if istr::eq(target_os(), ~"win32") { ret ".note.rustc"; }
ret ".note.rustc";
fn get_meta_sect_name() -> istr {
if istr::eq(target_os(), ~"macos") { ret ~"__DATA,__note.rustc"; }
if istr::eq(target_os(), ~"win32") { ret ~".note.rustc"; }
ret ~".note.rustc";
}
fn get_data_layout() -> str {
fn get_data_layout() -> istr {
if istr::eq(target_os(), ~"macos") {
ret "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16" + "-i32:32:32-i64:32:64" +
"-f32:32:32-f64:32:64-v64:64:64" +
"-v128:128:128-a0:0:64-f80:128:128" + "-n8:16:32";
ret ~"e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16" +
~"-i32:32:32-i64:32:64" +
~"-f32:32:32-f64:32:64-v64:64:64" +
~"-v128:128:128-a0:0:64-f80:128:128" +
~"-n8:16:32";
}
if istr::eq(target_os(), ~"win32") {
ret "e-p:32:32-f64:64:64-i64:64:64-f80:32:32-n8:16:32";
ret ~"e-p:32:32-f64:64:64-i64:64:64-f80:32:32-n8:16:32";
}
ret "e-p:32:32-f64:32:64-i64:32:64-f80:32:32-n8:16:32";
ret ~"e-p:32:32-f64:32:64-i64:32:64-f80:32:32-n8:16:32";
}
fn get_target_triple() -> str {
if istr::eq(target_os(), ~"macos") { ret "i686-apple-darwin"; }
if istr::eq(target_os(), ~"win32") { ret "i686-pc-mingw32"; }
ret "i686-unknown-linux-gnu";
fn get_target_triple() -> istr {
if istr::eq(target_os(), ~"macos") { ret ~"i686-apple-darwin"; }
if istr::eq(target_os(), ~"win32") { ret ~"i686-pc-mingw32"; }
ret ~"i686-unknown-linux-gnu";
}
//
// Local Variables:

View File

@ -200,7 +200,7 @@ fn get_metadata_section(filename: str) -> option::t<@[u8]> {
while llvm::LLVMIsSectionIteratorAtEnd(of.llof, si.llsi) == False {
let name_buf = llvm::LLVMGetSectionName(si.llsi);
let name = str::str_from_cstr(name_buf);
if str::eq(name, x86::get_meta_sect_name()) {
if str::eq(name, istr::to_estr(x86::get_meta_sect_name())) {
let cbuf = llvm::LLVMGetSectionContents(si.llsi);
let csz = llvm::LLVMGetSectionSize(si.llsi);
let cvbuf: *u8 = std::unsafe::reinterpret_cast(cbuf);

View File

@ -6248,7 +6248,8 @@ fn trap(bcx: &@block_ctxt) {
fn decl_no_op_type_glue(llmod: ModuleRef, taskptr_type: TypeRef) -> ValueRef {
let ty = T_fn([taskptr_type, T_ptr(T_i8())], T_void());
ret decl_fastcall_fn(llmod, abi::no_op_type_glue_name(), ty);
ret decl_fastcall_fn(llmod,
istr::to_estr(abi::no_op_type_glue_name()), ty);
}
fn vec_fill(bcx: &@block_ctxt, v: ValueRef) -> ValueRef {
@ -6274,13 +6275,16 @@ fn make_common_glue(sess: &session::session, output: &str) {
let llmod =
llvm::LLVMModuleCreateWithNameInContext(str::buf("rust_out"),
llvm::LLVMGetGlobalContext());
let dat_layt = x86::get_data_layout(); //HACK (buf lifetime issue)
let dat_layt = istr::to_estr(
x86::get_data_layout()); //HACK (buf lifetime issue)
llvm::LLVMSetDataLayout(llmod, str::buf(dat_layt));
let targ_trip = x86::get_target_triple(); //HACK (buf lifetime issue)
let targ_trip = istr::to_estr(
x86::get_target_triple()); //HACK (buf lifetime issue)
llvm::LLVMSetTarget(llmod, str::buf(targ_trip));
mk_target_data(x86::get_data_layout());
mk_target_data(istr::to_estr(x86::get_data_layout()));
declare_intrinsics(llmod);
let modl_asm = x86::get_module_asm(); //HACK (buf lifetime issue)
let modl_asm = istr::to_estr(
x86::get_module_asm()); //HACK (buf lifetime issue)
llvm::LLVMSetModuleInlineAsm(llmod, str::buf(modl_asm));
make_glues(llmod, taskptr_type);
link::write::run_passes(sess, llmod, istr::from_estr(output));
@ -6342,7 +6346,8 @@ fn write_metadata(cx: &@crate_ctxt, crate: &@ast::crate) {
llvm::LLVMAddGlobal(cx.llmod, val_ty(llconst),
str::buf("rust_metadata"));
llvm::LLVMSetInitializer(llglobal, llconst);
let met_sct_nm = x86::get_meta_sect_name(); //HACK (buf lifetime issue)
let met_sct_nm = istr::to_estr(
x86::get_meta_sect_name()); //HACK (buf lifetime issue)
llvm::LLVMSetSection(llglobal, str::buf(met_sct_nm));
llvm::LLVMSetLinkage(llglobal,
lib::llvm::LLVMInternalLinkage as llvm::Linkage);
@ -6369,9 +6374,11 @@ fn trans_crate(sess: &session::session, crate: &@ast::crate, tcx: &ty::ctxt,
let llmod =
llvm::LLVMModuleCreateWithNameInContext(str::buf("rust_out"),
llvm::LLVMGetGlobalContext());
let dat_layt = x86::get_data_layout(); //HACK (buf lifetime issue)
let dat_layt = istr::to_estr(
x86::get_data_layout()); //HACK (buf lifetime issue)
llvm::LLVMSetDataLayout(llmod, str::buf(dat_layt));
let targ_trip = x86::get_target_triple(); //HACK (buf lifetime issue)
let targ_trip = istr::to_estr(
x86::get_target_triple()); //HACK (buf lifetime issue)
llvm::LLVMSetTarget(llmod, str::buf(targ_trip));
let td = mk_target_data(dat_layt);
let tn = mk_type_names();