Search code examples
scalaintermediate-languagescala-compiler

Intermediate language used in scalac?


In the GCC compiler we see several 'intermediate languages': RTL, GENERIC and GIMPLE.

This answer hints at the idea of an intermediate representation in scalac.

My question is: is there an 'intermediate representation' of the compiler in Scala? Is there any documentation for this?

Assumptions:

  • I don't mean JVM byte code. I mean the level of abstraction above that.

Solution

  • The nearest equivalents would be icode and bcode as used by scalac, view Miguel Garcia's site on the Scalac optimiser for more information, here: http://magarciaepfl.github.io/scala/

    You might also consider Java bytecode itself to be your intermediate representation, given that bytecode is the ultimate output of scalac.

    Or perhaps the true intermediate is something that the JIT produces before it finally outputs native instructions?

    Ultimately though... There's no single place that you can point at an claim "there's the intermediate!". Scalac works in phases that successively change the abstract syntax tree, every single phase produces a new intermediate. The whole thing is like an onion, and it's very hard to try and pick out one layer as somehow being more significant than any other.