Skip to content
Snippets Groups Projects
strset.hir 567 B
Newer Older
  • Learn to ignore specific revisions
  • rarbore2's avatar
    rarbore2 committed
    fn strset<1>(str: array(u8, #0), byte: u8) -> array(u8, #0)
      zero = constant(u64, 0)
      one = constant(u64, 1)
      bound = dynamic_constant(#0)
      loop = region(start, if_true)
      idx = phi(loop, zero, idx_inc)
      str_inc = phi(loop, str, write)
      idx_inc = add(idx, one)
      in_bounds = lt(idx_inc, bound)
    
    rarbore2's avatar
    rarbore2 committed
      read = read(str_inc, position(idx))
      write = write(str_inc, byte, position(idx))
    
    rarbore2's avatar
    rarbore2 committed
      continue = ne(read, byte)
      if_cond = and(continue, in_bounds)
      if = if(loop, if_cond)
    
    Xavier Routh's avatar
    Xavier Routh committed
      if_false = projection(if, 0)
      if_true = projection(if, 1)
    
    rarbore2's avatar
    rarbore2 committed
      r = return(if_false, str_inc)