From 286be2d94e8904765e1ef0f5fcc2899f8501a654 Mon Sep 17 00:00:00 2001 From: Eric Holk Date: Mon, 1 Aug 2011 18:42:29 -0700 Subject: [PATCH] Adding an intrinsic for recv. --- src/rt/intrinsics/intrinsics.cpp | 5 + src/rt/intrinsics/intrinsics.ll.bak | 149 ++++++++++++++++++++++++++++ src/rt/intrinsics/intrinsics.ll.in | 103 +++++++++---------- src/rt/rust_internal.h | 3 + src/rt/rust_upcall.cpp | 2 - 5 files changed, 209 insertions(+), 53 deletions(-) create mode 100644 src/rt/intrinsics/intrinsics.ll.bak diff --git a/src/rt/intrinsics/intrinsics.cpp b/src/rt/intrinsics/intrinsics.cpp index f5179860373d..24f501ad0f57 100644 --- a/src/rt/intrinsics/intrinsics.cpp +++ b/src/rt/intrinsics/intrinsics.cpp @@ -55,3 +55,8 @@ rust_intrinsic_addr_of(rust_task *task, void **retptr, type_desc *ty, *retptr = valptr; } +extern "C" void +rust_intrinsic_recv(rust_task *task, void **retptr, type_desc *ty, + rust_port *port) { + port_recv(task, (uintptr_t*)*retptr, port); +} diff --git a/src/rt/intrinsics/intrinsics.ll.bak b/src/rt/intrinsics/intrinsics.ll.bak new file mode 100644 index 000000000000..8f02e4b3d980 --- /dev/null +++ b/src/rt/intrinsics/intrinsics.ll.bak @@ -0,0 +1,149 @@ +; ModuleID = 'intrinsics.cpp' +target triple = "@CFG_LLVM_TRIPLE@" + +%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 } +%struct.stk_seg = type { i32, i32, [0 x i8] } +%struct.gc_alloc = type { %struct.gc_alloc*, %struct.gc_alloc*, i32, [0 x i8] } +%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* } +%class.rust_thread = type { i32 (...)**, i8, %struct._opaque_pthread_t* } +%struct._opaque_pthread_t = type { i32, %struct.__darwin_pthread_handler_rec*, [596 x i8] } +%struct.__darwin_pthread_handler_rec = type { {}*, i8*, %struct.__darwin_pthread_handler_rec* } +%struct.rc_base = type { i32 } +%class.rust_log = type { i32 (...)**, %class.rust_srv*, %struct.rust_scheduler*, i8 } +%class.rust_srv = type { i32 (...)**, %struct.rust_env*, %class.memory_region } +%struct.rust_env = type { i32, i32, i8*, i8, i8, i8* } +%class.memory_region = type { i32 (...)**, %class.rust_srv*, %class.memory_region*, i32, %class.array_list.0, i8, i8, %class.lock_and_signal, i8 } +%class.array_list.0 = type { i32, %"struct.memory_region::alloc_header"**, i32 } +%"struct.memory_region::alloc_header" = type { i32, i32, i8*, [0 x i8] } +%class.lock_and_signal = type { i32 (...)**, %struct._opaque_pthread_cond_t, %struct._opaque_pthread_mutex_t, %struct._opaque_pthread_t*, i8, i8 } +%struct._opaque_pthread_cond_t = type { i32, [24 x i8] } +%struct._opaque_pthread_mutex_t = type { i32, [40 x i8] } +%class.rust_task_list = type { %class.indexed_list, %struct.rust_scheduler*, i8* } +%class.indexed_list = type { i32 (...)**, %class.array_list } +%class.array_list = type { i32, %struct.rust_task**, i32 } +%class.rust_crate_cache = type { %struct.type_desc*, %struct.rust_scheduler*, i32 } +%struct.type_desc = type { %struct.type_desc**, i32, i32, {}*, {}*, {}*, {}*, {}*, {}*, i32, {}*, %struct.UT_hash_handle, i32, [0 x %struct.type_desc*] } +%struct.UT_hash_handle = type { %struct.UT_hash_table*, i8*, i8*, %struct.UT_hash_handle*, %struct.UT_hash_handle*, i8*, i32, i32 } +%struct.UT_hash_table = type { %struct.UT_hash_bucket*, i32, i32, i32, %struct.UT_hash_handle*, i32, i32, i32, i32, i32 } +%struct.UT_hash_bucket = type { %struct.UT_hash_handle*, i32, i32 } +%struct.randctx = type { i32, [256 x i32], [256 x i32], i32, i32, i32 } +%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* } +%class.array_list.4 = type { i32, %struct.rust_scheduler**, i32 } +%class.hash_map = type { %"struct.hash_map::map_entry"* } +%"struct.hash_map::map_entry" = type opaque +%class.hash_map.3 = type { %"struct.hash_map::map_entry"* } +%"struct.hash_map::map_entry" = type opaque +%struct._opaque_pthread_attr_t = type { i32, [36 x i8] } +%struct.rust_cond = type { i8 } +%class.timer = type { i32 (...)**, i64, i64 } +%class.context = type { %struct.registers_t, %class.context* } +%struct.registers_t = type { i32, i32, i32, i32, i32, i32, i32, i32, i16, i16, i16, i16, i16, i16, i32, i32 } +%"class.rust_task::wakeup_callback" = type { i32 (...)** } +%struct.rust_vec = type { %struct.rc_base.5, i32, i32, i32, [0 x i8] } +%struct.rc_base.5 = type { i32 } +%struct.rust_ivec = type { i32, i32, %union.rust_ivec_payload } +%union.rust_ivec_payload = type { %struct.rust_ivec_heap* } +%struct.rust_ivec_heap = type { i32, [0 x i8] } +%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 } +%class.ptr_vec = type { %struct.rust_task*, i32, i32, %struct.rust_token** } +%struct.rust_token = type opaque +%class.ptr_vec.7 = type { %struct.rust_task*, i32, i32, %class.rust_chan** } +%class.rust_chan = type { i32, %class.rust_kernel*, %struct.rust_task*, %class.rust_port*, i32, %class.circular_buffer } +%class.circular_buffer = type { %class.rust_kernel*, i32, i32, i32, i32, i8* } + +@.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 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 + %size = getelementptr inbounds %struct.type_desc* %ty, i32 0, i32 1 + %tmp3 = load i32* %size, align 4, !tbaa !0 + %div = udiv i32 %tmp1, %tmp3 + store i32 %div, i32* %retptr, align 4, !tbaa !0 + ret void +} + +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 + %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 + store i32 %div, i32* %retptr, align 4, !tbaa !0 + ret void +} + +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 { +entry: + %size = getelementptr inbounds %struct.type_desc* %ty, i32 0, i32 1 + %tmp1 = load i32* %size, align 4, !tbaa !0 + %mul = mul i32 %tmp1, %count + %arrayidx = getelementptr inbounds i8* %ptr, i32 %mul + store i8* %arrayidx, i8** %retptr, align 4, !tbaa !3 + ret void +} + +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) { +entry: + %size = getelementptr inbounds %struct.type_desc* %t1, i32 0, i32 1 + %tmp1 = load i32* %size, align 4, !tbaa !0 + %size3 = getelementptr inbounds %struct.type_desc* %t2, i32 0, i32 1 + %tmp4 = load i32* %size3, align 4, !tbaa !0 + %cmp = icmp eq i32 %tmp1, %tmp4 + 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 45) + br label %return + +if.end: ; preds = %entry + tail call void @llvm.memmove.p0i8.p0i8.i32(i8* %retptr, i8* %src, i32 %tmp1, i32 1, i1 false) + br label %return + +return: ; preds = %if.end, %if.then + ret void +} + +declare void @upcall_fail(%struct.rust_task*, i8*, i8*, i32) + +declare void @llvm.memmove.p0i8.p0i8.i32(i8* nocapture, i8* nocapture, i32, i32, i1) nounwind + +define linkonce_odr void @rust_intrinsic_addr_of(%struct.rust_task* nocapture %task, i8** nocapture %retptr, %struct.type_desc* nocapture %ty, i8* %valptr) nounwind { +entry: + store i8* %valptr, i8** %retptr, align 4, !tbaa !3 + ret void +} + +define linkonce_odr void @rust_intrinsic_recv(%struct.rust_task* %task, i8** nocapture %retptr, %struct.type_desc* nocapture %ty, %class.rust_port* %port) { +entry: + %tmp2 = load i8** %retptr, align 4, !tbaa !3 + %0 = bitcast i8* %tmp2 to i32* + tail call void @port_recv(%struct.rust_task* %task, i32* %0, %class.rust_port* %port) + ret void +} + +declare void @port_recv(%struct.rust_task*, i32*, %class.rust_port*) + +!0 = metadata !{metadata !"long", metadata !1} +!1 = metadata !{metadata !"omnipotent char", metadata !2} +!2 = metadata !{metadata !"Simple C/C++ TBAA", null} +!3 = metadata !{metadata !"any pointer", metadata !1} diff --git a/src/rt/intrinsics/intrinsics.ll.in b/src/rt/intrinsics/intrinsics.ll.in index 801d9e5208fc..8f02e4b3d980 100644 --- a/src/rt/intrinsics/intrinsics.ll.in +++ b/src/rt/intrinsics/intrinsics.ll.in @@ -1,64 +1,55 @@ ; ModuleID = 'intrinsics.cpp' target triple = "@CFG_LLVM_TRIPLE@" -%0 = type { i32, i8**, i32 } -%1 = type { i32, %struct.rust_task**, i32 } -%2 = type { %"struct.hash_map *>::map_entry"* } -%3 = type { %"struct.hash_map *>::map_entry"* } -%4 = type { i32, %class.rust_task_thread**, i32 } -%5 = type { i32 (...)**, %6 } -%6 = type { i32, %class.rust_message_queue**, i32 } -%7 = type opaque -%8 = type opaque -%9 = type { %"struct.hash_map *>::map_entry"* } -%10 = type { %"struct.hash_map *>::map_entry"* } -%class.array_list = type { i32, %struct.maybe_proxy**, i32 } -%class.context = type { %struct.registers_t, %class.context* } -%class.hash_map = type { %"struct.hash_map *>::map_entry"* } -%class.indexed_list = type { i32 (...)**, %1 } -%class.lock_and_signal = type { i32 (...)**, %struct._opaque_pthread_cond_t, %struct._opaque_pthread_mutex_t, %struct._opaque_pthread_t*, i8 } -%class.lock_free_queue = type { i32 (...)**, %"struct.lock_free_queue::pointer_t", %"struct.lock_free_queue::pointer_t" } -%class.memory_region = type { i32 (...)**, %class.rust_srv*, %class.memory_region*, i32, %0, i8, i8, %class.lock_and_signal } -%class.rust_crate_cache = type { %struct.type_desc*, %struct.rust_scheduler*, i32 } -%class.rust_handle = type opaque -%class.rust_kernel = type { %class.rust_thread, %class.memory_region*, %class.rust_log, %class.rust_srv*, %class.hash_map, %2, %3, i8, %class.lock_and_signal, %4, %struct.rust_scheduler*, %class.lock_and_signal, %5 } -%class.rust_log = type { i32 (...)**, %class.rust_srv*, %struct.rust_scheduler*, i8, i8 } -%class.rust_message_queue = type { %class.lock_free_queue, %class.memory_region, %class.rust_kernel*, %8*, i32 } -%class.rust_srv = type { i32 (...)**, %class.memory_region } -%"class.rust_task::wakeup_callback" = type { i32 (...)** } -%class.rust_task_list = type { %class.indexed_list, %struct.rust_scheduler*, i8* } -%class.rust_task_thread = type { %class.rust_thread, i32, %class.rust_kernel* } +%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 } +%struct.stk_seg = type { i32, i32, [0 x i8] } +%struct.gc_alloc = type { %struct.gc_alloc*, %struct.gc_alloc*, i32, [0 x i8] } +%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* } %class.rust_thread = type { i32 (...)**, i8, %struct._opaque_pthread_t* } -%class.timer = type { i32 (...)**, i64, i64 } -%struct.UT_hash_bucket = type { %struct.UT_hash_handle*, i32, i32 } -%struct.UT_hash_handle = type { %struct.UT_hash_table*, i8*, i8*, %struct.UT_hash_handle*, %struct.UT_hash_handle*, i8*, i32, i32 } -%struct.UT_hash_table = type { %struct.UT_hash_bucket*, i32, i32, i32, %struct.UT_hash_handle*, i32, i32, i32, i32, i32 } -%struct.__darwin_pthread_handler_rec = type { void (i8*)*, i8*, %struct.__darwin_pthread_handler_rec* } -%struct._opaque_pthread_attr_t = type { i32, [36 x i8] } +%struct._opaque_pthread_t = type { i32, %struct.__darwin_pthread_handler_rec*, [596 x i8] } +%struct.__darwin_pthread_handler_rec = type { {}*, i8*, %struct.__darwin_pthread_handler_rec* } +%struct.rc_base = type { i32 } +%class.rust_log = type { i32 (...)**, %class.rust_srv*, %struct.rust_scheduler*, i8 } +%class.rust_srv = type { i32 (...)**, %struct.rust_env*, %class.memory_region } +%struct.rust_env = type { i32, i32, i8*, i8, i8, i8* } +%class.memory_region = type { i32 (...)**, %class.rust_srv*, %class.memory_region*, i32, %class.array_list.0, i8, i8, %class.lock_and_signal, i8 } +%class.array_list.0 = type { i32, %"struct.memory_region::alloc_header"**, i32 } +%"struct.memory_region::alloc_header" = type { i32, i32, i8*, [0 x i8] } +%class.lock_and_signal = type { i32 (...)**, %struct._opaque_pthread_cond_t, %struct._opaque_pthread_mutex_t, %struct._opaque_pthread_t*, i8, i8 } %struct._opaque_pthread_cond_t = type { i32, [24 x i8] } %struct._opaque_pthread_mutex_t = type { i32, [40 x i8] } -%struct._opaque_pthread_t = type { i32, %struct.__darwin_pthread_handler_rec*, [596 x i8] } -%struct.gc_alloc = type { %struct.gc_alloc*, %struct.gc_alloc*, i32, [0 x i8] } -%"struct.hash_map *>::map_entry" = type opaque -%"struct.hash_map *>::map_entry" = type opaque -%"struct.hash_map *>::map_entry" = type opaque -%"struct.hash_map *>::map_entry" = type opaque -%"struct.hash_map *>::map_entry" = type opaque -%"struct.lock_free_queue::node_t" = type { %7*, %"struct.lock_free_queue::pointer_t" } -%"struct.lock_free_queue::pointer_t" = type { %"struct.lock_free_queue::node_t"*, i32 } -%struct.maybe_proxy = type { %struct.rc_base, %struct.rust_task* } +%class.rust_task_list = type { %class.indexed_list, %struct.rust_scheduler*, i8* } +%class.indexed_list = type { i32 (...)**, %class.array_list } +%class.array_list = type { i32, %struct.rust_task**, i32 } +%class.rust_crate_cache = type { %struct.type_desc*, %struct.rust_scheduler*, i32 } +%struct.type_desc = type { %struct.type_desc**, i32, i32, {}*, {}*, {}*, {}*, {}*, {}*, i32, {}*, %struct.UT_hash_handle, i32, [0 x %struct.type_desc*] } +%struct.UT_hash_handle = type { %struct.UT_hash_table*, i8*, i8*, %struct.UT_hash_handle*, %struct.UT_hash_handle*, i8*, i32, i32 } +%struct.UT_hash_table = type { %struct.UT_hash_bucket*, i32, i32, i32, %struct.UT_hash_handle*, i32, i32, i32, i32, i32 } +%struct.UT_hash_bucket = type { %struct.UT_hash_handle*, i32, i32 } %struct.randctx = type { i32, [256 x i32], [256 x i32], i32, i32, i32 } -%struct.rc_base = type { i32 } -%struct.registers_t = type { i32, i32, i32, i32, i32, i32, i32, i32, i16, i16, i16, i16, i16, i16, i32, i32 } +%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* } +%class.array_list.4 = type { i32, %struct.rust_scheduler**, i32 } +%class.hash_map = type { %"struct.hash_map::map_entry"* } +%"struct.hash_map::map_entry" = type opaque +%class.hash_map.3 = type { %"struct.hash_map::map_entry"* } +%"struct.hash_map::map_entry" = type opaque +%struct._opaque_pthread_attr_t = type { i32, [36 x i8] } %struct.rust_cond = type { i8 } +%class.timer = type { i32 (...)**, i64, i64 } +%class.context = type { %struct.registers_t, %class.context* } +%struct.registers_t = type { i32, i32, i32, i32, i32, i32, i32, i32, i16, i16, i16, i16, i16, i16, i32, i32 } +%"class.rust_task::wakeup_callback" = type { i32 (...)** } +%struct.rust_vec = type { %struct.rc_base.5, i32, i32, i32, [0 x i8] } +%struct.rc_base.5 = type { i32 } %struct.rust_ivec = type { i32, i32, %union.rust_ivec_payload } -%struct.rust_ivec_heap = type { i32, [0 x i8] } -%struct.rust_scheduler = type { %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, %struct.rust_task*, %struct.rust_task*, i32, %class.rust_kernel*, i32, %9, %10, %class.rust_message_queue*, %struct._opaque_pthread_attr_t } -%struct.rust_task = type { %struct.maybe_proxy, %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.rust_handle*, %class.context, i32, i32, %class.memory_region, %"class.rust_task::wakeup_callback"*, %class.lock_and_signal } -%struct.rust_vec = type { %struct.rc_base, i32, i32, i32, [0 x i8] } -%struct.stk_seg = type { i32, i32, [0 x i8] } -%struct.type_desc = type { %struct.type_desc**, i32, i32, void (i8*, %struct.rust_task*, i8*, %struct.type_desc**, i8*)*, void (i8*, %struct.rust_task*, i8*, %struct.type_desc**, i8*)*, void (i8*, %struct.rust_task*, i8*, %struct.type_desc**, i8*)*, void (i8*, %struct.rust_task*, i8*, %struct.type_desc**, i8*)*, void (i8*, %struct.rust_task*, i8*, %struct.type_desc**, i8*)*, void (i8*, %struct.rust_task*, i8*, %struct.type_desc**, i8*)*, i32, void (i8*, %struct.rust_task*, i8*, %struct.type_desc**, i8*, i8*, i8)*, %struct.UT_hash_handle, i32, [0 x %struct.type_desc*] } %union.rust_ivec_payload = type { %struct.rust_ivec_heap* } +%struct.rust_ivec_heap = type { i32, [0 x i8] } +%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 } +%class.ptr_vec = type { %struct.rust_task*, i32, i32, %struct.rust_token** } +%struct.rust_token = type opaque +%class.ptr_vec.7 = type { %struct.rust_task*, i32, i32, %class.rust_chan** } +%class.rust_chan = type { i32, %class.rust_kernel*, %struct.rust_task*, %class.rust_port*, i32, %class.circular_buffer } +%class.circular_buffer = type { %class.rust_kernel*, i32, i32, i32, i32, i8* } @.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 @@ -142,6 +133,16 @@ entry: ret void } +define linkonce_odr void @rust_intrinsic_recv(%struct.rust_task* %task, i8** nocapture %retptr, %struct.type_desc* nocapture %ty, %class.rust_port* %port) { +entry: + %tmp2 = load i8** %retptr, align 4, !tbaa !3 + %0 = bitcast i8* %tmp2 to i32* + tail call void @port_recv(%struct.rust_task* %task, i32* %0, %class.rust_port* %port) + ret void +} + +declare void @port_recv(%struct.rust_task*, i32*, %class.rust_port*) + !0 = metadata !{metadata !"long", metadata !1} !1 = metadata !{metadata !"omnipotent char", metadata !2} !2 = metadata !{metadata !"Simple C/C++ TBAA", null} diff --git a/src/rt/rust_internal.h b/src/rt/rust_internal.h index 0b983bb88063..48cb575dfa84 100644 --- a/src/rt/rust_internal.h +++ b/src/rt/rust_internal.h @@ -295,6 +295,9 @@ typedef ptr_vec rust_wait_queue; #include "rust_port.h" #include "memory.h" +extern "C" CDECL void +port_recv(rust_task *task, uintptr_t *dptr, rust_port *port); + #include "test/rust_test_harness.h" #include "test/rust_test_util.h" #include "test/rust_test_runtime.h" diff --git a/src/rt/rust_upcall.cpp b/src/rt/rust_upcall.cpp index 4946a516479f..2554868c986e 100644 --- a/src/rt/rust_upcall.cpp +++ b/src/rt/rust_upcall.cpp @@ -193,8 +193,6 @@ upcall_send(rust_task *task, rust_chan *chan, void *sptr) { LOG(task, comm, "=== sent data ===>"); } -extern "C" CDECL void -port_recv(rust_task *task, uintptr_t *dptr, rust_port *port); extern "C" CDECL void upcall_recv(rust_task *task, uintptr_t *dptr, rust_port *port) { LOG_UPCALL_ENTRY(task);