Skip to content

Commit 2087b94

Browse files
committed
---
yaml --- r: 6202 b: refs/heads/master c: 061d2c2 h: refs/heads/master v: v3
1 parent e277b77 commit 2087b94

File tree

10 files changed

+190
-135
lines changed

10 files changed

+190
-135
lines changed

[refs]

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
---
2-
refs/heads/master: 68f82de8178ca5f7ed7a3803fdc41f84fc97664b
2+
refs/heads/master: 061d2c2f7791f18538c42d043fb320f0316a0ed6

trunk/src/etc/gen-intrinsics

+10-3
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,21 @@
66

77
for ARCH in i386 x86_64
88
do
9-
clang++ -emit-llvm -S -arch $ARCH -O3 -Isrc/rt/isaac -Isrc/rt/uthash \
9+
if [ $ARCH = "i386" ]
10+
then
11+
BITS=32
12+
else
13+
BITS=64
14+
fi
15+
16+
clang++ -emit-llvm -S -m$BITS -O3 -Isrc/rt/isaac -Isrc/rt/uthash \
1017
-Isrc/rt/arch/$ARCH -fno-stack-protector \
1118
-o src/rt/intrinsics/intrinsics.$ARCH.ll.in \
1219
src/rt/intrinsics/intrinsics.cpp
13-
sed -i "" \
20+
sed -i \
1421
-e 's/^target datalayout =/; target datalayout =/' \
1522
src/rt/intrinsics/intrinsics.$ARCH.ll.in
16-
sed -i "" \
23+
sed -i \
1724
-e 's/^target triple = "[^"]*"/target triple = "@CFG_TARGET_TRIPLE@"/' \
1825
src/rt/intrinsics/intrinsics.$ARCH.ll.in
1926
done

trunk/src/lib/task.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ export spawn;
5050
export spawn_notify;
5151
export spawn_joinable;
5252

53-
native "cdecl" mod rustrt {
53+
native "rust-intrinsic" mod rustrt {
5454
// these must run on the Rust stack so that they can swap stacks etc:
5555
fn task_sleep(time_in_us: uint);
5656
}

trunk/src/rt/intrinsics/intrinsics.cpp

+11
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,12 @@
99
extern "C" CDECL void
1010
upcall_fail(char const *expr, char const *file, size_t line);
1111

12+
extern "C" CDECL void
13+
port_recv(uintptr_t *dptr, rust_port *port);
14+
15+
extern "C" CDECL void
16+
rust_task_sleep(size_t time_in_us);
17+
1218
extern "C" void
1319
rust_intrinsic_vec_len(rust_task *task, size_t *retptr, type_desc *ty,
1420
rust_vec **vp)
@@ -54,3 +60,8 @@ rust_intrinsic_get_type_desc(rust_task *task, void **retptr,
5460
*(type_desc**)retptr = ty;
5561
}
5662

63+
extern "C" void
64+
rust_intrinsic_task_sleep(rust_task *_task, void **retptr,
65+
size_t time_in_us) {
66+
rust_task_sleep(time_in_us);
67+
}
+74-56
Original file line numberDiff line numberDiff line change
@@ -1,93 +1,99 @@
11
; ModuleID = 'src/rt/intrinsics/intrinsics.cpp'
2-
; target datalayout = "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"
2+
; target datalayout = "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:32:32-n8:16:32-S128"
33
target triple = "@CFG_TARGET_TRIPLE@"
44

5-
%0 = type { i32, %"struct.memory_region::alloc_header"**, i32 }
6-
%1 = type { i32, %struct.rust_scheduler**, i32 }
7-
%2 = type { %"struct.hash_map<long, rust_task *>::map_entry"* }
8-
%3 = type { %struct.rust_task*, i32, i32, %class.rust_chan** }
9-
%class.array_list = type { i32, %struct.rust_task**, i32 }
10-
%class.circular_buffer = type { %class.rust_kernel*, i32, i32, i32, i32, i8* }
5+
%struct.rust_task = type { %struct.rust_task_user, i32, %class.context, %struct.stk_seg*, i32, %struct.rust_scheduler*, %class.rust_crate_cache*, %class.rust_kernel*, i8*, %class.rust_task_list*, %struct.rust_cond*, i8*, %struct.rust_task*, i32, i32, %class.timer, i32*, %class.array_list.1, i32, i32, %class.memory_region, %"class.rust_task::wakeup_callback"*, i8, i8, i8, %class.lock_and_signal, %class.hash_map.4, %class.rust_obstack, %"class.std::map", i32, %"class.debug::task_debug_info" }
6+
%struct.rust_task_user = type { i32, i32, %struct.chan_handle, i32 }
7+
%struct.chan_handle = type { i32, i32 }
118
%class.context = type { %struct.registers_t, %class.context* }
12-
%"class.debug::task_debug_info" = type { %"class.std::map" }
13-
%class.hash_map = type { %"struct.hash_map<long, rust_port *>::map_entry"* }
14-
%class.indexed_list = type { i32 (...)**, %class.array_list }
15-
%class.lock_and_signal = type { i32 (...)**, %struct._opaque_pthread_cond_t, %struct._opaque_pthread_mutex_t, %struct._opaque_pthread_t*, i8, i8 }
16-
%class.memory_region = type { i32 (...)**, %class.rust_srv*, %class.memory_region*, i32, %0, i8, i8, %class.lock_and_signal }
17-
%class.ptr_vec = type { %struct.rust_task*, i32, i32, %struct.rust_token** }
18-
%class.rust_chan = type { i32, %class.rust_kernel*, %struct.rust_task*, %class.rust_port*, i32, %class.circular_buffer }
19-
%class.rust_crate_cache = type { %struct.type_desc*, %struct.rust_scheduler*, i32 }
20-
%class.rust_kernel = type { i32 (...)**, %class.memory_region, %class.rust_log, %class.rust_srv*, %class.lock_and_signal, %1, %struct.randctx, i32, %2, i32, i32, i32, %struct.rust_env* }
9+
%struct.registers_t = type { i32, i32, i32, i32, i32, i32, i32, i32, i16, i16, i16, i16, i16, i16, i32, i32 }
10+
%struct.stk_seg = type { %struct.stk_seg*, i32, i32, i32, [0 x i8] }
11+
%struct.rust_scheduler = type { %class.rust_thread, i32, i32, %class.rust_log, i32, %class.rust_srv*, i8*, %class.rust_task_list, %class.rust_task_list, %class.rust_task_list, %class.rust_task_list, %class.rust_crate_cache, %struct.randctx, %class.rust_kernel*, i32, i32, %class.lock_and_signal, i32, %union.pthread_attr_t, %struct.rust_env*, %class.context }
12+
%class.rust_thread = type { i32 (...)**, i8, i32 }
2113
%class.rust_log = type { i32 (...)**, %class.rust_srv*, %struct.rust_scheduler*, i8 }
22-
%class.rust_obstack = type { %struct.rust_obstack_chunk*, %struct.rust_task* }
23-
%class.rust_port = type { i32, i32, %class.rust_kernel*, %struct.rust_task*, %class.rust_chan*, i32, %class.ptr_vec, %3, %class.lock_and_signal }
2414
%class.rust_srv = type { i32 (...)**, %struct.rust_env*, %class.memory_region }
25-
%"class.rust_task::wakeup_callback" = type { i32 (...)** }
15+
%struct.rust_env = type { i32, i32, i8*, i8, i8, i8* }
16+
%class.memory_region = type { i32 (...)**, %class.rust_srv*, %class.memory_region*, i32, %class.array_list, i8, i8, %class.lock_and_signal }
17+
%class.array_list = type { i32, %"struct.memory_region::alloc_header"**, i32 }
18+
%"struct.memory_region::alloc_header" = type { i32, i32, i8*, i32, [0 x i8] }
19+
%class.lock_and_signal = type { i32 (...)**, %union.pthread_cond_t, %union.pthread_mutex_t, i32, i8, i8 }
20+
%union.pthread_cond_t = type { %struct.anon, [4 x i8] }
21+
%struct.anon = type { i32, i32, i64, i64, i64, i8*, i32, i32 }
22+
%union.pthread_mutex_t = type { %"struct.<anonymous union>::__pthread_mutex_s" }
23+
%"struct.<anonymous union>::__pthread_mutex_s" = type { i32, i32, i32, i32, i32, %union.anon }
24+
%union.anon = type { i32 }
2625
%class.rust_task_list = type { %class.indexed_list, %struct.rust_scheduler*, i8* }
27-
%class.rust_thread = type { i32 (...)**, i8, %struct._opaque_pthread_t* }
28-
%"class.std::_Rb_tree" = type { %"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" }
29-
%"class.std::map" = type { %"class.std::_Rb_tree" }
30-
%class.timer = type { i32 (...)**, i64, i64 }
31-
%struct.UT_hash_bucket = type { %struct.UT_hash_handle*, i32, i32 }
26+
%class.indexed_list = type { i32 (...)**, %class.array_list.1 }
27+
%class.array_list.1 = type { i32, %struct.rust_task**, i32 }
28+
%class.rust_crate_cache = type { %struct.type_desc*, %struct.rust_scheduler*, i32 }
29+
%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*] }
30+
%struct.rust_shape_tables = type { i8*, i8* }
3231
%struct.UT_hash_handle = type { %struct.UT_hash_table*, i8*, i8*, %struct.UT_hash_handle*, %struct.UT_hash_handle*, i8*, i32, i32 }
3332
%struct.UT_hash_table = type { %struct.UT_hash_bucket*, i32, i32, i32, %struct.UT_hash_handle*, i32, i32, i32, i32, i32 }
34-
%struct.__darwin_pthread_handler_rec = type { void (i8*)*, i8*, %struct.__darwin_pthread_handler_rec* }
35-
%struct._opaque_pthread_attr_t = type { i32, [36 x i8] }
36-
%struct._opaque_pthread_cond_t = type { i32, [24 x i8] }
37-
%struct._opaque_pthread_mutex_t = type { i32, [40 x i8] }
38-
%struct._opaque_pthread_t = type { i32, %struct.__darwin_pthread_handler_rec*, [596 x i8] }
39-
%struct.chan_handle = type { i32, i32 }
40-
%"struct.hash_map<long, rust_port *>::map_entry" = type opaque
41-
%"struct.hash_map<long, rust_task *>::map_entry" = type opaque
42-
%"struct.memory_region::alloc_header" = type { i32, i32, i8*, i32, [0 x i8] }
33+
%struct.UT_hash_bucket = type { %struct.UT_hash_handle*, i32, i32 }
4334
%struct.randctx = type { i32, [256 x i32], [256 x i32], i32, i32, i32 }
44-
%struct.registers_t = type { i32, i32, i32, i32, i32, i32, i32, i32, i16, i16, i16, i16, i16, i16, i32, i32 }
35+
%class.rust_kernel = type { i32 (...)**, %class.memory_region, %class.rust_log, %class.rust_srv*, %class.lock_and_signal, %class.array_list.3, %struct.randctx, i32, %class.hash_map, i32, i32, i32, %struct.rust_env* }
36+
%class.array_list.3 = type { i32, %struct.rust_scheduler**, i32 }
37+
%class.hash_map = type { %"struct.hash_map<int, rust_task *>::map_entry"* }
38+
%"struct.hash_map<int, rust_task *>::map_entry" = type opaque
39+
%union.pthread_attr_t = type { i32, [32 x i8] }
4540
%struct.rust_cond = type { i8 }
46-
%struct.rust_env = type { i32, i32, i8*, i8, i8, i8* }
41+
%class.timer = type { i32 (...)**, i64, i64 }
42+
%"class.rust_task::wakeup_callback" = type { i32 (...)** }
43+
%class.hash_map.4 = type { %"struct.hash_map<int, rust_port *>::map_entry"* }
44+
%"struct.hash_map<int, rust_port *>::map_entry" = type opaque
45+
%class.rust_obstack = type { %struct.rust_obstack_chunk*, %struct.rust_task* }
4746
%struct.rust_obstack_chunk = type { %struct.rust_obstack_chunk*, i32, i32, i32, [0 x i8] }
48-
%struct.rust_scheduler = type { %class.rust_thread, i32, i32, %class.rust_log, i32, %class.rust_srv*, i8*, %class.rust_task_list, %class.rust_task_list, %class.rust_task_list, %class.rust_task_list, %class.rust_crate_cache, %struct.randctx, %class.rust_kernel*, i32, i32, %class.lock_and_signal, i32, %struct._opaque_pthread_attr_t, %struct.rust_env*, %class.context }
49-
%struct.rust_shape_tables = type { i8*, i8* }
50-
%struct.rust_task = type { %struct.rust_task_user, i32, %class.context, %struct.rust_vec*, i32, %struct.rust_scheduler*, %class.rust_crate_cache*, %class.rust_kernel*, i8*, %class.rust_task_list*, %struct.rust_cond*, i8*, %struct.rust_task*, i32, i32, %class.timer, i32*, %class.array_list, i32, i32, %class.memory_region, %"class.rust_task::wakeup_callback"*, i8, i8, i8, %class.lock_and_signal, %class.hash_map, %class.rust_obstack, %"class.std::map", i32, %"class.debug::task_debug_info" }
51-
%struct.rust_task_user = type { i32, i32, %struct.chan_handle, i32 }
52-
%struct.rust_token = type opaque
53-
%struct.rust_vec = type { i32, i32, [0 x i8] }
54-
%"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 }
47+
%"class.std::map" = type { %"class.std::_Rb_tree" }
48+
%"class.std::_Rb_tree" = type { %"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" }
49+
%"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.std::less", %"struct.std::_Rb_tree_node_base", i32 }
50+
%"struct.std::less" = type { i8 }
5551
%"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*, 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*] }
52+
%"class.debug::task_debug_info" = type { %"class.std::map.5" }
53+
%"class.std::map.5" = type { %"class.std::_Rb_tree.6" }
54+
%"class.std::_Rb_tree.6" = type { %"struct.std::_Rb_tree<void *, std::pair<void *const, std::basic_string<char> >, std::_Select1st<std::pair<void *const, std::basic_string<char> > >, std::less<void *>, std::allocator<std::pair<void *const, std::basic_string<char> > > >::_Rb_tree_impl" }
55+
%"struct.std::_Rb_tree<void *, std::pair<void *const, std::basic_string<char> >, std::_Select1st<std::pair<void *const, std::basic_string<char> > >, std::less<void *>, std::allocator<std::pair<void *const, std::basic_string<char> > > >::_Rb_tree_impl" = type { %"struct.std::less", %"struct.std::_Rb_tree_node_base", i32 }
56+
%struct.rust_vec = type { i32, i32, [0 x i8] }
57+
%class.rust_port = type { i32, i32, %class.rust_kernel*, %struct.rust_task*, %class.rust_chan*, i32, %class.ptr_vec, %class.ptr_vec.13, %class.lock_and_signal }
58+
%class.rust_chan = type { i32, %class.rust_kernel*, %struct.rust_task*, %class.rust_port*, i32, %class.circular_buffer }
59+
%class.circular_buffer = type { %class.rust_kernel*, i32, i32, i32, i32, i8* }
60+
%class.ptr_vec = type { %struct.rust_task*, i32, i32, %struct.rust_token** }
61+
%struct.rust_token = type opaque
62+
%class.ptr_vec.13 = type { %struct.rust_task*, i32, i32, %class.rust_chan** }
5763

58-
@.str = private unnamed_addr constant [42 x i8] c"attempt to cast values of differing sizes\00"
59-
@.str1 = private unnamed_addr constant [33 x i8] c"src/rt/intrinsics/intrinsics.cpp\00"
64+
@.str = private unnamed_addr constant [42 x i8] c"attempt to cast values of differing sizes\00", align 1
65+
@.str1 = private unnamed_addr constant [33 x i8] c"src/rt/intrinsics/intrinsics.cpp\00", align 1
6066

6167
define void @rust_intrinsic_vec_len(%struct.rust_task* nocapture %task, i32* nocapture %retptr, %struct.type_desc* nocapture %ty, %struct.rust_vec** nocapture %vp) nounwind {
62-
%1 = load %struct.rust_vec** %vp, align 4
68+
%1 = load %struct.rust_vec** %vp, align 4, !tbaa !0
6369
%2 = getelementptr inbounds %struct.rust_vec* %1, i32 0, i32 0
64-
%3 = load i32* %2, align 4
70+
%3 = load i32* %2, align 4, !tbaa !3
6571
%4 = getelementptr inbounds %struct.type_desc* %ty, i32 0, i32 1
66-
%5 = load i32* %4, align 4
72+
%5 = load i32* %4, align 4, !tbaa !3
6773
%6 = udiv i32 %3, %5
68-
store i32 %6, i32* %retptr, align 4
74+
store i32 %6, i32* %retptr, align 4, !tbaa !3
6975
ret void
7076
}
7177

