Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New SSA IR #5

Open
tshort opened this issue Mar 23, 2018 · 4 comments
Open

New SSA IR #5

tshort opened this issue Mar 23, 2018 · 4 comments

Comments

@tshort
Copy link
Collaborator

tshort commented Mar 23, 2018

Does anyone know if Keno's new SSA IR will change the output of code_typed? I thought it might, but I haven't been able to figure that out.

If it does, it's something to keep track of here.

@MikeInnes
Copy link
Owner

Since we're immediately throwing out the SSA values themselves anyway, I expect this will be easy to update if it does change. The main change on 0.7 is linear IR, but I think even that'll work without any changes on our end.

@tshort
Copy link
Collaborator Author

tshort commented Mar 23, 2018

Phi nodes was a complication I was worried about, but maybe those can be thrown out, too.

@MikeInnes
Copy link
Owner

Even with phi nodes it should be straightforward to turn them into locals. We'll probably want some way to coalesce and/or remove locals entirely to clean up the code, which is a little harder, but tools like Binaryen will also do that for us for now.

@MikeInnes
Copy link
Owner

Quick example to give a flavour of what this looks like on 0.7:

julia> function pow(x, n)
         r = 1
         while n > 0
           r *= x
           n -= 1
         end
         return r
       end
pow (generic function with 1 method)

julia> @code_ir pow(1,2)
Code
1nothing
2%2 = φ (1 => 1, 3 => %6)::Int64%3 = φ (1 => %%3, 3 => %7)::Int64%4 = Main.:>(%3, 0)::Bool
└──      goto 4 if not %4
3%6 = Main.:*(%2, %%2)::Int64%7 = Main.:-(%3, 1)::Int64
└──      goto 2
4return %2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants