Skip to content

Commit 65e1fd7

Browse files
nikomatsakisbrson
authored andcommitted
---
yaml --- r: 6110 b: refs/heads/master c: f1bc930 h: refs/heads/master v: v3
1 parent cda4133 commit 65e1fd7

File tree

10 files changed

+97
-98
lines changed

10 files changed

+97
-98
lines changed

[refs]

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
---
2-
refs/heads/master: c0e9c42bd2f81d9694ee4c77b3440a44d38737e6
2+
refs/heads/master: f1bc9307d82b7ff55ea6fa0eebec2999e5bd8f8a

trunk/src/comp/back/upcall.rs

+6-5
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ fn declare_upcalls(targ_cfg: @session::config,
4848
let dv = bind decl(llmod, _, _, T_void());
4949

5050
let int_t = T_int(targ_cfg);
51+
let float_t = T_float(targ_cfg);
5152
let size_t = T_size_t(targ_cfg);
5253
let opaque_vec_t = T_opaque_vec(targ_cfg);
5354

@@ -88,16 +89,16 @@ fn declare_upcalls(targ_cfg: @session::config,
8889
d("dynastack_alloc_2", [size_t, T_ptr(tydesc_type)],
8990
T_ptr(T_i8())),
9091
dynastack_free: dv("dynastack_free", [T_ptr(T_i8())]),
91-
alloc_c_stack: d("alloc_c_stack", [T_size_t()], T_ptr(T_i8())),
92+
alloc_c_stack: d("alloc_c_stack", [size_t], T_ptr(T_i8())),
9293
call_c_stack: d("call_c_stack",
93-
[T_ptr(T_fn([], T_int())), T_ptr(T_i8())],
94+
[T_ptr(T_fn([], int_t)), T_ptr(T_i8())],
9495
int_t),
9596
call_c_stack_i64: d("call_c_stack_i64",
96-
[T_ptr(T_fn([], T_int())), T_ptr(T_i8())],
97+
[T_ptr(T_fn([], int_t)), T_ptr(T_i8())],
9798
T_i64()),
9899
call_c_stack_float: d("call_c_stack_float",
99-
[T_ptr(T_fn([], T_int())), T_ptr(T_i8())],
100-
T_float()),
100+
[T_ptr(T_fn([], int_t)), T_ptr(T_i8())],
101+
float_t),
101102
rust_personality: d("rust_personality", [], T_i32())
102103
};
103104
}

trunk/src/comp/metadata/creader.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ fn find_library_crate_aux(sess: session::session,
169169
}
170170

171171
fn get_metadata_section(sess: session::session,
172-
filename: str) -> option::t<@[u8]> {
172+
filename: str) -> option::t<@[u8]> unsafe {
173173
let mb = str::as_buf(filename, {|buf|
174174
llvm::LLVMRustCreateMemoryBufferWithContentsOfFile(buf)
175175
});

trunk/src/comp/middle/trans.rs

+28-40
Original file line numberDiff line numberDiff line change
@@ -226,13 +226,13 @@ fn type_of_tag(cx: @crate_ctxt, sp: span, did: ast::def_id, t: ty::t)
226226
let degen = std::vec::len(ty::tag_variants(cx.tcx, did)) == 1u;
227227
if check type_has_static_size(cx, t) {
228228
let size = static_size_of_tag(cx, sp, t);
229-
if !degen { T_tag(cx.tn, size) }
230-
else if size == 0u { T_struct([T_int()]) }
229+
if !degen { T_tag(cx, size) }
230+
else if size == 0u { T_struct([cx.int_type]) }
231231
else { T_array(T_i8(), size) }
232232
}
233233
else {
234-
if degen { T_struct([T_int()]) }
235-
else { T_opaque_tag(cx.tn) }
234+
if degen { T_struct([cx.int_type]) }
235+
else { T_opaque_tag(cx) }
236236
}
237237
}
238238

