forked from piood/MySysY2RV
-
Notifications
You must be signed in to change notification settings - Fork 0
/
hello.koopa
54 lines (45 loc) · 917 Bytes
/
hello.koopa
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
decl @putint(i32)
decl @putch(i32)
global @COMPILER__a_ = alloc i32, 10
fun @inc(): i32{
%entry:
%0 = load @COMPILER__a_
%1 = add %0, 1
store %1, @COMPILER__a_
%2 = load @COMPILER__a_
ret %2
}
fun @print_a(){
%entry:
%3 = load @COMPILER__a_
call @putint(%3)
call @putch(10)
ret
}
fun @main(): i32{
%entry:
@COMPILER__i__43_0 = alloc i32
store 0, @COMPILER__i__43_0
jump %while_1
%while_1:
%4 = load @COMPILER__i__43_0
%5 = lt %4, 10
br %5, %while_then_1, %end_while_1
%while_then_1:
%6 = call @inc()
@COMPILER__a__43_0_31_0 = alloc i32
store 1, @COMPILER__a__43_0_31_0
%7 = load @COMPILER__a__43_0_31_0
%8 = add %7, 2
store %8, @COMPILER__a__43_0_31_0
%9 = load @COMPILER__a__43_0_31_0
call @putint(%9)
call @putch(10)
call @print_a()
%10 = load @COMPILER__i__43_0
%11 = add %10, 1
store %11, @COMPILER__i__43_0
jump %while_1
%end_while_1:
ret 0
}