-
-
Notifications
You must be signed in to change notification settings - Fork 97
/
prime_numbers_cpp.asm
96 lines (92 loc) · 1.67 KB
/
prime_numbers_cpp.asm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
; generated from prot/cpp/prime_numbers_cpp.cpp by doing
; clang prot/cpp/prime_numbers_cpp.cpp -S -o test.ll -target riscv32
; then adding these headers lines, to test.ll, down to line 11 below, by hand
li sp, 800
addi sp, sp, -16
jal x1, _Z17prime_numbers_cppv
halt
_Z3outj:
outr a0
ret
.text
.attribute 4, 16
.attribute 5, "rv32i2p0_m2p0_a2p0_c2p0"
.file "prime_numbers_cpp.cpp"
.globl _Z17prime_numbers_cppv
.p2align 1
.type _Z17prime_numbers_cppv,@function
_Z17prime_numbers_cppv:
.cfi_startproc
addi sp, sp, -32
.cfi_def_cfa_offset 32
sw ra, 28(sp)
sw s0, 24(sp)
.cfi_offset ra, -4
.cfi_offset s0, -8
addi s0, sp, 32
.cfi_def_cfa s0, 0
li a0, 2
sw a0, -12(s0)
j .LBB0_1
.LBB0_1:
lw a1, -12(s0)
li a0, 31
bltu a0, a1, .LBB0_12
j .LBB0_2
.LBB0_2:
li a0, 1
sw a0, -16(s0)
li a0, 2
sw a0, -20(s0)
j .LBB0_3
.LBB0_3:
lw a0, -20(s0)
lw a1, -12(s0)
bgeu a0, a1, .LBB0_8
j .LBB0_4
.LBB0_4:
lw a0, -12(s0)
lw a1, -20(s0)
remu a0, a0, a1
li a1, 0
bne a0, a1, .LBB0_6
j .LBB0_5
.LBB0_5:
li a0, 0
sw a0, -16(s0)
j .LBB0_8
.LBB0_6:
j .LBB0_7
.LBB0_7:
lw a0, -20(s0)
addi a0, a0, 1
sw a0, -20(s0)
j .LBB0_3
.LBB0_8:
lw a0, -16(s0)
li a1, 0
beq a0, a1, .LBB0_10
j .LBB0_9
.LBB0_9:
lw a0, -12(s0)
call _Z3outj
j .LBB0_10
.LBB0_10:
j .LBB0_11
.LBB0_11:
lw a0, -12(s0)
addi a0, a0, 1
sw a0, -12(s0)
j .LBB0_1
.LBB0_12:
lw ra, 28(sp)
lw s0, 24(sp)
addi sp, sp, 32
ret
.Lfunc_end0:
.size _Z17prime_numbers_cppv, .Lfunc_end0-_Z17prime_numbers_cppv
.cfi_endproc
.ident "clang version 14.0.0 (https://github.com/tru/llvm-release-build fc075d7c96fe7c992dde351695a5d25fe084794a)"
.section ".note.GNU-stack","",@progbits
.addrsig
.addrsig_sym _Z3outj