fix: zero-out sub-32 bit expressions
This commit is contained in:
parent
4ffe85be91
commit
82a3d6068b
@ -41,8 +41,6 @@ object asmGenerator {
|
||||
private val RCX = Register(Q64, CX)
|
||||
private val argRegs = List(DI, SI, DX, CX, R8, R9)
|
||||
|
||||
private val _8_BIT_MASK = 0xff
|
||||
|
||||
extension [T](chain: Chain[T])
|
||||
def +(item: T): Chain[T] = chain.append(item)
|
||||
|
||||
@ -378,6 +376,7 @@ object asmGenerator {
|
||||
}
|
||||
|
||||
assert(stack.size == stackSizeStart + 1)
|
||||
chain ++= zeroRest(MemLocation(stack.head.pointer, Q64), expr.ty.size)
|
||||
chain
|
||||
}
|
||||
|
||||
@ -419,7 +418,7 @@ object asmGenerator {
|
||||
|
||||
chain += Compare(destX, stack.head)
|
||||
chain += Set(Register(B8, AX), cond)
|
||||
chain += And(RAX, ImmediateVal(_8_BIT_MASK))
|
||||
chain ++= zeroRest(RAX, B8)
|
||||
chain += stack.drop()
|
||||
chain += stack.push(B8, RAX)
|
||||
|
||||
@ -442,6 +441,10 @@ object asmGenerator {
|
||||
}
|
||||
|
||||
private def stackAlign: AsmLine = And(Register(Q64, SP), ImmediateVal(-16))
|
||||
private def zeroRest(dest: Dest, size: Size): Chain[AsmLine] = size match {
|
||||
case Q64 | D32 => Chain.empty
|
||||
case _ => Chain.one(And(dest, ImmediateVal((1 << (size.toInt * 8)) - 1)))
|
||||
}
|
||||
|
||||
private val escapedCharsMapping = escapedChars.map { case (k, v) => v -> s"\\$k" }
|
||||
extension (s: String) {
|
||||
|
@ -93,14 +93,13 @@ class ParallelExamplesSpec extends AnyFlatSpec with BeforeAndAfterAll {
|
||||
"^.*wacc-examples/valid/function/nested_functions.*$",
|
||||
"^.*wacc-examples/valid/function/simple_functions.*$",
|
||||
// "^.*wacc-examples/valid/if.*$",
|
||||
"^.*wacc-examples/valid/IO/print.*$",
|
||||
// "^.*wacc-examples/valid/IO/print.*$",
|
||||
// "^.*wacc-examples/valid/IO/read.*$",
|
||||
"^.*wacc-examples/valid/IO/IOLoop.wacc.*$",
|
||||
// "^.*wacc-examples/valid/IO/IOSequence.wacc.*$",
|
||||
"^.*wacc-examples/valid/pairs.*$",
|
||||
// "^.*wacc-examples/valid/pairs.*$",
|
||||
"^.*wacc-examples/valid/runtimeErr.*$",
|
||||
// "^.*wacc-examples/valid/scope.*$",
|
||||
"^.*wacc-examples/valid/scope/printAllTypes.wacc$", // while we still don't have arrays implemented
|
||||
// "^.*wacc-examples/valid/sequence.*$",
|
||||
// "^.*wacc-examples/valid/variables.*$",
|
||||
// "^.*wacc-examples/valid/while.*$",
|
||||
|
Loading…
x
Reference in New Issue
Block a user