https://kotlinlang.org logo
Title
e

el_tigro

05/01/2018, 5:47 AM
Hi, I was wondering if I could get some clarification on something that confused me in https://kotlinlang.org/docs/reference/native-overview.html
[Kotlin/Native] comprises a LLVM-based backend for the Kotlin compiler and a native implementation of the Kotlin runtime library
"backend" in this context does not mean an actual LLVM backend (which consumes IR to produce machine code). Instead it is backend for the Kotlin compiler itself. So
(Kotlin compiler + "backend") = LLVM frontend
. is this correct?
a

Aregev2

05/01/2018, 5:53 AM
K/n is the kotlin runtime implemented in llvm
o

olonho

05/01/2018, 7:52 AM
K/N is a LLVM-based backed for Kotlin compiler frontend, and from that point of view it will produce machine code from Kotlin high level IR fed by frontend. From LLVM POV, it is bitcode generator using standard LLVM backends
e

el_tigro

05/01/2018, 4:05 PM
Thank you for the responses. I think my confusion stemmed from a lack of understanding of how the LLVM infrastructure is used. I wrongly assumed that the K/N compiler only performs the "frontend" task of generating LLVM IR from Kotlin source, and then delegates the optimization and backend (IR --> machine code) tasks to the LLVM
opt
and
llc
utilities, respectively. I didn't realize that standard LLVM optimizer and backend libraries can simply be incorporated into the Kotlin compiler. Is my new understanding correct? Also, does that mean that the bulk of the development work on K/N is spent on the frontend task (compiling Kotlin source to IR)? Thanks again