IR: inline namedIrModulePhase and namedIrFilePhase phase builders

Construct NamedCompilerPhase directly instead. Only use phase builders
where the code becomes easier to read.
This commit is contained in:
Alexander Udalov
2020-07-01 02:55:04 +02:00
parent 15a969b3ba
commit 181965f6e8
6 changed files with 43 additions and 107 deletions
@@ -27,31 +27,20 @@ private fun makeWasmModulePhase(
name: String,
description: String,
prerequisite: Set<NamedCompilerPhase<WasmBackendContext, *>> = emptySet()
) = makeIrModulePhase(lowering, name, description, prerequisite, actions = setOf(validationAction, defaultDumper))
): NamedCompilerPhase<WasmBackendContext, IrModuleFragment> =
makeIrModulePhase(
lowering, name, description, prerequisite, actions = setOf(validationAction, defaultDumper)
)
private fun makeCustomWasmModulePhase(
op: (WasmBackendContext, IrModuleFragment) -> Unit,
description: String,
name: String,
prerequisite: Set<NamedCompilerPhase<WasmBackendContext, *>> = emptySet()
) = namedIrModulePhase(
name,
description,
prerequisite,
actions = setOf(defaultDumper, validationAction),
nlevels = 0,
lower = object : SameTypeCompilerPhase<WasmBackendContext, IrModuleFragment> {
override fun invoke(
phaseConfig: PhaseConfig,
phaserState: PhaserState<IrModuleFragment>,
context: WasmBackendContext,
input: IrModuleFragment
): IrModuleFragment {
op(context, input)
return input
}
}
)
): NamedCompilerPhase<WasmBackendContext, IrModuleFragment> =
makeCustomPhase(
op, name, description, prerequisite, actions = setOf(defaultDumper, validationAction), nlevels = 0,
)
private val validateIrBeforeLowering = makeCustomWasmModulePhase(
{ context, module -> validationCallback(context, module) },
@@ -351,7 +340,7 @@ private val objectUsageLoweringPhase = makeWasmModulePhase(
description = "Transform IrGetObjectValue into instance generator call"
)
val wasmPhases = namedIrModulePhase<WasmBackendContext>(
val wasmPhases = NamedCompilerPhase(
name = "IrModuleLowering",
description = "IR module lowering",
lower = validateIrBeforeLowering then