rust/src/rt/intrinsics/intrinsics.cpp

25 lines
550 B
C++
Raw Normal View History

// Use `clang++ -emit-llvm -S -arch i386 -O3 -I../isaac -I../uthash
// -I../arch/i386 -o intrinsics.ll intrinsics.cpp`
#include "../rust_internal.h"
extern "C" size_t
rust_intrinsic_vec_len(rust_task *task, type_desc *ty, rust_vec *v)
{
return v->fill / ty->size;
}
extern "C" size_t
rust_intrinsic_ivec_len(rust_task *task, type_desc *ty, rust_ivec *v)
{
size_t fill;
if (v->fill)
fill = v->fill;
else if (v->payload.ptr)
fill = v->payload.ptr->fill;
else
fill = 0;
return fill / ty->size;
}