sysy-data/hidden_functional_c/asm/22_matrix_multiply.s

244 lines
3.5 KiB
ArmAsm

.file "22_matrix_multiply.sy"
.option pic
.attribute arch, "rv64i2p1_m2p0_a2p1_f2p2_d2p2_c2p0_zicsr2p0_zifencei2p0"
.attribute unaligned_access, 0
.attribute stack_align, 16
.text
.align 1
.globl matrix_multiply
.type matrix_multiply, @function
matrix_multiply:
lla a4,.LANCHOR0
lw a3,0(a4)
ble a3,zero,.L1
lw a5,4(a4)
lw t4,8(a4)
ble a5,zero,.L1
li a4,400
mul a3,a3,a4
lla t2,b
lla t1,a
slli a5,a5,2
lla t5,res
add t3,a5,t2
mul a4,t4,a4
add t0,a3,t1
add t6,a4,t2
.L4:
mv a0,t6
mv a6,t2
mv a7,t5
.L9:
ble t4,zero,.L8
lw a2,0(a7)
mv a4,a6
mv a3,t1
.L5:
lw a1,0(a3)
lw a5,0(a4)
addi a4,a4,400
addi a3,a3,4
mulw a5,a5,a1
addw a2,a5,a2
bne a4,a0,.L5
sw a2,0(a7)
.L8:
addi a6,a6,4
addi a7,a7,4
addi a0,a0,4
bne a6,t3,.L9
addi t1,t1,400
addi t5,t5,400
bne t1,t0,.L4
.L1:
ret
.size matrix_multiply, .-matrix_multiply
.section .text.startup,"ax",@progbits
.align 1
.globl main
.type main, @function
main:
addi sp,sp,-48
sd ra,40(sp)
sd s0,32(sp)
sd s3,8(sp)
lla s0,.LANCHOR0
sd s4,0(sp)
sd s1,24(sp)
sd s2,16(sp)
call getint@plt
sw a0,0(s0)
call getint@plt
lw a4,0(s0)
sw a0,8(s0)
mv a5,a0
lla s4,a
li s3,0
ble a4,zero,.L15
ble a5,zero,.L15
.L26:
mv s2,s4
li s1,0
.L16:
call getint@plt
lw a5,8(s0)
sw a0,0(s2)
addiw s1,s1,1
addi s2,s2,4
bgt a5,s1,.L16
lw a4,0(s0)
addiw s3,s3,1
ble a4,s3,.L15
addi s4,s4,400
bgt a5,zero,.L26
.L15:
call getint@plt
sw a0,12(s0)
call getint@plt
lw a4,12(s0)
sw a0,4(s0)
mv a5,a0
lla s4,b
li s3,0
ble a4,zero,.L19
ble a5,zero,.L19
.L27:
mv s2,s4
li s1,0
.L20:
call getint@plt
lw a5,4(s0)
sw a0,0(s2)
addiw s1,s1,1
addi s2,s2,4
bgt a5,s1,.L20
lw a4,12(s0)
addiw s3,s3,1
ble a4,s3,.L19
addi s4,s4,400
bgt a5,zero,.L27
.L19:
call matrix_multiply
lw a5,0(s0)
ble a5,zero,.L22
lla s4,res
li s3,0
.L23:
lw a5,4(s0)
mv s2,s4
li s1,0
ble a5,zero,.L25
.L24:
lw a0,0(s2)
addiw s1,s1,1
addi s2,s2,4
call putint@plt
li a0,32
call putch@plt
lw a5,4(s0)
bgt a5,s1,.L24
.L25:
li a0,10
call putch@plt
lw a5,0(s0)
addiw s3,s3,1
addi s4,s4,400
bgt a5,s3,.L23
.L22:
ld ra,40(sp)
ld s0,32(sp)
ld s1,24(sp)
ld s2,16(sp)
ld s3,8(sp)
ld s4,0(sp)
li a0,0
addi sp,sp,48
jr ra
.size main, .-main
.globl m2
.globl n2
.globl m1
.globl n1
.globl res
.globl b
.globl a
.globl _sysy_idx
.globl _sysy_us
.globl _sysy_s
.globl _sysy_m
.globl _sysy_h
.globl _sysy_l2
.globl _sysy_l1
.globl _sysy_end
.globl _sysy_start
.bss
.align 3
.set .LANCHOR0,. + 0
.type m1, @object
.size m1, 4
m1:
.zero 4
.type n2, @object
.size n2, 4
n2:
.zero 4
.type n1, @object
.size n1, 4
n1:
.zero 4
.type m2, @object
.size m2, 4
m2:
.zero 4
.type res, @object
.size res, 40000
res:
.zero 40000
.type b, @object
.size b, 40000
b:
.zero 40000
.type a, @object
.size a, 40000
a:
.zero 40000
.type _sysy_idx, @object
.size _sysy_idx, 4
_sysy_idx:
.zero 4
.zero 4
.type _sysy_us, @object
.size _sysy_us, 4096
_sysy_us:
.zero 4096
.type _sysy_s, @object
.size _sysy_s, 4096
_sysy_s:
.zero 4096
.type _sysy_m, @object
.size _sysy_m, 4096
_sysy_m:
.zero 4096
.type _sysy_h, @object
.size _sysy_h, 4096
_sysy_h:
.zero 4096
.type _sysy_l2, @object
.size _sysy_l2, 4096
_sysy_l2:
.zero 4096
.type _sysy_l1, @object
.size _sysy_l1, 4096
_sysy_l1:
.zero 4096
.type _sysy_end, @object
.size _sysy_end, 16
_sysy_end:
.zero 16
.type _sysy_start, @object
.size _sysy_start, 16
_sysy_start:
.zero 16
.ident "GCC: (Debian 12.2.0-13) 12.2.0"
.section .note.GNU-stack,"",@progbits