Skip to content

Commit 4583b8b

Browse files
committed
---
yaml --- r: 3774 b: refs/heads/master c: d30f22e h: refs/heads/master v: v3
1 parent 9ce779b commit 4583b8b

File tree

5 files changed

+21
-76
lines changed

5 files changed

+21
-76
lines changed

[refs]

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

trunk/src/lib/ivec.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import uint::next_power_of_two;
77
type operator2[T,U,V] = fn(&T, &U) -> V;
88

99
native "rust-intrinsic" mod rusti {
10-
fn ivec_len_2[T](&T[] v) -> uint;
10+
fn ivec_len[T](&T[] v) -> uint;
1111
}
1212

1313
native "rust" mod rustrt {
@@ -32,7 +32,7 @@ fn to_ptr[T](&T[] v) -> *T {
3232
}
3333

3434
fn len[T](&T[mutable?] v) -> uint {
35-
ret rusti::ivec_len_2(v);
35+
ret rusti::ivec_len(v);
3636
}
3737

3838
type init_op[T] = fn(uint) -> T;

trunk/src/rt/intrinsics/intrinsics.cpp

+4-23
Original file line numberDiff line numberDiff line change
@@ -8,35 +8,16 @@
88
extern "C" CDECL void
99
upcall_fail(rust_task *task, char const *expr, char const *file, size_t line);
1010

11-
extern "C" size_t
12-
rust_intrinsic_vec_len(rust_task *task, type_desc *ty, rust_vec *v)
13-
{
14-
return v->fill / ty->size;
15-
}
16-
17-
extern "C" size_t
18-
rust_intrinsic_ivec_len(rust_task *task, type_desc *ty, rust_ivec *v)
19-
{
20-
size_t fill;
21-
if (v->fill)
22-
fill = v->fill;
23-
else if (v->payload.ptr)
24-
fill = v->payload.ptr->fill;
25-
else
26-
fill = 0;
27-
return fill / ty->size;
28-
}
29-
3011
extern "C" void
31-
rust_intrinsic_vec_len_2(rust_task *task, size_t *retptr, type_desc *ty,
32-
rust_vec *v)
12+
rust_intrinsic_vec_len(rust_task *task, size_t *retptr, type_desc *ty,
13+
rust_vec *v)
3314
{
3415
*retptr = v->fill / ty->size;
3516
}
3617

3718
extern "C" void
38-
rust_intrinsic_ivec_len_2(rust_task *task, size_t *retptr, type_desc *ty,
39-
rust_ivec *v)
19+
rust_intrinsic_ivec_len(rust_task *task, size_t *retptr, type_desc *ty,
20+
rust_ivec *v)
4021
{
4122
size_t fill;
4223
if (v->fill)

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

+3-39
Original file line numberDiff line numberDiff line change
@@ -64,43 +64,7 @@ target triple = "@CFG_LLVM_TRIPLE@"
6464
@.str = private unnamed_addr constant [42 x i8] c"attempt to cast values of differing sizes\00", align 1
6565
@.str1 = private unnamed_addr constant [15 x i8] c"intrinsics.cpp\00", align 1
6666

67-
define linkonce_odr i32 @rust_intrinsic_vec_len(%struct.rust_task* nocapture %task, %struct.type_desc* nocapture %ty, %struct.rust_vec* nocapture %v) nounwind readonly {
68-
entry:
69-
%fill = getelementptr inbounds %struct.rust_vec* %v, i32 0, i32 2
70-
%tmp1 = load i32* %fill, align 4, !tbaa !0
71-
%size = getelementptr inbounds %struct.type_desc* %ty, i32 0, i32 1
72-
%tmp3 = load i32* %size, align 4, !tbaa !0
73-
%div = udiv i32 %tmp1, %tmp3
74-
ret i32 %div
75-
}
76-
77-
define linkonce_odr i32 @rust_intrinsic_ivec_len(%struct.rust_task* nocapture %task, %struct.type_desc* nocapture %ty, %struct.rust_ivec* nocapture %v) nounwind readonly {
78-
entry:
79-
%fill1 = getelementptr inbounds %struct.rust_ivec* %v, i32 0, i32 0
80-
%tmp2 = load i32* %fill1, align 4, !tbaa !0
81-
%tobool = icmp eq i32 %tmp2, 0
82-
br i1 %tobool, label %if.else, label %if.end17
83-
84-
if.else: ; preds = %entry
85-
%ptr = getelementptr inbounds %struct.rust_ivec* %v, i32 0, i32 2, i32 0
86-
%tmp7 = load %struct.rust_ivec_heap** %ptr, align 4, !tbaa !3
87-
%tobool8 = icmp eq %struct.rust_ivec_heap* %tmp7, null
88-
br i1 %tobool8, label %if.end17, label %if.then9
89-
90-
if.then9: ; preds = %if.else
91-
%fill14 = getelementptr inbounds %struct.rust_ivec_heap* %tmp7, i32 0, i32 0
92-
%tmp15 = load i32* %fill14, align 4, !tbaa !0
93-
br label %if.end17
94-
95-
if.end17: ; preds = %if.else, %entry, %if.then9
96-
%fill.0 = phi i32 [ %tmp15, %if.then9 ], [ %tmp2, %entry ], [ 0, %if.else ]
97-
%size = getelementptr inbounds %struct.type_desc* %ty, i32 0, i32 1
98-
%tmp20 = load i32* %size, align 4, !tbaa !0
99-
%div = udiv i32 %fill.0, %tmp20
100-
ret i32 %div
101-
}
102-
103-
define linkonce_odr void @rust_intrinsic_vec_len_2(%struct.rust_task* nocapture %task, i32* nocapture %retptr, %struct.type_desc* nocapture %ty, %struct.rust_vec* nocapture %v) nounwind {
67+
define linkonce_odr void @rust_intrinsic_vec_len(%struct.rust_task* nocapture %task, i32* nocapture %retptr, %struct.type_desc* nocapture %ty, %struct.rust_vec* nocapture %v) nounwind {
10468
entry:
10569
%fill = getelementptr inbounds %struct.rust_vec* %v, i32 0, i32 2
10670
%tmp1 = load i32* %fill, align 4, !tbaa !0
@@ -111,7 +75,7 @@ entry:
11175
ret void
11276
}
11377

114-
define linkonce_odr void @rust_intrinsic_ivec_len_2(%struct.rust_task* nocapture %task, i32* nocapture %retptr, %struct.type_desc* nocapture %ty, %struct.rust_ivec* nocapture %v) nounwind {
78+
define linkonce_odr void @rust_intrinsic_ivec_len(%struct.rust_task* nocapture %task, i32* nocapture %retptr, %struct.type_desc* nocapture %ty, %struct.rust_ivec* nocapture %v) nounwind {
11579
entry:
11680
%fill1 = getelementptr inbounds %struct.rust_ivec* %v, i32 0, i32 0
11781
%tmp2 = load i32* %fill1, align 4, !tbaa !0
@@ -158,7 +122,7 @@ entry:
158122
br i1 %cmp, label %if.end, label %if.then
159123

160124
if.then: ; preds = %entry
161-
tail call void @upcall_fail(%struct.rust_task* %task, i8* getelementptr inbounds ([42 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([15 x i8]* @.str1, i32 0, i32 0), i32 64)
125+
tail call void @upcall_fail(%struct.rust_task* %task, i8* getelementptr inbounds ([42 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([15 x i8]* @.str1, i32 0, i32 0), i32 45)
162126
br label %return
163127

164128
if.end: ; preds = %entry
+11-11
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,31 @@
11
// xfail-stage0
22

3-
import rusti::ivec_len_2;
3+
import rusti::ivec_len;
44

55
native "rust-intrinsic" mod rusti {
6-
fn ivec_len_2[T](&T[] v) -> uint;
6+
fn ivec_len[T](&T[] v) -> uint;
77
}
88

99
fn main() {
1010
let int[] v = ~[];
11-
assert (ivec_len_2(v) == 0u); // zero-length
11+
assert (ivec_len(v) == 0u); // zero-length
1212
auto x = ~[ 1, 2 ];
13-
assert (ivec_len_2(x) == 2u); // on stack
13+
assert (ivec_len(x) == 2u); // on stack
1414
auto y = ~[ 1, 2, 3, 4, 5 ];
15-
assert (ivec_len_2(y) == 5u); // on heap
15+
assert (ivec_len(y) == 5u); // on heap
1616

1717
v += ~[];
18-
assert (ivec_len_2(v) == 0u); // zero-length append
18+
assert (ivec_len(v) == 0u); // zero-length append
1919
x += ~[ 3 ];
20-
assert (ivec_len_2(x) == 3u); // on-stack append
20+
assert (ivec_len(x) == 3u); // on-stack append
2121
y += ~[ 6, 7, 8, 9 ];
22-
assert (ivec_len_2(y) == 9u); // on-heap append
22+
assert (ivec_len(y) == 9u); // on-heap append
2323

2424
auto vv = v + v;
25-
assert (ivec_len_2(vv) == 0u); // zero-length add
25+
assert (ivec_len(vv) == 0u); // zero-length add
2626
auto xx = x + ~[ 4 ];
27-
assert (ivec_len_2(xx) == 4u); // on-stack add
27+
assert (ivec_len(xx) == 4u); // on-stack add
2828
auto yy = y + ~[ 10, 11 ];
29-
assert (ivec_len_2(yy) == 11u); // on-heap add
29+
assert (ivec_len(yy) == 11u); // on-heap add
3030
}
3131

0 commit comments

Comments
 (0)