192 lines
8.3 KiB
LLVM
192 lines
8.3 KiB
LLVM
; ModuleID = 'github.com/goplus/llgo/cl/_testrt/intgen'
|
|
source_filename = "github.com/goplus/llgo/cl/_testrt/intgen"
|
|
|
|
%"github.com/goplus/llgo/runtime/internal/runtime.Slice" = type { ptr, i64, i64 }
|
|
%"github.com/goplus/llgo/cl/_testrt/intgen.generator" = type { i32 }
|
|
|
|
@"github.com/goplus/llgo/cl/_testrt/intgen.init$guard" = global i1 false, align 1
|
|
@0 = private unnamed_addr constant [4 x i8] c"%d\0A\00", align 1
|
|
@1 = private unnamed_addr constant [4 x i8] c"%d\0A\00", align 1
|
|
@2 = private unnamed_addr constant [4 x i8] c"%d\0A\00", align 1
|
|
|
|
define %"github.com/goplus/llgo/runtime/internal/runtime.Slice" @"github.com/goplus/llgo/cl/_testrt/intgen.genInts"(i64 %0, { ptr, ptr } %1) {
|
|
_llgo_0:
|
|
%2 = call %"github.com/goplus/llgo/runtime/internal/runtime.Slice" @"github.com/goplus/llgo/runtime/internal/runtime.MakeSlice"(i64 %0, i64 %0, i64 4)
|
|
%3 = extractvalue %"github.com/goplus/llgo/runtime/internal/runtime.Slice" %2, 1
|
|
br label %_llgo_1
|
|
|
|
_llgo_1: ; preds = %_llgo_2, %_llgo_0
|
|
%4 = phi i64 [ -1, %_llgo_0 ], [ %5, %_llgo_2 ]
|
|
%5 = add i64 %4, 1
|
|
%6 = icmp slt i64 %5, %3
|
|
br i1 %6, label %_llgo_2, label %_llgo_3
|
|
|
|
_llgo_2: ; preds = %_llgo_1
|
|
%7 = extractvalue { ptr, ptr } %1, 1
|
|
%8 = extractvalue { ptr, ptr } %1, 0
|
|
%9 = call i32 %8(ptr %7)
|
|
%10 = extractvalue %"github.com/goplus/llgo/runtime/internal/runtime.Slice" %2, 0
|
|
%11 = extractvalue %"github.com/goplus/llgo/runtime/internal/runtime.Slice" %2, 1
|
|
%12 = icmp slt i64 %5, 0
|
|
%13 = icmp sge i64 %5, %11
|
|
%14 = or i1 %13, %12
|
|
call void @"github.com/goplus/llgo/runtime/internal/runtime.AssertIndexRange"(i1 %14)
|
|
%15 = getelementptr inbounds i32, ptr %10, i64 %5
|
|
store i32 %9, ptr %15, align 4
|
|
br label %_llgo_1
|
|
|
|
_llgo_3: ; preds = %_llgo_1
|
|
ret %"github.com/goplus/llgo/runtime/internal/runtime.Slice" %2
|
|
}
|
|
|
|
define i32 @"github.com/goplus/llgo/cl/_testrt/intgen.(*generator).next"(ptr %0) {
|
|
_llgo_0:
|
|
%1 = getelementptr inbounds %"github.com/goplus/llgo/cl/_testrt/intgen.generator", ptr %0, i32 0, i32 0
|
|
%2 = load i32, ptr %1, align 4
|
|
%3 = add i32 %2, 1
|
|
%4 = getelementptr inbounds %"github.com/goplus/llgo/cl/_testrt/intgen.generator", ptr %0, i32 0, i32 0
|
|
store i32 %3, ptr %4, align 4
|
|
%5 = getelementptr inbounds %"github.com/goplus/llgo/cl/_testrt/intgen.generator", ptr %0, i32 0, i32 0
|
|
%6 = load i32, ptr %5, align 4
|
|
ret i32 %6
|
|
}
|
|
|
|
define void @"github.com/goplus/llgo/cl/_testrt/intgen.init"() {
|
|
_llgo_0:
|
|
%0 = load i1, ptr @"github.com/goplus/llgo/cl/_testrt/intgen.init$guard", align 1
|
|
br i1 %0, label %_llgo_2, label %_llgo_1
|
|
|
|
_llgo_1: ; preds = %_llgo_0
|
|
store i1 true, ptr @"github.com/goplus/llgo/cl/_testrt/intgen.init$guard", align 1
|
|
br label %_llgo_2
|
|
|
|
_llgo_2: ; preds = %_llgo_1, %_llgo_0
|
|
ret void
|
|
}
|
|
|
|
define void @"github.com/goplus/llgo/cl/_testrt/intgen.main"() {
|
|
_llgo_0:
|
|
%0 = call %"github.com/goplus/llgo/runtime/internal/runtime.Slice" @"github.com/goplus/llgo/cl/_testrt/intgen.genInts"(i64 5, { ptr, ptr } { ptr @__llgo_stub.rand, ptr null })
|
|
%1 = extractvalue %"github.com/goplus/llgo/runtime/internal/runtime.Slice" %0, 1
|
|
br label %_llgo_1
|
|
|
|
_llgo_1: ; preds = %_llgo_2, %_llgo_0
|
|
%2 = phi i64 [ -1, %_llgo_0 ], [ %3, %_llgo_2 ]
|
|
%3 = add i64 %2, 1
|
|
%4 = icmp slt i64 %3, %1
|
|
br i1 %4, label %_llgo_2, label %_llgo_3
|
|
|
|
_llgo_2: ; preds = %_llgo_1
|
|
%5 = extractvalue %"github.com/goplus/llgo/runtime/internal/runtime.Slice" %0, 0
|
|
%6 = extractvalue %"github.com/goplus/llgo/runtime/internal/runtime.Slice" %0, 1
|
|
%7 = icmp slt i64 %3, 0
|
|
%8 = icmp sge i64 %3, %6
|
|
%9 = or i1 %8, %7
|
|
call void @"github.com/goplus/llgo/runtime/internal/runtime.AssertIndexRange"(i1 %9)
|
|
%10 = getelementptr inbounds i32, ptr %5, i64 %3
|
|
%11 = load i32, ptr %10, align 4
|
|
%12 = call i32 (ptr, ...) @printf(ptr @0, i32 %11)
|
|
br label %_llgo_1
|
|
|
|
_llgo_3: ; preds = %_llgo_1
|
|
%13 = call ptr @"github.com/goplus/llgo/runtime/internal/runtime.AllocZ"(i64 4)
|
|
store i32 1, ptr %13, align 4
|
|
%14 = call ptr @"github.com/goplus/llgo/runtime/internal/runtime.AllocU"(i64 8)
|
|
%15 = getelementptr inbounds { ptr }, ptr %14, i32 0, i32 0
|
|
store ptr %13, ptr %15, align 8
|
|
%16 = insertvalue { ptr, ptr } { ptr @"github.com/goplus/llgo/cl/_testrt/intgen.main$1", ptr undef }, ptr %14, 1
|
|
%17 = call %"github.com/goplus/llgo/runtime/internal/runtime.Slice" @"github.com/goplus/llgo/cl/_testrt/intgen.genInts"(i64 5, { ptr, ptr } %16)
|
|
%18 = extractvalue %"github.com/goplus/llgo/runtime/internal/runtime.Slice" %17, 1
|
|
br label %_llgo_4
|
|
|
|
_llgo_4: ; preds = %_llgo_5, %_llgo_3
|
|
%19 = phi i64 [ -1, %_llgo_3 ], [ %20, %_llgo_5 ]
|
|
%20 = add i64 %19, 1
|
|
%21 = icmp slt i64 %20, %18
|
|
br i1 %21, label %_llgo_5, label %_llgo_6
|
|
|
|
_llgo_5: ; preds = %_llgo_4
|
|
%22 = extractvalue %"github.com/goplus/llgo/runtime/internal/runtime.Slice" %17, 0
|
|
%23 = extractvalue %"github.com/goplus/llgo/runtime/internal/runtime.Slice" %17, 1
|
|
%24 = icmp slt i64 %20, 0
|
|
%25 = icmp sge i64 %20, %23
|
|
%26 = or i1 %25, %24
|
|
call void @"github.com/goplus/llgo/runtime/internal/runtime.AssertIndexRange"(i1 %26)
|
|
%27 = getelementptr inbounds i32, ptr %22, i64 %20
|
|
%28 = load i32, ptr %27, align 4
|
|
%29 = call i32 (ptr, ...) @printf(ptr @1, i32 %28)
|
|
br label %_llgo_4
|
|
|
|
_llgo_6: ; preds = %_llgo_4
|
|
%30 = call ptr @"github.com/goplus/llgo/runtime/internal/runtime.AllocZ"(i64 4)
|
|
%31 = getelementptr inbounds %"github.com/goplus/llgo/cl/_testrt/intgen.generator", ptr %30, i32 0, i32 0
|
|
store i32 1, ptr %31, align 4
|
|
%32 = call ptr @"github.com/goplus/llgo/runtime/internal/runtime.AllocU"(i64 8)
|
|
%33 = getelementptr inbounds { ptr }, ptr %32, i32 0, i32 0
|
|
store ptr %30, ptr %33, align 8
|
|
%34 = insertvalue { ptr, ptr } { ptr @"github.com/goplus/llgo/cl/_testrt/intgen.(*generator).next$bound", ptr undef }, ptr %32, 1
|
|
%35 = call %"github.com/goplus/llgo/runtime/internal/runtime.Slice" @"github.com/goplus/llgo/cl/_testrt/intgen.genInts"(i64 5, { ptr, ptr } %34)
|
|
%36 = extractvalue %"github.com/goplus/llgo/runtime/internal/runtime.Slice" %35, 1
|
|
br label %_llgo_7
|
|
|
|
_llgo_7: ; preds = %_llgo_8, %_llgo_6
|
|
%37 = phi i64 [ -1, %_llgo_6 ], [ %38, %_llgo_8 ]
|
|
%38 = add i64 %37, 1
|
|
%39 = icmp slt i64 %38, %36
|
|
br i1 %39, label %_llgo_8, label %_llgo_9
|
|
|
|
_llgo_8: ; preds = %_llgo_7
|
|
%40 = extractvalue %"github.com/goplus/llgo/runtime/internal/runtime.Slice" %35, 0
|
|
%41 = extractvalue %"github.com/goplus/llgo/runtime/internal/runtime.Slice" %35, 1
|
|
%42 = icmp slt i64 %38, 0
|
|
%43 = icmp sge i64 %38, %41
|
|
%44 = or i1 %43, %42
|
|
call void @"github.com/goplus/llgo/runtime/internal/runtime.AssertIndexRange"(i1 %44)
|
|
%45 = getelementptr inbounds i32, ptr %40, i64 %38
|
|
%46 = load i32, ptr %45, align 4
|
|
%47 = call i32 (ptr, ...) @printf(ptr @2, i32 %46)
|
|
br label %_llgo_7
|
|
|
|
_llgo_9: ; preds = %_llgo_7
|
|
ret void
|
|
}
|
|
|
|
define i32 @"github.com/goplus/llgo/cl/_testrt/intgen.main$1"(ptr %0) {
|
|
_llgo_0:
|
|
%1 = load { ptr }, ptr %0, align 8
|
|
%2 = extractvalue { ptr } %1, 0
|
|
%3 = load i32, ptr %2, align 4
|
|
%4 = mul i32 %3, 2
|
|
%5 = extractvalue { ptr } %1, 0
|
|
store i32 %4, ptr %5, align 4
|
|
%6 = extractvalue { ptr } %1, 0
|
|
%7 = load i32, ptr %6, align 4
|
|
ret i32 %7
|
|
}
|
|
|
|
declare %"github.com/goplus/llgo/runtime/internal/runtime.Slice" @"github.com/goplus/llgo/runtime/internal/runtime.MakeSlice"(i64, i64, i64)
|
|
|
|
declare void @"github.com/goplus/llgo/runtime/internal/runtime.AssertIndexRange"(i1)
|
|
|
|
declare i32 @rand()
|
|
|
|
define linkonce i32 @__llgo_stub.rand(ptr %0) {
|
|
_llgo_0:
|
|
%1 = tail call i32 @rand()
|
|
ret i32 %1
|
|
}
|
|
|
|
declare i32 @printf(ptr, ...)
|
|
|
|
declare ptr @"github.com/goplus/llgo/runtime/internal/runtime.AllocZ"(i64)
|
|
|
|
declare ptr @"github.com/goplus/llgo/runtime/internal/runtime.AllocU"(i64)
|
|
|
|
define i32 @"github.com/goplus/llgo/cl/_testrt/intgen.(*generator).next$bound"(ptr %0) {
|
|
_llgo_0:
|
|
%1 = load { ptr }, ptr %0, align 8
|
|
%2 = extractvalue { ptr } %1, 0
|
|
%3 = call i32 @"github.com/goplus/llgo/cl/_testrt/intgen.(*generator).next"(ptr %2)
|
|
ret i32 %3
|
|
}
|