build: build runtime local

This commit is contained in:
visualfc
2024-06-07 15:21:27 +08:00
parent 46899f042f
commit fe10ddc720
12 changed files with 37 additions and 87 deletions

View File

@@ -1,9 +1,5 @@
package main
import (
"github.com/goplus/llgo/internal/runtime/c"
)
func concat(args ...string) (ret string) {
for _, v := range args {
ret += v
@@ -17,5 +13,5 @@ func info(s string) string {
func main() {
result := concat("Hello", " ", "World")
c.Fprintf(c.Stderr, c.Str("Hi, %s\n"), c.AllocaCStr(result))
println(result)
}

View File

@@ -13,8 +13,6 @@ source_filename = "main"
@3 = private unnamed_addr constant [6 x i8] c"Hello\00", align 1
@4 = private unnamed_addr constant [2 x i8] c" \00", align 1
@5 = private unnamed_addr constant [6 x i8] c"World\00", align 1
@stderr = external global ptr
@6 = private unnamed_addr constant [8 x i8] c"Hi, %s\0A\00", align 1
define %"github.com/goplus/llgo/internal/runtime.String" @main.concat(%"github.com/goplus/llgo/internal/runtime.Slice" %0) {
_llgo_0:
@@ -119,12 +117,8 @@ _llgo_0:
store i64 3, ptr %21, align 4
%22 = load %"github.com/goplus/llgo/internal/runtime.Slice", ptr %18, align 8
%23 = call %"github.com/goplus/llgo/internal/runtime.String" @main.concat(%"github.com/goplus/llgo/internal/runtime.Slice" %22)
%24 = load ptr, ptr @stderr, align 8
%25 = extractvalue %"github.com/goplus/llgo/internal/runtime.String" %23, 1
%26 = add i64 %25, 1
%27 = alloca i8, i64 %26, align 1
%28 = call ptr @"github.com/goplus/llgo/internal/runtime.CStrCopy"(ptr %27, %"github.com/goplus/llgo/internal/runtime.String" %23)
%29 = call i32 (ptr, ptr, ...) @fprintf(ptr %24, ptr @6, ptr %28)
call void @"github.com/goplus/llgo/internal/runtime.PrintString"(%"github.com/goplus/llgo/internal/runtime.String" %23)
call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 10)
ret i32 0
}
@@ -136,6 +130,6 @@ declare void @"github.com/goplus/llgo/internal/runtime.init"()
declare ptr @"github.com/goplus/llgo/internal/runtime.AllocZ"(i64)
declare ptr @"github.com/goplus/llgo/internal/runtime.CStrCopy"(ptr, %"github.com/goplus/llgo/internal/runtime.String")
declare void @"github.com/goplus/llgo/internal/runtime.PrintString"(%"github.com/goplus/llgo/internal/runtime.String")
declare i32 @fprintf(ptr, ptr, ...)
declare void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8)

View File

@@ -60,10 +60,6 @@ func TestPython(t *testing.T) {
cltest.Pkg(t, ssa.PkgPython, "../py/llgo_autogen.ll")
}
func TestRuntime(t *testing.T) {
cltest.Pkg(t, ssa.PkgRuntime, "../internal/runtime/llgo_autogen.ll")
}
func TestVar(t *testing.T) {
testCompile(t, `package foo