Awesome
tre
A LLVM backed Go compiler.
tre
is built in Go and can compile a subset of Go code to LLVM IR. Clang is
used to compile the IR to an executable.
Building
# Build tre and run a test program
go build ./cmd/tre && ./tre -d ./compiler/testdata/fib.go && ./fib
Example
Example program that calculates the fibonacci sequence.
func fib(num int) int {
if num < 2 {
return num
}
return fib(num-2) + fib(num-1)
}
func main() {
printf("%d\n", fib(34))
}
More examples of what's possible can be found in the compiler testdata.
Features
Types
Language features
- first class func
- packages
- methods
- pointers
- interfaces
- chan
- goroutines
- if/else if/else
- switch