conflict fix
This commit is contained in:
@@ -13,6 +13,14 @@ func gwrite(b []byte) {
|
||||
c.Printf(c.Str("%s"), b)
|
||||
}
|
||||
|
||||
func printbool(v bool) {
|
||||
if v {
|
||||
printstring("true")
|
||||
} else {
|
||||
printstring("false")
|
||||
}
|
||||
}
|
||||
|
||||
func printfloat(v float64) {
|
||||
switch {
|
||||
case v != v:
|
||||
@@ -177,14 +185,37 @@ func main() {
|
||||
printnl()
|
||||
prinfsub(100.1)
|
||||
printnl()
|
||||
printnum(float32(1e9))
|
||||
printany(float32(1e9))
|
||||
printnl()
|
||||
printnum(float64(2e9))
|
||||
printany(float64(2e9))
|
||||
printnl()
|
||||
var b bool = true
|
||||
if b == true && b != false {
|
||||
println("check bool", b)
|
||||
}
|
||||
n1 := 0b1001
|
||||
n2 := 0b0011
|
||||
println("check &^", n1&^n2 == 0b1000, n2&^n1 == 0b0010)
|
||||
println(true, false, 'a', 'A', rune('中'),
|
||||
int8(1), int16(2), int32(3), int64(4), 5,
|
||||
uint8(1), uint16(2), uint32(3), uint64(4), uintptr(5),
|
||||
"llgo")
|
||||
}
|
||||
|
||||
func println(args ...any) {
|
||||
for i, v := range args {
|
||||
if i != 0 {
|
||||
printstring(" ")
|
||||
}
|
||||
printany(v)
|
||||
}
|
||||
printnl()
|
||||
}
|
||||
|
||||
func printnum(v any) {
|
||||
func printany(v any) {
|
||||
switch v := v.(type) {
|
||||
case bool:
|
||||
printbool(v)
|
||||
case int:
|
||||
printint(int64(v))
|
||||
case int8:
|
||||
@@ -211,6 +242,8 @@ func printnum(v any) {
|
||||
printfloat(float64(v))
|
||||
case float64:
|
||||
printfloat(float64(v))
|
||||
case string:
|
||||
printstring(v)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -13,13 +13,19 @@ source_filename = "main"
|
||||
@__llgo_argc = global ptr null
|
||||
@__llgo_argv = global ptr null
|
||||
@1 = private unnamed_addr constant [5 x i8] c"llgo\00", align 1
|
||||
@2 = private unnamed_addr constant [4 x i8] c"NaN\00", align 1
|
||||
@3 = private unnamed_addr constant [5 x i8] c"+Inf\00", align 1
|
||||
@4 = private unnamed_addr constant [5 x i8] c"-Inf\00", align 1
|
||||
@5 = private unnamed_addr constant [17 x i8] c"0123456789abcdef\00", align 1
|
||||
@6 = private unnamed_addr constant [2 x i8] c"-\00", align 1
|
||||
@7 = private unnamed_addr constant [2 x i8] c"\0A\00", align 1
|
||||
@8 = private unnamed_addr constant [2 x i8] c" \00", align 1
|
||||
@2 = private unnamed_addr constant [11 x i8] c"check bool\00", align 1
|
||||
@3 = private unnamed_addr constant [9 x i8] c"check &^\00", align 1
|
||||
@4 = private unnamed_addr constant [5 x i8] c"llgo\00", align 1
|
||||
@5 = private unnamed_addr constant [5 x i8] c"true\00", align 1
|
||||
@6 = private unnamed_addr constant [6 x i8] c"false\00", align 1
|
||||
@7 = private unnamed_addr constant [4 x i8] c"NaN\00", align 1
|
||||
@8 = private unnamed_addr constant [5 x i8] c"+Inf\00", align 1
|
||||
@9 = private unnamed_addr constant [5 x i8] c"-Inf\00", align 1
|
||||
@10 = private unnamed_addr constant [17 x i8] c"0123456789abcdef\00", align 1
|
||||
@11 = private unnamed_addr constant [2 x i8] c"-\00", align 1
|
||||
@12 = private unnamed_addr constant [2 x i8] c" \00", align 1
|
||||
@13 = private unnamed_addr constant [2 x i8] c"\0A\00", align 1
|
||||
@14 = private unnamed_addr constant [2 x i8] c" \00", align 1
|
||||
|
||||
define %"github.com/goplus/llgo/internal/runtime.Slice" @main.bytes(%"github.com/goplus/llgo/internal/runtime.String" %0) {
|
||||
_llgo_0:
|
||||
@@ -94,13 +100,115 @@ _llgo_0:
|
||||
call void @main.printnl()
|
||||
%3 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 13)
|
||||
%4 = call %"github.com/goplus/llgo/internal/runtime.iface" @"github.com/goplus/llgo/internal/runtime.MakeAnyInt"(ptr %3, i64 1315859240)
|
||||
call void @main.printnum(%"github.com/goplus/llgo/internal/runtime.iface" %4)
|
||||
call void @main.printany(%"github.com/goplus/llgo/internal/runtime.iface" %4)
|
||||
call void @main.printnl()
|
||||
%5 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 14)
|
||||
%6 = call %"github.com/goplus/llgo/internal/runtime.iface" @"github.com/goplus/llgo/internal/runtime.MakeAnyInt"(ptr %5, i64 4746175415993761792)
|
||||
call void @main.printnum(%"github.com/goplus/llgo/internal/runtime.iface" %6)
|
||||
call void @main.printany(%"github.com/goplus/llgo/internal/runtime.iface" %6)
|
||||
call void @main.printnl()
|
||||
br i1 true, label %_llgo_3, label %_llgo_2
|
||||
|
||||
_llgo_1: ; preds = %_llgo_3
|
||||
%7 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocZ"(i64 32)
|
||||
%8 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.iface", ptr %7, i64 0
|
||||
%9 = call %"github.com/goplus/llgo/internal/runtime.String" @"github.com/goplus/llgo/internal/runtime.NewString"(ptr @2, i64 10)
|
||||
%10 = call %"github.com/goplus/llgo/internal/runtime.iface" @"github.com/goplus/llgo/internal/runtime.MakeAnyString"(%"github.com/goplus/llgo/internal/runtime.String" %9)
|
||||
store %"github.com/goplus/llgo/internal/runtime.iface" %10, ptr %8, align 8
|
||||
%11 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.iface", ptr %7, i64 1
|
||||
%12 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 1)
|
||||
%13 = call %"github.com/goplus/llgo/internal/runtime.iface" @"github.com/goplus/llgo/internal/runtime.MakeAnyInt"(ptr %12, i64 -1)
|
||||
store %"github.com/goplus/llgo/internal/runtime.iface" %13, ptr %11, align 8
|
||||
%14 = call %"github.com/goplus/llgo/internal/runtime.Slice" @"github.com/goplus/llgo/internal/runtime.NewSlice3"(ptr %7, i64 16, i64 2, i64 0, i64 2, i64 2)
|
||||
call void @main.println(%"github.com/goplus/llgo/internal/runtime.Slice" %14)
|
||||
br label %_llgo_2
|
||||
|
||||
_llgo_2: ; preds = %_llgo_3, %_llgo_1, %_llgo_0
|
||||
%15 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocZ"(i64 48)
|
||||
%16 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.iface", ptr %15, i64 0
|
||||
%17 = call %"github.com/goplus/llgo/internal/runtime.String" @"github.com/goplus/llgo/internal/runtime.NewString"(ptr @3, i64 8)
|
||||
%18 = call %"github.com/goplus/llgo/internal/runtime.iface" @"github.com/goplus/llgo/internal/runtime.MakeAnyString"(%"github.com/goplus/llgo/internal/runtime.String" %17)
|
||||
store %"github.com/goplus/llgo/internal/runtime.iface" %18, ptr %16, align 8
|
||||
%19 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.iface", ptr %15, i64 1
|
||||
%20 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 1)
|
||||
%21 = call %"github.com/goplus/llgo/internal/runtime.iface" @"github.com/goplus/llgo/internal/runtime.MakeAnyInt"(ptr %20, i64 -1)
|
||||
store %"github.com/goplus/llgo/internal/runtime.iface" %21, ptr %19, align 8
|
||||
%22 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.iface", ptr %15, i64 2
|
||||
%23 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 1)
|
||||
%24 = call %"github.com/goplus/llgo/internal/runtime.iface" @"github.com/goplus/llgo/internal/runtime.MakeAnyInt"(ptr %23, i64 -1)
|
||||
store %"github.com/goplus/llgo/internal/runtime.iface" %24, ptr %22, align 8
|
||||
%25 = call %"github.com/goplus/llgo/internal/runtime.Slice" @"github.com/goplus/llgo/internal/runtime.NewSlice3"(ptr %15, i64 16, i64 3, i64 0, i64 3, i64 3)
|
||||
call void @main.println(%"github.com/goplus/llgo/internal/runtime.Slice" %25)
|
||||
%26 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocZ"(i64 256)
|
||||
%27 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.iface", ptr %26, i64 0
|
||||
%28 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 1)
|
||||
%29 = call %"github.com/goplus/llgo/internal/runtime.iface" @"github.com/goplus/llgo/internal/runtime.MakeAnyInt"(ptr %28, i64 -1)
|
||||
store %"github.com/goplus/llgo/internal/runtime.iface" %29, ptr %27, align 8
|
||||
%30 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.iface", ptr %26, i64 1
|
||||
%31 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 1)
|
||||
%32 = call %"github.com/goplus/llgo/internal/runtime.iface" @"github.com/goplus/llgo/internal/runtime.MakeAnyInt"(ptr %31, i64 0)
|
||||
store %"github.com/goplus/llgo/internal/runtime.iface" %32, ptr %30, align 8
|
||||
%33 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.iface", ptr %26, i64 2
|
||||
%34 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 5)
|
||||
%35 = call %"github.com/goplus/llgo/internal/runtime.iface" @"github.com/goplus/llgo/internal/runtime.MakeAnyInt"(ptr %34, i64 97)
|
||||
store %"github.com/goplus/llgo/internal/runtime.iface" %35, ptr %33, align 8
|
||||
%36 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.iface", ptr %26, i64 3
|
||||
%37 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 5)
|
||||
%38 = call %"github.com/goplus/llgo/internal/runtime.iface" @"github.com/goplus/llgo/internal/runtime.MakeAnyInt"(ptr %37, i64 65)
|
||||
store %"github.com/goplus/llgo/internal/runtime.iface" %38, ptr %36, align 8
|
||||
%39 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.iface", ptr %26, i64 4
|
||||
%40 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 5)
|
||||
%41 = call %"github.com/goplus/llgo/internal/runtime.iface" @"github.com/goplus/llgo/internal/runtime.MakeAnyInt"(ptr %40, i64 20013)
|
||||
store %"github.com/goplus/llgo/internal/runtime.iface" %41, ptr %39, align 8
|
||||
%42 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.iface", ptr %26, i64 5
|
||||
%43 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 3)
|
||||
%44 = call %"github.com/goplus/llgo/internal/runtime.iface" @"github.com/goplus/llgo/internal/runtime.MakeAnyInt"(ptr %43, i64 1)
|
||||
store %"github.com/goplus/llgo/internal/runtime.iface" %44, ptr %42, align 8
|
||||
%45 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.iface", ptr %26, i64 6
|
||||
%46 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 4)
|
||||
%47 = call %"github.com/goplus/llgo/internal/runtime.iface" @"github.com/goplus/llgo/internal/runtime.MakeAnyInt"(ptr %46, i64 2)
|
||||
store %"github.com/goplus/llgo/internal/runtime.iface" %47, ptr %45, align 8
|
||||
%48 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.iface", ptr %26, i64 7
|
||||
%49 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 5)
|
||||
%50 = call %"github.com/goplus/llgo/internal/runtime.iface" @"github.com/goplus/llgo/internal/runtime.MakeAnyInt"(ptr %49, i64 3)
|
||||
store %"github.com/goplus/llgo/internal/runtime.iface" %50, ptr %48, align 8
|
||||
%51 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.iface", ptr %26, i64 8
|
||||
%52 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 6)
|
||||
%53 = call %"github.com/goplus/llgo/internal/runtime.iface" @"github.com/goplus/llgo/internal/runtime.MakeAnyInt"(ptr %52, i64 4)
|
||||
store %"github.com/goplus/llgo/internal/runtime.iface" %53, ptr %51, align 8
|
||||
%54 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.iface", ptr %26, i64 9
|
||||
%55 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 2)
|
||||
%56 = call %"github.com/goplus/llgo/internal/runtime.iface" @"github.com/goplus/llgo/internal/runtime.MakeAnyInt"(ptr %55, i64 5)
|
||||
store %"github.com/goplus/llgo/internal/runtime.iface" %56, ptr %54, align 8
|
||||
%57 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.iface", ptr %26, i64 10
|
||||
%58 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 8)
|
||||
%59 = call %"github.com/goplus/llgo/internal/runtime.iface" @"github.com/goplus/llgo/internal/runtime.MakeAnyInt"(ptr %58, i64 1)
|
||||
store %"github.com/goplus/llgo/internal/runtime.iface" %59, ptr %57, align 8
|
||||
%60 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.iface", ptr %26, i64 11
|
||||
%61 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 9)
|
||||
%62 = call %"github.com/goplus/llgo/internal/runtime.iface" @"github.com/goplus/llgo/internal/runtime.MakeAnyInt"(ptr %61, i64 2)
|
||||
store %"github.com/goplus/llgo/internal/runtime.iface" %62, ptr %60, align 8
|
||||
%63 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.iface", ptr %26, i64 12
|
||||
%64 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 10)
|
||||
%65 = call %"github.com/goplus/llgo/internal/runtime.iface" @"github.com/goplus/llgo/internal/runtime.MakeAnyInt"(ptr %64, i64 3)
|
||||
store %"github.com/goplus/llgo/internal/runtime.iface" %65, ptr %63, align 8
|
||||
%66 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.iface", ptr %26, i64 13
|
||||
%67 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 11)
|
||||
%68 = call %"github.com/goplus/llgo/internal/runtime.iface" @"github.com/goplus/llgo/internal/runtime.MakeAnyInt"(ptr %67, i64 4)
|
||||
store %"github.com/goplus/llgo/internal/runtime.iface" %68, ptr %66, align 8
|
||||
%69 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.iface", ptr %26, i64 14
|
||||
%70 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 12)
|
||||
%71 = call %"github.com/goplus/llgo/internal/runtime.iface" @"github.com/goplus/llgo/internal/runtime.MakeAnyInt"(ptr %70, i64 5)
|
||||
store %"github.com/goplus/llgo/internal/runtime.iface" %71, ptr %69, align 8
|
||||
%72 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.iface", ptr %26, i64 15
|
||||
%73 = call %"github.com/goplus/llgo/internal/runtime.String" @"github.com/goplus/llgo/internal/runtime.NewString"(ptr @4, i64 4)
|
||||
%74 = call %"github.com/goplus/llgo/internal/runtime.iface" @"github.com/goplus/llgo/internal/runtime.MakeAnyString"(%"github.com/goplus/llgo/internal/runtime.String" %73)
|
||||
store %"github.com/goplus/llgo/internal/runtime.iface" %74, ptr %72, align 8
|
||||
%75 = call %"github.com/goplus/llgo/internal/runtime.Slice" @"github.com/goplus/llgo/internal/runtime.NewSlice3"(ptr %26, i64 16, i64 16, i64 0, i64 16, i64 16)
|
||||
call void @main.println(%"github.com/goplus/llgo/internal/runtime.Slice" %75)
|
||||
ret void
|
||||
|
||||
_llgo_3: ; preds = %_llgo_0
|
||||
br i1 true, label %_llgo_1, label %_llgo_2
|
||||
}
|
||||
|
||||
define void @main.prinfsub(double %0) {
|
||||
@@ -117,18 +225,223 @@ _llgo_0:
|
||||
ret void
|
||||
}
|
||||
|
||||
define void @main.printany(%"github.com/goplus/llgo/internal/runtime.iface" %0) {
|
||||
_llgo_0:
|
||||
%1 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 1)
|
||||
%2 = call { i64, i1 } @"github.com/goplus/llgo/internal/runtime.CheckI2Int"(%"github.com/goplus/llgo/internal/runtime.iface" %0, ptr %1)
|
||||
%3 = extractvalue { i64, i1 } %2, 0
|
||||
%4 = trunc i64 %3 to i1
|
||||
%5 = extractvalue { i64, i1 } %2, 1
|
||||
br i1 %5, label %_llgo_2, label %_llgo_3
|
||||
|
||||
_llgo_1: ; preds = %_llgo_30, %_llgo_29, %_llgo_28, %_llgo_26, %_llgo_24, %_llgo_22, %_llgo_20, %_llgo_18, %_llgo_16, %_llgo_14, %_llgo_12, %_llgo_10, %_llgo_8, %_llgo_6, %_llgo_4, %_llgo_2
|
||||
ret void
|
||||
|
||||
_llgo_2: ; preds = %_llgo_0
|
||||
call void @main.printbool(i1 %4)
|
||||
br label %_llgo_1
|
||||
|
||||
_llgo_3: ; preds = %_llgo_0
|
||||
%6 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 2)
|
||||
%7 = call { i64, i1 } @"github.com/goplus/llgo/internal/runtime.CheckI2Int"(%"github.com/goplus/llgo/internal/runtime.iface" %0, ptr %6)
|
||||
%8 = extractvalue { i64, i1 } %7, 0
|
||||
%9 = extractvalue { i64, i1 } %7, 1
|
||||
br i1 %9, label %_llgo_4, label %_llgo_5
|
||||
|
||||
_llgo_4: ; preds = %_llgo_3
|
||||
call void @main.printint(i64 %8)
|
||||
br label %_llgo_1
|
||||
|
||||
_llgo_5: ; preds = %_llgo_3
|
||||
%10 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 3)
|
||||
%11 = call { i64, i1 } @"github.com/goplus/llgo/internal/runtime.CheckI2Int"(%"github.com/goplus/llgo/internal/runtime.iface" %0, ptr %10)
|
||||
%12 = extractvalue { i64, i1 } %11, 0
|
||||
%13 = trunc i64 %12 to i8
|
||||
%14 = extractvalue { i64, i1 } %11, 1
|
||||
br i1 %14, label %_llgo_6, label %_llgo_7
|
||||
|
||||
_llgo_6: ; preds = %_llgo_5
|
||||
%15 = sext i8 %13 to i64
|
||||
call void @main.printint(i64 %15)
|
||||
br label %_llgo_1
|
||||
|
||||
_llgo_7: ; preds = %_llgo_5
|
||||
%16 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 4)
|
||||
%17 = call { i64, i1 } @"github.com/goplus/llgo/internal/runtime.CheckI2Int"(%"github.com/goplus/llgo/internal/runtime.iface" %0, ptr %16)
|
||||
%18 = extractvalue { i64, i1 } %17, 0
|
||||
%19 = trunc i64 %18 to i16
|
||||
%20 = extractvalue { i64, i1 } %17, 1
|
||||
br i1 %20, label %_llgo_8, label %_llgo_9
|
||||
|
||||
_llgo_8: ; preds = %_llgo_7
|
||||
%21 = sext i16 %19 to i64
|
||||
call void @main.printint(i64 %21)
|
||||
br label %_llgo_1
|
||||
|
||||
_llgo_9: ; preds = %_llgo_7
|
||||
%22 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 5)
|
||||
%23 = call { i64, i1 } @"github.com/goplus/llgo/internal/runtime.CheckI2Int"(%"github.com/goplus/llgo/internal/runtime.iface" %0, ptr %22)
|
||||
%24 = extractvalue { i64, i1 } %23, 0
|
||||
%25 = trunc i64 %24 to i32
|
||||
%26 = extractvalue { i64, i1 } %23, 1
|
||||
br i1 %26, label %_llgo_10, label %_llgo_11
|
||||
|
||||
_llgo_10: ; preds = %_llgo_9
|
||||
%27 = sext i32 %25 to i64
|
||||
call void @main.printint(i64 %27)
|
||||
br label %_llgo_1
|
||||
|
||||
_llgo_11: ; preds = %_llgo_9
|
||||
%28 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 6)
|
||||
%29 = call { i64, i1 } @"github.com/goplus/llgo/internal/runtime.CheckI2Int"(%"github.com/goplus/llgo/internal/runtime.iface" %0, ptr %28)
|
||||
%30 = extractvalue { i64, i1 } %29, 0
|
||||
%31 = extractvalue { i64, i1 } %29, 1
|
||||
br i1 %31, label %_llgo_12, label %_llgo_13
|
||||
|
||||
_llgo_12: ; preds = %_llgo_11
|
||||
call void @main.printint(i64 %30)
|
||||
br label %_llgo_1
|
||||
|
||||
_llgo_13: ; preds = %_llgo_11
|
||||
%32 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 7)
|
||||
%33 = call { i64, i1 } @"github.com/goplus/llgo/internal/runtime.CheckI2Int"(%"github.com/goplus/llgo/internal/runtime.iface" %0, ptr %32)
|
||||
%34 = extractvalue { i64, i1 } %33, 0
|
||||
%35 = extractvalue { i64, i1 } %33, 1
|
||||
br i1 %35, label %_llgo_14, label %_llgo_15
|
||||
|
||||
_llgo_14: ; preds = %_llgo_13
|
||||
call void @main.printuint(i64 %34)
|
||||
br label %_llgo_1
|
||||
|
||||
_llgo_15: ; preds = %_llgo_13
|
||||
%36 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 8)
|
||||
%37 = call { i64, i1 } @"github.com/goplus/llgo/internal/runtime.CheckI2Int"(%"github.com/goplus/llgo/internal/runtime.iface" %0, ptr %36)
|
||||
%38 = extractvalue { i64, i1 } %37, 0
|
||||
%39 = trunc i64 %38 to i8
|
||||
%40 = extractvalue { i64, i1 } %37, 1
|
||||
br i1 %40, label %_llgo_16, label %_llgo_17
|
||||
|
||||
_llgo_16: ; preds = %_llgo_15
|
||||
%41 = sext i8 %39 to i64
|
||||
call void @main.printuint(i64 %41)
|
||||
br label %_llgo_1
|
||||
|
||||
_llgo_17: ; preds = %_llgo_15
|
||||
%42 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 9)
|
||||
%43 = call { i64, i1 } @"github.com/goplus/llgo/internal/runtime.CheckI2Int"(%"github.com/goplus/llgo/internal/runtime.iface" %0, ptr %42)
|
||||
%44 = extractvalue { i64, i1 } %43, 0
|
||||
%45 = trunc i64 %44 to i16
|
||||
%46 = extractvalue { i64, i1 } %43, 1
|
||||
br i1 %46, label %_llgo_18, label %_llgo_19
|
||||
|
||||
_llgo_18: ; preds = %_llgo_17
|
||||
%47 = sext i16 %45 to i64
|
||||
call void @main.printuint(i64 %47)
|
||||
br label %_llgo_1
|
||||
|
||||
_llgo_19: ; preds = %_llgo_17
|
||||
%48 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 10)
|
||||
%49 = call { i64, i1 } @"github.com/goplus/llgo/internal/runtime.CheckI2Int"(%"github.com/goplus/llgo/internal/runtime.iface" %0, ptr %48)
|
||||
%50 = extractvalue { i64, i1 } %49, 0
|
||||
%51 = trunc i64 %50 to i32
|
||||
%52 = extractvalue { i64, i1 } %49, 1
|
||||
br i1 %52, label %_llgo_20, label %_llgo_21
|
||||
|
||||
_llgo_20: ; preds = %_llgo_19
|
||||
%53 = sext i32 %51 to i64
|
||||
call void @main.printuint(i64 %53)
|
||||
br label %_llgo_1
|
||||
|
||||
_llgo_21: ; preds = %_llgo_19
|
||||
%54 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 11)
|
||||
%55 = call { i64, i1 } @"github.com/goplus/llgo/internal/runtime.CheckI2Int"(%"github.com/goplus/llgo/internal/runtime.iface" %0, ptr %54)
|
||||
%56 = extractvalue { i64, i1 } %55, 0
|
||||
%57 = extractvalue { i64, i1 } %55, 1
|
||||
br i1 %57, label %_llgo_22, label %_llgo_23
|
||||
|
||||
_llgo_22: ; preds = %_llgo_21
|
||||
call void @main.printuint(i64 %56)
|
||||
br label %_llgo_1
|
||||
|
||||
_llgo_23: ; preds = %_llgo_21
|
||||
%58 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 12)
|
||||
%59 = call { i64, i1 } @"github.com/goplus/llgo/internal/runtime.CheckI2Int"(%"github.com/goplus/llgo/internal/runtime.iface" %0, ptr %58)
|
||||
%60 = extractvalue { i64, i1 } %59, 0
|
||||
%61 = extractvalue { i64, i1 } %59, 1
|
||||
br i1 %61, label %_llgo_24, label %_llgo_25
|
||||
|
||||
_llgo_24: ; preds = %_llgo_23
|
||||
call void @main.printuint(i64 %60)
|
||||
br label %_llgo_1
|
||||
|
||||
_llgo_25: ; preds = %_llgo_23
|
||||
%62 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 13)
|
||||
%63 = call { i64, i1 } @"github.com/goplus/llgo/internal/runtime.CheckI2Int"(%"github.com/goplus/llgo/internal/runtime.iface" %0, ptr %62)
|
||||
%64 = extractvalue { i64, i1 } %63, 0
|
||||
%65 = trunc i64 %64 to i32
|
||||
%66 = bitcast i32 %65 to float
|
||||
%67 = extractvalue { i64, i1 } %63, 1
|
||||
br i1 %67, label %_llgo_26, label %_llgo_27
|
||||
|
||||
_llgo_26: ; preds = %_llgo_25
|
||||
%68 = fpext float %66 to double
|
||||
call void @main.printfloat(double %68)
|
||||
br label %_llgo_1
|
||||
|
||||
_llgo_27: ; preds = %_llgo_25
|
||||
%69 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 14)
|
||||
%70 = call { i64, i1 } @"github.com/goplus/llgo/internal/runtime.CheckI2Int"(%"github.com/goplus/llgo/internal/runtime.iface" %0, ptr %69)
|
||||
%71 = extractvalue { i64, i1 } %70, 0
|
||||
%72 = bitcast i64 %71 to double
|
||||
%73 = extractvalue { i64, i1 } %70, 1
|
||||
br i1 %73, label %_llgo_28, label %_llgo_29
|
||||
|
||||
_llgo_28: ; preds = %_llgo_27
|
||||
call void @main.printfloat(double %72)
|
||||
br label %_llgo_1
|
||||
|
||||
_llgo_29: ; preds = %_llgo_27
|
||||
%74 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 24)
|
||||
%75 = call { %"github.com/goplus/llgo/internal/runtime.String", i1 } @"github.com/goplus/llgo/internal/runtime.CheckI2String"(%"github.com/goplus/llgo/internal/runtime.iface" %0, ptr %74)
|
||||
%76 = extractvalue { %"github.com/goplus/llgo/internal/runtime.String", i1 } %75, 0
|
||||
%77 = extractvalue { %"github.com/goplus/llgo/internal/runtime.String", i1 } %75, 1
|
||||
br i1 %77, label %_llgo_30, label %_llgo_1
|
||||
|
||||
_llgo_30: ; preds = %_llgo_29
|
||||
call void @main.printstring(%"github.com/goplus/llgo/internal/runtime.String" %76)
|
||||
br label %_llgo_1
|
||||
}
|
||||
|
||||
define void @main.printbool(i1 %0) {
|
||||
_llgo_0:
|
||||
br i1 %0, label %_llgo_1, label %_llgo_3
|
||||
|
||||
_llgo_1: ; preds = %_llgo_0
|
||||
%1 = call %"github.com/goplus/llgo/internal/runtime.String" @"github.com/goplus/llgo/internal/runtime.NewString"(ptr @5, i64 4)
|
||||
call void @main.printstring(%"github.com/goplus/llgo/internal/runtime.String" %1)
|
||||
br label %_llgo_2
|
||||
|
||||
_llgo_2: ; preds = %_llgo_3, %_llgo_1
|
||||
ret void
|
||||
|
||||
_llgo_3: ; preds = %_llgo_0
|
||||
%2 = call %"github.com/goplus/llgo/internal/runtime.String" @"github.com/goplus/llgo/internal/runtime.NewString"(ptr @6, i64 5)
|
||||
call void @main.printstring(%"github.com/goplus/llgo/internal/runtime.String" %2)
|
||||
br label %_llgo_2
|
||||
}
|
||||
|
||||
define void @main.printfloat(double %0) {
|
||||
_llgo_0:
|
||||
%1 = fcmp one double %0, %0
|
||||
br i1 %1, label %_llgo_1, label %_llgo_3
|
||||
|
||||
_llgo_1: ; preds = %_llgo_0
|
||||
%2 = call %"github.com/goplus/llgo/internal/runtime.String" @"github.com/goplus/llgo/internal/runtime.NewString"(ptr @2, i64 3)
|
||||
%2 = call %"github.com/goplus/llgo/internal/runtime.String" @"github.com/goplus/llgo/internal/runtime.NewString"(ptr @7, i64 3)
|
||||
call void @main.printstring(%"github.com/goplus/llgo/internal/runtime.String" %2)
|
||||
ret void
|
||||
|
||||
_llgo_2: ; preds = %_llgo_7
|
||||
%3 = call %"github.com/goplus/llgo/internal/runtime.String" @"github.com/goplus/llgo/internal/runtime.NewString"(ptr @3, i64 4)
|
||||
%3 = call %"github.com/goplus/llgo/internal/runtime.String" @"github.com/goplus/llgo/internal/runtime.NewString"(ptr @8, i64 4)
|
||||
call void @main.printstring(%"github.com/goplus/llgo/internal/runtime.String" %3)
|
||||
ret void
|
||||
|
||||
@@ -138,7 +451,7 @@ _llgo_3: ; preds = %_llgo_0
|
||||
br i1 %5, label %_llgo_6, label %_llgo_7
|
||||
|
||||
_llgo_4: ; preds = %_llgo_10
|
||||
%6 = call %"github.com/goplus/llgo/internal/runtime.String" @"github.com/goplus/llgo/internal/runtime.NewString"(ptr @4, i64 4)
|
||||
%6 = call %"github.com/goplus/llgo/internal/runtime.String" @"github.com/goplus/llgo/internal/runtime.NewString"(ptr @9, i64 4)
|
||||
call void @main.printstring(%"github.com/goplus/llgo/internal/runtime.String" %6)
|
||||
ret void
|
||||
|
||||
@@ -310,8 +623,13 @@ _llgo_0:
|
||||
|
||||
_llgo_1: ; preds = %_llgo_3
|
||||
%2 = urem i64 %14, 16
|
||||
<<<<<<< HEAD
|
||||
%3 = call %"github.com/goplus/llgo/internal/runtime.String" @"github.com/goplus/llgo/internal/runtime.NewString"(ptr @5, i64 16)
|
||||
%4 = extractvalue %"github.com/goplus/llgo/internal/runtime.String" %3, 0
|
||||
=======
|
||||
%3 = call %"github.com/goplus/llgo/internal/runtime.String" @"github.com/goplus/llgo/internal/runtime.NewString"(ptr @10, i64 16)
|
||||
%4 = call ptr @"github.com/goplus/llgo/internal/runtime.StringData"(%"github.com/goplus/llgo/internal/runtime.String" %3)
|
||||
>>>>>>> gop/main
|
||||
%5 = getelementptr inbounds i8, ptr %4, i64 %2
|
||||
%6 = load i8, ptr %5, align 1
|
||||
%7 = getelementptr inbounds i8, ptr %1, i64 %15
|
||||
@@ -354,7 +672,7 @@ _llgo_0:
|
||||
br i1 %1, label %_llgo_1, label %_llgo_2
|
||||
|
||||
_llgo_1: ; preds = %_llgo_0
|
||||
%2 = call %"github.com/goplus/llgo/internal/runtime.String" @"github.com/goplus/llgo/internal/runtime.NewString"(ptr @6, i64 1)
|
||||
%2 = call %"github.com/goplus/llgo/internal/runtime.String" @"github.com/goplus/llgo/internal/runtime.NewString"(ptr @11, i64 1)
|
||||
call void @main.printstring(%"github.com/goplus/llgo/internal/runtime.String" %2)
|
||||
%3 = sub i64 0, %0
|
||||
br label %_llgo_2
|
||||
@@ -365,165 +683,48 @@ _llgo_2: ; preds = %_llgo_1, %_llgo_0
|
||||
ret void
|
||||
}
|
||||
|
||||
define void @main.println(%"github.com/goplus/llgo/internal/runtime.Slice" %0) {
|
||||
_llgo_0:
|
||||
%1 = call i64 @"github.com/goplus/llgo/internal/runtime.SliceLen"(%"github.com/goplus/llgo/internal/runtime.Slice" %0)
|
||||
br label %_llgo_1
|
||||
|
||||
_llgo_1: ; preds = %_llgo_5, %_llgo_0
|
||||
%2 = phi i64 [ -1, %_llgo_0 ], [ %3, %_llgo_5 ]
|
||||
%3 = add i64 %2, 1
|
||||
%4 = icmp slt i64 %3, %1
|
||||
br i1 %4, label %_llgo_2, label %_llgo_3
|
||||
|
||||
_llgo_2: ; preds = %_llgo_1
|
||||
%5 = call ptr @"github.com/goplus/llgo/internal/runtime.SliceData"(%"github.com/goplus/llgo/internal/runtime.Slice" %0)
|
||||
%6 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.iface", ptr %5, i64 %3
|
||||
%7 = load %"github.com/goplus/llgo/internal/runtime.iface", ptr %6, align 8
|
||||
%8 = icmp ne i64 %3, 0
|
||||
br i1 %8, label %_llgo_4, label %_llgo_5
|
||||
|
||||
_llgo_3: ; preds = %_llgo_1
|
||||
call void @main.printnl()
|
||||
ret void
|
||||
|
||||
_llgo_4: ; preds = %_llgo_2
|
||||
%9 = call %"github.com/goplus/llgo/internal/runtime.String" @"github.com/goplus/llgo/internal/runtime.NewString"(ptr @12, i64 1)
|
||||
call void @main.printstring(%"github.com/goplus/llgo/internal/runtime.String" %9)
|
||||
br label %_llgo_5
|
||||
|
||||
_llgo_5: ; preds = %_llgo_4, %_llgo_2
|
||||
call void @main.printany(%"github.com/goplus/llgo/internal/runtime.iface" %7)
|
||||
br label %_llgo_1
|
||||
}
|
||||
|
||||
define void @main.printnl() {
|
||||
_llgo_0:
|
||||
%0 = call %"github.com/goplus/llgo/internal/runtime.String" @"github.com/goplus/llgo/internal/runtime.NewString"(ptr @7, i64 1)
|
||||
%0 = call %"github.com/goplus/llgo/internal/runtime.String" @"github.com/goplus/llgo/internal/runtime.NewString"(ptr @13, i64 1)
|
||||
call void @main.printstring(%"github.com/goplus/llgo/internal/runtime.String" %0)
|
||||
ret void
|
||||
}
|
||||
|
||||
define void @main.printnum(%"github.com/goplus/llgo/internal/runtime.iface" %0) {
|
||||
_llgo_0:
|
||||
%1 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 2)
|
||||
%2 = call { i64, i1 } @"github.com/goplus/llgo/internal/runtime.CheckI2Int"(%"github.com/goplus/llgo/internal/runtime.iface" %0, ptr %1)
|
||||
%3 = extractvalue { i64, i1 } %2, 0
|
||||
%4 = extractvalue { i64, i1 } %2, 1
|
||||
br i1 %4, label %_llgo_2, label %_llgo_3
|
||||
|
||||
_llgo_1: ; preds = %_llgo_26, %_llgo_25, %_llgo_24, %_llgo_22, %_llgo_20, %_llgo_18, %_llgo_16, %_llgo_14, %_llgo_12, %_llgo_10, %_llgo_8, %_llgo_6, %_llgo_4, %_llgo_2
|
||||
ret void
|
||||
|
||||
_llgo_2: ; preds = %_llgo_0
|
||||
call void @main.printint(i64 %3)
|
||||
br label %_llgo_1
|
||||
|
||||
_llgo_3: ; preds = %_llgo_0
|
||||
%5 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 3)
|
||||
%6 = call { i64, i1 } @"github.com/goplus/llgo/internal/runtime.CheckI2Int"(%"github.com/goplus/llgo/internal/runtime.iface" %0, ptr %5)
|
||||
%7 = extractvalue { i64, i1 } %6, 0
|
||||
%8 = extractvalue { i64, i1 } %6, 1
|
||||
br i1 %8, label %_llgo_4, label %_llgo_5
|
||||
|
||||
_llgo_4: ; preds = %_llgo_3
|
||||
call void @main.printint(i64 %7)
|
||||
br label %_llgo_1
|
||||
|
||||
_llgo_5: ; preds = %_llgo_3
|
||||
%9 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 4)
|
||||
%10 = call { i64, i1 } @"github.com/goplus/llgo/internal/runtime.CheckI2Int"(%"github.com/goplus/llgo/internal/runtime.iface" %0, ptr %9)
|
||||
%11 = extractvalue { i64, i1 } %10, 0
|
||||
%12 = extractvalue { i64, i1 } %10, 1
|
||||
br i1 %12, label %_llgo_6, label %_llgo_7
|
||||
|
||||
_llgo_6: ; preds = %_llgo_5
|
||||
call void @main.printint(i64 %11)
|
||||
br label %_llgo_1
|
||||
|
||||
_llgo_7: ; preds = %_llgo_5
|
||||
%13 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 5)
|
||||
%14 = call { i64, i1 } @"github.com/goplus/llgo/internal/runtime.CheckI2Int"(%"github.com/goplus/llgo/internal/runtime.iface" %0, ptr %13)
|
||||
%15 = extractvalue { i64, i1 } %14, 0
|
||||
%16 = extractvalue { i64, i1 } %14, 1
|
||||
br i1 %16, label %_llgo_8, label %_llgo_9
|
||||
|
||||
_llgo_8: ; preds = %_llgo_7
|
||||
call void @main.printint(i64 %15)
|
||||
br label %_llgo_1
|
||||
|
||||
_llgo_9: ; preds = %_llgo_7
|
||||
%17 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 6)
|
||||
%18 = call { i64, i1 } @"github.com/goplus/llgo/internal/runtime.CheckI2Int"(%"github.com/goplus/llgo/internal/runtime.iface" %0, ptr %17)
|
||||
%19 = extractvalue { i64, i1 } %18, 0
|
||||
%20 = extractvalue { i64, i1 } %18, 1
|
||||
br i1 %20, label %_llgo_10, label %_llgo_11
|
||||
|
||||
_llgo_10: ; preds = %_llgo_9
|
||||
call void @main.printint(i64 %19)
|
||||
br label %_llgo_1
|
||||
|
||||
_llgo_11: ; preds = %_llgo_9
|
||||
%21 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 7)
|
||||
%22 = call { i64, i1 } @"github.com/goplus/llgo/internal/runtime.CheckI2Int"(%"github.com/goplus/llgo/internal/runtime.iface" %0, ptr %21)
|
||||
%23 = extractvalue { i64, i1 } %22, 0
|
||||
%24 = extractvalue { i64, i1 } %22, 1
|
||||
br i1 %24, label %_llgo_12, label %_llgo_13
|
||||
|
||||
_llgo_12: ; preds = %_llgo_11
|
||||
call void @main.printuint(i64 %23)
|
||||
br label %_llgo_1
|
||||
|
||||
_llgo_13: ; preds = %_llgo_11
|
||||
%25 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 8)
|
||||
%26 = call { i64, i1 } @"github.com/goplus/llgo/internal/runtime.CheckI2Int"(%"github.com/goplus/llgo/internal/runtime.iface" %0, ptr %25)
|
||||
%27 = extractvalue { i64, i1 } %26, 0
|
||||
%28 = extractvalue { i64, i1 } %26, 1
|
||||
br i1 %28, label %_llgo_14, label %_llgo_15
|
||||
|
||||
_llgo_14: ; preds = %_llgo_13
|
||||
call void @main.printuint(i64 %27)
|
||||
br label %_llgo_1
|
||||
|
||||
_llgo_15: ; preds = %_llgo_13
|
||||
%29 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 9)
|
||||
%30 = call { i64, i1 } @"github.com/goplus/llgo/internal/runtime.CheckI2Int"(%"github.com/goplus/llgo/internal/runtime.iface" %0, ptr %29)
|
||||
%31 = extractvalue { i64, i1 } %30, 0
|
||||
%32 = extractvalue { i64, i1 } %30, 1
|
||||
br i1 %32, label %_llgo_16, label %_llgo_17
|
||||
|
||||
_llgo_16: ; preds = %_llgo_15
|
||||
call void @main.printuint(i64 %31)
|
||||
br label %_llgo_1
|
||||
|
||||
_llgo_17: ; preds = %_llgo_15
|
||||
%33 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 10)
|
||||
%34 = call { i64, i1 } @"github.com/goplus/llgo/internal/runtime.CheckI2Int"(%"github.com/goplus/llgo/internal/runtime.iface" %0, ptr %33)
|
||||
%35 = extractvalue { i64, i1 } %34, 0
|
||||
%36 = extractvalue { i64, i1 } %34, 1
|
||||
br i1 %36, label %_llgo_18, label %_llgo_19
|
||||
|
||||
_llgo_18: ; preds = %_llgo_17
|
||||
call void @main.printuint(i64 %35)
|
||||
br label %_llgo_1
|
||||
|
||||
_llgo_19: ; preds = %_llgo_17
|
||||
%37 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 11)
|
||||
%38 = call { i64, i1 } @"github.com/goplus/llgo/internal/runtime.CheckI2Int"(%"github.com/goplus/llgo/internal/runtime.iface" %0, ptr %37)
|
||||
%39 = extractvalue { i64, i1 } %38, 0
|
||||
%40 = extractvalue { i64, i1 } %38, 1
|
||||
br i1 %40, label %_llgo_20, label %_llgo_21
|
||||
|
||||
_llgo_20: ; preds = %_llgo_19
|
||||
call void @main.printuint(i64 %39)
|
||||
br label %_llgo_1
|
||||
|
||||
_llgo_21: ; preds = %_llgo_19
|
||||
%41 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 12)
|
||||
%42 = call { i64, i1 } @"github.com/goplus/llgo/internal/runtime.CheckI2Int"(%"github.com/goplus/llgo/internal/runtime.iface" %0, ptr %41)
|
||||
%43 = extractvalue { i64, i1 } %42, 0
|
||||
%44 = extractvalue { i64, i1 } %42, 1
|
||||
br i1 %44, label %_llgo_22, label %_llgo_23
|
||||
|
||||
_llgo_22: ; preds = %_llgo_21
|
||||
call void @main.printuint(i64 %43)
|
||||
br label %_llgo_1
|
||||
|
||||
_llgo_23: ; preds = %_llgo_21
|
||||
%45 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 13)
|
||||
%46 = call { float, i1 } @"github.com/goplus/llgo/internal/runtime.CheckI2Float32"(%"github.com/goplus/llgo/internal/runtime.iface" %0, ptr %45)
|
||||
%47 = extractvalue { float, i1 } %46, 0
|
||||
%48 = extractvalue { float, i1 } %46, 1
|
||||
br i1 %48, label %_llgo_24, label %_llgo_25
|
||||
|
||||
_llgo_24: ; preds = %_llgo_23
|
||||
%49 = fpext float %47 to double
|
||||
call void @main.printfloat(double %49)
|
||||
br label %_llgo_1
|
||||
|
||||
_llgo_25: ; preds = %_llgo_23
|
||||
%50 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 14)
|
||||
%51 = call { double, i1 } @"github.com/goplus/llgo/internal/runtime.CheckI2Float64"(%"github.com/goplus/llgo/internal/runtime.iface" %0, ptr %50)
|
||||
%52 = extractvalue { double, i1 } %51, 0
|
||||
%53 = extractvalue { double, i1 } %51, 1
|
||||
br i1 %53, label %_llgo_26, label %_llgo_1
|
||||
|
||||
_llgo_26: ; preds = %_llgo_25
|
||||
call void @main.printfloat(double %52)
|
||||
br label %_llgo_1
|
||||
}
|
||||
|
||||
define void @main.printsp() {
|
||||
_llgo_0:
|
||||
%0 = call %"github.com/goplus/llgo/internal/runtime.String" @"github.com/goplus/llgo/internal/runtime.NewString"(ptr @8, i64 1)
|
||||
%0 = call %"github.com/goplus/llgo/internal/runtime.String" @"github.com/goplus/llgo/internal/runtime.NewString"(ptr @14, i64 1)
|
||||
call void @main.printstring(%"github.com/goplus/llgo/internal/runtime.String" %0)
|
||||
ret void
|
||||
}
|
||||
@@ -599,10 +800,17 @@ declare ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64)
|
||||
|
||||
declare %"github.com/goplus/llgo/internal/runtime.iface" @"github.com/goplus/llgo/internal/runtime.MakeAnyInt"(ptr, i64)
|
||||
|
||||
declare %"github.com/goplus/llgo/internal/runtime.iface" @"github.com/goplus/llgo/internal/runtime.MakeAnyString"(%"github.com/goplus/llgo/internal/runtime.String")
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
declare %"github.com/goplus/llgo/internal/runtime.Slice" @"github.com/goplus/llgo/internal/runtime.NewSlice3"(ptr, i64, i64, i64, i64, i64)
|
||||
|
||||
>>>>>>> gop/main
|
||||
declare { i64, i1 } @"github.com/goplus/llgo/internal/runtime.CheckI2Int"(%"github.com/goplus/llgo/internal/runtime.iface", ptr)
|
||||
|
||||
declare { float, i1 } @"github.com/goplus/llgo/internal/runtime.CheckI2Float32"(%"github.com/goplus/llgo/internal/runtime.iface", ptr)
|
||||
declare { %"github.com/goplus/llgo/internal/runtime.String", i1 } @"github.com/goplus/llgo/internal/runtime.CheckI2String"(%"github.com/goplus/llgo/internal/runtime.iface", ptr)
|
||||
|
||||
declare { double, i1 } @"github.com/goplus/llgo/internal/runtime.CheckI2Float64"(%"github.com/goplus/llgo/internal/runtime.iface", ptr)
|
||||
declare ptr @"github.com/goplus/llgo/internal/runtime.StringData"(%"github.com/goplus/llgo/internal/runtime.String")
|
||||
|
||||
declare ptr @"github.com/goplus/llgo/internal/runtime.SliceData"(%"github.com/goplus/llgo/internal/runtime.Slice")
|
||||
|
||||
39
cl/_testrt/named/in.go
Normal file
39
cl/_testrt/named/in.go
Normal file
@@ -0,0 +1,39 @@
|
||||
package main
|
||||
|
||||
import "github.com/goplus/llgo/internal/runtime/c"
|
||||
|
||||
type mSpanList struct {
|
||||
first *mspan
|
||||
last *mspan
|
||||
}
|
||||
|
||||
type minfo struct {
|
||||
span *mspan
|
||||
info int
|
||||
}
|
||||
|
||||
type mspan struct {
|
||||
next *mspan
|
||||
prev *mspan
|
||||
list *mSpanList
|
||||
info minfo
|
||||
value int
|
||||
check func(int) int
|
||||
}
|
||||
|
||||
func main() {
|
||||
m := &mspan{}
|
||||
m.value = 100
|
||||
m.next = &mspan{}
|
||||
m.next.value = 200
|
||||
m.list = &mSpanList{}
|
||||
m.list.last = &mspan{}
|
||||
m.list.last.value = 300
|
||||
m.info.info = 10
|
||||
m.info.span = m
|
||||
m.check = func(n int) int {
|
||||
return m.value * n
|
||||
}
|
||||
c.Printf(c.Str("%d %d %d %d %d %d\n"), m.next.value, m.list.last.value, m.info.info,
|
||||
m.info.span.value, m.check(-2), m.info.span.check(-3))
|
||||
}
|
||||
143
cl/_testrt/named/out.ll
Normal file
143
cl/_testrt/named/out.ll
Normal file
@@ -0,0 +1,143 @@
|
||||
; ModuleID = 'main'
|
||||
source_filename = "main"
|
||||
|
||||
%main.mspan = type { ptr, ptr, ptr, %main.minfo, i64, { ptr, ptr } }
|
||||
%main.minfo = type { ptr, i64 }
|
||||
%main.mSpanList = type { ptr, ptr }
|
||||
|
||||
@"main.init$guard" = global ptr null
|
||||
@__llgo_argc = global ptr null
|
||||
@__llgo_argv = global ptr null
|
||||
@0 = private unnamed_addr constant [19 x i8] c"%d %d %d %d %d %d\0A\00", align 1
|
||||
|
||||
define void @main.init() {
|
||||
_llgo_0:
|
||||
%0 = load i1, ptr @"main.init$guard", align 1
|
||||
br i1 %0, label %_llgo_2, label %_llgo_1
|
||||
|
||||
_llgo_1: ; preds = %_llgo_0
|
||||
store i1 true, ptr @"main.init$guard", align 1
|
||||
br label %_llgo_2
|
||||
|
||||
_llgo_2: ; preds = %_llgo_1, %_llgo_0
|
||||
ret void
|
||||
}
|
||||
|
||||
define void @main(i32 %0, ptr %1) {
|
||||
_llgo_0:
|
||||
store i32 %0, ptr @__llgo_argc, align 4
|
||||
store ptr %1, ptr @__llgo_argv, align 8
|
||||
call void @"github.com/goplus/llgo/internal/runtime.init"()
|
||||
call void @main.init()
|
||||
%2 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocZ"(i64 8)
|
||||
%3 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocZ"(i64 64)
|
||||
store ptr %3, ptr %2, align 8
|
||||
%4 = load ptr, ptr %2, align 8
|
||||
%5 = getelementptr inbounds %main.mspan, ptr %4, i32 0, i32 4
|
||||
store i64 100, ptr %5, align 4
|
||||
%6 = load ptr, ptr %2, align 8
|
||||
%7 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocZ"(i64 64)
|
||||
%8 = getelementptr inbounds %main.mspan, ptr %6, i32 0, i32 0
|
||||
store ptr %7, ptr %8, align 8
|
||||
%9 = load ptr, ptr %2, align 8
|
||||
%10 = getelementptr inbounds %main.mspan, ptr %9, i32 0, i32 0
|
||||
%11 = load ptr, ptr %10, align 8
|
||||
%12 = getelementptr inbounds %main.mspan, ptr %11, i32 0, i32 4
|
||||
store i64 200, ptr %12, align 4
|
||||
%13 = load ptr, ptr %2, align 8
|
||||
%14 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocZ"(i64 16)
|
||||
%15 = getelementptr inbounds %main.mspan, ptr %13, i32 0, i32 2
|
||||
store ptr %14, ptr %15, align 8
|
||||
%16 = load ptr, ptr %2, align 8
|
||||
%17 = getelementptr inbounds %main.mspan, ptr %16, i32 0, i32 2
|
||||
%18 = load ptr, ptr %17, align 8
|
||||
%19 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocZ"(i64 64)
|
||||
%20 = getelementptr inbounds %main.mSpanList, ptr %18, i32 0, i32 1
|
||||
store ptr %19, ptr %20, align 8
|
||||
%21 = load ptr, ptr %2, align 8
|
||||
%22 = getelementptr inbounds %main.mspan, ptr %21, i32 0, i32 2
|
||||
%23 = load ptr, ptr %22, align 8
|
||||
%24 = getelementptr inbounds %main.mSpanList, ptr %23, i32 0, i32 1
|
||||
%25 = load ptr, ptr %24, align 8
|
||||
%26 = getelementptr inbounds %main.mspan, ptr %25, i32 0, i32 4
|
||||
store i64 300, ptr %26, align 4
|
||||
%27 = load ptr, ptr %2, align 8
|
||||
%28 = getelementptr inbounds %main.mspan, ptr %27, i32 0, i32 3
|
||||
%29 = getelementptr inbounds %main.minfo, ptr %28, i32 0, i32 1
|
||||
store i64 10, ptr %29, align 4
|
||||
%30 = load ptr, ptr %2, align 8
|
||||
%31 = getelementptr inbounds %main.mspan, ptr %30, i32 0, i32 3
|
||||
%32 = load ptr, ptr %2, align 8
|
||||
%33 = getelementptr inbounds %main.minfo, ptr %31, i32 0, i32 0
|
||||
store ptr %32, ptr %33, align 8
|
||||
%34 = load ptr, ptr %2, align 8
|
||||
%35 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 8)
|
||||
%36 = getelementptr inbounds { ptr }, ptr %35, i32 0, i32 0
|
||||
store ptr %2, ptr %36, align 8
|
||||
%37 = alloca { ptr, ptr }, align 8
|
||||
%38 = getelementptr inbounds { ptr, ptr }, ptr %37, i32 0, i32 0
|
||||
store ptr @"main.main$1", ptr %38, align 8
|
||||
%39 = getelementptr inbounds { ptr, ptr }, ptr %37, i32 0, i32 1
|
||||
store ptr %35, ptr %39, align 8
|
||||
%40 = load { ptr, ptr }, ptr %37, align 8
|
||||
%41 = getelementptr inbounds %main.mspan, ptr %34, i32 0, i32 5
|
||||
store { ptr, ptr } %40, ptr %41, align 8
|
||||
%42 = load ptr, ptr %2, align 8
|
||||
%43 = getelementptr inbounds %main.mspan, ptr %42, i32 0, i32 0
|
||||
%44 = load ptr, ptr %43, align 8
|
||||
%45 = getelementptr inbounds %main.mspan, ptr %44, i32 0, i32 4
|
||||
%46 = load i64, ptr %45, align 4
|
||||
%47 = load ptr, ptr %2, align 8
|
||||
%48 = getelementptr inbounds %main.mspan, ptr %47, i32 0, i32 2
|
||||
%49 = load ptr, ptr %48, align 8
|
||||
%50 = getelementptr inbounds %main.mSpanList, ptr %49, i32 0, i32 1
|
||||
%51 = load ptr, ptr %50, align 8
|
||||
%52 = getelementptr inbounds %main.mspan, ptr %51, i32 0, i32 4
|
||||
%53 = load i64, ptr %52, align 4
|
||||
%54 = load ptr, ptr %2, align 8
|
||||
%55 = getelementptr inbounds %main.mspan, ptr %54, i32 0, i32 3
|
||||
%56 = getelementptr inbounds %main.minfo, ptr %55, i32 0, i32 1
|
||||
%57 = load i64, ptr %56, align 4
|
||||
%58 = load ptr, ptr %2, align 8
|
||||
%59 = getelementptr inbounds %main.mspan, ptr %58, i32 0, i32 3
|
||||
%60 = getelementptr inbounds %main.minfo, ptr %59, i32 0, i32 0
|
||||
%61 = load ptr, ptr %60, align 8
|
||||
%62 = getelementptr inbounds %main.mspan, ptr %61, i32 0, i32 4
|
||||
%63 = load i64, ptr %62, align 4
|
||||
%64 = load ptr, ptr %2, align 8
|
||||
%65 = getelementptr inbounds %main.mspan, ptr %64, i32 0, i32 5
|
||||
%66 = load { ptr, ptr }, ptr %65, align 8
|
||||
%67 = extractvalue { ptr, ptr } %66, 1
|
||||
%68 = extractvalue { ptr, ptr } %66, 0
|
||||
%69 = call i64 %68(ptr %67, i64 -2)
|
||||
%70 = load ptr, ptr %2, align 8
|
||||
%71 = getelementptr inbounds %main.mspan, ptr %70, i32 0, i32 3
|
||||
%72 = getelementptr inbounds %main.minfo, ptr %71, i32 0, i32 0
|
||||
%73 = load ptr, ptr %72, align 8
|
||||
%74 = getelementptr inbounds %main.mspan, ptr %73, i32 0, i32 5
|
||||
%75 = load { ptr, ptr }, ptr %74, align 8
|
||||
%76 = extractvalue { ptr, ptr } %75, 1
|
||||
%77 = extractvalue { ptr, ptr } %75, 0
|
||||
%78 = call i64 %77(ptr %76, i64 -3)
|
||||
%79 = call i32 (ptr, ...) @printf(ptr @0, i64 %46, i64 %53, i64 %57, i64 %63, i64 %69, i64 %78)
|
||||
ret void
|
||||
}
|
||||
|
||||
declare void @"github.com/goplus/llgo/internal/runtime.init"()
|
||||
|
||||
declare ptr @"github.com/goplus/llgo/internal/runtime.AllocZ"(i64)
|
||||
|
||||
define i64 @"main.main$1"(ptr %0, i64 %1) {
|
||||
_llgo_0:
|
||||
%2 = load { ptr }, ptr %0, align 8
|
||||
%3 = extractvalue { ptr } %2, 0
|
||||
%4 = load ptr, ptr %3, align 8
|
||||
%5 = getelementptr inbounds %main.mspan, ptr %4, i32 0, i32 4
|
||||
%6 = load i64, ptr %5, align 4
|
||||
%7 = mul i64 %6, %1
|
||||
ret i64 %7
|
||||
}
|
||||
|
||||
declare ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64)
|
||||
|
||||
declare i32 @printf(ptr, ...)
|
||||
@@ -313,10 +313,6 @@ func (p *context) funcOf(fn *ssa.Function) (aFn llssa.Function, pyFn llssa.PyFun
|
||||
ftype = llgoStringData
|
||||
case "unreachable":
|
||||
ftype = llgoUnreachable
|
||||
case "bitCastTo64F":
|
||||
ftype = llgoBitCastTo64F
|
||||
case "bitCastTo32F":
|
||||
ftype = llgoBitCastTo32F
|
||||
default:
|
||||
panic("unknown llgo instruction: " + name)
|
||||
}
|
||||
@@ -588,10 +584,6 @@ func (p *context) compileInstrOrValue(b llssa.Builder, iv instrOrValue, asValue
|
||||
ret = p.stringData(b, args)
|
||||
case llgoUnreachable: // func unreachable()
|
||||
b.Unreachable()
|
||||
case llgoBitCastTo32F:
|
||||
ret = b.BitCast(p.compileValue(b, args[0]), b.Prog.Type(types.Typ[types.Float32], llssa.InGo))
|
||||
case llgoBitCastTo64F:
|
||||
ret = b.BitCast(p.compileValue(b, args[0]), b.Prog.Float64())
|
||||
default:
|
||||
panic("todo")
|
||||
}
|
||||
|
||||
18
cl/import.go
18
cl/import.go
@@ -310,16 +310,14 @@ const (
|
||||
pyFunc = int(llssa.InPython)
|
||||
llgoInstr = -1
|
||||
|
||||
llgoInstrBase = 0x80
|
||||
llgoUnreachable = llgoInstrBase + 0
|
||||
llgoCstr = llgoInstrBase + 1
|
||||
llgoAlloca = llgoInstrBase + 2
|
||||
llgoAllocaCStr = llgoInstrBase + 3
|
||||
llgoAdvance = llgoInstrBase + 4
|
||||
llgoIndex = llgoInstrBase + 5
|
||||
llgoBitCastTo32F = llgoInstrBase + 6
|
||||
llgoBitCastTo64F = llgoInstrBase + 7
|
||||
llgoStringData = llgoInstrBase + 8
|
||||
llgoInstrBase = 0x80
|
||||
llgoUnreachable = llgoInstrBase + 0
|
||||
llgoCstr = llgoInstrBase + 1
|
||||
llgoAlloca = llgoInstrBase + 2
|
||||
llgoAllocaCStr = llgoInstrBase + 3
|
||||
llgoAdvance = llgoInstrBase + 4
|
||||
llgoIndex = llgoInstrBase + 5
|
||||
llgoStringData = llgoInstrBase + 6
|
||||
)
|
||||
|
||||
func (p *context) funcName(fn *ssa.Function, ignore bool) (*types.Package, string, int) {
|
||||
|
||||
Binary file not shown.
@@ -77,38 +77,18 @@ func CheckI2Int(v Interface, t *Type) (uintptr, bool) {
|
||||
return 0, false
|
||||
}
|
||||
|
||||
func I2Float64(v Interface, t *Type) float64 {
|
||||
func I2String(v Interface, t *Type) string {
|
||||
if v.tab._type == t {
|
||||
return bitCastTo64F(uint64(uintptr(v.data)))
|
||||
return *(*string)(v.data)
|
||||
}
|
||||
panic("I2Float64: type mismatch")
|
||||
panic("I2String: type mismatch")
|
||||
}
|
||||
|
||||
func CheckI2Float64(v Interface, t *Type) (float64, bool) {
|
||||
func CheckI2String(v Interface, t *Type) (string, bool) {
|
||||
if v.tab._type == t {
|
||||
return bitCastTo64F(uint64(uintptr(v.data))), true
|
||||
return *(*string)(v.data), true
|
||||
}
|
||||
return 0, false
|
||||
return "", false
|
||||
}
|
||||
|
||||
func I2Float32(v Interface, t *Type) float32 {
|
||||
if v.tab._type == t {
|
||||
return bitCastTo32F(uint32(uintptr(v.data)))
|
||||
}
|
||||
panic("I2Float32: type mismatch")
|
||||
}
|
||||
|
||||
func CheckI2Float32(v Interface, t *Type) (float32, bool) {
|
||||
if v.tab._type == t {
|
||||
return bitCastTo32F(uint32(uintptr(v.data))), true
|
||||
}
|
||||
return 0, false
|
||||
}
|
||||
|
||||
//go:linkname bitCastTo64F llgo.bitCastTo64F
|
||||
func bitCastTo64F(uint64) float64
|
||||
|
||||
//go:linkname bitCastTo32F llgo.bitCastTo32F
|
||||
func bitCastTo32F(uint32) float32
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
71
ssa/expr.go
71
ssa/expr.go
@@ -24,6 +24,7 @@ import (
|
||||
"go/types"
|
||||
"log"
|
||||
|
||||
"github.com/goplus/llgo/internal/abi"
|
||||
"github.com/goplus/llvm"
|
||||
)
|
||||
|
||||
@@ -257,6 +258,11 @@ var floatPredOpToLLVM = []llvm.FloatPredicate{
|
||||
token.GEQ - predOpBase: llvm.FloatOGE,
|
||||
}
|
||||
|
||||
var boolPredOpToLLVM = []llvm.IntPredicate{
|
||||
token.EQL - predOpBase: llvm.IntEQ,
|
||||
token.NEQ - predOpBase: llvm.IntNE,
|
||||
}
|
||||
|
||||
// EQL NEQ LSS LEQ GTR GEQ == != < <= < >=
|
||||
func isPredOp(op token.Token) bool {
|
||||
return op >= predOpBase && op <= predOpLast
|
||||
@@ -289,7 +295,7 @@ func (b Builder) BinOp(op token.Token, x, y Expr) Expr {
|
||||
}
|
||||
case isLogicOp(op): // op: & | ^ << >> &^
|
||||
if op == token.AND_NOT {
|
||||
panic("todo")
|
||||
return Expr{b.impl.CreateAnd(x.impl, b.impl.CreateNot(y.impl, ""), ""), x.Type}
|
||||
}
|
||||
kind := x.kind
|
||||
llop := logicOpToLLVM[op-logicOpBase]
|
||||
@@ -310,7 +316,10 @@ func (b Builder) BinOp(op token.Token, x, y Expr) Expr {
|
||||
case vkFloat:
|
||||
pred := floatPredOpToLLVM[op-predOpBase]
|
||||
return Expr{llvm.CreateFCmp(b.impl, pred, x.impl, y.impl), tret}
|
||||
case vkString, vkComplex, vkBool:
|
||||
case vkBool:
|
||||
pred := boolPredOpToLLVM[op-predOpBase]
|
||||
return Expr{llvm.CreateICmp(b.impl, pred, x.impl, y.impl), tret}
|
||||
case vkString, vkComplex:
|
||||
panic("todo")
|
||||
}
|
||||
}
|
||||
@@ -1070,7 +1079,7 @@ func (b Builder) MakeInterface(tinter Type, x Expr) (ret Expr) {
|
||||
case *types.Basic:
|
||||
kind := tx.Kind()
|
||||
switch {
|
||||
case kind >= types.Int && kind <= types.Uintptr:
|
||||
case kind >= types.Bool && kind <= types.Uintptr:
|
||||
t := b.InlineCall(pkg.rtFunc("Basic"), prog.Val(int(kind)))
|
||||
tptr := prog.Uintptr()
|
||||
vptr := Expr{llvm.CreateIntCast(b.impl, x.impl, tptr.ll), tptr}
|
||||
@@ -1137,7 +1146,7 @@ func (b Builder) TypeAssert(x Expr, assertedTyp Type, commaOk bool) (ret Expr) {
|
||||
log.Printf("TypeAssert %v, %v, %v\n", x.impl, assertedTyp.raw.Type, commaOk)
|
||||
}
|
||||
switch assertedTyp.kind {
|
||||
case vkSigned, vkUnsigned:
|
||||
case vkSigned, vkUnsigned, vkFloat, vkBool:
|
||||
pkg := b.Func.Pkg
|
||||
fnName := "I2Int"
|
||||
if commaOk {
|
||||
@@ -1152,25 +1161,44 @@ func (b Builder) TypeAssert(x Expr, assertedTyp Type, commaOk bool) (ret Expr) {
|
||||
panic("todo")
|
||||
}
|
||||
typ := b.InlineCall(pkg.rtFunc("Basic"), b.Prog.Val(int(kind)))
|
||||
return b.InlineCall(fn, x, typ)
|
||||
case vkFloat:
|
||||
var fnName string
|
||||
kind := assertedTyp.raw.Underlying().(*types.Basic).Kind()
|
||||
switch kind {
|
||||
case types.Float32:
|
||||
fnName = "I2Float32"
|
||||
if commaOk {
|
||||
fnName = "CheckI2Float32"
|
||||
ret = b.InlineCall(fn, x, typ)
|
||||
if kind != types.Uintptr {
|
||||
conv := func(v llvm.Value) llvm.Value {
|
||||
switch kind {
|
||||
case types.Float32:
|
||||
v = castInt(b.impl, v, b.Prog.tyInt32())
|
||||
v = b.impl.CreateBitCast(v, assertedTyp.ll, "")
|
||||
case types.Float64:
|
||||
v = b.impl.CreateBitCast(v, assertedTyp.ll, "")
|
||||
default:
|
||||
v = castInt(b.impl, v, assertedTyp.ll)
|
||||
}
|
||||
return v
|
||||
}
|
||||
case types.Float64:
|
||||
fnName = "I2Float64"
|
||||
if commaOk {
|
||||
fnName = "CheckI2Float64"
|
||||
if !commaOk {
|
||||
ret.Type = assertedTyp
|
||||
ret.impl = conv(ret.impl)
|
||||
} else {
|
||||
ret.Type = b.Prog.toTuple(
|
||||
types.NewTuple(
|
||||
types.NewVar(token.NoPos, nil, "", assertedTyp.RawType()),
|
||||
ret.Type.RawType().(*types.Tuple).At(1),
|
||||
),
|
||||
)
|
||||
val0 := conv(b.impl.CreateExtractValue(ret.impl, 0, ""))
|
||||
val1 := b.impl.CreateExtractValue(ret.impl, 1, "")
|
||||
ret.impl = llvm.ConstStruct([]llvm.Value{val0, val1}, false)
|
||||
}
|
||||
}
|
||||
return
|
||||
case vkString:
|
||||
pkg := b.Func.Pkg
|
||||
fnName := "I2String"
|
||||
if commaOk {
|
||||
fnName = "CheckI2String"
|
||||
}
|
||||
fn := pkg.rtFunc(fnName)
|
||||
typ := b.InlineCall(pkg.rtFunc("Basic"), b.Prog.Val(int(kind)))
|
||||
typ := b.InlineCall(pkg.rtFunc("Basic"), b.Prog.Val(int(abi.String)))
|
||||
return b.InlineCall(fn, x, typ)
|
||||
}
|
||||
panic("todo")
|
||||
@@ -1285,11 +1313,4 @@ func (b Builder) BuiltinCall(fn string, args ...Expr) (ret Expr) {
|
||||
panic("todo")
|
||||
}
|
||||
|
||||
// BitCast bit cast expr to type
|
||||
func (b Builder) BitCast(val Expr, typ Type) (ret Expr) {
|
||||
ret.Type = typ
|
||||
ret.impl = b.impl.CreateBitCast(val.impl, typ.ll, "")
|
||||
return
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
@@ -109,6 +109,7 @@ type aProgram struct {
|
||||
target *Target
|
||||
td llvm.TargetData
|
||||
// tm llvm.TargetMachine
|
||||
named map[string]llvm.Type
|
||||
|
||||
intType llvm.Type
|
||||
int1Type llvm.Type
|
||||
@@ -164,7 +165,7 @@ func NewProgram(target *Target) Program {
|
||||
// TODO(xsw): Finalize may cause panic, so comment it.
|
||||
ctx.Finalize()
|
||||
*/
|
||||
return &aProgram{ctx: ctx, gocvt: newGoTypes(), target: target, td: td}
|
||||
return &aProgram{ctx: ctx, gocvt: newGoTypes(), target: target, td: td, named: make(map[string]llvm.Type)}
|
||||
}
|
||||
|
||||
// SetPython sets the Python package.
|
||||
|
||||
@@ -189,6 +189,10 @@ func (p Program) tyInt64() llvm.Type {
|
||||
return p.int64Type
|
||||
}
|
||||
|
||||
func (p Program) toTuple(typ *types.Tuple) Type {
|
||||
return &aType{p.toLLVMTuple(typ), rawType{typ}, vkTuple}
|
||||
}
|
||||
|
||||
func (p Program) toType(raw types.Type) Type {
|
||||
typ := rawType{raw}
|
||||
switch t := raw.(type) {
|
||||
@@ -252,7 +256,11 @@ func (p Program) toType(raw types.Type) Type {
|
||||
}
|
||||
|
||||
func (p Program) toLLVMNamedStruct(name string, raw *types.Struct) llvm.Type {
|
||||
if typ, ok := p.named[name]; ok {
|
||||
return typ
|
||||
}
|
||||
t := p.ctx.StructCreateNamed(name)
|
||||
p.named[name] = t
|
||||
fields := p.toLLVMFields(raw)
|
||||
t.StructSetBody(fields, false)
|
||||
return t
|
||||
|
||||
@@ -26,12 +26,14 @@ import (
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
type goTypes struct {
|
||||
typs map[unsafe.Pointer]unsafe.Pointer
|
||||
typs map[unsafe.Pointer]unsafe.Pointer
|
||||
named map[string]*types.Named
|
||||
}
|
||||
|
||||
func newGoTypes() goTypes {
|
||||
typs := make(map[unsafe.Pointer]unsafe.Pointer)
|
||||
return goTypes{typs}
|
||||
named := make(map[string]*types.Named)
|
||||
return goTypes{typs, named}
|
||||
}
|
||||
|
||||
type Background int
|
||||
@@ -116,10 +118,16 @@ func (p goTypes) cvtNamed(t *types.Named) (raw *types.Named, cvt bool) {
|
||||
defer func() {
|
||||
p.typs[unsafe.Pointer(t)] = unsafe.Pointer(raw)
|
||||
}()
|
||||
id := t.String()
|
||||
if named, ok := p.named[id]; ok {
|
||||
return named, false
|
||||
}
|
||||
named := types.NewNamed(t.Obj(), types.Typ[types.Int], nil)
|
||||
p.named[id] = named
|
||||
defer delete(p.named, id)
|
||||
if tund, cvt := p.cvtType(t.Underlying()); cvt {
|
||||
old := t.Obj()
|
||||
obj := types.NewTypeName(old.Pos(), old.Pkg(), old.Name(), nil)
|
||||
return types.NewNamed(obj, tund, nil), true
|
||||
named.SetUnderlying(tund)
|
||||
return named, true
|
||||
}
|
||||
return t, false
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user