remove wrappers from intrinsics

This commit is contained in:
Niko Matsakis 2011-11-15 20:07:06 -08:00
parent 23bb158acb
commit cbcdeb80d9
4 changed files with 339 additions and 305 deletions

View File

@ -5723,21 +5723,20 @@ fn raw_native_fn_type(ccx: @crate_ctxt, sp: span, args: [ty::arg],
ret T_fn(type_of_explicit_args(ccx, sp, args), type_of(ccx, sp, ret_ty));
}
fn register_native_fn(ccx: @crate_ctxt, sp: span, path: [str], name: str,
id: ast::node_id) {
fn register_native_fn(ccx: @crate_ctxt, sp: span, _path: [str], name: str,
id: ast::node_id) {
let fn_type = node_id_type(ccx, id); // NB: has no type params
let abi = ty::ty_fn_abi(ccx.tcx, fn_type);
// FIXME: There's probably a lot of unused code here now that
// there's only one possible combination of these three options
let pass_task;
let uses_retptr;
let cast_to_i32;
alt abi {
ast::native_abi_rust_intrinsic. {
pass_task = true;
uses_retptr = true;
cast_to_i32 = false;
let num_ty_param = native_fn_ty_param_count(ccx, id);
let fn_type = native_fn_wrapper_type(ccx, sp, num_ty_param, fn_type);
let ri_name = "rust_intrinsic_2_" + name;
let llnativefn = get_extern_fn(ccx.externs, ccx.llmod, ri_name,
lib::llvm::LLVMCCallConv, fn_type);
ccx.item_ids.insert(id, llnativefn);
ccx.item_symbols.insert(id, ri_name);
}
ast::native_abi_cdecl. | ast::native_abi_stdcall. {
@ -5747,140 +5746,9 @@ fn register_native_fn(ccx: @crate_ctxt, sp: span, path: [str], name: str,
ccx.llmod, shim_name, tys.shim_fn_ty);
ccx.item_ids.insert(id, llshimfn);
ccx.item_symbols.insert(id, shim_name);
ret;
}
}
let path = path;
let num_ty_param = native_fn_ty_param_count(ccx, id);
// Declare the wrapper.
let t = node_id_type(ccx, id);
let wrapper_type = native_fn_wrapper_type(ccx, sp, num_ty_param, t);
let ps: str = mangle_exported_name(ccx, path, node_id_type(ccx, id));
let wrapper_fn = decl_cdecl_fn(ccx.llmod, ps, wrapper_type);
ccx.item_ids.insert(id, wrapper_fn);
ccx.item_symbols.insert(id, ps);
// Build the wrapper.
let fcx = new_fn_ctxt(new_local_ctxt(ccx), sp, wrapper_fn);
let bcx = new_top_block_ctxt(fcx);
let lltop = bcx.llbb;
// Declare the function itself.
// FIXME: If the returned type is not nil, then we assume it's 32 bits
// wide. This is obviously wildly unsafe. We should have a better FFI
// that allows types of different sizes to be returned.
let rty = ty::ty_fn_ret(ccx.tcx, fn_type);
let rty_is_nil = ty::type_is_nil(ccx.tcx, rty);
let call_args: [ValueRef] = [];
if pass_task { call_args += [C_null(T_ptr(ccx.task_type))]; }
if uses_retptr { call_args += [bcx.fcx.llretptr]; }
let arg_n = 2u;
uint::range(0u, num_ty_param) {|_i|
let llarg = llvm::LLVMGetParam(fcx.llfn, arg_n);
fcx.lltydescs += [llarg];
assert (llarg as int != 0);
if cast_to_i32 {
call_args += [vp2i(bcx, llarg)];
} else { call_args += [llarg]; }
arg_n += 1u;
};
fn convert_arg_to_i32(cx: @block_ctxt, v: ValueRef, t: ty::t,
mode: ty::mode) -> ValueRef {
if mode == ast::by_ref || mode == ast::by_val {
let ccx = bcx_ccx(cx);
if ty::type_is_integral(bcx_tcx(cx), t) {
// FIXME: would be nice to have a postcondition that says
// if a type is integral, then it has static size (#586)
let lldsttype = ccx.int_type;
let sp = cx.sp;
check (type_has_static_size(ccx, t));
let llsrctype = type_of(ccx, sp, t);
if llvm::LLVMGetIntTypeWidth(lldsttype) >
llvm::LLVMGetIntTypeWidth(llsrctype) {
ret ZExtOrBitCast(cx, v, ccx.int_type);
}
ret TruncOrBitCast(cx, v, ccx.int_type);
}
if ty::type_is_fp(bcx_tcx(cx), t) {
ret FPToSI(cx, v, ccx.int_type);
}
}
ret vp2i(cx, v);
}
fn trans_simple_native_abi(bcx: @block_ctxt, name: str,
&call_args: [ValueRef], fn_type: ty::t,
uses_retptr: bool, cc: uint) ->
{val: ValueRef, rptr: ValueRef} {
let call_arg_tys: [TypeRef] = [];
for arg: ValueRef in call_args { call_arg_tys += [val_ty(arg)]; }
let ccx = bcx_ccx(bcx);
let llnativefnty =
if uses_retptr {
T_fn(call_arg_tys, T_void())
} else {
let fn_ret_ty = ty::ty_fn_ret(bcx_tcx(bcx), fn_type);
// FIXME: Could follow from a constraint on fn_type...
check (type_has_static_size(ccx, fn_ret_ty));
let sp = bcx.sp;
T_fn(call_arg_tys, type_of(ccx, sp, fn_ret_ty))
};
let llnativefn =
get_extern_fn(ccx.externs, ccx.llmod, name, cc, llnativefnty);
let r =
if cc == lib::llvm::LLVMCCallConv {
Call(bcx, llnativefn, call_args)
} else { CallWithConv(bcx, llnativefn, call_args, cc) };
let rptr = bcx.fcx.llretptr;
ret {val: r, rptr: rptr};
}
let args = ty::ty_fn_args(ccx.tcx, fn_type);
// Build up the list of arguments.
let i = arg_n;
for arg: ty::arg in args {
let llarg = llvm::LLVMGetParam(fcx.llfn, i);
assert (llarg as int != 0);
if cast_to_i32 {
let llarg_i32 = convert_arg_to_i32(bcx, llarg, arg.ty, arg.mode);
call_args += [llarg_i32];
} else { call_args += [llarg]; }
i += 1u;
}
let r;
let rptr;
alt abi {
ast::native_abi_rust_intrinsic. {
let external_name = "rust_intrinsic_" + name;
let result =
trans_simple_native_abi(bcx, external_name, call_args, fn_type,
uses_retptr, lib::llvm::LLVMCCallConv);
r = result.val;
rptr = result.rptr;
}
_ {
r =
trans_native_call(new_raw_block_ctxt(bcx.fcx, bcx.llbb),
ccx.externs, ccx.llmod, name, call_args);
rptr = BitCast(bcx, fcx.llretptr, T_ptr(ccx.int_type));
}
}
// We don't store the return value if it's nil, to avoid stomping on a nil
// pointer. This is the only concession made to non-i32 return values. See
// the FIXME above.
if !rty_is_nil && !uses_retptr { Store(bcx, r, rptr); }
build_return(bcx);
finish_fn(fcx, lltop);
}
fn item_path(item: @ast::item) -> [str] { ret [item.ident]; }

View File

@ -16,22 +16,30 @@ extern "C" CDECL void
rust_task_sleep(size_t time_in_us);
extern "C" void
rust_intrinsic_vec_len(rust_task *task, size_t *retptr, type_desc *ty,
rust_vec **vp)
rust_intrinsic_2_vec_len(size_t *retptr,
void *env,
type_desc *ty,
rust_vec **vp)
{
*retptr = (*vp)->fill / ty->size;
}
extern "C" void
rust_intrinsic_ptr_offset(rust_task *task, void **retptr, type_desc *ty,
void *ptr, uintptr_t count)
rust_intrinsic_2_ptr_offset(void **retptr,
void *env,
type_desc *ty,
void *ptr,
uintptr_t count)
{
*retptr = &((uint8_t *)ptr)[ty->size * count];
}
extern "C" void
rust_intrinsic_cast(rust_task *task, void *retptr, type_desc *t1,
type_desc *t2, void *src)
rust_intrinsic_2_cast(void *retptr,
void *env,
type_desc *t1,
type_desc *t2,
void *src)
{
if (t1->size != t2->size) {
upcall_fail("attempt to cast values of differing sizes",
@ -43,25 +51,91 @@ rust_intrinsic_cast(rust_task *task, void *retptr, type_desc *t1,
}
extern "C" void
rust_intrinsic_addr_of(rust_task *task, void **retptr, type_desc *ty,
rust_intrinsic_2_addr_of(void **retptr,
void *env,
type_desc *ty,
void *valptr) {
*retptr = valptr;
}
extern "C" void
rust_intrinsic_recv(rust_task *task, void **retptr, type_desc *ty,
rust_intrinsic_2_recv(void **retptr,
void *env,
type_desc *ty,
rust_port *port) {
port_recv((uintptr_t*)retptr, port);
}
extern "C" void
rust_intrinsic_get_type_desc(rust_task *task, void **retptr,
rust_intrinsic_2_get_type_desc(void **retptr,
void *env,
type_desc* ty) {
*(type_desc**)retptr = ty;
}
extern "C" void
rust_intrinsic_task_sleep(rust_task *_task, void **retptr,
size_t time_in_us) {
rust_task_sleep(time_in_us);
rust_intrinsic_2_task_sleep(void **retptr,
void *env,
size_t time_in_us) {
rust_task_sleep(time_in_us);
}
extern "C" void
rust_intrinsic_vec_len(void *task,
size_t *retptr,
type_desc *ty,
rust_vec **vp)
{
rust_intrinsic_2_vec_len(retptr, NULL, ty, vp);
}
extern "C" void
rust_intrinsic_ptr_offset(void *task,
void **retptr,
type_desc *ty,
void *ptr,
uintptr_t count)
{
rust_intrinsic_2_ptr_offset(retptr, NULL, ty, ptr, count);
}
extern "C" void
rust_intrinsic_cast(void *task,
void *retptr,
type_desc *t1,
type_desc *t2,
void *src)
{
rust_intrinsic_2_cast(retptr, NULL, t1, t2, src);
}
extern "C" void
rust_intrinsic_addr_of(void *task,
void **retptr,
type_desc *ty,
void *valptr) {
rust_intrinsic_2_addr_of(retptr, NULL, ty, valptr);
}
extern "C" void
rust_intrinsic_recv(void *task,
void **retptr,
type_desc *ty,
rust_port *port) {
rust_intrinsic_2_recv(retptr, NULL, ty, port);
}
extern "C" void
rust_intrinsic_get_type_desc(void *task,
void **retptr,
type_desc* ty) {
rust_intrinsic_2_get_type_desc(retptr, NULL, ty);
}
extern "C" void
rust_intrinsic_task_sleep(void *task,
void **retptr,
size_t time_in_us) {
rust_task_sleep(time_in_us);
}

View File

@ -1,99 +1,88 @@
; ModuleID = 'src/rt/intrinsics/intrinsics.cpp'
; 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"
; 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"
target triple = "@CFG_TARGET_TRIPLE@"
%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" }
%struct.rust_task_user = type { i32, i32, %struct.chan_handle, i32 }
%struct.chan_handle = type { i32, i32 }
%0 = type { i32, %"struct.memory_region::alloc_header"**, i32 }
%1 = type { i32, %struct.rust_scheduler**, i32 }
%2 = type { %"struct.hash_map<long, rust_task *>::map_entry"* }
%class.array_list = type { i32, %struct.rust_task**, i32 }
%class.circular_buffer = type { %class.rust_kernel*, i32, i32, i32, i32, i8* }
%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 }
%struct.stk_seg = type { %struct.stk_seg*, i32, i32, i32, [0 x i8] }
%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 }
%class.rust_thread = type { i32 (...)**, i8, 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, i8, i8, %class.lock_and_signal }
%class.array_list = type { i32, %"struct.memory_region::alloc_header"**, i32 }
%"struct.memory_region::alloc_header" = type { i32, i32, i8*, i32, [0 x i8] }
%class.lock_and_signal = type { i32 (...)**, %union.pthread_cond_t, %union.pthread_mutex_t, i32, i8, i8 }
%union.pthread_cond_t = type { %struct.anon, [4 x i8] }
%struct.anon = type { i32, i32, i64, i64, i64, i8*, i32, i32 }
%union.pthread_mutex_t = type { %"struct.<anonymous union>::__pthread_mutex_s" }
%"struct.<anonymous union>::__pthread_mutex_s" = type { i32, i32, i32, i32, i32, %union.anon }
%union.anon = type { i32 }
%class.rust_task_list = type { %class.indexed_list, %struct.rust_scheduler*, i8* }
%class.indexed_list = type { i32 (...)**, %class.array_list.1 }
%class.array_list.1 = type { i32, %struct.rust_task**, i32 }
%"class.debug::task_debug_info" = type { %"class.std::map" }
%class.hash_map = type { %"struct.hash_map<long, rust_port *>::map_entry"* }
%class.indexed_list = type { i32 (...)**, %class.array_list }
%class.lock_and_signal = type { i32 (...)**, %struct._opaque_pthread_cond_t, %struct._opaque_pthread_mutex_t, %struct._opaque_pthread_t*, i8, i8 }
%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 }
%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*] }
%struct.rust_shape_tables = type { i8*, i8* }
%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* }
%class.rust_log = type { i32 (...)**, %class.rust_srv*, %struct.rust_scheduler*, i8 }
%class.rust_obstack = type { %struct.rust_obstack_chunk*, %struct.rust_task* }
%class.rust_port = type { i32, i32, %class.rust_kernel*, %struct.rust_task*, i32, %class.circular_buffer, %class.lock_and_signal }
%class.rust_srv = type { i32 (...)**, %struct.rust_env*, %class.memory_region }
%"class.rust_task::wakeup_callback" = type { i32 (...)** }
%class.rust_task_list = type { %class.indexed_list, %struct.rust_scheduler*, i8* }
%class.rust_thread = type { i32 (...)**, i8, %struct._opaque_pthread_t* }
%"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" }
%"class.std::map" = type { %"class.std::_Rb_tree" }
%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.UT_hash_bucket = type { %struct.UT_hash_handle*, 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_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.chan_handle = type { i32, i32 }
%"struct.hash_map<long, rust_port *>::map_entry" = type opaque
%"struct.hash_map<long, rust_task *>::map_entry" = type opaque
%"struct.memory_region::alloc_header" = type { i8 }
%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.3, %struct.randctx, i32, %class.hash_map, i32, i32, i32, %struct.rust_env* }
%class.array_list.3 = type { i32, %struct.rust_scheduler**, i32 }
%class.hash_map = type { %"struct.hash_map<int, rust_task *>::map_entry"* }
%"struct.hash_map<int, rust_task *>::map_entry" = type opaque
%union.pthread_attr_t = type { i32, [32 x i8] }
%struct.rust_cond = type { i8 }
%class.timer = type { i32 (...)**, i64, i64 }
%"class.rust_task::wakeup_callback" = type { i32 (...)** }
%class.hash_map.4 = type { %"struct.hash_map<int, rust_port *>::map_entry"* }
%"struct.hash_map<int, rust_port *>::map_entry" = type opaque
%class.rust_obstack = type { %struct.rust_obstack_chunk*, %struct.rust_task* }
%struct.registers_t = type { i32, i32, i32, i32, i32, i32, i32, i32, i16, i16, i16, i16, i16, i16, i32, i32 }
%struct.rust_env = type { i32, i32, i8*, i8, i8, i8* }
%struct.rust_obstack_chunk = type { %struct.rust_obstack_chunk*, i32, i32, i32, [0 x i8] }
%"class.std::map" = type { %"class.std::_Rb_tree" }
%"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" }
%"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 }
%"struct.std::less" = type { i8 }
%"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"* }
%"class.debug::task_debug_info" = type { %"class.std::map.5" }
%"class.std::map.5" = type { %"class.std::_Rb_tree.6" }
%"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" }
%"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 }
%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 }
%struct.rust_shape_tables = type { i8*, i8* }
%struct.rust_task = type { %struct.rust_task_user, i32, %class.context, %struct.rust_obstack_chunk*, i32, %struct.rust_scheduler*, %class.rust_crate_cache*, %class.rust_kernel*, i8*, %class.rust_task_list*, %"struct.memory_region::alloc_header"*, 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" }
%struct.rust_task_user = type { i32, i32, %struct.chan_handle, i32 }
%struct.rust_vec = type { i32, i32, [0 x i8] }
%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 }
%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* }
%class.ptr_vec = type { %struct.rust_task*, i32, i32, %struct.rust_token** }
%struct.rust_token = type opaque
%class.ptr_vec.13 = type { %struct.rust_task*, i32, i32, %class.rust_chan** }
%"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.memory_region::alloc_header", %"struct.std::_Rb_tree_node_base", i32 }
%"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"* }
%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*] }
@.str = private unnamed_addr constant [42 x i8] c"attempt to cast values of differing sizes\00", align 1
@.str1 = private unnamed_addr constant [33 x i8] c"src/rt/intrinsics/intrinsics.cpp\00", align 1
@.str = private unnamed_addr constant [42 x i8] c"attempt to cast values of differing sizes\00"
@.str1 = private unnamed_addr constant [33 x i8] c"src/rt/intrinsics/intrinsics.cpp\00"
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 {
%1 = load %struct.rust_vec** %vp, align 4, !tbaa !0
define void @rust_intrinsic_2_vec_len(i32* nocapture %retptr, i8* nocapture %env, %struct.type_desc* nocapture %ty, %struct.rust_vec** nocapture %vp) nounwind {
%1 = load %struct.rust_vec** %vp, align 4
%2 = getelementptr inbounds %struct.rust_vec* %1, i32 0, i32 0
%3 = load i32* %2, align 4, !tbaa !3
%3 = load i32* %2, align 4
%4 = getelementptr inbounds %struct.type_desc* %ty, i32 0, i32 1
%5 = load i32* %4, align 4, !tbaa !3
%5 = load i32* %4, align 4
%6 = udiv i32 %3, %5
store i32 %6, i32* %retptr, align 4, !tbaa !3
store i32 %6, i32* %retptr, align 4
ret void
}
define void @rust_intrinsic_ptr_offset(%struct.rust_task* nocapture %task, i8** nocapture %retptr, %struct.type_desc* nocapture %ty, i8* %ptr, i32 %count) nounwind {
define void @rust_intrinsic_2_ptr_offset(i8** nocapture %retptr, i8* nocapture %env, %struct.type_desc* nocapture %ty, i8* %ptr, i32 %count) nounwind {
%1 = getelementptr inbounds %struct.type_desc* %ty, i32 0, i32 1
%2 = load i32* %1, align 4, !tbaa !3
%2 = load i32* %1, align 4
%3 = mul i32 %2, %count
%4 = getelementptr inbounds i8* %ptr, i32 %3
store i8* %4, i8** %retptr, align 4, !tbaa !0
store i8* %4, i8** %retptr, align 4
ret void
}
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) {
define void @rust_intrinsic_2_cast(i8* nocapture %retptr, i8* nocapture %env, %struct.type_desc* nocapture %t1, %struct.type_desc* nocapture %t2, i8* nocapture %src) {
%1 = getelementptr inbounds %struct.type_desc* %t1, i32 0, i32 1
%2 = load i32* %1, align 4, !tbaa !3
%2 = load i32* %1, align 4
%3 = getelementptr inbounds %struct.type_desc* %t2, i32 0, i32 1
%4 = load i32* %3, align 4, !tbaa !3
%4 = load i32* %3, align 4
%5 = icmp eq i32 %2, %4
br i1 %5, label %7, label %6
; <label>:6 ; preds = %0
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)
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 46)
br label %8
; <label>:7 ; preds = %0
@ -108,12 +97,12 @@ declare void @upcall_fail(i8*, i8*, i32)
declare void @llvm.memmove.p0i8.p0i8.i32(i8* nocapture, i8* nocapture, i32, i32, i1) nounwind
define void @rust_intrinsic_addr_of(%struct.rust_task* nocapture %task, i8** nocapture %retptr, %struct.type_desc* nocapture %ty, i8* %valptr) nounwind {
store i8* %valptr, i8** %retptr, align 4, !tbaa !0
define void @rust_intrinsic_2_addr_of(i8** nocapture %retptr, i8* nocapture %env, %struct.type_desc* nocapture %ty, i8* %valptr) nounwind {
store i8* %valptr, i8** %retptr, align 4
ret void
}
define void @rust_intrinsic_recv(%struct.rust_task* nocapture %task, i8** %retptr, %struct.type_desc* nocapture %ty, %class.rust_port* %port) {
define void @rust_intrinsic_2_recv(i8** %retptr, i8* nocapture %env, %struct.type_desc* nocapture %ty, %class.rust_port* %port) {
%1 = bitcast i8** %retptr to i32*
tail call void @port_recv(i32* %1, %class.rust_port* %port)
ret void
@ -121,20 +110,77 @@ define void @rust_intrinsic_recv(%struct.rust_task* nocapture %task, i8** %retpt
declare void @port_recv(i32*, %class.rust_port*)
define void @rust_intrinsic_get_type_desc(%struct.rust_task* nocapture %task, i8** nocapture %retptr, %struct.type_desc* %ty) nounwind {
define void @rust_intrinsic_2_get_type_desc(i8** nocapture %retptr, i8* nocapture %env, %struct.type_desc* %ty) nounwind {
%ty.c = bitcast %struct.type_desc* %ty to i8*
store i8* %ty.c, i8** %retptr, align 4, !tbaa !0
store i8* %ty.c, i8** %retptr, align 4
ret void
}
define void @rust_intrinsic_task_sleep(%struct.rust_task* nocapture %_task, i8** nocapture %retptr, i32 %time_in_us) {
define void @rust_intrinsic_2_task_sleep(i8** nocapture %retptr, i8* nocapture %env, i32 %time_in_us) {
tail call void @rust_task_sleep(i32 %time_in_us)
ret void
}
declare void @rust_task_sleep(i32)
!0 = metadata !{metadata !"any pointer", metadata !1}
!1 = metadata !{metadata !"omnipotent char", metadata !2}
!2 = metadata !{metadata !"Simple C/C++ TBAA", null}
!3 = metadata !{metadata !"int", metadata !1}
define void @rust_intrinsic_vec_len(i8* nocapture %task, i32* nocapture %retptr, %struct.type_desc* nocapture %ty, %struct.rust_vec** nocapture %vp) nounwind {
%1 = load %struct.rust_vec** %vp, align 4
%2 = getelementptr inbounds %struct.rust_vec* %1, i32 0, i32 0
%3 = load i32* %2, align 4
%4 = getelementptr inbounds %struct.type_desc* %ty, i32 0, i32 1
%5 = load i32* %4, align 4
%6 = udiv i32 %3, %5
store i32 %6, i32* %retptr, align 4
ret void
}
define void @rust_intrinsic_ptr_offset(i8* nocapture %task, i8** nocapture %retptr, %struct.type_desc* nocapture %ty, i8* %ptr, i32 %count) nounwind {
%1 = getelementptr inbounds %struct.type_desc* %ty, i32 0, i32 1
%2 = load i32* %1, align 4
%3 = mul i32 %2, %count
%4 = getelementptr inbounds i8* %ptr, i32 %3
store i8* %4, i8** %retptr, align 4
ret void
}
define void @rust_intrinsic_cast(i8* nocapture %task, i8* nocapture %retptr, %struct.type_desc* nocapture %t1, %struct.type_desc* nocapture %t2, i8* nocapture %src) {
%1 = getelementptr inbounds %struct.type_desc* %t1, i32 0, i32 1
%2 = load i32* %1, align 4
%3 = getelementptr inbounds %struct.type_desc* %t2, i32 0, i32 1
%4 = load i32* %3, align 4
%5 = icmp eq i32 %2, %4
br i1 %5, label %7, label %6
; <label>:6 ; preds = %0
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 46)
br label %rust_intrinsic_2_cast.exit
; <label>:7 ; preds = %0
tail call void @llvm.memmove.p0i8.p0i8.i32(i8* %retptr, i8* %src, i32 %2, i32 1, i1 false)
br label %rust_intrinsic_2_cast.exit
rust_intrinsic_2_cast.exit: ; preds = %6, %7
ret void
}
define void @rust_intrinsic_addr_of(i8* nocapture %task, i8** nocapture %retptr, %struct.type_desc* nocapture %ty, i8* %valptr) nounwind {
store i8* %valptr, i8** %retptr, align 4
ret void
}
define void @rust_intrinsic_recv(i8* nocapture %task, i8** %retptr, %struct.type_desc* nocapture %ty, %class.rust_port* %port) {
%1 = bitcast i8** %retptr to i32*
tail call void @port_recv(i32* %1, %class.rust_port* %port)
ret void
}
define void @rust_intrinsic_get_type_desc(i8* nocapture %task, i8** nocapture %retptr, %struct.type_desc* %ty) nounwind {
%ty.c.i = bitcast %struct.type_desc* %ty to i8*
store i8* %ty.c.i, i8** %retptr, align 4
ret void
}
define void @rust_intrinsic_task_sleep(i8* nocapture %task, i8** nocapture %retptr, i32 %time_in_us) {
tail call void @rust_task_sleep(i32 %time_in_us)
ret void
}

View File

@ -1,99 +1,88 @@
; ModuleID = 'src/rt/intrinsics/intrinsics.cpp'
; target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128"
; target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64"
target triple = "@CFG_TARGET_TRIPLE@"
%struct.rust_task = type { %struct.rust_task_user, i64, %class.context, %struct.stk_seg*, i64, %struct.rust_scheduler*, %class.rust_crate_cache*, %class.rust_kernel*, i8*, %class.rust_task_list*, %struct.rust_cond*, i8*, %struct.rust_task*, i32, i64, %class.timer, i64*, %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" }
%struct.rust_task_user = type { i64, i32, %struct.chan_handle, i64 }
%struct.chan_handle = type { i64, i64 }
%0 = type { i64, %"struct.memory_region::alloc_header"**, i64 }
%1 = type { i64, %struct.rust_scheduler**, i64 }
%2 = type { %"struct.hash_map<long, rust_task *>::map_entry"* }
%class.array_list = type { i64, %struct.rust_task**, i64 }
%class.circular_buffer = type { %class.rust_kernel*, i64, i64, i64, i64, i8* }
%class.context = type { %struct.registers_t, %class.context* }
%struct.registers_t = type { [7 x i64], [6 x i64], i64 }
%struct.stk_seg = type { %struct.stk_seg*, i64, i32, [0 x i8] }
%struct.rust_scheduler = type { %class.rust_thread, i64, i64, %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, i64, %union.pthread_attr_t, %struct.rust_env*, %class.context }
%class.rust_thread = type { i32 (...)**, i8, i64 }
%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 { i64, i64, i8*, i8, i8, i8* }
%class.memory_region = type { i32 (...)**, %class.rust_srv*, %class.memory_region*, i32, %class.array_list, i8, i8, %class.lock_and_signal }
%class.array_list = type { i64, %"struct.memory_region::alloc_header"**, i64 }
%"struct.memory_region::alloc_header" = type { i32, i32, i8*, i32, [0 x i8] }
%class.lock_and_signal = type { i32 (...)**, %union.pthread_cond_t, %union.pthread_mutex_t, i64, i8, i8 }
%union.pthread_cond_t = type { %struct.anon }
%struct.anon = type { i32, i32, i64, i64, i64, i8*, i32, i32 }
%union.pthread_mutex_t = type { %"struct.<anonymous union>::__pthread_mutex_s" }
%"struct.<anonymous union>::__pthread_mutex_s" = type { i32, i32, i32, i32, i32, i32, %struct.__pthread_internal_list }
%struct.__pthread_internal_list = type { %struct.__pthread_internal_list*, %struct.__pthread_internal_list* }
%class.rust_task_list = type { %class.indexed_list, %struct.rust_scheduler*, i8* }
%class.indexed_list = type { i32 (...)**, %class.array_list.1 }
%class.array_list.1 = type { i64, %struct.rust_task**, i64 }
%"class.debug::task_debug_info" = type { %"class.std::map" }
%class.hash_map = type { %"struct.hash_map<long, rust_port *>::map_entry"* }
%class.indexed_list = type { i32 (...)**, %class.array_list }
%class.lock_and_signal = type { i32 (...)**, %struct._opaque_pthread_cond_t, %struct._opaque_pthread_attr_t, %struct._opaque_pthread_t*, i8, i8 }
%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*, i64 }
%struct.type_desc = type { %struct.type_desc**, i64, i64, 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*)*, i64, void (i8*, i8*, %struct.type_desc**, i8*, i8*, i8)*, i8*, %struct.rust_shape_tables*, i64, i64, %struct.UT_hash_handle, i64, [0 x %struct.type_desc*] }
%struct.rust_shape_tables = type { i8*, i8* }
%class.rust_kernel = type { i32 (...)**, %class.memory_region, %class.rust_log, %class.rust_srv*, %class.lock_and_signal, %1, %struct.randctx, i64, %2, i64, i32, i32, %struct.rust_env* }
%class.rust_log = type { i32 (...)**, %class.rust_srv*, %struct.rust_scheduler*, i8 }
%class.rust_obstack = type { %struct.rust_obstack_chunk*, %struct.rust_task* }
%class.rust_port = type { i64, i64, %class.rust_kernel*, %struct.rust_task*, i64, %class.circular_buffer, %class.lock_and_signal }
%class.rust_srv = type { i32 (...)**, %struct.rust_env*, %class.memory_region }
%"class.rust_task::wakeup_callback" = type { i32 (...)** }
%class.rust_task_list = type { %class.indexed_list, %struct.rust_scheduler*, i8* }
%class.rust_thread = type { i32 (...)**, i8, %struct._opaque_pthread_t* }
%"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" }
%"class.std::map" = type { %"class.std::_Rb_tree" }
%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*, i64, i32, i32, i32, i32 }
%struct.UT_hash_bucket = type { %struct.UT_hash_handle*, i32, i32 }
%struct.randctx = type { i64, [256 x i64], [256 x i64], i64, i64, i64 }
%class.rust_kernel = type { i32 (...)**, %class.memory_region, %class.rust_log, %class.rust_srv*, %class.lock_and_signal, %class.array_list.3, %struct.randctx, i64, %class.hash_map, i64, i32, i32, %struct.rust_env* }
%class.array_list.3 = type { i64, %struct.rust_scheduler**, i64 }
%class.hash_map = type { %"struct.hash_map<long, rust_task *>::map_entry"* }
%"struct.hash_map<long, rust_task *>::map_entry" = type opaque
%union.pthread_attr_t = type { i64, [48 x i8] }
%struct.rust_cond = type { i8 }
%class.timer = type { i32 (...)**, i64, i64 }
%"class.rust_task::wakeup_callback" = type { i32 (...)** }
%class.hash_map.4 = type { %"struct.hash_map<long, rust_port *>::map_entry"* }
%struct.__darwin_pthread_handler_rec = type { void (i8*)*, i8*, %struct.__darwin_pthread_handler_rec* }
%struct._opaque_pthread_attr_t = type { i64, [56 x i8] }
%struct._opaque_pthread_cond_t = type { i64, [40 x i8] }
%struct._opaque_pthread_t = type { i64, %struct.__darwin_pthread_handler_rec*, [1168 x i8] }
%struct.chan_handle = type { i64, i64 }
%"struct.hash_map<long, rust_port *>::map_entry" = type opaque
%class.rust_obstack = type { %struct.rust_obstack_chunk*, %struct.rust_task* }
%"struct.hash_map<long, rust_task *>::map_entry" = type opaque
%"struct.memory_region::alloc_header" = type { i8 }
%struct.randctx = type { i64, [256 x i64], [256 x i64], i64, i64, i64 }
%struct.registers_t = type { [22 x i64] }
%struct.rust_env = type { i64, i64, i8*, i8, i8, i8* }
%struct.rust_obstack_chunk = type { %struct.rust_obstack_chunk*, i64, i64, i64, [0 x i8] }
%"class.std::map" = type { %"class.std::_Rb_tree" }
%"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" }
%"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", i64 }
%"struct.std::less" = type { i8 }
%"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"* }
%"class.debug::task_debug_info" = type { %"class.std::map.5" }
%"class.std::map.5" = type { %"class.std::_Rb_tree.6" }
%"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" }
%"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", i64 }
%struct.rust_scheduler = type { %class.rust_thread, i64, i64, %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, i64, %struct._opaque_pthread_attr_t, %struct.rust_env*, %class.context }
%struct.rust_shape_tables = type { i8*, i8* }
%struct.rust_task = type { %struct.rust_task_user, i64, %class.context, %struct.stk_seg*, i64, %struct.rust_scheduler*, %class.rust_crate_cache*, %class.rust_kernel*, i8*, %class.rust_task_list*, %"struct.memory_region::alloc_header"*, i8*, %struct.rust_task*, i32, i64, %class.timer, i64*, %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" }
%struct.rust_task_user = type { i64, i64, %struct.chan_handle, i64 }
%struct.rust_vec = type { i64, i64, [0 x i8] }
%class.rust_port = type { i64, i64, %class.rust_kernel*, %struct.rust_task*, %class.rust_chan*, i64, %class.ptr_vec, %class.ptr_vec.13, %class.lock_and_signal }
%class.rust_chan = type { i64, %class.rust_kernel*, %struct.rust_task*, %class.rust_port*, i64, %class.circular_buffer }
%class.circular_buffer = type { %class.rust_kernel*, i64, i64, i64, i64, i8* }
%class.ptr_vec = type { %struct.rust_task*, i64, i64, %struct.rust_token** }
%struct.rust_token = type opaque
%class.ptr_vec.13 = type { %struct.rust_task*, i64, i64, %class.rust_chan** }
%"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.memory_region::alloc_header", %"struct.std::_Rb_tree_node_base", i64 }
%"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"* }
%struct.stk_seg = type { %struct.stk_seg*, i64, i32, [0 x i8] }
%struct.type_desc = type { %struct.type_desc**, i64, i64, 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*)*, i64, void (i8*, i8*, %struct.type_desc**, i8*, i8*, i8)*, i8*, %struct.rust_shape_tables*, i64, i64, %struct.UT_hash_handle, i64, [0 x %struct.type_desc*] }
@.str = private unnamed_addr constant [42 x i8] c"attempt to cast values of differing sizes\00", align 1
@.str1 = private unnamed_addr constant [33 x i8] c"src/rt/intrinsics/intrinsics.cpp\00", align 1
@.str = private unnamed_addr constant [42 x i8] c"attempt to cast values of differing sizes\00"
@.str1 = private unnamed_addr constant [33 x i8] c"src/rt/intrinsics/intrinsics.cpp\00"
define void @rust_intrinsic_vec_len(%struct.rust_task* nocapture %task, i64* nocapture %retptr, %struct.type_desc* nocapture %ty, %struct.rust_vec** nocapture %vp) nounwind uwtable {
%1 = load %struct.rust_vec** %vp, align 8, !tbaa !0
define void @rust_intrinsic_2_vec_len(i64* nocapture %retptr, i8* nocapture %env, %struct.type_desc* nocapture %ty, %struct.rust_vec** nocapture %vp) nounwind {
%1 = load %struct.rust_vec** %vp, align 8
%2 = getelementptr inbounds %struct.rust_vec* %1, i64 0, i32 0
%3 = load i64* %2, align 8, !tbaa !3
%3 = load i64* %2, align 8
%4 = getelementptr inbounds %struct.type_desc* %ty, i64 0, i32 1
%5 = load i64* %4, align 8, !tbaa !3
%5 = load i64* %4, align 8
%6 = udiv i64 %3, %5
store i64 %6, i64* %retptr, align 8, !tbaa !3
store i64 %6, i64* %retptr, align 8
ret void
}
define void @rust_intrinsic_ptr_offset(%struct.rust_task* nocapture %task, i8** nocapture %retptr, %struct.type_desc* nocapture %ty, i8* %ptr, i64 %count) nounwind uwtable {
define void @rust_intrinsic_2_ptr_offset(i8** nocapture %retptr, i8* nocapture %env, %struct.type_desc* nocapture %ty, i8* %ptr, i64 %count) nounwind {
%1 = getelementptr inbounds %struct.type_desc* %ty, i64 0, i32 1
%2 = load i64* %1, align 8, !tbaa !3
%2 = load i64* %1, align 8
%3 = mul i64 %2, %count
%4 = getelementptr inbounds i8* %ptr, i64 %3
store i8* %4, i8** %retptr, align 8, !tbaa !0
store i8* %4, i8** %retptr, align 8
ret void
}
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) uwtable {
define void @rust_intrinsic_2_cast(i8* nocapture %retptr, i8* nocapture %env, %struct.type_desc* nocapture %t1, %struct.type_desc* nocapture %t2, i8* nocapture %src) {
%1 = getelementptr inbounds %struct.type_desc* %t1, i64 0, i32 1
%2 = load i64* %1, align 8, !tbaa !3
%2 = load i64* %1, align 8
%3 = getelementptr inbounds %struct.type_desc* %t2, i64 0, i32 1
%4 = load i64* %3, align 8, !tbaa !3
%4 = load i64* %3, align 8
%5 = icmp eq i64 %2, %4
br i1 %5, label %7, label %6
; <label>:6 ; preds = %0
tail call void @upcall_fail(i8* getelementptr inbounds ([42 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([33 x i8]* @.str1, i64 0, i64 0), i64 38)
tail call void @upcall_fail(i8* getelementptr inbounds ([42 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([33 x i8]* @.str1, i64 0, i64 0), i64 46)
br label %8
; <label>:7 ; preds = %0
@ -108,12 +97,12 @@ declare void @upcall_fail(i8*, i8*, i64)
declare void @llvm.memmove.p0i8.p0i8.i64(i8* nocapture, i8* nocapture, i64, i32, i1) nounwind
define void @rust_intrinsic_addr_of(%struct.rust_task* nocapture %task, i8** nocapture %retptr, %struct.type_desc* nocapture %ty, i8* %valptr) nounwind uwtable {
store i8* %valptr, i8** %retptr, align 8, !tbaa !0
define void @rust_intrinsic_2_addr_of(i8** nocapture %retptr, i8* nocapture %env, %struct.type_desc* nocapture %ty, i8* %valptr) nounwind {
store i8* %valptr, i8** %retptr, align 8
ret void
}
define void @rust_intrinsic_recv(%struct.rust_task* nocapture %task, i8** %retptr, %struct.type_desc* nocapture %ty, %class.rust_port* %port) uwtable {
define void @rust_intrinsic_2_recv(i8** %retptr, i8* nocapture %env, %struct.type_desc* nocapture %ty, %class.rust_port* %port) {
%1 = bitcast i8** %retptr to i64*
tail call void @port_recv(i64* %1, %class.rust_port* %port)
ret void
@ -121,20 +110,77 @@ define void @rust_intrinsic_recv(%struct.rust_task* nocapture %task, i8** %retpt
declare void @port_recv(i64*, %class.rust_port*)
define void @rust_intrinsic_get_type_desc(%struct.rust_task* nocapture %task, i8** nocapture %retptr, %struct.type_desc* %ty) nounwind uwtable {
define void @rust_intrinsic_2_get_type_desc(i8** nocapture %retptr, i8* nocapture %env, %struct.type_desc* %ty) nounwind {
%ty.c = bitcast %struct.type_desc* %ty to i8*
store i8* %ty.c, i8** %retptr, align 8, !tbaa !0
store i8* %ty.c, i8** %retptr, align 8
ret void
}
define void @rust_intrinsic_task_sleep(%struct.rust_task* nocapture %_task, i8** nocapture %retptr, i64 %time_in_us) uwtable {
define void @rust_intrinsic_2_task_sleep(i8** nocapture %retptr, i8* nocapture %env, i64 %time_in_us) {
tail call void @rust_task_sleep(i64 %time_in_us)
ret void
}
declare void @rust_task_sleep(i64)
!0 = metadata !{metadata !"any pointer", metadata !1}
!1 = metadata !{metadata !"omnipotent char", metadata !2}
!2 = metadata !{metadata !"Simple C/C++ TBAA", null}
!3 = metadata !{metadata !"long", metadata !1}
define void @rust_intrinsic_vec_len(i8* nocapture %task, i64* nocapture %retptr, %struct.type_desc* nocapture %ty, %struct.rust_vec** nocapture %vp) nounwind {
%1 = load %struct.rust_vec** %vp, align 8
%2 = getelementptr inbounds %struct.rust_vec* %1, i64 0, i32 0
%3 = load i64* %2, align 8
%4 = getelementptr inbounds %struct.type_desc* %ty, i64 0, i32 1
%5 = load i64* %4, align 8
%6 = udiv i64 %3, %5
store i64 %6, i64* %retptr, align 8
ret void
}
define void @rust_intrinsic_ptr_offset(i8* nocapture %task, i8** nocapture %retptr, %struct.type_desc* nocapture %ty, i8* %ptr, i64 %count) nounwind {
%1 = getelementptr inbounds %struct.type_desc* %ty, i64 0, i32 1
%2 = load i64* %1, align 8
%3 = mul i64 %2, %count
%4 = getelementptr inbounds i8* %ptr, i64 %3
store i8* %4, i8** %retptr, align 8
ret void
}
define void @rust_intrinsic_cast(i8* nocapture %task, i8* nocapture %retptr, %struct.type_desc* nocapture %t1, %struct.type_desc* nocapture %t2, i8* nocapture %src) {
%1 = getelementptr inbounds %struct.type_desc* %t1, i64 0, i32 1
%2 = load i64* %1, align 8
%3 = getelementptr inbounds %struct.type_desc* %t2, i64 0, i32 1
%4 = load i64* %3, align 8
%5 = icmp eq i64 %2, %4
br i1 %5, label %7, label %6
; <label>:6 ; preds = %0
tail call void @upcall_fail(i8* getelementptr inbounds ([42 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([33 x i8]* @.str1, i64 0, i64 0), i64 46)
br label %rust_intrinsic_2_cast.exit
; <label>:7 ; preds = %0
tail call void @llvm.memmove.p0i8.p0i8.i64(i8* %retptr, i8* %src, i64 %2, i32 1, i1 false)
br label %rust_intrinsic_2_cast.exit
rust_intrinsic_2_cast.exit: ; preds = %6, %7
ret void
}
define void @rust_intrinsic_addr_of(i8* nocapture %task, i8** nocapture %retptr, %struct.type_desc* nocapture %ty, i8* %valptr) nounwind {
store i8* %valptr, i8** %retptr, align 8
ret void
}
define void @rust_intrinsic_recv(i8* nocapture %task, i8** %retptr, %struct.type_desc* nocapture %ty, %class.rust_port* %port) {
%1 = bitcast i8** %retptr to i64*
tail call void @port_recv(i64* %1, %class.rust_port* %port)
ret void
}
define void @rust_intrinsic_get_type_desc(i8* nocapture %task, i8** nocapture %retptr, %struct.type_desc* %ty) nounwind {
%ty.c.i = bitcast %struct.type_desc* %ty to i8*
store i8* %ty.c.i, i8** %retptr, align 8
ret void
}
define void @rust_intrinsic_task_sleep(i8* nocapture %task, i8** nocapture %retptr, i64 %time_in_us) {
tail call void @rust_task_sleep(i64 %time_in_us)
ret void
}