move out c/cpp/py
This commit is contained in:
19
cl/_testdata/ptrmthd/in.go
Normal file
19
cl/_testdata/ptrmthd/in.go
Normal file
@@ -0,0 +1,19 @@
|
||||
package main
|
||||
|
||||
import _ "unsafe"
|
||||
|
||||
//go:linkname printf C.printf
|
||||
func printf(format *int8, __llgo_va_list ...any)
|
||||
|
||||
type T int8
|
||||
|
||||
func (f *T) Print(v int) {
|
||||
printf((*int8)(f), v)
|
||||
}
|
||||
|
||||
var format = [...]T{'H', 'e', 'l', 'l', 'o', ' ', '%', 'd', '\n', 0}
|
||||
|
||||
func main() {
|
||||
f := &format[0]
|
||||
f.Print(100)
|
||||
}
|
||||
42
cl/_testdata/ptrmthd/out.ll
Normal file
42
cl/_testdata/ptrmthd/out.ll
Normal file
@@ -0,0 +1,42 @@
|
||||
; ModuleID = 'github.com/goplus/llgo/cl/_testdata/ptrmthd'
|
||||
source_filename = "github.com/goplus/llgo/cl/_testdata/ptrmthd"
|
||||
|
||||
@"github.com/goplus/llgo/cl/_testdata/ptrmthd.format" = global [10 x i8] zeroinitializer, align 1
|
||||
@"github.com/goplus/llgo/cl/_testdata/ptrmthd.init$guard" = global i1 false, align 1
|
||||
|
||||
define void @"github.com/goplus/llgo/cl/_testdata/ptrmthd.(*T).Print"(ptr %0, i64 %1) {
|
||||
_llgo_0:
|
||||
call void (ptr, ...) @printf(ptr %0, i64 %1)
|
||||
ret void
|
||||
}
|
||||
|
||||
define void @"github.com/goplus/llgo/cl/_testdata/ptrmthd.init"() {
|
||||
_llgo_0:
|
||||
%0 = load i1, ptr @"github.com/goplus/llgo/cl/_testdata/ptrmthd.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/_testdata/ptrmthd.init$guard", align 1
|
||||
store i8 72, ptr @"github.com/goplus/llgo/cl/_testdata/ptrmthd.format", align 1
|
||||
store i8 101, ptr getelementptr inbounds (i8, ptr @"github.com/goplus/llgo/cl/_testdata/ptrmthd.format", i64 1), align 1
|
||||
store i8 108, ptr getelementptr inbounds (i8, ptr @"github.com/goplus/llgo/cl/_testdata/ptrmthd.format", i64 2), align 1
|
||||
store i8 108, ptr getelementptr inbounds (i8, ptr @"github.com/goplus/llgo/cl/_testdata/ptrmthd.format", i64 3), align 1
|
||||
store i8 111, ptr getelementptr inbounds (i8, ptr @"github.com/goplus/llgo/cl/_testdata/ptrmthd.format", i64 4), align 1
|
||||
store i8 32, ptr getelementptr inbounds (i8, ptr @"github.com/goplus/llgo/cl/_testdata/ptrmthd.format", i64 5), align 1
|
||||
store i8 37, ptr getelementptr inbounds (i8, ptr @"github.com/goplus/llgo/cl/_testdata/ptrmthd.format", i64 6), align 1
|
||||
store i8 100, ptr getelementptr inbounds (i8, ptr @"github.com/goplus/llgo/cl/_testdata/ptrmthd.format", i64 7), align 1
|
||||
store i8 10, ptr getelementptr inbounds (i8, ptr @"github.com/goplus/llgo/cl/_testdata/ptrmthd.format", i64 8), align 1
|
||||
store i8 0, ptr getelementptr inbounds (i8, ptr @"github.com/goplus/llgo/cl/_testdata/ptrmthd.format", i64 9), align 1
|
||||
br label %_llgo_2
|
||||
|
||||
_llgo_2: ; preds = %_llgo_1, %_llgo_0
|
||||
ret void
|
||||
}
|
||||
|
||||
define void @"github.com/goplus/llgo/cl/_testdata/ptrmthd.main"() {
|
||||
_llgo_0:
|
||||
call void @"github.com/goplus/llgo/cl/_testdata/ptrmthd.(*T).Print"(ptr @"github.com/goplus/llgo/cl/_testdata/ptrmthd.format", i64 100)
|
||||
ret void
|
||||
}
|
||||
|
||||
declare void @printf(ptr, ...)
|
||||
Reference in New Issue
Block a user