Skip to content

Commit 845b87f

Browse files
committed
---
yaml --- r: 2860 b: refs/heads/master c: cc96eea h: refs/heads/master v: v3
1 parent 95082d1 commit 845b87f

File tree

5 files changed

+141
-144
lines changed

5 files changed

+141
-144
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
---
2-
refs/heads/master: b6971d94dfa67f4e0ce81c2cd70af6f8b1dad8fa
2+
refs/heads/master: cc96eeafca395ae2889ddfea8dc3194f2ad1c80d

trunk/mk/rt.mk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ RUNTIME_CS := rt/sync/timer.cpp \
2929
rt/test/rust_test_runtime.cpp \
3030
rt/test/rust_test_util.cpp
3131

32-
RUNTIME_LL := rt/new_exit.ll
32+
RUNTIME_LL := rt/new_exit.ll rt/vec_append.ll
3333

3434
RUNTIME_S := rt/activate_glue.s rt/yield_glue.s
3535

trunk/src/comp/middle/trans.rs

Lines changed: 0 additions & 142 deletions
Original file line numberDiff line numberDiff line change
@@ -7997,147 +7997,6 @@ fn vec_p1_adjusted(&@block_ctxt bcx, ValueRef v,
79977997
ret bcx.build.GEP(vec_p0(bcx, v), [len]);
79987998
}
79997999

