Keeping up with the Gophers
A brief history of gccgo, improvements, and the future
Chris Manghane
Google Gopher | Compilers and Toolchains
Chris Manghane
Google Gopher | Compilers and Toolchains
2010-01-26 Ian Lance Taylor <iant@google.com> * MAINTAINERS: Add myself as Go frontend maintainer.
"Ian just showed up at our door with a fully working compiler" ~ probably Rob
3gofrontend (gcc/go/gofrontend/expressions.cc)
- tree val_type_tree = type_to_tree(this->type()->get_backend(gogo)); - go_assert(val_type_tree != error_mark_node); - return build_int_cstu(val_type_tree, val); + mpz_t cst; + mpz_init_set_ui(cst, val); + Btype* int_btype = this->type()->get_backend(gogo); + return gogo->backend()->integer_constant_expression(int_btype, cst);
backend (gcc/go/go-gcc.cc)
Bexpression* Gcc_backend::integer_constant_expression(Btype* btype, mpz_t val) { tree t = btype->get_tree(); tree ret = double_int_to_tree(t, mpz_get_double_int(t, val, true)); return this->make_expression(ret); }
$ cat hello.go package main import "fmt" func main() { fmt.Println("Hello World!") } $ go run -gccgoflags="-fgo-optimize-allocs" hello.go Hello World! $ go version go version go1.4.2 gccgo (GCC) 6.0.0 20150714 (experimental) linux/amd64
escape.go
package main var global *int func f(i *int) { global = i } func main() { a := new(int) f(a) }
Connection Graph