a little more on phases.
This commit is contained in:
committed by
alexander-gorshenev
parent
62737efd54
commit
8035a77e52
+14
-12
@@ -51,21 +51,23 @@ public fun runTopLevelPhases(konanConfig: KonanConfig, environment: KotlinCoreEn
|
|||||||
val moduleDescriptor = analyzerWithCompilerReport.analysisResult.moduleDescriptor
|
val moduleDescriptor = analyzerWithCompilerReport.analysisResult.moduleDescriptor
|
||||||
|
|
||||||
val context = Context(konanConfig, bindingContext, moduleDescriptor)
|
val context = Context(konanConfig, bindingContext, moduleDescriptor)
|
||||||
|
|
||||||
// Translate AST to high level IR.
|
|
||||||
val translator = Psi2IrTranslator(Psi2IrConfiguration(false))
|
|
||||||
val module = translator.generateModule( moduleDescriptor,
|
|
||||||
environment.getSourceFiles(), bindingContext)
|
|
||||||
|
|
||||||
context.irModule = module
|
|
||||||
val phaser = PhaseManager(context)
|
val phaser = PhaseManager(context)
|
||||||
|
|
||||||
phaser.phase(KonanPhase.OPTIMIZER) {
|
phaser.phase(KonanPhase.PSI_TO_IR) {
|
||||||
KonanLower(context).lower(module)
|
// Translate AST to high level IR.
|
||||||
}
|
val translator = Psi2IrTranslator(Psi2IrConfiguration(false))
|
||||||
|
val module = translator.generateModule( moduleDescriptor,
|
||||||
|
environment.getSourceFiles(), bindingContext)
|
||||||
|
|
||||||
phaser.phase(KonanPhase.BITCODE) {
|
context.irModule = module
|
||||||
emitLLVM(context)
|
}
|
||||||
|
phaser.phase(KonanPhase.BACKEND) {
|
||||||
|
phaser.phase(KonanPhase.LOWER) {
|
||||||
|
KonanLower(context).lower()
|
||||||
|
}
|
||||||
|
phaser.phase(KonanPhase.BITCODE) {
|
||||||
|
emitLLVM(context)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
phaser.phase(KonanPhase.LINKER) {
|
phaser.phase(KonanPhase.LINKER) {
|
||||||
|
|||||||
+2
-3
@@ -8,8 +8,8 @@ import org.jetbrains.kotlin.ir.declarations.IrModuleFragment
|
|||||||
|
|
||||||
internal class KonanLower(val context: Context) {
|
internal class KonanLower(val context: Context) {
|
||||||
|
|
||||||
fun lower(module: IrModuleFragment) {
|
fun lower() {
|
||||||
module.files.forEach {
|
context.irModule!!.files.forEach {
|
||||||
lower(it)
|
lower(it)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -20,7 +20,6 @@ internal class KonanLower(val context: Context) {
|
|||||||
phaser.phase(KonanPhase.LOWER_BUILTIN_OPERATORS) {
|
phaser.phase(KonanPhase.LOWER_BUILTIN_OPERATORS) {
|
||||||
BuiltinOperatorLowering(context).runOnFilePostfix(irFile)
|
BuiltinOperatorLowering(context).runOnFilePostfix(irFile)
|
||||||
}
|
}
|
||||||
|
|
||||||
phaser.phase(KonanPhase.LOWER_SHARED_VARIABLES) {
|
phaser.phase(KonanPhase.LOWER_SHARED_VARIABLES) {
|
||||||
SharedVariablesLowering(context).runOnFilePostfix(irFile)
|
SharedVariablesLowering(context).runOnFilePostfix(irFile)
|
||||||
}
|
}
|
||||||
|
|||||||
+13
-13
@@ -5,19 +5,19 @@ import org.jetbrains.kotlin.backend.konan.Context
|
|||||||
enum class KonanPhase(val description: String,
|
enum class KonanPhase(val description: String,
|
||||||
var enabled: Boolean = true, var verbose: Boolean = false) {
|
var enabled: Boolean = true, var verbose: Boolean = false) {
|
||||||
|
|
||||||
BACKEND("All backend"), // TODO: it is unused
|
/* */ PSI_TO_IR("Psi to IR conversion"),
|
||||||
OPTIMIZER("IR Optimizer"),
|
/* */ BACKEND("All backend"),
|
||||||
LOWER_BUILTIN_OPERATORS("BuiltIn Operators Lowering"),
|
/* ... */ LOWER("IR Lowering"),
|
||||||
LOWER_SHARED_VARIABLES("Shared Variable Lowering"),
|
/* ... ... */ LOWER_BUILTIN_OPERATORS("BuiltIn Operators Lowering"),
|
||||||
LOWER_LOCAL_FUNCTIONS("Local Function Lowering"),
|
/* ... ... */ LOWER_SHARED_VARIABLES("Shared Variable Lowering"),
|
||||||
LOWER_CALLABLES("Callable references Lowering"),
|
/* ... ... */ LOWER_LOCAL_FUNCTIONS("Local Function Lowering"),
|
||||||
AUTOBOX("Autoboxing of primitive types"),
|
/* ... ... */ LOWER_CALLABLES("Callable references Lowering"),
|
||||||
LOWER("IR Lowering"), // TODO: it is unused
|
/* ... ... */ AUTOBOX("Autoboxing of primitive types"),
|
||||||
BITCODE("LLVM BitCode Generation"),
|
/* ... */ BITCODE("LLVM BitCode Generation"),
|
||||||
RTTI("RTTI Generation"),
|
/* ... ... */ RTTI("RTTI Generation"),
|
||||||
CODEGEN("Code Generation"),
|
/* ... ... */ CODEGEN("Code Generation"),
|
||||||
METADATOR("Metadata Generation"),
|
/* ... ... */ METADATOR("Metadata Generation"),
|
||||||
LINKER("Link Stage");
|
/* */ LINKER("Link Stage");
|
||||||
}
|
}
|
||||||
|
|
||||||
object KonanPhases {
|
object KonanPhases {
|
||||||
|
|||||||
Reference in New Issue
Block a user