sysy-data/performance_c/asm/brainfuck-bootstrap.s

597 lines
9.4 KiB
ArmAsm
Raw Normal View History

2024-06-14 13:34:46 +08:00
.text
.attribute 4, 16
.attribute 5, "rv64i2p0_m2p0_a2p0_f2p0_d2p0_c2p0"
.file "brainfuck-bootstrap.sy"
.section .sdata,"aw",@progbits
.p2align 3
.LCPI0_0:
.quad 360287970357415681
.text
.globl get_bf_char
.p2align 1
.type get_bf_char,@function
get_bf_char:
addi sp, sp, -32
sd ra, 24(sp)
sd s0, 16(sp)
sd s1, 8(sp)
sd s2, 0(sp)
lui a0, %hi(.LCPI0_0)
ld s0, %lo(.LCPI0_0)(a0)
li s1, 58
li s2, 1
.LBB0_1:
call getch
addi a1, a0, -35
bltu s1, a1, .LBB0_1
sll a1, s2, a1
and a1, a1, s0
beqz a1, .LBB0_1
ld ra, 24(sp)
ld s0, 16(sp)
ld s1, 8(sp)
ld s2, 0(sp)
addi sp, sp, 32
ret
.Lfunc_end0:
.size get_bf_char, .Lfunc_end0-get_bf_char
.section .sdata,"aw",@progbits
.p2align 3
.LCPI1_0:
.quad 360287970357415680
.LCPI1_1:
.quad 360287970357415681
.text
.globl read_program
.p2align 1
.type read_program,@function
read_program:
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)
lui a0, %hi(.LCPI1_0)
ld s0, %lo(.LCPI1_0)(a0)
li s1, 58
li s2, 1
.LBB1_1:
call getch
addi a1, a0, -35
bltu s1, a1, .LBB1_1
sll a2, s2, a1
and a2, a2, s0
bnez a2, .LBB1_4
bnez a1, .LBB1_1
j .LBB1_9
.LBB1_4:
lui s2, %hi(program_length)
lw a1, %lo(program_length)(s2)
lui a2, %hi(program)
addi s3, a2, %lo(program)
lui a2, %hi(.LCPI1_1)
ld s0, %lo(.LCPI1_1)(a2)
li s1, 58
li s4, 1
li s5, 35
.LBB1_5:
slli a1, a1, 2
add a1, a1, s3
sw a0, 0(a1)
.LBB1_6:
call getch
addi a1, a0, -35
bltu s1, a1, .LBB1_6
sll a1, s4, a1
and a1, a1, s0
beqz a1, .LBB1_6
lw a1, %lo(program_length)(s2)
addiw a1, a1, 1
sw a1, %lo(program_length)(s2)
bne a0, s5, .LBB1_5
.LBB1_9:
call getch
li a1, 105
bne a0, a1, .LBB1_13
call getint
lui s2, %hi(input_length)
sw a0, %lo(input_length)(s2)
call getch
lw a0, %lo(input_length)(s2)
blez a0, .LBB1_13
li s1, 0
lui a0, %hi(input)
addi s0, a0, %lo(input)
.LBB1_12:
call getch
lw a1, %lo(input_length)(s2)
sw a0, 0(s0)
addi s1, s1, 1
addi s0, s0, 4
blt s1, a1, .LBB1_12
.LBB1_13:
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)
addi sp, sp, 64
ret
.Lfunc_end1:
.size read_program, .Lfunc_end1-read_program
.globl run_program
.p2align 1
.type run_program,@function
run_program:
addi sp, sp, -2032
sd ra, 2024(sp)
sd s0, 2016(sp)
sd s1, 2008(sp)
sd s2, 2000(sp)
sd s3, 1992(sp)
addi sp, sp, -64
lui a0, 1
addiw a2, a0, -2048
addi a0, sp, 8
addi s2, sp, 8
li a1, 0
call memset@plt
lui a0, %hi(program_length)
lw a0, %lo(program_length)(a0)
lui a6, %hi(output_length)
sw zero, %lo(output_length)(a6)
blez a0, .LBB2_20
li a4, 0
li a2, 0
li t0, 0
li t1, 0
li t4, 0
lui a1, %hi(input_length)
lw a7, %lo(input_length)(a1)
lui a1, %hi(program)
addi a1, a1, %lo(program)
li t5, 50
lui a3, %hi(.LJTI2_0)
addi s3, a3, %lo(.LJTI2_0)
lui a5, %hi(tape)
addi t6, a5, %lo(tape)
lui a5, %hi(input)
addi t2, a5, %lo(input)
lui a5, %hi(output)
addi t3, a5, %lo(output)
j .LBB2_4
.LBB2_2:
slli a3, a2, 2
add a3, a3, t6
lw a3, 0(a3)
slli a5, t4, 2
add a5, a5, t3
sw a3, 0(a5)
addiw t4, t4, 1
sw t4, %lo(output_length)(a6)
.LBB2_3:
addiw a4, a4, 1
bge a4, a0, .LBB2_20
.LBB2_4:
slli a5, a4, 2
add s0, a5, a1
lw s0, 0(s0)
addi s0, s0, -43
bltu t5, s0, .LBB2_3
slli s0, s0, 2
add s0, s0, s3
lw s0, 0(s0)
jr s0
.LBB2_6:
slli a5, a2, 2
add a5, a5, t6
lw s0, 0(a5)
addiw s0, s0, 1
sw s0, 0(a5)
j .LBB2_3
.LBB2_7:
bge t0, a7, .LBB2_16
slli a3, t0, 2
add a3, a3, t2
lw a3, 0(a3)
slli a5, a2, 2
add a5, a5, t6
sw a3, 0(a5)
addiw t0, t0, 1
j .LBB2_3
.LBB2_9:
slli a5, a2, 2
add a5, a5, t6
lw s0, 0(a5)
addiw s0, s0, -1
sw s0, 0(a5)
j .LBB2_3
.LBB2_10:
addiw a2, a2, -1
j .LBB2_3
.LBB2_11:
addiw a2, a2, 1
j .LBB2_3
.LBB2_12:
slli s0, a2, 2
add s0, s0, t6
lw s0, 0(s0)
beqz s0, .LBB2_17
slli a5, t1, 2
add a5, a5, s2
sw a4, 0(a5)
addiw t1, t1, 1
j .LBB2_3
.LBB2_14:
slli a3, a2, 2
add a3, a3, t6
lw a3, 0(a3)
addiw a5, t1, -1
beqz a3, .LBB2_19
slli a3, a5, 2
add a3, a3, s2
lw a4, 0(a3)
j .LBB2_3
.LBB2_16:
slli a3, a2, 2
add a3, a3, t6
sw zero, 0(a3)
j .LBB2_3
.LBB2_17:
add a5, a5, a1
addi a5, a5, 4
li s0, 1
.LBB2_18:
lw s1, 0(a5)
addi a4, a4, 1
addi a3, s1, -93
seqz a3, a3
subw a3, s0, a3
addi s0, s1, -91
seqz s0, s0
addw s0, s0, a3
addi a5, a5, 4
bnez s0, .LBB2_18
j .LBB2_3
.LBB2_19:
mv t1, a5
j .LBB2_3
.LBB2_20:
addi sp, sp, 64
ld ra, 2024(sp)
ld s0, 2016(sp)
ld s1, 2008(sp)
ld s2, 2000(sp)
ld s3, 1992(sp)
addi sp, sp, 2032
ret
.Lfunc_end2:
.size run_program, .Lfunc_end2-run_program
.section .rodata,"a",@progbits
.p2align 2
.LJTI2_0:
.word .LBB2_6
.word .LBB2_7
.word .LBB2_9
.word .LBB2_2
.word .LBB2_3
.word .LBB2_3
.word .LBB2_3
.word .LBB2_3
.word .LBB2_3
.word .LBB2_3
.word .LBB2_3
.word .LBB2_3
.word .LBB2_3
.word .LBB2_3
.word .LBB2_3
.word .LBB2_3
.word .LBB2_3
.word .LBB2_10
.word .LBB2_3
.word .LBB2_11
.word .LBB2_3
.word .LBB2_3
.word .LBB2_3
.word .LBB2_3
.word .LBB2_3
.word .LBB2_3
.word .LBB2_3
.word .LBB2_3
.word .LBB2_3
.word .LBB2_3
.word .LBB2_3
.word .LBB2_3
.word .LBB2_3
.word .LBB2_3
.word .LBB2_3
.word .LBB2_3
.word .LBB2_3
.word .LBB2_3
.word .LBB2_3
.word .LBB2_3
.word .LBB2_3
.word .LBB2_3
.word .LBB2_3
.word .LBB2_3
.word .LBB2_3
.word .LBB2_3
.word .LBB2_3
.word .LBB2_3
.word .LBB2_12
.word .LBB2_3
.word .LBB2_14
.text
.globl output_
.p2align 1
.type output_,@function
output_:
addi sp, sp, -32
sd ra, 24(sp)
sd s0, 16(sp)
sd s1, 8(sp)
sd s2, 0(sp)
lui s2, %hi(output_length)
lw a0, %lo(output_length)(s2)
blez a0, .LBB3_3
li s1, 0
lui a0, %hi(output)
addi s0, a0, %lo(output)
.LBB3_2:
lw a0, 0(s0)
call putch
lw a0, %lo(output_length)(s2)
addi s1, s1, 1
addi s0, s0, 4
blt s1, a0, .LBB3_2
.LBB3_3:
ld ra, 24(sp)
ld s0, 16(sp)
ld s1, 8(sp)
ld s2, 0(sp)
addi sp, sp, 32
ret
.Lfunc_end3:
.size output_, .Lfunc_end3-output_
.section .sdata,"aw",@progbits
.p2align 3
.LCPI4_0:
.quad 360287970357415680
.LCPI4_1:
.quad 360287970357415681
.text
.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)
lui a0, %hi(.LCPI4_0)
ld s0, %lo(.LCPI4_0)(a0)
li s1, 58
li s2, 1
.LBB4_1:
call getch
addi a1, a0, -35
bltu s1, a1, .LBB4_1
sll a2, s2, a1
and a2, a2, s0
bnez a2, .LBB4_4
bnez a1, .LBB4_1
j .LBB4_9
.LBB4_4:
lui s2, %hi(program_length)
lw a1, %lo(program_length)(s2)
lui a2, %hi(program)
addi s3, a2, %lo(program)
lui a2, %hi(.LCPI4_1)
ld s0, %lo(.LCPI4_1)(a2)
li s1, 58
li s4, 1
li s5, 35
.LBB4_5:
slli a1, a1, 2
add a1, a1, s3
sw a0, 0(a1)
.LBB4_6:
call getch
addi a1, a0, -35
bltu s1, a1, .LBB4_6
sll a1, s4, a1
and a1, a1, s0
beqz a1, .LBB4_6
lw a1, %lo(program_length)(s2)
addiw a1, a1, 1
sw a1, %lo(program_length)(s2)
bne a0, s5, .LBB4_5
.LBB4_9:
call getch
li a1, 105
bne a0, a1, .LBB4_13
call getint
lui s2, %hi(input_length)
sw a0, %lo(input_length)(s2)
call getch
lw a0, %lo(input_length)(s2)
blez a0, .LBB4_13
li s1, 0
lui a0, %hi(input)
addi s0, a0, %lo(input)
.LBB4_12:
call getch
lw a1, %lo(input_length)(s2)
sw a0, 0(s0)
addi s1, s1, 1
addi s0, s0, 4
blt s1, a1, .LBB4_12
.LBB4_13:
li a0, 121
call _sysy_starttime
call run_program
li a0, 123
call _sysy_stoptime
lui s2, %hi(output_length)
lw a0, %lo(output_length)(s2)
blez a0, .LBB4_16
li s1, 0
lui a0, %hi(output)
addi s0, a0, %lo(output)
.LBB4_15:
lw a0, 0(s0)
call putch
lw a0, %lo(output_length)(s2)
addi s1, s1, 1
addi s0, s0, 4
blt s1, a0, .LBB4_15
.LBB4_16:
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)
addi sp, sp, 64
ret
.Lfunc_end4:
.size main, .Lfunc_end4-main
.type program_length,@object
.section .sbss,"aw",@nobits
.globl program_length
.p2align 2
program_length:
.word 0
.size program_length, 4
.type program,@object
.bss
.globl program
.p2align 2
program:
.zero 262144
.size program, 262144
.type tape,@object
.globl tape
.p2align 2
tape:
.zero 262144
.size tape, 262144
.type input,@object
.globl input
.p2align 2
input:
.zero 262144
.size input, 262144
.type input_length,@object
.section .sbss,"aw",@nobits
.globl input_length
.p2align 2
input_length:
.word 0
.size input_length, 4
.type output,@object
.bss
.globl output
.p2align 2
output:
.zero 262144
.size output, 262144
.type output_length,@object
.section .sbss,"aw",@nobits
.globl output_length
.p2align 2
output_length:
.word 0
.size output_length, 4
.type _sysy_start,@object
.bss
.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