forked from NUDT-compiler/nudt-compiler-cpp
Compare commits
5 Commits
| Author | SHA1 | Date |
|---|---|---|
|
|
107f2a15e7 | 2 days ago |
|
|
2796eb9c94 | 2 days ago |
|
|
226867f326 | 2 days ago |
|
|
3cd26ec0b0 | 2 weeks ago |
|
|
c0a4de925f | 1 month ago |
@ -0,0 +1,34 @@
|
||||
OUTPUT_DIR="test_outputs"
|
||||
mkdir -p "$OUTPUT_DIR"
|
||||
|
||||
echo "=== 编译器功能测试 ==="
|
||||
echo "结果将保存到 $OUTPUT_DIR/ 目录"
|
||||
echo ""
|
||||
|
||||
for test in test/test_case/functional/*.sy; do
|
||||
name=$(basename "$test" .sy)
|
||||
|
||||
echo "正在测试: $name"
|
||||
|
||||
# 检查是否有对应的输入文件
|
||||
in_file="test/test_case/functional/${name}.in"
|
||||
out_file="$OUTPUT_DIR/${name}.ll"
|
||||
|
||||
if [ -f "$in_file" ]; then
|
||||
echo " 使用输入文件: $in_file"
|
||||
echo " 输出保存到: $out_file"
|
||||
echo ""
|
||||
./build/bin/compiler --emit-ir "$test" < "$in_file" 2>&1 | tee "$out_file"
|
||||
else
|
||||
echo " 输出保存到: $out_file"
|
||||
echo ""
|
||||
./build/bin/compiler --emit-ir "$test" 2>&1 | tee "$out_file"
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo "--- 测试完成 ---"
|
||||
echo ""
|
||||
done
|
||||
|
||||
echo "所有测试完成!"
|
||||
echo "查看结果: ls -la $OUTPUT_DIR/"
|
||||
@ -0,0 +1,187 @@
|
||||
declare i32 @getint()
|
||||
declare i32 @getch()
|
||||
declare void @putint(i32)
|
||||
declare void @putch(i32)
|
||||
declare i32 @getarray(i32*)
|
||||
declare void @putarray(i32, i32*)
|
||||
declare void @starttime()
|
||||
declare void @stoptime()
|
||||
define i32 @main() {
|
||||
entry:
|
||||
%t1 = alloca i32
|
||||
%t2 = alloca i32, i32 8
|
||||
%t11 = alloca i32
|
||||
%t12 = alloca i32, i32 8
|
||||
%t21 = alloca i32, i32 8
|
||||
%t38 = alloca i32, i32 8
|
||||
%t58 = alloca i32, i32 8
|
||||
br label %bbt0
|
||||
bbt0:
|
||||
%t3 = getelementptr i32, i32* %t2, i32 0
|
||||
store i32 1, i32* %t3
|
||||
%t4 = getelementptr i32, i32* %t2, i32 1
|
||||
store i32 2, i32* %t4
|
||||
%t5 = getelementptr i32, i32* %t2, i32 2
|
||||
store i32 3, i32* %t5
|
||||
%t6 = getelementptr i32, i32* %t2, i32 3
|
||||
store i32 4, i32* %t6
|
||||
%t7 = getelementptr i32, i32* %t2, i32 4
|
||||
store i32 0, i32* %t7
|
||||
%t8 = getelementptr i32, i32* %t2, i32 5
|
||||
store i32 0, i32* %t8
|
||||
%t9 = getelementptr i32, i32* %t2, i32 6
|
||||
store i32 7, i32* %t9
|
||||
%t10 = getelementptr i32, i32* %t2, i32 7
|
||||
store i32 0, i32* %t10
|
||||
store i32 3, i32* %t11
|
||||
%t13 = getelementptr i32, i32* %t12, i32 0
|
||||
store i32 0, i32* %t13
|
||||
%t14 = getelementptr i32, i32* %t12, i32 1
|
||||
store i32 0, i32* %t14
|
||||
%t15 = getelementptr i32, i32* %t12, i32 2
|
||||
store i32 0, i32* %t15
|
||||
%t16 = getelementptr i32, i32* %t12, i32 3
|
||||
store i32 0, i32* %t16
|
||||
%t17 = getelementptr i32, i32* %t12, i32 4
|
||||
store i32 0, i32* %t17
|
||||
%t18 = getelementptr i32, i32* %t12, i32 5
|
||||
store i32 0, i32* %t18
|
||||
%t19 = getelementptr i32, i32* %t12, i32 6
|
||||
store i32 0, i32* %t19
|
||||
%t20 = getelementptr i32, i32* %t12, i32 7
|
||||
store i32 0, i32* %t20
|
||||
%t22 = getelementptr i32, i32* %t21, i32 0
|
||||
store i32 0, i32* %t22
|
||||
%t23 = getelementptr i32, i32* %t21, i32 1
|
||||
store i32 0, i32* %t23
|
||||
%t24 = getelementptr i32, i32* %t21, i32 2
|
||||
store i32 0, i32* %t24
|
||||
%t25 = getelementptr i32, i32* %t21, i32 3
|
||||
store i32 0, i32* %t25
|
||||
%t26 = getelementptr i32, i32* %t21, i32 4
|
||||
store i32 0, i32* %t26
|
||||
%t27 = getelementptr i32, i32* %t21, i32 5
|
||||
store i32 0, i32* %t27
|
||||
%t28 = getelementptr i32, i32* %t21, i32 6
|
||||
store i32 0, i32* %t28
|
||||
%t29 = getelementptr i32, i32* %t21, i32 7
|
||||
store i32 0, i32* %t29
|
||||
%t30 = getelementptr i32, i32* %t21, i32 0
|
||||
store i32 1, i32* %t30
|
||||
%t31 = getelementptr i32, i32* %t21, i32 1
|
||||
store i32 2, i32* %t31
|
||||
%t32 = getelementptr i32, i32* %t21, i32 2
|
||||
store i32 3, i32* %t32
|
||||
%t33 = getelementptr i32, i32* %t21, i32 3
|
||||
store i32 4, i32* %t33
|
||||
%t34 = getelementptr i32, i32* %t21, i32 4
|
||||
store i32 5, i32* %t34
|
||||
%t35 = getelementptr i32, i32* %t21, i32 5
|
||||
store i32 6, i32* %t35
|
||||
%t36 = getelementptr i32, i32* %t21, i32 6
|
||||
store i32 7, i32* %t36
|
||||
%t37 = getelementptr i32, i32* %t21, i32 7
|
||||
store i32 8, i32* %t37
|
||||
%t39 = getelementptr i32, i32* %t38, i32 0
|
||||
store i32 0, i32* %t39
|
||||
%t40 = getelementptr i32, i32* %t38, i32 1
|
||||
store i32 0, i32* %t40
|
||||
%t41 = getelementptr i32, i32* %t38, i32 2
|
||||
store i32 0, i32* %t41
|
||||
%t42 = getelementptr i32, i32* %t38, i32 3
|
||||
store i32 0, i32* %t42
|
||||
%t43 = getelementptr i32, i32* %t38, i32 4
|
||||
store i32 0, i32* %t43
|
||||
%t44 = getelementptr i32, i32* %t38, i32 5
|
||||
store i32 0, i32* %t44
|
||||
%t45 = getelementptr i32, i32* %t38, i32 6
|
||||
store i32 0, i32* %t45
|
||||
%t46 = getelementptr i32, i32* %t38, i32 7
|
||||
store i32 0, i32* %t46
|
||||
%t47 = mul i32 3, 2
|
||||
%t48 = add i32 0, %t47
|
||||
%t49 = add i32 %t48, 0
|
||||
%t50 = getelementptr i32, i32* %t2, i32 %t49
|
||||
%t51 = load i32, i32* %t50
|
||||
%t52 = getelementptr i32, i32* %t38, i32 0
|
||||
store i32 1, i32* %t52
|
||||
%t53 = getelementptr i32, i32* %t38, i32 1
|
||||
store i32 2, i32* %t53
|
||||
%t54 = getelementptr i32, i32* %t38, i32 2
|
||||
store i32 3, i32* %t54
|
||||
%t55 = getelementptr i32, i32* %t38, i32 4
|
||||
store i32 5, i32* %t55
|
||||
%t56 = getelementptr i32, i32* %t38, i32 6
|
||||
store i32 %t51, i32* %t56
|
||||
%t57 = getelementptr i32, i32* %t38, i32 7
|
||||
store i32 8, i32* %t57
|
||||
%t59 = getelementptr i32, i32* %t58, i32 0
|
||||
store i32 0, i32* %t59
|
||||
%t60 = getelementptr i32, i32* %t58, i32 1
|
||||
store i32 0, i32* %t60
|
||||
%t61 = getelementptr i32, i32* %t58, i32 2
|
||||
store i32 0, i32* %t61
|
||||
%t62 = getelementptr i32, i32* %t58, i32 3
|
||||
store i32 0, i32* %t62
|
||||
%t63 = getelementptr i32, i32* %t58, i32 4
|
||||
store i32 0, i32* %t63
|
||||
%t64 = getelementptr i32, i32* %t58, i32 5
|
||||
store i32 0, i32* %t64
|
||||
%t65 = getelementptr i32, i32* %t58, i32 6
|
||||
store i32 0, i32* %t65
|
||||
%t66 = getelementptr i32, i32* %t58, i32 7
|
||||
store i32 0, i32* %t66
|
||||
%t67 = mul i32 2, 2
|
||||
%t68 = add i32 0, %t67
|
||||
%t69 = add i32 %t68, 1
|
||||
%t70 = getelementptr i32, i32* %t38, i32 %t69
|
||||
%t71 = load i32, i32* %t70
|
||||
%t72 = mul i32 2, 2
|
||||
%t73 = add i32 0, %t72
|
||||
%t74 = add i32 %t73, 1
|
||||
%t75 = getelementptr i32, i32* %t21, i32 %t74
|
||||
%t76 = load i32, i32* %t75
|
||||
%t77 = getelementptr i32, i32* %t58, i32 0
|
||||
store i32 %t71, i32* %t77
|
||||
%t78 = getelementptr i32, i32* %t58, i32 1
|
||||
store i32 %t76, i32* %t78
|
||||
%t79 = getelementptr i32, i32* %t58, i32 2
|
||||
store i32 3, i32* %t79
|
||||
%t80 = getelementptr i32, i32* %t58, i32 3
|
||||
store i32 4, i32* %t80
|
||||
%t81 = getelementptr i32, i32* %t58, i32 4
|
||||
store i32 5, i32* %t81
|
||||
%t82 = getelementptr i32, i32* %t58, i32 5
|
||||
store i32 6, i32* %t82
|
||||
%t83 = getelementptr i32, i32* %t58, i32 6
|
||||
store i32 7, i32* %t83
|
||||
%t84 = getelementptr i32, i32* %t58, i32 7
|
||||
store i32 8, i32* %t84
|
||||
%t85 = mul i32 3, 2
|
||||
%t86 = add i32 0, %t85
|
||||
%t87 = add i32 %t86, 1
|
||||
%t88 = add i32 %t87, 0
|
||||
%t89 = getelementptr i32, i32* %t58, i32 %t88
|
||||
%t90 = load i32, i32* %t89
|
||||
%t91 = mul i32 0, 2
|
||||
%t92 = add i32 0, %t91
|
||||
%t93 = add i32 %t92, 0
|
||||
%t94 = add i32 %t93, 0
|
||||
%t95 = getelementptr i32, i32* %t58, i32 %t94
|
||||
%t96 = load i32, i32* %t95
|
||||
%t97 = add i32 %t90, %t96
|
||||
%t98 = mul i32 0, 2
|
||||
%t99 = add i32 0, %t98
|
||||
%t100 = add i32 %t99, 1
|
||||
%t101 = add i32 %t100, 0
|
||||
%t102 = getelementptr i32, i32* %t58, i32 %t101
|
||||
%t103 = load i32, i32* %t102
|
||||
%t104 = add i32 %t97, %t103
|
||||
%t105 = mul i32 3, 2
|
||||
%t106 = add i32 0, %t105
|
||||
%t107 = add i32 %t106, 0
|
||||
%t108 = getelementptr i32, i32* %t38, i32 %t107
|
||||
%t109 = load i32, i32* %t108
|
||||
%t110 = add i32 %t104, %t109
|
||||
ret i32 %t110
|
||||
}
|
||||
@ -0,0 +1,37 @@
|
||||
@a = global i32 0
|
||||
|
||||
declare i32 @getint()
|
||||
declare i32 @getch()
|
||||
declare void @putint(i32)
|
||||
declare void @putch(i32)
|
||||
declare i32 @getarray(i32*)
|
||||
declare void @putarray(i32, i32*)
|
||||
declare void @starttime()
|
||||
declare void @stoptime()
|
||||
define i32 @func(i32 %arg0) {
|
||||
entry:
|
||||
%t1 = alloca i32
|
||||
%t2 = alloca i32
|
||||
br label %bbt0
|
||||
bbt0:
|
||||
store i32 %arg0, i32* %t1
|
||||
%t3 = load i32, i32* %t1
|
||||
%t4 = sub i32 %t3, 1
|
||||
store i32 %t4, i32* %t1
|
||||
%t5 = load i32, i32* %t1
|
||||
ret i32 %t5
|
||||
}
|
||||
define i32 @main() {
|
||||
entry:
|
||||
%t7 = alloca i32
|
||||
%t8 = alloca i32
|
||||
br label %bbt6
|
||||
bbt6:
|
||||
store i32 0, i32* %t8
|
||||
store i32 10, i32* @a
|
||||
%t9 = load i32, i32* @a
|
||||
%t10 = call i32 @func(i32 %t9)
|
||||
store i32 %t10, i32* %t8
|
||||
%t11 = load i32, i32* %t8
|
||||
ret i32 %t11
|
||||
}
|
||||
@ -0,0 +1,25 @@
|
||||
declare i32 @getint()
|
||||
declare i32 @getch()
|
||||
declare void @putint(i32)
|
||||
declare void @putch(i32)
|
||||
declare i32 @getarray(i32*)
|
||||
declare void @putarray(i32, i32*)
|
||||
declare void @starttime()
|
||||
declare void @stoptime()
|
||||
define i32 @main() {
|
||||
entry:
|
||||
%t1 = alloca i32
|
||||
%t2 = alloca i32
|
||||
%t3 = alloca i32
|
||||
br label %bbt0
|
||||
bbt0:
|
||||
store i32 0, i32* %t2
|
||||
store i32 0, i32* %t3
|
||||
store i32 10, i32* %t2
|
||||
%t4 = sub i32 0, 1
|
||||
store i32 %t4, i32* %t3
|
||||
%t5 = load i32, i32* %t2
|
||||
%t6 = load i32, i32* %t3
|
||||
%t7 = add i32 %t5, %t6
|
||||
ret i32 %t7
|
||||
}
|
||||
@ -0,0 +1,23 @@
|
||||
@a = global i32 10
|
||||
|
||||
declare i32 @getint()
|
||||
declare i32 @getch()
|
||||
declare void @putint(i32)
|
||||
declare void @putch(i32)
|
||||
declare i32 @getarray(i32*)
|
||||
declare void @putarray(i32, i32*)
|
||||
declare void @starttime()
|
||||
declare void @stoptime()
|
||||
define i32 @main() {
|
||||
entry:
|
||||
%t1 = alloca i32
|
||||
%t2 = alloca i32
|
||||
br label %bbt0
|
||||
bbt0:
|
||||
store i32 0, i32* %t2
|
||||
store i32 2, i32* %t2
|
||||
%t3 = load i32, i32* %t2
|
||||
%t4 = load i32, i32* @a
|
||||
%t5 = sub i32 %t3, %t4
|
||||
ret i32 %t5
|
||||
}
|
||||
@ -0,0 +1,287 @@
|
||||
@V = global i32 4
|
||||
@space = global i32 32
|
||||
@LF = global i32 10
|
||||
|
||||
declare i32 @getint()
|
||||
declare i32 @getch()
|
||||
declare void @putint(i32)
|
||||
declare void @putch(i32)
|
||||
declare i32 @getarray(i32*)
|
||||
declare void @putarray(i32, i32*)
|
||||
declare void @starttime()
|
||||
declare void @stoptime()
|
||||
define void @printSolution(i32* %arg0) {
|
||||
entry:
|
||||
%t1 = alloca i32
|
||||
%t2 = alloca i32
|
||||
br label %bbt0
|
||||
bbt0:
|
||||
store i32 0, i32* %t2
|
||||
br label %bbt3
|
||||
bbt3:
|
||||
%t6 = load i32, i32* %t2
|
||||
%t7 = load i32, i32* @V
|
||||
%t8 = icmp slt i32 %t6, %t7
|
||||
br i1 %t8, label %bbt4, label %bbt5
|
||||
bbt4:
|
||||
%t9 = load i32, i32* %t2
|
||||
%t10 = getelementptr i32, i32* %arg0, i32 %t9
|
||||
%t11 = load i32, i32* %t10
|
||||
call void @putint(i32 %t11)
|
||||
%t12 = load i32, i32* @space
|
||||
call void @putch(i32 %t12)
|
||||
%t13 = load i32, i32* %t2
|
||||
%t14 = add i32 %t13, 1
|
||||
store i32 %t14, i32* %t2
|
||||
br label %bbt3
|
||||
bbt5:
|
||||
%t15 = load i32, i32* @LF
|
||||
call void @putch(i32 %t15)
|
||||
ret void
|
||||
}
|
||||
define void @printMessage() {
|
||||
entry:
|
||||
%t17 = alloca i32
|
||||
br label %bbt16
|
||||
bbt16:
|
||||
call void @putch(i32 78)
|
||||
call void @putch(i32 111)
|
||||
call void @putch(i32 116)
|
||||
%t18 = load i32, i32* @space
|
||||
call void @putch(i32 %t18)
|
||||
call void @putch(i32 101)
|
||||
call void @putch(i32 120)
|
||||
call void @putch(i32 105)
|
||||
call void @putch(i32 115)
|
||||
call void @putch(i32 116)
|
||||
ret void
|
||||
}
|
||||
define i32 @isSafe(i32* %arg0, i32* %arg1) {
|
||||
entry:
|
||||
%t20 = alloca i32
|
||||
%t21 = alloca i32
|
||||
%t28 = alloca i32
|
||||
br label %bbt19
|
||||
bbt19:
|
||||
store i32 0, i32* %t21
|
||||
br label %bbt22
|
||||
bbt22:
|
||||
%t25 = load i32, i32* %t21
|
||||
%t26 = load i32, i32* @V
|
||||
%t27 = icmp slt i32 %t25, %t26
|
||||
br i1 %t27, label %bbt23, label %bbt24
|
||||
bbt23:
|
||||
%t29 = load i32, i32* %t21
|
||||
%t30 = add i32 %t29, 1
|
||||
store i32 %t30, i32* %t28
|
||||
br label %bbt31
|
||||
bbt24:
|
||||
ret i32 1
|
||||
bbt31:
|
||||
%t34 = load i32, i32* %t28
|
||||
%t35 = load i32, i32* @V
|
||||
%t36 = icmp slt i32 %t34, %t35
|
||||
br i1 %t36, label %bbt32, label %bbt33
|
||||
bbt32:
|
||||
store i32 0, i32* %t20
|
||||
%t39 = load i32, i32* %t21
|
||||
%t40 = mul i32 %t39, 4
|
||||
%t41 = add i32 0, %t40
|
||||
%t42 = load i32, i32* %t28
|
||||
%t43 = add i32 %t41, %t42
|
||||
%t44 = getelementptr i32, i32* %arg0, i32 %t43
|
||||
%t45 = load i32, i32* %t44
|
||||
%t46 = icmp ne i32 %t45, 0
|
||||
br i1 %t46, label %bbt47, label %bbt49
|
||||
bbt33:
|
||||
%t61 = load i32, i32* %t21
|
||||
%t62 = add i32 %t61, 1
|
||||
store i32 %t62, i32* %t21
|
||||
br label %bbt22
|
||||
bbt37:
|
||||
ret i32 0
|
||||
bbt38:
|
||||
%t59 = load i32, i32* %t28
|
||||
%t60 = add i32 %t59, 1
|
||||
store i32 %t60, i32* %t28
|
||||
br label %bbt31
|
||||
bbt47:
|
||||
%t50 = load i32, i32* %t28
|
||||
%t51 = getelementptr i32, i32* %arg1, i32 %t50
|
||||
%t52 = load i32, i32* %t51
|
||||
%t53 = load i32, i32* %t21
|
||||
%t54 = getelementptr i32, i32* %arg1, i32 %t53
|
||||
%t55 = load i32, i32* %t54
|
||||
%t56 = icmp eq i32 %t52, %t55
|
||||
br i1 %t56, label %bbt48, label %bbt49
|
||||
bbt48:
|
||||
store i32 1, i32* %t20
|
||||
br label %bbt49
|
||||
bbt49:
|
||||
%t57 = load i32, i32* %t20
|
||||
%t58 = icmp ne i32 %t57, 0
|
||||
br i1 %t58, label %bbt37, label %bbt38
|
||||
}
|
||||
define i32 @graphColoring(i32* %arg0, i32 %arg1, i32 %arg2, i32* %arg3) {
|
||||
entry:
|
||||
%t64 = alloca i32
|
||||
%t65 = alloca i32
|
||||
%t66 = alloca i32
|
||||
%t76 = alloca i32
|
||||
br label %bbt63
|
||||
bbt63:
|
||||
store i32 %arg1, i32* %t64
|
||||
store i32 %arg2, i32* %t65
|
||||
%t69 = load i32, i32* %t65
|
||||
%t70 = load i32, i32* @V
|
||||
%t71 = icmp eq i32 %t69, %t70
|
||||
br i1 %t71, label %bbt67, label %bbt68
|
||||
bbt67:
|
||||
%t74 = call i32 @isSafe(i32* %arg0, i32* %arg3)
|
||||
%t75 = icmp ne i32 %t74, 0
|
||||
br i1 %t75, label %bbt72, label %bbt73
|
||||
bbt68:
|
||||
store i32 1, i32* %t76
|
||||
br label %bbt77
|
||||
bbt72:
|
||||
call void @printSolution(i32* %arg3)
|
||||
ret i32 1
|
||||
bbt73:
|
||||
ret i32 0
|
||||
bbt77:
|
||||
%t80 = load i32, i32* %t76
|
||||
%t81 = load i32, i32* %t64
|
||||
%t82 = icmp sle i32 %t80, %t81
|
||||
br i1 %t82, label %bbt78, label %bbt79
|
||||
bbt78:
|
||||
%t83 = load i32, i32* %t76
|
||||
%t84 = load i32, i32* %t65
|
||||
%t85 = getelementptr i32, i32* %arg3, i32 %t84
|
||||
store i32 %t83, i32* %t85
|
||||
%t88 = load i32, i32* %t64
|
||||
%t89 = load i32, i32* %t65
|
||||
%t90 = add i32 %t89, 1
|
||||
%t91 = call i32 @graphColoring(i32* %arg0, i32 %t88, i32 %t90, i32* %arg3)
|
||||
%t92 = icmp ne i32 %t91, 0
|
||||
br i1 %t92, label %bbt86, label %bbt87
|
||||
bbt79:
|
||||
ret i32 0
|
||||
bbt86:
|
||||
ret i32 1
|
||||
bbt87:
|
||||
%t93 = load i32, i32* %t65
|
||||
%t94 = getelementptr i32, i32* %arg3, i32 %t93
|
||||
store i32 0, i32* %t94
|
||||
%t95 = load i32, i32* %t76
|
||||
%t96 = add i32 %t95, 1
|
||||
store i32 %t96, i32* %t76
|
||||
br label %bbt77
|
||||
}
|
||||
define i32 @main() {
|
||||
entry:
|
||||
%t98 = alloca i32
|
||||
%t99 = alloca i32, i32 16
|
||||
%t132 = alloca i32
|
||||
%t133 = alloca i32, i32 4
|
||||
%t138 = alloca i32
|
||||
br label %bbt97
|
||||
bbt97:
|
||||
%t100 = getelementptr i32, i32* %t99, i32 0
|
||||
store i32 0, i32* %t100
|
||||
%t101 = getelementptr i32, i32* %t99, i32 1
|
||||
store i32 0, i32* %t101
|
||||
%t102 = getelementptr i32, i32* %t99, i32 2
|
||||
store i32 0, i32* %t102
|
||||
%t103 = getelementptr i32, i32* %t99, i32 3
|
||||
store i32 0, i32* %t103
|
||||
%t104 = getelementptr i32, i32* %t99, i32 4
|
||||
store i32 0, i32* %t104
|
||||
%t105 = getelementptr i32, i32* %t99, i32 5
|
||||
store i32 0, i32* %t105
|
||||
%t106 = getelementptr i32, i32* %t99, i32 6
|
||||
store i32 0, i32* %t106
|
||||
%t107 = getelementptr i32, i32* %t99, i32 7
|
||||
store i32 0, i32* %t107
|
||||
%t108 = getelementptr i32, i32* %t99, i32 8
|
||||
store i32 0, i32* %t108
|
||||
%t109 = getelementptr i32, i32* %t99, i32 9
|
||||
store i32 0, i32* %t109
|
||||
%t110 = getelementptr i32, i32* %t99, i32 10
|
||||
store i32 0, i32* %t110
|
||||
%t111 = getelementptr i32, i32* %t99, i32 11
|
||||
store i32 0, i32* %t111
|
||||
%t112 = getelementptr i32, i32* %t99, i32 12
|
||||
store i32 0, i32* %t112
|
||||
%t113 = getelementptr i32, i32* %t99, i32 13
|
||||
store i32 0, i32* %t113
|
||||
%t114 = getelementptr i32, i32* %t99, i32 14
|
||||
store i32 0, i32* %t114
|
||||
%t115 = getelementptr i32, i32* %t99, i32 15
|
||||
store i32 0, i32* %t115
|
||||
%t116 = getelementptr i32, i32* %t99, i32 0
|
||||
store i32 0, i32* %t116
|
||||
%t117 = getelementptr i32, i32* %t99, i32 1
|
||||
store i32 1, i32* %t117
|
||||
%t118 = getelementptr i32, i32* %t99, i32 2
|
||||
store i32 1, i32* %t118
|
||||
%t119 = getelementptr i32, i32* %t99, i32 3
|
||||
store i32 1, i32* %t119
|
||||
%t120 = getelementptr i32, i32* %t99, i32 4
|
||||
store i32 1, i32* %t120
|
||||
%t121 = getelementptr i32, i32* %t99, i32 5
|
||||
store i32 0, i32* %t121
|
||||
%t122 = getelementptr i32, i32* %t99, i32 6
|
||||
store i32 1, i32* %t122
|
||||
%t123 = getelementptr i32, i32* %t99, i32 7
|
||||
store i32 0, i32* %t123
|
||||
%t124 = getelementptr i32, i32* %t99, i32 8
|
||||
store i32 1, i32* %t124
|
||||
%t125 = getelementptr i32, i32* %t99, i32 9
|
||||
store i32 1, i32* %t125
|
||||
%t126 = getelementptr i32, i32* %t99, i32 10
|
||||
store i32 0, i32* %t126
|
||||
%t127 = getelementptr i32, i32* %t99, i32 11
|
||||
store i32 1, i32* %t127
|
||||
%t128 = getelementptr i32, i32* %t99, i32 12
|
||||
store i32 1, i32* %t128
|
||||
%t129 = getelementptr i32, i32* %t99, i32 13
|
||||
store i32 0, i32* %t129
|
||||
%t130 = getelementptr i32, i32* %t99, i32 14
|
||||
store i32 1, i32* %t130
|
||||
%t131 = getelementptr i32, i32* %t99, i32 15
|
||||
store i32 0, i32* %t131
|
||||
store i32 3, i32* %t132
|
||||
%t134 = getelementptr i32, i32* %t133, i32 0
|
||||
store i32 0, i32* %t134
|
||||
%t135 = getelementptr i32, i32* %t133, i32 1
|
||||
store i32 0, i32* %t135
|
||||
%t136 = getelementptr i32, i32* %t133, i32 2
|
||||
store i32 0, i32* %t136
|
||||
%t137 = getelementptr i32, i32* %t133, i32 3
|
||||
store i32 0, i32* %t137
|
||||
store i32 0, i32* %t138
|
||||
br label %bbt139
|
||||
bbt139:
|
||||
%t142 = load i32, i32* %t138
|
||||
%t143 = load i32, i32* @V
|
||||
%t144 = icmp slt i32 %t142, %t143
|
||||
br i1 %t144, label %bbt140, label %bbt141
|
||||
bbt140:
|
||||
%t145 = load i32, i32* %t138
|
||||
%t146 = getelementptr i32, i32* %t133, i32 %t145
|
||||
store i32 0, i32* %t146
|
||||
%t147 = load i32, i32* %t138
|
||||
%t148 = add i32 %t147, 1
|
||||
store i32 %t148, i32* %t138
|
||||
br label %bbt139
|
||||
bbt141:
|
||||
%t151 = load i32, i32* %t132
|
||||
%t152 = call i32 @graphColoring(i32* %t99, i32 %t151, i32 0, i32* %t133)
|
||||
%t153 = icmp eq i32 %t152, 0
|
||||
br i1 %t153, label %bbt149, label %bbt150
|
||||
bbt149:
|
||||
call void @printMessage()
|
||||
br label %bbt150
|
||||
bbt150:
|
||||
ret i32 0
|
||||
}
|
||||
@ -0,0 +1,220 @@
|
||||
@MAX_SIZE = global i32 100
|
||||
@a = global [10000 x i32] zeroinitializer
|
||||
@b = global [10000 x i32] zeroinitializer
|
||||
@res = global [10000 x i32] zeroinitializer
|
||||
@n1 = global i32 0
|
||||
@m1 = global i32 0
|
||||
@n2 = global i32 0
|
||||
@m2 = global i32 0
|
||||
|
||||
declare i32 @getint()
|
||||
declare i32 @getch()
|
||||
declare void @putint(i32)
|
||||
declare void @putch(i32)
|
||||
declare i32 @getarray(i32*)
|
||||
declare void @putarray(i32, i32*)
|
||||
declare void @starttime()
|
||||
declare void @stoptime()
|
||||
define void @matrix_multiply() {
|
||||
entry:
|
||||
%t1 = alloca i32
|
||||
%t2 = alloca i32
|
||||
%t9 = alloca i32
|
||||
%t16 = alloca i32
|
||||
br label %bbt0
|
||||
bbt0:
|
||||
store i32 0, i32* %t2
|
||||
br label %bbt3
|
||||
bbt3:
|
||||
%t6 = load i32, i32* %t2
|
||||
%t7 = load i32, i32* @m1
|
||||
%t8 = icmp slt i32 %t6, %t7
|
||||
br i1 %t8, label %bbt4, label %bbt5
|
||||
bbt4:
|
||||
store i32 0, i32* %t9
|
||||
br label %bbt10
|
||||
bbt5:
|
||||
ret void
|
||||
bbt10:
|
||||
%t13 = load i32, i32* %t9
|
||||
%t14 = load i32, i32* @n2
|
||||
%t15 = icmp slt i32 %t13, %t14
|
||||
br i1 %t15, label %bbt11, label %bbt12
|
||||
bbt11:
|
||||
store i32 0, i32* %t16
|
||||
br label %bbt17
|
||||
bbt12:
|
||||
%t56 = load i32, i32* %t2
|
||||
%t57 = add i32 %t56, 1
|
||||
store i32 %t57, i32* %t2
|
||||
br label %bbt3
|
||||
bbt17:
|
||||
%t20 = load i32, i32* %t16
|
||||
%t21 = load i32, i32* @n1
|
||||
%t22 = icmp slt i32 %t20, %t21
|
||||
br i1 %t22, label %bbt18, label %bbt19
|
||||
bbt18:
|
||||
%t23 = load i32, i32* %t2
|
||||
%t24 = mul i32 %t23, 100
|
||||
%t25 = add i32 0, %t24
|
||||
%t26 = load i32, i32* %t9
|
||||
%t27 = add i32 %t25, %t26
|
||||
%t28 = getelementptr [10000 x i32], [10000 x i32]* @res, i32 0, i32 %t27
|
||||
%t29 = load i32, i32* %t28
|
||||
%t30 = load i32, i32* %t2
|
||||
%t31 = mul i32 %t30, 100
|
||||
%t32 = add i32 0, %t31
|
||||
%t33 = load i32, i32* %t16
|
||||
%t34 = add i32 %t32, %t33
|
||||
%t35 = getelementptr [10000 x i32], [10000 x i32]* @a, i32 0, i32 %t34
|
||||
%t36 = load i32, i32* %t35
|
||||
%t37 = load i32, i32* %t16
|
||||
%t38 = mul i32 %t37, 100
|
||||
%t39 = add i32 0, %t38
|
||||
%t40 = load i32, i32* %t9
|
||||
%t41 = add i32 %t39, %t40
|
||||
%t42 = getelementptr [10000 x i32], [10000 x i32]* @b, i32 0, i32 %t41
|
||||
%t43 = load i32, i32* %t42
|
||||
%t44 = mul i32 %t36, %t43
|
||||
%t45 = add i32 %t29, %t44
|
||||
%t46 = load i32, i32* %t2
|
||||
%t47 = mul i32 %t46, 100
|
||||
%t48 = add i32 0, %t47
|
||||
%t49 = load i32, i32* %t9
|
||||
%t50 = add i32 %t48, %t49
|
||||
%t51 = getelementptr [10000 x i32], [10000 x i32]* @res, i32 0, i32 %t50
|
||||
store i32 %t45, i32* %t51
|
||||
%t52 = load i32, i32* %t16
|
||||
%t53 = add i32 %t52, 1
|
||||
store i32 %t53, i32* %t16
|
||||
br label %bbt17
|
||||
bbt19:
|
||||
%t54 = load i32, i32* %t9
|
||||
%t55 = add i32 %t54, 1
|
||||
store i32 %t55, i32* %t9
|
||||
br label %bbt10
|
||||
}
|
||||
define i32 @main() {
|
||||
entry:
|
||||
%t59 = alloca i32
|
||||
%t60 = alloca i32
|
||||
%t61 = alloca i32
|
||||
br label %bbt58
|
||||
bbt58:
|
||||
store i32 0, i32* %t60
|
||||
store i32 0, i32* %t61
|
||||
%t62 = call i32 @getint()
|
||||
store i32 %t62, i32* @m1
|
||||
%t63 = call i32 @getint()
|
||||
store i32 %t63, i32* @n1
|
||||
store i32 0, i32* %t60
|
||||
br label %bbt64
|
||||
bbt64:
|
||||
%t67 = load i32, i32* %t60
|
||||
%t68 = load i32, i32* @m1
|
||||
%t69 = icmp slt i32 %t67, %t68
|
||||
br i1 %t69, label %bbt65, label %bbt66
|
||||
bbt65:
|
||||
store i32 0, i32* %t61
|
||||
br label %bbt70
|
||||
bbt66:
|
||||
%t87 = call i32 @getint()
|
||||
store i32 %t87, i32* @m2
|
||||
%t88 = call i32 @getint()
|
||||
store i32 %t88, i32* @n2
|
||||
store i32 0, i32* %t60
|
||||
br label %bbt89
|
||||
bbt70:
|
||||
%t73 = load i32, i32* %t61
|
||||
%t74 = load i32, i32* @n1
|
||||
%t75 = icmp slt i32 %t73, %t74
|
||||
br i1 %t75, label %bbt71, label %bbt72
|
||||
bbt71:
|
||||
%t76 = call i32 @getint()
|
||||
%t77 = load i32, i32* %t60
|
||||
%t78 = mul i32 %t77, 100
|
||||
%t79 = add i32 0, %t78
|
||||
%t80 = load i32, i32* %t61
|
||||
%t81 = add i32 %t79, %t80
|
||||
%t82 = getelementptr [10000 x i32], [10000 x i32]* @a, i32 0, i32 %t81
|
||||
store i32 %t76, i32* %t82
|
||||
%t83 = load i32, i32* %t61
|
||||
%t84 = add i32 %t83, 1
|
||||
store i32 %t84, i32* %t61
|
||||
br label %bbt70
|
||||
bbt72:
|
||||
%t85 = load i32, i32* %t60
|
||||
%t86 = add i32 %t85, 1
|
||||
store i32 %t86, i32* %t60
|
||||
br label %bbt64
|
||||
bbt89:
|
||||
%t92 = load i32, i32* %t60
|
||||
%t93 = load i32, i32* @m2
|
||||
%t94 = icmp slt i32 %t92, %t93
|
||||
br i1 %t94, label %bbt90, label %bbt91
|
||||
bbt90:
|
||||
store i32 0, i32* %t61
|
||||
br label %bbt95
|
||||
bbt91:
|
||||
call void @matrix_multiply()
|
||||
store i32 0, i32* %t60
|
||||
br label %bbt112
|
||||
bbt95:
|
||||
%t98 = load i32, i32* %t61
|
||||
%t99 = load i32, i32* @n2
|
||||
%t100 = icmp slt i32 %t98, %t99
|
||||
br i1 %t100, label %bbt96, label %bbt97
|
||||
bbt96:
|
||||
%t101 = call i32 @getint()
|
||||
%t102 = load i32, i32* %t60
|
||||
%t103 = mul i32 %t102, 100
|
||||
%t104 = add i32 0, %t103
|
||||
%t105 = load i32, i32* %t61
|
||||
%t106 = add i32 %t104, %t105
|
||||
%t107 = getelementptr [10000 x i32], [10000 x i32]* @b, i32 0, i32 %t106
|
||||
store i32 %t101, i32* %t107
|
||||
%t108 = load i32, i32* %t61
|
||||
%t109 = add i32 %t108, 1
|
||||
store i32 %t109, i32* %t61
|
||||
br label %bbt95
|
||||
bbt97:
|
||||
%t110 = load i32, i32* %t60
|
||||
%t111 = add i32 %t110, 1
|
||||
store i32 %t111, i32* %t60
|
||||
br label %bbt89
|
||||
bbt112:
|
||||
%t115 = load i32, i32* %t60
|
||||
%t116 = load i32, i32* @m1
|
||||
%t117 = icmp slt i32 %t115, %t116
|
||||
br i1 %t117, label %bbt113, label %bbt114
|
||||
bbt113:
|
||||
store i32 0, i32* %t61
|
||||
br label %bbt118
|
||||
bbt114:
|
||||
ret i32 0
|
||||
bbt118:
|
||||
%t121 = load i32, i32* %t61
|
||||
%t122 = load i32, i32* @n2
|
||||
%t123 = icmp slt i32 %t121, %t122
|
||||
br i1 %t123, label %bbt119, label %bbt120
|
||||
bbt119:
|
||||
%t124 = load i32, i32* %t60
|
||||
%t125 = mul i32 %t124, 100
|
||||
%t126 = add i32 0, %t125
|
||||
%t127 = load i32, i32* %t61
|
||||
%t128 = add i32 %t126, %t127
|
||||
%t129 = getelementptr [10000 x i32], [10000 x i32]* @res, i32 0, i32 %t128
|
||||
%t130 = load i32, i32* %t129
|
||||
call void @putint(i32 %t130)
|
||||
call void @putch(i32 32)
|
||||
%t131 = load i32, i32* %t61
|
||||
%t132 = add i32 %t131, 1
|
||||
store i32 %t132, i32* %t61
|
||||
br label %bbt118
|
||||
bbt120:
|
||||
call void @putch(i32 10)
|
||||
%t133 = load i32, i32* %t60
|
||||
%t134 = add i32 %t133, 1
|
||||
store i32 %t134, i32* %t60
|
||||
br label %bbt112
|
||||
}
|
||||
@ -0,0 +1,133 @@
|
||||
declare i32 @getint()
|
||||
declare i32 @getch()
|
||||
declare void @putint(i32)
|
||||
declare void @putch(i32)
|
||||
declare i32 @getarray(i32*)
|
||||
declare void @putarray(i32, i32*)
|
||||
declare void @starttime()
|
||||
declare void @stoptime()
|
||||
define i32 @main() {
|
||||
entry:
|
||||
%t1 = alloca i32
|
||||
%t2 = alloca i32
|
||||
%t3 = alloca i32
|
||||
%t6 = alloca i32
|
||||
%t18 = alloca i32
|
||||
%t34 = alloca i32
|
||||
%t49 = alloca i32
|
||||
%t54 = alloca i32
|
||||
%t67 = alloca i32
|
||||
br label %bbt0
|
||||
bbt0:
|
||||
call void @putch(i32 97)
|
||||
call void @putch(i32 10)
|
||||
store i32 1, i32* %t2
|
||||
store i32 0, i32* %t3
|
||||
%t4 = load i32, i32* %t2
|
||||
%t5 = add i32 %t4, 2
|
||||
store i32 %t5, i32* %t2
|
||||
%t7 = load i32, i32* %t2
|
||||
%t8 = add i32 %t7, 3
|
||||
store i32 %t8, i32* %t6
|
||||
%t9 = load i32, i32* %t6
|
||||
%t10 = add i32 %t9, 4
|
||||
store i32 %t10, i32* %t6
|
||||
%t11 = load i32, i32* %t3
|
||||
%t12 = load i32, i32* %t2
|
||||
%t13 = add i32 %t11, %t12
|
||||
%t14 = load i32, i32* %t6
|
||||
%t15 = add i32 %t13, %t14
|
||||
store i32 %t15, i32* %t3
|
||||
%t16 = load i32, i32* %t6
|
||||
%t17 = add i32 %t16, 5
|
||||
store i32 %t17, i32* %t6
|
||||
%t19 = load i32, i32* %t6
|
||||
%t20 = add i32 %t19, 6
|
||||
store i32 %t20, i32* %t18
|
||||
%t21 = load i32, i32* %t2
|
||||
%t22 = load i32, i32* %t18
|
||||
%t23 = add i32 %t21, %t22
|
||||
store i32 %t23, i32* %t2
|
||||
%t24 = load i32, i32* %t3
|
||||
%t25 = load i32, i32* %t2
|
||||
%t26 = add i32 %t24, %t25
|
||||
%t27 = load i32, i32* %t6
|
||||
%t28 = add i32 %t26, %t27
|
||||
%t29 = load i32, i32* %t18
|
||||
%t30 = add i32 %t28, %t29
|
||||
store i32 %t30, i32* %t3
|
||||
%t31 = load i32, i32* %t6
|
||||
%t32 = load i32, i32* %t2
|
||||
%t33 = add i32 %t31, %t32
|
||||
store i32 %t33, i32* %t6
|
||||
%t35 = load i32, i32* %t18
|
||||
%t36 = add i32 %t35, 7
|
||||
store i32 %t36, i32* %t34
|
||||
%t37 = load i32, i32* %t34
|
||||
%t38 = add i32 %t37, 8
|
||||
store i32 %t38, i32* %t34
|
||||
%t39 = load i32, i32* %t3
|
||||
%t40 = load i32, i32* %t34
|
||||
%t41 = add i32 %t39, %t40
|
||||
%t42 = load i32, i32* %t6
|
||||
%t43 = add i32 %t41, %t42
|
||||
%t44 = load i32, i32* %t18
|
||||
%t45 = add i32 %t43, %t44
|
||||
store i32 %t45, i32* %t3
|
||||
%t46 = load i32, i32* %t6
|
||||
%t47 = load i32, i32* %t34
|
||||
%t48 = add i32 %t46, %t47
|
||||
store i32 %t48, i32* %t6
|
||||
%t50 = load i32, i32* %t18
|
||||
%t51 = add i32 %t50, 9
|
||||
store i32 %t51, i32* %t49
|
||||
%t52 = load i32, i32* %t34
|
||||
%t53 = add i32 %t52, 10
|
||||
store i32 %t53, i32* %t34
|
||||
store i32 11, i32* %t54
|
||||
%t55 = load i32, i32* %t49
|
||||
%t56 = add i32 %t55, 12
|
||||
store i32 %t56, i32* %t49
|
||||
%t57 = load i32, i32* %t3
|
||||
%t58 = load i32, i32* %t54
|
||||
%t59 = add i32 %t57, %t58
|
||||
%t60 = load i32, i32* %t49
|
||||
%t61 = add i32 %t59, %t60
|
||||
%t62 = load i32, i32* %t18
|
||||
%t63 = add i32 %t61, %t62
|
||||
store i32 %t63, i32* %t3
|
||||
%t64 = load i32, i32* %t18
|
||||
%t65 = load i32, i32* %t49
|
||||
%t66 = add i32 %t64, %t65
|
||||
store i32 %t66, i32* %t18
|
||||
%t68 = load i32, i32* %t49
|
||||
%t69 = add i32 %t68, 13
|
||||
store i32 %t69, i32* %t67
|
||||
%t70 = load i32, i32* %t67
|
||||
%t71 = load i32, i32* %t54
|
||||
%t72 = add i32 %t70, %t71
|
||||
store i32 %t72, i32* %t67
|
||||
%t73 = load i32, i32* %t3
|
||||
%t74 = load i32, i32* %t54
|
||||
%t75 = add i32 %t73, %t74
|
||||
%t76 = load i32, i32* %t49
|
||||
%t77 = add i32 %t75, %t76
|
||||
%t78 = load i32, i32* %t67
|
||||
%t79 = add i32 %t77, %t78
|
||||
store i32 %t79, i32* %t3
|
||||
%t80 = load i32, i32* %t3
|
||||
%t81 = load i32, i32* %t18
|
||||
%t82 = sub i32 %t80, %t81
|
||||
store i32 %t82, i32* %t3
|
||||
%t83 = load i32, i32* %t3
|
||||
%t84 = load i32, i32* %t6
|
||||
%t85 = sub i32 %t83, %t84
|
||||
store i32 %t85, i32* %t3
|
||||
%t86 = load i32, i32* %t3
|
||||
%t87 = load i32, i32* %t2
|
||||
%t88 = sub i32 %t86, %t87
|
||||
store i32 %t88, i32* %t3
|
||||
%t89 = load i32, i32* %t3
|
||||
%t90 = srem i32 %t89, 77
|
||||
ret i32 %t90
|
||||
}
|
||||
@ -0,0 +1,43 @@
|
||||
declare i32 @getint()
|
||||
declare i32 @getch()
|
||||
declare void @putint(i32)
|
||||
declare void @putch(i32)
|
||||
declare i32 @getarray(i32*)
|
||||
declare void @putarray(i32, i32*)
|
||||
declare void @starttime()
|
||||
declare void @stoptime()
|
||||
define i32 @main() {
|
||||
entry:
|
||||
%t1 = alloca i32
|
||||
%t2 = alloca i32
|
||||
%t3 = alloca i32
|
||||
br label %bbt0
|
||||
bbt0:
|
||||
store i32 0, i32* %t2
|
||||
store i32 0, i32* %t2
|
||||
store i32 0, i32* %t3
|
||||
store i32 0, i32* %t3
|
||||
br label %bbt4
|
||||
bbt4:
|
||||
%t7 = load i32, i32* %t2
|
||||
%t8 = icmp slt i32 %t7, 100
|
||||
br i1 %t8, label %bbt5, label %bbt6
|
||||
bbt5:
|
||||
%t11 = load i32, i32* %t2
|
||||
%t12 = icmp eq i32 %t11, 50
|
||||
br i1 %t12, label %bbt9, label %bbt10
|
||||
bbt6:
|
||||
%t18 = load i32, i32* %t3
|
||||
ret i32 %t18
|
||||
bbt9:
|
||||
br label %bbt6
|
||||
bbt10:
|
||||
%t13 = load i32, i32* %t3
|
||||
%t14 = load i32, i32* %t2
|
||||
%t15 = add i32 %t13, %t14
|
||||
store i32 %t15, i32* %t3
|
||||
%t16 = load i32, i32* %t2
|
||||
%t17 = add i32 %t16, 1
|
||||
store i32 %t17, i32* %t2
|
||||
br label %bbt4
|
||||
}
|
||||
@ -0,0 +1,34 @@
|
||||
declare i32 @getint()
|
||||
declare i32 @getch()
|
||||
declare void @putint(i32)
|
||||
declare void @putch(i32)
|
||||
declare i32 @getarray(i32*)
|
||||
declare void @putarray(i32, i32*)
|
||||
declare void @starttime()
|
||||
declare void @stoptime()
|
||||
define i32 @main() {
|
||||
entry:
|
||||
%t1 = alloca i32
|
||||
%t2 = alloca i32
|
||||
%t3 = alloca i32
|
||||
%t4 = alloca i32
|
||||
%t5 = alloca i32
|
||||
br label %bbt0
|
||||
bbt0:
|
||||
store i32 0, i32* %t2
|
||||
store i32 0, i32* %t3
|
||||
store i32 0, i32* %t4
|
||||
store i32 0, i32* %t5
|
||||
store i32 10, i32* %t2
|
||||
store i32 4, i32* %t3
|
||||
store i32 2, i32* %t4
|
||||
store i32 2, i32* %t5
|
||||
%t6 = load i32, i32* %t4
|
||||
%t7 = load i32, i32* %t2
|
||||
%t8 = add i32 %t6, %t7
|
||||
%t9 = load i32, i32* %t3
|
||||
%t10 = load i32, i32* %t5
|
||||
%t11 = sub i32 %t9, %t10
|
||||
%t12 = mul i32 %t8, %t11
|
||||
ret i32 %t12
|
||||
}
|
||||
@ -0,0 +1,280 @@
|
||||
; ModuleID = '/tmp/nudt_float_fallback_EB5hgk.c'
|
||||
source_filename = "/tmp/nudt_float_fallback_EB5hgk.c"
|
||||
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
|
||||
target triple = "x86_64-pc-linux-gnu"
|
||||
|
||||
@RADIUS = dso_local constant float 5.500000e+00, align 4
|
||||
@PI = dso_local constant float 0x400921FB60000000, align 4
|
||||
@EPS = dso_local constant float 0x3EB0C6F7A0000000, align 4
|
||||
@PI_HEX = dso_local constant float 0x400921FB60000000, align 4
|
||||
@HEX2 = dso_local constant float 7.812500e-02, align 4
|
||||
@FACT = dso_local constant float -3.300000e+04, align 4
|
||||
@EVAL1 = dso_local constant float 0x4057C21FC0000000, align 4
|
||||
@EVAL2 = dso_local constant float 0x4041475CE0000000, align 4
|
||||
@EVAL3 = dso_local constant float 0x4041475CE0000000, align 4
|
||||
@CONV1 = dso_local constant float 2.330000e+02, align 4
|
||||
@CONV2 = dso_local constant float 4.095000e+03, align 4
|
||||
@MAX = dso_local constant i32 1000000000, align 4
|
||||
@TWO = dso_local constant i32 2, align 4
|
||||
@THREE = dso_local constant i32 3, align 4
|
||||
@FIVE = dso_local constant i32 5, align 4
|
||||
|
||||
; Function Attrs: noinline nounwind optnone uwtable
|
||||
define dso_local float @float_abs(float noundef %0) #0 {
|
||||
%2 = alloca float, align 4
|
||||
%3 = alloca float, align 4
|
||||
store float %0, ptr %3, align 4
|
||||
%4 = load float, ptr %3, align 4
|
||||
%5 = fcmp olt float %4, 0.000000e+00
|
||||
br i1 %5, label %6, label %9
|
||||
|
||||
6: ; preds = %1
|
||||
%7 = load float, ptr %3, align 4
|
||||
%8 = fneg float %7
|
||||
store float %8, ptr %2, align 4
|
||||
br label %11
|
||||
|
||||
9: ; preds = %1
|
||||
%10 = load float, ptr %3, align 4
|
||||
store float %10, ptr %2, align 4
|
||||
br label %11
|
||||
|
||||
11: ; preds = %9, %6
|
||||
%12 = load float, ptr %2, align 4
|
||||
ret float %12
|
||||
}
|
||||
|
||||
; Function Attrs: noinline nounwind optnone uwtable
|
||||
define dso_local float @circle_area(i32 noundef %0) #0 {
|
||||
%2 = alloca i32, align 4
|
||||
store i32 %0, ptr %2, align 4
|
||||
%3 = load i32, ptr %2, align 4
|
||||
%4 = sitofp i32 %3 to float
|
||||
%5 = fmul float 0x400921FB60000000, %4
|
||||
%6 = load i32, ptr %2, align 4
|
||||
%7 = sitofp i32 %6 to float
|
||||
%8 = load i32, ptr %2, align 4
|
||||
%9 = load i32, ptr %2, align 4
|
||||
%10 = mul nsw i32 %8, %9
|
||||
%11 = sitofp i32 %10 to float
|
||||
%12 = fmul float %11, 0x400921FB60000000
|
||||
%13 = call float @llvm.fmuladd.f32(float %5, float %7, float %12)
|
||||
%14 = fdiv float %13, 2.000000e+00
|
||||
ret float %14
|
||||
}
|
||||
|
||||
; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
|
||||
declare float @llvm.fmuladd.f32(float, float, float) #1
|
||||
|
||||
; Function Attrs: noinline nounwind optnone uwtable
|
||||
define dso_local i32 @float_eq(float noundef %0, float noundef %1) #0 {
|
||||
%3 = alloca i32, align 4
|
||||
%4 = alloca float, align 4
|
||||
%5 = alloca float, align 4
|
||||
store float %0, ptr %4, align 4
|
||||
store float %1, ptr %5, align 4
|
||||
%6 = load float, ptr %4, align 4
|
||||
%7 = load float, ptr %5, align 4
|
||||
%8 = fsub float %6, %7
|
||||
%9 = call float @float_abs(float noundef %8)
|
||||
%10 = fcmp olt float %9, 0x3EB0C6F7A0000000
|
||||
br i1 %10, label %11, label %12
|
||||
|
||||
11: ; preds = %2
|
||||
store i32 1, ptr %3, align 4
|
||||
br label %13
|
||||
|
||||
12: ; preds = %2
|
||||
store i32 0, ptr %3, align 4
|
||||
br label %13
|
||||
|
||||
13: ; preds = %12, %11
|
||||
%14 = load i32, ptr %3, align 4
|
||||
ret i32 %14
|
||||
}
|
||||
|
||||
; Function Attrs: noinline nounwind optnone uwtable
|
||||
define dso_local void @error() #0 {
|
||||
call void @putch(i32 noundef 101)
|
||||
call void @putch(i32 noundef 114)
|
||||
call void @putch(i32 noundef 114)
|
||||
call void @putch(i32 noundef 111)
|
||||
call void @putch(i32 noundef 114)
|
||||
call void @putch(i32 noundef 10)
|
||||
ret void
|
||||
}
|
||||
|
||||
declare void @putch(i32 noundef) #2
|
||||
|
||||
; Function Attrs: noinline nounwind optnone uwtable
|
||||
define dso_local void @ok() #0 {
|
||||
call void @putch(i32 noundef 111)
|
||||
call void @putch(i32 noundef 107)
|
||||
call void @putch(i32 noundef 10)
|
||||
ret void
|
||||
}
|
||||
|
||||
; Function Attrs: noinline nounwind optnone uwtable
|
||||
define dso_local void @assert(i32 noundef %0) #0 {
|
||||
%2 = alloca i32, align 4
|
||||
store i32 %0, ptr %2, align 4
|
||||
%3 = load i32, ptr %2, align 4
|
||||
%4 = icmp ne i32 %3, 0
|
||||
br i1 %4, label %6, label %5
|
||||
|
||||
5: ; preds = %1
|
||||
call void @error()
|
||||
br label %7
|
||||
|
||||
6: ; preds = %1
|
||||
call void @ok()
|
||||
br label %7
|
||||
|
||||
7: ; preds = %6, %5
|
||||
ret void
|
||||
}
|
||||
|
||||
; Function Attrs: noinline nounwind optnone uwtable
|
||||
define dso_local void @assert_not(i32 noundef %0) #0 {
|
||||
%2 = alloca i32, align 4
|
||||
store i32 %0, ptr %2, align 4
|
||||
%3 = load i32, ptr %2, align 4
|
||||
%4 = icmp ne i32 %3, 0
|
||||
br i1 %4, label %5, label %6
|
||||
|
||||
5: ; preds = %1
|
||||
call void @error()
|
||||
br label %7
|
||||
|
||||
6: ; preds = %1
|
||||
call void @ok()
|
||||
br label %7
|
||||
|
||||
7: ; preds = %6, %5
|
||||
ret void
|
||||
}
|
||||
|
||||
; Function Attrs: noinline nounwind optnone uwtable
|
||||
define dso_local i32 @main() #0 {
|
||||
%1 = alloca i32, align 4
|
||||
%2 = alloca i32, align 4
|
||||
%3 = alloca i32, align 4
|
||||
%4 = alloca [10 x float], align 16
|
||||
%5 = alloca i32, align 4
|
||||
%6 = alloca float, align 4
|
||||
%7 = alloca float, align 4
|
||||
%8 = alloca float, align 4
|
||||
store i32 0, ptr %1, align 4
|
||||
%9 = call i32 @float_eq(float noundef 7.812500e-02, float noundef -3.300000e+04)
|
||||
call void @assert_not(i32 noundef %9)
|
||||
%10 = call i32 @float_eq(float noundef 0x4057C21FC0000000, float noundef 0x4041475CE0000000)
|
||||
call void @assert_not(i32 noundef %10)
|
||||
%11 = call i32 @float_eq(float noundef 0x4041475CE0000000, float noundef 0x4041475CE0000000)
|
||||
call void @assert(i32 noundef %11)
|
||||
%12 = call float @circle_area(i32 noundef 5)
|
||||
%13 = call float @circle_area(i32 noundef 5)
|
||||
%14 = call i32 @float_eq(float noundef %12, float noundef %13)
|
||||
call void @assert(i32 noundef %14)
|
||||
%15 = call i32 @float_eq(float noundef 2.330000e+02, float noundef 4.095000e+03)
|
||||
call void @assert_not(i32 noundef %15)
|
||||
br i1 true, label %16, label %17
|
||||
|
||||
16: ; preds = %0
|
||||
call void @ok()
|
||||
br label %17
|
||||
|
||||
17: ; preds = %16, %0
|
||||
call void @ok()
|
||||
call void @ok()
|
||||
store i32 1, ptr %2, align 4
|
||||
store i32 0, ptr %3, align 4
|
||||
call void @llvm.memset.p0.i64(ptr align 16 %4, i8 0, i64 40, i1 false)
|
||||
%18 = getelementptr inbounds <{ float, float, [8 x float] }>, ptr %4, i32 0, i32 0
|
||||
store float 1.000000e+00, ptr %18, align 16
|
||||
%19 = getelementptr inbounds <{ float, float, [8 x float] }>, ptr %4, i32 0, i32 1
|
||||
store float 2.000000e+00, ptr %19, align 4
|
||||
%20 = getelementptr inbounds [10 x float], ptr %4, i64 0, i64 0
|
||||
%21 = call i32 @getfarray(ptr noundef %20)
|
||||
store i32 %21, ptr %5, align 4
|
||||
br label %22
|
||||
|
||||
22: ; preds = %25, %17
|
||||
%23 = load i32, ptr %2, align 4
|
||||
%24 = icmp slt i32 %23, 1000000000
|
||||
br i1 %24, label %25, label %52
|
||||
|
||||
25: ; preds = %22
|
||||
%26 = call float @getfloat()
|
||||
store float %26, ptr %6, align 4
|
||||
%27 = load float, ptr %6, align 4
|
||||
%28 = fmul float 0x400921FB60000000, %27
|
||||
%29 = load float, ptr %6, align 4
|
||||
%30 = fmul float %28, %29
|
||||
store float %30, ptr %7, align 4
|
||||
%31 = load float, ptr %6, align 4
|
||||
%32 = fptosi float %31 to i32
|
||||
%33 = call float @circle_area(i32 noundef %32)
|
||||
store float %33, ptr %8, align 4
|
||||
%34 = load i32, ptr %3, align 4
|
||||
%35 = sext i32 %34 to i64
|
||||
%36 = getelementptr inbounds [10 x float], ptr %4, i64 0, i64 %35
|
||||
%37 = load float, ptr %36, align 4
|
||||
%38 = load float, ptr %6, align 4
|
||||
%39 = fadd float %37, %38
|
||||
%40 = load i32, ptr %3, align 4
|
||||
%41 = sext i32 %40 to i64
|
||||
%42 = getelementptr inbounds [10 x float], ptr %4, i64 0, i64 %41
|
||||
store float %39, ptr %42, align 4
|
||||
%43 = load float, ptr %7, align 4
|
||||
call void @putfloat(float noundef %43)
|
||||
call void @putch(i32 noundef 32)
|
||||
%44 = load float, ptr %8, align 4
|
||||
%45 = fptosi float %44 to i32
|
||||
call void @putint(i32 noundef %45)
|
||||
call void @putch(i32 noundef 10)
|
||||
%46 = load i32, ptr %2, align 4
|
||||
%47 = sitofp i32 %46 to double
|
||||
%48 = fmul double %47, 1.000000e+01
|
||||
%49 = fptosi double %48 to i32
|
||||
store i32 %49, ptr %2, align 4
|
||||
%50 = load i32, ptr %3, align 4
|
||||
%51 = add nsw i32 %50, 1
|
||||
store i32 %51, ptr %3, align 4
|
||||
br label %22, !llvm.loop !6
|
||||
|
||||
52: ; preds = %22
|
||||
%53 = load i32, ptr %5, align 4
|
||||
%54 = getelementptr inbounds [10 x float], ptr %4, i64 0, i64 0
|
||||
call void @putfarray(i32 noundef %53, ptr noundef %54)
|
||||
ret i32 0
|
||||
}
|
||||
|
||||
; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
|
||||
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #3
|
||||
|
||||
declare i32 @getfarray(ptr noundef) #2
|
||||
|
||||
declare float @getfloat() #2
|
||||
|
||||
declare void @putfloat(float noundef) #2
|
||||
|
||||
declare void @putint(i32 noundef) #2
|
||||
|
||||
declare void @putfarray(i32 noundef, ptr noundef) #2
|
||||
|
||||
attributes #0 = { noinline nounwind optnone uwtable "frame-pointer"="all" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
|
||||
attributes #1 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
|
||||
attributes #2 = { "frame-pointer"="all" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
|
||||
attributes #3 = { nocallback nofree nounwind willreturn memory(argmem: write) }
|
||||
|
||||
!llvm.module.flags = !{!0, !1, !2, !3, !4}
|
||||
!llvm.ident = !{!5}
|
||||
|
||||
!0 = !{i32 1, !"wchar_size", i32 4}
|
||||
!1 = !{i32 8, !"PIC Level", i32 2}
|
||||
!2 = !{i32 7, !"PIE Level", i32 2}
|
||||
!3 = !{i32 7, !"uwtable", i32 2}
|
||||
!4 = !{i32 7, !"frame-pointer", i32 2}
|
||||
!5 = !{!"Ubuntu clang version 18.1.3 (1ubuntu1)"}
|
||||
!6 = distinct !{!6, !7}
|
||||
!7 = !{!"llvm.loop.mustprogress"}
|
||||
@ -0,0 +1,22 @@
|
||||
declare i32 @getint()
|
||||
declare i32 @getch()
|
||||
declare void @putint(i32)
|
||||
declare void @putch(i32)
|
||||
declare i32 @getarray(i32*)
|
||||
declare void @putarray(i32, i32*)
|
||||
declare void @starttime()
|
||||
declare void @stoptime()
|
||||
define i32 @main() {
|
||||
entry:
|
||||
%t1 = alloca i32
|
||||
%t2 = alloca i32
|
||||
%t3 = alloca i32
|
||||
br label %bbt0
|
||||
bbt0:
|
||||
store i32 1, i32* %t2
|
||||
store i32 2, i32* %t3
|
||||
%t4 = load i32, i32* %t2
|
||||
%t5 = load i32, i32* %t3
|
||||
%t6 = add i32 %t4, %t5
|
||||
ret i32 %t6
|
||||
}
|
||||
Loading…
Reference in new issue