8000-
fn trans_vec_append_glue(@local_ctxt cx, &ast::span sp) {
8001-
8002-
auto llfn = cx.ccx.glues.vec_append_glue;
8003-
8004-
let ValueRef lltaskptr = llvm::LLVMGetParam(llfn, 0u);
8005-
let ValueRef llvec_tydesc = llvm::LLVMGetParam(llfn, 1u);
8006-
let ValueRef llelt_tydesc = llvm::LLVMGetParam(llfn, 2u);
8007-
let ValueRef lldst_vec_ptr = llvm::LLVMGetParam(llfn, 3u);
8008-
let ValueRef llsrc_vec = llvm::LLVMGetParam(llfn, 4u);
8009-
let ValueRef llskipnull = llvm::LLVMGetParam(llfn, 5u);
8010-
auto derived_tydescs =
8011-
map::mk_hashmap[ty::t, derived_tydesc_info](ty::hash_ty, ty::eq_ty);
8012-
8013-
auto llbbs = mk_standard_basic_blocks(llfn);
8014-
8015-
auto fcx = @rec(llfn=llfn,
8016-
lltaskptr=lltaskptr,
8017-
llenv=C_null(T_ptr(T_nil())),
8018-
llretptr=C_null(T_ptr(T_nil())),
8019-
mutable llallocas = llbbs._0,
8020-
mutable llcopyargs = llbbs._1,
8021-
mutable llderivedtydescs = llbbs._2,
8022-
mutable llself=none[self_vt],
8023-
mutable lliterbody=none[ValueRef],
8024-
llargs=new_def_hash[ValueRef](),
8025-
llobjfields=new_def_hash[ValueRef](),
8026-
lllocals=new_def_hash[ValueRef](),
8027-
llupvars=new_def_hash[ValueRef](),
8028-
mutable lltydescs=vec::empty[ValueRef](),
8029-
derived_tydescs=derived_tydescs,
8030-
sp=sp,
8031-
lcx=cx);
8032-
8033-
auto bcx = new_top_block_ctxt(fcx);
8034-
auto lltop = bcx.llbb;
8035-
8036-
auto lldst_vec = bcx.build.Load(lldst_vec_ptr);
8037-
8038-
// First the dst vec needs to grow to accommodate the src vec.
8039-
// To do this we have to figure out how many bytes to add.
8040-
8041-
auto llcopy_dst_ptr = alloca(bcx, T_int());
8042-
auto llnew_vec = bcx.build.Call(bcx.fcx.lcx.ccx.upcalls.vec_grow,
8043-
[bcx.fcx.lltaskptr, lldst_vec,
8044-
vec_fill_adjusted(bcx, llsrc_vec, llskipnull),
8045-
llcopy_dst_ptr, llvec_tydesc]);
8046-
maybe_name_value(bcx.fcx.lcx.ccx, llnew_vec, "llnew_vec");
8047-
8048-
auto copy_dst_cx = new_sub_block_ctxt(bcx, "copy new <- dst");
8049-
auto copy_src_cx = new_sub_block_ctxt(bcx, "copy new <- src");
8050-
8051-
auto pp0 = alloca(bcx, T_ptr(T_i8()));
8052-
bcx.build.Store(vec_p1_adjusted(bcx, llnew_vec, llskipnull), pp0);
8053-
maybe_name_value(bcx.fcx.lcx.ccx, pp0, "pp0");
8054-
8055-
bcx.build.CondBr(bcx.build.TruncOrBitCast
8056-
(bcx.build.Load(llcopy_dst_ptr),
8057-
T_i1()),
8058-
copy_dst_cx.llbb,
8059-
copy_src_cx.llbb);
8060-
8061-
8062-
fn copy_elts(&@block_ctxt cx,
8063-
ValueRef elt_tydesc,
8064-
ValueRef dst,
8065-
ValueRef src,
8066-
ValueRef n_bytes) -> result {
8067-
8068-
auto src_lim = cx.build.GEP(src, [n_bytes]);
8069-
maybe_name_value(cx.fcx.lcx.ccx, src_lim, "src_lim");
8070-
8071-
auto elt_llsz =
8072-
cx.build.Load(cx.build.GEP(elt_tydesc,
8073-
[C_int(0),
8074-
C_int(abi::tydesc_field_size)]));
8075-
maybe_name_value(cx.fcx.lcx.ccx, elt_llsz, "elt_llsz");
8076-
8077-
auto elt_llalign =
8078-
cx.build.Load(cx.build.GEP(elt_tydesc,
8079-
[C_int(0),
8080-
C_int(abi::tydesc_field_align)]));
8081-
maybe_name_value(cx.fcx.lcx.ccx, elt_llsz, "elt_llalign");
8082-
8083-
8084-
fn take_one(ValueRef elt_tydesc,
8085-
&@block_ctxt cx,
8086-
ValueRef dst, ValueRef src) -> result {
8087-
auto ti = none[@tydesc_info];
8088-
call_tydesc_glue_full(cx, src,
8089-
elt_tydesc,
8090-
abi::tydesc_field_take_glue, ti);
8091-
ret res(cx, src);
8092-
}
8093-
8094-
auto bcx = iter_sequence_raw(cx, dst, src, src_lim,
8095-
elt_llsz, bind take_one(elt_tydesc,
8096-
_, _, _)).bcx;
8097-
8098-
ret call_memmove(bcx, dst, src, n_bytes, elt_llalign);
8099-
}
8100-
8101-
// Copy any dst elements in, omitting null if doing str.
8102-
8103-
auto n_bytes = vec_fill_adjusted(copy_dst_cx, lldst_vec, llskipnull);
8104-
maybe_name_value(copy_dst_cx.fcx.lcx.ccx, n_bytes, "n_bytes");
8105-
8106-
copy_dst_cx = copy_elts(copy_dst_cx,
8107-
llelt_tydesc,
8108-
vec_p0(copy_dst_cx, llnew_vec),
8109-
vec_p0(copy_dst_cx, lldst_vec),
8110-
n_bytes).bcx;
8111-
8112-
put_vec_fill(copy_dst_cx, llnew_vec, vec_fill(copy_dst_cx, lldst_vec));
8113-
8114-
copy_dst_cx.build.Store(vec_p1_adjusted(copy_dst_cx, llnew_vec,
8115-
llskipnull), pp0);
8116-
copy_dst_cx.build.Br(copy_src_cx.llbb);
8117-
8118-
8119-
// Copy any src elements in, carrying along null if doing str.
8120-
n_bytes = vec_fill(copy_src_cx, llsrc_vec);
8121-
copy_src_cx = copy_elts(copy_src_cx,
8122-
llelt_tydesc,
8123-
copy_src_cx.build.Load(pp0),
8124-
vec_p0(copy_src_cx, llsrc_vec),
8125-
n_bytes).bcx;
8126-
8127-
put_vec_fill(copy_src_cx, llnew_vec,
8128-
copy_src_cx.build.Add(vec_fill_adjusted(copy_src_cx,
8129-
llnew_vec,
8130-
llskipnull),
8131-
n_bytes));
8132-
8133-
// Write new_vec back through the alias we were given.
8134-
copy_src_cx.build.Store(llnew_vec, lldst_vec_ptr);
8135-
copy_src_cx.build.RetVoid();
8136-
8137-
finish_fn(fcx, lltop);
8138-
}
8139-
8140-
81418000
fn make_glues(ModuleRef llmod, &type_names tn) -> @glue_fns {
81428001
ret @rec(yield_glue = decl_glue(llmod, tn, abi::yield_glue_name()),
81438002
no_op_type_glue = decl_no_op_type_glue(llmod, tn),
@@ -8279,7 +8138,6 @@ fn trans_crate(&session::session sess, &@ast::crate crate,
82798138
collect_tag_ctors(ccx, crate);
82808139
trans_constants(ccx, crate);
82818140
trans_mod(cx, crate.node.module);
8282-
trans_vec_append_glue(cx, crate.span);
82838141
auto crate_map = create_crate_map(ccx);
82848142
if (!sess.get_opts().shared) {
82858143
trans_main_fn(cx, crate_map);

trunk/src/rt/rustrt.def.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ rust_process_wait
2323
rust_ptr_eq
2424
rust_run_program
2525
rust_start
26+
rust_vec_append_glue
2627
size_of
2728
squareroot
2829
str_alloc

trunk/src/rt/vec_append.ll

Lines changed: 138 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
%0 = type { i32, i32, i32, i32, [0 x i32] }
2+
%task = type { i32, i32, i32, i32, i32, i32, i32, i32 }
3+
%tydesc = type { %tydesc**, i32, i32, void (i1*, %task*, i1*, %tydesc**, i8*)*, void (i1*, %task*, i1*, %tydesc**, i8*)*, void (i1*, %task*, i1*, %tydesc**, i8*)*, void (i1*, %task*, i1*, %tydesc**, i8*)*, void (i1*, %task*, i1*, %tydesc**, i8*)*, void (i1*, %task*, i1*, %tydesc**, i8*)*, void (i1*, %task*, i1*, %tydesc**, i8*)*, void (i1*, %task*, i1*, %tydesc**, i8*, i8*, i8)* }
4+
5+
declare void @llvm.memmove.p0i8.p0i8.i32(i8* nocapture, i8* nocapture, i32, i32, i1) nounwind
6+
7+
define fastcc void @rust_vec_append_glue(%task*, %tydesc*, %tydesc*, %0**, %0*, i1) {
8+
allocas:
9+
%6 = alloca i32
10+
%7 = alloca i8*
11+
br label %copy_args
12+
13+
copy_args: ; preds = %allocas
14+
br label %derived_tydescs
15+
16+
derived_tydescs: ; preds = %copy_args
17+
br label %8
18+
19+
; <label>:8 ; preds = %derived_tydescs
20+
%9 = load %0** %3
21+
%10 = getelementptr %0* %4, i32 0, i32 2
22+
%11 = load i32* %10
23+
%12 = sub i32 %11, 1
24+
%13 = select i1 %5, i32 %12, i32 %11
25+
%14 = call %0* @upcall_vec_grow(%task* %0, %0* %9, i32 %13, i32* %6, %tydesc* %1)
26+
%15 = getelementptr %0* %14, i32 0, i32 2
27+
%16 = load i32* %15
28+
%17 = sub i32 %16, 1
29+
%18 = select i1 %5, i32 %17, i32 %16
30+
%19 = getelementptr %0* %14, i32 0, i32 4
31+
%20 = bitcast [0 x i32]* %19 to i8*
32+
%21 = getelementptr i8* %20, i32 %18
33+
store i8* %21, i8** %7
34+
%22 = load i32* %6
35+
%23 = trunc i32 %22 to i1
36+
br i1 %23, label %24, label %41
37+
38+
; <label>:24 ; preds = %8
39+
%25 = getelementptr %0* %9, i32 0, i32 2
40+
%26 = load i32* %25
41+
%27 = sub i32 %26, 1
42+
%28 = select i1 %5, i32 %27, i32 %26
43+
%29 = getelementptr %0* %14, i32 0, i32 4
44+
%30 = bitcast [0 x i32]* %29 to i8*
45+
%31 = getelementptr %0* %9, i32 0, i32 4
46+
%32 = bitcast [0 x i32]* %31 to i8*
47+
%33 = getelementptr i8* %32, i32 %28
48+
%34 = getelementptr %tydesc* %2, i32 0, i32 1
49+
%35 = load i32* %34
50+
%36 = getelementptr %tydesc* %2, i32 0, i32 2
51+
%37 = load i32* %36
52+
%38 = ptrtoint i8* %30 to i32
53+
%39 = ptrtoint i8* %32 to i32
54+
%40 = ptrtoint i8* %33 to i32
55+
br label %55
56+
57+
; <label>:41 ; preds = %68, %8
58+
%42 = getelementptr %0* %4, i32 0, i32 2
59+
%43 = load i32* %42
60+
%44 = load i8** %7
61+
%45 = getelementptr %0* %4, i32 0, i32 4
62+
%46 = bitcast [0 x i32]* %45 to i8*
63+
%47 = getelementptr i8* %46, i32 %43
64+
%48 = getelementptr %tydesc* %2, i32 0, i32 1
65+
%49 = load i32* %48
66+
%50 = getelementptr %tydesc* %2, i32 0, i32 2
67+
%51 = load i32* %50
68+
%52 = ptrtoint i8* %44 to i32
69+
%53 = ptrtoint i8* %46 to i32
70+
%54 = ptrtoint i8* %47 to i32
71+
br label %79
72+
73+
; <label>:55 ; preds = %59, %24
74+
%56 = phi i32 [ %38, %24 ], [ %66, %59 ]
75+
%57 = phi i32 [ %39, %24 ], [ %67, %59 ]
76+
%58 = icmp ult i32 %57, %40
77+
br i1 %58, label %59, label %68
78+
79+
; <label>:59 ; preds = %55
80+
%60 = inttoptr i32 %56 to i8*
81+
%61 = inttoptr i32 %57 to i8*
82+
%62 = getelementptr %tydesc* %2, i32 0, i32 0
83+
%63 = load %tydesc*** %62
84+
%64 = getelementptr %tydesc* %2, i32 0, i32 3
85+
%65 = load void (i1*, %task*, i1*, %tydesc**, i8*)** %64
86+
call fastcc void %65(i1* null, %task* %0, i1* null, %tydesc** %63, i8* %61)
87+
%66 = add i32 %56, %35
88+
%67 = add i32 %57, %35
89+
br label %55
90+
91+
; <label>:68 ; preds = %55
92+
call void @llvm.memmove.p0i8.p0i8.i32(i8* %30, i8* %32, i32 %28, i32 0, i1 false)
93+
%69 = getelementptr %0* %9, i32 0, i32 2
94+
%70 = load i32* %69
95+
%71 = getelementptr %0* %14, i32 0, i32 2
96+
store i32 %70, i32* %71
97+
%72 = getelementptr %0* %14, i32 0, i32 2
98+
%73 = load i32* %72
99+
%74 = sub i32 %73, 1
100+
%75 = select i1 %5, i32 %74, i32 %73
101+
%76 = getelementptr %0* %14, i32 0, i32 4
102+
%77 = bitcast [0 x i32]* %76 to i8*
103+
%78 = getelementptr i8* %77, i32 %75
104+
store i8* %78, i8** %7
105+
br label %41
106+
107+
; <label>:79 ; preds = %83, %41
108+
%80 = phi i32 [ %52, %41 ], [ %90, %83 ]
109+
%81 = phi i32 [ %53, %41 ], [ %91, %83 ]
110+
%82 = icmp ult i32 %81, %54
111+
br i1 %82, label %83, label %92
112+
113+
; <label>:83 ; preds = %79
114+
%84 = inttoptr i32 %80 to i8*
115+
%85 = inttoptr i32 %81 to i8*
116+
%86 = getelementptr %tydesc* %2, i32 0, i32 0
117+
%87 = load %tydesc*** %86
118+
%88 = getelementptr %tydesc* %2, i32 0, i32 3
119+
%89 = load void (i1*, %task*, i1*, %tydesc**, i8*)** %88
120+
call fastcc void %89(i1* null, %task* %0, i1* null, %tydesc** %87, i8* %85)
121+
%90 = add i32 %80, %49
122+
%91 = add i32 %81, %49
123+
br label %79
124+
125+
; <label>:92 ; preds = %79
126+
call void @llvm.memmove.p0i8.p0i8.i32(i8* %44, i8* %46, i32 %43, i32 0, i1 false)
127+
%93 = getelementptr %0* %14, i32 0, i32 2
128+
%94 = load i32* %93
129+
%95 = sub i32 %94, 1
130+
%96 = select i1 %5, i32 %95, i32 %94
131+
%97 = add i32 %96, %43
132+
%98 = getelementptr %0* %14, i32 0, i32 2
133+
store i32 %97, i32* %98
134+
store %0* %14, %0** %3
135+
ret void
136+
}
137+
138+
declare %0* @upcall_vec_grow(%task*, %0*, i32, i32*, %tydesc*)

0 commit comments

Comments
 (0)