218 lines
3.1 KiB
ArmAsm
218 lines
3.1 KiB
ArmAsm
|
.text
|
||
|
.attribute 4, 16
|
||
|
.attribute 5, "rv64i2p0_m2p0_a2p0_f2p0_d2p0_c2p0"
|
||
|
.file "21_union_find.sy"
|
||
|
.globl find
|
||
|
.p2align 1
|
||
|
.type find,@function
|
||
|
find:
|
||
|
addi sp, sp, -16
|
||
|
sd ra, 8(sp)
|
||
|
sd s0, 0(sp)
|
||
|
lui a1, %hi(parent)
|
||
|
addi a1, a1, %lo(parent)
|
||
|
slli a2, a0, 2
|
||
|
add s0, a2, a1
|
||
|
lw a1, 0(s0)
|
||
|
beq a1, a0, .LBB0_2
|
||
|
mv a0, a1
|
||
|
call find
|
||
|
sw a0, 0(s0)
|
||
|
.LBB0_2:
|
||
|
ld ra, 8(sp)
|
||
|
ld s0, 0(sp)
|
||
|
addi sp, sp, 16
|
||
|
ret
|
||
|
.Lfunc_end0:
|
||
|
.size find, .Lfunc_end0-find
|
||
|
|
||
|
.globl merge
|
||
|
.p2align 1
|
||
|
.type merge,@function
|
||
|
merge:
|
||
|
addi sp, sp, -32
|
||
|
sd ra, 24(sp)
|
||
|
sd s0, 16(sp)
|
||
|
sd s1, 8(sp)
|
||
|
mv s1, a1
|
||
|
call find
|
||
|
mv s0, a0
|
||
|
mv a0, s1
|
||
|
call find
|
||
|
beq s0, a0, .LBB1_2
|
||
|
lui a1, %hi(parent)
|
||
|
addi a1, a1, %lo(parent)
|
||
|
slli a0, a0, 2
|
||
|
add a0, a0, a1
|
||
|
sw s0, 0(a0)
|
||
|
.LBB1_2:
|
||
|
ld ra, 24(sp)
|
||
|
ld s0, 16(sp)
|
||
|
ld s1, 8(sp)
|
||
|
addi sp, sp, 32
|
||
|
ret
|
||
|
.Lfunc_end1:
|
||
|
.size merge, .Lfunc_end1-merge
|
||
|
|
||
|
.globl main
|
||
|
.p2align 1
|
||
|
.type main,@function
|
||
|
main:
|
||
|
addi sp, sp, -64
|
||
|
sd ra, 56(sp)
|
||
|
sd s0, 48(sp)
|
||
|
sd s1, 40(sp)
|
||
|
sd s2, 32(sp)
|
||
|
sd s3, 24(sp)
|
||
|
sd s4, 16(sp)
|
||
|
sd s5, 8(sp)
|
||
|
sd s6, 0(sp)
|
||
|
call getint
|
||
|
mv s2, a0
|
||
|
call getint
|
||
|
mv s3, a0
|
||
|
slli s4, s2, 32
|
||
|
blez s2, .LBB2_3
|
||
|
li a0, 0
|
||
|
lui a1, %hi(parent)
|
||
|
addi a1, a1, %lo(parent)
|
||
|
srli a2, s4, 32
|
||
|
.LBB2_2:
|
||
|
sw a0, 0(a1)
|
||
|
addi a0, a0, 1
|
||
|
addi a1, a1, 4
|
||
|
bne a2, a0, .LBB2_2
|
||
|
.LBB2_3:
|
||
|
blez s3, .LBB2_8
|
||
|
li s1, 0
|
||
|
lui a0, %hi(parent)
|
||
|
addi s6, a0, %lo(parent)
|
||
|
j .LBB2_6
|
||
|
.LBB2_5:
|
||
|
addiw s1, s1, 1
|
||
|
bge s1, s3, .LBB2_8
|
||
|
.LBB2_6:
|
||
|
call getint
|
||
|
mv s0, a0
|
||
|
call getint
|
||
|
mv s5, a0
|
||
|
mv a0, s0
|
||
|
call find
|
||
|
mv s0, a0
|
||
|
mv a0, s5
|
||
|
call find
|
||
|
beq s0, a0, .LBB2_5
|
||
|
slli a0, a0, 2
|
||
|
add a0, a0, s6
|
||
|
sw s0, 0(a0)
|
||
|
j .LBB2_5
|
||
|
.LBB2_8:
|
||
|
blez s2, .LBB2_11
|
||
|
li a1, 0
|
||
|
li a0, 0
|
||
|
lui a2, %hi(parent)
|
||
|
addi a2, a2, %lo(parent)
|
||
|
srli a3, s4, 32
|
||
|
.LBB2_10:
|
||
|
lwu a4, 0(a2)
|
||
|
xor a4, a4, a1
|
||
|
seqz a4, a4
|
||
|
addw a0, a0, a4
|
||
|
addi a1, a1, 1
|
||
|
addi a2, a2, 4
|
||
|
bne a3, a1, .LBB2_10
|
||
|
j .LBB2_12
|
||
|
.LBB2_11:
|
||
|
li a0, 0
|
||
|
.LBB2_12:
|
||
|
call putint
|
||
|
li a0, 0
|
||
|
ld ra, 56(sp)
|
||
|
ld s0, 48(sp)
|
||
|
ld s1, 40(sp)
|
||
|
ld s2, 32(sp)
|
||
|
ld s3, 24(sp)
|
||
|
ld s4, 16(sp)
|
||
|
ld s5, 8(sp)
|
||
|
ld s6, 0(sp)
|
||
|
addi sp, sp, 64
|
||
|
ret
|
||
|
.Lfunc_end2:
|
||
|
.size main, .Lfunc_end2-main
|
||
|
|
||
|
.type parent,@object
|
||
|
.bss
|
||
|
.globl parent
|
||
|
.p2align 2
|
||
|
parent:
|
||
|
.zero 4020
|
||
|
.size parent, 4020
|
||
|
|
||
|
.type _sysy_start,@object
|
||
|
.globl _sysy_start
|
||
|
.p2align 3
|
||
|
_sysy_start:
|
||
|
.zero 16
|
||
|
.size _sysy_start, 16
|
||
|
|
||
|
.type _sysy_end,@object
|
||
|
.globl _sysy_end
|
||
|
.p2align 3
|
||
|
_sysy_end:
|
||
|
.zero 16
|
||
|
.size _sysy_end, 16
|
||
|
|
||
|
.type _sysy_l1,@object
|
||
|
.globl _sysy_l1
|
||
|
.p2align 2
|
||
|
_sysy_l1:
|
||
|
.zero 4096
|
||
|
.size _sysy_l1, 4096
|
||
|
|
||
|
.type _sysy_l2,@object
|
||
|
.globl _sysy_l2
|
||
|
.p2align 2
|
||
|
_sysy_l2:
|
||
|
.zero 4096
|
||
|
.size _sysy_l2, 4096
|
||
|
|
||
|
.type _sysy_h,@object
|
||
|
.globl _sysy_h
|
||
|
.p2align 2
|
||
|
_sysy_h:
|
||
|
.zero 4096
|
||
|
.size _sysy_h, 4096
|
||
|
|
||
|
.type _sysy_m,@object
|
||
|
.globl _sysy_m
|
||
|
.p2align 2
|
||
|
_sysy_m:
|
||
|
.zero 4096
|
||
|
.size _sysy_m, 4096
|
||
|
|
||
|
.type _sysy_s,@object
|
||
|
.globl _sysy_s
|
||
|
.p2align 2
|
||
|
_sysy_s:
|
||
|
.zero 4096
|
||
|
.size _sysy_s, 4096
|
||
|
|
||
|
.type _sysy_us,@object
|
||
|
.globl _sysy_us
|
||
|
.p2align 2
|
||
|
_sysy_us:
|
||
|
.zero 4096
|
||
|
.size _sysy_us, 4096
|
||
|
|
||
|
.type _sysy_idx,@object
|
||
|
.section .sbss,"aw",@nobits
|
||
|
.globl _sysy_idx
|
||
|
.p2align 2
|
||
|
_sysy_idx:
|
||
|
.word 0
|
||
|
.size _sysy_idx, 4
|
||
|
|
||
|
.ident "Debian clang version 14.0.6"
|
||
|
.section ".note.GNU-stack","",@progbits
|
||
|
.addrsig
|