ventura
03/02/2022, 11:39 AMventura
03/02/2022, 11:40 AMventura
03/02/2022, 11:42 AMPiotr Krzemiński
03/02/2022, 11:43 AMventura
03/02/2022, 11:44 AMPiotr Krzemiński
03/02/2022, 11:45 AMventura
03/02/2022, 12:02 PMventura
03/02/2022, 1:57 PMventura
03/02/2022, 7:50 PMjvg
03/02/2022, 8:48 PMmcpiroman
03/03/2022, 9:46 AMobjectweb.asm
) but symmetrically there are only .NET once for .NET. So one would either have to find some way to utilize them (e.g. parts of Roslyn compiler, which is also written in C#)) from kotlin code for rewrite everything.jvg
03/03/2022, 4:20 PMjvg
03/03/2022, 4:23 PMventura
03/03/2022, 8:23 PMventura
03/03/2022, 8:29 PMobjectweb.asm
generation, so I can discover how KIR (Kotlin Intermediate Representation) becomes not only JVM but also JS bytecodemcpiroman
03/03/2022, 10:56 PMcompiler/ir/ir.tree
. Its root is a IrModuleFragment
node for each compiler module.
• An ordered list of phases are executed (known as lowering), each of which transforms the IR tree in some way, so that at the end it looks as close to the to-be-emitted code as possible, while also remaining its structure. The list of phases differs for each backend, e.g. JVM once are defined in compiler/ir/backend.jvm/lower/src/org/jetbrains/kotlin/backend/jvm/JvmLower.kt
. Many common bits of these phases are shared between backends (compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower
) though.
• The lowered IR tree is then converted into backend-specific representation and transformed a bit further. E.g. for JS this is roughly an JS AST. AFAIK this part for JVM is the only place where you can find something like what you mention as a tuple representation.
• Based on that representation a target code is emitted, e.g. using `objectweb.asm`for JVM.
So we may say there are actually at least 4 apparently distinctive internal representations (AST, frontend representation, backend IR, codegen specific) in the whole compiler pipeline. In the source code though, the term IR refers most commonly to the 3-th one.ventura
03/04/2022, 11:29 AMventura
03/04/2022, 11:32 AMventura
03/04/2022, 11:47 AMventura
03/04/2022, 1:33 PMIrElementVisitor
⬅️ IrElementTransformer
⬅️ IrModuleFragment
ventura
01/28/2023, 10:39 AMventura
01/28/2023, 11:02 AMventura
01/28/2023, 11:04 AMventura
01/28/2023, 11:33 AMbackend.common
).mcpiroman
01/30/2023, 9:55 AM