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 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)
|
||||
|
||||
phaser.phase(KonanPhase.OPTIMIZER) {
|
||||
KonanLower(context).lower(module)
|
||||
}
|
||||
phaser.phase(KonanPhase.PSI_TO_IR) {
|
||||
// Translate AST to high level IR.
|
||||
val translator = Psi2IrTranslator(Psi2IrConfiguration(false))
|
||||
val module = translator.generateModule( moduleDescriptor,
|
||||
environment.getSourceFiles(), bindingContext)
|
||||
|
||||
phaser.phase(KonanPhase.BITCODE) {
|
||||
emitLLVM(context)
|
||||
context.irModule = module
|
||||
}
|
||||
phaser.phase(KonanPhase.BACKEND) {
|
||||
phaser.phase(KonanPhase.LOWER) {
|
||||
KonanLower(context).lower()
|
||||
}
|
||||
phaser.phase(KonanPhase.BITCODE) {
|
||||
emitLLVM(context)
|
||||
}
|
||||
}
|
||||
|
||||
phaser.phase(KonanPhase.LINKER) {
|
||||
|
||||
+2
-3
@@ -8,8 +8,8 @@ import org.jetbrains.kotlin.ir.declarations.IrModuleFragment
|
||||
|
||||
internal class KonanLower(val context: Context) {
|
||||
|
||||
fun lower(module: IrModuleFragment) {
|
||||
module.files.forEach {
|
||||
fun lower() {
|
||||
context.irModule!!.files.forEach {
|
||||
lower(it)
|
||||
}
|
||||
}
|
||||
@@ -20,7 +20,6 @@ internal class KonanLower(val context: Context) {
|
||||
phaser.phase(KonanPhase.LOWER_BUILTIN_OPERATORS) {
|
||||
BuiltinOperatorLowering(context).runOnFilePostfix(irFile)
|
||||
}
|
||||
|
||||
phaser.phase(KonanPhase.LOWER_SHARED_VARIABLES) {
|
||||
SharedVariablesLowering(context).runOnFilePostfix(irFile)
|
||||
}
|
||||
|
||||
+13
-13
@@ -5,19 +5,19 @@ import org.jetbrains.kotlin.backend.konan.Context
|
||||
enum class KonanPhase(val description: String,
|
||||
var enabled: Boolean = true, var verbose: Boolean = false) {
|
||||
|
||||
BACKEND("All backend"), // TODO: it is unused
|
||||
OPTIMIZER("IR Optimizer"),
|
||||
LOWER_BUILTIN_OPERATORS("BuiltIn Operators Lowering"),
|
||||
LOWER_SHARED_VARIABLES("Shared Variable Lowering"),
|
||||
LOWER_LOCAL_FUNCTIONS("Local Function Lowering"),
|
||||
LOWER_CALLABLES("Callable references Lowering"),
|
||||
AUTOBOX("Autoboxing of primitive types"),
|
||||
LOWER("IR Lowering"), // TODO: it is unused
|
||||
BITCODE("LLVM BitCode Generation"),
|
||||
RTTI("RTTI Generation"),
|
||||
CODEGEN("Code Generation"),
|
||||
METADATOR("Metadata Generation"),
|
||||
LINKER("Link Stage");
|
||||
/* */ PSI_TO_IR("Psi to IR conversion"),
|
||||
/* */ BACKEND("All backend"),
|
||||
/* ... */ LOWER("IR Lowering"),
|
||||
/* ... ... */ LOWER_BUILTIN_OPERATORS("BuiltIn Operators Lowering"),
|
||||
/* ... ... */ LOWER_SHARED_VARIABLES("Shared Variable Lowering"),
|
||||
/* ... ... */ LOWER_LOCAL_FUNCTIONS("Local Function Lowering"),
|
||||
/* ... ... */ LOWER_CALLABLES("Callable references Lowering"),
|
||||
/* ... ... */ AUTOBOX("Autoboxing of primitive types"),
|
||||
/* ... */ BITCODE("LLVM BitCode Generation"),
|
||||
/* ... ... */ RTTI("RTTI Generation"),
|
||||
/* ... ... */ CODEGEN("Code Generation"),
|
||||
/* ... ... */ METADATOR("Metadata Generation"),
|
||||
/* */ LINKER("Link Stage");
|
||||
}
|
||||
|
||||
object KonanPhases {
|
||||
|
||||
Reference in New Issue
Block a user