feat: Zero registers via XOR

This commit is contained in:
Jonny 2025-02-26 21:39:23 +00:00
parent 09df7af2ab
commit 18534a64a6

View File

@ -73,7 +73,7 @@ object asmGenerator {
funcPrologue(),
Chain.one(stack.align()),
main.foldMap(generateStmt(_)),
Chain.one(Move(RAX, ImmediateVal(0))),
Chain.one(Xor(RAX, RAX)),
funcEpilogue(),
generateBuiltInFuncs(),
funcs.foldMap(generateUserFunc(_))
@ -143,7 +143,7 @@ object asmGenerator {
Chain(
stack.align(),
assemblyIR.Call(CLibFunc.PrintF),
Move(RDI, ImmediateVal(0)),
Xor(RDI, RDI),
assemblyIR.Call(CLibFunc.Fflush)
)
)
@ -293,7 +293,10 @@ object asmGenerator {
case _ => // Other array types TODO
}
case BoolLiter(v) => chain += stack.push(ImmediateVal(if (v) 1 else 0))
case BoolLiter(true) => chain += stack.push(ImmediateVal(1))
case BoolLiter(false) =>
chain += Xor(RAX, RAX)
chain += stack.push(RAX)
case NullLiter() => chain += stack.push(ImmediateVal(0))
case ArrayElem(_, _) => // TODO: Implement handling
case UnaryOp(x, op) =>