Advertisement
Guest User

boxing/unboxing vectors

a guest
Aug 2nd, 2014
203
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
OCaml 1.08 KB | None | 0 0
  1.   let match_composite ty = match classify_type ty with
  2.       TypeKind.Vector ->
  3.       let size = vector_size (type_of llval) in
  4.       let ptr = build_in_bounds_gep value_ptr (idx 3) "boxptr" builder in
  5.       let vec_ptr = build_in_bounds_gep ptr [| const_int i32_type 0 |]
  6.                                         "vecptr" builder in
  7.       let new_vec = build_alloca (vector_type i64_type size) "vec" builder in
  8.       let new_vec_ptr = build_in_bounds_gep new_vec (idx 0) "vecptr" builder in
  9.       let rhvector_type size = pointer_type (vector_type i64_type size) in
  10.       ignore (build_store new_vec_ptr vec_ptr builder);
  11.       let el = build_load ptr "el" builder in
  12.       build_bitcast el (rhvector_type size) "dst" builder
  13.  
  14. let unbox_vec llval =
  15.   let idx0 = [| const_int i32_type 0; const_int i32_type 3 |] in
  16.   let ptr = build_in_bounds_gep llval idx0 "boxptr" builder in
  17.   let el = build_load ptr "el" builder in
  18.   let rhvector_type size = pointer_type (vector_type i64_type size) in
  19.   let vec = build_bitcast el (rhvector_type 3) "vecptr" builder in
  20.   build_load vec "load" builder
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement