Commit 4ec587b4 authored by Eva Darulova's avatar Eva Darulova
Browse files

generating SSA forms for fixed-point arithmetic case

parent fed64c22
......@@ -162,10 +162,22 @@ object Main {
private def computePipeline(ctx: Context): Pipeline[Program, Program] = {
val fixedPointArith = ctx.findOption(analysis.RangeErrorPhase.optionPrecision) match {
case Some("Fixed16") => true
case Some("Fixed32") => true
case _ => false
}
// this is not ideal, using 'magic' strings
if (ctx.hasFlag("dynamic")) {
analysis.SpecsProcessingPhase andThen
analysis.DynamicPhase
} else if (ctx.hasFlag("codegen") && fixedPointArith) {
analysis.SpecsProcessingPhase andThen
transform.SSATransformerPhase andThen
analysis.RangeErrorPhase andThen
InfoPhase andThen
backend.CodeGenerationPhase
} else if (ctx.hasFlag("codegen")) {
analysis.SpecsProcessingPhase andThen
analysis.RangeErrorPhase andThen
......
......@@ -20,14 +20,17 @@ object RangeErrorPhase extends DaisyPhase with ErrorFunctions {
override val name = "range-error phase"
override val description = "Computes ranges and absolute errors"
val optionPrecision = ChoiceOptionDef("precision", "Type of precision to use",
Set("Float32", "Float64", "DoubleDouble", "QuadDouble",
"Fixed16", "Fixed32"), "Float64")
override val definedOptions: Set[CmdLineOptionDef[Any]] = Set(
ChoiceOptionDef("rangeMethod", "Method to use for range analysis",
Set("affine", "interval", "smt", "subdiv"), "interval"),
FlagOptionDef("noInitialErrors", "do not track initial errors specified by user"),
FlagOptionDef("noRoundoff", "do not track roundoff errors"),
ChoiceOptionDef("precision", "Type of precision to use",
Set("Float32", "Float64", "DoubleDouble", "QuadDouble",
"Fixed16", "Fixed32", "Fixed64"), "Float64")
optionPrecision
)
implicit val debugSection = DebugSectionAnalysis
......@@ -81,8 +84,6 @@ object RangeErrorPhase extends DaisyPhase with ErrorFunctions {
uniformPrecision = Fixed(16)
case "Fixed32" =>
uniformPrecision = Fixed(32)
case "Fixed64" =>
uniformPrecision = Fixed(64)
case _ =>
reporter.warning(s"Unknown precision specified: $s, choosing default ($uniformPrecision)!")
}
......
......@@ -35,7 +35,6 @@ object CodeGenerationPhase extends DaisyPhase {
case "QuadDouble" => uniformPrecision = QuadDouble
case "Fixed16" => uniformPrecision = Fixed(16)
case "Fixed32" => uniformPrecision = Fixed(32)
case "Fixed64" => uniformPrecision = Fixed(64)
case _ =>
ctx.reporter.warning(s"Unknown precision specified: $s, choosing default ($uniformPrecision)!")
}
......
......@@ -45,13 +45,19 @@ object SSATransformerPhase extends DaisyPhase {
val newBody = toSSA(fnc.body.get)
// TODO: probably can just use copy here
FunDef(fnc.id, fnc.returnType, fnc.params, fnc.precondition,
Some(newBody), fnc.postcondition, fnc.isField)
fnc.copy(body = Some(newBody))
} else {
fnc
})
println("Original program:")
println(prg)
println("\nNew program:")
println(lang.PrettyPrinter.withIDs(Program(prg.id, newDefs)))
timer.stop
reporter.info("Finished SSA transformation phase")
......@@ -91,6 +97,12 @@ object SSATransformerPhase extends DaisyPhase {
case (Let(id, v, b), _) =>
Let(id, v, merge(b, rhs, recons))
case (p1, Let(id, v, b)) if (isSimpleExpr(p1)) =>
val t1 = fresh()
Let(t1, p1,
Let(id, v,
merge(Variable(t1), b, recons)))
case (t: Terminal, Let(id, v, b)) if isSimpleExpr(b) =>
val t1 = fresh()
Let(id, v,
......@@ -117,8 +129,6 @@ object SSATransformerPhase extends DaisyPhase {
val t2 = fresh()
Let(t1, p1,
Let(t2, p2, recons(Seq(Variable(t1), Variable(t2)))))
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment