Skip to content

Commit 0b63781

Browse files
author
Eric Holk
committed
---
yaml --- r: 4310 b: refs/heads/master c: 286be2d h: refs/heads/master v: v3
1 parent 8068f9a commit 0b63781

File tree

6 files changed

+210
-54
lines changed

6 files changed

+210
-54
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: 2f7ed335178c7fbe5d35e015774ca06486c69ce3
2+
refs/heads/master: 286be2d94e8904765e1ef0f5fcc2899f8501a654

trunk/src/rt/intrinsics/intrinsics.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,3 +55,8 @@ rust_intrinsic_addr_of(rust_task *task, void **retptr, type_desc *ty,
5555
*retptr = valptr;
5656
}
5757

58+
extern "C" void
59+
rust_intrinsic_recv(rust_task *task, void **retptr, type_desc *ty,
60+
rust_port *port) {
61+
port_recv(task, (uintptr_t*)*retptr, port);
62+
}
Lines changed: 149 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,149 @@
1+
; ModuleID = 'intrinsics.cpp'
2+
target triple = "@CFG_LLVM_TRIPLE@"
3+
4+
%struct.rust_task = type { i32, %struct.stk_seg*, i32, i32, %struct.gc_alloc*, %struct.rust_scheduler*, %class.rust_crate_cache*, %class.rust_kernel*, i8*, %class.rust_task_list*, %struct.rust_cond*, i8*, %struct.rust_task*, i32, i32, i32, %class.timer, i32*, %class.array_list, %class.context, i32, i32, %class.memory_region, %"class.rust_task::wakeup_callback"*, i8, i8, %class.lock_and_signal }
5+
%struct.stk_seg = type { i32, i32, [0 x i8] }
6+
%struct.gc_alloc = type { %struct.gc_alloc*, %struct.gc_alloc*, i32, [0 x i8] }
7+
%struct.rust_scheduler = type { %class.rust_thread, %struct.rc_base, 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, %class.hash_map, %class.hash_map.3, i32, %class.lock_and_signal, i32, %struct._opaque_pthread_attr_t, %struct.rust_env* }
8+
%class.rust_thread = type { i32 (...)**, i8, %struct._opaque_pthread_t* }
9+
%struct._opaque_pthread_t = type { i32, %struct.__darwin_pthread_handler_rec*, [596 x i8] }
10+
%struct.__darwin_pthread_handler_rec = type { {}*, i8*, %struct.__darwin_pthread_handler_rec* }
11+
%struct.rc_base = type { i32 }
12+
%class.rust_log = type { i32 (...)**, %class.rust_srv*, %struct.rust_scheduler*, i8 }
13+
%class.rust_srv = type { i32 (...)**, %struct.rust_env*, %class.memory_region }
14+
%struct.rust_env = type { i32, i32, i8*, i8, i8, i8* }
15+
%class.memory_region = type { i32 (...)**, %class.rust_srv*, %class.memory_region*, i32, %class.array_list.0, i8, i8, %class.lock_and_signal, i8 }
16+
%class.array_list.0 = type { i32, %"struct.memory_region::alloc_header"**, i32 }
17+
%"struct.memory_region::alloc_header" = type { i32, i32, i8*, [0 x i8] }
18+
%class.lock_and_signal = type { i32 (...)**, %struct._opaque_pthread_cond_t, %struct._opaque_pthread_mutex_t, %struct._opaque_pthread_t*, i8, i8 }
19+
%struct._opaque_pthread_cond_t = type { i32, [24 x i8] }
20+
%struct._opaque_pthread_mutex_t = type { i32, [40 x i8] }
21+
%class.rust_task_list = type { %class.indexed_list, %struct.rust_scheduler*, i8* }
22+
%class.indexed_list = type { i32 (...)**, %class.array_list }
23+
%class.array_list = type { i32, %struct.rust_task**, i32 }
24+
%class.rust_crate_cache = type { %struct.type_desc*, %struct.rust_scheduler*, i32 }
25+
%struct.type_desc = type { %struct.type_desc**, i32, i32, {}*, {}*, {}*, {}*, {}*, {}*, i32, {}*, %struct.UT_hash_handle, i32, [0 x %struct.type_desc*] }
26+
%struct.UT_hash_handle = type { %struct.UT_hash_table*, i8*, i8*, %struct.UT_hash_handle*, %struct.UT_hash_handle*, i8*, i32, i32 }
27+
%struct.UT_hash_table = type { %struct.UT_hash_bucket*, i32, i32, i32, %struct.UT_hash_handle*, i32, i32, i32, i32, i32 }
28+
%struct.UT_hash_bucket = type { %struct.UT_hash_handle*, i32, i32 }
29+
%struct.randctx = type { i32, [256 x i32], [256 x i32], i32, i32, i32 }
30+
%class.rust_kernel = type { i32 (...)**, %class.memory_region, %class.rust_log, %class.rust_srv*, %class.lock_and_signal, %class.array_list.4, %struct.randctx, i32, i32, i32, %struct.rust_env* }
31+
%class.array_list.4 = type { i32, %struct.rust_scheduler**, i32 }
32+
%class.hash_map = type { %"struct.hash_map<rust_task *, rust_task *>::map_entry"* }
33+
%"struct.hash_map<rust_task *, rust_task *>::map_entry" = type opaque
34+
%class.hash_map.3 = type { %"struct.hash_map<rust_port *, rust_port *>::map_entry"* }
35+
%"struct.hash_map<rust_port *, rust_port *>::map_entry" = type opaque
36+
%struct._opaque_pthread_attr_t = type { i32, [36 x i8] }
37+
%struct.rust_cond = type { i8 }
38+
%class.timer = type { i32 (...)**, i64, i64 }
39+
%class.context = type { %struct.registers_t, %class.context* }
40+
%struct.registers_t = type { i32, i32, i32, i32, i32, i32, i32, i32, i16, i16, i16, i16, i16, i16, i32, i32 }
41+
%"class.rust_task::wakeup_callback" = type { i32 (...)** }
42+
%struct.rust_vec = type { %struct.rc_base.5, i32, i32, i32, [0 x i8] }
43+
%struct.rc_base.5 = type { i32 }
44+
%struct.rust_ivec = type { i32, i32, %union.rust_ivec_payload }
45+
%union.rust_ivec_payload = type { %struct.rust_ivec_heap* }
46+
%struct.rust_ivec_heap = type { i32, [0 x i8] }
47+
%class.rust_port = type { i32, %class.rust_kernel*, %struct.rust_task*, i32, %class.ptr_vec, %class.ptr_vec.7, %class.rust_chan*, %class.lock_and_signal }
48+
%class.ptr_vec = type { %struct.rust_task*, i32, i32, %struct.rust_token** }
49+
%struct.rust_token = type opaque
50+
%class.ptr_vec.7 = type { %struct.rust_task*, i32, i32, %class.rust_chan** }
51+
%class.rust_chan = type { i32, %class.rust_kernel*, %struct.rust_task*, %class.rust_port*, i32, %class.circular_buffer }
52+
%class.circular_buffer = type { %class.rust_kernel*, i32, i32, i32, i32, i8* }
53+
54+
@.str = private unnamed_addr constant [42 x i8] c"attempt to cast values of differing sizes\00", align 1
55+
@.str1 = private unnamed_addr constant [15 x i8] c"intrinsics.cpp\00", align 1
56+
57+
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 {
58+
entry:
59+
%fill = getelementptr inbounds %struct.rust_vec* %v, i32 0, i32 2
60+
%tmp1 = load i32* %fill, align 4, !tbaa !0
61+
%size = getelementptr inbounds %struct.type_desc* %ty, i32 0, i32 1
62+
%tmp3 = load i32* %size, align 4, !tbaa !0
63+
%div = udiv i32 %tmp1, %tmp3
64+
store i32 %div, i32* %retptr, align 4, !tbaa !0
65+
ret void
66+
}
67+
68+
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 {
69+
entry:
70+
%fill1 = getelementptr inbounds %struct.rust_ivec* %v, i32 0, i32 0
71+
%tmp2 = load i32* %fill1, align 4, !tbaa !0
72+
%tobool = icmp eq i32 %tmp2, 0
73+
br i1 %tobool, label %if.else, label %if.end17
74+
75+
if.else: ; preds = %entry
76+
%ptr = getelementptr inbounds %struct.rust_ivec* %v, i32 0, i32 2, i32 0
77+
%tmp7 = load %struct.rust_ivec_heap** %ptr, align 4, !tbaa !3
78+
%tobool8 = icmp eq %struct.rust_ivec_heap* %tmp7, null
79+
br i1 %tobool8, label %if.end17, label %if.then9
80+
81+
if.then9: ; preds = %if.else
82+
%fill14 = getelementptr inbounds %struct.rust_ivec_heap* %tmp7, i32 0, i32 0
83+
%tmp15 = load i32* %fill14, align 4, !tbaa !0
84+
br label %if.end17
85+
86+
if.end17: ; preds = %if.else, %entry, %if.then9
87+
%fill.0 = phi i32 [ %tmp15, %if.then9 ], [ %tmp2, %entry ], [ 0, %if.else ]
88+
%size = getelementptr inbounds %struct.type_desc* %ty, i32 0, i32 1
89+
%tmp20 = load i32* %size, align 4, !tbaa !0
90+
%div = udiv i32 %fill.0, %tmp20
91+
store i32 %div, i32* %retptr, align 4, !tbaa !0
92+
ret void
93+
}
94+
95+
define linkonce_odr void @rust_intrinsic_ptr_offset(%struct.rust_task* nocapture %task, i8** nocapture %retptr, %struct.type_desc* nocapture %ty, i8* %ptr, i32 %count) nounwind {
96+
entry:
97+
%size = getelementptr inbounds %struct.type_desc* %ty, i32 0, i32 1
98+
%tmp1 = load i32* %size, align 4, !tbaa !0
99+
%mul = mul i32 %tmp1, %count
100+
%arrayidx = getelementptr inbounds i8* %ptr, i32 %mul
101+
store i8* %arrayidx, i8** %retptr, align 4, !tbaa !3
102+
ret void
103+
}
104+
105+
define linkonce_odr void @rust_intrinsic_cast(%struct.rust_task* %task, i8* nocapture %retptr, %struct.type_desc* nocapture %t1, %struct.type_desc* nocapture %t2, i8* nocapture %src) {
106+
entry:
107+
%size = getelementptr inbounds %struct.type_desc* %t1, i32 0, i32 1
108+
%tmp1 = load i32* %size, align 4, !tbaa !0
109+
%size3 = getelementptr inbounds %struct.type_desc* %t2, i32 0, i32 1
110+
%tmp4 = load i32* %size3, align 4, !tbaa !0
111+
%cmp = icmp eq i32 %tmp1, %tmp4
112+
br i1 %cmp, label %if.end, label %if.then
113+
114+
if.then: ; preds = %entry
115+
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)
116+
br label %return
117+
118+
if.end: ; preds = %entry
119+
tail call void @llvm.memmove.p0i8.p0i8.i32(i8* %retptr, i8* %src, i32 %tmp1, i32 1, i1 false)
120+
br label %return
121+
122+
return: ; preds = %if.end, %if.then
123+
ret void
124+
}
125+
126+
declare void @upcall_fail(%struct.rust_task*, i8*, i8*, i32)
127+
128+
declare void @llvm.memmove.p0i8.p0i8.i32(i8* nocapture, i8* nocapture, i32, i32, i1) nounwind
129+
130+
define linkonce_odr void @rust_intrinsic_addr_of(%struct.rust_task* nocapture %task, i8** nocapture %retptr, %struct.type_desc* nocapture %ty, i8* %valptr) nounwind {
131+
entry:
132+
store i8* %valptr, i8** %retptr, align 4, !tbaa !3
133+
ret void
134+
}
135+
136+
define linkonce_odr void @rust_intrinsic_recv(%struct.rust_task* %task, i8** nocapture %retptr, %struct.type_desc* nocapture %ty, %class.rust_port* %port) {
137+
entry:
138+
%tmp2 = load i8** %retptr, align 4, !tbaa !3
139+
%0 = bitcast i8* %tmp2 to i32*
140+
tail call void @port_recv(%struct.rust_task* %task, i32* %0, %class.rust_port* %port)
141+
ret void
142+
}
143+
144+
declare void @port_recv(%struct.rust_task*, i32*, %class.rust_port*)
145+
146+
!0 = metadata !{metadata !"long", metadata !1}
147+
!1 = metadata !{metadata !"omnipotent char", metadata !2}
148+
!2 = metadata !{metadata !"Simple C/C++ TBAA", null}
149+
!3 = metadata !{metadata !"any pointer", metadata !1}

0 commit comments

Comments
 (0)