2024-05-31 12:01:11 +08:00
|
|
|
; ModuleID = 'main'
|
|
|
|
|
source_filename = "main"
|
|
|
|
|
|
|
|
|
|
%"github.com/goplus/llgo/internal/runtime.String" = type { ptr, i64 }
|
|
|
|
|
|
|
|
|
|
@"main.init$guard" = global ptr null
|
|
|
|
|
@__llgo_argc = global ptr null
|
|
|
|
|
@__llgo_argv = global ptr null
|
|
|
|
|
@0 = private unnamed_addr constant [2 x i8] c".\00", align 1
|
|
|
|
|
@1 = private unnamed_addr constant [14 x i8] c"Hello, World!\00", align 1
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
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 1)
|
|
|
|
|
store i1 false, ptr %2, align 1
|
|
|
|
|
%3 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 8)
|
|
|
|
|
%4 = getelementptr inbounds { ptr }, ptr %3, i32 0, i32 0
|
|
|
|
|
store ptr %2, ptr %4, align 8
|
|
|
|
|
%5 = alloca { ptr, ptr }, align 8
|
|
|
|
|
%6 = getelementptr inbounds { ptr, ptr }, ptr %5, i32 0, i32 0
|
|
|
|
|
store ptr @"main.main$1", ptr %6, align 8
|
|
|
|
|
%7 = getelementptr inbounds { ptr, ptr }, ptr %5, i32 0, i32 1
|
|
|
|
|
store ptr %3, ptr %7, align 8
|
|
|
|
|
%8 = load { ptr, ptr }, ptr %5, align 8
|
2024-06-01 15:52:54 +08:00
|
|
|
%9 = call ptr @malloc(i64 16)
|
|
|
|
|
%10 = getelementptr inbounds { { ptr, ptr } }, ptr %9, i32 0, i32 0
|
|
|
|
|
store { ptr, ptr } %8, ptr %10, align 8
|
|
|
|
|
%11 = alloca i8, i64 8, align 1
|
|
|
|
|
%12 = call i32 @pthread_create(ptr %11, ptr null, ptr @"main._llgo_routine$1", ptr %9)
|
2024-05-31 12:01:11 +08:00
|
|
|
br label %_llgo_3
|
|
|
|
|
|
|
|
|
|
_llgo_1: ; preds = %_llgo_3
|
2024-06-01 15:52:54 +08:00
|
|
|
%13 = alloca %"github.com/goplus/llgo/internal/runtime.String", align 8
|
|
|
|
|
%14 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %13, i32 0, i32 0
|
|
|
|
|
store ptr @0, ptr %14, align 8
|
|
|
|
|
%15 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %13, i32 0, i32 1
|
|
|
|
|
store i64 1, ptr %15, align 4
|
|
|
|
|
%16 = load %"github.com/goplus/llgo/internal/runtime.String", ptr %13, align 8
|
|
|
|
|
call void @"github.com/goplus/llgo/internal/runtime.PrintString"(%"github.com/goplus/llgo/internal/runtime.String" %16)
|
2024-05-31 12:01:11 +08:00
|
|
|
br label %_llgo_3
|
|
|
|
|
|
|
|
|
|
_llgo_2: ; preds = %_llgo_3
|
|
|
|
|
ret i32 0
|
|
|
|
|
|
|
|
|
|
_llgo_3: ; preds = %_llgo_1, %_llgo_0
|
2024-06-01 15:52:54 +08:00
|
|
|
%17 = load i1, ptr %2, align 1
|
|
|
|
|
br i1 %17, label %_llgo_2, label %_llgo_1
|
2024-05-31 12:01:11 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
declare void @"github.com/goplus/llgo/internal/runtime.init"()
|
|
|
|
|
|
|
|
|
|
declare ptr @"github.com/goplus/llgo/internal/runtime.AllocZ"(i64)
|
|
|
|
|
|
|
|
|
|
define void @"main.main$1"(ptr %0) {
|
|
|
|
|
_llgo_0:
|
|
|
|
|
%1 = alloca %"github.com/goplus/llgo/internal/runtime.String", align 8
|
|
|
|
|
%2 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %1, i32 0, i32 0
|
|
|
|
|
store ptr @1, ptr %2, align 8
|
|
|
|
|
%3 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %1, i32 0, i32 1
|
|
|
|
|
store i64 13, ptr %3, align 4
|
|
|
|
|
%4 = load %"github.com/goplus/llgo/internal/runtime.String", ptr %1, align 8
|
|
|
|
|
call void @"github.com/goplus/llgo/internal/runtime.PrintString"(%"github.com/goplus/llgo/internal/runtime.String" %4)
|
|
|
|
|
call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 10)
|
|
|
|
|
%5 = load { ptr }, ptr %0, align 8
|
|
|
|
|
%6 = extractvalue { ptr } %5, 0
|
|
|
|
|
store i1 true, ptr %6, align 1
|
|
|
|
|
ret void
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
declare ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64)
|
|
|
|
|
|
2024-06-01 15:52:54 +08:00
|
|
|
declare ptr @malloc(i64)
|
|
|
|
|
|
|
|
|
|
define ptr @"main._llgo_routine$1"(ptr %0) {
|
|
|
|
|
_llgo_0:
|
|
|
|
|
%1 = load { { ptr, ptr } }, ptr %0, align 8
|
|
|
|
|
%2 = extractvalue { { ptr, ptr } } %1, 0
|
|
|
|
|
%3 = extractvalue { ptr, ptr } %2, 1
|
|
|
|
|
%4 = extractvalue { ptr, ptr } %2, 0
|
|
|
|
|
call void %4(ptr %3)
|
|
|
|
|
call void @free({ { ptr, ptr } } %1)
|
|
|
|
|
ret ptr null
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
declare void @free(ptr)
|
|
|
|
|
|
|
|
|
|
declare i32 @pthread_create(ptr, ptr, ptr, ptr)
|
|
|
|
|
|
2024-05-31 12:01:11 +08:00
|
|
|
declare void @"github.com/goplus/llgo/internal/runtime.PrintString"(%"github.com/goplus/llgo/internal/runtime.String")
|
|
|
|
|
|
|
|
|
|
declare void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8)
|