[K/N] Support prerequisites in phase builders
This commit is contained in:
committed by
Space Team
parent
32a265a7eb
commit
fafa2b1a67
+3
-1
@@ -232,11 +232,13 @@ private fun PhaseEngine<NativeGenerationState>.convertToNativeGeneration(
|
|||||||
private fun createFileLoweringPhase(
|
private fun createFileLoweringPhase(
|
||||||
name: String,
|
name: String,
|
||||||
description: String,
|
description: String,
|
||||||
lowering: (NativeGenerationState) -> FileLoweringPass
|
lowering: (NativeGenerationState) -> FileLoweringPass,
|
||||||
|
prerequisite: Set<AbstractNamedCompilerPhase<*, *, *>> = emptySet(),
|
||||||
): SimpleNamedCompilerPhase<NativeGenerationState, IrFile, IrFile> = createSimpleNamedCompilerPhase(
|
): SimpleNamedCompilerPhase<NativeGenerationState, IrFile, IrFile> = createSimpleNamedCompilerPhase(
|
||||||
name,
|
name,
|
||||||
description,
|
description,
|
||||||
postactions = fileLoweringActions,
|
postactions = fileLoweringActions,
|
||||||
|
prerequisite = prerequisite,
|
||||||
outputIfNotEnabled = { _, _, _, irFile -> irFile },
|
outputIfNotEnabled = { _, _, _, irFile -> irFile },
|
||||||
op = { context, irFile ->
|
op = { context, irFile ->
|
||||||
lowering(context).lower(irFile)
|
lowering(context).lower(irFile)
|
||||||
|
|||||||
+4
@@ -13,6 +13,7 @@ internal fun <Context : LoggingContext, Input, Output> createSimpleNamedCompiler
|
|||||||
description: String,
|
description: String,
|
||||||
preactions: Set<Action<Input, Context>> = emptySet(),
|
preactions: Set<Action<Input, Context>> = emptySet(),
|
||||||
postactions: Set<Action<Output, Context>> = emptySet(),
|
postactions: Set<Action<Output, Context>> = emptySet(),
|
||||||
|
prerequisite: Set<AbstractNamedCompilerPhase<*, *, *>> = emptySet(),
|
||||||
outputIfNotEnabled: (PhaseConfigurationService, PhaserState<Input>, Context, Input) -> Output,
|
outputIfNotEnabled: (PhaseConfigurationService, PhaserState<Input>, Context, Input) -> Output,
|
||||||
op: (Context, Input) -> Output
|
op: (Context, Input) -> Output
|
||||||
): SimpleNamedCompilerPhase<Context, Input, Output> = object : SimpleNamedCompilerPhase<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 ->
|
postactions = postactions.map { f ->
|
||||||
fun(actionState: ActionState, data: Pair<Input, Output>, context: Context) = f(actionState, data.second, context)
|
fun(actionState: ActionState, data: Pair<Input, Output>, context: Context) = f(actionState, data.second, context)
|
||||||
}.toSet(),
|
}.toSet(),
|
||||||
|
prerequisite = prerequisite,
|
||||||
) {
|
) {
|
||||||
override fun outputIfNotEnabled(phaseConfig: PhaseConfigurationService, phaserState: PhaserState<Input>, context: Context, input: Input): Output =
|
override fun outputIfNotEnabled(phaseConfig: PhaseConfigurationService, phaserState: PhaserState<Input>, context: Context, input: Input): Output =
|
||||||
outputIfNotEnabled(phaseConfig, phaserState, context, input)
|
outputIfNotEnabled(phaseConfig, phaserState, context, input)
|
||||||
@@ -35,6 +37,7 @@ internal fun <Context : LoggingContext, Input> createSimpleNamedCompilerPhase(
|
|||||||
description: String,
|
description: String,
|
||||||
preactions: Set<Action<Input, Context>> = emptySet(),
|
preactions: Set<Action<Input, Context>> = emptySet(),
|
||||||
postactions: Set<Action<Input, Context>> = emptySet(),
|
postactions: Set<Action<Input, Context>> = emptySet(),
|
||||||
|
prerequisite: Set<AbstractNamedCompilerPhase<*, *, *>> = emptySet(),
|
||||||
op: (Context, Input) -> Unit
|
op: (Context, Input) -> Unit
|
||||||
): SimpleNamedCompilerPhase<Context, Input, Unit> = object : SimpleNamedCompilerPhase<Context, Input, Unit>(
|
): SimpleNamedCompilerPhase<Context, Input, Unit> = object : SimpleNamedCompilerPhase<Context, Input, Unit>(
|
||||||
name,
|
name,
|
||||||
@@ -43,6 +46,7 @@ internal fun <Context : LoggingContext, Input> createSimpleNamedCompilerPhase(
|
|||||||
postactions = postactions.map { f ->
|
postactions = postactions.map { f ->
|
||||||
fun(actionState: ActionState, data: Pair<Input, Unit>, context: Context) = f(actionState, data.first, context)
|
fun(actionState: ActionState, data: Pair<Input, Unit>, context: Context) = f(actionState, data.first, context)
|
||||||
}.toSet(),
|
}.toSet(),
|
||||||
|
prerequisite = prerequisite,
|
||||||
) {
|
) {
|
||||||
override fun outputIfNotEnabled(phaseConfig: PhaseConfigurationService, phaserState: PhaserState<Input>, context: Context, input: Input) {}
|
override fun outputIfNotEnabled(phaseConfig: PhaseConfigurationService, phaserState: PhaserState<Input>, context: Context, input: Input) {}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user