2011-06-16 10:32:52 -07:00
|
|
|
// Use `clang++ -emit-llvm -S -arch i386 -O3 -I../isaac -I../uthash
|
2011-07-08 21:55:43 -07:00
|
|
|
// -I../arch/i386 -fno-stack-protector -o intrinsics.ll intrinsics.cpp`
|
2011-05-05 12:45:34 -07:00
|
|
|
|
2011-05-03 18:49:29 -07:00
|
|
|
#include "../rust_internal.h"
|
2011-09-28 11:31:44 -07:00
|
|
|
#include "../rust_scheduler.h"
|
2011-07-09 20:14:20 -07:00
|
|
|
#include <cstdlib>
|
|
|
|
#include <cstring>
|
|
|
|
|
|
|
|
extern "C" CDECL void
|
|
|
|
upcall_fail(rust_task *task, char const *expr, char const *file, size_t line);
|
2011-05-03 18:49:29 -07:00
|
|
|
|
2011-07-09 21:13:25 -07:00
|
|
|
extern "C" void
|
2011-08-25 10:18:02 +02:00
|
|
|
rust_intrinsic_vec_len(rust_task *task, size_t *retptr, type_desc *ty,
|
|
|
|
rust_vec **vp)
|
2011-07-09 21:13:25 -07:00
|
|
|
{
|
2011-08-25 10:18:02 +02:00
|
|
|
*retptr = (*vp)->fill / ty->size;
|
2011-07-09 21:13:25 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
extern "C" void
|
|
|
|
rust_intrinsic_ptr_offset(rust_task *task, void **retptr, type_desc *ty,
|
|
|
|
void *ptr, uintptr_t count)
|
2011-07-08 21:55:43 -07:00
|
|
|
{
|
2011-07-09 21:13:25 -07:00
|
|
|
*retptr = &((uint8_t *)ptr)[ty->size * count];
|
2011-07-08 21:55:43 -07:00
|
|
|
}
|
|
|
|
|
2011-07-09 20:14:20 -07:00
|
|
|
extern "C" void
|
2011-07-09 21:13:25 -07:00
|
|
|
rust_intrinsic_cast(rust_task *task, void *retptr, type_desc *t1,
|
|
|
|
type_desc *t2, void *src)
|
2011-07-09 20:14:20 -07:00
|
|
|
{
|
|
|
|
if (t1->size != t2->size) {
|
2011-10-20 11:56:45 +02:00
|
|
|
upcall_fail("attempt to cast values of differing sizes",
|
2011-07-09 20:14:20 -07:00
|
|
|
__FILE__, __LINE__);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2011-07-09 21:13:25 -07:00
|
|
|
memmove(retptr, src, t1->size);
|
2011-07-09 20:14:20 -07:00
|
|
|
}
|
|
|
|
|
2011-07-11 14:25:15 -07:00
|
|
|
extern "C" void
|
|
|
|
rust_intrinsic_addr_of(rust_task *task, void **retptr, type_desc *ty,
|
|
|
|
void *valptr) {
|
|
|
|
*retptr = valptr;
|
|
|
|
}
|
|
|
|
|
2011-08-01 18:42:29 -07:00
|
|
|
extern "C" void
|
|
|
|
rust_intrinsic_recv(rust_task *task, void **retptr, type_desc *ty,
|
|
|
|
rust_port *port) {
|
2011-10-20 11:56:45 +02:00
|
|
|
port_recv((uintptr_t*)retptr, port);
|
2011-08-01 18:42:29 -07:00
|
|
|
}
|
2011-09-28 11:31:44 -07:00
|
|
|
|