Git Product home page Git Product logo

go2ll-talk's Introduction

go2ll-talk

The code presented at Sheffield Go, 7th March.

Slides link

To run, just say make.

To take a look at the output of the program, run go run ., or build it and run it as you would any go program.

What's going on?

The goal of this talk was to show you how you could use some existing tooling to make a binary from Go code.

Of course, this isn't possible in 20 minutes, so we take some liberties:

  1. We use Go's x/tools/ssa (static single assignment) package, which enables us to turn Go's langauge semantics into a fairly simple data structure we can work with. (This is called the Intermediate Representation, or "IR").

  2. We use LLVM, which is a compiler framework which also uses static single assignment for its IR.

  3. The goal of this program then is to translate from one IR to the other.

To show some output, we use printf, which we steal from libc, C's runtime. We compile the resulting intermediate clang, the C frontend, which happens to be able to compile .ll (LLVM's "assembly" format).

This compiler is not at all general. It supports only the + operator and calling the println function (which is actually libc's printf function). So it can't do very much. But hopefully that simplicity is also what allows some newcomers to understand it.

go2ll

In the near future I plan to publish go2ll, which is a slightly more sophisticated frontend. It will only ever be a toy, because, for example, it is unlikely to implement garbage collection and goroutines. This means it won't be good for abitrary Go programs. On the other hand, I can still think of a few interesting uses, such as for speeding up CPU intensive compute kernels. I have already been able to demonstrate 30-40% speedups in already fairly well tuned code such as that for computing SHA1 and strconv.ParseFloat.

go2ll-talk's People

Contributors

pwaller avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.