IR: do not use AnyNamedPhase where there is Context parameter

This commit is contained in:
Alexander Udalov
2020-07-01 01:56:05 +02:00
parent ef58f1e72e
commit 7997d4afd3
6 changed files with 23 additions and 23 deletions
@@ -28,7 +28,7 @@ inline fun <R, D> PhaserState<D>.downlevel(nlevels: Int, block: () -> R): R {
interface CompilerPhase<in Context : CommonBackendContext, Input, Output> {
fun invoke(phaseConfig: PhaseConfig, phaserState: PhaserState<Input>, context: Context, input: Input): Output
fun getNamedSubphases(startDepth: Int = 0): List<Pair<Int, AnyNamedPhase>> = emptyList()
fun getNamedSubphases(startDepth: Int = 0): List<Pair<Int, NamedCompilerPhase<Context, *>>> = emptyList()
// In phase trees, `stickyPostconditions` is inherited along the right edge to be used in `then`.
val stickyPostconditions: Set<Checker<Output>> get() = emptySet()
@@ -67,7 +67,7 @@ infix operator fun <Data, Context> Action<Data, Context>.plus(other: Action<Data
class NamedCompilerPhase<in Context : CommonBackendContext, Data>(
val name: String,
val description: String,
val prerequisite: Set<AnyNamedPhase>,
val prerequisite: Set<NamedCompilerPhase<Context, *>>,
private val lower: CompilerPhase<Context, Data, Data>,
val preconditions: Set<Checker<Data>> = emptySet(),
val postconditions: Set<Checker<Data>> = emptySet(),
@@ -136,7 +136,7 @@ class NamedCompilerPhase<in Context : CommonBackendContext, Data>(
return result!!
}
override fun getNamedSubphases(startDepth: Int): List<Pair<Int, NamedCompilerPhase<*, *>>> =
override fun getNamedSubphases(startDepth: Int): List<Pair<Int, NamedCompilerPhase<Context, *>>> =
listOf(startDepth to this) + lower.getNamedSubphases(startDepth + nlevels)
override fun toString() = "Compiler Phase @$name"
@@ -33,7 +33,7 @@ private class CompositePhase<Context : CommonBackendContext, Input, Output>(
return result as Output
}
override fun getNamedSubphases(startDepth: Int): List<Pair<Int, AnyNamedPhase>> =
override fun getNamedSubphases(startDepth: Int): List<Pair<Int, NamedCompilerPhase<Context, *>>> =
phases.flatMap { it.getNamedSubphases(startDepth) }
override val stickyPostconditions get() = phases.last().stickyPostconditions
@@ -51,7 +51,7 @@ infix fun <Context : CommonBackendContext, Input, Mid, Output> CompilerPhase<Con
fun <Context : CommonBackendContext> namedIrModulePhase(
name: String,
description: String,
prerequisite: Set<AnyNamedPhase> = emptySet(),
prerequisite: Set<NamedCompilerPhase<Context, *>> = emptySet(),
lower: CompilerPhase<Context, IrModuleFragment, IrModuleFragment>,
preconditions: Set<Checker<IrModuleFragment>> = emptySet(),
postconditions: Set<Checker<IrModuleFragment>> = emptySet(),
@@ -73,7 +73,7 @@ fun <Context : CommonBackendContext> namedIrModulePhase(
fun <Context : CommonBackendContext> namedIrFilePhase(
name: String,
description: String,
prerequisite: Set<AnyNamedPhase> = emptySet(),
prerequisite: Set<NamedCompilerPhase<Context, *>> = emptySet(),
lower: CompilerPhase<Context, IrFile, IrFile>,
preconditions: Set<Checker<IrFile>> = emptySet(),
postconditions: Set<Checker<IrFile>> = emptySet(),
@@ -96,7 +96,7 @@ fun <Context : CommonBackendContext, Element : IrElement> makeCustomPhase(
op: (Context, Element) -> Unit,
description: String,
name: String,
prerequisite: Set<AnyNamedPhase> = emptySet(),
prerequisite: Set<NamedCompilerPhase<Context, *>> = emptySet(),
preconditions: Set<Checker<Element>> = emptySet(),
postconditions: Set<Checker<Element>> = emptySet(),
stickyPostconditions: Set<Checker<Element>> = emptySet(),
@@ -127,7 +127,7 @@ fun <Context : CommonBackendContext, Element : IrElement> makeCustomPhase(
fun <Context : CommonBackendContext> namedUnitPhase(
name: String,
description: String,
prerequisite: Set<AnyNamedPhase> = emptySet(),
prerequisite: Set<NamedCompilerPhase<Context, *>> = emptySet(),
nlevels: Int = 1,
lower: CompilerPhase<Context, Unit, Unit>
) = NamedCompilerPhase(
@@ -140,7 +140,7 @@ fun <Context : CommonBackendContext> namedUnitPhase(
fun <Context : CommonBackendContext> namedOpUnitPhase(
name: String,
description: String,
prerequisite: Set<AnyNamedPhase>,
prerequisite: Set<NamedCompilerPhase<Context, *>>,
op: Context.() -> Unit
) = namedUnitPhase(
name, description, prerequisite,
@@ -155,7 +155,7 @@ fun <Context : CommonBackendContext> namedOpUnitPhase(
fun <Context : CommonBackendContext> performByIrFile(
name: String = "PerformByIrFile",
description: String = "Perform phases by IrFile",
prerequisite: Set<AnyNamedPhase> = emptySet(),
prerequisite: Set<NamedCompilerPhase<Context, *>> = emptySet(),
preconditions: Set<Checker<IrModuleFragment>> = emptySet(),
postconditions: Set<Checker<IrModuleFragment>> = emptySet(),
stickyPostconditions: Set<Checker<IrModuleFragment>> = emptySet(),
@@ -195,7 +195,7 @@ fun <Context : CommonBackendContext> makeIrFilePhase(
lowering: (Context) -> FileLoweringPass,
name: String,
description: String,
prerequisite: Set<AnyNamedPhase> = emptySet(),
prerequisite: Set<NamedCompilerPhase<Context, *>> = emptySet(),
preconditions: Set<Checker<IrFile>> = emptySet(),
postconditions: Set<Checker<IrFile>> = emptySet(),
stickyPostconditions: Set<Checker<IrFile>> = emptySet(),
@@ -219,7 +219,7 @@ fun <Context : CommonBackendContext> makeIrModulePhase(
lowering: (Context) -> FileLoweringPass,
name: String,
description: String,
prerequisite: Set<AnyNamedPhase> = emptySet(),
prerequisite: Set<NamedCompilerPhase<Context, *>> = emptySet(),
preconditions: Set<Checker<IrModuleFragment>> = emptySet(),
postconditions: Set<Checker<IrModuleFragment>> = emptySet(),
stickyPostconditions: Set<Checker<IrModuleFragment>> = emptySet(),