7278
define void @rust_intrinsic_ptr_offset(%struct.rust_task* nocapture %task, i8** nocapture %retptr, %struct.type_desc* nocapture %ty, i8* %ptr, i32 %count) nounwind {
7379
%1 = getelementptr inbounds %struct.type_desc* %ty, i32 0, i32 1
74-
%2 = load i32* %1, align 4
80+
%2 = load i32* %1, align 4, !tbaa !3
7581
%3 = mul i32 %2, %count
7682
%4 = getelementptr inbounds i8* %ptr, i32 %3
77-
store i8* %4, i8** %retptr, align 4
83+
store i8* %4, i8** %retptr, align 4, !tbaa !0
7884
ret void
7985
}
8086

8187
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) {
8288
%1 = getelementptr inbounds %struct.type_desc* %t1, i32 0, i32 1
83-
%2 = load i32* %1, align 4
89+
%2 = load i32* %1, align 4, !tbaa !3
8490
%3 = getelementptr inbounds %struct.type_desc* %t2, i32 0, i32 1
85-
%4 = load i32* %3, align 4
91+
%4 = load i32* %3, align 4, !tbaa !3
8692
%5 = icmp eq i32 %2, %4
8793
br i1 %5, label %7, label %6
8894

8995
; <label>:6 ; preds = %0
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)
96+
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 38)
9197
br label %8
9298

