ssa: fix binop string cat ret type
This commit is contained in:
@@ -11,6 +11,10 @@ func concat(args ...string) (ret string) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func info(s string) string {
|
||||||
|
return "" + s + "..."
|
||||||
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
result := concat("Hello", " ", "World")
|
result := concat("Hello", " ", "World")
|
||||||
c.Fprintf(c.Stderr, c.Str("Hi, %s\n"), c.AllocaCStr(result))
|
c.Fprintf(c.Stderr, c.Str("Hi, %s\n"), c.AllocaCStr(result))
|
||||||
|
|||||||
@@ -6,13 +6,15 @@ source_filename = "main"
|
|||||||
|
|
||||||
@"main.init$guard" = global ptr null
|
@"main.init$guard" = global ptr null
|
||||||
@0 = private unnamed_addr constant [1 x i8] zeroinitializer, align 1
|
@0 = private unnamed_addr constant [1 x i8] zeroinitializer, align 1
|
||||||
|
@1 = private unnamed_addr constant [1 x i8] zeroinitializer, align 1
|
||||||
|
@2 = private unnamed_addr constant [4 x i8] c"...\00", align 1
|
||||||
@__llgo_argc = global ptr null
|
@__llgo_argc = global ptr null
|
||||||
@__llgo_argv = global ptr null
|
@__llgo_argv = global ptr null
|
||||||
@1 = private unnamed_addr constant [6 x i8] c"Hello\00", align 1
|
@3 = private unnamed_addr constant [6 x i8] c"Hello\00", align 1
|
||||||
@2 = private unnamed_addr constant [2 x i8] c" \00", align 1
|
@4 = private unnamed_addr constant [2 x i8] c" \00", align 1
|
||||||
@3 = private unnamed_addr constant [6 x i8] c"World\00", align 1
|
@5 = private unnamed_addr constant [6 x i8] c"World\00", align 1
|
||||||
@__stderrp = external global ptr
|
@__stderrp = external global ptr
|
||||||
@4 = private unnamed_addr constant [8 x i8] c"Hi, %s\0A\00", align 1
|
@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) {
|
define %"github.com/goplus/llgo/internal/runtime.String" @main.concat(%"github.com/goplus/llgo/internal/runtime.Slice" %0) {
|
||||||
_llgo_0:
|
_llgo_0:
|
||||||
@@ -49,6 +51,15 @@ _llgo_3: ; preds = %_llgo_1
|
|||||||
ret %"github.com/goplus/llgo/internal/runtime.String" %11
|
ret %"github.com/goplus/llgo/internal/runtime.String" %11
|
||||||
}
|
}
|
||||||
|
|
||||||
|
define %"github.com/goplus/llgo/internal/runtime.String" @main.info(%"github.com/goplus/llgo/internal/runtime.String" %0) {
|
||||||
|
_llgo_0:
|
||||||
|
%1 = call %"github.com/goplus/llgo/internal/runtime.String" @"github.com/goplus/llgo/internal/runtime.NewString"(ptr @1, i64 0)
|
||||||
|
%2 = call %"github.com/goplus/llgo/internal/runtime.String" @"github.com/goplus/llgo/internal/runtime.StringCat"(%"github.com/goplus/llgo/internal/runtime.String" %1, %"github.com/goplus/llgo/internal/runtime.String" %0)
|
||||||
|
%3 = call %"github.com/goplus/llgo/internal/runtime.String" @"github.com/goplus/llgo/internal/runtime.NewString"(ptr @2, i64 3)
|
||||||
|
%4 = call %"github.com/goplus/llgo/internal/runtime.String" @"github.com/goplus/llgo/internal/runtime.StringCat"(%"github.com/goplus/llgo/internal/runtime.String" %2, %"github.com/goplus/llgo/internal/runtime.String" %3)
|
||||||
|
ret %"github.com/goplus/llgo/internal/runtime.String" %4
|
||||||
|
}
|
||||||
|
|
||||||
define void @main.init() {
|
define void @main.init() {
|
||||||
_llgo_0:
|
_llgo_0:
|
||||||
%0 = load i1, ptr @"main.init$guard", align 1
|
%0 = load i1, ptr @"main.init$guard", align 1
|
||||||
@@ -70,13 +81,13 @@ _llgo_0:
|
|||||||
call void @main.init()
|
call void @main.init()
|
||||||
%2 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocZ"(i64 48)
|
%2 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocZ"(i64 48)
|
||||||
%3 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %2, i64 0
|
%3 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %2, i64 0
|
||||||
%4 = call %"github.com/goplus/llgo/internal/runtime.String" @"github.com/goplus/llgo/internal/runtime.NewString"(ptr @1, i64 5)
|
%4 = call %"github.com/goplus/llgo/internal/runtime.String" @"github.com/goplus/llgo/internal/runtime.NewString"(ptr @3, i64 5)
|
||||||
store %"github.com/goplus/llgo/internal/runtime.String" %4, ptr %3, align 8
|
store %"github.com/goplus/llgo/internal/runtime.String" %4, ptr %3, align 8
|
||||||
%5 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %2, i64 1
|
%5 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %2, i64 1
|
||||||
%6 = call %"github.com/goplus/llgo/internal/runtime.String" @"github.com/goplus/llgo/internal/runtime.NewString"(ptr @2, i64 1)
|
%6 = call %"github.com/goplus/llgo/internal/runtime.String" @"github.com/goplus/llgo/internal/runtime.NewString"(ptr @4, i64 1)
|
||||||
store %"github.com/goplus/llgo/internal/runtime.String" %6, ptr %5, align 8
|
store %"github.com/goplus/llgo/internal/runtime.String" %6, ptr %5, align 8
|
||||||
%7 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %2, i64 2
|
%7 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %2, i64 2
|
||||||
%8 = call %"github.com/goplus/llgo/internal/runtime.String" @"github.com/goplus/llgo/internal/runtime.NewString"(ptr @3, i64 5)
|
%8 = call %"github.com/goplus/llgo/internal/runtime.String" @"github.com/goplus/llgo/internal/runtime.NewString"(ptr @5, i64 5)
|
||||||
store %"github.com/goplus/llgo/internal/runtime.String" %8, ptr %7, align 8
|
store %"github.com/goplus/llgo/internal/runtime.String" %8, ptr %7, align 8
|
||||||
%9 = call %"github.com/goplus/llgo/internal/runtime.Slice" @"github.com/goplus/llgo/internal/runtime.NewSlice3"(ptr %2, i64 16, i64 3, i64 0, i64 3, i64 3)
|
%9 = call %"github.com/goplus/llgo/internal/runtime.Slice" @"github.com/goplus/llgo/internal/runtime.NewSlice3"(ptr %2, i64 16, i64 3, i64 0, i64 3, i64 3)
|
||||||
%10 = call %"github.com/goplus/llgo/internal/runtime.String" @main.concat(%"github.com/goplus/llgo/internal/runtime.Slice" %9)
|
%10 = call %"github.com/goplus/llgo/internal/runtime.String" @main.concat(%"github.com/goplus/llgo/internal/runtime.Slice" %9)
|
||||||
@@ -85,7 +96,7 @@ _llgo_0:
|
|||||||
%13 = add i64 %12, 1
|
%13 = add i64 %12, 1
|
||||||
%14 = alloca i8, i64 %13, align 1
|
%14 = alloca i8, i64 %13, align 1
|
||||||
%15 = call ptr @"github.com/goplus/llgo/internal/runtime.CStrCopy"(ptr %14, %"github.com/goplus/llgo/internal/runtime.String" %10)
|
%15 = call ptr @"github.com/goplus/llgo/internal/runtime.CStrCopy"(ptr %14, %"github.com/goplus/llgo/internal/runtime.String" %10)
|
||||||
%16 = call i32 (ptr, ptr, ...) @fprintf(ptr %11, ptr @4, ptr %15)
|
%16 = call i32 (ptr, ptr, ...) @fprintf(ptr %11, ptr @6, ptr %15)
|
||||||
ret void
|
ret void
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -284,7 +284,7 @@ func (b Builder) BinOp(op token.Token, x, y Expr) Expr {
|
|||||||
case vkString:
|
case vkString:
|
||||||
if op == token.ADD {
|
if op == token.ADD {
|
||||||
pkg := b.Func.Pkg
|
pkg := b.Func.Pkg
|
||||||
return b.InlineCall(pkg.rtFunc("StringCat"), x, y)
|
return Expr{b.InlineCall(pkg.rtFunc("StringCat"), x, y).impl, x.Type}
|
||||||
}
|
}
|
||||||
case vkComplex:
|
case vkComplex:
|
||||||
default:
|
default:
|
||||||
|
|||||||
Reference in New Issue
Block a user