564 lines
7.3 KiB
ArmAsm
564 lines
7.3 KiB
ArmAsm
.file "21_union_find.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 find
|
|
.type find, @function
|
|
find:
|
|
addi sp,sp,-48
|
|
sd s0,32(sp)
|
|
sd s1,24(sp)
|
|
lla s0,parent
|
|
slli s1,a0,2
|
|
add a5,s0,s1
|
|
lw a5,0(a5)
|
|
sd ra,40(sp)
|
|
sd s2,16(sp)
|
|
sd s3,8(sp)
|
|
sd s4,0(sp)
|
|
bne a5,a0,.L8
|
|
ld ra,40(sp)
|
|
ld s0,32(sp)
|
|
ld s1,24(sp)
|
|
ld s2,16(sp)
|
|
ld s3,8(sp)
|
|
ld s4,0(sp)
|
|
addi sp,sp,48
|
|
jr ra
|
|
.L8:
|
|
slli s2,a5,2
|
|
add a4,s0,s2
|
|
lw a0,0(a4)
|
|
beq a5,a0,.L3
|
|
slli s3,a0,2
|
|
add a5,s0,s3
|
|
lw a5,0(a5)
|
|
bne a0,a5,.L9
|
|
.L4:
|
|
add s2,s0,s2
|
|
sw a5,0(s2)
|
|
mv a0,a5
|
|
.L3:
|
|
add s0,s0,s1
|
|
ld ra,40(sp)
|
|
sw a0,0(s0)
|
|
ld s0,32(sp)
|
|
ld s1,24(sp)
|
|
ld s2,16(sp)
|
|
ld s3,8(sp)
|
|
ld s4,0(sp)
|
|
addi sp,sp,48
|
|
jr ra
|
|
.L9:
|
|
slli s4,a5,2
|
|
add s4,s0,s4
|
|
lw a0,0(s4)
|
|
beq a5,a0,.L5
|
|
call find
|
|
sw a0,0(s4)
|
|
.L5:
|
|
add s3,s0,s3
|
|
sw a0,0(s3)
|
|
mv a5,a0
|
|
j .L4
|
|
.size find, .-find
|
|
.align 1
|
|
.globl merge
|
|
.type merge, @function
|
|
merge:
|
|
addi sp,sp,-112
|
|
sd s0,96(sp)
|
|
sd s2,80(sp)
|
|
lla s0,parent
|
|
slli s2,a0,2
|
|
add a5,s0,s2
|
|
sd s1,88(sp)
|
|
lw s1,0(a5)
|
|
sd ra,104(sp)
|
|
sd s3,72(sp)
|
|
sd s4,64(sp)
|
|
sd s5,56(sp)
|
|
sd s6,48(sp)
|
|
sd s7,40(sp)
|
|
sd s8,32(sp)
|
|
sd s9,24(sp)
|
|
bne a0,s1,.L29
|
|
.L11:
|
|
slli s2,a1,2
|
|
add a5,s0,s2
|
|
lw a5,0(a5)
|
|
bne a1,a5,.L30
|
|
.L19:
|
|
beq a5,s1,.L10
|
|
slli a5,a5,2
|
|
add s0,s0,a5
|
|
sw s1,0(s0)
|
|
.L10:
|
|
ld ra,104(sp)
|
|
ld s0,96(sp)
|
|
ld s1,88(sp)
|
|
ld s2,80(sp)
|
|
ld s3,72(sp)
|
|
ld s4,64(sp)
|
|
ld s5,56(sp)
|
|
ld s6,48(sp)
|
|
ld s7,40(sp)
|
|
ld s8,32(sp)
|
|
ld s9,24(sp)
|
|
addi sp,sp,112
|
|
jr ra
|
|
.L30:
|
|
slli s3,a5,2
|
|
add a4,s0,s3
|
|
lw a4,0(a4)
|
|
beq a5,a4,.L20
|
|
slli s4,a4,2
|
|
add a5,s0,s4
|
|
lw a5,0(a5)
|
|
bne a4,a5,.L31
|
|
.L21:
|
|
add s3,s0,s3
|
|
sw a5,0(s3)
|
|
mv a4,a5
|
|
.L20:
|
|
add s2,s0,s2
|
|
sw a4,0(s2)
|
|
mv a5,a4
|
|
j .L19
|
|
.L29:
|
|
slli s3,s1,2
|
|
add a5,s0,s3
|
|
lw a5,0(a5)
|
|
beq s1,a5,.L12
|
|
slli s1,a5,2
|
|
add a4,s0,s1
|
|
lw a4,0(a4)
|
|
bne a5,a4,.L32
|
|
.L13:
|
|
add s3,s0,s3
|
|
sw a4,0(s3)
|
|
mv a5,a4
|
|
.L12:
|
|
add s2,s0,s2
|
|
sw a5,0(s2)
|
|
mv s1,a5
|
|
j .L11
|
|
.L32:
|
|
slli s4,a4,2
|
|
add a5,s0,s4
|
|
lw a5,0(a5)
|
|
beq a4,a5,.L14
|
|
slli s5,a5,2
|
|
add a4,s0,s5
|
|
lw a4,0(a4)
|
|
bne a5,a4,.L33
|
|
.L15:
|
|
add s4,s0,s4
|
|
sw a4,0(s4)
|
|
mv a5,a4
|
|
.L14:
|
|
add s1,s0,s1
|
|
sw a5,0(s1)
|
|
mv a4,a5
|
|
j .L13
|
|
.L31:
|
|
slli s5,a5,2
|
|
add a4,s0,s5
|
|
lw a4,0(a4)
|
|
beq a5,a4,.L22
|
|
slli s6,a4,2
|
|
add a5,s0,s6
|
|
lw a5,0(a5)
|
|
bne a4,a5,.L34
|
|
.L23:
|
|
add s5,s0,s5
|
|
sw a5,0(s5)
|
|
mv a4,a5
|
|
.L22:
|
|
add s4,s0,s4
|
|
sw a4,0(s4)
|
|
mv a5,a4
|
|
j .L21
|
|
.L34:
|
|
slli s7,a5,2
|
|
add a4,s0,s7
|
|
lw a4,0(a4)
|
|
beq a5,a4,.L24
|
|
slli s8,a4,2
|
|
add a5,s0,s8
|
|
lw a5,0(a5)
|
|
beq a4,a5,.L25
|
|
slli s9,a5,2
|
|
add s9,s0,s9
|
|
lw a0,0(s9)
|
|
beq a5,a0,.L26
|
|
call find
|
|
sw a0,0(s9)
|
|
.L26:
|
|
add s8,s0,s8
|
|
sw a0,0(s8)
|
|
mv a5,a0
|
|
.L25:
|
|
add s7,s0,s7
|
|
sw a5,0(s7)
|
|
mv a4,a5
|
|
.L24:
|
|
add s6,s0,s6
|
|
sw a4,0(s6)
|
|
mv a5,a4
|
|
j .L23
|
|
.L33:
|
|
slli s6,a4,2
|
|
add a5,s0,s6
|
|
lw a5,0(a5)
|
|
beq a4,a5,.L16
|
|
slli s7,a5,2
|
|
add a4,s0,s7
|
|
lw a4,0(a4)
|
|
beq a5,a4,.L17
|
|
slli s8,a4,2
|
|
add s8,s0,s8
|
|
lw a0,0(s8)
|
|
beq a4,a0,.L18
|
|
sd a1,8(sp)
|
|
call find
|
|
ld a1,8(sp)
|
|
sw a0,0(s8)
|
|
.L18:
|
|
add s7,s0,s7
|
|
sw a0,0(s7)
|
|
mv a4,a0
|
|
.L17:
|
|
add s6,s0,s6
|
|
sw a4,0(s6)
|
|
mv a5,a4
|
|
.L16:
|
|
add s5,s0,s5
|
|
sw a5,0(s5)
|
|
mv a4,a5
|
|
j .L15
|
|
.size merge, .-merge
|
|
.section .text.startup,"ax",@progbits
|
|
.align 1
|
|
.globl main
|
|
.type main, @function
|
|
main:
|
|
addi sp,sp,-144
|
|
sd ra,136(sp)
|
|
sd s4,96(sp)
|
|
sd s7,72(sp)
|
|
sd s0,128(sp)
|
|
sd s1,120(sp)
|
|
sd s2,112(sp)
|
|
sd s3,104(sp)
|
|
sd s5,88(sp)
|
|
sd s6,80(sp)
|
|
sd s8,64(sp)
|
|
sd s9,56(sp)
|
|
sd s10,48(sp)
|
|
sd s11,40(sp)
|
|
call getint@plt
|
|
mv s7,a0
|
|
call getint@plt
|
|
mv s4,a0
|
|
ble s7,zero,.L36
|
|
lla s0,parent
|
|
mv a4,s0
|
|
li a5,0
|
|
.L37:
|
|
sw a5,0(a4)
|
|
addiw a5,a5,1
|
|
addi a4,a4,4
|
|
bne s7,a5,.L37
|
|
ble s4,zero,.L42
|
|
.L41:
|
|
li s6,0
|
|
.L40:
|
|
call getint@plt
|
|
slli s5,a0,2
|
|
mv s3,a0
|
|
call getint@plt
|
|
add a5,s0,s5
|
|
lw s1,0(a5)
|
|
mv s2,a0
|
|
beq s3,s1,.L43
|
|
slli s3,s1,2
|
|
add a5,s0,s3
|
|
lw a5,0(a5)
|
|
beq s1,a5,.L44
|
|
slli s1,a5,2
|
|
add a4,s0,s1
|
|
lw a4,0(a4)
|
|
beq a5,a4,.L45
|
|
slli s8,a4,2
|
|
add a5,s0,s8
|
|
lw a5,0(a5)
|
|
bne a4,a5,.L74
|
|
.L46:
|
|
add s1,s0,s1
|
|
sw a4,0(s1)
|
|
.L45:
|
|
add s3,s0,s3
|
|
sw a4,0(s3)
|
|
mv a5,a4
|
|
.L44:
|
|
add s5,s0,s5
|
|
sw a5,0(s5)
|
|
mv s1,a5
|
|
.L43:
|
|
slli s3,s2,2
|
|
add a5,s0,s3
|
|
lw a5,0(a5)
|
|
beq s2,a5,.L53
|
|
slli s2,a5,2
|
|
add a4,s0,s2
|
|
lw a4,0(a4)
|
|
beq a5,a4,.L54
|
|
slli s5,a4,2
|
|
add a5,s0,s5
|
|
lw a5,0(a5)
|
|
beq a4,a5,.L55
|
|
slli s8,a5,2
|
|
add a4,s0,s8
|
|
lw a4,0(a4)
|
|
bne a5,a4,.L75
|
|
.L56:
|
|
add s5,s0,s5
|
|
sw a5,0(s5)
|
|
.L55:
|
|
add s2,s0,s2
|
|
sw a5,0(s2)
|
|
mv a4,a5
|
|
.L54:
|
|
add s3,s0,s3
|
|
sw a4,0(s3)
|
|
mv a5,a4
|
|
.L53:
|
|
beq a5,s1,.L63
|
|
slli a5,a5,2
|
|
add a5,s0,a5
|
|
sw s1,0(a5)
|
|
.L63:
|
|
addiw s6,s6,1
|
|
bgt s4,s6,.L40
|
|
ble s7,zero,.L39
|
|
.L42:
|
|
lla a4,parent
|
|
li a0,0
|
|
li a5,0
|
|
.L65:
|
|
lw a3,0(a4)
|
|
addi a4,a4,4
|
|
bne a3,a5,.L64
|
|
addiw a0,a0,1
|
|
.L64:
|
|
addiw a5,a5,1
|
|
bne s7,a5,.L65
|
|
.L66:
|
|
call putint@plt
|
|
ld ra,136(sp)
|
|
ld s0,128(sp)
|
|
ld s1,120(sp)
|
|
ld s2,112(sp)
|
|
ld s3,104(sp)
|
|
ld s4,96(sp)
|
|
ld s5,88(sp)
|
|
ld s6,80(sp)
|
|
ld s7,72(sp)
|
|
ld s8,64(sp)
|
|
ld s9,56(sp)
|
|
ld s10,48(sp)
|
|
ld s11,40(sp)
|
|
li a0,0
|
|
addi sp,sp,144
|
|
jr ra
|
|
.L75:
|
|
slli s9,a4,2
|
|
add a5,s0,s9
|
|
lw a5,0(a5)
|
|
beq a4,a5,.L57
|
|
slli s10,a5,2
|
|
add a4,s0,s10
|
|
lw a4,0(a4)
|
|
bne a5,a4,.L76
|
|
.L58:
|
|
add s9,s0,s9
|
|
sw a4,0(s9)
|
|
mv a5,a4
|
|
.L57:
|
|
add s8,s0,s8
|
|
sw a5,0(s8)
|
|
j .L56
|
|
.L74:
|
|
slli s9,a5,2
|
|
add a4,s0,s9
|
|
lw a4,0(a4)
|
|
beq a5,a4,.L47
|
|
slli s10,a4,2
|
|
add a5,s0,s10
|
|
lw a5,0(a5)
|
|
bne a4,a5,.L77
|
|
.L48:
|
|
add s9,s0,s9
|
|
sw a5,0(s9)
|
|
mv a4,a5
|
|
.L47:
|
|
add s8,s0,s8
|
|
sw a4,0(s8)
|
|
j .L46
|
|
.L77:
|
|
slli s11,a5,2
|
|
add a4,s0,s11
|
|
lw a4,0(a4)
|
|
beq a5,a4,.L49
|
|
slli a3,a4,2
|
|
add a5,s0,a3
|
|
lw a5,0(a5)
|
|
bne a4,a5,.L78
|
|
.L50:
|
|
add s11,s0,s11
|
|
sw a5,0(s11)
|
|
mv a4,a5
|
|
.L49:
|
|
add s10,s0,s10
|
|
sw a4,0(s10)
|
|
mv a5,a4
|
|
j .L48
|
|
.L76:
|
|
slli s11,a4,2
|
|
add a5,s0,s11
|
|
lw a5,0(a5)
|
|
beq a4,a5,.L59
|
|
slli a3,a5,2
|
|
add a4,s0,a3
|
|
lw a4,0(a4)
|
|
bne a5,a4,.L79
|
|
.L60:
|
|
add s11,s0,s11
|
|
sw a4,0(s11)
|
|
mv a5,a4
|
|
.L59:
|
|
add s10,s0,s10
|
|
sw a5,0(s10)
|
|
mv a4,a5
|
|
j .L58
|
|
.L39:
|
|
li a0,0
|
|
j .L66
|
|
.L36:
|
|
ble a0,zero,.L39
|
|
lla s0,parent
|
|
j .L41
|
|
.L79:
|
|
slli a2,a4,2
|
|
add a5,s0,a2
|
|
lw a5,0(a5)
|
|
beq a4,a5,.L61
|
|
slli a4,a5,2
|
|
add a1,s0,a4
|
|
lw a0,0(a1)
|
|
sd a4,24(sp)
|
|
beq a5,a0,.L62
|
|
sd a2,16(sp)
|
|
sd a3,8(sp)
|
|
call find
|
|
ld a4,24(sp)
|
|
ld a2,16(sp)
|
|
ld a3,8(sp)
|
|
add a4,s0,a4
|
|
sw a0,0(a4)
|
|
.L62:
|
|
add a2,s0,a2
|
|
sw a0,0(a2)
|
|
mv a5,a0
|
|
.L61:
|
|
add a3,s0,a3
|
|
sw a5,0(a3)
|
|
mv a4,a5
|
|
j .L60
|
|
.L78:
|
|
slli a2,a5,2
|
|
add a4,s0,a2
|
|
lw a4,0(a4)
|
|
beq a5,a4,.L51
|
|
slli a5,a4,2
|
|
add a1,s0,a5
|
|
lw a0,0(a1)
|
|
sd a5,24(sp)
|
|
beq a4,a0,.L52
|
|
sd a2,16(sp)
|
|
sd a3,8(sp)
|
|
call find
|
|
ld a5,24(sp)
|
|
ld a2,16(sp)
|
|
ld a3,8(sp)
|
|
add a5,s0,a5
|
|
sw a0,0(a5)
|
|
.L52:
|
|
add a2,s0,a2
|
|
sw a0,0(a2)
|
|
mv a4,a0
|
|
.L51:
|
|
add a3,s0,a3
|
|
sw a4,0(a3)
|
|
mv a5,a4
|
|
j .L50
|
|
.size main, .-main
|
|
.globl parent
|
|
.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
|
|
.type parent, @object
|
|
.size parent, 4020
|
|
parent:
|
|
.zero 4020
|
|
.type _sysy_idx, @object
|
|
.size _sysy_idx, 4
|
|
_sysy_idx:
|
|
.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
|