Advertisement
Guest User

Untitled

a guest
Dec 17th, 2018
162
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
LLVM 0.80 KB | None | 0 0
  1.     let list_slice_ty m typ =
  2.        ... load src list, list_slice(i,j) ...
  3.        (* init loop counter *)
  4.        let loop_cnt_ptr = L.build_alloca i32_t "loop_cnt" build in
  5.        let _ = L.build_store (L.const_int i32_t 0) loop_cnt_ptr build in
  6.  
  7.        (* define upper bound of loop *)
  8.        let loop_upper_bound = L.build_sub (L.param def 1) (L.param def 0) "loop_upper_bound" build in
  9.  
  10.        (* loop condition: cntr <= (j-i) *)
  11.        let loop_cond = L.build_icmp L.Icmp.Sle loop_cnt_ptr loop_upper_bound "cond" build in
  12.  
  13.        (* loop iteration: cntr = cntr + 1 *)
  14.        let loop_itr = L.build_add loop_cnt_ptr (L.const_int i32_t 1) "loop_itr" build in
  15.  
  16.        (* loop body: assignment *)
  17.        let loop_body = (* assign b[loop_cnt] = a[loop_cnt + i] *) in
  18.  
  19.        construct_for_loop;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement