Fixed push and pop on arm64

This commit is contained in:
2025-03-13 17:20:11 +01:00
parent c1913d99d0
commit 5b3769a0db
2 changed files with 5 additions and 2 deletions

View File

@ -16,6 +16,7 @@ func TestSubRegisterNumber(t *testing.T) {
Code uint32
}{
{arm.X0, arm.X0, 1, 0xD1000400},
{arm.SP, arm.SP, 16, 0xD10043FF},
}
for _, pattern := range usagePatterns {

View File

@ -87,14 +87,16 @@ func (c *compiler) compileARM(x asm.Instruction) {
switch x.Type {
case asm.TypeRegister:
operand := c.assembler.Param.Register[x.Index]
c.append(arm.StorePair(operand.Register, operand.Register, arm.SP, -16))
c.append(arm.SubRegisterNumber(arm.SP, arm.SP, 16))
c.append(arm.StoreRegister(operand.Register, arm.SP, 0, 8))
}
case asm.POP:
switch x.Type {
case asm.TypeRegister:
operand := c.assembler.Param.Register[x.Index]
c.append(arm.LoadPair(operand.Register, operand.Register, arm.SP, 16))
c.append(arm.LoadRegister(operand.Register, arm.SP, 0, 8))
c.append(arm.AddRegisterNumber(arm.SP, arm.SP, 16))
}
case asm.ADD: