fix: only push one item to stack on comparisons
This commit is contained in:
parent
631f9ddca5
commit
2cf18a47a8
@ -317,12 +317,12 @@ object asmGenerator {
|
||||
chain += stack.drop()
|
||||
chain += stack.push(RDX)
|
||||
|
||||
case BinaryOperator.Eq => chain ++= generateComparison(x, y, Cond.Equal)
|
||||
case BinaryOperator.Neq => chain ++= generateComparison(x, y, Cond.NotEqual)
|
||||
case BinaryOperator.Greater => chain ++= generateComparison(x, y, Cond.Greater)
|
||||
case BinaryOperator.GreaterEq => chain ++= generateComparison(x, y, Cond.GreaterEqual)
|
||||
case BinaryOperator.Less => chain ++= generateComparison(x, y, Cond.Less)
|
||||
case BinaryOperator.LessEq => chain ++= generateComparison(x, y, Cond.LessEqual)
|
||||
case BinaryOperator.Eq => chain ++= generateComparison(Cond.Equal)
|
||||
case BinaryOperator.Neq => chain ++= generateComparison(Cond.NotEqual)
|
||||
case BinaryOperator.Greater => chain ++= generateComparison(Cond.Greater)
|
||||
case BinaryOperator.GreaterEq => chain ++= generateComparison(Cond.GreaterEqual)
|
||||
case BinaryOperator.Less => chain ++= generateComparison(Cond.Less)
|
||||
case BinaryOperator.LessEq => chain ++= generateComparison(Cond.LessEqual)
|
||||
case BinaryOperator.And => chain += And(stack.head(SizeDir.DWord), EAX)
|
||||
case BinaryOperator.Or => chain += Or(stack.head(SizeDir.DWord), EAX)
|
||||
}
|
||||
@ -367,18 +367,14 @@ object asmGenerator {
|
||||
chain
|
||||
}
|
||||
|
||||
def generateComparison(x: Expr, y: Expr, cond: Cond)(using
|
||||
def generateComparison(cond: Cond)(using
|
||||
stack: Stack,
|
||||
strings: ListBuffer[String],
|
||||
labelGenerator: LabelGenerator
|
||||
): Chain[AsmLine] = {
|
||||
|
||||
var chain = Chain.empty[AsmLine]
|
||||
|
||||
chain ++= evalExprOntoStack(x)
|
||||
chain ++= evalExprOntoStack(y)
|
||||
chain += stack.pop(RAX)
|
||||
chain += Compare(stack.head(SizeDir.DWord), EAX)
|
||||
chain += Compare(EAX, stack.head(SizeDir.DWord))
|
||||
chain += Set(Register(RegSize.Byte, RegName.AL), cond)
|
||||
chain += And(RAX, ImmediateVal(_8_BIT_MASK))
|
||||
chain += stack.drop()
|
||||
|
@ -126,6 +126,11 @@ object assemblyIR {
|
||||
override def toString = s"$name:"
|
||||
}
|
||||
|
||||
case class Comment(comment: String) extends AsmLine {
|
||||
override def toString =
|
||||
comment.split("\n").map(line => s"# ${line}").mkString("\n")
|
||||
}
|
||||
|
||||
enum Cond {
|
||||
case Equal,
|
||||
NotEqual,
|
||||
|
@ -102,7 +102,7 @@ class ParallelExamplesSpec extends AnyFlatSpec with BeforeAndAfterAll {
|
||||
"^.*wacc-examples/valid/scope.*$",
|
||||
// "^.*wacc-examples/valid/sequence.*$",
|
||||
// "^.*wacc-examples/valid/variables.*$",
|
||||
"^.*wacc-examples/valid/while.*$",
|
||||
// "^.*wacc-examples/valid/while.*$",
|
||||
// format: on
|
||||
).find(filename.matches).isDefined
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user