[K/N] Support prerequisites in phase builders

This commit is contained in:
Sergey Bogolepov
2023-01-24 15:00:23 +02:00
committed by Space Team
parent 32a265a7eb
commit fafa2b1a67
2 changed files with 7 additions and 1 deletions
@@ -232,11 +232,13 @@ private fun PhaseEngine<NativeGenerationState>.convertToNativeGeneration(
private fun createFileLoweringPhase(
name: String,
description: String,
lowering: (NativeGenerationState) -> FileLoweringPass
lowering: (NativeGenerationState) -> FileLoweringPass,
prerequisite: Set<AbstractNamedCompilerPhase<*, *, *>> = emptySet(),
): SimpleNamedCompilerPhase<NativeGenerationState, IrFile, IrFile> = createSimpleNamedCompilerPhase(
name,
description,
postactions = fileLoweringActions,
prerequisite = prerequisite,
outputIfNotEnabled = { _, _, _, irFile -> irFile },
op = { context, irFile ->
lowering(context).lower(irFile)
@@ -13,6 +13,7 @@ internal fun <Context : LoggingContext, Input, Output> createSimpleNamedCompiler
description: String,
preactions: Set<Action<Input, Context>> = emptySet(),
postactions: Set<Action<Output, Context>> = emptySet(),
prerequisite: Set<AbstractNamedCompilerPhase<*, *, *>> = emptySet(),
outputIfNotEnabled: (PhaseConfigurationService, PhaserState<Input>, Context, Input) -> Output,
op: (Context, Input) -> Output
): SimpleNamedCompilerPhase<Context, Input, Output> = object : SimpleNamedCompilerPhase<Context, Input, Output>(
@@ -22,6 +23,7 @@ internal fun <Context : LoggingContext, Input, Output> createSimpleNamedCompiler
postactions = postactions.map { f ->
fun(actionState: ActionState, data: Pair<Input, Output>, context: Context) = f(actionState, data.second, context)
}.toSet(),
prerequisite = prerequisite,
) {
override fun outputIfNotEnabled(phaseConfig: PhaseConfigurationService, phaserState: PhaserState<Input>, context: Context, input: Input): Output =
outputIfNotEnabled(phaseConfig, phaserState, context, input)
@@ -35,6 +37,7 @@ internal fun <Context : LoggingContext, Input> createSimpleNamedCompilerPhase(
description: String,
preactions: Set<Action<Input, Context>> = emptySet(),
postactions: Set<Action<Input, Context>> = emptySet(),
prerequisite: Set<AbstractNamedCompilerPhase<*, *, *>> = emptySet(),
op: (Context, Input) -> Unit
): SimpleNamedCompilerPhase<Context, Input, Unit> = object : SimpleNamedCompilerPhase<Context, Input, Unit>(
name,
@@ -43,6 +46,7 @@ internal fun <Context : LoggingContext, Input> createSimpleNamedCompilerPhase(
postactions = postactions.map { f ->
fun(actionState: ActionState, data: Pair<Input, Unit>, context: Context) = f(actionState, data.first, context)
}.toSet(),
prerequisite = prerequisite,
) {
override fun outputIfNotEnabled(phaseConfig: PhaseConfigurationService, phaserState: PhaserState<Input>, context: Context, input: Input) {}