cgo: supports c/go callback funcs

This commit is contained in:
Li Jie
2024-11-26 22:34:19 +08:00
parent 5380ffa471
commit 90763de93c
12 changed files with 162 additions and 84 deletions

View File

@@ -1,12 +1,23 @@
; ModuleID = 'main'
source_filename = "main"
%"github.com/goplus/llgo/internal/runtime.eface" = type { ptr, ptr }
@"github.com/goplus/llgo/internal/runtime.cgoAlwaysFalse" = external global i1, align 1
@main.format = global [10 x i8] zeroinitializer, align 1
@"main.init$guard" = global i1 false, align 1
@__llgo_argc = global i32 0, align 4
@__llgo_argv = global ptr null, align 8
define ptr @main._Cgo_ptr(ptr %0) {
_llgo_0:
ret ptr %0
}
declare void @runtime.cgoUse(%"github.com/goplus/llgo/internal/runtime.eface")
declare void @runtime.cgoCheckResult(%"github.com/goplus/llgo/internal/runtime.eface")
define void @main.init() {
_llgo_0:
%0 = load i1, ptr @"main.init$guard", align 1

View File

@@ -2,6 +2,7 @@
source_filename = "main"
%main.Foo = type { i32, i1 }
%"github.com/goplus/llgo/internal/runtime.eface" = type { ptr, ptr }
@"github.com/goplus/llgo/internal/runtime.cgoAlwaysFalse" = external global i1, align 1
@main.format = global [10 x i8] zeroinitializer, align 1
@@ -35,6 +36,15 @@ _llgo_0:
ret void
}
define ptr @main._Cgo_ptr(ptr %0) {
_llgo_0:
ret ptr %0
}
declare void @runtime.cgoUse(%"github.com/goplus/llgo/internal/runtime.eface")
declare void @runtime.cgoCheckResult(%"github.com/goplus/llgo/internal/runtime.eface")
define void @main.init() {
_llgo_0:
%0 = load i1, ptr @"main.init$guard", align 1

View File

@@ -1,6 +1,8 @@
; ModuleID = 'main'
source_filename = "main"
%"github.com/goplus/llgo/internal/runtime.eface" = type { ptr, ptr }
@"github.com/goplus/llgo/internal/runtime.cgoAlwaysFalse" = external global i1, align 1
@main.format = global [10 x i8] zeroinitializer, align 1
@"main.init$guard" = global i1 false, align 1
@@ -23,6 +25,15 @@ _llgo_2: ; preds = %_llgo_1, %_llgo_0
ret void
}
define ptr @main._Cgo_ptr(ptr %0) {
_llgo_0:
ret ptr %0
}
declare void @runtime.cgoUse(%"github.com/goplus/llgo/internal/runtime.eface")
declare void @runtime.cgoCheckResult(%"github.com/goplus/llgo/internal/runtime.eface")
define void @main.init() {
_llgo_0:
%0 = load i1, ptr @"main.init$guard", align 1