-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathllvm_ir.txt
40 lines (36 loc) · 1.15 KB
/
llvm_ir.txt
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
declare i32 @getint()
declare void @putint(i32)
declare void @putch(i32)
declare void @putstr(i8*)
@N = constant i32 10
@a = global [3 x [3 x i32]] [[3 x i32] [i32 0, i32 1, i32 2], [3 x i32] [i32 3, i32 4, i32 5], [3 x i32] [i32 6, i32 7, i32 8]]
@b = global [3 x i32] [i32 1, i32 2, i32 3]
define dso_local i32 @f([3 x i32]* %0, i32 %1){
l0:
%2 = alloca [3 x i32]*
store [3 x i32]* %0, [3 x i32]** %2
%3 = alloca i32
store i32 %1, i32* %3
%4 = load [3 x i32]*, [3 x i32]** %2
%5 = getelementptr [3 x i32], [3 x i32]* %4, i32 1, i32 1
%6 = load i32, i32* %5
%7 = load i32, i32* %3
%8 = add i32 %6, %7
ret i32 %8
}
define dso_local i32 @main(){
l1:
%0 = getelementptr [3 x [3 x i32]], [3 x [3 x i32]]* @a, i32 0, i32 1, i32 2
%1 = load i32, i32* %0
call void @putint(i32 %1)
call void @putch(i32 32)
%2 = getelementptr [3 x i32], [3 x i32]* @b, i32 0, i32 2
%3 = load i32, i32* %2
call void @putint(i32 %3)
call void @putch(i32 10)
%4 = getelementptr [3 x [3 x i32]], [3 x [3 x i32]]* @a, i32 0, i32 0
%5 = getelementptr [3 x [3 x i32]], [3 x [3 x i32]]* @a, i32 0, i32 0, i32 0
%6 = load i32, i32* %5
%7 = call i32 @f([3 x i32]* %4, i32 %6)
ret i32 0
}