@@ -3031,12 +3031,13 @@ fn trans_var(cx: @block_ctxt, sp: span, def: ast::def, id: ast::node_id)
30313031
let lltagty = type_of_tag(ccx, sp, tid, tag_ty);
30323032
let bcx = alloc_result.bcx;
30333033
let lltagptr = PointerCast(bcx, lltagblob, T_ptr(lltagty));
3034-
let lldiscrimptr = GEP(bcx, lltagptr, [C_int(0), C_int(0)]);
3034+
let lldiscrimptr = GEP(bcx, lltagptr, [C_int(ccx, 0),
3035+
C_int(ccx, 0)]);
30353036
let d = if std::vec::len(ty::tag_variants(ccx.tcx, tid)) != 1u {
30363037
let lldiscrim_gv = lookup_discriminant(bcx.fcx.lcx, vid);
30373038
let lldiscrim = Load(bcx, lldiscrim_gv);
30383039
lldiscrim
3039-
} else { C_int(0) };
3040+
} else { C_int(ccx, 0) };
30403041
Store(bcx, d, lldiscrimptr);
30413042
ret lval_no_env(bcx, lltagptr, temporary);
30423043
}
@@ -3914,7 +3915,8 @@ fn trans_c_stack_native_call(bcx: @block_ctxt, f: @ast::expr,
39143915
let i = 0u, n = vec::len(llargs);
39153916
while i < n {
39163917
let llarg = llargs[i].llval;
3917-
store_inbounds(bcx, llarg, llargbundle, [C_int(0), C_uint(i)]);
3918+
store_inbounds(bcx, llarg, llargbundle, [C_int(ccx, 0),
3919+
C_uint(ccx, i)]);
39183920
i += 1u;
39193921
}
39203922

@@ -4449,8 +4451,8 @@ fn trans_log(lvl: int, cx: @block_ctxt, e: @ast::expr) -> @block_ctxt {
44494451
let llvalptr = r.val;
44504452
let llval_i8 = PointerCast(log_bcx, llvalptr, T_ptr(T_i8()));
44514453

4452-
Call(log_bcx, bcx_ccx(log_bcx).upcalls.log_type,
4453-
[lltydesc, llval_i8, C_int(lvl)]);
4454+
Call(log_bcx, ccx.upcalls.log_type,
4455+
[lltydesc, llval_i8, C_int(ccx, lvl)]);
44544456

44554457
log_bcx = trans_block_cleanups(log_bcx, log_cx);
44564458
Br(log_bcx, after_cx.llbb);
@@ -4514,7 +4516,7 @@ fn trans_fail_value(bcx: @block_ctxt, sp_opt: option::t<span>,
45144516
}
45154517
let V_str = PointerCast(bcx, V_fail_str, T_ptr(T_i8()));
45164518
V_filename = PointerCast(bcx, V_filename, T_ptr(T_i8()));
4517-
let args = [V_str, V_filename, C_int(V_line)];
4519+
let args = [V_str, V_filename, C_int(ccx, V_line)];
45184520
let bcx = invoke(bcx, bcx_ccx(bcx).upcalls._fail, args);
45194521
Unreachable(bcx);
45204522
ret bcx;
@@ -5518,16 +5520,16 @@ fn create_main_wrapper(ccx: @crate_ctxt, sp: span, main_llfn: ValueRef,
55185520
fn main_name() -> str { ret "main"; }
55195521
#[cfg(target_os = "linux")]
55205522
fn main_name() -> str { ret "main"; }
5521-
let llfty = T_fn([T_int(), T_int()], T_int());
5523+
let llfty = T_fn([ccx.int_type, ccx.int_type], ccx.int_type);
55225524
let llfn = decl_cdecl_fn(ccx.llmod, main_name(), llfty);
55235525
let llbb = str::as_buf("top", {|buf|
55245526
llvm::LLVMAppendBasicBlock(llfn, buf)
55255527
});
55265528
let bld = *ccx.builder;
55275529
llvm::LLVMPositionBuilderAtEnd(bld, llbb);
55285530
let crate_map = ccx.crate_map;
5529-
let start_ty = T_fn([val_ty(rust_main), T_int(), T_int(),
5530-
val_ty(crate_map)], T_int());
5531+
let start_ty = T_fn([val_ty(rust_main), ccx.int_type, ccx.int_type,
5532+
val_ty(crate_map)], ccx.int_type);
55315533
let start = str::as_buf("rust_start", {|buf|
55325534
llvm::LLVMAddGlobal(ccx.llmod, start_ty, buf)
55335535
});
@@ -6018,10 +6020,11 @@ fn create_module_map(ccx: @crate_ctxt) -> ValueRef {
60186020
lib::llvm::LLVMInternalLinkage as llvm::Linkage);
60196021
let elts: [ValueRef] = [];
60206022
ccx.module_data.items {|key, val|
6021-
let elt = C_struct([p2i(C_cstr(ccx, key)), p2i(val)]);
6023+
let elt = C_struct([p2i(ccx, C_cstr(ccx, key)),
6024+
p2i(ccx, val)]);
60226025
elts += [elt];
60236026
};
6024-
let term = C_struct([C_int(0), C_int(0)]);
6027+
let term = C_struct([C_int(ccx, 0), C_int(ccx, 0)]);
60256028
elts += [term];
60266029
llvm::LLVMSetInitializer(map, C_array(elttype, elts));
60276030
ret map;
@@ -6030,13 +6033,15 @@ fn create_module_map(ccx: @crate_ctxt) -> ValueRef {
60306033

60316034
fn decl_crate_map(sess: session::session, mapname: str,
60326035
llmod: ModuleRef) -> ValueRef {
6036+
let targ_cfg = sess.get_targ_cfg();
6037+
let int_type = T_int(targ_cfg);
60336038
let n_subcrates = 1;
60346039
let cstore = sess.get_cstore();
60356040
while cstore::have_crate_data(cstore, n_subcrates) { n_subcrates += 1; }
60366041
if !sess.get_opts().library { mapname = "toplevel"; }
60376042
let sym_name = "_rust_crate_map_" + mapname;
6038-
let arrtype = T_array(T_int(), n_subcrates as uint);
6039-
let maptype = T_struct([T_int(), arrtype]);
6043+
let arrtype = T_array(int_type, n_subcrates as uint);
6044+
let maptype = T_struct([int_type, arrtype]);
60406045
let map = str::as_buf(sym_name, {|buf|
60416046
llvm::LLVMAddGlobal(llmod, maptype, buf)
60426047
});
@@ -6053,32 +6058,15 @@ fn fill_crate_map(ccx: @crate_ctxt, map: ValueRef) {
60536058
while cstore::have_crate_data(cstore, i) {
60546059
let nm = "_rust_crate_map_" + cstore::get_crate_data(cstore, i).name;
60556060
let cr = str::as_buf(nm, {|buf|
6056-
llvm::LLVMAddGlobal(ccx.llmod, T_int(), buf)
6061+
llvm::LLVMAddGlobal(ccx.llmod, ccx.int_type, buf)
60576062
});
6058-
subcrates += [p2i(cr)];
6063+
subcrates += [p2i(ccx, cr)];
60596064
i += 1;
60606065
}
6061-
subcrates += [C_int(0)];
6062-
llvm::LLVMSetInitializer(map, C_struct([p2i(create_module_map(ccx)),
6063-
C_array(T_int(), subcrates)]));
60646066
subcrates += [C_int(ccx, 0)];
6065-
let mapname;
6066-
if ccx.sess.get_opts().library {
6067-
mapname = ccx.link_meta.name;
6068-
} else { mapname = "toplevel"; }
6069-
let sym_name = "_rust_crate_map_" + mapname;
6070-
let arrtype = T_array(ccx.int_type, std::vec::len::<ValueRef>(subcrates));
6071-
let maptype = T_struct([ccx.int_type, arrtype]);
6072-
let map =
6073-
str::as_buf(sym_name,
6074-
{|buf| llvm::LLVMAddGlobal(ccx.llmod, maptype, buf) });
6075-
llvm::LLVMSetLinkage(map,
6076-
lib::llvm::LLVMExternalLinkage as llvm::Linkage);
6077-
llvm::LLVMSetInitializer(map,
6078-
C_struct([p2i(ccx, create_module_map(ccx)),
6079-
C_array(ccx.int_type, subcrates)]));
6080-
ret map;
6081-
>>>>>>> work on making the size of ints depend on the target arch
6067+
llvm::LLVMSetInitializer(map, C_struct(
6068+
[p2i(ccx, create_module_map(ccx)),
6069+
C_array(ccx.int_type, subcrates)]));
60826070
}
60836071

60846072
fn write_metadata(cx: @crate_ctxt, crate: @ast::crate) {
@@ -6138,7 +6126,7 @@ fn trans_crate(sess: session::session, crate: @ast::crate, tcx: ty::ctxt,
61386126
let task_type = T_task(targ_cfg);
61396127
let taskptr_type = T_ptr(task_type);
61406128
tn.associate("taskptr", taskptr_type);
6141-
let tydesc_type = T_tydesc(targ_cfg, taskptr_type);
6129+
let tydesc_type = T_tydesc(targ_cfg);
61426130
tn.associate("tydesc", tydesc_type);
61436131
let hasher = ty::hash_ty;
61446132
let eqer = ty::eq_ty;

trunk/src/comp/middle/trans_build.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -497,15 +497,15 @@ fn _UndefReturn(cx: @block_ctxt, Fn: ValueRef) -> ValueRef {
497497
}
498498

499499
fn Call(cx: @block_ctxt, Fn: ValueRef, Args: [ValueRef]) -> ValueRef {
500-
if cx.unreachable { ret _UndefReturn(Fn); }
500+
if cx.unreachable { ret _UndefReturn(cx, Fn); }
501501
unsafe {
502502
ret llvm::LLVMBuildCall(B(cx), Fn, vec::to_ptr(Args),
503503
vec::len(Args), noname());
504504
}
505505
}
506506

507507
fn FastCall(cx: @block_ctxt, Fn: ValueRef, Args: [ValueRef]) -> ValueRef {
508-
if cx.unreachable { ret _UndefReturn(Fn); }
508+
if cx.unreachable { ret _UndefReturn(cx, Fn); }
509509
unsafe {
510510
let v = llvm::LLVMBuildCall(B(cx), Fn, vec::to_ptr(Args),
511511
vec::len(Args), noname());
@@ -516,7 +516,7 @@ fn FastCall(cx: @block_ctxt, Fn: ValueRef, Args: [ValueRef]) -> ValueRef {
516516

517517
fn CallWithConv(cx: @block_ctxt, Fn: ValueRef, Args: [ValueRef], Conv: uint)
518518
-> ValueRef {
519-
if cx.unreachable { ret _UndefReturn(Fn); }
519+
if cx.unreachable { ret _UndefReturn(cx, Fn); }
520520
unsafe {
521521
let v = llvm::LLVMBuildCall(B(cx), Fn, vec::to_ptr(Args),
522522
vec::len(Args), noname());

trunk/src/comp/middle/trans_common.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -576,7 +576,7 @@ fn T_task(targ_cfg: @session::config) -> TypeRef {
576576
ret t;
577577
}
578578

579-
fn T_tydesc_field(cx: @crate_ctxt, field: int) -> TypeRef {
579+
fn T_tydesc_field(cx: @crate_ctxt, field: int) -> TypeRef unsafe {
580580
// Bit of a kludge: pick the fn typeref out of the tydesc..
581581

582582
let tydesc_elts: [TypeRef] =

trunk/src/rt/arch/i386/_context.S

+28-28
Original file line numberDiff line numberDiff line change
@@ -20,19 +20,19 @@ The registers_t variable is in (%esp)
2020
swap_registers:
2121
// save the old context
2222
movl 4(%esp), %eax
23-
//movl %eax, 0(%eax)
24-
movl %ebx, 4(%eax)
25-
//movl %ecx, 8(%eax)
26-
//movl %edx, 12(%eax)
27-
movl %ebp, 16(%eax)
28-
movl %esi, 20(%eax)
29-
movl %edi, 24(%eax)
30-
//movl %cs, 32(%eax)
31-
//movl %ds, 34(%eax)
32-
//movl %ss, 36(%eax)
33-
//movl %es, 38(%eax)
34-
//movl %fs, 40(%eax)
35-
//movl %gs, 42(%eax)
23+
//movl %eax, 0(%eax)
24+
movl %ebx, 4(%eax)
25+
//movl %ecx, 8(%eax)
26+
//movl %edx, 12(%eax)
27+
movl %ebp, 16(%eax)
28+
movl %esi, 20(%eax)
29+
movl %edi, 24(%eax)
30+
//movl %cs, 32(%eax)
31+
//movl %ds, 34(%eax)
32+
//movl %ss, 36(%eax)
33+
//movl %es, 38(%eax)
34+
//movl %fs, 40(%eax)
35+
//movl %gs, 42(%eax)
3636

3737
// save the flags
3838
pushf
@@ -48,20 +48,20 @@ swap_registers:
4848
// restore the new context
4949
movl 4(%esp), %eax
5050

51-
movl 4(%eax), %ebx
52-
// save ecx for later...
53-
//movl 12(%eax), %edx
54-
movl 16(%eax), %ebp
55-
movl 20(%eax), %esi
56-
movl 24(%eax), %edi
57-
movl 28(%eax), %esp
58-
// We can't actually change this...
59-
//movl 32(%eax), %cs
60-
//movl 34(%eax), %ds
61-
//movl 36(%eax), %ss
62-
//movl 38(%eax), %es
63-
//movl 40(%eax), %fs
64-
//movl 42(%eax), %gs
51+
movl 4(%eax), %ebx
52+
// save ecx for later...
53+
//movl 12(%eax), %edx
54+
movl 16(%eax), %ebp
55+
movl 20(%eax), %esi
56+
movl 24(%eax), %edi
57+
movl 28(%eax), %esp
58+
// We can't actually change this...
59+
//movl 32(%eax), %cs
60+
//movl 34(%eax), %ds
61+
//movl 36(%eax), %ss
62+
//movl 38(%eax), %es
63+
//movl 40(%eax), %fs
64+
//movl 42(%eax), %gs
6565

6666
// restore the flags
6767
movl 44(%eax), %ecx
@@ -70,7 +70,7 @@ swap_registers:
7070

7171
// ok, now we can restore ecx
7272
//movl 8(%eax), %ecx
73-
73+
7474
// Return!
7575
jmp *48(%eax)
7676

trunk/src/rt/intrinsics/intrinsics.i386.ll.in

+14-9
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ target triple = "@CFG_TARGET_TRIPLE@"
5353
%struct.rust_vec = type { i32, i32, [0 x i8] }
5454
%"struct.std::_Rb_tree<void *, std::pair<void *const, const type_desc *>, std::_Select1st<std::pair<void *const, const type_desc *> >, std::less<void *>, std::allocator<std::pair<void *const, const type_desc *> > >::_Rb_tree_impl" = type { %struct.rust_cond, %"struct.std::_Rb_tree_node_base", i32 }
5555
%"struct.std::_Rb_tree_node_base" = type { i32, %"struct.std::_Rb_tree_node_base"*, %"struct.std::_Rb_tree_node_base"*, %"struct.std::_Rb_tree_node_base"* }
56-
%struct.type_desc = type { %struct.type_desc**, i32, i32, void (i8*, %struct.rust_task*, i8*, %struct.type_desc**, i8*)*, void (i8*, %struct.rust_task*, i8*, %struct.type_desc**, i8*)*, void (i8*, %struct.rust_task*, i8*, %struct.type_desc**, i8*)*, i8*, void (i8*, %struct.rust_task*, i8*, %struct.type_desc**, i8*)*, void (i8*, %struct.rust_task*, i8*, %struct.type_desc**, i8*)*, i32, void (i8*, %struct.rust_task*, i8*, %struct.type_desc**, i8*, i8*, i8)*, i8*, %struct.rust_shape_tables*, i32, i32, %struct.UT_hash_handle, i32, [0 x %struct.type_desc*] }
56+
%struct.type_desc = type { %struct.type_desc**, i32, i32, void (i8*, i8*, %struct.type_desc**, i8*)*, void (i8*, i8*, %struct.type_desc**, i8*)*, void (i8*, i8*, %struct.type_desc**, i8*)*, i8*, void (i8*, i8*, %struct.type_desc**, i8*)*, void (i8*, i8*, %struct.type_desc**, i8*)*, i32, void (i8*, i8*, %struct.type_desc**, i8*, i8*, i8)*, i8*, %struct.rust_shape_tables*, i32, i32, %struct.UT_hash_handle, i32, [0 x %struct.type_desc*] }
5757

5858
@.str = private unnamed_addr constant [42 x i8] c"attempt to cast values of differing sizes\00"
5959
@.str1 = private unnamed_addr constant [33 x i8] c"src/rt/intrinsics/intrinsics.cpp\00"
@@ -78,7 +78,7 @@ define void @rust_intrinsic_ptr_offset(%struct.rust_task* nocapture %task, i8**
7878
ret void
7979
}
8080

81-
define void @rust_intrinsic_cast(%struct.rust_task* %task, i8* nocapture %retptr, %struct.type_desc* nocapture %t1, %struct.type_desc* nocapture %t2, i8* nocapture %src) {
81+
define void @rust_intrinsic_cast(%struct.rust_task* nocapture %task, i8* nocapture %retptr, %struct.type_desc* nocapture %t1, %struct.type_desc* nocapture %t2, i8* nocapture %src) {
8282
%1 = getelementptr inbounds %struct.type_desc* %t1, i32 0, i32 1
8383
%2 = load i32* %1, align 4
8484
%3 = getelementptr inbounds %struct.type_desc* %t2, i32 0, i32 1
@@ -87,7 +87,7 @@ define void @rust_intrinsic_cast(%struct.rust_task* %task, i8* nocapture %retptr
8787
br i1 %5, label %7, label %6
8888

8989
; <label>:6 ; preds = %0
90-
tail call void @upcall_fail(%struct.rust_task* %task, i8* getelementptr inbounds ([42 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([33 x i8]* @.str1, i32 0, i32 0), i32 32)
90+
tail call void @upcall_fail(i8* getelementptr inbounds ([42 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([33 x i8]* @.str1, i32 0, i32 0), i32 32)
9191
br label %8
9292

9393
; <label>:7 ; preds = %0
@@ -98,7 +98,7 @@ define void @rust_intrinsic_cast(%struct.rust_task* %task, i8* nocapture %retptr
9898
ret void
9999
}
100100

101-
declare void @upcall_fail(%struct.rust_task*, i8*, i8*, i32)
101+
declare void @upcall_fail(i8*, i8*, i32)
102102

103103
declare void @llvm.memmove.p0i8.p0i8.i32(i8* nocapture, i8* nocapture, i32, i32, i1) nounwind
104104

@@ -107,11 +107,16 @@ define void @rust_intrinsic_addr_of(%struct.rust_task* nocapture %task, i8** noc
107107
ret void
108108
}
109109

110-
define void @rust_intrinsic_recv(%struct.rust_task* %task, i8** %retptr, %struct.type_desc* nocapture %ty, %class.rust_port* %port) {
111-
%1 = bitcast %struct.rust_task* %task to i8*
112-
%2 = bitcast i8** %retptr to i32*
113-
tail call void @port_recv(i8* %1, i32* %2, %class.rust_port* %port)
110+
define void @rust_intrinsic_recv(%struct.rust_task* nocapture %task, i8** %retptr, %struct.type_desc* nocapture %ty, %class.rust_port* %port) {
111+
%1 = bitcast i8** %retptr to i32*
112+
tail call void @port_recv(i32* %1, %class.rust_port* %port)
114113
ret void
115114
}
116115

117-
declare void @port_recv(i8*, i32*, %class.rust_port*)
116+
declare void @port_recv(i32*, %class.rust_port*)
117+
118+
define void @rust_intrinsic_get_type_desc(%struct.rust_task* nocapture %task, i8** nocapture %retptr, %struct.type_desc* %ty) nounwind {
119+
%ty.c = bitcast %struct.type_desc* %ty to i8*
120+
store i8* %ty.c, i8** %retptr, align 4
121+
ret void
122+
}

0 commit comments

Comments
 (0)