The llgo
compiler is the LLVM-based frontend for Go written in Go language only. Using this frontend, we can generate the LLVM assembly code from a program written in Go.
You need to download the llgo
binaries or build llgo
from the source code and add the binaries in the PATH
file location as configured.
Do the following steps:
Create a Go source file, for example, that will be used for generating the LLVM assembly using
llgo
. Createtest.go
:|$ cat test.go |package main |import "fmt" |func main() { | fmt.Println("Test Message") |}
Now, use
llgo
to get the LLVM assembly:$llgo -dump test.go ; ModuleID = 'main' target datalayout = "e-p:64:64:64..." target triple = "x86_64-unknown-linux" %0 = type { i8*, i8* } ....
The llgo
compiler is the frontend for the Go language; it takes the test.go
program as its input and emits the LLVM IR.
For information about how to get and install
llgo,
refer to https://github.com/go-llvm/llgo