llgo/ssa,runtime: Slice

This commit is contained in:
xushiwei
2024-04-30 08:23:55 +08:00
parent 91401c4571
commit 0bfc269652
12 changed files with 109 additions and 16 deletions

View File

@@ -7,8 +7,8 @@ import (
)
func main() {
s := c.String("Hi\n")
s := c.Str("Hi\n")
s2 := c.Alloca(4)
c.Memcpy(s2, unsafe.Pointer(s), 4)
c.Printf(c.String("%s"), s2)
c.Printf(c.Str("%s"), s2)
}

View File

@@ -9,5 +9,5 @@ func incVal(a any) int {
}
func main() {
c.Printf(c.String("Hello %d\n"), incVal(100))
c.Printf(c.Str("Hello %d\n"), incVal(100))
}

16
cl/_testcgo/sum/in.go Normal file
View File

@@ -0,0 +1,16 @@
package main
import (
"github.com/goplus/llgo/internal/runtime/c"
)
func sum(args ...int) (ret int) {
for _, v := range args {
ret += v
}
return
}
func main() {
c.Printf(c.Str("Hello %d\n"), sum(1, 2, 3, 4))
}

0
cl/_testcgo/sum/out.ll Normal file
View File

View File

@@ -10,5 +10,5 @@ func foo() {
func main() {
foo()
c.Printf(c.String("Hello\n"))
c.Printf(c.Str("Hello\n"))
}