diff --git a/cl/_testdata/print/out.ll b/cl/_testdata/print/out.ll index 44457e288..9f89186a3 100644 --- a/cl/_testdata/print/out.ll +++ b/cl/_testdata/print/out.ll @@ -13,9 +13,24 @@ 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 +@_llgo_float32 = linkonce global ptr null +@_llgo_float64 = linkonce global ptr null @2 = private unnamed_addr constant [11 x i8] c"check bool\00", align 1 +@_llgo_string = linkonce global ptr null +@_llgo_bool = linkonce global ptr null @3 = private unnamed_addr constant [9 x i8] c"check &^\00", align 1 +@_llgo_int32 = linkonce global ptr null +@_llgo_int8 = linkonce global ptr null +@_llgo_int16 = linkonce global ptr null +@_llgo_int64 = linkonce global ptr null +@_llgo_int = linkonce global ptr null +@_llgo_uint8 = linkonce global ptr null +@_llgo_uint16 = linkonce global ptr null +@_llgo_uint32 = linkonce global ptr null +@_llgo_uint64 = linkonce global ptr null +@_llgo_uintptr = linkonce global ptr null @4 = private unnamed_addr constant [5 x i8] c"llgo\00", align 1 +@_llgo_uint = linkonce global ptr null @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 @@ -70,6 +85,7 @@ _llgo_0: _llgo_1: ; preds = %_llgo_0 store i1 true, ptr @"main.init$guard", align 1 + call void @"main.init$abi"() store i64 0, ptr @main.minhexdigits, align 4 br label %_llgo_2 @@ -103,7 +119,7 @@ _llgo_0: call void @main.printnl() call void @main.prinfsub(double 1.001000e+02) call void @main.printnl() - %6 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 13) + %6 = load ptr, ptr @_llgo_float32, align 8 %7 = alloca %"github.com/goplus/llgo/internal/runtime.eface", align 8 %8 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %7, i32 0, i32 0 store ptr %6, ptr %8, align 8 @@ -112,7 +128,7 @@ _llgo_0: %10 = load %"github.com/goplus/llgo/internal/runtime.eface", ptr %7, align 8 call void @main.printany(%"github.com/goplus/llgo/internal/runtime.eface" %10) call void @main.printnl() - %11 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 14) + %11 = load ptr, ptr @_llgo_float64, align 8 %12 = alloca %"github.com/goplus/llgo/internal/runtime.eface", align 8 %13 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %12, i32 0, i32 0 store ptr %11, ptr %13, align 8 @@ -132,7 +148,7 @@ _llgo_1: ; preds = %_llgo_3 %20 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %18, i32 0, i32 1 store i64 10, ptr %20, align 4 %21 = load %"github.com/goplus/llgo/internal/runtime.String", ptr %18, align 8 - %22 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 24) + %22 = load ptr, ptr @_llgo_string, align 8 %23 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 16) store %"github.com/goplus/llgo/internal/runtime.String" %21, ptr %23, align 8 %24 = alloca %"github.com/goplus/llgo/internal/runtime.eface", align 8 @@ -143,7 +159,7 @@ _llgo_1: ; preds = %_llgo_3 %27 = load %"github.com/goplus/llgo/internal/runtime.eface", ptr %24, align 8 store %"github.com/goplus/llgo/internal/runtime.eface" %27, ptr %17, align 8 %28 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %16, i64 1 - %29 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 1) + %29 = load ptr, ptr @_llgo_bool, align 8 %30 = alloca %"github.com/goplus/llgo/internal/runtime.eface", align 8 %31 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %30, i32 0, i32 0 store ptr %29, ptr %31, align 8 @@ -171,7 +187,7 @@ _llgo_2: ; preds = %_llgo_3, %_llgo_1, %43 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %41, i32 0, i32 1 store i64 8, ptr %43, align 4 %44 = load %"github.com/goplus/llgo/internal/runtime.String", ptr %41, align 8 - %45 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 24) + %45 = load ptr, ptr @_llgo_string, align 8 %46 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 16) store %"github.com/goplus/llgo/internal/runtime.String" %44, ptr %46, align 8 %47 = alloca %"github.com/goplus/llgo/internal/runtime.eface", align 8 @@ -182,7 +198,7 @@ _llgo_2: ; preds = %_llgo_3, %_llgo_1, %50 = load %"github.com/goplus/llgo/internal/runtime.eface", ptr %47, align 8 store %"github.com/goplus/llgo/internal/runtime.eface" %50, ptr %40, align 8 %51 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %39, i64 1 - %52 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 1) + %52 = load ptr, ptr @_llgo_bool, align 8 %53 = alloca %"github.com/goplus/llgo/internal/runtime.eface", align 8 %54 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %53, i32 0, i32 0 store ptr %52, ptr %54, align 8 @@ -191,7 +207,7 @@ _llgo_2: ; preds = %_llgo_3, %_llgo_1, %56 = load %"github.com/goplus/llgo/internal/runtime.eface", ptr %53, align 8 store %"github.com/goplus/llgo/internal/runtime.eface" %56, ptr %51, align 8 %57 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %39, i64 2 - %58 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 1) + %58 = load ptr, ptr @_llgo_bool, align 8 %59 = alloca %"github.com/goplus/llgo/internal/runtime.eface", align 8 %60 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %59, i32 0, i32 0 store ptr %58, ptr %60, align 8 @@ -210,7 +226,7 @@ _llgo_2: ; preds = %_llgo_3, %_llgo_1, call void @main.println(%"github.com/goplus/llgo/internal/runtime.Slice" %67) %68 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocZ"(i64 256) %69 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %68, i64 0 - %70 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 1) + %70 = load ptr, ptr @_llgo_bool, align 8 %71 = alloca %"github.com/goplus/llgo/internal/runtime.eface", align 8 %72 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %71, i32 0, i32 0 store ptr %70, ptr %72, align 8 @@ -219,7 +235,7 @@ _llgo_2: ; preds = %_llgo_3, %_llgo_1, %74 = load %"github.com/goplus/llgo/internal/runtime.eface", ptr %71, align 8 store %"github.com/goplus/llgo/internal/runtime.eface" %74, ptr %69, align 8 %75 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %68, i64 1 - %76 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 1) + %76 = load ptr, ptr @_llgo_bool, align 8 %77 = alloca %"github.com/goplus/llgo/internal/runtime.eface", align 8 %78 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %77, i32 0, i32 0 store ptr %76, ptr %78, align 8 @@ -228,7 +244,7 @@ _llgo_2: ; preds = %_llgo_3, %_llgo_1, %80 = load %"github.com/goplus/llgo/internal/runtime.eface", ptr %77, align 8 store %"github.com/goplus/llgo/internal/runtime.eface" %80, ptr %75, align 8 %81 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %68, i64 2 - %82 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 5) + %82 = load ptr, ptr @_llgo_int32, align 8 %83 = alloca %"github.com/goplus/llgo/internal/runtime.eface", align 8 %84 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %83, i32 0, i32 0 store ptr %82, ptr %84, align 8 @@ -237,7 +253,7 @@ _llgo_2: ; preds = %_llgo_3, %_llgo_1, %86 = load %"github.com/goplus/llgo/internal/runtime.eface", ptr %83, align 8 store %"github.com/goplus/llgo/internal/runtime.eface" %86, ptr %81, align 8 %87 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %68, i64 3 - %88 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 5) + %88 = load ptr, ptr @_llgo_int32, align 8 %89 = alloca %"github.com/goplus/llgo/internal/runtime.eface", align 8 %90 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %89, i32 0, i32 0 store ptr %88, ptr %90, align 8 @@ -246,7 +262,7 @@ _llgo_2: ; preds = %_llgo_3, %_llgo_1, %92 = load %"github.com/goplus/llgo/internal/runtime.eface", ptr %89, align 8 store %"github.com/goplus/llgo/internal/runtime.eface" %92, ptr %87, align 8 %93 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %68, i64 4 - %94 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 5) + %94 = load ptr, ptr @_llgo_int32, align 8 %95 = alloca %"github.com/goplus/llgo/internal/runtime.eface", align 8 %96 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %95, i32 0, i32 0 store ptr %94, ptr %96, align 8 @@ -255,7 +271,7 @@ _llgo_2: ; preds = %_llgo_3, %_llgo_1, %98 = load %"github.com/goplus/llgo/internal/runtime.eface", ptr %95, align 8 store %"github.com/goplus/llgo/internal/runtime.eface" %98, ptr %93, align 8 %99 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %68, i64 5 - %100 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 3) + %100 = load ptr, ptr @_llgo_int8, align 8 %101 = alloca %"github.com/goplus/llgo/internal/runtime.eface", align 8 %102 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %101, i32 0, i32 0 store ptr %100, ptr %102, align 8 @@ -264,7 +280,7 @@ _llgo_2: ; preds = %_llgo_3, %_llgo_1, %104 = load %"github.com/goplus/llgo/internal/runtime.eface", ptr %101, align 8 store %"github.com/goplus/llgo/internal/runtime.eface" %104, ptr %99, align 8 %105 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %68, i64 6 - %106 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 4) + %106 = load ptr, ptr @_llgo_int16, align 8 %107 = alloca %"github.com/goplus/llgo/internal/runtime.eface", align 8 %108 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %107, i32 0, i32 0 store ptr %106, ptr %108, align 8 @@ -273,7 +289,7 @@ _llgo_2: ; preds = %_llgo_3, %_llgo_1, %110 = load %"github.com/goplus/llgo/internal/runtime.eface", ptr %107, align 8 store %"github.com/goplus/llgo/internal/runtime.eface" %110, ptr %105, align 8 %111 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %68, i64 7 - %112 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 5) + %112 = load ptr, ptr @_llgo_int32, align 8 %113 = alloca %"github.com/goplus/llgo/internal/runtime.eface", align 8 %114 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %113, i32 0, i32 0 store ptr %112, ptr %114, align 8 @@ -282,7 +298,7 @@ _llgo_2: ; preds = %_llgo_3, %_llgo_1, %116 = load %"github.com/goplus/llgo/internal/runtime.eface", ptr %113, align 8 store %"github.com/goplus/llgo/internal/runtime.eface" %116, ptr %111, align 8 %117 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %68, i64 8 - %118 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 6) + %118 = load ptr, ptr @_llgo_int64, align 8 %119 = alloca %"github.com/goplus/llgo/internal/runtime.eface", align 8 %120 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %119, i32 0, i32 0 store ptr %118, ptr %120, align 8 @@ -291,7 +307,7 @@ _llgo_2: ; preds = %_llgo_3, %_llgo_1, %122 = load %"github.com/goplus/llgo/internal/runtime.eface", ptr %119, align 8 store %"github.com/goplus/llgo/internal/runtime.eface" %122, ptr %117, align 8 %123 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %68, i64 9 - %124 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 2) + %124 = load ptr, ptr @_llgo_int, align 8 %125 = alloca %"github.com/goplus/llgo/internal/runtime.eface", align 8 %126 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %125, i32 0, i32 0 store ptr %124, ptr %126, align 8 @@ -300,7 +316,7 @@ _llgo_2: ; preds = %_llgo_3, %_llgo_1, %128 = load %"github.com/goplus/llgo/internal/runtime.eface", ptr %125, align 8 store %"github.com/goplus/llgo/internal/runtime.eface" %128, ptr %123, align 8 %129 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %68, i64 10 - %130 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 8) + %130 = load ptr, ptr @_llgo_uint8, align 8 %131 = alloca %"github.com/goplus/llgo/internal/runtime.eface", align 8 %132 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %131, i32 0, i32 0 store ptr %130, ptr %132, align 8 @@ -309,7 +325,7 @@ _llgo_2: ; preds = %_llgo_3, %_llgo_1, %134 = load %"github.com/goplus/llgo/internal/runtime.eface", ptr %131, align 8 store %"github.com/goplus/llgo/internal/runtime.eface" %134, ptr %129, align 8 %135 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %68, i64 11 - %136 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 9) + %136 = load ptr, ptr @_llgo_uint16, align 8 %137 = alloca %"github.com/goplus/llgo/internal/runtime.eface", align 8 %138 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %137, i32 0, i32 0 store ptr %136, ptr %138, align 8 @@ -318,7 +334,7 @@ _llgo_2: ; preds = %_llgo_3, %_llgo_1, %140 = load %"github.com/goplus/llgo/internal/runtime.eface", ptr %137, align 8 store %"github.com/goplus/llgo/internal/runtime.eface" %140, ptr %135, align 8 %141 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %68, i64 12 - %142 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 10) + %142 = load ptr, ptr @_llgo_uint32, align 8 %143 = alloca %"github.com/goplus/llgo/internal/runtime.eface", align 8 %144 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %143, i32 0, i32 0 store ptr %142, ptr %144, align 8 @@ -327,7 +343,7 @@ _llgo_2: ; preds = %_llgo_3, %_llgo_1, %146 = load %"github.com/goplus/llgo/internal/runtime.eface", ptr %143, align 8 store %"github.com/goplus/llgo/internal/runtime.eface" %146, ptr %141, align 8 %147 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %68, i64 13 - %148 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 11) + %148 = load ptr, ptr @_llgo_uint64, align 8 %149 = alloca %"github.com/goplus/llgo/internal/runtime.eface", align 8 %150 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %149, i32 0, i32 0 store ptr %148, ptr %150, align 8 @@ -336,7 +352,7 @@ _llgo_2: ; preds = %_llgo_3, %_llgo_1, %152 = load %"github.com/goplus/llgo/internal/runtime.eface", ptr %149, align 8 store %"github.com/goplus/llgo/internal/runtime.eface" %152, ptr %147, align 8 %153 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %68, i64 14 - %154 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 12) + %154 = load ptr, ptr @_llgo_uintptr, align 8 %155 = alloca %"github.com/goplus/llgo/internal/runtime.eface", align 8 %156 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %155, i32 0, i32 0 store ptr %154, ptr %156, align 8 @@ -351,7 +367,7 @@ _llgo_2: ; preds = %_llgo_3, %_llgo_1, %162 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %160, i32 0, i32 1 store i64 4, ptr %162, align 4 %163 = load %"github.com/goplus/llgo/internal/runtime.String", ptr %160, align 8 - %164 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 24) + %164 = load ptr, ptr @_llgo_string, align 8 %165 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 16) store %"github.com/goplus/llgo/internal/runtime.String" %163, ptr %165, align 8 %166 = alloca %"github.com/goplus/llgo/internal/runtime.eface", align 8 @@ -393,7 +409,7 @@ _llgo_0: define void @main.printany(%"github.com/goplus/llgo/internal/runtime.eface" %0) { _llgo_0: %1 = extractvalue %"github.com/goplus/llgo/internal/runtime.eface" %0, 0 - %2 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 1) + %2 = load ptr, ptr @_llgo_bool, align 8 %3 = icmp eq ptr %1, %2 br i1 %3, label %_llgo_31, label %_llgo_32 @@ -406,7 +422,7 @@ _llgo_2: ; preds = %_llgo_33 _llgo_3: ; preds = %_llgo_33 %4 = extractvalue %"github.com/goplus/llgo/internal/runtime.eface" %0, 0 - %5 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 2) + %5 = load ptr, ptr @_llgo_int, align 8 %6 = icmp eq ptr %4, %5 br i1 %6, label %_llgo_34, label %_llgo_35 @@ -416,7 +432,7 @@ _llgo_4: ; preds = %_llgo_36 _llgo_5: ; preds = %_llgo_36 %7 = extractvalue %"github.com/goplus/llgo/internal/runtime.eface" %0, 0 - %8 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 3) + %8 = load ptr, ptr @_llgo_int8, align 8 %9 = icmp eq ptr %7, %8 br i1 %9, label %_llgo_37, label %_llgo_38 @@ -427,7 +443,7 @@ _llgo_6: ; preds = %_llgo_39 _llgo_7: ; preds = %_llgo_39 %11 = extractvalue %"github.com/goplus/llgo/internal/runtime.eface" %0, 0 - %12 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 4) + %12 = load ptr, ptr @_llgo_int16, align 8 %13 = icmp eq ptr %11, %12 br i1 %13, label %_llgo_40, label %_llgo_41 @@ -438,7 +454,7 @@ _llgo_8: ; preds = %_llgo_42 _llgo_9: ; preds = %_llgo_42 %15 = extractvalue %"github.com/goplus/llgo/internal/runtime.eface" %0, 0 - %16 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 5) + %16 = load ptr, ptr @_llgo_int32, align 8 %17 = icmp eq ptr %15, %16 br i1 %17, label %_llgo_43, label %_llgo_44 @@ -449,7 +465,7 @@ _llgo_10: ; preds = %_llgo_45 _llgo_11: ; preds = %_llgo_45 %19 = extractvalue %"github.com/goplus/llgo/internal/runtime.eface" %0, 0 - %20 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 6) + %20 = load ptr, ptr @_llgo_int64, align 8 %21 = icmp eq ptr %19, %20 br i1 %21, label %_llgo_46, label %_llgo_47 @@ -459,7 +475,7 @@ _llgo_12: ; preds = %_llgo_48 _llgo_13: ; preds = %_llgo_48 %22 = extractvalue %"github.com/goplus/llgo/internal/runtime.eface" %0, 0 - %23 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 7) + %23 = load ptr, ptr @_llgo_uint, align 8 %24 = icmp eq ptr %22, %23 br i1 %24, label %_llgo_49, label %_llgo_50 @@ -469,7 +485,7 @@ _llgo_14: ; preds = %_llgo_51 _llgo_15: ; preds = %_llgo_51 %25 = extractvalue %"github.com/goplus/llgo/internal/runtime.eface" %0, 0 - %26 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 8) + %26 = load ptr, ptr @_llgo_uint8, align 8 %27 = icmp eq ptr %25, %26 br i1 %27, label %_llgo_52, label %_llgo_53 @@ -480,7 +496,7 @@ _llgo_16: ; preds = %_llgo_54 _llgo_17: ; preds = %_llgo_54 %29 = extractvalue %"github.com/goplus/llgo/internal/runtime.eface" %0, 0 - %30 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 9) + %30 = load ptr, ptr @_llgo_uint16, align 8 %31 = icmp eq ptr %29, %30 br i1 %31, label %_llgo_55, label %_llgo_56 @@ -491,7 +507,7 @@ _llgo_18: ; preds = %_llgo_57 _llgo_19: ; preds = %_llgo_57 %33 = extractvalue %"github.com/goplus/llgo/internal/runtime.eface" %0, 0 - %34 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 10) + %34 = load ptr, ptr @_llgo_uint32, align 8 %35 = icmp eq ptr %33, %34 br i1 %35, label %_llgo_58, label %_llgo_59 @@ -502,7 +518,7 @@ _llgo_20: ; preds = %_llgo_60 _llgo_21: ; preds = %_llgo_60 %37 = extractvalue %"github.com/goplus/llgo/internal/runtime.eface" %0, 0 - %38 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 11) + %38 = load ptr, ptr @_llgo_uint64, align 8 %39 = icmp eq ptr %37, %38 br i1 %39, label %_llgo_61, label %_llgo_62 @@ -512,7 +528,7 @@ _llgo_22: ; preds = %_llgo_63 _llgo_23: ; preds = %_llgo_63 %40 = extractvalue %"github.com/goplus/llgo/internal/runtime.eface" %0, 0 - %41 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 12) + %41 = load ptr, ptr @_llgo_uintptr, align 8 %42 = icmp eq ptr %40, %41 br i1 %42, label %_llgo_64, label %_llgo_65 @@ -522,7 +538,7 @@ _llgo_24: ; preds = %_llgo_66 _llgo_25: ; preds = %_llgo_66 %43 = extractvalue %"github.com/goplus/llgo/internal/runtime.eface" %0, 0 - %44 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 13) + %44 = load ptr, ptr @_llgo_float32, align 8 %45 = icmp eq ptr %43, %44 br i1 %45, label %_llgo_67, label %_llgo_68 @@ -533,7 +549,7 @@ _llgo_26: ; preds = %_llgo_69 _llgo_27: ; preds = %_llgo_69 %47 = extractvalue %"github.com/goplus/llgo/internal/runtime.eface" %0, 0 - %48 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 14) + %48 = load ptr, ptr @_llgo_float64, align 8 %49 = icmp eq ptr %47, %48 br i1 %49, label %_llgo_70, label %_llgo_71 @@ -543,7 +559,7 @@ _llgo_28: ; preds = %_llgo_72 _llgo_29: ; preds = %_llgo_72 %50 = extractvalue %"github.com/goplus/llgo/internal/runtime.eface" %0, 0 - %51 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 24) + %51 = load ptr, ptr @_llgo_string, align 8 %52 = icmp eq ptr %50, %51 br i1 %52, label %_llgo_73, label %_llgo_74 @@ -1396,6 +1412,161 @@ declare i32 @printf(ptr, ...) declare void @"github.com/goplus/llgo/internal/runtime.init"() +define void @"main.init$abi"() { +_llgo_0: + %0 = load ptr, ptr @_llgo_float32, align 8 + %1 = icmp eq ptr %0, null + br i1 %1, label %_llgo_1, label %_llgo_2 + +_llgo_1: ; preds = %_llgo_0 + %2 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 13) + store ptr %2, ptr @_llgo_float32, align 8 + br label %_llgo_2 + +_llgo_2: ; preds = %_llgo_1, %_llgo_0 + %3 = load ptr, ptr @_llgo_float64, align 8 + %4 = icmp eq ptr %3, null + br i1 %4, label %_llgo_3, label %_llgo_4 + +_llgo_3: ; preds = %_llgo_2 + %5 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 14) + store ptr %5, ptr @_llgo_float64, align 8 + br label %_llgo_4 + +_llgo_4: ; preds = %_llgo_3, %_llgo_2 + %6 = load ptr, ptr @_llgo_string, align 8 + %7 = icmp eq ptr %6, null + br i1 %7, label %_llgo_5, label %_llgo_6 + +_llgo_5: ; preds = %_llgo_4 + %8 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 24) + store ptr %8, ptr @_llgo_string, align 8 + br label %_llgo_6 + +_llgo_6: ; preds = %_llgo_5, %_llgo_4 + %9 = load ptr, ptr @_llgo_bool, align 8 + %10 = icmp eq ptr %9, null + br i1 %10, label %_llgo_7, label %_llgo_8 + +_llgo_7: ; preds = %_llgo_6 + %11 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 1) + store ptr %11, ptr @_llgo_bool, align 8 + br label %_llgo_8 + +_llgo_8: ; preds = %_llgo_7, %_llgo_6 + %12 = load ptr, ptr @_llgo_int32, align 8 + %13 = icmp eq ptr %12, null + br i1 %13, label %_llgo_9, label %_llgo_10 + +_llgo_9: ; preds = %_llgo_8 + %14 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 5) + store ptr %14, ptr @_llgo_int32, align 8 + br label %_llgo_10 + +_llgo_10: ; preds = %_llgo_9, %_llgo_8 + %15 = load ptr, ptr @_llgo_int8, align 8 + %16 = icmp eq ptr %15, null + br i1 %16, label %_llgo_11, label %_llgo_12 + +_llgo_11: ; preds = %_llgo_10 + %17 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 3) + store ptr %17, ptr @_llgo_int8, align 8 + br label %_llgo_12 + +_llgo_12: ; preds = %_llgo_11, %_llgo_10 + %18 = load ptr, ptr @_llgo_int16, align 8 + %19 = icmp eq ptr %18, null + br i1 %19, label %_llgo_13, label %_llgo_14 + +_llgo_13: ; preds = %_llgo_12 + %20 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 4) + store ptr %20, ptr @_llgo_int16, align 8 + br label %_llgo_14 + +_llgo_14: ; preds = %_llgo_13, %_llgo_12 + %21 = load ptr, ptr @_llgo_int64, align 8 + %22 = icmp eq ptr %21, null + br i1 %22, label %_llgo_15, label %_llgo_16 + +_llgo_15: ; preds = %_llgo_14 + %23 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 6) + store ptr %23, ptr @_llgo_int64, align 8 + br label %_llgo_16 + +_llgo_16: ; preds = %_llgo_15, %_llgo_14 + %24 = load ptr, ptr @_llgo_int, align 8 + %25 = icmp eq ptr %24, null + br i1 %25, label %_llgo_17, label %_llgo_18 + +_llgo_17: ; preds = %_llgo_16 + %26 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 2) + store ptr %26, ptr @_llgo_int, align 8 + br label %_llgo_18 + +_llgo_18: ; preds = %_llgo_17, %_llgo_16 + %27 = load ptr, ptr @_llgo_uint8, align 8 + %28 = icmp eq ptr %27, null + br i1 %28, label %_llgo_19, label %_llgo_20 + +_llgo_19: ; preds = %_llgo_18 + %29 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 8) + store ptr %29, ptr @_llgo_uint8, align 8 + br label %_llgo_20 + +_llgo_20: ; preds = %_llgo_19, %_llgo_18 + %30 = load ptr, ptr @_llgo_uint16, align 8 + %31 = icmp eq ptr %30, null + br i1 %31, label %_llgo_21, label %_llgo_22 + +_llgo_21: ; preds = %_llgo_20 + %32 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 9) + store ptr %32, ptr @_llgo_uint16, align 8 + br label %_llgo_22 + +_llgo_22: ; preds = %_llgo_21, %_llgo_20 + %33 = load ptr, ptr @_llgo_uint32, align 8 + %34 = icmp eq ptr %33, null + br i1 %34, label %_llgo_23, label %_llgo_24 + +_llgo_23: ; preds = %_llgo_22 + %35 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 10) + store ptr %35, ptr @_llgo_uint32, align 8 + br label %_llgo_24 + +_llgo_24: ; preds = %_llgo_23, %_llgo_22 + %36 = load ptr, ptr @_llgo_uint64, align 8 + %37 = icmp eq ptr %36, null + br i1 %37, label %_llgo_25, label %_llgo_26 + +_llgo_25: ; preds = %_llgo_24 + %38 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 11) + store ptr %38, ptr @_llgo_uint64, align 8 + br label %_llgo_26 + +_llgo_26: ; preds = %_llgo_25, %_llgo_24 + %39 = load ptr, ptr @_llgo_uintptr, align 8 + %40 = icmp eq ptr %39, null + br i1 %40, label %_llgo_27, label %_llgo_28 + +_llgo_27: ; preds = %_llgo_26 + %41 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 12) + store ptr %41, ptr @_llgo_uintptr, align 8 + br label %_llgo_28 + +_llgo_28: ; preds = %_llgo_27, %_llgo_26 + %42 = load ptr, ptr @_llgo_uint, align 8 + %43 = icmp eq ptr %42, null + br i1 %43, label %_llgo_29, label %_llgo_30 + +_llgo_29: ; preds = %_llgo_28 + %44 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 7) + store ptr %44, ptr @_llgo_uint, align 8 + br label %_llgo_30 + +_llgo_30: ; preds = %_llgo_29, %_llgo_28 + ret void +} + declare ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64) declare ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64) diff --git a/cl/_testdata/vargs/out.ll b/cl/_testdata/vargs/out.ll index 9d9d841e7..a687457b7 100644 --- a/cl/_testdata/vargs/out.ll +++ b/cl/_testdata/vargs/out.ll @@ -8,6 +8,7 @@ source_filename = "main" @"main.init$guard" = global ptr null @__llgo_argc = global ptr null @__llgo_argv = global ptr null +@_llgo_int = linkonce global ptr null @0 = private unnamed_addr constant [4 x i8] c"%d\0A\00", align 1 @1 = private unnamed_addr constant [22 x i8] c"type assertion failed\00", align 1 @@ -18,6 +19,7 @@ _llgo_0: _llgo_1: ; preds = %_llgo_0 store i1 true, ptr @"main.init$guard", align 1 + call void @"main.init$abi"() br label %_llgo_2 _llgo_2: ; preds = %_llgo_1, %_llgo_0 @@ -32,7 +34,7 @@ _llgo_0: call void @main.init() %2 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocZ"(i64 48) %3 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %2, i64 0 - %4 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 2) + %4 = load ptr, ptr @_llgo_int, align 8 %5 = alloca %"github.com/goplus/llgo/internal/runtime.eface", align 8 %6 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %5, i32 0, i32 0 store ptr %4, ptr %6, align 8 @@ -41,7 +43,7 @@ _llgo_0: %8 = load %"github.com/goplus/llgo/internal/runtime.eface", ptr %5, align 8 store %"github.com/goplus/llgo/internal/runtime.eface" %8, ptr %3, align 8 %9 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %2, i64 1 - %10 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 2) + %10 = load ptr, ptr @_llgo_int, align 8 %11 = alloca %"github.com/goplus/llgo/internal/runtime.eface", align 8 %12 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %11, i32 0, i32 0 store ptr %10, ptr %12, align 8 @@ -50,7 +52,7 @@ _llgo_0: %14 = load %"github.com/goplus/llgo/internal/runtime.eface", ptr %11, align 8 store %"github.com/goplus/llgo/internal/runtime.eface" %14, ptr %9, align 8 %15 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %2, i64 2 - %16 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 2) + %16 = load ptr, ptr @_llgo_int, align 8 %17 = alloca %"github.com/goplus/llgo/internal/runtime.eface", align 8 %18 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %17, i32 0, i32 0 store ptr %16, ptr %18, align 8 @@ -88,7 +90,7 @@ _llgo_2: ; preds = %_llgo_1 %7 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %6, i64 %3 %8 = load %"github.com/goplus/llgo/internal/runtime.eface", ptr %7, align 8 %9 = extractvalue %"github.com/goplus/llgo/internal/runtime.eface" %8, 0 - %10 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 2) + %10 = load ptr, ptr @_llgo_int, align 8 %11 = icmp eq ptr %9, %10 br i1 %11, label %_llgo_4, label %_llgo_5 @@ -116,6 +118,21 @@ declare void @"github.com/goplus/llgo/internal/runtime.init"() declare ptr @"github.com/goplus/llgo/internal/runtime.AllocZ"(i64) +define void @"main.init$abi"() { +_llgo_0: + %0 = load ptr, ptr @_llgo_int, align 8 + %1 = icmp eq ptr %0, null + br i1 %1, label %_llgo_1, label %_llgo_2 + +_llgo_1: ; preds = %_llgo_0 + %2 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 2) + store ptr %2, ptr @_llgo_int, align 8 + br label %_llgo_2 + +_llgo_2: ; preds = %_llgo_1, %_llgo_0 + ret void +} + declare ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64) declare void @"github.com/goplus/llgo/internal/runtime.AssertIndexRange"(i1) diff --git a/cl/_testgo/eface/in.go b/cl/_testgo/eface/in.go index 4f13ae5be..8b04a217a 100644 --- a/cl/_testgo/eface/in.go +++ b/cl/_testgo/eface/in.go @@ -45,8 +45,5 @@ func dump(v any) { func dumpTyp(t *abi.Type, sep string) { print(sep) - println(t.Kind(), t.Size_, t.PtrBytes, t.Hash, t.TFlag, t.Align_, t.Str_, t.PtrToThis_) - if t.Elem() != nil { - dumpTyp(t.Elem(), sep+"\t") - } + println(t.Kind(), t.Size_, t.PtrBytes, t.Hash, t.TFlag, t.Align_) } diff --git a/cl/_testgo/eface/out.ll b/cl/_testgo/eface/out.ll index ff8f5bc4a..e65c1abbc 100644 --- a/cl/_testgo/eface/out.ll +++ b/cl/_testgo/eface/out.ll @@ -10,22 +10,36 @@ source_filename = "main" @"main.init$guard" = global ptr null @0 = private unnamed_addr constant [1 x i8] zeroinitializer, align 1 -@1 = private unnamed_addr constant [2 x i8] c"\09\00", align 1 @__llgo_argc = global ptr null @__llgo_argv = global ptr null +@_llgo_bool = linkonce global ptr null +@_llgo_int = linkonce global ptr null +@_llgo_int8 = linkonce global ptr null +@_llgo_int16 = linkonce global ptr null +@_llgo_int32 = linkonce global ptr null +@_llgo_int64 = linkonce global ptr null +@_llgo_uint = linkonce global ptr null +@_llgo_uint8 = linkonce global ptr null +@_llgo_uint16 = linkonce global ptr null +@_llgo_uint32 = linkonce global ptr null +@_llgo_uint64 = linkonce global ptr null +@_llgo_uintptr = linkonce global ptr null +@_llgo_float32 = linkonce global ptr null +@_llgo_float64 = linkonce global ptr null @"[10]_llgo_int" = linkonce global ptr null @"_llgo_func$2_iS07vIlF2_rZqWB5eU0IvP_9HviM4MYZNkXZDvbac" = linkonce global ptr null @"*_llgo_int" = linkonce global ptr null @"[]_llgo_int" = linkonce global ptr null -@2 = private unnamed_addr constant [6 x i8] c"hello\00", align 1 +@1 = private unnamed_addr constant [6 x i8] c"hello\00", align 1 +@_llgo_string = linkonce global ptr null @"main.struct$RKbUG45GE4henGMAdmt0Rju0JptyR8NsX7IZLsOI0OM" = global ptr null -@3 = private unnamed_addr constant [2 x i8] c"x\00", align 1 -@4 = private unnamed_addr constant [1 x i8] zeroinitializer, align 1 -@5 = private unnamed_addr constant [2 x i8] c"y\00", align 1 -@6 = private unnamed_addr constant [1 x i8] zeroinitializer, align 1 -@7 = private unnamed_addr constant [2 x i8] c"z\00", align 1 -@8 = private unnamed_addr constant [1 x i8] zeroinitializer, align 1 -@9 = private unnamed_addr constant [5 x i8] c"main\00", align 1 +@2 = private unnamed_addr constant [2 x i8] c"x\00", align 1 +@3 = private unnamed_addr constant [1 x i8] zeroinitializer, align 1 +@4 = private unnamed_addr constant [2 x i8] c"y\00", align 1 +@5 = private unnamed_addr constant [1 x i8] zeroinitializer, align 1 +@6 = private unnamed_addr constant [2 x i8] c"z\00", align 1 +@7 = private unnamed_addr constant [1 x i8] zeroinitializer, align 1 +@8 = private unnamed_addr constant [5 x i8] c"main\00", align 1 define void @main.dump(%"github.com/goplus/llgo/internal/runtime.eface" %0) { _llgo_0: @@ -57,46 +71,21 @@ _llgo_0: %10 = load i8, ptr %9, align 1 %11 = getelementptr inbounds %"github.com/goplus/llgo/internal/abi.Type", ptr %0, i32 0, i32 4 %12 = load i8, ptr %11, align 1 - %13 = getelementptr inbounds %"github.com/goplus/llgo/internal/abi.Type", ptr %0, i32 0, i32 9 - %14 = load %"github.com/goplus/llgo/internal/runtime.String", ptr %13, align 8 - %15 = getelementptr inbounds %"github.com/goplus/llgo/internal/abi.Type", ptr %0, i32 0, i32 10 - %16 = load ptr, ptr %15, align 8 call void @"github.com/goplus/llgo/internal/runtime.PrintUint"(i64 %2) call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 32) call void @"github.com/goplus/llgo/internal/runtime.PrintUint"(i64 %4) call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 32) call void @"github.com/goplus/llgo/internal/runtime.PrintUint"(i64 %6) call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 32) - %17 = zext i32 %8 to i64 - call void @"github.com/goplus/llgo/internal/runtime.PrintUint"(i64 %17) + %13 = zext i32 %8 to i64 + call void @"github.com/goplus/llgo/internal/runtime.PrintUint"(i64 %13) call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 32) - %18 = zext i8 %10 to i64 - call void @"github.com/goplus/llgo/internal/runtime.PrintUint"(i64 %18) + %14 = zext i8 %10 to i64 + call void @"github.com/goplus/llgo/internal/runtime.PrintUint"(i64 %14) call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 32) - %19 = zext i8 %12 to i64 - call void @"github.com/goplus/llgo/internal/runtime.PrintUint"(i64 %19) - call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 32) - call void @"github.com/goplus/llgo/internal/runtime.PrintString"(%"github.com/goplus/llgo/internal/runtime.String" %14) - call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 32) - call void @"github.com/goplus/llgo/internal/runtime.PrintPointer"(ptr %16) + %15 = zext i8 %12 to i64 + call void @"github.com/goplus/llgo/internal/runtime.PrintUint"(i64 %15) call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 10) - %20 = call ptr @"(*github.com/goplus/llgo/internal/abi.Type).Elem"(ptr %0) - %21 = icmp ne ptr %20, null - br i1 %21, label %_llgo_1, label %_llgo_2 - -_llgo_1: ; preds = %_llgo_0 - %22 = call ptr @"(*github.com/goplus/llgo/internal/abi.Type).Elem"(ptr %0) - %23 = alloca %"github.com/goplus/llgo/internal/runtime.String", align 8 - %24 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %23, i32 0, i32 0 - store ptr @1, ptr %24, align 8 - %25 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %23, i32 0, i32 1 - store i64 1, ptr %25, align 4 - %26 = load %"github.com/goplus/llgo/internal/runtime.String", ptr %23, align 8 - %27 = 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" %26) - call void @main.dumpTyp(ptr %22, %"github.com/goplus/llgo/internal/runtime.String" %27) - br label %_llgo_2 - -_llgo_2: ; preds = %_llgo_1, %_llgo_0 ret void } @@ -121,7 +110,7 @@ _llgo_0: 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.Basic"(i64 1) + %2 = load ptr, ptr @_llgo_bool, align 8 %3 = alloca %"github.com/goplus/llgo/internal/runtime.eface", align 8 %4 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %3, i32 0, i32 0 store ptr %2, ptr %4, align 8 @@ -129,7 +118,7 @@ _llgo_0: store ptr inttoptr (i64 -1 to ptr), ptr %5, align 8 %6 = load %"github.com/goplus/llgo/internal/runtime.eface", ptr %3, align 8 call void @main.dump(%"github.com/goplus/llgo/internal/runtime.eface" %6) - %7 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 2) + %7 = load ptr, ptr @_llgo_int, align 8 %8 = alloca %"github.com/goplus/llgo/internal/runtime.eface", align 8 %9 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %8, i32 0, i32 0 store ptr %7, ptr %9, align 8 @@ -137,7 +126,7 @@ _llgo_0: store ptr null, ptr %10, align 8 %11 = load %"github.com/goplus/llgo/internal/runtime.eface", ptr %8, align 8 call void @main.dump(%"github.com/goplus/llgo/internal/runtime.eface" %11) - %12 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 3) + %12 = load ptr, ptr @_llgo_int8, align 8 %13 = alloca %"github.com/goplus/llgo/internal/runtime.eface", align 8 %14 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %13, i32 0, i32 0 store ptr %12, ptr %14, align 8 @@ -145,7 +134,7 @@ _llgo_0: store ptr null, ptr %15, align 8 %16 = load %"github.com/goplus/llgo/internal/runtime.eface", ptr %13, align 8 call void @main.dump(%"github.com/goplus/llgo/internal/runtime.eface" %16) - %17 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 4) + %17 = load ptr, ptr @_llgo_int16, align 8 %18 = alloca %"github.com/goplus/llgo/internal/runtime.eface", align 8 %19 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %18, i32 0, i32 0 store ptr %17, ptr %19, align 8 @@ -153,7 +142,7 @@ _llgo_0: store ptr null, ptr %20, align 8 %21 = load %"github.com/goplus/llgo/internal/runtime.eface", ptr %18, align 8 call void @main.dump(%"github.com/goplus/llgo/internal/runtime.eface" %21) - %22 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 5) + %22 = load ptr, ptr @_llgo_int32, align 8 %23 = alloca %"github.com/goplus/llgo/internal/runtime.eface", align 8 %24 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %23, i32 0, i32 0 store ptr %22, ptr %24, align 8 @@ -161,7 +150,7 @@ _llgo_0: store ptr null, ptr %25, align 8 %26 = load %"github.com/goplus/llgo/internal/runtime.eface", ptr %23, align 8 call void @main.dump(%"github.com/goplus/llgo/internal/runtime.eface" %26) - %27 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 6) + %27 = load ptr, ptr @_llgo_int64, align 8 %28 = alloca %"github.com/goplus/llgo/internal/runtime.eface", align 8 %29 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %28, i32 0, i32 0 store ptr %27, ptr %29, align 8 @@ -169,7 +158,7 @@ _llgo_0: store ptr null, ptr %30, align 8 %31 = load %"github.com/goplus/llgo/internal/runtime.eface", ptr %28, align 8 call void @main.dump(%"github.com/goplus/llgo/internal/runtime.eface" %31) - %32 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 7) + %32 = load ptr, ptr @_llgo_uint, align 8 %33 = alloca %"github.com/goplus/llgo/internal/runtime.eface", align 8 %34 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %33, i32 0, i32 0 store ptr %32, ptr %34, align 8 @@ -177,7 +166,7 @@ _llgo_0: store ptr null, ptr %35, align 8 %36 = load %"github.com/goplus/llgo/internal/runtime.eface", ptr %33, align 8 call void @main.dump(%"github.com/goplus/llgo/internal/runtime.eface" %36) - %37 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 8) + %37 = load ptr, ptr @_llgo_uint8, align 8 %38 = alloca %"github.com/goplus/llgo/internal/runtime.eface", align 8 %39 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %38, i32 0, i32 0 store ptr %37, ptr %39, align 8 @@ -185,7 +174,7 @@ _llgo_0: store ptr null, ptr %40, align 8 %41 = load %"github.com/goplus/llgo/internal/runtime.eface", ptr %38, align 8 call void @main.dump(%"github.com/goplus/llgo/internal/runtime.eface" %41) - %42 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 9) + %42 = load ptr, ptr @_llgo_uint16, align 8 %43 = alloca %"github.com/goplus/llgo/internal/runtime.eface", align 8 %44 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %43, i32 0, i32 0 store ptr %42, ptr %44, align 8 @@ -193,7 +182,7 @@ _llgo_0: store ptr null, ptr %45, align 8 %46 = load %"github.com/goplus/llgo/internal/runtime.eface", ptr %43, align 8 call void @main.dump(%"github.com/goplus/llgo/internal/runtime.eface" %46) - %47 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 10) + %47 = load ptr, ptr @_llgo_uint32, align 8 %48 = alloca %"github.com/goplus/llgo/internal/runtime.eface", align 8 %49 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %48, i32 0, i32 0 store ptr %47, ptr %49, align 8 @@ -201,7 +190,7 @@ _llgo_0: store ptr null, ptr %50, align 8 %51 = load %"github.com/goplus/llgo/internal/runtime.eface", ptr %48, align 8 call void @main.dump(%"github.com/goplus/llgo/internal/runtime.eface" %51) - %52 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 11) + %52 = load ptr, ptr @_llgo_uint64, align 8 %53 = alloca %"github.com/goplus/llgo/internal/runtime.eface", align 8 %54 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %53, i32 0, i32 0 store ptr %52, ptr %54, align 8 @@ -209,7 +198,7 @@ _llgo_0: store ptr null, ptr %55, align 8 %56 = load %"github.com/goplus/llgo/internal/runtime.eface", ptr %53, align 8 call void @main.dump(%"github.com/goplus/llgo/internal/runtime.eface" %56) - %57 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 12) + %57 = load ptr, ptr @_llgo_uintptr, align 8 %58 = alloca %"github.com/goplus/llgo/internal/runtime.eface", align 8 %59 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %58, i32 0, i32 0 store ptr %57, ptr %59, align 8 @@ -217,7 +206,7 @@ _llgo_0: store ptr null, ptr %60, align 8 %61 = load %"github.com/goplus/llgo/internal/runtime.eface", ptr %58, align 8 call void @main.dump(%"github.com/goplus/llgo/internal/runtime.eface" %61) - %62 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 13) + %62 = load ptr, ptr @_llgo_float32, align 8 %63 = alloca %"github.com/goplus/llgo/internal/runtime.eface", align 8 %64 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %63, i32 0, i32 0 store ptr %62, ptr %64, align 8 @@ -225,7 +214,7 @@ _llgo_0: store ptr null, ptr %65, align 8 %66 = load %"github.com/goplus/llgo/internal/runtime.eface", ptr %63, align 8 call void @main.dump(%"github.com/goplus/llgo/internal/runtime.eface" %66) - %67 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 14) + %67 = load ptr, ptr @_llgo_float64, align 8 %68 = alloca %"github.com/goplus/llgo/internal/runtime.eface", align 8 %69 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %68, i32 0, i32 0 store ptr %67, ptr %69, align 8 @@ -280,11 +269,11 @@ _llgo_0: call void @main.dump(%"github.com/goplus/llgo/internal/runtime.eface" %99) %100 = alloca %"github.com/goplus/llgo/internal/runtime.String", align 8 %101 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %100, i32 0, i32 0 - store ptr @2, ptr %101, align 8 + store ptr @1, ptr %101, align 8 %102 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %100, i32 0, i32 1 store i64 5, ptr %102, align 4 %103 = load %"github.com/goplus/llgo/internal/runtime.String", ptr %100, align 8 - %104 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 24) + %104 = load ptr, ptr @_llgo_string, align 8 %105 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 16) store %"github.com/goplus/llgo/internal/runtime.String" %103, ptr %105, align 8 %106 = alloca %"github.com/goplus/llgo/internal/runtime.eface", align 8 @@ -317,158 +306,302 @@ declare void @"github.com/goplus/llgo/internal/runtime.PrintUint"(i64) declare void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8) -declare void @"github.com/goplus/llgo/internal/runtime.PrintPointer"(ptr) - -declare ptr @"(*github.com/goplus/llgo/internal/abi.Type).Elem"(ptr) - -declare %"github.com/goplus/llgo/internal/runtime.String" @"github.com/goplus/llgo/internal/runtime.StringCat"(%"github.com/goplus/llgo/internal/runtime.String", %"github.com/goplus/llgo/internal/runtime.String") - declare void @"github.com/goplus/llgo/internal/abi.init"() declare void @"github.com/goplus/llgo/internal/runtime.init"() -declare ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64) - -declare ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64) - -define void @"main.main$1"() { -_llgo_0: - ret void -} - define void @"main.init$abi"() { _llgo_0: - %0 = load ptr, ptr @"[10]_llgo_int", align 8 + %0 = load ptr, ptr @_llgo_bool, align 8 %1 = icmp eq ptr %0, null br i1 %1, label %_llgo_1, label %_llgo_2 _llgo_1: ; preds = %_llgo_0 - %2 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 2) - %3 = call ptr @"github.com/goplus/llgo/internal/runtime.ArrayOf"(i64 10, ptr %2) - store ptr %3, ptr @"[10]_llgo_int", align 8 + %2 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 1) + store ptr %2, ptr @_llgo_bool, align 8 br label %_llgo_2 _llgo_2: ; preds = %_llgo_1, %_llgo_0 - %4 = load ptr, ptr @"_llgo_func$2_iS07vIlF2_rZqWB5eU0IvP_9HviM4MYZNkXZDvbac", align 8 - %5 = icmp eq ptr %4, null - br i1 %5, label %_llgo_3, label %_llgo_4 + %3 = load ptr, ptr @_llgo_int, align 8 + %4 = icmp eq ptr %3, null + br i1 %4, label %_llgo_3, label %_llgo_4 _llgo_3: ; preds = %_llgo_2 - %6 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 0) - %7 = alloca %"github.com/goplus/llgo/internal/runtime.Slice", align 8 - %8 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.Slice", ptr %7, i32 0, i32 0 - store ptr %6, ptr %8, align 8 - %9 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.Slice", ptr %7, i32 0, i32 1 - store i64 0, ptr %9, align 4 - %10 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.Slice", ptr %7, i32 0, i32 2 - store i64 0, ptr %10, align 4 - %11 = load %"github.com/goplus/llgo/internal/runtime.Slice", ptr %7, align 8 - %12 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 0) - %13 = alloca %"github.com/goplus/llgo/internal/runtime.Slice", align 8 - %14 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.Slice", ptr %13, i32 0, i32 0 - store ptr %12, ptr %14, align 8 - %15 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.Slice", ptr %13, i32 0, i32 1 - store i64 0, ptr %15, align 4 - %16 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.Slice", ptr %13, i32 0, i32 2 - store i64 0, ptr %16, align 4 - %17 = load %"github.com/goplus/llgo/internal/runtime.Slice", ptr %13, align 8 - %18 = call ptr @"github.com/goplus/llgo/internal/runtime.Func"(%"github.com/goplus/llgo/internal/runtime.Slice" %11, %"github.com/goplus/llgo/internal/runtime.Slice" %17, i1 false) - store ptr %18, ptr @"_llgo_func$2_iS07vIlF2_rZqWB5eU0IvP_9HviM4MYZNkXZDvbac", align 8 + %5 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 2) + store ptr %5, ptr @_llgo_int, align 8 br label %_llgo_4 _llgo_4: ; preds = %_llgo_3, %_llgo_2 - %19 = load ptr, ptr @"*_llgo_int", align 8 - %20 = icmp eq ptr %19, null - br i1 %20, label %_llgo_5, label %_llgo_6 + %6 = load ptr, ptr @_llgo_int8, align 8 + %7 = icmp eq ptr %6, null + br i1 %7, label %_llgo_5, label %_llgo_6 _llgo_5: ; preds = %_llgo_4 - %21 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 2) - %22 = call ptr @"github.com/goplus/llgo/internal/runtime.PointerTo"(ptr %21) - store ptr %22, ptr @"*_llgo_int", align 8 + %8 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 3) + store ptr %8, ptr @_llgo_int8, align 8 br label %_llgo_6 _llgo_6: ; preds = %_llgo_5, %_llgo_4 - %23 = load ptr, ptr @"[]_llgo_int", align 8 - %24 = icmp eq ptr %23, null - br i1 %24, label %_llgo_7, label %_llgo_8 + %9 = load ptr, ptr @_llgo_int16, align 8 + %10 = icmp eq ptr %9, null + br i1 %10, label %_llgo_7, label %_llgo_8 _llgo_7: ; preds = %_llgo_6 - %25 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 2) - %26 = call ptr @"github.com/goplus/llgo/internal/runtime.SliceOf"(ptr %25) - store ptr %26, ptr @"[]_llgo_int", align 8 + %11 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 4) + store ptr %11, ptr @_llgo_int16, align 8 br label %_llgo_8 _llgo_8: ; preds = %_llgo_7, %_llgo_6 - %27 = alloca %"github.com/goplus/llgo/internal/runtime.String", align 8 - %28 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %27, i32 0, i32 0 - store ptr @3, ptr %28, align 8 - %29 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %27, i32 0, i32 1 - store i64 1, ptr %29, align 4 - %30 = load %"github.com/goplus/llgo/internal/runtime.String", ptr %27, align 8 - %31 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 3) - %32 = alloca %"github.com/goplus/llgo/internal/runtime.String", align 8 - %33 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %32, i32 0, i32 0 - store ptr @4, ptr %33, align 8 - %34 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %32, i32 0, i32 1 - store i64 0, ptr %34, align 4 - %35 = load %"github.com/goplus/llgo/internal/runtime.String", ptr %32, align 8 - %36 = call %"github.com/goplus/llgo/internal/abi.StructField" @"github.com/goplus/llgo/internal/runtime.StructField"(%"github.com/goplus/llgo/internal/runtime.String" %30, ptr %31, i64 0, %"github.com/goplus/llgo/internal/runtime.String" %35, i1 false) - %37 = alloca %"github.com/goplus/llgo/internal/runtime.String", align 8 - %38 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %37, i32 0, i32 0 - store ptr @5, ptr %38, align 8 - %39 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %37, i32 0, i32 1 - store i64 1, ptr %39, align 4 - %40 = load %"github.com/goplus/llgo/internal/runtime.String", ptr %37, align 8 - %41 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 2) - %42 = alloca %"github.com/goplus/llgo/internal/runtime.String", align 8 - %43 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %42, i32 0, i32 0 - store ptr @6, ptr %43, align 8 - %44 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %42, i32 0, i32 1 - store i64 0, ptr %44, align 4 - %45 = load %"github.com/goplus/llgo/internal/runtime.String", ptr %42, align 8 - %46 = call %"github.com/goplus/llgo/internal/abi.StructField" @"github.com/goplus/llgo/internal/runtime.StructField"(%"github.com/goplus/llgo/internal/runtime.String" %40, ptr %41, i64 8, %"github.com/goplus/llgo/internal/runtime.String" %45, i1 false) - %47 = alloca %"github.com/goplus/llgo/internal/runtime.String", align 8 - %48 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %47, i32 0, i32 0 - store ptr @7, ptr %48, align 8 - %49 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %47, i32 0, i32 1 - store i64 1, ptr %49, align 4 - %50 = load %"github.com/goplus/llgo/internal/runtime.String", ptr %47, align 8 - %51 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 2) - %52 = alloca %"github.com/goplus/llgo/internal/runtime.String", align 8 - %53 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %52, i32 0, i32 0 - store ptr @8, ptr %53, align 8 - %54 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %52, i32 0, i32 1 - store i64 0, ptr %54, align 4 - %55 = load %"github.com/goplus/llgo/internal/runtime.String", ptr %52, align 8 - %56 = call %"github.com/goplus/llgo/internal/abi.StructField" @"github.com/goplus/llgo/internal/runtime.StructField"(%"github.com/goplus/llgo/internal/runtime.String" %50, ptr %51, i64 16, %"github.com/goplus/llgo/internal/runtime.String" %55, i1 false) - %57 = alloca %"github.com/goplus/llgo/internal/runtime.String", align 8 - %58 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %57, i32 0, i32 0 - store ptr @9, ptr %58, align 8 - %59 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %57, i32 0, i32 1 - store i64 4, ptr %59, align 4 - %60 = load %"github.com/goplus/llgo/internal/runtime.String", ptr %57, align 8 - %61 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 168) - %62 = getelementptr %"github.com/goplus/llgo/internal/abi.StructField", ptr %61, i64 0 - store %"github.com/goplus/llgo/internal/abi.StructField" %36, ptr %62, align 8 - %63 = getelementptr %"github.com/goplus/llgo/internal/abi.StructField", ptr %61, i64 1 - store %"github.com/goplus/llgo/internal/abi.StructField" %46, ptr %63, align 8 - %64 = getelementptr %"github.com/goplus/llgo/internal/abi.StructField", ptr %61, i64 2 - store %"github.com/goplus/llgo/internal/abi.StructField" %56, ptr %64, align 8 - %65 = alloca %"github.com/goplus/llgo/internal/runtime.Slice", align 8 - %66 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.Slice", ptr %65, i32 0, i32 0 - store ptr %61, ptr %66, align 8 - %67 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.Slice", ptr %65, i32 0, i32 1 - store i64 3, ptr %67, align 4 - %68 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.Slice", ptr %65, i32 0, i32 2 - store i64 3, ptr %68, align 4 - %69 = load %"github.com/goplus/llgo/internal/runtime.Slice", ptr %65, align 8 - %70 = call ptr @"github.com/goplus/llgo/internal/runtime.Struct"(%"github.com/goplus/llgo/internal/runtime.String" %60, i64 24, %"github.com/goplus/llgo/internal/runtime.Slice" %69) - store ptr %70, ptr @"main.struct$RKbUG45GE4henGMAdmt0Rju0JptyR8NsX7IZLsOI0OM", align 8 + %12 = load ptr, ptr @_llgo_int32, align 8 + %13 = icmp eq ptr %12, null + br i1 %13, label %_llgo_9, label %_llgo_10 + +_llgo_9: ; preds = %_llgo_8 + %14 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 5) + store ptr %14, ptr @_llgo_int32, align 8 + br label %_llgo_10 + +_llgo_10: ; preds = %_llgo_9, %_llgo_8 + %15 = load ptr, ptr @_llgo_int64, align 8 + %16 = icmp eq ptr %15, null + br i1 %16, label %_llgo_11, label %_llgo_12 + +_llgo_11: ; preds = %_llgo_10 + %17 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 6) + store ptr %17, ptr @_llgo_int64, align 8 + br label %_llgo_12 + +_llgo_12: ; preds = %_llgo_11, %_llgo_10 + %18 = load ptr, ptr @_llgo_uint, align 8 + %19 = icmp eq ptr %18, null + br i1 %19, label %_llgo_13, label %_llgo_14 + +_llgo_13: ; preds = %_llgo_12 + %20 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 7) + store ptr %20, ptr @_llgo_uint, align 8 + br label %_llgo_14 + +_llgo_14: ; preds = %_llgo_13, %_llgo_12 + %21 = load ptr, ptr @_llgo_uint8, align 8 + %22 = icmp eq ptr %21, null + br i1 %22, label %_llgo_15, label %_llgo_16 + +_llgo_15: ; preds = %_llgo_14 + %23 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 8) + store ptr %23, ptr @_llgo_uint8, align 8 + br label %_llgo_16 + +_llgo_16: ; preds = %_llgo_15, %_llgo_14 + %24 = load ptr, ptr @_llgo_uint16, align 8 + %25 = icmp eq ptr %24, null + br i1 %25, label %_llgo_17, label %_llgo_18 + +_llgo_17: ; preds = %_llgo_16 + %26 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 9) + store ptr %26, ptr @_llgo_uint16, align 8 + br label %_llgo_18 + +_llgo_18: ; preds = %_llgo_17, %_llgo_16 + %27 = load ptr, ptr @_llgo_uint32, align 8 + %28 = icmp eq ptr %27, null + br i1 %28, label %_llgo_19, label %_llgo_20 + +_llgo_19: ; preds = %_llgo_18 + %29 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 10) + store ptr %29, ptr @_llgo_uint32, align 8 + br label %_llgo_20 + +_llgo_20: ; preds = %_llgo_19, %_llgo_18 + %30 = load ptr, ptr @_llgo_uint64, align 8 + %31 = icmp eq ptr %30, null + br i1 %31, label %_llgo_21, label %_llgo_22 + +_llgo_21: ; preds = %_llgo_20 + %32 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 11) + store ptr %32, ptr @_llgo_uint64, align 8 + br label %_llgo_22 + +_llgo_22: ; preds = %_llgo_21, %_llgo_20 + %33 = load ptr, ptr @_llgo_uintptr, align 8 + %34 = icmp eq ptr %33, null + br i1 %34, label %_llgo_23, label %_llgo_24 + +_llgo_23: ; preds = %_llgo_22 + %35 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 12) + store ptr %35, ptr @_llgo_uintptr, align 8 + br label %_llgo_24 + +_llgo_24: ; preds = %_llgo_23, %_llgo_22 + %36 = load ptr, ptr @_llgo_float32, align 8 + %37 = icmp eq ptr %36, null + br i1 %37, label %_llgo_25, label %_llgo_26 + +_llgo_25: ; preds = %_llgo_24 + %38 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 13) + store ptr %38, ptr @_llgo_float32, align 8 + br label %_llgo_26 + +_llgo_26: ; preds = %_llgo_25, %_llgo_24 + %39 = load ptr, ptr @_llgo_float64, align 8 + %40 = icmp eq ptr %39, null + br i1 %40, label %_llgo_27, label %_llgo_28 + +_llgo_27: ; preds = %_llgo_26 + %41 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 14) + store ptr %41, ptr @_llgo_float64, align 8 + br label %_llgo_28 + +_llgo_28: ; preds = %_llgo_27, %_llgo_26 + %42 = load ptr, ptr @_llgo_int, align 8 + %43 = load ptr, ptr @"[10]_llgo_int", align 8 + %44 = icmp eq ptr %43, null + br i1 %44, label %_llgo_29, label %_llgo_30 + +_llgo_29: ; preds = %_llgo_28 + %45 = call ptr @"github.com/goplus/llgo/internal/runtime.ArrayOf"(i64 10, ptr %42) + store ptr %45, ptr @"[10]_llgo_int", align 8 + br label %_llgo_30 + +_llgo_30: ; preds = %_llgo_29, %_llgo_28 + %46 = load ptr, ptr @"_llgo_func$2_iS07vIlF2_rZqWB5eU0IvP_9HviM4MYZNkXZDvbac", align 8 + %47 = icmp eq ptr %46, null + br i1 %47, label %_llgo_31, label %_llgo_32 + +_llgo_31: ; preds = %_llgo_30 + %48 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 0) + %49 = alloca %"github.com/goplus/llgo/internal/runtime.Slice", align 8 + %50 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.Slice", ptr %49, i32 0, i32 0 + store ptr %48, ptr %50, align 8 + %51 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.Slice", ptr %49, i32 0, i32 1 + store i64 0, ptr %51, align 4 + %52 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.Slice", ptr %49, i32 0, i32 2 + store i64 0, ptr %52, align 4 + %53 = load %"github.com/goplus/llgo/internal/runtime.Slice", ptr %49, align 8 + %54 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 0) + %55 = alloca %"github.com/goplus/llgo/internal/runtime.Slice", align 8 + %56 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.Slice", ptr %55, i32 0, i32 0 + store ptr %54, ptr %56, align 8 + %57 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.Slice", ptr %55, i32 0, i32 1 + store i64 0, ptr %57, align 4 + %58 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.Slice", ptr %55, i32 0, i32 2 + store i64 0, ptr %58, align 4 + %59 = load %"github.com/goplus/llgo/internal/runtime.Slice", ptr %55, align 8 + %60 = call ptr @"github.com/goplus/llgo/internal/runtime.Func"(%"github.com/goplus/llgo/internal/runtime.Slice" %53, %"github.com/goplus/llgo/internal/runtime.Slice" %59, i1 false) + store ptr %60, ptr @"_llgo_func$2_iS07vIlF2_rZqWB5eU0IvP_9HviM4MYZNkXZDvbac", align 8 + br label %_llgo_32 + +_llgo_32: ; preds = %_llgo_31, %_llgo_30 + %61 = load ptr, ptr @_llgo_int, align 8 + %62 = load ptr, ptr @"*_llgo_int", align 8 + %63 = icmp eq ptr %62, null + br i1 %63, label %_llgo_33, label %_llgo_34 + +_llgo_33: ; preds = %_llgo_32 + %64 = call ptr @"github.com/goplus/llgo/internal/runtime.PointerTo"(ptr %61) + store ptr %64, ptr @"*_llgo_int", align 8 + br label %_llgo_34 + +_llgo_34: ; preds = %_llgo_33, %_llgo_32 + %65 = load ptr, ptr @_llgo_int, align 8 + %66 = load ptr, ptr @"[]_llgo_int", align 8 + %67 = icmp eq ptr %66, null + br i1 %67, label %_llgo_35, label %_llgo_36 + +_llgo_35: ; preds = %_llgo_34 + %68 = call ptr @"github.com/goplus/llgo/internal/runtime.SliceOf"(ptr %65) + store ptr %68, ptr @"[]_llgo_int", align 8 + br label %_llgo_36 + +_llgo_36: ; preds = %_llgo_35, %_llgo_34 + %69 = load ptr, ptr @_llgo_string, align 8 + %70 = icmp eq ptr %69, null + br i1 %70, label %_llgo_37, label %_llgo_38 + +_llgo_37: ; preds = %_llgo_36 + %71 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 24) + store ptr %71, ptr @_llgo_string, align 8 + br label %_llgo_38 + +_llgo_38: ; preds = %_llgo_37, %_llgo_36 + %72 = load ptr, ptr @_llgo_int8, align 8 + %73 = load ptr, ptr @_llgo_int, align 8 + %74 = load ptr, ptr @_llgo_int, align 8 + %75 = alloca %"github.com/goplus/llgo/internal/runtime.String", align 8 + %76 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %75, i32 0, i32 0 + store ptr @2, ptr %76, align 8 + %77 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %75, i32 0, i32 1 + store i64 1, ptr %77, align 4 + %78 = load %"github.com/goplus/llgo/internal/runtime.String", ptr %75, align 8 + %79 = alloca %"github.com/goplus/llgo/internal/runtime.String", align 8 + %80 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %79, i32 0, i32 0 + store ptr @3, ptr %80, align 8 + %81 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %79, i32 0, i32 1 + store i64 0, ptr %81, align 4 + %82 = load %"github.com/goplus/llgo/internal/runtime.String", ptr %79, align 8 + %83 = call %"github.com/goplus/llgo/internal/abi.StructField" @"github.com/goplus/llgo/internal/runtime.StructField"(%"github.com/goplus/llgo/internal/runtime.String" %78, ptr %72, i64 0, %"github.com/goplus/llgo/internal/runtime.String" %82, i1 false) + %84 = alloca %"github.com/goplus/llgo/internal/runtime.String", align 8 + %85 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %84, i32 0, i32 0 + store ptr @4, ptr %85, align 8 + %86 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %84, i32 0, i32 1 + store i64 1, ptr %86, align 4 + %87 = load %"github.com/goplus/llgo/internal/runtime.String", ptr %84, align 8 + %88 = alloca %"github.com/goplus/llgo/internal/runtime.String", align 8 + %89 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %88, i32 0, i32 0 + store ptr @5, ptr %89, align 8 + %90 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %88, i32 0, i32 1 + store i64 0, ptr %90, align 4 + %91 = load %"github.com/goplus/llgo/internal/runtime.String", ptr %88, align 8 + %92 = call %"github.com/goplus/llgo/internal/abi.StructField" @"github.com/goplus/llgo/internal/runtime.StructField"(%"github.com/goplus/llgo/internal/runtime.String" %87, ptr %73, i64 8, %"github.com/goplus/llgo/internal/runtime.String" %91, i1 false) + %93 = alloca %"github.com/goplus/llgo/internal/runtime.String", align 8 + %94 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %93, i32 0, i32 0 + store ptr @6, ptr %94, align 8 + %95 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %93, i32 0, i32 1 + store i64 1, ptr %95, align 4 + %96 = load %"github.com/goplus/llgo/internal/runtime.String", ptr %93, align 8 + %97 = alloca %"github.com/goplus/llgo/internal/runtime.String", align 8 + %98 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %97, i32 0, i32 0 + store ptr @7, ptr %98, align 8 + %99 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %97, i32 0, i32 1 + store i64 0, ptr %99, align 4 + %100 = load %"github.com/goplus/llgo/internal/runtime.String", ptr %97, align 8 + %101 = call %"github.com/goplus/llgo/internal/abi.StructField" @"github.com/goplus/llgo/internal/runtime.StructField"(%"github.com/goplus/llgo/internal/runtime.String" %96, ptr %74, i64 16, %"github.com/goplus/llgo/internal/runtime.String" %100, i1 false) + %102 = alloca %"github.com/goplus/llgo/internal/runtime.String", align 8 + %103 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %102, i32 0, i32 0 + store ptr @8, ptr %103, align 8 + %104 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %102, i32 0, i32 1 + store i64 4, ptr %104, align 4 + %105 = load %"github.com/goplus/llgo/internal/runtime.String", ptr %102, align 8 + %106 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 168) + %107 = getelementptr %"github.com/goplus/llgo/internal/abi.StructField", ptr %106, i64 0 + store %"github.com/goplus/llgo/internal/abi.StructField" %83, ptr %107, align 8 + %108 = getelementptr %"github.com/goplus/llgo/internal/abi.StructField", ptr %106, i64 1 + store %"github.com/goplus/llgo/internal/abi.StructField" %92, ptr %108, align 8 + %109 = getelementptr %"github.com/goplus/llgo/internal/abi.StructField", ptr %106, i64 2 + store %"github.com/goplus/llgo/internal/abi.StructField" %101, ptr %109, align 8 + %110 = alloca %"github.com/goplus/llgo/internal/runtime.Slice", align 8 + %111 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.Slice", ptr %110, i32 0, i32 0 + store ptr %106, ptr %111, align 8 + %112 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.Slice", ptr %110, i32 0, i32 1 + store i64 3, ptr %112, align 4 + %113 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.Slice", ptr %110, i32 0, i32 2 + store i64 3, ptr %113, align 4 + %114 = load %"github.com/goplus/llgo/internal/runtime.Slice", ptr %110, align 8 + %115 = call ptr @"github.com/goplus/llgo/internal/runtime.Struct"(%"github.com/goplus/llgo/internal/runtime.String" %105, i64 24, %"github.com/goplus/llgo/internal/runtime.Slice" %114) + store ptr %115, ptr @"main.struct$RKbUG45GE4henGMAdmt0Rju0JptyR8NsX7IZLsOI0OM", align 8 ret void } +declare ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64) + declare ptr @"github.com/goplus/llgo/internal/runtime.ArrayOf"(i64, ptr) +declare ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64) + +define void @"main.main$1"() { +_llgo_0: + ret void +} + declare ptr @"github.com/goplus/llgo/internal/runtime.Func"(%"github.com/goplus/llgo/internal/runtime.Slice", %"github.com/goplus/llgo/internal/runtime.Slice", i1) declare ptr @"github.com/goplus/llgo/internal/runtime.PointerTo"(ptr) diff --git a/cl/_testgo/errors/out.ll b/cl/_testgo/errors/out.ll index 930efb985..f544af601 100644 --- a/cl/_testgo/errors/out.ll +++ b/cl/_testgo/errors/out.ll @@ -4,29 +4,30 @@ source_filename = "main" %"github.com/goplus/llgo/internal/runtime.iface" = type { ptr, ptr } %"github.com/goplus/llgo/internal/runtime.String" = type { ptr, i64 } %main.errorString = type { %"github.com/goplus/llgo/internal/runtime.String" } -%"github.com/goplus/llgo/internal/abi.Imethod" = type { %"github.com/goplus/llgo/internal/runtime.String", ptr } +%"github.com/goplus/llgo/internal/abi.StructField" = type { %"github.com/goplus/llgo/internal/runtime.String", ptr, i64, %"github.com/goplus/llgo/internal/runtime.String", i1 } %"github.com/goplus/llgo/internal/runtime.Slice" = type { ptr, i64, i64 } %"github.com/goplus/llgo/internal/abi.Method" = type { %"github.com/goplus/llgo/internal/runtime.String", ptr, ptr, ptr } -%"github.com/goplus/llgo/internal/abi.StructField" = type { %"github.com/goplus/llgo/internal/runtime.String", ptr, i64, %"github.com/goplus/llgo/internal/runtime.String", i1 } +%"github.com/goplus/llgo/internal/abi.Imethod" = type { %"github.com/goplus/llgo/internal/runtime.String", ptr } @"main.init$guard" = global ptr null @"*_llgo_main.errorString" = global ptr null -@"_llgo_iface$Fh8eUJ-Gw4e6TYuajcFIOSCuqSPKAt5nS4ow7xeGXEU" = linkonce global ptr null -@__llgo_argc = global ptr null -@__llgo_argv = global ptr null -@0 = private unnamed_addr constant [9 x i8] c"an error\00", align 1 @_llgo_main.errorString = global ptr null -@1 = private unnamed_addr constant [6 x i8] c"Error\00", align 1 -@"_llgo_func$zNDVRsWTIpUPKouNUS805RGX--IV9qVK8B31IZbg5to" = linkonce global ptr null -@2 = private unnamed_addr constant [5 x i8] c"main\00", align 1 @"main.struct$QTufDJA9wEDzuzgkA-ZSrLqW-B6lWN8O25mTSglAoLQ" = global ptr null +@_llgo_string = linkonce global ptr null +@0 = private unnamed_addr constant [2 x i8] c"s\00", align 1 +@1 = private unnamed_addr constant [1 x i8] zeroinitializer, align 1 +@2 = private unnamed_addr constant [5 x i8] c"main\00", align 1 @3 = private unnamed_addr constant [6 x i8] c"Error\00", align 1 -@"_llgo_func$8LHAAczeMU-_MsqDJ4-62jHfhzpiOiRnFkBoaL3mfxg" = linkonce global ptr null +@"_llgo_func$zNDVRsWTIpUPKouNUS805RGX--IV9qVK8B31IZbg5to" = linkonce global ptr null @4 = private unnamed_addr constant [5 x i8] c"main\00", align 1 @5 = private unnamed_addr constant [17 x i8] c"main.errorString\00", align 1 -@6 = private unnamed_addr constant [2 x i8] c"s\00", align 1 -@7 = private unnamed_addr constant [1 x i8] zeroinitializer, align 1 -@8 = private unnamed_addr constant [5 x i8] c"main\00", align 1 +@"_llgo_iface$Fh8eUJ-Gw4e6TYuajcFIOSCuqSPKAt5nS4ow7xeGXEU" = linkonce global ptr null +@6 = private unnamed_addr constant [6 x i8] c"Error\00", align 1 +@7 = private unnamed_addr constant [5 x i8] c"main\00", align 1 +@8 = private unnamed_addr constant [1 x i8] zeroinitializer, align 1 +@__llgo_argc = global ptr null +@__llgo_argv = global ptr null +@9 = private unnamed_addr constant [9 x i8] c"an error\00", align 1 define %"github.com/goplus/llgo/internal/runtime.iface" @main.New(%"github.com/goplus/llgo/internal/runtime.String" %0) { _llgo_0: @@ -74,7 +75,7 @@ _llgo_0: call void @main.init() %2 = alloca %"github.com/goplus/llgo/internal/runtime.String", align 8 %3 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %2, i32 0, i32 0 - store ptr @0, ptr %3, align 8 + store ptr @9, ptr %3, align 8 %4 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %2, i32 0, i32 1 store i64 8, ptr %4, align 4 %5 = load %"github.com/goplus/llgo/internal/runtime.String", ptr %2, align 8 @@ -101,229 +102,202 @@ _llgo_0: declare ptr @"github.com/goplus/llgo/internal/runtime.AllocZ"(i64) -declare ptr @"github.com/goplus/llgo/internal/runtime.NewItab"(ptr, ptr) - -declare void @"github.com/goplus/llgo/internal/runtime.init"() - -declare void @"github.com/goplus/llgo/internal/runtime.PrintIface"(%"github.com/goplus/llgo/internal/runtime.iface") - -declare void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8) - -declare void @"github.com/goplus/llgo/internal/runtime.PrintString"(%"github.com/goplus/llgo/internal/runtime.String") - define void @"main.init$abi"() { _llgo_0: - call void @"main.init$abi2"() - %0 = load ptr, ptr @_llgo_main.errorString, align 8 - %1 = call ptr @"github.com/goplus/llgo/internal/runtime.PointerTo"(ptr %0) - store ptr %1, ptr @"*_llgo_main.errorString", align 8 - %2 = load ptr, ptr @"_llgo_iface$Fh8eUJ-Gw4e6TYuajcFIOSCuqSPKAt5nS4ow7xeGXEU", align 8 - %3 = icmp eq ptr %2, null - br i1 %3, label %_llgo_1, label %_llgo_2 + %0 = call ptr @"github.com/goplus/llgo/internal/runtime.NewNamed"(i64 25, i64 0, i64 1) + store ptr %0, ptr @_llgo_main.errorString, align 8 + %1 = load ptr, ptr @_llgo_string, align 8 + %2 = icmp eq ptr %1, null + br i1 %2, label %_llgo_1, label %_llgo_2 _llgo_1: ; preds = %_llgo_0 - %4 = alloca %"github.com/goplus/llgo/internal/runtime.String", align 8 - %5 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %4, i32 0, i32 0 - store ptr @1, ptr %5, align 8 - %6 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %4, i32 0, i32 1 - store i64 5, ptr %6, align 4 - %7 = load %"github.com/goplus/llgo/internal/runtime.String", ptr %4, align 8 - %8 = load ptr, ptr @"_llgo_func$zNDVRsWTIpUPKouNUS805RGX--IV9qVK8B31IZbg5to", align 8 - %9 = alloca %"github.com/goplus/llgo/internal/abi.Imethod", align 8 - %10 = getelementptr inbounds %"github.com/goplus/llgo/internal/abi.Imethod", ptr %9, i32 0, i32 0 - store %"github.com/goplus/llgo/internal/runtime.String" %7, ptr %10, align 8 - %11 = getelementptr inbounds %"github.com/goplus/llgo/internal/abi.Imethod", ptr %9, i32 0, i32 1 - store ptr %8, ptr %11, align 8 - %12 = load %"github.com/goplus/llgo/internal/abi.Imethod", ptr %9, align 8 - %13 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 24) - %14 = getelementptr %"github.com/goplus/llgo/internal/abi.Imethod", ptr %13, i64 0 - store %"github.com/goplus/llgo/internal/abi.Imethod" %12, ptr %14, align 8 - %15 = alloca %"github.com/goplus/llgo/internal/runtime.Slice", align 8 - %16 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.Slice", ptr %15, i32 0, i32 0 - store ptr %13, ptr %16, align 8 - %17 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.Slice", ptr %15, i32 0, i32 1 - store i64 1, ptr %17, align 4 - %18 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.Slice", ptr %15, i32 0, i32 2 - store i64 1, ptr %18, align 4 - %19 = load %"github.com/goplus/llgo/internal/runtime.Slice", ptr %15, align 8 - %20 = alloca %"github.com/goplus/llgo/internal/runtime.String", align 8 - %21 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %20, i32 0, i32 0 - store ptr @2, ptr %21, align 8 - %22 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %20, i32 0, i32 1 - store i64 4, ptr %22, align 4 - %23 = load %"github.com/goplus/llgo/internal/runtime.String", ptr %20, align 8 - %24 = call ptr @"github.com/goplus/llgo/internal/runtime.Interface"(%"github.com/goplus/llgo/internal/runtime.String" %23, %"github.com/goplus/llgo/internal/runtime.Slice" %19) - store ptr %24, ptr @"_llgo_iface$Fh8eUJ-Gw4e6TYuajcFIOSCuqSPKAt5nS4ow7xeGXEU", align 8 + %3 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 24) + store ptr %3, ptr @_llgo_string, align 8 br label %_llgo_2 _llgo_2: ; preds = %_llgo_1, %_llgo_0 - ret void -} - -declare ptr @"github.com/goplus/llgo/internal/runtime.PointerTo"(ptr) - -declare ptr @"github.com/goplus/llgo/internal/runtime.Interface"(%"github.com/goplus/llgo/internal/runtime.String", %"github.com/goplus/llgo/internal/runtime.Slice") - -declare ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64) - -define void @"main.init$abi2"() { -_llgo_0: - call void @"main.init$abi3"() - %0 = load ptr, ptr @"main.struct$QTufDJA9wEDzuzgkA-ZSrLqW-B6lWN8O25mTSglAoLQ", align 8 - %1 = alloca %"github.com/goplus/llgo/internal/runtime.String", align 8 - %2 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %1, i32 0, i32 0 - store ptr @3, ptr %2, align 8 - %3 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %1, i32 0, i32 1 - store i64 5, ptr %3, align 4 - %4 = load %"github.com/goplus/llgo/internal/runtime.String", ptr %1, align 8 - %5 = load ptr, ptr @"_llgo_func$8LHAAczeMU-_MsqDJ4-62jHfhzpiOiRnFkBoaL3mfxg", align 8 - %6 = alloca %"github.com/goplus/llgo/internal/abi.Method", align 8 - %7 = getelementptr inbounds %"github.com/goplus/llgo/internal/abi.Method", ptr %6, i32 0, i32 0 - store %"github.com/goplus/llgo/internal/runtime.String" %4, ptr %7, align 8 - %8 = getelementptr inbounds %"github.com/goplus/llgo/internal/abi.Method", ptr %6, i32 0, i32 1 - store ptr %5, ptr %8, align 8 - %9 = getelementptr inbounds %"github.com/goplus/llgo/internal/abi.Method", ptr %6, i32 0, i32 2 - store ptr @"(*main.errorString).Error", ptr %9, align 8 - %10 = getelementptr inbounds %"github.com/goplus/llgo/internal/abi.Method", ptr %6, i32 0, i32 3 - store ptr @"(*main.errorString).Error", ptr %10, align 8 - %11 = load %"github.com/goplus/llgo/internal/abi.Method", ptr %6, align 8 - %12 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 40) - %13 = getelementptr %"github.com/goplus/llgo/internal/abi.Method", ptr %12, i64 0 - store %"github.com/goplus/llgo/internal/abi.Method" %11, ptr %13, align 8 - %14 = alloca %"github.com/goplus/llgo/internal/runtime.Slice", align 8 - %15 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.Slice", ptr %14, i32 0, i32 0 - store ptr %12, ptr %15, align 8 - %16 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.Slice", ptr %14, i32 0, i32 1 - store i64 1, ptr %16, align 4 - %17 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.Slice", ptr %14, i32 0, i32 2 - store i64 1, ptr %17, align 4 - %18 = load %"github.com/goplus/llgo/internal/runtime.Slice", ptr %14, align 8 - %19 = alloca %"github.com/goplus/llgo/internal/runtime.String", align 8 - %20 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %19, i32 0, i32 0 - store ptr @4, ptr %20, align 8 - %21 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %19, i32 0, i32 1 - store i64 4, ptr %21, align 4 - %22 = load %"github.com/goplus/llgo/internal/runtime.String", ptr %19, align 8 - %23 = alloca %"github.com/goplus/llgo/internal/runtime.String", align 8 - %24 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %23, i32 0, i32 0 - store ptr @5, ptr %24, align 8 - %25 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %23, i32 0, i32 1 - store i64 16, ptr %25, align 4 - %26 = load %"github.com/goplus/llgo/internal/runtime.String", ptr %23, align 8 - %27 = call ptr @"github.com/goplus/llgo/internal/runtime.Named"(%"github.com/goplus/llgo/internal/runtime.String" %22, %"github.com/goplus/llgo/internal/runtime.String" %26, ptr %0, %"github.com/goplus/llgo/internal/runtime.Slice" %18) - store ptr %27, ptr @_llgo_main.errorString, align 8 - %28 = load ptr, ptr @"_llgo_func$zNDVRsWTIpUPKouNUS805RGX--IV9qVK8B31IZbg5to", align 8 - %29 = icmp eq ptr %28, null - br i1 %29, label %_llgo_1, label %_llgo_2 - -_llgo_1: ; preds = %_llgo_0 - %30 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 0) - %31 = alloca %"github.com/goplus/llgo/internal/runtime.Slice", align 8 - %32 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.Slice", ptr %31, i32 0, i32 0 - store ptr %30, ptr %32, align 8 - %33 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.Slice", ptr %31, i32 0, i32 1 - store i64 0, ptr %33, align 4 - %34 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.Slice", ptr %31, i32 0, i32 2 - store i64 0, ptr %34, align 4 - %35 = load %"github.com/goplus/llgo/internal/runtime.Slice", ptr %31, align 8 - %36 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 24) - %37 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 8) - %38 = getelementptr ptr, ptr %37, i64 0 - store ptr %36, ptr %38, align 8 - %39 = alloca %"github.com/goplus/llgo/internal/runtime.Slice", align 8 - %40 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.Slice", ptr %39, i32 0, i32 0 - store ptr %37, ptr %40, align 8 - %41 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.Slice", ptr %39, i32 0, i32 1 - store i64 1, ptr %41, align 4 - %42 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.Slice", ptr %39, i32 0, i32 2 - store i64 1, ptr %42, align 4 - %43 = load %"github.com/goplus/llgo/internal/runtime.Slice", ptr %39, align 8 - %44 = call ptr @"github.com/goplus/llgo/internal/runtime.Func"(%"github.com/goplus/llgo/internal/runtime.Slice" %35, %"github.com/goplus/llgo/internal/runtime.Slice" %43, i1 false) - store ptr %44, ptr @"_llgo_func$zNDVRsWTIpUPKouNUS805RGX--IV9qVK8B31IZbg5to", align 8 - br label %_llgo_2 - -_llgo_2: ; preds = %_llgo_1, %_llgo_0 - ret void -} - -declare ptr @"github.com/goplus/llgo/internal/runtime.Named"(%"github.com/goplus/llgo/internal/runtime.String", %"github.com/goplus/llgo/internal/runtime.String", ptr, %"github.com/goplus/llgo/internal/runtime.Slice") - -declare ptr @"github.com/goplus/llgo/internal/runtime.Func"(%"github.com/goplus/llgo/internal/runtime.Slice", %"github.com/goplus/llgo/internal/runtime.Slice", i1) - -declare ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64) - -define void @"main.init$abi3"() { -_llgo_0: - %0 = alloca %"github.com/goplus/llgo/internal/runtime.String", align 8 - %1 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %0, i32 0, i32 0 - store ptr @6, ptr %1, align 8 - %2 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %0, i32 0, i32 1 - store i64 1, ptr %2, align 4 - %3 = load %"github.com/goplus/llgo/internal/runtime.String", ptr %0, align 8 - %4 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 24) + %4 = load ptr, ptr @_llgo_string, align 8 %5 = alloca %"github.com/goplus/llgo/internal/runtime.String", align 8 %6 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %5, i32 0, i32 0 - store ptr @7, ptr %6, align 8 + store ptr @0, ptr %6, align 8 %7 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %5, i32 0, i32 1 - store i64 0, ptr %7, align 4 + store i64 1, ptr %7, align 4 %8 = load %"github.com/goplus/llgo/internal/runtime.String", ptr %5, align 8 - %9 = call %"github.com/goplus/llgo/internal/abi.StructField" @"github.com/goplus/llgo/internal/runtime.StructField"(%"github.com/goplus/llgo/internal/runtime.String" %3, ptr %4, i64 0, %"github.com/goplus/llgo/internal/runtime.String" %8, i1 false) - %10 = alloca %"github.com/goplus/llgo/internal/runtime.String", align 8 - %11 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %10, i32 0, i32 0 - store ptr @8, ptr %11, align 8 - %12 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %10, i32 0, i32 1 - store i64 4, ptr %12, align 4 - %13 = load %"github.com/goplus/llgo/internal/runtime.String", ptr %10, align 8 - %14 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 56) - %15 = getelementptr %"github.com/goplus/llgo/internal/abi.StructField", ptr %14, i64 0 - store %"github.com/goplus/llgo/internal/abi.StructField" %9, ptr %15, align 8 - %16 = alloca %"github.com/goplus/llgo/internal/runtime.Slice", align 8 - %17 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.Slice", ptr %16, i32 0, i32 0 - store ptr %14, ptr %17, align 8 - %18 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.Slice", ptr %16, i32 0, i32 1 - store i64 1, ptr %18, align 4 - %19 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.Slice", ptr %16, i32 0, i32 2 - store i64 1, ptr %19, align 4 - %20 = load %"github.com/goplus/llgo/internal/runtime.Slice", ptr %16, align 8 - %21 = call ptr @"github.com/goplus/llgo/internal/runtime.Struct"(%"github.com/goplus/llgo/internal/runtime.String" %13, i64 16, %"github.com/goplus/llgo/internal/runtime.Slice" %20) - store ptr %21, ptr @"main.struct$QTufDJA9wEDzuzgkA-ZSrLqW-B6lWN8O25mTSglAoLQ", align 8 - %22 = load ptr, ptr @"_llgo_func$8LHAAczeMU-_MsqDJ4-62jHfhzpiOiRnFkBoaL3mfxg", align 8 - %23 = icmp eq ptr %22, null - br i1 %23, label %_llgo_1, label %_llgo_2 + %9 = alloca %"github.com/goplus/llgo/internal/runtime.String", align 8 + %10 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %9, i32 0, i32 0 + store ptr @1, ptr %10, align 8 + %11 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %9, i32 0, i32 1 + store i64 0, ptr %11, align 4 + %12 = load %"github.com/goplus/llgo/internal/runtime.String", ptr %9, align 8 + %13 = call %"github.com/goplus/llgo/internal/abi.StructField" @"github.com/goplus/llgo/internal/runtime.StructField"(%"github.com/goplus/llgo/internal/runtime.String" %8, ptr %4, i64 0, %"github.com/goplus/llgo/internal/runtime.String" %12, i1 false) + %14 = alloca %"github.com/goplus/llgo/internal/runtime.String", align 8 + %15 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %14, i32 0, i32 0 + store ptr @2, ptr %15, align 8 + %16 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %14, i32 0, i32 1 + store i64 4, ptr %16, align 4 + %17 = load %"github.com/goplus/llgo/internal/runtime.String", ptr %14, align 8 + %18 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 56) + %19 = getelementptr %"github.com/goplus/llgo/internal/abi.StructField", ptr %18, i64 0 + store %"github.com/goplus/llgo/internal/abi.StructField" %13, ptr %19, align 8 + %20 = alloca %"github.com/goplus/llgo/internal/runtime.Slice", align 8 + %21 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.Slice", ptr %20, i32 0, i32 0 + store ptr %18, ptr %21, align 8 + %22 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.Slice", ptr %20, i32 0, i32 1 + store i64 1, ptr %22, align 4 + %23 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.Slice", ptr %20, i32 0, i32 2 + store i64 1, ptr %23, align 4 + %24 = load %"github.com/goplus/llgo/internal/runtime.Slice", ptr %20, align 8 + %25 = call ptr @"github.com/goplus/llgo/internal/runtime.Struct"(%"github.com/goplus/llgo/internal/runtime.String" %17, i64 16, %"github.com/goplus/llgo/internal/runtime.Slice" %24) + store ptr %25, ptr @"main.struct$QTufDJA9wEDzuzgkA-ZSrLqW-B6lWN8O25mTSglAoLQ", align 8 + %26 = load ptr, ptr @"main.struct$QTufDJA9wEDzuzgkA-ZSrLqW-B6lWN8O25mTSglAoLQ", align 8 + %27 = alloca %"github.com/goplus/llgo/internal/runtime.String", align 8 + %28 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %27, i32 0, i32 0 + store ptr @3, ptr %28, align 8 + %29 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %27, i32 0, i32 1 + store i64 5, ptr %29, align 4 + %30 = load %"github.com/goplus/llgo/internal/runtime.String", ptr %27, align 8 + %31 = load ptr, ptr @_llgo_string, align 8 + %32 = load ptr, ptr @"_llgo_func$zNDVRsWTIpUPKouNUS805RGX--IV9qVK8B31IZbg5to", align 8 + %33 = icmp eq ptr %32, null + br i1 %33, label %_llgo_3, label %_llgo_4 -_llgo_1: ; preds = %_llgo_0 - %24 = load ptr, ptr @"*_llgo_main.errorString", align 8 - %25 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 8) - %26 = getelementptr ptr, ptr %25, i64 0 - store ptr %24, ptr %26, align 8 - %27 = alloca %"github.com/goplus/llgo/internal/runtime.Slice", align 8 - %28 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.Slice", ptr %27, i32 0, i32 0 - store ptr %25, ptr %28, align 8 - %29 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.Slice", ptr %27, i32 0, i32 1 - store i64 1, ptr %29, align 4 - %30 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.Slice", ptr %27, i32 0, i32 2 - store i64 1, ptr %30, align 4 - %31 = load %"github.com/goplus/llgo/internal/runtime.Slice", ptr %27, align 8 - %32 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 24) - %33 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 8) - %34 = getelementptr ptr, ptr %33, i64 0 - store ptr %32, ptr %34, align 8 +_llgo_3: ; preds = %_llgo_2 + %34 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 0) %35 = alloca %"github.com/goplus/llgo/internal/runtime.Slice", align 8 %36 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.Slice", ptr %35, i32 0, i32 0 - store ptr %33, ptr %36, align 8 + store ptr %34, ptr %36, align 8 %37 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.Slice", ptr %35, i32 0, i32 1 - store i64 1, ptr %37, align 4 + store i64 0, ptr %37, align 4 %38 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.Slice", ptr %35, i32 0, i32 2 - store i64 1, ptr %38, align 4 + store i64 0, ptr %38, align 4 %39 = load %"github.com/goplus/llgo/internal/runtime.Slice", ptr %35, align 8 - %40 = call ptr @"github.com/goplus/llgo/internal/runtime.Func"(%"github.com/goplus/llgo/internal/runtime.Slice" %31, %"github.com/goplus/llgo/internal/runtime.Slice" %39, i1 false) - store ptr %40, ptr @"_llgo_func$8LHAAczeMU-_MsqDJ4-62jHfhzpiOiRnFkBoaL3mfxg", align 8 - br label %_llgo_2 + %40 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 8) + %41 = getelementptr ptr, ptr %40, i64 0 + store ptr %31, ptr %41, align 8 + %42 = alloca %"github.com/goplus/llgo/internal/runtime.Slice", align 8 + %43 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.Slice", ptr %42, i32 0, i32 0 + store ptr %40, ptr %43, align 8 + %44 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.Slice", ptr %42, i32 0, i32 1 + store i64 1, ptr %44, align 4 + %45 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.Slice", ptr %42, i32 0, i32 2 + store i64 1, ptr %45, align 4 + %46 = load %"github.com/goplus/llgo/internal/runtime.Slice", ptr %42, align 8 + %47 = call ptr @"github.com/goplus/llgo/internal/runtime.Func"(%"github.com/goplus/llgo/internal/runtime.Slice" %39, %"github.com/goplus/llgo/internal/runtime.Slice" %46, i1 false) + store ptr %47, ptr @"_llgo_func$zNDVRsWTIpUPKouNUS805RGX--IV9qVK8B31IZbg5to", align 8 + br label %_llgo_4 -_llgo_2: ; preds = %_llgo_1, %_llgo_0 +_llgo_4: ; preds = %_llgo_3, %_llgo_2 + %48 = load ptr, ptr @"_llgo_func$zNDVRsWTIpUPKouNUS805RGX--IV9qVK8B31IZbg5to", align 8 + %49 = alloca %"github.com/goplus/llgo/internal/abi.Method", align 8 + %50 = getelementptr inbounds %"github.com/goplus/llgo/internal/abi.Method", ptr %49, i32 0, i32 0 + store %"github.com/goplus/llgo/internal/runtime.String" %30, ptr %50, align 8 + %51 = getelementptr inbounds %"github.com/goplus/llgo/internal/abi.Method", ptr %49, i32 0, i32 1 + store ptr %48, ptr %51, align 8 + %52 = getelementptr inbounds %"github.com/goplus/llgo/internal/abi.Method", ptr %49, i32 0, i32 2 + store ptr @"(*main.errorString).Error", ptr %52, align 8 + %53 = getelementptr inbounds %"github.com/goplus/llgo/internal/abi.Method", ptr %49, i32 0, i32 3 + store ptr @"(*main.errorString).Error", ptr %53, align 8 + %54 = load %"github.com/goplus/llgo/internal/abi.Method", ptr %49, align 8 + %55 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 40) + %56 = getelementptr %"github.com/goplus/llgo/internal/abi.Method", ptr %55, i64 0 + store %"github.com/goplus/llgo/internal/abi.Method" %54, ptr %56, align 8 + %57 = alloca %"github.com/goplus/llgo/internal/runtime.Slice", align 8 + %58 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.Slice", ptr %57, i32 0, i32 0 + store ptr %55, ptr %58, align 8 + %59 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.Slice", ptr %57, i32 0, i32 1 + store i64 1, ptr %59, align 4 + %60 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.Slice", ptr %57, i32 0, i32 2 + store i64 1, ptr %60, align 4 + %61 = load %"github.com/goplus/llgo/internal/runtime.Slice", ptr %57, align 8 + %62 = alloca %"github.com/goplus/llgo/internal/runtime.String", align 8 + %63 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %62, i32 0, i32 0 + store ptr @4, ptr %63, align 8 + %64 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %62, i32 0, i32 1 + store i64 4, ptr %64, align 4 + %65 = load %"github.com/goplus/llgo/internal/runtime.String", ptr %62, align 8 + %66 = alloca %"github.com/goplus/llgo/internal/runtime.String", align 8 + %67 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %66, i32 0, i32 0 + store ptr @5, ptr %67, align 8 + %68 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %66, i32 0, i32 1 + store i64 16, ptr %68, align 4 + %69 = load %"github.com/goplus/llgo/internal/runtime.String", ptr %66, align 8 + call void @"github.com/goplus/llgo/internal/runtime.InitNamed"(ptr %0, %"github.com/goplus/llgo/internal/runtime.String" %65, %"github.com/goplus/llgo/internal/runtime.String" %69, ptr %26, { ptr, i64, i64 } zeroinitializer, %"github.com/goplus/llgo/internal/runtime.Slice" %61) + %70 = load ptr, ptr @_llgo_main.errorString, align 8 + %71 = call ptr @"github.com/goplus/llgo/internal/runtime.PointerTo"(ptr %70) + store ptr %71, ptr @"*_llgo_main.errorString", align 8 + %72 = load ptr, ptr @"_llgo_func$zNDVRsWTIpUPKouNUS805RGX--IV9qVK8B31IZbg5to", align 8 + %73 = load ptr, ptr @"_llgo_iface$Fh8eUJ-Gw4e6TYuajcFIOSCuqSPKAt5nS4ow7xeGXEU", align 8 + %74 = icmp eq ptr %73, null + br i1 %74, label %_llgo_5, label %_llgo_6 + +_llgo_5: ; preds = %_llgo_4 + %75 = alloca %"github.com/goplus/llgo/internal/runtime.String", align 8 + %76 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %75, i32 0, i32 0 + store ptr @6, ptr %76, align 8 + %77 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %75, i32 0, i32 1 + store i64 5, ptr %77, align 4 + %78 = load %"github.com/goplus/llgo/internal/runtime.String", ptr %75, align 8 + %79 = alloca %"github.com/goplus/llgo/internal/abi.Imethod", align 8 + %80 = getelementptr inbounds %"github.com/goplus/llgo/internal/abi.Imethod", ptr %79, i32 0, i32 0 + store %"github.com/goplus/llgo/internal/runtime.String" %78, ptr %80, align 8 + %81 = getelementptr inbounds %"github.com/goplus/llgo/internal/abi.Imethod", ptr %79, i32 0, i32 1 + store ptr %72, ptr %81, align 8 + %82 = load %"github.com/goplus/llgo/internal/abi.Imethod", ptr %79, align 8 + %83 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 24) + %84 = getelementptr %"github.com/goplus/llgo/internal/abi.Imethod", ptr %83, i64 0 + store %"github.com/goplus/llgo/internal/abi.Imethod" %82, ptr %84, align 8 + %85 = alloca %"github.com/goplus/llgo/internal/runtime.Slice", align 8 + %86 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.Slice", ptr %85, i32 0, i32 0 + store ptr %83, ptr %86, align 8 + %87 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.Slice", ptr %85, i32 0, i32 1 + store i64 1, ptr %87, align 4 + %88 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.Slice", ptr %85, i32 0, i32 2 + store i64 1, ptr %88, align 4 + %89 = load %"github.com/goplus/llgo/internal/runtime.Slice", ptr %85, align 8 + %90 = alloca %"github.com/goplus/llgo/internal/runtime.String", align 8 + %91 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %90, i32 0, i32 0 + store ptr @7, ptr %91, align 8 + %92 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %90, i32 0, i32 1 + store i64 4, ptr %92, align 4 + %93 = load %"github.com/goplus/llgo/internal/runtime.String", ptr %90, align 8 + %94 = alloca %"github.com/goplus/llgo/internal/runtime.String", align 8 + %95 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %94, i32 0, i32 0 + store ptr @8, ptr %95, align 8 + %96 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %94, i32 0, i32 1 + store i64 0, ptr %96, align 4 + %97 = load %"github.com/goplus/llgo/internal/runtime.String", ptr %94, align 8 + %98 = call ptr @"github.com/goplus/llgo/internal/runtime.Interface"(%"github.com/goplus/llgo/internal/runtime.String" %93, %"github.com/goplus/llgo/internal/runtime.String" %97, %"github.com/goplus/llgo/internal/runtime.Slice" %89) + store ptr %98, ptr @"_llgo_iface$Fh8eUJ-Gw4e6TYuajcFIOSCuqSPKAt5nS4ow7xeGXEU", align 8 + br label %_llgo_6 + +_llgo_6: ; preds = %_llgo_5, %_llgo_4 ret void } +declare ptr @"github.com/goplus/llgo/internal/runtime.NewNamed"(i64, i64, i64) + +declare ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64) + declare ptr @"github.com/goplus/llgo/internal/runtime.Struct"(%"github.com/goplus/llgo/internal/runtime.String", i64, %"github.com/goplus/llgo/internal/runtime.Slice") declare %"github.com/goplus/llgo/internal/abi.StructField" @"github.com/goplus/llgo/internal/runtime.StructField"(%"github.com/goplus/llgo/internal/runtime.String", ptr, i64, %"github.com/goplus/llgo/internal/runtime.String", i1) + +declare ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64) + +declare void @"github.com/goplus/llgo/internal/runtime.InitNamed"(ptr, %"github.com/goplus/llgo/internal/runtime.String", %"github.com/goplus/llgo/internal/runtime.String", ptr, %"github.com/goplus/llgo/internal/runtime.Slice", %"github.com/goplus/llgo/internal/runtime.Slice") + +declare ptr @"github.com/goplus/llgo/internal/runtime.Func"(%"github.com/goplus/llgo/internal/runtime.Slice", %"github.com/goplus/llgo/internal/runtime.Slice", i1) + +declare ptr @"github.com/goplus/llgo/internal/runtime.PointerTo"(ptr) + +declare ptr @"github.com/goplus/llgo/internal/runtime.Interface"(%"github.com/goplus/llgo/internal/runtime.String", %"github.com/goplus/llgo/internal/runtime.String", %"github.com/goplus/llgo/internal/runtime.Slice") + +declare ptr @"github.com/goplus/llgo/internal/runtime.NewItab"(ptr, ptr) + +declare void @"github.com/goplus/llgo/internal/runtime.init"() + +declare void @"github.com/goplus/llgo/internal/runtime.PrintIface"(%"github.com/goplus/llgo/internal/runtime.iface") + +declare void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8) + +declare void @"github.com/goplus/llgo/internal/runtime.PrintString"(%"github.com/goplus/llgo/internal/runtime.String") diff --git a/cl/_testgo/strucintf/out.ll b/cl/_testgo/strucintf/out.ll index 9e09848fe..f23f046d5 100644 --- a/cl/_testgo/strucintf/out.ll +++ b/cl/_testgo/strucintf/out.ll @@ -8,18 +8,19 @@ source_filename = "main" @"main.init$guard" = global ptr null @"main.struct$MYpsoM99ZwFY087IpUOkIw1zjBA_sgFXVodmn1m-G88" = global ptr null +@_llgo_int = linkonce global ptr null +@0 = private unnamed_addr constant [2 x i8] c"v\00", align 1 +@1 = private unnamed_addr constant [1 x i8] zeroinitializer, align 1 +@2 = private unnamed_addr constant [5 x i8] c"main\00", align 1 @__llgo_argc = global ptr null @__llgo_argv = global ptr null @"_llgo_struct$K-dZ9QotZfVPz2a0YdRa9vmZUuDXPTqZOlMShKEDJtk" = linkonce global ptr null -@0 = private unnamed_addr constant [12 x i8] c"Foo: not ok\00", align 1 -@1 = private unnamed_addr constant [12 x i8] c"Bar: not ok\00", align 1 -@2 = private unnamed_addr constant [10 x i8] c"F: not ok\00", align 1 -@3 = private unnamed_addr constant [2 x i8] c"v\00", align 1 +@3 = private unnamed_addr constant [2 x i8] c"V\00", align 1 @4 = private unnamed_addr constant [1 x i8] zeroinitializer, align 1 @5 = private unnamed_addr constant [5 x i8] c"main\00", align 1 -@6 = private unnamed_addr constant [2 x i8] c"V\00", align 1 -@7 = private unnamed_addr constant [1 x i8] zeroinitializer, align 1 -@8 = private unnamed_addr constant [5 x i8] c"main\00", align 1 +@6 = private unnamed_addr constant [12 x i8] c"Foo: not ok\00", align 1 +@7 = private unnamed_addr constant [12 x i8] c"Bar: not ok\00", align 1 +@8 = private unnamed_addr constant [10 x i8] c"F: not ok\00", align 1 define %"github.com/goplus/llgo/internal/runtime.eface" @main.Foo() { _llgo_0: @@ -88,7 +89,7 @@ _llgo_2: ; preds = %_llgo_3, %_llgo_1 _llgo_3: ; preds = %_llgo_12 %16 = alloca %"github.com/goplus/llgo/internal/runtime.String", align 8 %17 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %16, i32 0, i32 0 - store ptr @0, ptr %17, align 8 + store ptr @6, ptr %17, align 8 %18 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %16, i32 0, i32 1 store i64 11, ptr %18, align 4 %19 = load %"github.com/goplus/llgo/internal/runtime.String", ptr %16, align 8 @@ -115,7 +116,7 @@ _llgo_5: ; preds = %_llgo_6, %_llgo_4 _llgo_6: ; preds = %_llgo_15 %28 = alloca %"github.com/goplus/llgo/internal/runtime.String", align 8 %29 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %28, i32 0, i32 0 - store ptr @1, ptr %29, align 8 + store ptr @7, ptr %29, align 8 %30 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %28, i32 0, i32 1 store i64 11, ptr %30, align 4 %31 = load %"github.com/goplus/llgo/internal/runtime.String", ptr %28, align 8 @@ -136,7 +137,7 @@ _llgo_8: ; preds = %_llgo_9, %_llgo_7 _llgo_9: ; preds = %_llgo_18 %34 = alloca %"github.com/goplus/llgo/internal/runtime.String", align 8 %35 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %34, i32 0, i32 0 - store ptr @2, ptr %35, align 8 + store ptr @8, ptr %35, align 8 %36 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %34, i32 0, i32 1 store i64 9, ptr %36, align 4 %37 = load %"github.com/goplus/llgo/internal/runtime.String", ptr %34, align 8 @@ -240,103 +241,113 @@ _llgo_18: ; preds = %_llgo_17, %_llgo_16 declare ptr @"github.com/goplus/llgo/internal/runtime.Zeroinit"(ptr, i64) -declare void @"github.com/goplus/llgo/cl/internal/foo.init"() - -declare void @"github.com/goplus/llgo/internal/runtime.init"() - -declare void @"github.com/goplus/llgo/internal/runtime.PrintInt"(i64) - -declare void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8) - -declare %"github.com/goplus/llgo/internal/runtime.eface" @"github.com/goplus/llgo/cl/internal/foo.Bar"() - -declare void @"github.com/goplus/llgo/internal/runtime.PrintString"(%"github.com/goplus/llgo/internal/runtime.String") - -declare %"github.com/goplus/llgo/internal/runtime.eface" @"github.com/goplus/llgo/cl/internal/foo.F"() - define void @"main.init$abi"() { _llgo_0: - %0 = alloca %"github.com/goplus/llgo/internal/runtime.String", align 8 - %1 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %0, i32 0, i32 0 - store ptr @3, ptr %1, align 8 - %2 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %0, i32 0, i32 1 - store i64 1, ptr %2, align 4 - %3 = load %"github.com/goplus/llgo/internal/runtime.String", ptr %0, align 8 - %4 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 2) - %5 = alloca %"github.com/goplus/llgo/internal/runtime.String", align 8 - %6 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %5, i32 0, i32 0 - store ptr @4, ptr %6, align 8 - %7 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %5, i32 0, i32 1 - store i64 0, ptr %7, align 4 - %8 = load %"github.com/goplus/llgo/internal/runtime.String", ptr %5, align 8 - %9 = call %"github.com/goplus/llgo/internal/abi.StructField" @"github.com/goplus/llgo/internal/runtime.StructField"(%"github.com/goplus/llgo/internal/runtime.String" %3, ptr %4, i64 0, %"github.com/goplus/llgo/internal/runtime.String" %8, i1 false) - %10 = alloca %"github.com/goplus/llgo/internal/runtime.String", align 8 - %11 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %10, i32 0, i32 0 - store ptr @5, ptr %11, align 8 - %12 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %10, i32 0, i32 1 - store i64 4, ptr %12, align 4 - %13 = load %"github.com/goplus/llgo/internal/runtime.String", ptr %10, align 8 - %14 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 56) - %15 = getelementptr %"github.com/goplus/llgo/internal/abi.StructField", ptr %14, i64 0 - store %"github.com/goplus/llgo/internal/abi.StructField" %9, ptr %15, align 8 - %16 = alloca %"github.com/goplus/llgo/internal/runtime.Slice", align 8 - %17 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.Slice", ptr %16, i32 0, i32 0 - store ptr %14, ptr %17, align 8 - %18 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.Slice", ptr %16, i32 0, i32 1 - store i64 1, ptr %18, align 4 - %19 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.Slice", ptr %16, i32 0, i32 2 - store i64 1, ptr %19, align 4 - %20 = load %"github.com/goplus/llgo/internal/runtime.Slice", ptr %16, align 8 - %21 = call ptr @"github.com/goplus/llgo/internal/runtime.Struct"(%"github.com/goplus/llgo/internal/runtime.String" %13, i64 8, %"github.com/goplus/llgo/internal/runtime.Slice" %20) - store ptr %21, ptr @"main.struct$MYpsoM99ZwFY087IpUOkIw1zjBA_sgFXVodmn1m-G88", align 8 - %22 = load ptr, ptr @"_llgo_struct$K-dZ9QotZfVPz2a0YdRa9vmZUuDXPTqZOlMShKEDJtk", align 8 - %23 = icmp eq ptr %22, null - br i1 %23, label %_llgo_1, label %_llgo_2 + %0 = load ptr, ptr @_llgo_int, align 8 + %1 = icmp eq ptr %0, null + br i1 %1, label %_llgo_1, label %_llgo_2 _llgo_1: ; preds = %_llgo_0 - %24 = alloca %"github.com/goplus/llgo/internal/runtime.String", align 8 - %25 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %24, i32 0, i32 0 - store ptr @6, ptr %25, align 8 - %26 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %24, i32 0, i32 1 - store i64 1, ptr %26, align 4 - %27 = load %"github.com/goplus/llgo/internal/runtime.String", ptr %24, align 8 - %28 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 2) - %29 = alloca %"github.com/goplus/llgo/internal/runtime.String", align 8 - %30 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %29, i32 0, i32 0 - store ptr @7, ptr %30, align 8 - %31 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %29, i32 0, i32 1 - store i64 0, ptr %31, align 4 - %32 = load %"github.com/goplus/llgo/internal/runtime.String", ptr %29, align 8 - %33 = call %"github.com/goplus/llgo/internal/abi.StructField" @"github.com/goplus/llgo/internal/runtime.StructField"(%"github.com/goplus/llgo/internal/runtime.String" %27, ptr %28, i64 0, %"github.com/goplus/llgo/internal/runtime.String" %32, i1 false) - %34 = alloca %"github.com/goplus/llgo/internal/runtime.String", align 8 - %35 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %34, i32 0, i32 0 - store ptr @8, ptr %35, align 8 - %36 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %34, i32 0, i32 1 - store i64 4, ptr %36, align 4 - %37 = load %"github.com/goplus/llgo/internal/runtime.String", ptr %34, align 8 - %38 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 56) - %39 = getelementptr %"github.com/goplus/llgo/internal/abi.StructField", ptr %38, i64 0 - store %"github.com/goplus/llgo/internal/abi.StructField" %33, ptr %39, align 8 - %40 = alloca %"github.com/goplus/llgo/internal/runtime.Slice", align 8 - %41 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.Slice", ptr %40, i32 0, i32 0 - store ptr %38, ptr %41, align 8 - %42 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.Slice", ptr %40, i32 0, i32 1 - store i64 1, ptr %42, align 4 - %43 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.Slice", ptr %40, i32 0, i32 2 - store i64 1, ptr %43, align 4 - %44 = load %"github.com/goplus/llgo/internal/runtime.Slice", ptr %40, align 8 - %45 = call ptr @"github.com/goplus/llgo/internal/runtime.Struct"(%"github.com/goplus/llgo/internal/runtime.String" %37, i64 8, %"github.com/goplus/llgo/internal/runtime.Slice" %44) - store ptr %45, ptr @"_llgo_struct$K-dZ9QotZfVPz2a0YdRa9vmZUuDXPTqZOlMShKEDJtk", align 8 + %2 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 2) + store ptr %2, ptr @_llgo_int, align 8 br label %_llgo_2 _llgo_2: ; preds = %_llgo_1, %_llgo_0 + %3 = load ptr, ptr @_llgo_int, align 8 + %4 = alloca %"github.com/goplus/llgo/internal/runtime.String", align 8 + %5 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %4, i32 0, i32 0 + store ptr @0, ptr %5, align 8 + %6 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %4, i32 0, i32 1 + store i64 1, ptr %6, align 4 + %7 = load %"github.com/goplus/llgo/internal/runtime.String", ptr %4, align 8 + %8 = alloca %"github.com/goplus/llgo/internal/runtime.String", align 8 + %9 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %8, i32 0, i32 0 + store ptr @1, ptr %9, align 8 + %10 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %8, i32 0, i32 1 + store i64 0, ptr %10, align 4 + %11 = load %"github.com/goplus/llgo/internal/runtime.String", ptr %8, align 8 + %12 = call %"github.com/goplus/llgo/internal/abi.StructField" @"github.com/goplus/llgo/internal/runtime.StructField"(%"github.com/goplus/llgo/internal/runtime.String" %7, ptr %3, i64 0, %"github.com/goplus/llgo/internal/runtime.String" %11, i1 false) + %13 = alloca %"github.com/goplus/llgo/internal/runtime.String", align 8 + %14 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %13, i32 0, i32 0 + store ptr @2, ptr %14, align 8 + %15 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %13, i32 0, i32 1 + store i64 4, ptr %15, align 4 + %16 = load %"github.com/goplus/llgo/internal/runtime.String", ptr %13, align 8 + %17 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 56) + %18 = getelementptr %"github.com/goplus/llgo/internal/abi.StructField", ptr %17, i64 0 + store %"github.com/goplus/llgo/internal/abi.StructField" %12, ptr %18, align 8 + %19 = alloca %"github.com/goplus/llgo/internal/runtime.Slice", align 8 + %20 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.Slice", ptr %19, i32 0, i32 0 + store ptr %17, ptr %20, align 8 + %21 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.Slice", ptr %19, i32 0, i32 1 + store i64 1, ptr %21, align 4 + %22 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.Slice", ptr %19, i32 0, i32 2 + store i64 1, ptr %22, align 4 + %23 = load %"github.com/goplus/llgo/internal/runtime.Slice", ptr %19, align 8 + %24 = call ptr @"github.com/goplus/llgo/internal/runtime.Struct"(%"github.com/goplus/llgo/internal/runtime.String" %16, i64 8, %"github.com/goplus/llgo/internal/runtime.Slice" %23) + store ptr %24, ptr @"main.struct$MYpsoM99ZwFY087IpUOkIw1zjBA_sgFXVodmn1m-G88", align 8 + %25 = load ptr, ptr @_llgo_int, align 8 + %26 = load ptr, ptr @"_llgo_struct$K-dZ9QotZfVPz2a0YdRa9vmZUuDXPTqZOlMShKEDJtk", align 8 + %27 = icmp eq ptr %26, null + br i1 %27, label %_llgo_3, label %_llgo_4 + +_llgo_3: ; preds = %_llgo_2 + %28 = alloca %"github.com/goplus/llgo/internal/runtime.String", align 8 + %29 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %28, i32 0, i32 0 + store ptr @3, ptr %29, align 8 + %30 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %28, i32 0, i32 1 + store i64 1, ptr %30, align 4 + %31 = load %"github.com/goplus/llgo/internal/runtime.String", ptr %28, align 8 + %32 = alloca %"github.com/goplus/llgo/internal/runtime.String", align 8 + %33 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %32, i32 0, i32 0 + store ptr @4, ptr %33, align 8 + %34 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %32, i32 0, i32 1 + store i64 0, ptr %34, align 4 + %35 = load %"github.com/goplus/llgo/internal/runtime.String", ptr %32, align 8 + %36 = call %"github.com/goplus/llgo/internal/abi.StructField" @"github.com/goplus/llgo/internal/runtime.StructField"(%"github.com/goplus/llgo/internal/runtime.String" %31, ptr %25, i64 0, %"github.com/goplus/llgo/internal/runtime.String" %35, i1 false) + %37 = alloca %"github.com/goplus/llgo/internal/runtime.String", align 8 + %38 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %37, i32 0, i32 0 + store ptr @5, ptr %38, align 8 + %39 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %37, i32 0, i32 1 + store i64 4, ptr %39, align 4 + %40 = load %"github.com/goplus/llgo/internal/runtime.String", ptr %37, align 8 + %41 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 56) + %42 = getelementptr %"github.com/goplus/llgo/internal/abi.StructField", ptr %41, i64 0 + store %"github.com/goplus/llgo/internal/abi.StructField" %36, ptr %42, align 8 + %43 = alloca %"github.com/goplus/llgo/internal/runtime.Slice", align 8 + %44 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.Slice", ptr %43, i32 0, i32 0 + store ptr %41, ptr %44, align 8 + %45 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.Slice", ptr %43, i32 0, i32 1 + store i64 1, ptr %45, align 4 + %46 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.Slice", ptr %43, i32 0, i32 2 + store i64 1, ptr %46, align 4 + %47 = load %"github.com/goplus/llgo/internal/runtime.Slice", ptr %43, align 8 + %48 = call ptr @"github.com/goplus/llgo/internal/runtime.Struct"(%"github.com/goplus/llgo/internal/runtime.String" %40, i64 8, %"github.com/goplus/llgo/internal/runtime.Slice" %47) + store ptr %48, ptr @"_llgo_struct$K-dZ9QotZfVPz2a0YdRa9vmZUuDXPTqZOlMShKEDJtk", align 8 + br label %_llgo_4 + +_llgo_4: ; preds = %_llgo_3, %_llgo_2 ret void } +declare ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64) + declare ptr @"github.com/goplus/llgo/internal/runtime.Struct"(%"github.com/goplus/llgo/internal/runtime.String", i64, %"github.com/goplus/llgo/internal/runtime.Slice") declare %"github.com/goplus/llgo/internal/abi.StructField" @"github.com/goplus/llgo/internal/runtime.StructField"(%"github.com/goplus/llgo/internal/runtime.String", ptr, i64, %"github.com/goplus/llgo/internal/runtime.String", i1) -declare ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64) - declare ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64) + +declare void @"github.com/goplus/llgo/cl/internal/foo.init"() + +declare void @"github.com/goplus/llgo/internal/runtime.init"() + +declare void @"github.com/goplus/llgo/internal/runtime.PrintInt"(i64) + +declare void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8) + +declare %"github.com/goplus/llgo/internal/runtime.eface" @"github.com/goplus/llgo/cl/internal/foo.Bar"() + +declare void @"github.com/goplus/llgo/internal/runtime.PrintString"(%"github.com/goplus/llgo/internal/runtime.String") + +declare %"github.com/goplus/llgo/internal/runtime.eface" @"github.com/goplus/llgo/cl/internal/foo.F"() diff --git a/cl/_testgo/struczero/out.ll b/cl/_testgo/struczero/out.ll index 2de205dae..f0cd306ba 100644 --- a/cl/_testgo/struczero/out.ll +++ b/cl/_testgo/struczero/out.ll @@ -5,35 +5,37 @@ source_filename = "main" %"github.com/goplus/llgo/internal/runtime.eface" = type { ptr, ptr } %main.bar = type { ptr, float } %"github.com/goplus/llgo/internal/runtime.String" = type { ptr, i64 } -%"github.com/goplus/llgo/internal/abi.Method" = type { %"github.com/goplus/llgo/internal/runtime.String", ptr, ptr, ptr } -%"github.com/goplus/llgo/internal/runtime.Slice" = type { ptr, i64, i64 } %"github.com/goplus/llgo/internal/abi.StructField" = type { %"github.com/goplus/llgo/internal/runtime.String", ptr, i64, %"github.com/goplus/llgo/internal/runtime.String", i1 } +%"github.com/goplus/llgo/internal/runtime.Slice" = type { ptr, i64, i64 } +%"github.com/goplus/llgo/internal/abi.Method" = type { %"github.com/goplus/llgo/internal/runtime.String", ptr, ptr, ptr } @"main.init$guard" = global ptr null @"_llgo_github.com/goplus/llgo/cl/internal/foo.Foo" = linkonce global ptr null -@_llgo_main.bar = global ptr null -@__llgo_argc = global ptr null -@__llgo_argv = global ptr null -@0 = private unnamed_addr constant [7 x i8] c"notOk:\00", align 1 @"main.struct$qQwZyFy_4JRalRxVVsVD8R09X5t58tWjTrtJPtHbEjs" = global ptr null -@1 = private unnamed_addr constant [3 x i8] c"Pb\00", align 1 -@"_llgo_func$9WyRPk13jhLNuX5vkY3DFEfqvowhmGCLb2eJ8uGOVkM" = linkonce global ptr null -@2 = private unnamed_addr constant [39 x i8] c"github.com/goplus/llgo/cl/internal/foo\00", align 1 -@3 = private unnamed_addr constant [43 x i8] c"github.com/goplus/llgo/cl/internal/foo.Foo\00", align 1 -@"main.struct$Ci43nzKYkRLddRL_N4mkykxLXfJlqJGS5n04LKThPNo" = global ptr null -@4 = private unnamed_addr constant [5 x i8] c"main\00", align 1 -@5 = private unnamed_addr constant [9 x i8] c"main.bar\00", align 1 -@6 = private unnamed_addr constant [3 x i8] c"pb\00", align 1 @"*_llgo_byte" = linkonce global ptr null -@7 = private unnamed_addr constant [1 x i8] zeroinitializer, align 1 -@8 = private unnamed_addr constant [2 x i8] c"F\00", align 1 +@_llgo_byte = linkonce global ptr null +@_llgo_float32 = linkonce global ptr null +@0 = private unnamed_addr constant [3 x i8] c"pb\00", align 1 +@1 = private unnamed_addr constant [1 x i8] zeroinitializer, align 1 +@2 = private unnamed_addr constant [2 x i8] c"F\00", align 1 +@3 = private unnamed_addr constant [1 x i8] zeroinitializer, align 1 +@4 = private unnamed_addr constant [5 x i8] c"main\00", align 1 +@5 = private unnamed_addr constant [3 x i8] c"Pb\00", align 1 +@"_llgo_func$NfGSLZ1QiKRoFkKeqYSXE5hUU5bpeteSJKrbMNUzYRE" = linkonce global ptr null +@6 = private unnamed_addr constant [39 x i8] c"github.com/goplus/llgo/cl/internal/foo\00", align 1 +@7 = private unnamed_addr constant [43 x i8] c"github.com/goplus/llgo/cl/internal/foo.Foo\00", align 1 +@_llgo_main.bar = global ptr null +@"main.struct$Ci43nzKYkRLddRL_N4mkykxLXfJlqJGS5n04LKThPNo" = global ptr null +@8 = private unnamed_addr constant [3 x i8] c"pb\00", align 1 @9 = private unnamed_addr constant [1 x i8] zeroinitializer, align 1 -@10 = private unnamed_addr constant [5 x i8] c"main\00", align 1 -@11 = private unnamed_addr constant [3 x i8] c"pb\00", align 1 -@12 = private unnamed_addr constant [1 x i8] zeroinitializer, align 1 -@13 = private unnamed_addr constant [2 x i8] c"f\00", align 1 -@14 = private unnamed_addr constant [1 x i8] zeroinitializer, align 1 -@15 = private unnamed_addr constant [5 x i8] c"main\00", align 1 +@10 = private unnamed_addr constant [2 x i8] c"f\00", align 1 +@11 = private unnamed_addr constant [1 x i8] zeroinitializer, align 1 +@12 = private unnamed_addr constant [5 x i8] c"main\00", align 1 +@13 = private unnamed_addr constant [5 x i8] c"main\00", align 1 +@14 = private unnamed_addr constant [9 x i8] c"main.bar\00", align 1 +@__llgo_argc = global ptr null +@__llgo_argv = global ptr null +@15 = private unnamed_addr constant [7 x i8] c"notOk:\00", align 1 define { %"github.com/goplus/llgo/cl/internal/foo.Foo", i1 } @main.Bar(%"github.com/goplus/llgo/internal/runtime.eface" %0) { _llgo_0: @@ -141,7 +143,7 @@ _llgo_0: %11 = xor i1 %6, true %12 = alloca %"github.com/goplus/llgo/internal/runtime.String", align 8 %13 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %12, i32 0, i32 0 - store ptr @0, ptr %13, align 8 + store ptr @15, ptr %13, align 8 %14 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %12, i32 0, i32 1 store i64 6, ptr %14, align 4 %15 = load %"github.com/goplus/llgo/internal/runtime.String", ptr %12, align 8 @@ -183,269 +185,298 @@ _llgo_0: ret i32 0 } -declare void @"github.com/goplus/llgo/cl/internal/foo.init"() - -declare void @"github.com/goplus/llgo/internal/runtime.init"() - -declare ptr @"github.com/goplus/llgo/internal/runtime.Zeroinit"(ptr, i64) - -declare void @"github.com/goplus/llgo/internal/runtime.PrintPointer"(ptr) - -declare void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8) - -declare void @"github.com/goplus/llgo/internal/runtime.PrintFloat"(double) - -declare void @"github.com/goplus/llgo/internal/runtime.PrintString"(%"github.com/goplus/llgo/internal/runtime.String") - -declare void @"github.com/goplus/llgo/internal/runtime.PrintBool"(i1) - -declare ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64) - -declare ptr @"(github.com/goplus/llgo/cl/internal/foo.Foo).Pb"(%"github.com/goplus/llgo/cl/internal/foo.Foo") - define void @"main.init$abi"() { _llgo_0: - call void @"main.init$abi2"() %0 = load ptr, ptr @"_llgo_github.com/goplus/llgo/cl/internal/foo.Foo", align 8 %1 = icmp eq ptr %0, null br i1 %1, label %_llgo_1, label %_llgo_2 _llgo_1: ; preds = %_llgo_0 - %2 = load ptr, ptr @"main.struct$qQwZyFy_4JRalRxVVsVD8R09X5t58tWjTrtJPtHbEjs", align 8 - %3 = alloca %"github.com/goplus/llgo/internal/runtime.String", align 8 - %4 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %3, i32 0, i32 0 - store ptr @1, ptr %4, align 8 - %5 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %3, i32 0, i32 1 - store i64 2, ptr %5, align 4 - %6 = load %"github.com/goplus/llgo/internal/runtime.String", ptr %3, align 8 - %7 = load ptr, ptr @"_llgo_func$9WyRPk13jhLNuX5vkY3DFEfqvowhmGCLb2eJ8uGOVkM", align 8 - %8 = alloca %"github.com/goplus/llgo/internal/abi.Method", align 8 - %9 = getelementptr inbounds %"github.com/goplus/llgo/internal/abi.Method", ptr %8, i32 0, i32 0 - store %"github.com/goplus/llgo/internal/runtime.String" %6, ptr %9, align 8 - %10 = getelementptr inbounds %"github.com/goplus/llgo/internal/abi.Method", ptr %8, i32 0, i32 1 - store ptr %7, ptr %10, align 8 - %11 = getelementptr inbounds %"github.com/goplus/llgo/internal/abi.Method", ptr %8, i32 0, i32 2 - store ptr @"(github.com/goplus/llgo/cl/internal/foo.Foo).Pb", ptr %11, align 8 - %12 = getelementptr inbounds %"github.com/goplus/llgo/internal/abi.Method", ptr %8, i32 0, i32 3 - store ptr @"(github.com/goplus/llgo/cl/internal/foo.Foo).Pb", ptr %12, align 8 - %13 = load %"github.com/goplus/llgo/internal/abi.Method", ptr %8, align 8 - %14 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 40) - %15 = getelementptr %"github.com/goplus/llgo/internal/abi.Method", ptr %14, i64 0 - store %"github.com/goplus/llgo/internal/abi.Method" %13, ptr %15, align 8 - %16 = alloca %"github.com/goplus/llgo/internal/runtime.Slice", align 8 - %17 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.Slice", ptr %16, i32 0, i32 0 - store ptr %14, ptr %17, align 8 - %18 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.Slice", ptr %16, i32 0, i32 1 - store i64 1, ptr %18, align 4 - %19 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.Slice", ptr %16, i32 0, i32 2 - store i64 1, ptr %19, align 4 - %20 = load %"github.com/goplus/llgo/internal/runtime.Slice", ptr %16, align 8 - %21 = alloca %"github.com/goplus/llgo/internal/runtime.String", align 8 - %22 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %21, i32 0, i32 0 - store ptr @2, ptr %22, align 8 - %23 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %21, i32 0, i32 1 - store i64 38, ptr %23, align 4 - %24 = load %"github.com/goplus/llgo/internal/runtime.String", ptr %21, align 8 - %25 = alloca %"github.com/goplus/llgo/internal/runtime.String", align 8 - %26 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %25, i32 0, i32 0 - store ptr @3, ptr %26, align 8 - %27 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %25, i32 0, i32 1 - store i64 42, ptr %27, align 4 - %28 = load %"github.com/goplus/llgo/internal/runtime.String", ptr %25, align 8 - %29 = call ptr @"github.com/goplus/llgo/internal/runtime.Named"(%"github.com/goplus/llgo/internal/runtime.String" %24, %"github.com/goplus/llgo/internal/runtime.String" %28, ptr %2, %"github.com/goplus/llgo/internal/runtime.Slice" %20) - store ptr %29, ptr @"_llgo_github.com/goplus/llgo/cl/internal/foo.Foo", align 8 + %2 = call ptr @"github.com/goplus/llgo/internal/runtime.NewNamed"(i64 25, i64 1, i64 1) + store ptr %2, ptr @"_llgo_github.com/goplus/llgo/cl/internal/foo.Foo", align 8 br label %_llgo_2 _llgo_2: ; preds = %_llgo_1, %_llgo_0 - %30 = load ptr, ptr @"main.struct$Ci43nzKYkRLddRL_N4mkykxLXfJlqJGS5n04LKThPNo", align 8 - %31 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 0) - %32 = alloca %"github.com/goplus/llgo/internal/runtime.Slice", align 8 - %33 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.Slice", ptr %32, i32 0, i32 0 - store ptr %31, ptr %33, align 8 - %34 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.Slice", ptr %32, i32 0, i32 1 - store i64 0, ptr %34, align 4 - %35 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.Slice", ptr %32, i32 0, i32 2 - store i64 0, ptr %35, align 4 - %36 = load %"github.com/goplus/llgo/internal/runtime.Slice", ptr %32, align 8 - %37 = alloca %"github.com/goplus/llgo/internal/runtime.String", align 8 - %38 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %37, i32 0, i32 0 - store ptr @4, ptr %38, align 8 - %39 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %37, i32 0, i32 1 - store i64 4, ptr %39, align 4 - %40 = load %"github.com/goplus/llgo/internal/runtime.String", ptr %37, align 8 - %41 = alloca %"github.com/goplus/llgo/internal/runtime.String", align 8 - %42 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %41, i32 0, i32 0 - store ptr @5, ptr %42, align 8 - %43 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %41, i32 0, i32 1 - store i64 8, ptr %43, align 4 - %44 = load %"github.com/goplus/llgo/internal/runtime.String", ptr %41, align 8 - %45 = call ptr @"github.com/goplus/llgo/internal/runtime.Named"(%"github.com/goplus/llgo/internal/runtime.String" %40, %"github.com/goplus/llgo/internal/runtime.String" %44, ptr %30, %"github.com/goplus/llgo/internal/runtime.Slice" %36) - store ptr %45, ptr @_llgo_main.bar, align 8 - ret void -} - -declare ptr @"github.com/goplus/llgo/internal/runtime.Named"(%"github.com/goplus/llgo/internal/runtime.String", %"github.com/goplus/llgo/internal/runtime.String", ptr, %"github.com/goplus/llgo/internal/runtime.Slice") - -define void @"main.init$abi2"() { -_llgo_0: - call void @"main.init$abi3"() - %0 = alloca %"github.com/goplus/llgo/internal/runtime.String", align 8 - %1 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %0, i32 0, i32 0 - store ptr @6, ptr %1, align 8 - %2 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %0, i32 0, i32 1 - store i64 2, ptr %2, align 4 - %3 = load %"github.com/goplus/llgo/internal/runtime.String", ptr %0, align 8 - %4 = load ptr, ptr @"*_llgo_byte", align 8 - %5 = alloca %"github.com/goplus/llgo/internal/runtime.String", align 8 - %6 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %5, i32 0, i32 0 - store ptr @7, ptr %6, align 8 - %7 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %5, i32 0, i32 1 - store i64 0, ptr %7, align 4 - %8 = load %"github.com/goplus/llgo/internal/runtime.String", ptr %5, align 8 - %9 = call %"github.com/goplus/llgo/internal/abi.StructField" @"github.com/goplus/llgo/internal/runtime.StructField"(%"github.com/goplus/llgo/internal/runtime.String" %3, ptr %4, i64 0, %"github.com/goplus/llgo/internal/runtime.String" %8, i1 false) - %10 = alloca %"github.com/goplus/llgo/internal/runtime.String", align 8 - %11 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %10, i32 0, i32 0 - store ptr @8, ptr %11, align 8 - %12 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %10, i32 0, i32 1 - store i64 1, ptr %12, align 4 - %13 = load %"github.com/goplus/llgo/internal/runtime.String", ptr %10, align 8 - %14 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 13) + %3 = load ptr, ptr @_llgo_byte, align 8 + %4 = icmp eq ptr %3, null + br i1 %4, label %_llgo_3, label %_llgo_4 + +_llgo_3: ; preds = %_llgo_2 + %5 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 8) + store ptr %5, ptr @_llgo_byte, align 8 + br label %_llgo_4 + +_llgo_4: ; preds = %_llgo_3, %_llgo_2 + %6 = load ptr, ptr @_llgo_byte, align 8 + %7 = load ptr, ptr @"*_llgo_byte", align 8 + %8 = icmp eq ptr %7, null + br i1 %8, label %_llgo_5, label %_llgo_6 + +_llgo_5: ; preds = %_llgo_4 + %9 = call ptr @"github.com/goplus/llgo/internal/runtime.PointerTo"(ptr %6) + store ptr %9, ptr @"*_llgo_byte", align 8 + br label %_llgo_6 + +_llgo_6: ; preds = %_llgo_5, %_llgo_4 + %10 = load ptr, ptr @"*_llgo_byte", align 8 + %11 = load ptr, ptr @_llgo_float32, align 8 + %12 = icmp eq ptr %11, null + br i1 %12, label %_llgo_7, label %_llgo_8 + +_llgo_7: ; preds = %_llgo_6 + %13 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 13) + store ptr %13, ptr @_llgo_float32, align 8 + br label %_llgo_8 + +_llgo_8: ; preds = %_llgo_7, %_llgo_6 + %14 = load ptr, ptr @_llgo_float32, align 8 %15 = alloca %"github.com/goplus/llgo/internal/runtime.String", align 8 %16 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %15, i32 0, i32 0 - store ptr @9, ptr %16, align 8 + store ptr @0, ptr %16, align 8 %17 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %15, i32 0, i32 1 - store i64 0, ptr %17, align 4 + store i64 2, ptr %17, align 4 %18 = load %"github.com/goplus/llgo/internal/runtime.String", ptr %15, align 8 - %19 = call %"github.com/goplus/llgo/internal/abi.StructField" @"github.com/goplus/llgo/internal/runtime.StructField"(%"github.com/goplus/llgo/internal/runtime.String" %13, ptr %14, i64 8, %"github.com/goplus/llgo/internal/runtime.String" %18, i1 false) - %20 = alloca %"github.com/goplus/llgo/internal/runtime.String", align 8 - %21 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %20, i32 0, i32 0 - store ptr @10, ptr %21, align 8 - %22 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %20, i32 0, i32 1 - store i64 4, ptr %22, align 4 - %23 = load %"github.com/goplus/llgo/internal/runtime.String", ptr %20, align 8 - %24 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 112) - %25 = getelementptr %"github.com/goplus/llgo/internal/abi.StructField", ptr %24, i64 0 - store %"github.com/goplus/llgo/internal/abi.StructField" %9, ptr %25, align 8 - %26 = getelementptr %"github.com/goplus/llgo/internal/abi.StructField", ptr %24, i64 1 - store %"github.com/goplus/llgo/internal/abi.StructField" %19, ptr %26, align 8 - %27 = alloca %"github.com/goplus/llgo/internal/runtime.Slice", align 8 - %28 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.Slice", ptr %27, i32 0, i32 0 - store ptr %24, ptr %28, align 8 - %29 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.Slice", ptr %27, i32 0, i32 1 - store i64 2, ptr %29, align 4 - %30 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.Slice", ptr %27, i32 0, i32 2 - store i64 2, ptr %30, align 4 - %31 = load %"github.com/goplus/llgo/internal/runtime.Slice", ptr %27, align 8 - %32 = call ptr @"github.com/goplus/llgo/internal/runtime.Struct"(%"github.com/goplus/llgo/internal/runtime.String" %23, i64 16, %"github.com/goplus/llgo/internal/runtime.Slice" %31) - store ptr %32, ptr @"main.struct$qQwZyFy_4JRalRxVVsVD8R09X5t58tWjTrtJPtHbEjs", align 8 - %33 = load ptr, ptr @"_llgo_func$9WyRPk13jhLNuX5vkY3DFEfqvowhmGCLb2eJ8uGOVkM", align 8 - %34 = icmp eq ptr %33, null - br i1 %34, label %_llgo_1, label %_llgo_2 - -_llgo_1: ; preds = %_llgo_0 - %35 = load ptr, ptr @"_llgo_github.com/goplus/llgo/cl/internal/foo.Foo", align 8 - %36 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 8) - %37 = getelementptr ptr, ptr %36, i64 0 - store ptr %35, ptr %37, align 8 - %38 = alloca %"github.com/goplus/llgo/internal/runtime.Slice", align 8 - %39 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.Slice", ptr %38, i32 0, i32 0 - store ptr %36, ptr %39, align 8 - %40 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.Slice", ptr %38, i32 0, i32 1 - store i64 1, ptr %40, align 4 - %41 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.Slice", ptr %38, i32 0, i32 2 - store i64 1, ptr %41, align 4 - %42 = load %"github.com/goplus/llgo/internal/runtime.Slice", ptr %38, align 8 - %43 = load ptr, ptr @"*_llgo_byte", align 8 - %44 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 8) - %45 = getelementptr ptr, ptr %44, i64 0 - store ptr %43, ptr %45, align 8 - %46 = alloca %"github.com/goplus/llgo/internal/runtime.Slice", align 8 - %47 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.Slice", ptr %46, i32 0, i32 0 - store ptr %44, ptr %47, align 8 - %48 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.Slice", ptr %46, i32 0, i32 1 - store i64 1, ptr %48, align 4 - %49 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.Slice", ptr %46, i32 0, i32 2 - store i64 1, ptr %49, align 4 - %50 = load %"github.com/goplus/llgo/internal/runtime.Slice", ptr %46, align 8 - %51 = call ptr @"github.com/goplus/llgo/internal/runtime.Func"(%"github.com/goplus/llgo/internal/runtime.Slice" %42, %"github.com/goplus/llgo/internal/runtime.Slice" %50, i1 false) - store ptr %51, ptr @"_llgo_func$9WyRPk13jhLNuX5vkY3DFEfqvowhmGCLb2eJ8uGOVkM", align 8 - br label %_llgo_2 - -_llgo_2: ; preds = %_llgo_1, %_llgo_0 - %52 = alloca %"github.com/goplus/llgo/internal/runtime.String", align 8 - %53 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %52, i32 0, i32 0 - store ptr @11, ptr %53, align 8 - %54 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %52, i32 0, i32 1 - store i64 2, ptr %54, align 4 - %55 = load %"github.com/goplus/llgo/internal/runtime.String", ptr %52, align 8 - %56 = load ptr, ptr @"*_llgo_byte", align 8 + %19 = alloca %"github.com/goplus/llgo/internal/runtime.String", align 8 + %20 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %19, i32 0, i32 0 + store ptr @1, ptr %20, align 8 + %21 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %19, i32 0, i32 1 + store i64 0, ptr %21, align 4 + %22 = load %"github.com/goplus/llgo/internal/runtime.String", ptr %19, align 8 + %23 = call %"github.com/goplus/llgo/internal/abi.StructField" @"github.com/goplus/llgo/internal/runtime.StructField"(%"github.com/goplus/llgo/internal/runtime.String" %18, ptr %10, i64 0, %"github.com/goplus/llgo/internal/runtime.String" %22, i1 false) + %24 = alloca %"github.com/goplus/llgo/internal/runtime.String", align 8 + %25 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %24, i32 0, i32 0 + store ptr @2, ptr %25, align 8 + %26 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %24, i32 0, i32 1 + store i64 1, ptr %26, align 4 + %27 = load %"github.com/goplus/llgo/internal/runtime.String", ptr %24, align 8 + %28 = alloca %"github.com/goplus/llgo/internal/runtime.String", align 8 + %29 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %28, i32 0, i32 0 + store ptr @3, ptr %29, align 8 + %30 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %28, i32 0, i32 1 + store i64 0, ptr %30, align 4 + %31 = load %"github.com/goplus/llgo/internal/runtime.String", ptr %28, align 8 + %32 = call %"github.com/goplus/llgo/internal/abi.StructField" @"github.com/goplus/llgo/internal/runtime.StructField"(%"github.com/goplus/llgo/internal/runtime.String" %27, ptr %14, i64 8, %"github.com/goplus/llgo/internal/runtime.String" %31, i1 false) + %33 = alloca %"github.com/goplus/llgo/internal/runtime.String", align 8 + %34 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %33, i32 0, i32 0 + store ptr @4, ptr %34, align 8 + %35 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %33, i32 0, i32 1 + store i64 4, ptr %35, align 4 + %36 = load %"github.com/goplus/llgo/internal/runtime.String", ptr %33, align 8 + %37 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 112) + %38 = getelementptr %"github.com/goplus/llgo/internal/abi.StructField", ptr %37, i64 0 + store %"github.com/goplus/llgo/internal/abi.StructField" %23, ptr %38, align 8 + %39 = getelementptr %"github.com/goplus/llgo/internal/abi.StructField", ptr %37, i64 1 + store %"github.com/goplus/llgo/internal/abi.StructField" %32, ptr %39, align 8 + %40 = alloca %"github.com/goplus/llgo/internal/runtime.Slice", align 8 + %41 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.Slice", ptr %40, i32 0, i32 0 + store ptr %37, ptr %41, align 8 + %42 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.Slice", ptr %40, i32 0, i32 1 + store i64 2, ptr %42, align 4 + %43 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.Slice", ptr %40, i32 0, i32 2 + store i64 2, ptr %43, align 4 + %44 = load %"github.com/goplus/llgo/internal/runtime.Slice", ptr %40, align 8 + %45 = call ptr @"github.com/goplus/llgo/internal/runtime.Struct"(%"github.com/goplus/llgo/internal/runtime.String" %36, i64 16, %"github.com/goplus/llgo/internal/runtime.Slice" %44) + store ptr %45, ptr @"main.struct$qQwZyFy_4JRalRxVVsVD8R09X5t58tWjTrtJPtHbEjs", align 8 + %46 = load ptr, ptr @"main.struct$qQwZyFy_4JRalRxVVsVD8R09X5t58tWjTrtJPtHbEjs", align 8 + br i1 %1, label %_llgo_9, label %_llgo_10 + +_llgo_9: ; preds = %_llgo_8 + %47 = alloca %"github.com/goplus/llgo/internal/runtime.String", align 8 + %48 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %47, i32 0, i32 0 + store ptr @5, ptr %48, align 8 + %49 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %47, i32 0, i32 1 + store i64 2, ptr %49, align 4 + %50 = load %"github.com/goplus/llgo/internal/runtime.String", ptr %47, align 8 + %51 = load ptr, ptr @"*_llgo_byte", align 8 + %52 = load ptr, ptr @"_llgo_func$NfGSLZ1QiKRoFkKeqYSXE5hUU5bpeteSJKrbMNUzYRE", align 8 + %53 = icmp eq ptr %52, null + br i1 %53, label %_llgo_11, label %_llgo_12 + +_llgo_10: ; preds = %_llgo_12, %_llgo_8 + %54 = call ptr @"github.com/goplus/llgo/internal/runtime.NewNamed"(i64 25, i64 0, i64 0) + store ptr %54, ptr @_llgo_main.bar, align 8 + %55 = load ptr, ptr @"*_llgo_byte", align 8 + %56 = load ptr, ptr @_llgo_float32, align 8 %57 = alloca %"github.com/goplus/llgo/internal/runtime.String", align 8 %58 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %57, i32 0, i32 0 - store ptr @12, ptr %58, align 8 + store ptr @8, ptr %58, align 8 %59 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %57, i32 0, i32 1 - store i64 0, ptr %59, align 4 + store i64 2, ptr %59, align 4 %60 = load %"github.com/goplus/llgo/internal/runtime.String", ptr %57, align 8 - %61 = call %"github.com/goplus/llgo/internal/abi.StructField" @"github.com/goplus/llgo/internal/runtime.StructField"(%"github.com/goplus/llgo/internal/runtime.String" %55, ptr %56, i64 0, %"github.com/goplus/llgo/internal/runtime.String" %60, i1 false) - %62 = alloca %"github.com/goplus/llgo/internal/runtime.String", align 8 - %63 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %62, i32 0, i32 0 - store ptr @13, ptr %63, align 8 - %64 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %62, i32 0, i32 1 - store i64 1, ptr %64, align 4 - %65 = load %"github.com/goplus/llgo/internal/runtime.String", ptr %62, align 8 - %66 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 13) - %67 = alloca %"github.com/goplus/llgo/internal/runtime.String", align 8 - %68 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %67, i32 0, i32 0 - store ptr @14, ptr %68, align 8 - %69 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %67, i32 0, i32 1 - store i64 0, ptr %69, align 4 - %70 = load %"github.com/goplus/llgo/internal/runtime.String", ptr %67, align 8 - %71 = call %"github.com/goplus/llgo/internal/abi.StructField" @"github.com/goplus/llgo/internal/runtime.StructField"(%"github.com/goplus/llgo/internal/runtime.String" %65, ptr %66, i64 8, %"github.com/goplus/llgo/internal/runtime.String" %70, i1 false) - %72 = alloca %"github.com/goplus/llgo/internal/runtime.String", align 8 - %73 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %72, i32 0, i32 0 - store ptr @15, ptr %73, align 8 - %74 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %72, i32 0, i32 1 - store i64 4, ptr %74, align 4 - %75 = load %"github.com/goplus/llgo/internal/runtime.String", ptr %72, align 8 - %76 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 112) - %77 = getelementptr %"github.com/goplus/llgo/internal/abi.StructField", ptr %76, i64 0 - store %"github.com/goplus/llgo/internal/abi.StructField" %61, ptr %77, align 8 - %78 = getelementptr %"github.com/goplus/llgo/internal/abi.StructField", ptr %76, i64 1 - store %"github.com/goplus/llgo/internal/abi.StructField" %71, ptr %78, align 8 - %79 = alloca %"github.com/goplus/llgo/internal/runtime.Slice", align 8 - %80 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.Slice", ptr %79, i32 0, i32 0 - store ptr %76, ptr %80, align 8 - %81 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.Slice", ptr %79, i32 0, i32 1 - store i64 2, ptr %81, align 4 - %82 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.Slice", ptr %79, i32 0, i32 2 - store i64 2, ptr %82, align 4 - %83 = load %"github.com/goplus/llgo/internal/runtime.Slice", ptr %79, align 8 - %84 = call ptr @"github.com/goplus/llgo/internal/runtime.Struct"(%"github.com/goplus/llgo/internal/runtime.String" %75, i64 16, %"github.com/goplus/llgo/internal/runtime.Slice" %83) - store ptr %84, ptr @"main.struct$Ci43nzKYkRLddRL_N4mkykxLXfJlqJGS5n04LKThPNo", align 8 + %61 = alloca %"github.com/goplus/llgo/internal/runtime.String", align 8 + %62 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %61, i32 0, i32 0 + store ptr @9, ptr %62, align 8 + %63 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %61, i32 0, i32 1 + store i64 0, ptr %63, align 4 + %64 = load %"github.com/goplus/llgo/internal/runtime.String", ptr %61, align 8 + %65 = call %"github.com/goplus/llgo/internal/abi.StructField" @"github.com/goplus/llgo/internal/runtime.StructField"(%"github.com/goplus/llgo/internal/runtime.String" %60, ptr %55, i64 0, %"github.com/goplus/llgo/internal/runtime.String" %64, i1 false) + %66 = alloca %"github.com/goplus/llgo/internal/runtime.String", align 8 + %67 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %66, i32 0, i32 0 + store ptr @10, ptr %67, align 8 + %68 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %66, i32 0, i32 1 + store i64 1, ptr %68, align 4 + %69 = load %"github.com/goplus/llgo/internal/runtime.String", ptr %66, align 8 + %70 = alloca %"github.com/goplus/llgo/internal/runtime.String", align 8 + %71 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %70, i32 0, i32 0 + store ptr @11, ptr %71, align 8 + %72 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %70, i32 0, i32 1 + store i64 0, ptr %72, align 4 + %73 = load %"github.com/goplus/llgo/internal/runtime.String", ptr %70, align 8 + %74 = call %"github.com/goplus/llgo/internal/abi.StructField" @"github.com/goplus/llgo/internal/runtime.StructField"(%"github.com/goplus/llgo/internal/runtime.String" %69, ptr %56, i64 8, %"github.com/goplus/llgo/internal/runtime.String" %73, i1 false) + %75 = alloca %"github.com/goplus/llgo/internal/runtime.String", align 8 + %76 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %75, i32 0, i32 0 + store ptr @12, ptr %76, align 8 + %77 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %75, i32 0, i32 1 + store i64 4, ptr %77, align 4 + %78 = load %"github.com/goplus/llgo/internal/runtime.String", ptr %75, align 8 + %79 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 112) + %80 = getelementptr %"github.com/goplus/llgo/internal/abi.StructField", ptr %79, i64 0 + store %"github.com/goplus/llgo/internal/abi.StructField" %65, ptr %80, align 8 + %81 = getelementptr %"github.com/goplus/llgo/internal/abi.StructField", ptr %79, i64 1 + store %"github.com/goplus/llgo/internal/abi.StructField" %74, ptr %81, align 8 + %82 = alloca %"github.com/goplus/llgo/internal/runtime.Slice", align 8 + %83 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.Slice", ptr %82, i32 0, i32 0 + store ptr %79, ptr %83, align 8 + %84 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.Slice", ptr %82, i32 0, i32 1 + store i64 2, ptr %84, align 4 + %85 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.Slice", ptr %82, i32 0, i32 2 + store i64 2, ptr %85, align 4 + %86 = load %"github.com/goplus/llgo/internal/runtime.Slice", ptr %82, align 8 + %87 = call ptr @"github.com/goplus/llgo/internal/runtime.Struct"(%"github.com/goplus/llgo/internal/runtime.String" %78, i64 16, %"github.com/goplus/llgo/internal/runtime.Slice" %86) + store ptr %87, ptr @"main.struct$Ci43nzKYkRLddRL_N4mkykxLXfJlqJGS5n04LKThPNo", align 8 + %88 = load ptr, ptr @"main.struct$Ci43nzKYkRLddRL_N4mkykxLXfJlqJGS5n04LKThPNo", align 8 + %89 = alloca %"github.com/goplus/llgo/internal/runtime.String", align 8 + %90 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %89, i32 0, i32 0 + store ptr @13, ptr %90, align 8 + %91 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %89, i32 0, i32 1 + store i64 4, ptr %91, align 4 + %92 = load %"github.com/goplus/llgo/internal/runtime.String", ptr %89, align 8 + %93 = alloca %"github.com/goplus/llgo/internal/runtime.String", align 8 + %94 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %93, i32 0, i32 0 + store ptr @14, ptr %94, align 8 + %95 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %93, i32 0, i32 1 + store i64 8, ptr %95, align 4 + %96 = load %"github.com/goplus/llgo/internal/runtime.String", ptr %93, align 8 + call void @"github.com/goplus/llgo/internal/runtime.InitNamed"(ptr %54, %"github.com/goplus/llgo/internal/runtime.String" %92, %"github.com/goplus/llgo/internal/runtime.String" %96, ptr %88, { ptr, i64, i64 } zeroinitializer, { ptr, i64, i64 } zeroinitializer) ret void + +_llgo_11: ; preds = %_llgo_9 + %97 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 0) + %98 = alloca %"github.com/goplus/llgo/internal/runtime.Slice", align 8 + %99 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.Slice", ptr %98, i32 0, i32 0 + store ptr %97, ptr %99, align 8 + %100 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.Slice", ptr %98, i32 0, i32 1 + store i64 0, ptr %100, align 4 + %101 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.Slice", ptr %98, i32 0, i32 2 + store i64 0, ptr %101, align 4 + %102 = load %"github.com/goplus/llgo/internal/runtime.Slice", ptr %98, align 8 + %103 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 8) + %104 = getelementptr ptr, ptr %103, i64 0 + store ptr %51, ptr %104, align 8 + %105 = alloca %"github.com/goplus/llgo/internal/runtime.Slice", align 8 + %106 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.Slice", ptr %105, i32 0, i32 0 + store ptr %103, ptr %106, align 8 + %107 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.Slice", ptr %105, i32 0, i32 1 + store i64 1, ptr %107, align 4 + %108 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.Slice", ptr %105, i32 0, i32 2 + store i64 1, ptr %108, align 4 + %109 = load %"github.com/goplus/llgo/internal/runtime.Slice", ptr %105, align 8 + %110 = call ptr @"github.com/goplus/llgo/internal/runtime.Func"(%"github.com/goplus/llgo/internal/runtime.Slice" %102, %"github.com/goplus/llgo/internal/runtime.Slice" %109, i1 false) + store ptr %110, ptr @"_llgo_func$NfGSLZ1QiKRoFkKeqYSXE5hUU5bpeteSJKrbMNUzYRE", align 8 + br label %_llgo_12 + +_llgo_12: ; preds = %_llgo_11, %_llgo_9 + %111 = load ptr, ptr @"_llgo_func$NfGSLZ1QiKRoFkKeqYSXE5hUU5bpeteSJKrbMNUzYRE", align 8 + %112 = alloca %"github.com/goplus/llgo/internal/abi.Method", align 8 + %113 = getelementptr inbounds %"github.com/goplus/llgo/internal/abi.Method", ptr %112, i32 0, i32 0 + store %"github.com/goplus/llgo/internal/runtime.String" %50, ptr %113, align 8 + %114 = getelementptr inbounds %"github.com/goplus/llgo/internal/abi.Method", ptr %112, i32 0, i32 1 + store ptr %111, ptr %114, align 8 + %115 = getelementptr inbounds %"github.com/goplus/llgo/internal/abi.Method", ptr %112, i32 0, i32 2 + store ptr @"(*github.com/goplus/llgo/cl/internal/foo.Foo).Pb", ptr %115, align 8 + %116 = getelementptr inbounds %"github.com/goplus/llgo/internal/abi.Method", ptr %112, i32 0, i32 3 + store ptr @"(*github.com/goplus/llgo/cl/internal/foo.Foo).Pb", ptr %116, align 8 + %117 = load %"github.com/goplus/llgo/internal/abi.Method", ptr %112, align 8 + %118 = alloca %"github.com/goplus/llgo/internal/abi.Method", align 8 + %119 = getelementptr inbounds %"github.com/goplus/llgo/internal/abi.Method", ptr %118, i32 0, i32 0 + store %"github.com/goplus/llgo/internal/runtime.String" %50, ptr %119, align 8 + %120 = getelementptr inbounds %"github.com/goplus/llgo/internal/abi.Method", ptr %118, i32 0, i32 1 + store ptr %111, ptr %120, align 8 + %121 = getelementptr inbounds %"github.com/goplus/llgo/internal/abi.Method", ptr %118, i32 0, i32 2 + store ptr @"(*github.com/goplus/llgo/cl/internal/foo.Foo).Pb", ptr %121, align 8 + %122 = getelementptr inbounds %"github.com/goplus/llgo/internal/abi.Method", ptr %118, i32 0, i32 3 + store ptr @"(github.com/goplus/llgo/cl/internal/foo.Foo).Pb", ptr %122, align 8 + %123 = load %"github.com/goplus/llgo/internal/abi.Method", ptr %118, align 8 + %124 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 40) + %125 = getelementptr %"github.com/goplus/llgo/internal/abi.Method", ptr %124, i64 0 + store %"github.com/goplus/llgo/internal/abi.Method" %123, ptr %125, align 8 + %126 = alloca %"github.com/goplus/llgo/internal/runtime.Slice", align 8 + %127 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.Slice", ptr %126, i32 0, i32 0 + store ptr %124, ptr %127, align 8 + %128 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.Slice", ptr %126, i32 0, i32 1 + store i64 1, ptr %128, align 4 + %129 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.Slice", ptr %126, i32 0, i32 2 + store i64 1, ptr %129, align 4 + %130 = load %"github.com/goplus/llgo/internal/runtime.Slice", ptr %126, align 8 + %131 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 40) + %132 = getelementptr %"github.com/goplus/llgo/internal/abi.Method", ptr %131, i64 0 + store %"github.com/goplus/llgo/internal/abi.Method" %117, ptr %132, align 8 + %133 = alloca %"github.com/goplus/llgo/internal/runtime.Slice", align 8 + %134 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.Slice", ptr %133, i32 0, i32 0 + store ptr %131, ptr %134, align 8 + %135 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.Slice", ptr %133, i32 0, i32 1 + store i64 1, ptr %135, align 4 + %136 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.Slice", ptr %133, i32 0, i32 2 + store i64 1, ptr %136, align 4 + %137 = load %"github.com/goplus/llgo/internal/runtime.Slice", ptr %133, align 8 + %138 = alloca %"github.com/goplus/llgo/internal/runtime.String", align 8 + %139 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %138, i32 0, i32 0 + store ptr @6, ptr %139, align 8 + %140 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %138, i32 0, i32 1 + store i64 38, ptr %140, align 4 + %141 = load %"github.com/goplus/llgo/internal/runtime.String", ptr %138, align 8 + %142 = alloca %"github.com/goplus/llgo/internal/runtime.String", align 8 + %143 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %142, i32 0, i32 0 + store ptr @7, ptr %143, align 8 + %144 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %142, i32 0, i32 1 + store i64 42, ptr %144, align 4 + %145 = load %"github.com/goplus/llgo/internal/runtime.String", ptr %142, align 8 + call void @"github.com/goplus/llgo/internal/runtime.InitNamed"(ptr %2, %"github.com/goplus/llgo/internal/runtime.String" %141, %"github.com/goplus/llgo/internal/runtime.String" %145, ptr %46, %"github.com/goplus/llgo/internal/runtime.Slice" %130, %"github.com/goplus/llgo/internal/runtime.Slice" %137) + br label %_llgo_10 } +declare ptr @"github.com/goplus/llgo/internal/runtime.NewNamed"(i64, i64, i64) + +declare ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64) + +declare ptr @"github.com/goplus/llgo/internal/runtime.PointerTo"(ptr) + declare ptr @"github.com/goplus/llgo/internal/runtime.Struct"(%"github.com/goplus/llgo/internal/runtime.String", i64, %"github.com/goplus/llgo/internal/runtime.Slice") declare %"github.com/goplus/llgo/internal/abi.StructField" @"github.com/goplus/llgo/internal/runtime.StructField"(%"github.com/goplus/llgo/internal/runtime.String", ptr, i64, %"github.com/goplus/llgo/internal/runtime.String", i1) -declare ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64) +declare ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64) + +declare void @"github.com/goplus/llgo/internal/runtime.InitNamed"(ptr, %"github.com/goplus/llgo/internal/runtime.String", %"github.com/goplus/llgo/internal/runtime.String", ptr, %"github.com/goplus/llgo/internal/runtime.Slice", %"github.com/goplus/llgo/internal/runtime.Slice") declare ptr @"github.com/goplus/llgo/internal/runtime.Func"(%"github.com/goplus/llgo/internal/runtime.Slice", %"github.com/goplus/llgo/internal/runtime.Slice", i1) -define void @"main.init$abi3"() { -_llgo_0: - %0 = load ptr, ptr @"*_llgo_byte", align 8 - %1 = icmp eq ptr %0, null - br i1 %1, label %_llgo_1, label %_llgo_2 +declare ptr @"(*github.com/goplus/llgo/cl/internal/foo.Foo).Pb"(ptr) -_llgo_1: ; preds = %_llgo_0 - %2 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 8) - %3 = call ptr @"github.com/goplus/llgo/internal/runtime.PointerTo"(ptr %2) - store ptr %3, ptr @"*_llgo_byte", align 8 - br label %_llgo_2 +declare ptr @"(github.com/goplus/llgo/cl/internal/foo.Foo).Pb"(%"github.com/goplus/llgo/cl/internal/foo.Foo") -_llgo_2: ; preds = %_llgo_1, %_llgo_0 - ret void -} +declare void @"github.com/goplus/llgo/cl/internal/foo.init"() -declare ptr @"github.com/goplus/llgo/internal/runtime.PointerTo"(ptr) +declare void @"github.com/goplus/llgo/internal/runtime.init"() + +declare ptr @"github.com/goplus/llgo/internal/runtime.Zeroinit"(ptr, i64) + +declare void @"github.com/goplus/llgo/internal/runtime.PrintPointer"(ptr) + +declare void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8) + +declare void @"github.com/goplus/llgo/internal/runtime.PrintFloat"(double) + +declare void @"github.com/goplus/llgo/internal/runtime.PrintString"(%"github.com/goplus/llgo/internal/runtime.String") + +declare void @"github.com/goplus/llgo/internal/runtime.PrintBool"(i1) diff --git a/cl/_testrt/any/out.ll b/cl/_testrt/any/out.ll index 50a3b9db4..d2f59f3fb 100644 --- a/cl/_testrt/any/out.ll +++ b/cl/_testrt/any/out.ll @@ -6,7 +6,9 @@ source_filename = "main" @"main.init$guard" = global ptr null @"*_llgo_int8" = linkonce global ptr null +@_llgo_int8 = linkonce global ptr null @0 = private unnamed_addr constant [22 x i8] c"type assertion failed\00", align 1 +@_llgo_int = linkonce global ptr null @1 = private unnamed_addr constant [22 x i8] c"type assertion failed\00", align 1 @__llgo_argc = global ptr null @__llgo_argv = global ptr null @@ -38,7 +40,7 @@ _llgo_2: ; preds = %_llgo_0 define i64 @main.incVal(%"github.com/goplus/llgo/internal/runtime.eface" %0) { _llgo_0: %1 = extractvalue %"github.com/goplus/llgo/internal/runtime.eface" %0, 0 - %2 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 2) + %2 = load ptr, ptr @_llgo_int, align 8 %3 = icmp eq ptr %1, %2 br i1 %3, label %_llgo_1, label %_llgo_2 @@ -87,7 +89,7 @@ _llgo_0: store ptr @3, ptr %5, align 8 %6 = load %"github.com/goplus/llgo/internal/runtime.eface", ptr %3, align 8 %7 = call ptr @main.hi(%"github.com/goplus/llgo/internal/runtime.eface" %6) - %8 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 2) + %8 = load ptr, ptr @_llgo_int, align 8 %9 = alloca %"github.com/goplus/llgo/internal/runtime.eface", align 8 %10 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %9, i32 0, i32 0 store ptr %8, ptr %10, align 8 @@ -99,28 +101,48 @@ _llgo_0: ret i32 0 } -declare void @"github.com/goplus/llgo/internal/runtime.TracePanic"(%"github.com/goplus/llgo/internal/runtime.eface") - -declare ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64) - -declare void @"github.com/goplus/llgo/internal/runtime.init"() - -declare i32 @printf(ptr, ...) - define void @"main.init$abi"() { _llgo_0: - %0 = load ptr, ptr @"*_llgo_int8", align 8 + %0 = load ptr, ptr @_llgo_int8, align 8 %1 = icmp eq ptr %0, null br i1 %1, label %_llgo_1, label %_llgo_2 _llgo_1: ; preds = %_llgo_0 %2 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 3) - %3 = call ptr @"github.com/goplus/llgo/internal/runtime.PointerTo"(ptr %2) - store ptr %3, ptr @"*_llgo_int8", align 8 + store ptr %2, ptr @_llgo_int8, align 8 br label %_llgo_2 _llgo_2: ; preds = %_llgo_1, %_llgo_0 + %3 = load ptr, ptr @_llgo_int8, align 8 + %4 = load ptr, ptr @"*_llgo_int8", align 8 + %5 = icmp eq ptr %4, null + br i1 %5, label %_llgo_3, label %_llgo_4 + +_llgo_3: ; preds = %_llgo_2 + %6 = call ptr @"github.com/goplus/llgo/internal/runtime.PointerTo"(ptr %3) + store ptr %6, ptr @"*_llgo_int8", align 8 + br label %_llgo_4 + +_llgo_4: ; preds = %_llgo_3, %_llgo_2 + %7 = load ptr, ptr @_llgo_int, align 8 + %8 = icmp eq ptr %7, null + br i1 %8, label %_llgo_5, label %_llgo_6 + +_llgo_5: ; preds = %_llgo_4 + %9 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 2) + store ptr %9, ptr @_llgo_int, align 8 + br label %_llgo_6 + +_llgo_6: ; preds = %_llgo_5, %_llgo_4 ret void } +declare ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64) + declare ptr @"github.com/goplus/llgo/internal/runtime.PointerTo"(ptr) + +declare void @"github.com/goplus/llgo/internal/runtime.TracePanic"(%"github.com/goplus/llgo/internal/runtime.eface") + +declare void @"github.com/goplus/llgo/internal/runtime.init"() + +declare i32 @printf(ptr, ...) diff --git a/cl/_testrt/builtin/out.ll b/cl/_testrt/builtin/out.ll index c0a05db6e..8045b41c2 100644 --- a/cl/_testrt/builtin/out.ll +++ b/cl/_testrt/builtin/out.ll @@ -16,6 +16,7 @@ source_filename = "main" @2 = 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 @4 = private unnamed_addr constant [4 x i8] c"def\00", align 1 +@_llgo_int = linkonce global ptr null @5 = private unnamed_addr constant [5 x i8] c"ABCD\00", align 1 @6 = private unnamed_addr constant [8 x i8] c"\E4\B8\ADabcd\00", align 1 @7 = private unnamed_addr constant [8 x i8] c"\E4\B8\ADabcd\00", align 1 @@ -85,6 +86,7 @@ _llgo_0: _llgo_1: ; preds = %_llgo_0 store i1 true, ptr @"main.init$guard", align 1 + call void @"main.init$abi"() store i64 9223372036854775807, ptr @main.a, align 4 store i64 -9223372036854775808, ptr @main.b, align 4 store i64 -1, ptr @main.n, align 4 @@ -323,7 +325,7 @@ _llgo_0: call void @"github.com/goplus/llgo/internal/runtime.PrintSlice"(%"github.com/goplus/llgo/internal/runtime.Slice" %122) call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 10) %123 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocZ"(i64 16) - %124 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 2) + %124 = load ptr, ptr @_llgo_int, align 8 %125 = alloca %"github.com/goplus/llgo/internal/runtime.eface", align 8 %126 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %125, i32 0, i32 0 store ptr %124, ptr %126, align 8 @@ -641,6 +643,21 @@ declare void @"github.com/goplus/llgo/internal/runtime.PrintString"(%"github.com declare %"github.com/goplus/llgo/internal/runtime.Slice" @"github.com/goplus/llgo/internal/runtime.SliceAppend"(%"github.com/goplus/llgo/internal/runtime.Slice", ptr, i64, i64) +define void @"main.init$abi"() { +_llgo_0: + %0 = load ptr, ptr @_llgo_int, align 8 + %1 = icmp eq ptr %0, null + br i1 %1, label %_llgo_1, label %_llgo_2 + +_llgo_1: ; preds = %_llgo_0 + %2 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 2) + store ptr %2, ptr @_llgo_int, align 8 + br label %_llgo_2 + +_llgo_2: ; preds = %_llgo_1, %_llgo_0 + ret void +} + declare ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64) declare void @"github.com/goplus/llgo/internal/runtime.PrintBool"(i1) diff --git a/cl/_testrt/cast/out.ll b/cl/_testrt/cast/out.ll index 1f82dabd5..1f6b0f303 100644 --- a/cl/_testrt/cast/out.ll +++ b/cl/_testrt/cast/out.ll @@ -6,6 +6,7 @@ source_filename = "main" @"main.init$guard" = global ptr null @0 = private unnamed_addr constant [6 x i8] c"error\00", align 1 +@_llgo_string = linkonce global ptr null @1 = private unnamed_addr constant [6 x i8] c"error\00", align 1 @2 = private unnamed_addr constant [6 x i8] c"error\00", align 1 @3 = private unnamed_addr constant [6 x i8] c"error\00", align 1 @@ -34,7 +35,7 @@ _llgo_1: ; preds = %_llgo_0 %6 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %4, i32 0, i32 1 store i64 5, ptr %6, align 4 %7 = load %"github.com/goplus/llgo/internal/runtime.String", ptr %4, align 8 - %8 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 24) + %8 = load ptr, ptr @_llgo_string, align 8 %9 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 16) store %"github.com/goplus/llgo/internal/runtime.String" %7, ptr %9, align 8 %10 = alloca %"github.com/goplus/llgo/internal/runtime.eface", align 8 @@ -63,7 +64,7 @@ _llgo_1: ; preds = %_llgo_0 %6 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %4, i32 0, i32 1 store i64 5, ptr %6, align 4 %7 = load %"github.com/goplus/llgo/internal/runtime.String", ptr %4, align 8 - %8 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 24) + %8 = load ptr, ptr @_llgo_string, align 8 %9 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 16) store %"github.com/goplus/llgo/internal/runtime.String" %7, ptr %9, align 8 %10 = alloca %"github.com/goplus/llgo/internal/runtime.eface", align 8 @@ -92,7 +93,7 @@ _llgo_1: ; preds = %_llgo_0 %6 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %4, i32 0, i32 1 store i64 5, ptr %6, align 4 %7 = load %"github.com/goplus/llgo/internal/runtime.String", ptr %4, align 8 - %8 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 24) + %8 = load ptr, ptr @_llgo_string, align 8 %9 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 16) store %"github.com/goplus/llgo/internal/runtime.String" %7, ptr %9, align 8 %10 = alloca %"github.com/goplus/llgo/internal/runtime.eface", align 8 @@ -121,7 +122,7 @@ _llgo_1: ; preds = %_llgo_0 %6 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %4, i32 0, i32 1 store i64 5, ptr %6, align 4 %7 = load %"github.com/goplus/llgo/internal/runtime.String", ptr %4, align 8 - %8 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 24) + %8 = load ptr, ptr @_llgo_string, align 8 %9 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 16) store %"github.com/goplus/llgo/internal/runtime.String" %7, ptr %9, align 8 %10 = alloca %"github.com/goplus/llgo/internal/runtime.eface", align 8 @@ -150,7 +151,7 @@ _llgo_1: ; preds = %_llgo_0 %6 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %4, i32 0, i32 1 store i64 5, ptr %6, align 4 %7 = load %"github.com/goplus/llgo/internal/runtime.String", ptr %4, align 8 - %8 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 24) + %8 = load ptr, ptr @_llgo_string, align 8 %9 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 16) store %"github.com/goplus/llgo/internal/runtime.String" %7, ptr %9, align 8 %10 = alloca %"github.com/goplus/llgo/internal/runtime.eface", align 8 @@ -179,7 +180,7 @@ _llgo_1: ; preds = %_llgo_0 %6 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %4, i32 0, i32 1 store i64 5, ptr %6, align 4 %7 = load %"github.com/goplus/llgo/internal/runtime.String", ptr %4, align 8 - %8 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 24) + %8 = load ptr, ptr @_llgo_string, align 8 %9 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 16) store %"github.com/goplus/llgo/internal/runtime.String" %7, ptr %9, align 8 %10 = alloca %"github.com/goplus/llgo/internal/runtime.eface", align 8 @@ -208,7 +209,7 @@ _llgo_1: ; preds = %_llgo_0 %6 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %4, i32 0, i32 1 store i64 5, ptr %6, align 4 %7 = load %"github.com/goplus/llgo/internal/runtime.String", ptr %4, align 8 - %8 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 24) + %8 = load ptr, ptr @_llgo_string, align 8 %9 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 16) store %"github.com/goplus/llgo/internal/runtime.String" %7, ptr %9, align 8 %10 = alloca %"github.com/goplus/llgo/internal/runtime.eface", align 8 @@ -237,7 +238,7 @@ _llgo_1: ; preds = %_llgo_0 %6 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %4, i32 0, i32 1 store i64 5, ptr %6, align 4 %7 = load %"github.com/goplus/llgo/internal/runtime.String", ptr %4, align 8 - %8 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 24) + %8 = load ptr, ptr @_llgo_string, align 8 %9 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 16) store %"github.com/goplus/llgo/internal/runtime.String" %7, ptr %9, align 8 %10 = alloca %"github.com/goplus/llgo/internal/runtime.eface", align 8 @@ -266,7 +267,7 @@ _llgo_1: ; preds = %_llgo_0 %6 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %4, i32 0, i32 1 store i64 5, ptr %6, align 4 %7 = load %"github.com/goplus/llgo/internal/runtime.String", ptr %4, align 8 - %8 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 24) + %8 = load ptr, ptr @_llgo_string, align 8 %9 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 16) store %"github.com/goplus/llgo/internal/runtime.String" %7, ptr %9, align 8 %10 = alloca %"github.com/goplus/llgo/internal/runtime.eface", align 8 @@ -295,7 +296,7 @@ _llgo_1: ; preds = %_llgo_0 %6 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %4, i32 0, i32 1 store i64 5, ptr %6, align 4 %7 = load %"github.com/goplus/llgo/internal/runtime.String", ptr %4, align 8 - %8 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 24) + %8 = load ptr, ptr @_llgo_string, align 8 %9 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 16) store %"github.com/goplus/llgo/internal/runtime.String" %7, ptr %9, align 8 %10 = alloca %"github.com/goplus/llgo/internal/runtime.eface", align 8 @@ -324,7 +325,7 @@ _llgo_1: ; preds = %_llgo_0 %6 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %4, i32 0, i32 1 store i64 5, ptr %6, align 4 %7 = load %"github.com/goplus/llgo/internal/runtime.String", ptr %4, align 8 - %8 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 24) + %8 = load ptr, ptr @_llgo_string, align 8 %9 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 16) store %"github.com/goplus/llgo/internal/runtime.String" %7, ptr %9, align 8 %10 = alloca %"github.com/goplus/llgo/internal/runtime.eface", align 8 @@ -353,7 +354,7 @@ _llgo_1: ; preds = %_llgo_0 %6 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %4, i32 0, i32 1 store i64 5, ptr %6, align 4 %7 = load %"github.com/goplus/llgo/internal/runtime.String", ptr %4, align 8 - %8 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 24) + %8 = load ptr, ptr @_llgo_string, align 8 %9 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 16) store %"github.com/goplus/llgo/internal/runtime.String" %7, ptr %9, align 8 %10 = alloca %"github.com/goplus/llgo/internal/runtime.eface", align 8 @@ -377,7 +378,7 @@ _llgo_3: ; preds = %_llgo_2 %18 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %16, i32 0, i32 1 store i64 5, ptr %18, align 4 %19 = load %"github.com/goplus/llgo/internal/runtime.String", ptr %16, align 8 - %20 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 24) + %20 = load ptr, ptr @_llgo_string, align 8 %21 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 16) store %"github.com/goplus/llgo/internal/runtime.String" %19, ptr %21, align 8 %22 = alloca %"github.com/goplus/llgo/internal/runtime.eface", align 8 @@ -400,6 +401,7 @@ _llgo_0: _llgo_1: ; preds = %_llgo_0 store i1 true, ptr @"main.init$guard", align 1 + call void @"main.init$abi"() br label %_llgo_2 _llgo_2: ; preds = %_llgo_1, %_llgo_0 @@ -470,6 +472,21 @@ _llgo_0: ret i32 0 } +define void @"main.init$abi"() { +_llgo_0: + %0 = load ptr, ptr @_llgo_string, align 8 + %1 = icmp eq ptr %0, null + br i1 %1, label %_llgo_1, label %_llgo_2 + +_llgo_1: ; preds = %_llgo_0 + %2 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 24) + store ptr %2, ptr @_llgo_string, align 8 + br label %_llgo_2 + +_llgo_2: ; preds = %_llgo_1, %_llgo_0 + ret void +} + declare ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64) declare ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64) diff --git a/cl/_testrt/panic/out.ll b/cl/_testrt/panic/out.ll index 362b3bb2b..4bac30165 100644 --- a/cl/_testrt/panic/out.ll +++ b/cl/_testrt/panic/out.ll @@ -8,6 +8,7 @@ source_filename = "main" @__llgo_argc = global ptr null @__llgo_argv = global ptr null @0 = private unnamed_addr constant [14 x i8] c"panic message\00", align 1 +@_llgo_string = linkonce global ptr null define void @main.init() { _llgo_0: @@ -16,6 +17,7 @@ _llgo_0: _llgo_1: ; preds = %_llgo_0 store i1 true, ptr @"main.init$guard", align 1 + call void @"main.init$abi"() br label %_llgo_2 _llgo_2: ; preds = %_llgo_1, %_llgo_0 @@ -34,7 +36,7 @@ _llgo_0: %4 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %2, i32 0, i32 1 store i64 13, ptr %4, align 4 %5 = load %"github.com/goplus/llgo/internal/runtime.String", ptr %2, align 8 - %6 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 24) + %6 = load ptr, ptr @_llgo_string, align 8 %7 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 16) store %"github.com/goplus/llgo/internal/runtime.String" %5, ptr %7, align 8 %8 = alloca %"github.com/goplus/llgo/internal/runtime.eface", align 8 @@ -49,6 +51,21 @@ _llgo_0: declare void @"github.com/goplus/llgo/internal/runtime.init"() +define void @"main.init$abi"() { +_llgo_0: + %0 = load ptr, ptr @_llgo_string, align 8 + %1 = icmp eq ptr %0, null + br i1 %1, label %_llgo_1, label %_llgo_2 + +_llgo_1: ; preds = %_llgo_0 + %2 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 24) + store ptr %2, ptr @_llgo_string, align 8 + br label %_llgo_2 + +_llgo_2: ; preds = %_llgo_1, %_llgo_0 + ret void +} + declare ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64) declare ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64) diff --git a/internal/abi/llgo_autogen.lla b/internal/abi/llgo_autogen.lla index f5f43eca1..35581290b 100644 Binary files a/internal/abi/llgo_autogen.lla and b/internal/abi/llgo_autogen.lla differ diff --git a/internal/abi/type.go b/internal/abi/type.go index dc1d82571..2c8662385 100644 --- a/internal/abi/type.go +++ b/internal/abi/type.go @@ -134,6 +134,12 @@ const ( // TFlagRegularMemory means that equal and hash functions can treat // this type as a single region of t.size bytes. TFlagRegularMemory TFlag = 1 << 3 + + // TFlagVariadic means a funcType with variadic parameters + TFlagVariadic TFlag = 1 << 4 + + // TFlagUninited means this type is not fully initialized. + TFlagUninited TFlag = 1 << 7 ) // ----------------------------------------------------------------------------- @@ -186,35 +192,15 @@ type ChanType struct { } // funcType represents a function type. -// -// A *Type for each in and out parameter is stored in an array that -// directly follows the funcType (and possibly its uncommonType). So -// a function type with one method, one input, and one output is: -// -// struct { -// funcType -// uncommonType -// [2]*rtype // [0] is in, [1] is out -// } type FuncType struct { Type - InCount uint16 - OutCount uint16 // top bit is set if last input parameter is ... -} - -// In returns the number of input parameters of a function type. -func (p *FuncType) In() int { - return int(p.InCount) -} - -// Out returns the number of output results of a function type. -func (p *FuncType) Out() int { - return int(p.OutCount &^ (1 << 15)) + In []*Type + Out []*Type } // Variadic reports whether the function type is variadic. func (p *FuncType) Variadic() bool { - return p.OutCount&(1<<15) != 0 + return p.TFlag&TFlagVariadic != 0 } type StructField struct { @@ -304,6 +290,14 @@ func (t *Type) Align() int { return int(t.Align_) } func (t *Type) FieldAlign() int { return int(t.FieldAlign_) } +// Name returns the name of type t. +func (t *Type) Name() string { + if t.TFlag&TFlagExtraStar != 0 { + return "*" + t.Str_ + } + return t.Str_ +} + func (t *Type) Common() *Type { return t } diff --git a/internal/runtime/llgo_autogen.lla b/internal/runtime/llgo_autogen.lla index d723b748b..841d6f08b 100644 Binary files a/internal/runtime/llgo_autogen.lla and b/internal/runtime/llgo_autogen.lla differ diff --git a/internal/runtime/z_face.go b/internal/runtime/z_face.go index eccb20390..14243461c 100644 --- a/internal/runtime/z_face.go +++ b/internal/runtime/z_face.go @@ -102,46 +102,50 @@ func hdrSizeOf(kind abi.Kind) uintptr { return typeHdrSize } -// Named returns a named type. -func Named(pkgPath, name string, underlying *Type, methods []Method) *Type { +// NewNamed returns an uninitialized named type. +func NewNamed(kind abi.Kind, methods, ptrMethods int) *Type { + ret := newUninitedNamed(kind, methods) + ret.PtrToThis_ = newUninitedNamed(abi.Pointer, ptrMethods) + return ret +} + +// InitNamed initializes an uninitialized named type. +func InitNamed(ret *Type, pkgPath, name string, underlying *Type, methods, ptrMethods []Method) { + ptr := ret.PtrToThis_ + doInitNamed(ret, pkgPath, name, underlying, methods) + doInitNamed(ptr, pkgPath, name, newPointer(ret), ptrMethods) + ret.PtrToThis_ = ptr + ptr.TFlag |= abi.TFlagExtraStar +} + +func newUninitedNamed(kind abi.Kind, methods int) *Type { + size := hdrSizeOf(kind) + uncommonTypeHdrSize + uintptr(methods)*methodSize + ret := (*Type)(AllocU(size)) + ret.Kind_ = uint8(kind) + ret.TFlag = abi.TFlagUninited + return ret +} + +func doInitNamed(ret *Type, pkgPath, name string, underlying *Type, methods []Method) { tflag := underlying.TFlag if tflag&abi.TFlagUncommon != 0 { panic("runtime: underlying type is already named") } - kind := underlying.Kind() - n := len(methods) - if kind == abi.Interface { - if n > 0 { - panic("runtime: interface type cannot have methods") - } - ret := *underlying.InterfaceType() - ret.PkgPath_ = pkgPath - ret.Str_ = name - return &ret.Type + kind := abi.Kind(ret.Kind_) + if ret.TFlag != abi.TFlagUninited || kind != underlying.Kind() { + panic("initNamed: unexpected named type") } + ptr := unsafe.Pointer(ret) baseSize := hdrSizeOf(kind) - extraSize := uintptr(0) - if kind == abi.Func { - f := underlying.FuncType() - extraSize = uintptr(f.In()+f.Out()) * pointerSize - } - - size := baseSize + extraSize - if n > 0 || pkgPath != "" { - size += uncommonTypeHdrSize + uintptr(n)*methodSize - tflag |= abi.TFlagUncommon - } - - ptr := AllocU(size) c.Memcpy(ptr, unsafe.Pointer(underlying), baseSize) - ret := (*Type)(ptr) - ret.TFlag = tflag | abi.TFlagNamed + ret.TFlag = tflag | abi.TFlagNamed | abi.TFlagUncommon ret.Str_ = name - xcount := 0 + n := len(methods) + xcount := uint16(0) for _, m := range methods { if !m.Exported() { break @@ -151,52 +155,40 @@ func Named(pkgPath, name string, underlying *Type, methods []Method) *Type { uncommon := (*abi.UncommonType)(c.Advance(ptr, int(baseSize))) uncommon.PkgPath_ = pkgPath uncommon.Mcount = uint16(n) - uncommon.Xcount = uint16(xcount) - uncommon.Moff = uint32(uncommonTypeHdrSize + extraSize) + uncommon.Xcount = xcount + uncommon.Moff = uint32(uncommonTypeHdrSize) extraOff := int(baseSize + uncommonTypeHdrSize) - if extraSize > 0 { - src := c.Advance(unsafe.Pointer(underlying), int(baseSize)) - dest := c.Advance(unsafe.Pointer(ptr), extraOff) - c.Memcpy(dest, src, extraSize) - extraOff += int(extraSize) - } - data := (*abi.Method)(c.Advance(ptr, extraOff)) copy(unsafe.Slice(data, n), methods) - return ret } // Func returns a function type. func Func(in, out []*Type, variadic bool) *FuncType { - n := len(in) + len(out) - ptr := AllocU(funcTypeHdrSize + uintptr(n)*pointerSize) - c.Memset(ptr, 0, funcTypeHdrSize) - - ret := (*abi.FuncType)(ptr) - ret.Size_ = pointerSize - ret.Hash = uint32(abi.Func) // TODO(xsw): hash - ret.Kind_ = uint8(abi.Func) - ret.InCount = uint16(len(in)) - ret.OutCount = uint16(len(out)) + ret := &FuncType{ + Type: Type{ + Size_: unsafe.Sizeof(uintptr(0)), + Hash: uint32(abi.Func), // TODO(xsw): hash + Kind_: uint8(abi.Func), + }, + In: in, + Out: out, + } if variadic { - ret.OutCount |= 1 << 15 + ret.TFlag |= abi.TFlagVariadic } - - data := (**Type)(c.Advance(ptr, int(funcTypeHdrSize))) - params := unsafe.Slice(data, n) - copy(params, in) - copy(params[len(in):], out) return ret } // Interface returns an interface type. -func Interface(pkgPath string, methods []Imethod) *InterfaceType { +// Don't call NewNamed for named interface type. +func Interface(pkgPath, name string, methods []Imethod) *InterfaceType { ret := &abi.InterfaceType{ Type: Type{ Size_: unsafe.Sizeof(eface{}), Hash: uint32(abi.Interface), // TODO(xsw): hash Kind_: uint8(abi.Interface), + Str_: name, }, PkgPath_: pkgPath, Methods: methods, @@ -239,7 +231,6 @@ func findMethod(mthds []abi.Method, im abi.Imethod) abi.Text { mName := m.Name_ if mName >= imName { if mName == imName && m.Mtyp_ == im.Typ_ { - println("==> findMethod", mName, m.Ifn_) return m.Ifn_ } break diff --git a/internal/runtime/z_type.go b/internal/runtime/z_type.go index 08c11b036..8d6f82615 100644 --- a/internal/runtime/z_type.go +++ b/internal/runtime/z_type.go @@ -116,20 +116,25 @@ func Struct(pkgPath string, size uintptr, fields ...abi.StructField) *Type { func PointerTo(elem *Type) *Type { ret := elem.PtrToThis_ if ret == nil { - ptr := &abi.PtrType{ - Type: Type{ - Size_: unsafe.Sizeof(uintptr(0)), - Hash: uint32(abi.Pointer), // TODO(xsw): hash - Kind_: uint8(abi.Pointer), - }, - Elem: elem, - } - ret = &ptr.Type + ret = newPointer(elem) elem.PtrToThis_ = ret } return ret } +func newPointer(elem *Type) *Type { + ptr := &abi.PtrType{ + Type: Type{ + Size_: unsafe.Sizeof(uintptr(0)), + Hash: uint32(abi.Pointer), // TODO(xsw): hash + Kind_: uint8(abi.Pointer), + }, + Elem: elem, + } + return &ptr.Type +} + +// SliceOf returns the slice type with element elem. func SliceOf(elem *Type) *Type { ret := &abi.SliceType{ Type: Type{ @@ -142,6 +147,7 @@ func SliceOf(elem *Type) *Type { return &ret.Type } +// ArrayOf returns the array type with element elem and length. func ArrayOf(length uintptr, elem *Type) *Type { ret := &abi.ArrayType{ Type: Type{ diff --git a/ssa/abi/abi.go b/ssa/abi/abi.go index 6d6fd74f9..4289d6bdc 100644 --- a/ssa/abi/abi.go +++ b/ssa/abi/abi.go @@ -40,19 +40,43 @@ func BasicKind(t *types.Basic) abi.Kind { return abi.Kind(kind) } +func UnderlyingKind(t types.Type) abi.Kind { + switch t := t.(type) { + case *types.Basic: + return BasicKind(t) + case *types.Pointer: + return abi.Pointer + case *types.Slice: + return abi.Slice + case *types.Signature: + return abi.Func + case *types.Interface: + return abi.Interface + case *types.Struct: + return abi.Struct + case *types.Map: + return abi.Map + case *types.Array: + return abi.Array + case *types.Chan: + return abi.Chan + } + panic("todo") +} + // ----------------------------------------------------------------------------- -type Kind int +type DataKind int const ( - Invalid Kind = iota - Indirect // allocate memory for the value - Pointer // store a pointer value directly in the interface value - Integer // store a integer value directly in the interface value - BitCast // store other value (need bitcast) directly in the interface value + Invalid DataKind = iota + Indirect // allocate memory for the value + Pointer // store a pointer value directly in the interface value + Integer // store a integer value directly in the interface value + BitCast // store other value (need bitcast) directly in the interface value ) -func KindOf(raw types.Type, lvl int, is32Bits bool) (Kind, types.Type, int) { +func DataKindOf(raw types.Type, lvl int, is32Bits bool) (DataKind, types.Type, int) { switch t := raw.Underlying().(type) { case *types.Basic: kind := t.Kind() @@ -76,12 +100,12 @@ func KindOf(raw types.Type, lvl int, is32Bits bool) (Kind, types.Type, int) { return Pointer, raw, lvl case *types.Struct: if t.NumFields() == 1 { - return KindOf(t.Field(0).Type(), lvl+1, is32Bits) + return DataKindOf(t.Field(0).Type(), lvl+1, is32Bits) } case *types.Interface, *types.Slice: case *types.Array: if t.Len() == 1 { - return KindOf(t.Elem(), lvl+1, is32Bits) + return DataKindOf(t.Elem(), lvl+1, is32Bits) } default: panic("unkown type") diff --git a/ssa/abitype.go b/ssa/abitype.go new file mode 100644 index 000000000..a0deac813 --- /dev/null +++ b/ssa/abitype.go @@ -0,0 +1,364 @@ +/* + * Copyright (c) 2024 The GoPlus Authors (goplus.org). All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package ssa + +import ( + "go/token" + "go/types" + "unsafe" + + "github.com/goplus/llgo/ssa/abi" + "github.com/goplus/llvm" +) + +// ----------------------------------------------------------------------------- + +// abiBasic returns the abi type of the specified basic kind. +func (b Builder) abiBasic(t *types.Basic) func() Expr { + /* + TODO(xsw): + return b.abiExtern(abi.BasicName(t)) + */ + return func() Expr { + kind := int(abi.BasicKind(t)) + return b.InlineCall(b.Pkg.rtFunc("Basic"), b.Prog.Val(kind)) + } +} + +/* +func (b Builder) abiExtern(name string) Expr { + g := b.Pkg.NewVarFrom(name, b.Prog.AbiTypePtrPtr()) + return b.Load(g.Expr) +} +*/ + +func (b Builder) abiTypeOf(t types.Type) func() Expr { + switch t := t.(type) { + case *types.Basic: + return b.abiBasic(t) + case *types.Pointer: + return b.abiPointerOf(t) + case *types.Struct: + return b.abiStructOf(t) + case *types.Named: + return b.abiNamedOf(t) + case *types.Interface: + return b.abiInterfaceOf("", t) + case *types.Signature: + return b.abiFuncOf(t) + case *types.Slice: + return b.abiSliceOf(t) + case *types.Array: + return b.abiArrayOf(t) + } + panic("todo") +} + +func (b Builder) abiTupleOf(t *types.Tuple) func() Expr { + n := t.Len() + tuple := make([]Expr, n) + for i := 0; i < n; i++ { + tuple[i] = b.abiType(t.At(i).Type()) + } + return func() Expr { + prog := b.Prog + tSlice := prog.Slice(prog.AbiTypePtr()) + return b.SliceLit(tSlice, tuple...) + } +} + +// func Func(in, out []*Type, variadic bool) +func (b Builder) abiFuncOf(sig *types.Signature) func() Expr { + params := b.abiTupleOf(sig.Params()) + results := b.abiTupleOf(sig.Results()) + return func() Expr { + prog := b.Prog + pkg := b.Pkg + fn := pkg.rtFunc("Func") + variadic := prog.Val(sig.Variadic()) + return b.Call(fn, params(), results(), variadic) + } +} + +// Imethod{name string, typ *FuncType} +func (b Builder) abiImethodOf(mName string, typ Expr) Expr { + prog := b.Prog + name := b.Str(mName) + return b.aggregateValue(prog.rtType("Imethod"), name.impl, typ.impl) +} + +func (b Builder) abiMethods(t *types.Named) (ret int) { + n := t.NumMethods() + for i := 0; i < n; i++ { + m := t.Method(i) + mSig := m.Type().(*types.Signature) + recvType := mSig.Recv().Type() + if _, ok := recvType.(*types.Pointer); !ok { + ret++ + } + } + return +} + +// Method{name string, typ *FuncType, ifn, tfn abi.Text} +func (b Builder) abiMethodOf(m *types.Func /*, bg Background = InGo */) (mthd, ptrMthd Expr) { + prog := b.Prog + mPkg, mName := m.Pkg(), m.Name() + mSig := m.Type().(*types.Signature) + + name := b.Str(mName).impl + abiSigGo := types.NewSignatureType(nil, nil, nil, mSig.Params(), mSig.Results(), mSig.Variadic()) + abiSig := prog.FuncDecl(abiSigGo, InGo).raw.Type + abiTyp := b.abiType(abiSig) + abiTypImpl := abiTyp.impl + + recv := mSig.Recv() + recvType := recv.Type() + if _, ok := recvType.(*types.Pointer); ok { + ptrMthd, _ = b.abiMthd(mPkg, mName, mSig, name, abiTypImpl, llvm.Value{}) + return + } + ptrRecv := types.NewVar(0, nil, "", types.NewPointer(recvType)) + ptrSig := types.NewSignatureType(ptrRecv, nil, nil, mSig.Params(), mSig.Results(), mSig.Variadic()) + ptrMthd, ifn := b.abiMthd(mPkg, mName, ptrSig, name, abiTypImpl, llvm.Value{}) + mthd, _ = b.abiMthd(mPkg, mName, mSig, name, abiTypImpl, ifn) + return +} + +func (b Builder) abiMthd(mPkg *types.Package, mName string, mSig *types.Signature, name, abiTyp, ifn llvm.Value) (ret Expr, tfn llvm.Value) { + fullName := FuncName(mPkg, mName, mSig.Recv()) + tfn = b.Pkg.NewFunc(fullName, mSig, InGo).impl // TODO(xsw): use rawType to speed up + if ifn.IsNil() { + ifn = tfn + } + ret = b.aggregateValue(b.Prog.rtType("Method"), name, abiTyp, ifn, tfn) + return +} + +// func Interface(pkgPath, name string, methods []abi.Imethod) +func (b Builder) abiInterfaceOf(name string, t *types.Interface) func() Expr { + n := t.NumMethods() + typs := make([]Expr, n) + for i := 0; i < n; i++ { + m := t.Method(i) + typs[i] = b.abiType(m.Type()) + } + return func() Expr { + prog := b.Prog + methods := make([]Expr, n) + for i := 0; i < n; i++ { + m := t.Method(i) + methods[i] = b.abiImethodOf(m.Name(), typs[i]) + } + pkg := b.Pkg + fn := pkg.rtFunc("Interface") + pkgPath := pkg.Path() + tSlice := lastParamType(prog, fn) + methodSlice := b.SliceLit(tSlice, methods...) + return b.Call(fn, b.Str(pkgPath), b.Str(name), methodSlice) + } +} + +// func NewNamed(kind abi.Kind, methods, ptrMethods int) +func (b Builder) abiNamedOf(t *types.Named) func() Expr { + return func() Expr { + pkg := b.Pkg + tunder := t.Underlying() + kind := int(abi.UnderlyingKind(tunder)) + numMethods := b.abiMethods(t) + numPtrMethods := t.NumMethods() + newNamed := pkg.rtFunc("NewNamed") + return b.Call(newNamed, b.Prog.Val(kind), b.Prog.Val(numMethods), b.Prog.Val(numPtrMethods)) + } +} + +// func InitNamed(ret *Type, pkgPath, name string, underlying *Type, methods, ptrMethods []Method) +func (b Builder) abiInitNamed(ret Expr, t *types.Named) func() Expr { + under := b.abiType(t.Underlying()) + return func() Expr { + pkg := b.Pkg + prog := b.Prog + path := abi.PathOf(t.Obj().Pkg()) + name := NameOf(t) + + var initNamed = pkg.rtFunc("InitNamed") + var tSlice = lastParamType(prog, initNamed) + var n = t.NumMethods() + var methods, ptrMethods Expr + if n == 0 { + methods = prog.Zero(tSlice) + ptrMethods = methods + } else { + var mthds []Expr + var ptrMthds = make([]Expr, 0, n) + for i := 0; i < n; i++ { + m := t.Method(i) + mthd, ptrMthd := b.abiMethodOf(m) + if !mthd.IsNil() { + mthds = append(mthds, mthd) + } + ptrMthds = append(ptrMthds, ptrMthd) + } + if len(mthds) > 0 { + methods = b.SliceLit(tSlice, mthds...) + } else { + methods = prog.Zero(tSlice) + } + ptrMethods = b.SliceLit(tSlice, ptrMthds...) + } + return b.Call(initNamed, ret, b.Str(path), b.Str(name), under, methods, ptrMethods) + } +} + +func (b Builder) abiPointerOf(t *types.Pointer) func() Expr { + elem := b.abiType(t.Elem()) + return func() Expr { + return b.Call(b.Pkg.rtFunc("PointerTo"), elem) + } +} + +func (b Builder) abiSliceOf(t *types.Slice) func() Expr { + elem := b.abiType(t.Elem()) + return func() Expr { + return b.Call(b.Pkg.rtFunc("SliceOf"), elem) + } +} + +func (b Builder) abiArrayOf(t *types.Array) func() Expr { + elem := b.abiType(t.Elem()) + return func() Expr { + n := b.Prog.IntVal(uint64(t.Len()), b.Prog.Uintptr()) + return b.Call(b.Pkg.rtFunc("ArrayOf"), n, elem) + } +} + +// func StructField(name string, typ *abi.Type, off uintptr, tag string, embedded bool) +// func Struct(pkgPath string, size uintptr, fields []abi.StructField) +func (b Builder) abiStructOf(t *types.Struct) func() Expr { + n := t.NumFields() + typs := make([]Expr, n) + for i := 0; i < n; i++ { + f := t.Field(i) + typs[i] = b.abiType(f.Type()) + } + return func() Expr { + pkg := b.Pkg + prog := b.Prog + flds := make([]Expr, n) + strucAbi := pkg.rtFunc("Struct") + sfAbi := pkg.rtFunc("StructField") + tStruc := prog.rawType(t) + for i := 0; i < n; i++ { + f := t.Field(i) + off := uintptr(prog.OffsetOf(tStruc, i)) + name := b.Str(f.Name()) + tag := b.Str(t.Tag(i)) + embedded := prog.Val(f.Embedded()) + flds[i] = b.Call(sfAbi, name, typs[i], prog.Val(off), tag, embedded) + } + pkgPath := b.Str(pkg.Path()) + tSlice := lastParamType(prog, strucAbi) + fldSlice := b.SliceLit(tSlice, flds...) + size := prog.IntVal(prog.SizeOf(tStruc), prog.Uintptr()) + return b.Call(strucAbi, pkgPath, size, fldSlice) + } +} + +func lastParamType(prog Program, fn Expr) Type { + params := fn.raw.Type.(*types.Signature).Params() + return prog.rawType(params.At(params.Len() - 1).Type()) +} + +// ----------------------------------------------------------------------------- + +type abiTypes struct { + iniabi unsafe.Pointer +} + +func (p Package) hasAbiInit() bool { + return p.iniabi != nil +} + +func (p Package) abiInit(b Builder) { + inib := Builder(p.iniabi) + inib.Return() + b.Call(inib.Func.Expr) +} + +func (p Package) abiBuilder() Builder { + if p.iniabi == nil { + sigAbiInit := types.NewSignatureType(nil, nil, nil, nil, nil, false) + fn := p.NewFunc(p.Path()+".init$abi", sigAbiInit, InC) + fnb := fn.MakeBody(1) + p.iniabi = unsafe.Pointer(fnb) + } + return Builder(p.iniabi) +} + +func (p Package) abiTypeInit(g Global, t types.Type, pub bool) { + b := p.abiBuilder() + tabi := b.abiTypeOf(t) + expr := g.Expr + var eq Expr + var blks []BasicBlock + if pub { + eq = b.BinOp(token.EQL, b.Load(expr), b.Prog.Null(expr.Type)) + blks = b.Func.MakeBlocks(2) + b.If(eq, blks[0], blks[1]) + b.SetBlockEx(blks[0], AtEnd, false) + } + vexpr := tabi() + b.Store(expr, vexpr) + if pub { + b.Jump(blks[1]) + b.SetBlockEx(blks[1], AtEnd, false) + b.blk.last = blks[1].last + } + if t, ok := t.(*types.Named); ok { + tabi = b.abiInitNamed(vexpr, t) + if pub { + blks = b.Func.MakeBlocks(2) + b.If(eq, blks[0], blks[1]) + b.SetBlockEx(blks[0], AtEnd, false) + } + tabi() + if pub { + b.Jump(blks[1]) + b.SetBlockEx(blks[1], AtEnd, false) + b.blk.last = blks[1].last + } + } +} + +// abiType returns the abi type of the specified type. +func (b Builder) abiType(t types.Type) Expr { + pkg := b.Pkg + name, pub := pkg.abi.TypeName(t) + g := pkg.VarOf(name) + if g == nil { + prog := b.Prog + g = pkg.doNewVar(name, prog.AbiTypePtrPtr()) + g.Init(prog.Null(g.Type)) + if pub { + g.impl.SetLinkage(llvm.LinkOnceAnyLinkage) + } + pkg.abiTypeInit(g, t, pub) + } + return b.Load(g.Expr) +} + +// ----------------------------------------------------------------------------- diff --git a/ssa/cl_test.go b/ssa/cl_test.go index 513944c16..209c3bb4f 100644 --- a/ssa/cl_test.go +++ b/ssa/cl_test.go @@ -57,38 +57,6 @@ func TestMakeInterface(t *testing.T) { b.MakeInterface(prog.Any(), prog.IntVal(100, prog.Int64())) b.MakeInterface(prog.Any(), prog.FloatVal(100, prog.Float64())) b.Return() - ssatest.Assert(t, pkg, `; ModuleID = 'foo' -source_filename = "foo" - -%"github.com/goplus/llgo/internal/runtime.eface" = type { ptr, ptr } - -define void @main() { -_llgo_0: - %0 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 6) - %1 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 8) - store i64 100, ptr %1, align 4 - %2 = alloca %"github.com/goplus/llgo/internal/runtime.eface", align 8 - %3 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %2, i32 0, i32 0 - store ptr %0, ptr %3, align 8 - %4 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %2, i32 0, i32 1 - store ptr %1, ptr %4, align 8 - %5 = load %"github.com/goplus/llgo/internal/runtime.eface", ptr %2, align 8 - %6 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 14) - %7 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 8) - store double 1.000000e+02, ptr %7, align 8 - %8 = alloca %"github.com/goplus/llgo/internal/runtime.eface", align 8 - %9 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %8, i32 0, i32 0 - store ptr %6, ptr %9, align 8 - %10 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.eface", ptr %8, i32 0, i32 1 - store ptr %7, ptr %10, align 8 - %11 = load %"github.com/goplus/llgo/internal/runtime.eface", ptr %8, align 8 - ret void -} - -declare ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64) - -declare ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64) -`) } /* diff --git a/ssa/interface.go b/ssa/interface.go index f89a3edcc..b2d7065b6 100644 --- a/ssa/interface.go +++ b/ssa/interface.go @@ -20,7 +20,6 @@ import ( "go/token" "go/types" "log" - "unsafe" "github.com/goplus/llgo/ssa/abi" "github.com/goplus/llvm" @@ -28,220 +27,6 @@ import ( // ----------------------------------------------------------------------------- -// abiBasic returns the abi type of the specified basic kind. -func (b Builder) abiBasic(t *types.Basic) Expr { - /* - TODO(xsw): - return b.abiExtern(abi.BasicName(t)) - */ - kind := int(abi.BasicKind(t)) - return b.InlineCall(b.Pkg.rtFunc("Basic"), b.Prog.Val(kind)) -} - -/* -func (b Builder) abiExtern(name string) Expr { - g := b.Pkg.NewVarFrom(name, b.Prog.AbiTypePtrPtr()) - return b.Load(g.Expr) -} -*/ - -func (b Builder) abiTypeOf(t types.Type) Expr { - switch t := t.(type) { - case *types.Basic: - return b.abiBasic(t) - case *types.Pointer: - return b.abiPointerOf(t) - case *types.Struct: - return b.abiStructOf(t) - case *types.Named: - return b.abiNamedOf(t) - case *types.Interface: - return b.abiInterfaceOf(t) - case *types.Signature: - return b.abiFuncOf(t) - case *types.Slice: - return b.abiSliceOf(t) - case *types.Array: - return b.abiArrayOf(t) - } - panic("todo") -} - -func (b Builder) abiTupleOf(t *types.Tuple) Expr { - n := t.Len() - prog := b.Prog - tSlice := prog.Slice(prog.AbiTypePtr()) - tuple := make([]Expr, n) - for i := 0; i < n; i++ { - tuple[i] = b.abiType(t.At(i).Type()) - } - return b.SliceLit(tSlice, tuple...) -} - -// func Func(in, out []*Type, variadic bool) -func (b Builder) abiFuncOf(sig *types.Signature) Expr { - prog := b.Prog - pkg := b.Pkg - fn := pkg.rtFunc("Func") - params := b.abiTupleOf(sig.Params()) - results := b.abiTupleOf(sig.Results()) - variadic := prog.Val(sig.Variadic()) - return b.Call(fn, params, results, variadic) -} - -// Imethod{name string, typ *FuncType} -func (b Builder) abiImethodOf(m *types.Func) Expr { - prog := b.Prog - name := b.Str(m.Name()) - typ := b.abiType(m.Type()) - return b.aggregateValue(prog.rtType("Imethod"), name.impl, typ.impl) -} - -// Method{name string, typ *FuncType, ifn, tfn abi.Text} -func (b Builder) abiMethodOf(m *types.Func) Expr { - prog := b.Prog - mName := m.Name() - mSig := m.Type().(*types.Signature) - fullName := FuncName(m.Pkg(), mName, mSig.Recv()) - name := b.Str(mName) - fn := b.Pkg.NewFunc(fullName, mSig, InGo) - sig := fn.raw.Type.(*types.Signature) - sig = types.NewSignatureType(nil, nil, nil, sig.Params(), sig.Results(), sig.Variadic()) - typ := b.abiType(sig) - // TODO(xsw): ifn, tfn - return b.aggregateValue(prog.rtType("Method"), name.impl, typ.impl, fn.impl, fn.impl) -} - -// func Interface(pkgPath string, methods []abi.Imethod) -func (b Builder) abiInterfaceOf(t *types.Interface) Expr { - prog := b.Prog - n := t.NumMethods() - methods := make([]Expr, n) - for i := 0; i < n; i++ { - m := t.Method(i) - methods[i] = b.abiImethodOf(m) - } - pkg := b.Pkg - fn := pkg.rtFunc("Interface") - pkgPath := pkg.Path() - tSlice := lastParamType(prog, fn) - methodSlice := b.SliceLit(tSlice, methods...) - return b.Call(fn, b.Str(pkgPath), methodSlice) -} - -// func Named(pkgPath, name string, underlying *Type, methods []abi.Method) -func (b Builder) abiNamedOf(t *types.Named) Expr { - tunder := t.Underlying() - under := b.abiType(tunder) - path := abi.PathOf(t.Obj().Pkg()) - name := NameOf(t) - prog := b.Prog - pkg := b.Pkg - - var fn = pkg.rtFunc("Named") - var tSlice = lastParamType(prog, fn) - var methods Expr - if _, ok := tunder.(*types.Interface); ok { - methods = prog.Zero(tSlice) - } else { - n := t.NumMethods() - mths := make([]Expr, n) - for i := 0; i < n; i++ { - m := t.Method(i) - mths[i] = b.abiMethodOf(m) - } - methods = b.SliceLit(tSlice, mths...) - } - return b.Call(fn, b.Str(path), b.Str(name), under, methods) -} - -func (b Builder) abiPointerOf(t *types.Pointer) Expr { - elem := b.abiType(t.Elem()) - return b.Call(b.Pkg.rtFunc("PointerTo"), elem) -} - -func (b Builder) abiSliceOf(t *types.Slice) Expr { - elem := b.abiTypeOf(t.Elem()) - return b.Call(b.Pkg.rtFunc("SliceOf"), elem) -} - -func (b Builder) abiArrayOf(t *types.Array) Expr { - elem := b.abiTypeOf(t.Elem()) - return b.Call(b.Pkg.rtFunc("ArrayOf"), b.Prog.IntVal(uint64(t.Len()), b.Prog.Uintptr()), elem) -} - -// func Struct(pkgPath string, size uintptr, fields []abi.StructField) -func (b Builder) abiStructOf(t *types.Struct) Expr { - pkg := b.Pkg - prog := b.Prog - n := t.NumFields() - flds := make([]Expr, n) - strucAbi := pkg.rtFunc("Struct") - sfAbi := pkg.rtFunc("StructField") - typ := prog.rawType(t) - for i := 0; i < n; i++ { - f := t.Field(i) - off := uintptr(prog.OffsetOf(typ, i)) - flds[i] = b.structField(sfAbi, prog, f, off, t.Tag(i)) - } - pkgPath := b.Str(pkg.Path()) - tSlice := lastParamType(prog, strucAbi) - fldSlice := b.SliceLit(tSlice, flds...) - size := prog.IntVal(prog.SizeOf(typ), prog.Uintptr()) - return b.Call(strucAbi, pkgPath, size, fldSlice) -} - -func lastParamType(prog Program, fn Expr) Type { - params := fn.raw.Type.(*types.Signature).Params() - return prog.rawType(params.At(params.Len() - 1).Type()) -} - -// func StructField(name string, typ *abi.Type, off uintptr, tag string, embedded bool) abi.StructField -func (b Builder) structField(sfAbi Expr, prog Program, f *types.Var, offset uintptr, tag string) Expr { - name := b.Str(f.Name()) - typ := b.abiType(f.Type()) - embedded := prog.Val(f.Embedded()) - return b.Call(sfAbi, name, typ, prog.Val(offset), b.Str(tag), embedded) -} - -// abiType returns the abi type of the specified type. -func (b Builder) abiType(t types.Type) Expr { - switch tx := t.(type) { - case *types.Basic: - return b.abiBasic(tx) - } - pkg := b.Pkg - name, pub := pkg.abi.TypeName(t) - g := pkg.VarOf(name) - if g == nil { - prog := b.Prog - g = pkg.doNewVar(name, prog.AbiTypePtrPtr()) - g.Init(prog.Null(g.Type)) - if pub { - g.impl.SetLinkage(llvm.LinkOnceAnyLinkage) - } - pkg.abiini = append(pkg.abiini, func(param unsafe.Pointer) { - b := Builder(param) - expr := g.Expr - var blks []BasicBlock - if pub { - eq := b.BinOp(token.EQL, b.Load(expr), b.Prog.Null(expr.Type)) - blks = b.Func.MakeBlocks(2) - b.If(eq, blks[0], blks[1]) - b.SetBlockEx(blks[0], AtEnd, false) - } - tabi := b.abiTypeOf(t) - b.Store(expr, tabi) - if pub { - b.Jump(blks[1]) - b.SetBlockEx(blks[1], AtEnd, false) - b.blk.last = blks[1].last - } - }) - } - return b.Load(g.Expr) -} - // unsafeEface(t *abi.Type, data unsafe.Pointer) Eface func (b Builder) unsafeEface(t, data llvm.Value) llvm.Value { return aggregateValue(b.impl, b.Prog.rtEface(), t, data) @@ -288,7 +73,8 @@ func (b Builder) Imethod(intf Expr, method *types.Func) Expr { itab := Expr{b.faceItab(impl), prog.VoidPtrPtr()} pfn := b.Advance(itab, prog.IntVal(uint64(i+3), prog.Int())) fn := b.Load(pfn) - return b.aggregateValue(tclosure, fn.impl, b.faceData(impl)) + ret := b.aggregateValue(tclosure, fn.impl, b.faceData(impl)) + return ret } // ----------------------------------------------------------------------------- @@ -315,7 +101,7 @@ func (b Builder) MakeInterface(tinter Type, x Expr) (ret Expr) { prog := b.Prog typ := x.Type tabi := b.abiType(typ.raw.Type) - kind, _, lvl := abi.KindOf(typ.raw.Type, 0, prog.is32Bits) + kind, _, lvl := abi.DataKindOf(typ.raw.Type, 0, prog.is32Bits) switch kind { case abi.Indirect: vptr := b.AllocU(typ) @@ -345,7 +131,7 @@ func (b Builder) MakeInterface(tinter Type, x Expr) (ret Expr) { func (b Builder) valFromData(typ Type, data llvm.Value) Expr { prog := b.Prog - kind, real, lvl := abi.KindOf(typ.raw.Type, 0, prog.is32Bits) + kind, real, lvl := abi.DataKindOf(typ.raw.Type, 0, prog.is32Bits) switch kind { case abi.Indirect: impl := b.impl diff --git a/ssa/package.go b/ssa/package.go index 38fa3ae5f..cac873e64 100644 --- a/ssa/package.go +++ b/ssa/package.go @@ -20,7 +20,6 @@ import ( "go/token" "go/types" "strconv" - "unsafe" "github.com/goplus/llgo/ssa/abi" "github.com/goplus/llvm" @@ -165,6 +164,8 @@ type aProgram struct { paramObjPtr_ *types.Var + ptrSize int + NeedRuntime bool NeedPyInit bool is32Bits bool @@ -194,7 +195,7 @@ func NewProgram(target *Target) Program { return &aProgram{ ctx: ctx, gocvt: newGoTypes(), target: target, td: td, is32Bits: is32Bits, - named: make(map[string]llvm.Type), + ptrSize: td.PointerSize(), named: make(map[string]llvm.Type), } } @@ -508,15 +509,17 @@ func (p Program) Uint64() Type { // initializer) and "init#%d", the nth declared init function, // and unspecified other things too. type aPackage struct { - mod llvm.Module - abi abi.Builder - abiini []func(b unsafe.Pointer) // b Builder + mod llvm.Module + vars map[string]Global fns map[string]Function stubs map[string]Function pyobjs map[string]PyObjRef pymods map[string]Global Prog Program + + abi abi.Builder + abiTypes } type Package = *aPackage @@ -580,31 +583,12 @@ func (p Package) String() string { // AfterInit is called after the package is initialized (init all packages that depends on). func (p Package) AfterInit(b Builder, ret BasicBlock) { - doAbiInit := len(p.abiini) > 0 + doAbiInit := p.hasAbiInit() doPyLoadModSyms := p.pyHasModSyms() if doAbiInit || doPyLoadModSyms { b.SetBlockEx(ret, afterInit, false) if doAbiInit { - sigAbiInit := types.NewSignatureType(nil, nil, nil, nil, nil, false) - baseName := p.Path() + ".init$abi" - name := baseName - idx := 1 - fn := p.NewFunc(name, sigAbiInit, InC) - b.Call(fn.Expr) - for { - fnb := fn.MakeBody(1) - first := fnb.blk - p.callAbiInit(fnb) - fnb.Return() - if len(p.abiini) == 0 { - break - } - idx++ - name = baseName + strconv.Itoa(idx) - fn = p.NewFunc(name, sigAbiInit, InC) - fnb.SetBlockEx(first, AtStart, false) - fnb.Call(fn.Expr) - } + p.abiInit(b) } if doPyLoadModSyms { p.pyLoadModSyms(b) @@ -612,14 +596,6 @@ func (p Package) AfterInit(b Builder, ret BasicBlock) { } } -func (p Package) callAbiInit(fnb Builder) { - abiini := p.abiini - p.abiini = nil - for _, abiInit := range abiini { - abiInit(unsafe.Pointer(fnb)) - } -} - /* type CodeGenFileType = llvm.CodeGenFileType diff --git a/ssa/type.go b/ssa/type.go index 36bbc0893..6cab59781 100644 --- a/ssa/type.go +++ b/ssa/type.go @@ -178,7 +178,7 @@ func OffsetOf(prog Program, t Type, i int) Expr { */ func (p Program) PointerSize() int { - return p.td.PointerSize() + return p.ptrSize } func (p Program) Slice(typ Type) Type {