ba9b021253
Our libem had two implementations of loading a block from a stack, one for lar 4 and one for los 4. Now lar 4 and los 4 share the code in .los4. Likewise, sar 4 and sts 4 share the code in .sts4. Rename .los to .los4 and .sts to .sts4, because they implement los 4 and sts 4. Remove the special case for loading or storing 4 bytes, because we can do it with 1 iteration of the loop. Remove the lines to "align size" where the size must already be a multiple of 4. Fix the upper bound check in .aar4. Change .aar4, .lar4, .los4, .sar4, .sts4 to pass all operands on the real stack, except that .los4 and .sts4 take the size in register r3. Have .aar4 set r3 to the size of the array element. So lar 4 is just .aar4 then .los4, and sar 4 is just .aar4 then .sts4. ncg no longer calls .lar4 and .sar4 in libem, because it inlines the code; but I keep .lar4 and .sar4 in libem, because mcg references them. They might or might not work in mcg.
36 lines
666 B
ArmAsm
36 lines
666 B
ArmAsm
.sect .text
|
|
|
|
! Stores a variable-sized block from the stack.
|
|
!
|
|
! On entry: r3 = size
|
|
! Stack: ( block address -- )
|
|
! Preserves r10 for .sar4
|
|
|
|
.define .sts4
|
|
.sts4:
|
|
lwz r4, 0(sp) ! r4 = address
|
|
|
|
! Sizes 1 and 2 are handled specially.
|
|
cmplwi r3, 1
|
|
ble 1f
|
|
cmplwi r3, 2
|
|
ble 2f
|
|
|
|
! Else the size must be a multiple of 4.
|
|
srwi r5, r3, 2
|
|
mtspr ctr, r5 ! ctr = number of words
|
|
addi r4, r4, -4 ! adjust address to before block
|
|
4: lwzu r5, 4(sp)
|
|
stwu r5, 4(r4)
|
|
bdnz 4b ! decrement ctr, jump if non-zero
|
|
addi sp, sp, 4
|
|
blr
|
|
|
|
1: lwz r5, 4(sp)
|
|
stb r5, 0(r4)
|
|
b 3f
|
|
2: lwz r5, 4(sp)
|
|
sth r5, 0(r4)
|
|
3: addi sp, sp, 8
|
|
blr
|