Skip to content
Snippets Groups Projects
Commit ef5ac0b5 authored by rarbore2's avatar rarbore2
Browse files

Merge branch 'interpreter' into 'main'

interpreter

See merge request !30
parents bf1b9c90 3471b7f9
No related branches found
No related tags found
1 merge request!30interpreter
fn simple3<1>(a: array(f32, #0), b: array(f32, #0)) -> f32
zero = constant(f32, 0.0)
fork = fork(start, #0)
id = thread_id(fork)
join = join(fork)
r = return(join, dot_red)
aval = read(a, position(id))
bval = read(b, position(id))
mul = mul(aval, bval)
dot = add(mul, dot_red)
dot_red = reduce(join, zero, dot)
\ No newline at end of file
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)
read = read(str_inc, position(idx))
write = write(str_inc, byte, position(idx))
continue = ne(read, byte)
if_cond = and(continue, in_bounds)
if = if(loop, if_cond)
if_false = projection(if, 0)
if_true = projection(if, 1)
r = return(if_false, str_inc)
fn sum<1>(a: array(i32, #0)) -> i32
zero_idx = constant(u64, 0)
one_idx = constant(u64, 1)
zero_inc = constant(i32, 0)
bound = dynamic_constant(#0)
loop = region(start, if_true)
idx = phi(loop, zero_idx, idx_inc)
idx_inc = add(idx, one_idx)
red = phi(loop, zero_inc, red_add)
read = read(a, position(idx))
red_add = add(red, read)
in_bounds = lt(idx_inc, bound)
if = if(loop, in_bounds)
if_false = projection(if, 0)
if_true = projection(if, 1)
r = return(if_false, red_add)
\ No newline at end of file
fn alt_sum<1>(a: array(i32, #0)) -> i32
zero_idx = constant(u64, 0)
one_idx = constant(u64, 1)
two_idx = constant(u64, 2)
zero_inc = constant(i32, 0)
bound = dynamic_constant(#0)
loop = region(start, if_true)
idx = phi(loop, zero_idx, idx_inc)
idx_inc = add(idx, one_idx)
red = phi(loop, zero_inc, red_add)
rem = rem(idx, two_idx)
odd = eq(rem, one_idx)
negate_if = if(loop, odd)
negate_if_false = projection(negate_if, 0)
negate_if_true = projection(negate_if, 1)
negate_bottom = region(negate_if_false, negate_if_true)
read = read(a, position(idx))
read_neg = neg(read)
read_phi = phi(negate_bottom, read, read_neg)
red_add = add(red, read_phi)
in_bounds = lt(idx_inc, bound)
if = if(negate_bottom, in_bounds)
if_false = projection(if, 0)
if_true = projection(if, 1)
r = return(if_false, red_add)
[toolchain]
channel = "nightly"
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment