TL;DR: what's the best way to do SSA back-translation when using
x/tools/go/ssa?

I'm thinking about a Go compiler which accepts a subset of Go and emits
assembly for a microcontroller. Instead of going all the way from
lexing, parsing etc. I'd like to use x/tools/go/ssa.

In order to generate assembly code I need to remove the Phi functions
and rename the registers accordingly. The register field in SSA is not
exported and can be accessed read-only by Name(). This makes SSA
back-translation cumbersome.

What do you suggest to solve this problem?

My ideas:

* visit all SSA nodes and clone them into a new data structure which
 supports register renaming. That would probably mean reimplementing a
 lot of x/tools/go/ssa.

* export the register field from x/tools/go/ssa. That would need to be
 done by Go devs with write access to the repository.

If you have any comments on these or another ideas how to get from Go
code to assembly please tell me.

(I know about `go compile -S` this is suitable only for supported
architectures. A microcontroller with 512 Bytes of RAM most likely will
never be supported. That's why I want to implement just a subsetof Go.)

--
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to