diff --git a/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/driver/phases/Lowerings.kt b/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/driver/phases/Lowerings.kt index a8b9dc284f9..ba7e0da9565 100644 --- a/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/driver/phases/Lowerings.kt +++ b/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/driver/phases/Lowerings.kt @@ -62,7 +62,7 @@ internal val modulePhaseActions: Set( +internal val functionsWithoutBoundCheck = createSimpleNamedCompilerPhase( name = "FunctionsWithoutBoundCheckGenerator", description = "Functions without bounds check generation", op = { context, _ -> FunctionsWithoutBoundCheckGenerator(context).generate() } @@ -256,7 +256,7 @@ private val forLoopsPhase = createFileLoweringPhase( }, name = "ForLoops", description = "For loops lowering", - prerequisite = setOf(FunctionsWithoutBoundCheck) + prerequisite = setOf(functionsWithoutBoundCheck) ) private val dataClassesPhase = createFileLoweringPhase( @@ -420,7 +420,7 @@ internal val UnboxInlinePhase = createFileLoweringPhase( lowering = ::UnboxInlineLowering, ) -private val InlinePhase = createFileLoweringPhase( +private val inlinePhase = createFileLoweringPhase( lowering = { context: NativeGenerationState -> object : FileLoweringPass { override fun lower(irFile: IrFile) { @@ -433,27 +433,27 @@ private val InlinePhase = createFileLoweringPhase( // prerequisite = setOf(lowerBeforeInlinePhase, arrayConstructorPhase, extractLocalClassesFromInlineBodies) ) -private val DelegationPhase = createFileLoweringPhase( +private val delegationPhase = createFileLoweringPhase( lowering = ::PropertyDelegationLowering, name = "Delegation", description = "Delegation lowering" // prerequisite = setOf(volatilePhase) ) -private val FunctionReferencePhase = createFileLoweringPhase( +private val functionReferencePhase = createFileLoweringPhase( lowering = ::FunctionReferenceLowering, name = "FunctionReference", description = "Function references lowering", // prerequisite = setOf(delegationPhase, localFunctionsPhase) // TODO: make weak dependency on `testProcessorPhase` ) -private val InventNamesForLocalClasses = createFileLoweringPhase( +private val inventNamesForLocalClasses = createFileLoweringPhase( lowering = ::NativeInventNamesForLocalClasses, name = "InventNamesForLocalClasses", description = "Invent names for local classes and anonymous objects", ) -private val UseInternalAbiPhase = createSimpleNamedCompilerPhase( +private val useInternalAbiPhase = createSimpleNamedCompilerPhase( name = "UseInternalAbi", description = "Use internal ABI functions to access private entities", outputIfNotEnabled = { _, _, _, irFile -> irFile }, @@ -463,13 +463,13 @@ private val UseInternalAbiPhase = createSimpleNamedCompilerPhase object : FileLoweringPass { override fun lower(irFile: IrFile) { @@ -485,7 +485,7 @@ private val CoroutinesPhase = createFileLoweringPhase( // prerequisite = setOf(localFunctionsPhase, finallyBlocksPhase, kotlinNothingValueExceptionPhase) ) -private val InteropPhase = createFileLoweringPhase( +private val interopPhase = createFileLoweringPhase( lowering = ::InteropLowering, name = "Interop", description = "Interop lowering", @@ -499,10 +499,10 @@ private fun PhaseEngine.getAllLowerings() = listOfNotNull arrayConstructorPhase, lateinitPhase, sharedVariablesPhase, - InventNamesForLocalClasses, + inventNamesForLocalClasses, extractLocalClassesFromInlineBodies, wrapInlineDeclarationsWithReifiedTypeParametersLowering, - InlinePhase, + inlinePhase, provisionalFunctionExpressionPhase, postInlinePhase, contractsDslRemovePhase, @@ -524,45 +524,29 @@ private fun PhaseEngine.getAllLowerings() = listOfNotNull dataClassesPhase, ifNullExpressionsFusionPhase, testProcessorPhase.takeIf { context.config.configuration.getNotNull(KonanConfigKeys.GENERATE_TEST_RUNNER) != TestRunnerKind.NONE }, - DelegationPhase, - FunctionReferencePhase, + delegationPhase, + functionReferencePhase, singleAbstractMethodPhase, enumWhenPhase, builtinOperatorPhase, finallyBlocksPhase, enumClassPhase, enumUsagePhase, - InteropPhase, + interopPhase, varargPhase, kotlinNothingValueExceptionPhase, - CoroutinesPhase, + coroutinesPhase, typeOperatorPhase, expressionBodyTransformPhase, - ObjectClassesPhase, + objectClassesPhase, constantInliningPhase, staticInitializersPhase, bridgesPhase, exportInternalAbiPhase.takeIf { context.config.produce.isCache }, - UseInternalAbiPhase, + useInternalAbiPhase, autoboxPhase, ) -/** - * Simplify porting of lowerings from static driver (where lowerings were executed in one big Context) - * to dynamic with NativeGenerationState. It can be done manual rewriting, but it is an enormous work. - */ -private fun PhaseEngine.convertToNativeGeneration( - phase: SameTypeNamedCompilerPhase, -): SimpleNamedCompilerPhase { - return createSimpleNamedCompilerPhase( - phase.name, - phase.description, - postactions = fileLoweringActions, - outputIfNotEnabled = { _, _, _, irFile -> irFile }, - op = { context, irFile -> phase.phaseBody(phaseConfig, phaserState.changePhaserStateType(), context.context, irFile) } - ) -} - private fun createFileLoweringPhase( name: String, description: String, diff --git a/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/driver/phases/TopLevelPhases.kt b/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/driver/phases/TopLevelPhases.kt index b2f3e17ee1e..42ebafa350e 100644 --- a/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/driver/phases/TopLevelPhases.kt +++ b/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/driver/phases/TopLevelPhases.kt @@ -9,7 +9,6 @@ import org.jetbrains.kotlin.backend.konan.* import org.jetbrains.kotlin.backend.konan.driver.PhaseContext import org.jetbrains.kotlin.backend.konan.driver.PhaseEngine import org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment -import org.jetbrains.kotlin.ir.declarations.IrFile import org.jetbrains.kotlin.ir.declarations.IrClass import org.jetbrains.kotlin.ir.declarations.IrDeclaration import org.jetbrains.kotlin.ir.declarations.IrModuleFragment @@ -51,7 +50,7 @@ internal fun PhaseEngine.runPsiToIr( internal fun PhaseEngine.runBackend(backendContext: Context, irModule: IrModuleFragment) { useContext(backendContext) { backendEngine -> - backendEngine.runPhase(FunctionsWithoutBoundCheck) + backendEngine.runPhase(functionsWithoutBoundCheck) val fragments = backendEngine.splitIntoFragments(irModule) fragments.forEach { (generationState, fragment) -> backendEngine.useContext(generationState) { generationStateEngine ->