You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

193 lines
6.6 KiB

@N = global i32 100010
@M = global i32 3000000
@x = global [100010 x i32] zeroinitializer
@y = global [3000000 x i32] zeroinitializer
@v = global [3000000 x i32] zeroinitializer
@a = global [100010 x i32] zeroinitializer
@b = global [100010 x i32] zeroinitializer
@c = global [100010 x i32] zeroinitializer
declare i32 @getint()
declare float @getfloat()
declare i32 @getarray(i32* %arg.a)
declare i32 @getfarray(float* %arg.a)
declare i32 @getch()
declare void @putint(i32 %arg.x)
declare void @putfloat(float %arg.x)
declare void @putarray(i32 %arg.n, i32* %arg.a)
declare void @putfarray(i32 %arg.n, float* %arg.a)
declare void @putch(i32 %arg.x)
declare void @starttime()
declare void @stoptime()
define void @spmv(i32 %arg.n, i32* %arg.xptr, i32* %arg.yidx, i32* %arg.vals, i32* %arg.b, i32* %arg.x) {
entry:
%t1 = alloca i32
%t2 = alloca i32
%t3 = alloca i32
%t0 = alloca i32
store i32 %arg.n, i32* %t0
store i32 0, i32* %t1
store i32 0, i32* %t2
store i32 0, i32* %t3
store i32 0, i32* %t1
br label %while.cond.1
while.cond.1:
%t4 = load i32, i32* %t1
%t5 = load i32, i32* %t0
%t6 = icmp slt i32 %t4, %t5
%t7 = zext i1 %t6 to i32
%t8 = icmp ne i32 %t7, 0
br i1 %t8, label %while.body.2, label %while.end.3
while.body.2:
%t9 = load i32, i32* %t1
%t10 = getelementptr inbounds i32, i32* %arg.x, i32 %t9
store i32 0, i32* %t10
%t11 = load i32, i32* %t1
%t12 = add i32 %t11, 1
store i32 %t12, i32* %t1
br label %while.cond.1
while.end.3:
store i32 0, i32* %t1
br label %while.cond.4
while.cond.4:
%t13 = load i32, i32* %t1
%t14 = load i32, i32* %t0
%t15 = icmp slt i32 %t13, %t14
%t16 = zext i1 %t15 to i32
%t17 = icmp ne i32 %t16, 0
br i1 %t17, label %while.body.5, label %while.end.6
while.body.5:
%t18 = load i32, i32* %t1
%t19 = getelementptr inbounds i32, i32* %arg.xptr, i32 %t18
%t20 = load i32, i32* %t19
store i32 %t20, i32* %t2
br label %while.cond.7
while.end.6:
ret void
while.cond.7:
%t21 = load i32, i32* %t2
%t22 = load i32, i32* %t1
%t23 = add i32 %t22, 1
%t24 = getelementptr inbounds i32, i32* %arg.xptr, i32 %t23
%t25 = load i32, i32* %t24
%t26 = icmp slt i32 %t21, %t25
%t27 = zext i1 %t26 to i32
%t28 = icmp ne i32 %t27, 0
br i1 %t28, label %while.body.8, label %while.end.9
while.body.8:
%t29 = load i32, i32* %t2
%t30 = getelementptr inbounds i32, i32* %arg.yidx, i32 %t29
%t31 = load i32, i32* %t30
%t32 = getelementptr inbounds i32, i32* %arg.x, i32 %t31
%t33 = load i32, i32* %t2
%t34 = getelementptr inbounds i32, i32* %arg.yidx, i32 %t33
%t35 = load i32, i32* %t34
%t36 = getelementptr inbounds i32, i32* %arg.x, i32 %t35
%t37 = load i32, i32* %t36
%t38 = load i32, i32* %t2
%t39 = getelementptr inbounds i32, i32* %arg.vals, i32 %t38
%t40 = load i32, i32* %t39
%t41 = add i32 %t37, %t40
store i32 %t41, i32* %t32
%t42 = load i32, i32* %t2
%t43 = add i32 %t42, 1
store i32 %t43, i32* %t2
br label %while.cond.7
while.end.9:
%t44 = load i32, i32* %t1
%t45 = getelementptr inbounds i32, i32* %arg.xptr, i32 %t44
%t46 = load i32, i32* %t45
store i32 %t46, i32* %t2
br label %while.cond.10
while.cond.10:
%t47 = load i32, i32* %t2
%t48 = load i32, i32* %t1
%t49 = add i32 %t48, 1
%t50 = getelementptr inbounds i32, i32* %arg.xptr, i32 %t49
%t51 = load i32, i32* %t50
%t52 = icmp slt i32 %t47, %t51
%t53 = zext i1 %t52 to i32
%t54 = icmp ne i32 %t53, 0
br i1 %t54, label %while.body.11, label %while.end.12
while.body.11:
%t55 = load i32, i32* %t2
%t56 = getelementptr inbounds i32, i32* %arg.yidx, i32 %t55
%t57 = load i32, i32* %t56
%t58 = getelementptr inbounds i32, i32* %arg.x, i32 %t57
%t59 = load i32, i32* %t2
%t60 = getelementptr inbounds i32, i32* %arg.yidx, i32 %t59
%t61 = load i32, i32* %t60
%t62 = getelementptr inbounds i32, i32* %arg.x, i32 %t61
%t63 = load i32, i32* %t62
%t64 = load i32, i32* %t2
%t65 = getelementptr inbounds i32, i32* %arg.vals, i32 %t64
%t66 = load i32, i32* %t65
%t67 = load i32, i32* %t1
%t68 = getelementptr inbounds i32, i32* %arg.b, i32 %t67
%t69 = load i32, i32* %t68
%t70 = sub i32 %t69, 1
%t71 = mul i32 %t66, %t70
%t72 = add i32 %t63, %t71
store i32 %t72, i32* %t58
%t73 = load i32, i32* %t2
%t74 = add i32 %t73, 1
store i32 %t74, i32* %t2
br label %while.cond.10
while.end.12:
%t75 = load i32, i32* %t1
%t76 = add i32 %t75, 1
store i32 %t76, i32* %t1
br label %while.cond.4
}
define i32 @main() {
entry:
%t77 = alloca i32
%t81 = alloca i32
%t89 = alloca i32
%t78 = getelementptr inbounds [100010 x i32], [100010 x i32]* @x, i32 0, i32 0
%t79 = call i32 @getarray(i32* %t78)
%t80 = sub i32 %t79, 1
store i32 %t80, i32* %t77
%t82 = getelementptr inbounds [3000000 x i32], [3000000 x i32]* @y, i32 0, i32 0
%t83 = call i32 @getarray(i32* %t82)
store i32 %t83, i32* %t81
%t84 = getelementptr inbounds [3000000 x i32], [3000000 x i32]* @v, i32 0, i32 0
%t85 = call i32 @getarray(i32* %t84)
%t86 = getelementptr inbounds [100010 x i32], [100010 x i32]* @a, i32 0, i32 0
%t87 = call i32 @getarray(i32* %t86)
call void @starttime()
store i32 0, i32* %t89
br label %while.cond.13
while.cond.13:
%t90 = load i32, i32* %t89
%t91 = icmp slt i32 %t90, 100
%t92 = zext i1 %t91 to i32
%t93 = icmp ne i32 %t92, 0
br i1 %t93, label %while.body.14, label %while.end.15
while.body.14:
%t94 = load i32, i32* %t77
%t95 = getelementptr inbounds [100010 x i32], [100010 x i32]* @x, i32 0, i32 0
%t96 = getelementptr inbounds [3000000 x i32], [3000000 x i32]* @y, i32 0, i32 0
%t97 = getelementptr inbounds [3000000 x i32], [3000000 x i32]* @v, i32 0, i32 0
%t98 = getelementptr inbounds [100010 x i32], [100010 x i32]* @a, i32 0, i32 0
%t99 = getelementptr inbounds [100010 x i32], [100010 x i32]* @b, i32 0, i32 0
call void @spmv(i32 %t94, i32* %t95, i32* %t96, i32* %t97, i32* %t98, i32* %t99)
%t101 = load i32, i32* %t77
%t102 = getelementptr inbounds [100010 x i32], [100010 x i32]* @x, i32 0, i32 0
%t103 = getelementptr inbounds [3000000 x i32], [3000000 x i32]* @y, i32 0, i32 0
%t104 = getelementptr inbounds [3000000 x i32], [3000000 x i32]* @v, i32 0, i32 0
%t105 = getelementptr inbounds [100010 x i32], [100010 x i32]* @b, i32 0, i32 0
%t106 = getelementptr inbounds [100010 x i32], [100010 x i32]* @a, i32 0, i32 0
call void @spmv(i32 %t101, i32* %t102, i32* %t103, i32* %t104, i32* %t105, i32* %t106)
%t108 = load i32, i32* %t89
%t109 = add i32 %t108, 1
store i32 %t109, i32* %t89
br label %while.cond.13
while.end.15:
call void @stoptime()
%t111 = load i32, i32* %t77
%t112 = getelementptr inbounds [100010 x i32], [100010 x i32]* @b, i32 0, i32 0
call void @putarray(i32 %t111, i32* %t112)
ret i32 0
}