mirror of
https://github.com/rust-lang/rust.git
synced 2025-01-11 23:33:00 +00:00
rt: Remove the _2 prefix from intrinsics; all rust-intrinsics now use explicit return pointers
This commit is contained in:
parent
f02c998a8d
commit
d30f22eb65
@ -7,7 +7,7 @@ import uint::next_power_of_two;
|
||||
type operator2[T,U,V] = fn(&T, &U) -> V;
|
||||
|
||||
native "rust-intrinsic" mod rusti {
|
||||
fn ivec_len_2[T](&T[] v) -> uint;
|
||||
fn ivec_len[T](&T[] v) -> uint;
|
||||
}
|
||||
|
||||
native "rust" mod rustrt {
|
||||
@ -32,7 +32,7 @@ fn to_ptr[T](&T[] v) -> *T {
|
||||
}
|
||||
|
||||
fn len[T](&T[mutable?] v) -> uint {
|
||||
ret rusti::ivec_len_2(v);
|
||||
ret rusti::ivec_len(v);
|
||||
}
|
||||
|
||||
type init_op[T] = fn(uint) -> T;
|
||||
|
@ -8,35 +8,16 @@
|
||||
extern "C" CDECL void
|
||||
upcall_fail(rust_task *task, char const *expr, char const *file, size_t line);
|
||||
|
||||
extern "C" size_t
|
||||
rust_intrinsic_vec_len(rust_task *task, type_desc *ty, rust_vec *v)
|
||||
{
|
||||
return v->fill / ty->size;
|
||||
}
|
||||
|
||||
extern "C" size_t
|
||||
rust_intrinsic_ivec_len(rust_task *task, type_desc *ty, rust_ivec *v)
|
||||
{
|
||||
size_t fill;
|
||||
if (v->fill)
|
||||
fill = v->fill;
|
||||
else if (v->payload.ptr)
|
||||
fill = v->payload.ptr->fill;
|
||||
else
|
||||
fill = 0;
|
||||
return fill / ty->size;
|
||||
}
|
||||
|
||||
extern "C" void
|
||||
rust_intrinsic_vec_len_2(rust_task *task, size_t *retptr, type_desc *ty,
|
||||
rust_vec *v)
|
||||
rust_intrinsic_vec_len(rust_task *task, size_t *retptr, type_desc *ty,
|
||||
rust_vec *v)
|
||||
{
|
||||
*retptr = v->fill / ty->size;
|
||||
}
|
||||
|
||||
extern "C" void
|
||||
rust_intrinsic_ivec_len_2(rust_task *task, size_t *retptr, type_desc *ty,
|
||||
rust_ivec *v)
|
||||
rust_intrinsic_ivec_len(rust_task *task, size_t *retptr, type_desc *ty,
|
||||
rust_ivec *v)
|
||||
{
|
||||
size_t fill;
|
||||
if (v->fill)
|
||||
|
@ -64,43 +64,7 @@ target triple = "@CFG_LLVM_TRIPLE@"
|
||||
@.str = private unnamed_addr constant [42 x i8] c"attempt to cast values of differing sizes\00", align 1
|
||||
@.str1 = private unnamed_addr constant [15 x i8] c"intrinsics.cpp\00", align 1
|
||||
|
||||
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 {
|
||||
entry:
|
||||
%fill = getelementptr inbounds %struct.rust_vec* %v, i32 0, i32 2
|
||||
%tmp1 = load i32* %fill, align 4, !tbaa !0
|
||||
%size = getelementptr inbounds %struct.type_desc* %ty, i32 0, i32 1
|
||||
%tmp3 = load i32* %size, align 4, !tbaa !0
|
||||
%div = udiv i32 %tmp1, %tmp3
|
||||
ret i32 %div
|
||||
}
|
||||
|
||||
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 {
|
||||
entry:
|
||||
%fill1 = getelementptr inbounds %struct.rust_ivec* %v, i32 0, i32 0
|
||||
%tmp2 = load i32* %fill1, align 4, !tbaa !0
|
||||
%tobool = icmp eq i32 %tmp2, 0
|
||||
br i1 %tobool, label %if.else, label %if.end17
|
||||
|
||||
if.else: ; preds = %entry
|
||||
%ptr = getelementptr inbounds %struct.rust_ivec* %v, i32 0, i32 2, i32 0
|
||||
%tmp7 = load %struct.rust_ivec_heap** %ptr, align 4, !tbaa !3
|
||||
%tobool8 = icmp eq %struct.rust_ivec_heap* %tmp7, null
|
||||
br i1 %tobool8, label %if.end17, label %if.then9
|
||||
|
||||
if.then9: ; preds = %if.else
|
||||
%fill14 = getelementptr inbounds %struct.rust_ivec_heap* %tmp7, i32 0, i32 0
|
||||
%tmp15 = load i32* %fill14, align 4, !tbaa !0
|
||||
br label %if.end17
|
||||
|
||||
if.end17: ; preds = %if.else, %entry, %if.then9
|
||||
%fill.0 = phi i32 [ %tmp15, %if.then9 ], [ %tmp2, %entry ], [ 0, %if.else ]
|
||||
%size = getelementptr inbounds %struct.type_desc* %ty, i32 0, i32 1
|
||||
%tmp20 = load i32* %size, align 4, !tbaa !0
|
||||
%div = udiv i32 %fill.0, %tmp20
|
||||
ret i32 %div
|
||||
}
|
||||
|
||||
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 {
|
||||
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 {
|
||||
entry:
|
||||
%fill = getelementptr inbounds %struct.rust_vec* %v, i32 0, i32 2
|
||||
%tmp1 = load i32* %fill, align 4, !tbaa !0
|
||||
@ -111,7 +75,7 @@ entry:
|
||||
ret void
|
||||
}
|
||||
|
||||
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 {
|
||||
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 {
|
||||
entry:
|
||||
%fill1 = getelementptr inbounds %struct.rust_ivec* %v, i32 0, i32 0
|
||||
%tmp2 = load i32* %fill1, align 4, !tbaa !0
|
||||
@ -158,7 +122,7 @@ entry:
|
||||
br i1 %cmp, label %if.end, label %if.then
|
||||
|
||||
if.then: ; preds = %entry
|
||||
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)
|
||||
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)
|
||||
br label %return
|
||||
|
||||
if.end: ; preds = %entry
|
||||
|
@ -1,31 +1,31 @@
|
||||
// xfail-stage0
|
||||
|
||||
import rusti::ivec_len_2;
|
||||
import rusti::ivec_len;
|
||||
|
||||
native "rust-intrinsic" mod rusti {
|
||||
fn ivec_len_2[T](&T[] v) -> uint;
|
||||
fn ivec_len[T](&T[] v) -> uint;
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let int[] v = ~[];
|
||||
assert (ivec_len_2(v) == 0u); // zero-length
|
||||
assert (ivec_len(v) == 0u); // zero-length
|
||||
auto x = ~[ 1, 2 ];
|
||||
assert (ivec_len_2(x) == 2u); // on stack
|
||||
assert (ivec_len(x) == 2u); // on stack
|
||||
auto y = ~[ 1, 2, 3, 4, 5 ];
|
||||
assert (ivec_len_2(y) == 5u); // on heap
|
||||
assert (ivec_len(y) == 5u); // on heap
|
||||
|
||||
v += ~[];
|
||||
assert (ivec_len_2(v) == 0u); // zero-length append
|
||||
assert (ivec_len(v) == 0u); // zero-length append
|
||||
x += ~[ 3 ];
|
||||
assert (ivec_len_2(x) == 3u); // on-stack append
|
||||
assert (ivec_len(x) == 3u); // on-stack append
|
||||
y += ~[ 6, 7, 8, 9 ];
|
||||
assert (ivec_len_2(y) == 9u); // on-heap append
|
||||
assert (ivec_len(y) == 9u); // on-heap append
|
||||
|
||||
auto vv = v + v;
|
||||
assert (ivec_len_2(vv) == 0u); // zero-length add
|
||||
assert (ivec_len(vv) == 0u); // zero-length add
|
||||
auto xx = x + ~[ 4 ];
|
||||
assert (ivec_len_2(xx) == 4u); // on-stack add
|
||||
assert (ivec_len(xx) == 4u); // on-stack add
|
||||
auto yy = y + ~[ 10, 11 ];
|
||||
assert (ivec_len_2(yy) == 11u); // on-heap add
|
||||
assert (ivec_len(yy) == 11u); // on-heap add
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user