9399
; <label>:7 ; preds = %0
@@ -103,7 +109,7 @@ declare void @upcall_fail(i8*, i8*, i32)
103109
declare void @llvm.memmove.p0i8.p0i8.i32(i8* nocapture, i8* nocapture, i32, i32, i1) nounwind
104110

105111
define void @rust_intrinsic_addr_of(%struct.rust_task* nocapture %task, i8** nocapture %retptr, %struct.type_desc* nocapture %ty, i8* %valptr) nounwind {
106-
store i8* %valptr, i8** %retptr, align 4
112+
store i8* %valptr, i8** %retptr, align 4, !tbaa !0
107113
ret void
108114
}
109115

@@ -117,6 +123,18 @@ declare void @port_recv(i32*, %class.rust_port*)
117123

118124
define void @rust_intrinsic_get_type_desc(%struct.rust_task* nocapture %task, i8** nocapture %retptr, %struct.type_desc* %ty) nounwind {
119125
%ty.c = bitcast %struct.type_desc* %ty to i8*
120-
store i8* %ty.c, i8** %retptr, align 4
126+
store i8* %ty.c, i8** %retptr, align 4, !tbaa !0
121127
ret void
122128
}
129+
130+
define void @rust_intrinsic_task_sleep(%struct.rust_task* nocapture %_task, i8** nocapture %retptr, i32 %time_in_us) {
131+
tail call void @rust_task_sleep(i32 %time_in_us)
132+
ret void
133+
}
134+
135+
declare void @rust_task_sleep(i32)
136+
137+
!0 = metadata !{metadata !"any pointer", metadata !1}
138+
!1 = metadata !{metadata !"omnipotent char", metadata !2}
139+
!2 = metadata !{metadata !"Simple C/C++ TBAA", null}
140+
!3 = metadata !{metadata !"int", metadata !1}

0 commit comments

Comments
 (0)