168 lines
7.8 KiB
LLVM
168 lines
7.8 KiB
LLVM
; ModuleID = 'main'
|
|
source_filename = "main"
|
|
|
|
%"github.com/goplus/llgo/internal/runtime.eface" = type { ptr, ptr }
|
|
%"github.com/goplus/llgo/internal/runtime.Slice" = type { ptr, i64, i64 }
|
|
%"github.com/goplus/llgo/internal/runtime.String" = type { ptr, i64 }
|
|
|
|
@"main.init$guard" = global i1 false, align 1
|
|
@__llgo_argc = global i32 0, align 4
|
|
@__llgo_argv = global ptr null, align 8
|
|
@_llgo_int = linkonce global ptr null, align 8
|
|
@0 = private unnamed_addr constant [4 x i8] c"%d\0A\00", align 1
|
|
@1 = private unnamed_addr constant [21 x i8] c"type assertion failed", align 1
|
|
@_llgo_string = linkonce global ptr null, align 8
|
|
|
|
define void @main.init() {
|
|
_llgo_0:
|
|
%0 = load i1, ptr @"main.init$guard", align 1
|
|
br i1 %0, label %_llgo_2, label %_llgo_1
|
|
|
|
_llgo_1: ; preds = %_llgo_0
|
|
store i1 true, ptr @"main.init$guard", align 1
|
|
call void @"main.init$after"()
|
|
br label %_llgo_2
|
|
|
|
_llgo_2: ; preds = %_llgo_1, %_llgo_0
|
|
ret void
|
|
}
|
|
|
|
define i32 @main(i32 %0, ptr %1) {
|
|
_llgo_0:
|
|
store i32 %0, ptr @__llgo_argc, align 4
|
|
store ptr %1, ptr @__llgo_argv, align 8
|
|
call void @"github.com/goplus/llgo/internal/runtime.init"()
|
|
call void @main.init()
|
|
%2 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocZ"(i64 48)
|
|
%3 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %2, i64 0
|
|
%4 = load ptr, ptr @_llgo_int, align 8
|
|
%5 = alloca %"github.com/goplus/llgo/internal/runtime.eface", align 8
|
|
%6 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %5, i32 0, i32 0
|
|
store ptr %4, ptr %6, align 8
|
|
%7 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %5, i32 0, i32 1
|
|
store ptr inttoptr (i64 1 to ptr), ptr %7, align 8
|
|
%8 = load %"github.com/goplus/llgo/internal/runtime.eface", ptr %5, align 8
|
|
store %"github.com/goplus/llgo/internal/runtime.eface" %8, ptr %3, align 8
|
|
%9 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %2, i64 1
|
|
%10 = load ptr, ptr @_llgo_int, align 8
|
|
%11 = alloca %"github.com/goplus/llgo/internal/runtime.eface", align 8
|
|
%12 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %11, i32 0, i32 0
|
|
store ptr %10, ptr %12, align 8
|
|
%13 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %11, i32 0, i32 1
|
|
store ptr inttoptr (i64 2 to ptr), ptr %13, align 8
|
|
%14 = load %"github.com/goplus/llgo/internal/runtime.eface", ptr %11, align 8
|
|
store %"github.com/goplus/llgo/internal/runtime.eface" %14, ptr %9, align 8
|
|
%15 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %2, i64 2
|
|
%16 = load ptr, ptr @_llgo_int, align 8
|
|
%17 = alloca %"github.com/goplus/llgo/internal/runtime.eface", align 8
|
|
%18 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %17, i32 0, i32 0
|
|
store ptr %16, ptr %18, align 8
|
|
%19 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %17, i32 0, i32 1
|
|
store ptr inttoptr (i64 3 to ptr), ptr %19, align 8
|
|
%20 = load %"github.com/goplus/llgo/internal/runtime.eface", ptr %17, align 8
|
|
store %"github.com/goplus/llgo/internal/runtime.eface" %20, ptr %15, align 8
|
|
%21 = alloca %"github.com/goplus/llgo/internal/runtime.Slice", align 8
|
|
%22 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.Slice", ptr %21, i32 0, i32 0
|
|
store ptr %2, ptr %22, align 8
|
|
%23 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.Slice", ptr %21, i32 0, i32 1
|
|
store i64 3, ptr %23, align 4
|
|
%24 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.Slice", ptr %21, i32 0, i32 2
|
|
store i64 3, ptr %24, align 4
|
|
%25 = load %"github.com/goplus/llgo/internal/runtime.Slice", ptr %21, align 8
|
|
call void @main.test(%"github.com/goplus/llgo/internal/runtime.Slice" %25)
|
|
ret i32 0
|
|
}
|
|
|
|
define void @main.test(%"github.com/goplus/llgo/internal/runtime.Slice" %0) {
|
|
_llgo_0:
|
|
%1 = extractvalue %"github.com/goplus/llgo/internal/runtime.Slice" %0, 1
|
|
br label %_llgo_1
|
|
|
|
_llgo_1: ; preds = %_llgo_4, %_llgo_0
|
|
%2 = phi i64 [ -1, %_llgo_0 ], [ %3, %_llgo_4 ]
|
|
%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/internal/runtime.Slice" %0, 0
|
|
%6 = extractvalue %"github.com/goplus/llgo/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/internal/runtime.AssertIndexRange"(i1 %9)
|
|
%10 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %5, i64 %3
|
|
%11 = load %"github.com/goplus/llgo/internal/runtime.eface", ptr %10, align 8
|
|
%12 = extractvalue %"github.com/goplus/llgo/internal/runtime.eface" %11, 0
|
|
%13 = load ptr, ptr @_llgo_int, align 8
|
|
%14 = icmp eq ptr %12, %13
|
|
br i1 %14, label %_llgo_4, label %_llgo_5
|
|
|
|
_llgo_3: ; preds = %_llgo_1
|
|
ret void
|
|
|
|
_llgo_4: ; preds = %_llgo_2
|
|
%15 = extractvalue %"github.com/goplus/llgo/internal/runtime.eface" %11, 1
|
|
%16 = ptrtoint ptr %15 to i64
|
|
%17 = call i32 (ptr, ...) @printf(ptr @0, i64 %16)
|
|
br label %_llgo_1
|
|
|
|
_llgo_5: ; preds = %_llgo_2
|
|
%18 = alloca %"github.com/goplus/llgo/internal/runtime.String", align 8
|
|
%19 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %18, i32 0, i32 0
|
|
store ptr @1, ptr %19, align 8
|
|
%20 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %18, i32 0, i32 1
|
|
store i64 21, ptr %20, align 4
|
|
%21 = load %"github.com/goplus/llgo/internal/runtime.String", ptr %18, align 8
|
|
%22 = load ptr, ptr @_llgo_string, align 8
|
|
%23 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 16)
|
|
store %"github.com/goplus/llgo/internal/runtime.String" %21, ptr %23, align 8
|
|
%24 = alloca %"github.com/goplus/llgo/internal/runtime.eface", align 8
|
|
%25 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %24, i32 0, i32 0
|
|
store ptr %22, ptr %25, align 8
|
|
%26 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %24, i32 0, i32 1
|
|
store ptr %23, ptr %26, align 8
|
|
%27 = load %"github.com/goplus/llgo/internal/runtime.eface", ptr %24, align 8
|
|
call void @"github.com/goplus/llgo/internal/runtime.Panic"(%"github.com/goplus/llgo/internal/runtime.eface" %27)
|
|
unreachable
|
|
}
|
|
|
|
declare void @"github.com/goplus/llgo/internal/runtime.init"()
|
|
|
|
declare ptr @"github.com/goplus/llgo/internal/runtime.AllocZ"(i64)
|
|
|
|
define void @"main.init$after"() {
|
|
_llgo_0:
|
|
%0 = load ptr, ptr @_llgo_int, align 8
|
|
%1 = icmp eq ptr %0, null
|
|
br i1 %1, label %_llgo_1, label %_llgo_2
|
|
|
|
_llgo_1: ; preds = %_llgo_0
|
|
%2 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 34)
|
|
store ptr %2, ptr @_llgo_int, align 8
|
|
br label %_llgo_2
|
|
|
|
_llgo_2: ; preds = %_llgo_1, %_llgo_0
|
|
%3 = load ptr, ptr @_llgo_string, align 8
|
|
%4 = icmp eq ptr %3, null
|
|
br i1 %4, label %_llgo_3, label %_llgo_4
|
|
|
|
_llgo_3: ; preds = %_llgo_2
|
|
%5 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 24)
|
|
store ptr %5, ptr @_llgo_string, align 8
|
|
br label %_llgo_4
|
|
|
|
_llgo_4: ; preds = %_llgo_3, %_llgo_2
|
|
ret void
|
|
}
|
|
|
|
declare ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64)
|
|
|
|
declare void @"github.com/goplus/llgo/internal/runtime.AssertIndexRange"(i1)
|
|
|
|
declare ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64)
|
|
|
|
declare void @"github.com/goplus/llgo/internal/runtime.Panic"(%"github.com/goplus/llgo/internal/runtime.eface")
|
|
|
|
declare i32 @printf(ptr, ...)
|