cmd/compile: simplify converting a Go function to buildable Go assembly #29538
I'm slowly learning x86 assembly and how Go uses it, so it's very useful to see how existing functions in Go are translated to it.
The next logical step is to be able to make small changes to that assembly, to see if my understanding of it is correct, and to play with trying to make the code better manually. However, as I've found out, there's no easy way to move a function from a
After reading some blog posts online and some trial and error, I've found out that most functions can be translated by hand. For example, take a single file with this very simple Go function:
However, we can't just add the assembly to the source code and make the Go func a stub, as that just fails:
We can apply multiple changes to get it to work:
End result, which works just as fine as the Go code:
In this case, we're done. But if the function had jumps like
I've succsesfully done this with multiple funcs on the small side, but it's tedious. Worse even, I still haven't been able to correctly translate a function calling another function to assembly - I keep getting panics like
I think the compiler should support translating Go functions to assembly which can just be dumped onto a
Ideas that come to mind to improve
For example, borrowing from flags like
If this makes sense, I'm happy to do some of the work during the upcoming cycle. I'll just need a bit of help from the compiler folks, as my assembly (and especially Go assembly syntax) knowledge is limited.
The text was updated successfully, but these errors were encountered:
I forgot to address one point - why this should be part of