ack/mach/powerpc/libem/exg.s
George Koehler 504d2aa34e Revise stack shuffles and integer conversions in PowerPC ncg.
Allow asp 4, exg 4 to shuffle tokens without coercing them into
registers; but comment why dup 4, dup 8 coerce tokens into registers.

Allow dup, dus, exg with larger sizes; and add tests dup_e.e and
exg_e.e to check that dup 20, dus, exg 20 work as well in powerpc as
in i80 and i86.

Then powerpc failed to compile loc 2 loc 4 cuu in dup_e.e.  Revise the
integer conversions, so powerpc can compile and pass the test.
2017-12-09 18:57:10 -05:00

23 lines
443 B
ArmAsm

.sect .text
! Exchange top two values on stack.
! Stack: ( a b size -- b a )
.define .exg
.exg:
lwz r3, 0(sp) ! r3 = size
srwi r7, r3, 2
mtspr ctr, r7 ! ctr = size / 4
mr r4, sp ! r4 = pointer before value b
add r5, r4, r3 ! r5 = pointer before value a
! Loop to swap each pair of words.
1: lwzu r6, 4(r4)
lwzu r7, 4(r5)
stw r6, 0(r5)
stw r7, 0(r4)
bdnz 1b ! loop ctr times
addi sp, sp, 4 ! drop size from stack
blr