SetBlockEx: BeforeLast
This commit is contained in:
@@ -24,11 +24,16 @@ _llgo_1: ; preds = %_llgo_0
|
|||||||
store i64 0, ptr %5, align 4
|
store i64 0, ptr %5, align 4
|
||||||
%6 = load %"github.com/goplus/llgo/internal/runtime.String", ptr %3, align 8
|
%6 = load %"github.com/goplus/llgo/internal/runtime.String", ptr %3, align 8
|
||||||
%7 = call %"github.com/goplus/llgo/internal/abi.Name" @"github.com/goplus/llgo/internal/abi.NewName"(%"github.com/goplus/llgo/internal/runtime.String" %0, %"github.com/goplus/llgo/internal/runtime.String" %6, i1 false, i1 false)
|
%7 = call %"github.com/goplus/llgo/internal/abi.Name" @"github.com/goplus/llgo/internal/abi.NewName"(%"github.com/goplus/llgo/internal/runtime.String" %0, %"github.com/goplus/llgo/internal/runtime.String" %6, i1 false, i1 false)
|
||||||
|
%8 = extractvalue %"github.com/goplus/llgo/internal/abi.Name" %7, 0
|
||||||
br label %_llgo_2
|
br label %_llgo_2
|
||||||
|
|
||||||
_llgo_2: ; preds = %_llgo_1, %_llgo_0
|
_llgo_2: ; preds = %_llgo_1, %_llgo_0
|
||||||
%8 = phi ptr [ zeroinitializer, %_llgo_0 ], [ %7, %_llgo_1 ]
|
%9 = phi ptr [ null, %_llgo_0 ], [ %8, %_llgo_1 ]
|
||||||
ret ptr %8
|
%10 = alloca %"github.com/goplus/llgo/internal/abi.Name", align 8
|
||||||
|
%11 = getelementptr inbounds %"github.com/goplus/llgo/internal/abi.Name", ptr %10, i32 0, i32 0
|
||||||
|
store ptr %9, ptr %11, align 8
|
||||||
|
%12 = load %"github.com/goplus/llgo/internal/abi.Name", ptr %10, align 8
|
||||||
|
ret %"github.com/goplus/llgo/internal/abi.Name" %12
|
||||||
}
|
}
|
||||||
|
|
||||||
define void @main.init() {
|
define void @main.init() {
|
||||||
|
|||||||
@@ -158,85 +158,118 @@ _llgo_10: ; preds = %_llgo_0
|
|||||||
%45 = getelementptr inbounds { { i64 }, i1 }, ptr %43, i32 0, i32 1
|
%45 = getelementptr inbounds { { i64 }, i1 }, ptr %43, i32 0, i32 1
|
||||||
store i1 true, ptr %45, align 1
|
store i1 true, ptr %45, align 1
|
||||||
%46 = load { { i64 }, i1 }, ptr %43, align 4
|
%46 = load { { i64 }, i1 }, ptr %43, align 4
|
||||||
|
%47 = extractvalue { { i64 }, i1 } %46, 0
|
||||||
|
%48 = extractvalue { { i64 }, i1 } %46, 1
|
||||||
br label %_llgo_12
|
br label %_llgo_12
|
||||||
|
|
||||||
_llgo_11: ; preds = %_llgo_0
|
_llgo_11: ; preds = %_llgo_0
|
||||||
%47 = alloca { { i64 }, i1 }, align 8
|
%49 = alloca { { i64 }, i1 }, align 8
|
||||||
%48 = getelementptr inbounds { { i64 }, i1 }, ptr %47, i32 0, i32 0
|
%50 = getelementptr inbounds { { i64 }, i1 }, ptr %49, i32 0, i32 0
|
||||||
store { i64 } zeroinitializer, ptr %48, align 4
|
store { i64 } zeroinitializer, ptr %50, align 4
|
||||||
%49 = getelementptr inbounds { { i64 }, i1 }, ptr %47, i32 0, i32 1
|
%51 = getelementptr inbounds { { i64 }, i1 }, ptr %49, i32 0, i32 1
|
||||||
store i1 false, ptr %49, align 1
|
store i1 false, ptr %51, align 1
|
||||||
%50 = load { { i64 }, i1 }, ptr %47, align 4
|
%52 = load { { i64 }, i1 }, ptr %49, align 4
|
||||||
|
%53 = extractvalue { { i64 }, i1 } %52, 0
|
||||||
|
%54 = extractvalue { { i64 }, i1 } %52, 1
|
||||||
br label %_llgo_12
|
br label %_llgo_12
|
||||||
|
|
||||||
_llgo_12: ; preds = %_llgo_11, %_llgo_10
|
_llgo_12: ; preds = %_llgo_11, %_llgo_10
|
||||||
%51 = phi { { i64 }, i1 } [ %46, %_llgo_10 ], [ %50, %_llgo_11 ]
|
%55 = phi i64 [ %47, %_llgo_10 ], [ %53, %_llgo_11 ]
|
||||||
%52 = extractvalue { { i64 }, i1 } %51, 0
|
%56 = phi i1 [ %48, %_llgo_10 ], [ %54, %_llgo_11 ]
|
||||||
store { i64 } %52, ptr %4, align 4
|
%57 = alloca { { i64 }, i1 }, align 8
|
||||||
%53 = extractvalue { { i64 }, i1 } %51, 1
|
%58 = getelementptr inbounds { { i64 }, i1 }, ptr %57, i32 0, i32 0
|
||||||
br i1 %53, label %_llgo_1, label %_llgo_3
|
store i64 %55, ptr %58, align 4
|
||||||
|
%59 = getelementptr inbounds { { i64 }, i1 }, ptr %57, i32 0, i32 1
|
||||||
|
store i1 %56, ptr %59, align 1
|
||||||
|
%60 = load { { i64 }, i1 }, ptr %57, align 4
|
||||||
|
%61 = extractvalue { { i64 }, i1 } %60, 0
|
||||||
|
store { i64 } %61, ptr %4, align 4
|
||||||
|
%62 = extractvalue { { i64 }, i1 } %60, 1
|
||||||
|
br i1 %62, label %_llgo_1, label %_llgo_3
|
||||||
|
|
||||||
_llgo_13: ; preds = %_llgo_2
|
_llgo_13: ; preds = %_llgo_2
|
||||||
%54 = extractvalue %"github.com/goplus/llgo/internal/runtime.eface" %10, 1
|
%63 = extractvalue %"github.com/goplus/llgo/internal/runtime.eface" %10, 1
|
||||||
%55 = ptrtoint ptr %54 to i64
|
%64 = ptrtoint ptr %63 to i64
|
||||||
%56 = alloca { i64 }, align 8
|
%65 = alloca { i64 }, align 8
|
||||||
%57 = getelementptr inbounds { i64 }, ptr %56, i32 0, i32 0
|
%66 = getelementptr inbounds { i64 }, ptr %65, i32 0, i32 0
|
||||||
store i64 %55, ptr %57, align 4
|
store i64 %64, ptr %66, align 4
|
||||||
%58 = load { i64 }, ptr %56, align 4
|
%67 = load { i64 }, ptr %65, align 4
|
||||||
%59 = alloca { { i64 }, i1 }, align 8
|
%68 = alloca { { i64 }, i1 }, align 8
|
||||||
%60 = getelementptr inbounds { { i64 }, i1 }, ptr %59, i32 0, i32 0
|
%69 = getelementptr inbounds { { i64 }, i1 }, ptr %68, i32 0, i32 0
|
||||||
store { i64 } %58, ptr %60, align 4
|
store { i64 } %67, ptr %69, align 4
|
||||||
%61 = getelementptr inbounds { { i64 }, i1 }, ptr %59, i32 0, i32 1
|
%70 = getelementptr inbounds { { i64 }, i1 }, ptr %68, i32 0, i32 1
|
||||||
store i1 true, ptr %61, align 1
|
store i1 true, ptr %70, align 1
|
||||||
%62 = load { { i64 }, i1 }, ptr %59, align 4
|
%71 = load { { i64 }, i1 }, ptr %68, align 4
|
||||||
|
%72 = extractvalue { { i64 }, i1 } %71, 0
|
||||||
|
%73 = extractvalue { { i64 }, i1 } %71, 1
|
||||||
br label %_llgo_15
|
br label %_llgo_15
|
||||||
|
|
||||||
_llgo_14: ; preds = %_llgo_2
|
_llgo_14: ; preds = %_llgo_2
|
||||||
%63 = alloca { { i64 }, i1 }, align 8
|
%74 = alloca { { i64 }, i1 }, align 8
|
||||||
%64 = getelementptr inbounds { { i64 }, i1 }, ptr %63, i32 0, i32 0
|
%75 = getelementptr inbounds { { i64 }, i1 }, ptr %74, i32 0, i32 0
|
||||||
store { i64 } zeroinitializer, ptr %64, align 4
|
store { i64 } zeroinitializer, ptr %75, align 4
|
||||||
%65 = getelementptr inbounds { { i64 }, i1 }, ptr %63, i32 0, i32 1
|
%76 = getelementptr inbounds { { i64 }, i1 }, ptr %74, i32 0, i32 1
|
||||||
store i1 false, ptr %65, align 1
|
store i1 false, ptr %76, align 1
|
||||||
%66 = load { { i64 }, i1 }, ptr %63, align 4
|
%77 = load { { i64 }, i1 }, ptr %74, align 4
|
||||||
|
%78 = extractvalue { { i64 }, i1 } %77, 0
|
||||||
|
%79 = extractvalue { { i64 }, i1 } %77, 1
|
||||||
br label %_llgo_15
|
br label %_llgo_15
|
||||||
|
|
||||||
_llgo_15: ; preds = %_llgo_14, %_llgo_13
|
_llgo_15: ; preds = %_llgo_14, %_llgo_13
|
||||||
%67 = phi { { i64 }, i1 } [ %62, %_llgo_13 ], [ %66, %_llgo_14 ]
|
%80 = phi i64 [ %72, %_llgo_13 ], [ %78, %_llgo_14 ]
|
||||||
%68 = extractvalue { { i64 }, i1 } %67, 0
|
%81 = phi i1 [ %73, %_llgo_13 ], [ %79, %_llgo_14 ]
|
||||||
store { i64 } %68, ptr %12, align 4
|
%82 = alloca { { i64 }, i1 }, align 8
|
||||||
%69 = extractvalue { { i64 }, i1 } %67, 1
|
%83 = getelementptr inbounds { { i64 }, i1 }, ptr %82, i32 0, i32 0
|
||||||
br i1 %69, label %_llgo_4, label %_llgo_6
|
store i64 %80, ptr %83, align 4
|
||||||
|
%84 = getelementptr inbounds { { i64 }, i1 }, ptr %82, i32 0, i32 1
|
||||||
|
store i1 %81, ptr %84, align 1
|
||||||
|
%85 = load { { i64 }, i1 }, ptr %82, align 4
|
||||||
|
%86 = extractvalue { { i64 }, i1 } %85, 0
|
||||||
|
store { i64 } %86, ptr %12, align 4
|
||||||
|
%87 = extractvalue { { i64 }, i1 } %85, 1
|
||||||
|
br i1 %87, label %_llgo_4, label %_llgo_6
|
||||||
|
|
||||||
_llgo_16: ; preds = %_llgo_5
|
_llgo_16: ; preds = %_llgo_5
|
||||||
%70 = extractvalue %"github.com/goplus/llgo/internal/runtime.eface" %24, 1
|
%88 = extractvalue %"github.com/goplus/llgo/internal/runtime.eface" %24, 1
|
||||||
%71 = ptrtoint ptr %70 to i64
|
%89 = ptrtoint ptr %88 to i64
|
||||||
%72 = alloca { i64 }, align 8
|
%90 = alloca { i64 }, align 8
|
||||||
%73 = getelementptr inbounds { i64 }, ptr %72, i32 0, i32 0
|
%91 = getelementptr inbounds { i64 }, ptr %90, i32 0, i32 0
|
||||||
store i64 %71, ptr %73, align 4
|
store i64 %89, ptr %91, align 4
|
||||||
%74 = load { i64 }, ptr %72, align 4
|
%92 = load { i64 }, ptr %90, align 4
|
||||||
%75 = alloca { { i64 }, i1 }, align 8
|
%93 = alloca { { i64 }, i1 }, align 8
|
||||||
%76 = getelementptr inbounds { { i64 }, i1 }, ptr %75, i32 0, i32 0
|
%94 = getelementptr inbounds { { i64 }, i1 }, ptr %93, i32 0, i32 0
|
||||||
store { i64 } %74, ptr %76, align 4
|
store { i64 } %92, ptr %94, align 4
|
||||||
%77 = getelementptr inbounds { { i64 }, i1 }, ptr %75, i32 0, i32 1
|
%95 = getelementptr inbounds { { i64 }, i1 }, ptr %93, i32 0, i32 1
|
||||||
store i1 true, ptr %77, align 1
|
store i1 true, ptr %95, align 1
|
||||||
%78 = load { { i64 }, i1 }, ptr %75, align 4
|
%96 = load { { i64 }, i1 }, ptr %93, align 4
|
||||||
|
%97 = extractvalue { { i64 }, i1 } %96, 0
|
||||||
|
%98 = extractvalue { { i64 }, i1 } %96, 1
|
||||||
br label %_llgo_18
|
br label %_llgo_18
|
||||||
|
|
||||||
_llgo_17: ; preds = %_llgo_5
|
_llgo_17: ; preds = %_llgo_5
|
||||||
%79 = alloca { { i64 }, i1 }, align 8
|
%99 = alloca { { i64 }, i1 }, align 8
|
||||||
%80 = getelementptr inbounds { { i64 }, i1 }, ptr %79, i32 0, i32 0
|
%100 = getelementptr inbounds { { i64 }, i1 }, ptr %99, i32 0, i32 0
|
||||||
store { i64 } zeroinitializer, ptr %80, align 4
|
store { i64 } zeroinitializer, ptr %100, align 4
|
||||||
%81 = getelementptr inbounds { { i64 }, i1 }, ptr %79, i32 0, i32 1
|
%101 = getelementptr inbounds { { i64 }, i1 }, ptr %99, i32 0, i32 1
|
||||||
store i1 false, ptr %81, align 1
|
store i1 false, ptr %101, align 1
|
||||||
%82 = load { { i64 }, i1 }, ptr %79, align 4
|
%102 = load { { i64 }, i1 }, ptr %99, align 4
|
||||||
|
%103 = extractvalue { { i64 }, i1 } %102, 0
|
||||||
|
%104 = extractvalue { { i64 }, i1 } %102, 1
|
||||||
br label %_llgo_18
|
br label %_llgo_18
|
||||||
|
|
||||||
_llgo_18: ; preds = %_llgo_17, %_llgo_16
|
_llgo_18: ; preds = %_llgo_17, %_llgo_16
|
||||||
%83 = phi { { i64 }, i1 } [ %78, %_llgo_16 ], [ %82, %_llgo_17 ]
|
%105 = phi i64 [ %97, %_llgo_16 ], [ %103, %_llgo_17 ]
|
||||||
%84 = extractvalue { { i64 }, i1 } %83, 0
|
%106 = phi i1 [ %98, %_llgo_16 ], [ %104, %_llgo_17 ]
|
||||||
store { i64 } %84, ptr %23, align 4
|
%107 = alloca { { i64 }, i1 }, align 8
|
||||||
%85 = extractvalue { { i64 }, i1 } %83, 1
|
%108 = getelementptr inbounds { { i64 }, i1 }, ptr %107, i32 0, i32 0
|
||||||
br i1 %85, label %_llgo_7, label %_llgo_9
|
store i64 %105, ptr %108, align 4
|
||||||
|
%109 = getelementptr inbounds { { i64 }, i1 }, ptr %107, i32 0, i32 1
|
||||||
|
store i1 %106, ptr %109, align 1
|
||||||
|
%110 = load { { i64 }, i1 }, ptr %107, align 4
|
||||||
|
%111 = extractvalue { { i64 }, i1 } %110, 0
|
||||||
|
store { i64 } %111, ptr %23, align 4
|
||||||
|
%112 = extractvalue { { i64 }, i1 } %110, 1
|
||||||
|
br i1 %112, label %_llgo_7, label %_llgo_9
|
||||||
}
|
}
|
||||||
|
|
||||||
declare ptr @"github.com/goplus/llgo/internal/runtime.Zeroinit"(ptr, i64)
|
declare ptr @"github.com/goplus/llgo/internal/runtime.Zeroinit"(ptr, i64)
|
||||||
@@ -277,67 +310,71 @@ _llgo_0:
|
|||||||
%12 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %10, i32 0, i32 1
|
%12 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %10, i32 0, i32 1
|
||||||
store i64 4, ptr %12, align 4
|
store i64 4, ptr %12, align 4
|
||||||
%13 = load %"github.com/goplus/llgo/internal/runtime.String", ptr %10, align 8
|
%13 = load %"github.com/goplus/llgo/internal/runtime.String", ptr %10, align 8
|
||||||
%14 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 24)
|
%14 = call %"github.com/goplus/llgo/internal/abi.Name" @"github.com/goplus/llgo/internal/runtime.NewPkgName"(%"github.com/goplus/llgo/internal/runtime.String" %13)
|
||||||
%15 = getelementptr %"github.com/goplus/llgo/internal/abi.StructField", ptr %14, i64 0
|
%15 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 24)
|
||||||
store %"github.com/goplus/llgo/internal/abi.StructField" %9, ptr %15, align 8
|
%16 = getelementptr %"github.com/goplus/llgo/internal/abi.StructField", ptr %15, i64 0
|
||||||
%16 = alloca %"github.com/goplus/llgo/internal/runtime.Slice", align 8
|
store %"github.com/goplus/llgo/internal/abi.StructField" %9, ptr %16, align 8
|
||||||
%17 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.Slice", ptr %16, i32 0, i32 0
|
%17 = alloca %"github.com/goplus/llgo/internal/runtime.Slice", align 8
|
||||||
store ptr %14, ptr %17, align 8
|
%18 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.Slice", ptr %17, i32 0, i32 0
|
||||||
%18 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.Slice", ptr %16, i32 0, i32 1
|
store ptr %15, ptr %18, align 8
|
||||||
store i64 1, ptr %18, align 4
|
%19 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.Slice", ptr %17, i32 0, i32 1
|
||||||
%19 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.Slice", ptr %16, i32 0, i32 2
|
|
||||||
store i64 1, ptr %19, align 4
|
store i64 1, ptr %19, align 4
|
||||||
%20 = load %"github.com/goplus/llgo/internal/runtime.Slice", ptr %16, align 8
|
%20 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.Slice", ptr %17, i32 0, i32 2
|
||||||
%21 = call ptr @"github.com/goplus/llgo/internal/runtime.Struct"(%"github.com/goplus/llgo/internal/runtime.String" %13, %"github.com/goplus/llgo/internal/runtime.Slice" %20)
|
store i64 1, ptr %20, align 4
|
||||||
store ptr %21, ptr @"main.struct$MYpsoM99ZwFY087IpUOkIw1zjBA_sgFXVodmn1m-G88", align 8
|
%21 = load %"github.com/goplus/llgo/internal/runtime.Slice", ptr %17, align 8
|
||||||
%22 = load ptr, ptr @"_llgo_struct$K-dZ9QotZfVPz2a0YdRa9vmZUuDXPTqZOlMShKEDJtk", align 8
|
%22 = call ptr @"github.com/goplus/llgo/internal/runtime.Struct"(%"github.com/goplus/llgo/internal/abi.Name" %14, i64 8, %"github.com/goplus/llgo/internal/runtime.Slice" %21)
|
||||||
%23 = icmp eq ptr %22, null
|
store ptr %22, ptr @"main.struct$MYpsoM99ZwFY087IpUOkIw1zjBA_sgFXVodmn1m-G88", align 8
|
||||||
br i1 %23, label %_llgo_1, label %_llgo_2
|
%23 = load ptr, ptr @"_llgo_struct$K-dZ9QotZfVPz2a0YdRa9vmZUuDXPTqZOlMShKEDJtk", align 8
|
||||||
|
%24 = icmp eq ptr %23, null
|
||||||
|
br i1 %24, label %_llgo_1, label %_llgo_2
|
||||||
|
|
||||||
_llgo_1: ; preds = %_llgo_0
|
_llgo_1: ; preds = %_llgo_0
|
||||||
%24 = alloca %"github.com/goplus/llgo/internal/runtime.String", align 8
|
%25 = 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
|
%26 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %25, i32 0, i32 0
|
||||||
store ptr @6, ptr %25, align 8
|
store ptr @6, ptr %26, align 8
|
||||||
%26 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %24, i32 0, i32 1
|
%27 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %25, i32 0, i32 1
|
||||||
store i64 1, ptr %26, align 4
|
store i64 1, ptr %27, align 4
|
||||||
%27 = load %"github.com/goplus/llgo/internal/runtime.String", ptr %24, align 8
|
%28 = load %"github.com/goplus/llgo/internal/runtime.String", ptr %25, align 8
|
||||||
%28 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 2)
|
%29 = call ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64 2)
|
||||||
%29 = alloca %"github.com/goplus/llgo/internal/runtime.String", align 8
|
%30 = 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
|
%31 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %30, i32 0, i32 0
|
||||||
store ptr @7, ptr %30, align 8
|
store ptr @7, ptr %31, align 8
|
||||||
%31 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %29, i32 0, i32 1
|
%32 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %30, i32 0, i32 1
|
||||||
store i64 0, ptr %31, align 4
|
store i64 0, ptr %32, align 4
|
||||||
%32 = load %"github.com/goplus/llgo/internal/runtime.String", ptr %29, align 8
|
%33 = load %"github.com/goplus/llgo/internal/runtime.String", ptr %30, 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 true, i1 false)
|
%34 = call %"github.com/goplus/llgo/internal/abi.StructField" @"github.com/goplus/llgo/internal/runtime.StructField"(%"github.com/goplus/llgo/internal/runtime.String" %28, ptr %29, i64 0, %"github.com/goplus/llgo/internal/runtime.String" %33, i1 true, i1 false)
|
||||||
%34 = alloca %"github.com/goplus/llgo/internal/runtime.String", align 8
|
%35 = 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
|
%36 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %35, i32 0, i32 0
|
||||||
store ptr @8, ptr %35, align 8
|
store ptr @8, ptr %36, align 8
|
||||||
%36 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %34, i32 0, i32 1
|
%37 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %35, i32 0, i32 1
|
||||||
store i64 4, ptr %36, align 4
|
store i64 4, ptr %37, align 4
|
||||||
%37 = load %"github.com/goplus/llgo/internal/runtime.String", ptr %34, align 8
|
%38 = load %"github.com/goplus/llgo/internal/runtime.String", ptr %35, align 8
|
||||||
%38 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 24)
|
%39 = call %"github.com/goplus/llgo/internal/abi.Name" @"github.com/goplus/llgo/internal/runtime.NewPkgName"(%"github.com/goplus/llgo/internal/runtime.String" %38)
|
||||||
%39 = getelementptr %"github.com/goplus/llgo/internal/abi.StructField", ptr %38, i64 0
|
%40 = call ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64 24)
|
||||||
store %"github.com/goplus/llgo/internal/abi.StructField" %33, ptr %39, align 8
|
%41 = getelementptr %"github.com/goplus/llgo/internal/abi.StructField", ptr %40, i64 0
|
||||||
%40 = alloca %"github.com/goplus/llgo/internal/runtime.Slice", align 8
|
store %"github.com/goplus/llgo/internal/abi.StructField" %34, ptr %41, align 8
|
||||||
%41 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.Slice", ptr %40, i32 0, i32 0
|
%42 = alloca %"github.com/goplus/llgo/internal/runtime.Slice", align 8
|
||||||
store ptr %38, ptr %41, align 8
|
%43 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.Slice", ptr %42, i32 0, i32 0
|
||||||
%42 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.Slice", ptr %40, i32 0, i32 1
|
store ptr %40, ptr %43, align 8
|
||||||
store i64 1, ptr %42, align 4
|
%44 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.Slice", ptr %42, i32 0, i32 1
|
||||||
%43 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.Slice", ptr %40, i32 0, i32 2
|
store i64 1, ptr %44, align 4
|
||||||
store i64 1, ptr %43, align 4
|
%45 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.Slice", ptr %42, i32 0, i32 2
|
||||||
%44 = load %"github.com/goplus/llgo/internal/runtime.Slice", ptr %40, align 8
|
store i64 1, ptr %45, align 4
|
||||||
%45 = call ptr @"github.com/goplus/llgo/internal/runtime.Struct"(%"github.com/goplus/llgo/internal/runtime.String" %37, %"github.com/goplus/llgo/internal/runtime.Slice" %44)
|
%46 = load %"github.com/goplus/llgo/internal/runtime.Slice", ptr %42, align 8
|
||||||
store ptr %45, ptr @"_llgo_struct$K-dZ9QotZfVPz2a0YdRa9vmZUuDXPTqZOlMShKEDJtk", align 8
|
%47 = call ptr @"github.com/goplus/llgo/internal/runtime.Struct"(%"github.com/goplus/llgo/internal/abi.Name" %39, i64 8, %"github.com/goplus/llgo/internal/runtime.Slice" %46)
|
||||||
|
store ptr %47, ptr @"_llgo_struct$K-dZ9QotZfVPz2a0YdRa9vmZUuDXPTqZOlMShKEDJtk", align 8
|
||||||
br label %_llgo_2
|
br label %_llgo_2
|
||||||
|
|
||||||
_llgo_2: ; preds = %_llgo_1, %_llgo_0
|
_llgo_2: ; preds = %_llgo_1, %_llgo_0
|
||||||
ret void
|
ret void
|
||||||
}
|
}
|
||||||
|
|
||||||
declare ptr @"github.com/goplus/llgo/internal/runtime.Struct"(i64, %"github.com/goplus/llgo/internal/runtime.String", %"github.com/goplus/llgo/internal/runtime.Slice")
|
declare ptr @"github.com/goplus/llgo/internal/runtime.Struct"(%"github.com/goplus/llgo/internal/abi.Name", 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, i1)
|
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, i1)
|
||||||
|
|
||||||
declare ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64)
|
declare ptr @"github.com/goplus/llgo/internal/runtime.Basic"(i64)
|
||||||
|
|
||||||
|
declare %"github.com/goplus/llgo/internal/abi.Name" @"github.com/goplus/llgo/internal/runtime.NewPkgName"(%"github.com/goplus/llgo/internal/runtime.String")
|
||||||
|
|
||||||
declare ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64)
|
declare ptr @"github.com/goplus/llgo/internal/runtime.AllocU"(i64)
|
||||||
|
|||||||
@@ -32,14 +32,14 @@ _llgo_0:
|
|||||||
_llgo_1: ; preds = %_llgo_2, %_llgo_0
|
_llgo_1: ; preds = %_llgo_2, %_llgo_0
|
||||||
%8 = phi ptr [ %6, %_llgo_0 ], [ %22, %_llgo_2 ]
|
%8 = phi ptr [ %6, %_llgo_0 ], [ %22, %_llgo_2 ]
|
||||||
%9 = phi i64 [ %7, %_llgo_0 ], [ %23, %_llgo_2 ]
|
%9 = phi i64 [ %7, %_llgo_0 ], [ %23, %_llgo_2 ]
|
||||||
%10 = phi i64 [ -1, %_llgo_0 ], [ %15, %_llgo_2 ]
|
%10 = alloca %"github.com/goplus/llgo/internal/runtime.String", align 8
|
||||||
%11 = 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
|
||||||
%12 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %11, i32 0, i32 0
|
store ptr %8, ptr %11, align 8
|
||||||
store ptr %8, ptr %12, align 8
|
%12 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %10, i32 0, i32 1
|
||||||
%13 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %11, i32 0, i32 1
|
store i64 %9, ptr %12, align 4
|
||||||
store i64 %9, ptr %13, align 4
|
%13 = load %"github.com/goplus/llgo/internal/runtime.String", ptr %10, align 8
|
||||||
%14 = load %"github.com/goplus/llgo/internal/runtime.String", ptr %11, align 8
|
%14 = phi i64 [ -1, %_llgo_0 ], [ %15, %_llgo_2 ]
|
||||||
%15 = add i64 %10, 1
|
%15 = add i64 %14, 1
|
||||||
%16 = icmp slt i64 %15, %1
|
%16 = icmp slt i64 %15, %1
|
||||||
br i1 %16, label %_llgo_2, label %_llgo_3
|
br i1 %16, label %_llgo_2, label %_llgo_3
|
||||||
|
|
||||||
@@ -49,13 +49,13 @@ _llgo_2: ; preds = %_llgo_1
|
|||||||
%18 = extractvalue %"github.com/goplus/llgo/internal/runtime.Slice" %0, 0
|
%18 = extractvalue %"github.com/goplus/llgo/internal/runtime.Slice" %0, 0
|
||||||
%19 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %18, i64 %15
|
%19 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %18, i64 %15
|
||||||
%20 = load %"github.com/goplus/llgo/internal/runtime.String", ptr %19, align 8
|
%20 = load %"github.com/goplus/llgo/internal/runtime.String", ptr %19, align 8
|
||||||
%21 = call %"github.com/goplus/llgo/internal/runtime.String" @"github.com/goplus/llgo/internal/runtime.StringCat"(%"github.com/goplus/llgo/internal/runtime.String" %14, %"github.com/goplus/llgo/internal/runtime.String" %20)
|
%21 = call %"github.com/goplus/llgo/internal/runtime.String" @"github.com/goplus/llgo/internal/runtime.StringCat"(%"github.com/goplus/llgo/internal/runtime.String" %13, %"github.com/goplus/llgo/internal/runtime.String" %20)
|
||||||
%22 = extractvalue %"github.com/goplus/llgo/internal/runtime.String" %21, 0
|
%22 = extractvalue %"github.com/goplus/llgo/internal/runtime.String" %21, 0
|
||||||
%23 = extractvalue %"github.com/goplus/llgo/internal/runtime.String" %21, 1
|
%23 = extractvalue %"github.com/goplus/llgo/internal/runtime.String" %21, 1
|
||||||
br label %_llgo_1
|
br label %_llgo_1
|
||||||
|
|
||||||
_llgo_3: ; preds = %_llgo_1
|
_llgo_3: ; preds = %_llgo_1
|
||||||
ret %"github.com/goplus/llgo/internal/runtime.String" %14
|
ret %"github.com/goplus/llgo/internal/runtime.String" %13
|
||||||
}
|
}
|
||||||
|
|
||||||
define %"github.com/goplus/llgo/internal/runtime.String" @main.info(%"github.com/goplus/llgo/internal/runtime.String" %0) {
|
define %"github.com/goplus/llgo/internal/runtime.String" @main.info(%"github.com/goplus/llgo/internal/runtime.String" %0) {
|
||||||
|
|||||||
@@ -540,7 +540,8 @@ func (p *context) compilePhi(b llssa.Builder, v *ssa.Phi) (ret llssa.Expr) {
|
|||||||
bblks[i] = p.fn.Block(pred.Index)
|
bblks[i] = p.fn.Block(pred.Index)
|
||||||
}
|
}
|
||||||
edges := v.Edges
|
edges := v.Edges
|
||||||
phi.AddIncoming(b, bblks, func(i int) llssa.Expr {
|
phi.AddIncoming(b, bblks, func(i int, blk llssa.BasicBlock) llssa.Expr {
|
||||||
|
b.SetBlockEx(blk, llssa.BeforeLast, false)
|
||||||
return p.compileValue(b, edges[i])
|
return p.compileValue(b, edges[i])
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func TestFromTestgo(t *testing.T) {
|
func TestFromTestgo(t *testing.T) {
|
||||||
cltest.FromDir(t, "abiname", "../cl/_testgo", false)
|
cltest.FromDir(t, "strucintf", "../cl/_testgo", false)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestFromTestpy(t *testing.T) {
|
func TestFromTestpy(t *testing.T) {
|
||||||
|
|||||||
13
ssa/expr.go
13
ssa/expr.go
@@ -525,16 +525,15 @@ func (b Builder) newPhi(t Type, phis []llvm.Value) Phi {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// AddIncoming adds incoming values to a phi node.
|
// AddIncoming adds incoming values to a phi node.
|
||||||
func (p Phi) AddIncoming(b Builder, preds []BasicBlock, f func(i int) Expr) {
|
func (p Phi) AddIncoming(b Builder, preds []BasicBlock, f func(i int, blk BasicBlock) Expr) {
|
||||||
bs := llvmPredBlocks(preds)
|
bs := llvmPredBlocks(preds)
|
||||||
phis := p.phis
|
phis := p.phis
|
||||||
if phis != nil {
|
if phis != nil {
|
||||||
vals := make([][]llvm.Value, len(phis))
|
vals := make([][]llvm.Value, len(phis))
|
||||||
for iblk, blk := range preds {
|
for iblk, blk := range preds {
|
||||||
last := blk.last.LastInstruction()
|
val := f(iblk, blk).impl
|
||||||
b.impl.SetInsertPointBefore(last)
|
|
||||||
impl := b.impl
|
impl := b.impl
|
||||||
val := f(iblk).impl
|
b.SetBlockEx(blk, BeforeLast, false)
|
||||||
for i := range phis {
|
for i := range phis {
|
||||||
if iblk == 0 {
|
if iblk == 0 {
|
||||||
vals[i] = make([]llvm.Value, len(preds))
|
vals[i] = make([]llvm.Value, len(preds))
|
||||||
@@ -548,9 +547,7 @@ func (p Phi) AddIncoming(b Builder, preds []BasicBlock, f func(i int) Expr) {
|
|||||||
} else {
|
} else {
|
||||||
vals := make([]llvm.Value, len(preds))
|
vals := make([]llvm.Value, len(preds))
|
||||||
for iblk, blk := range preds {
|
for iblk, blk := range preds {
|
||||||
last := blk.last.LastInstruction()
|
vals[iblk] = f(iblk, blk).impl
|
||||||
b.impl.SetInsertPointBefore(last)
|
|
||||||
vals[iblk] = f(iblk).impl
|
|
||||||
}
|
}
|
||||||
p.impl.AddIncoming(vals, bs)
|
p.impl.AddIncoming(vals, bs)
|
||||||
}
|
}
|
||||||
@@ -571,7 +568,7 @@ func (b Builder) Phi(t Type) Phi {
|
|||||||
phis := createStrucPhis(impl, nil, tund, b.Prog)
|
phis := createStrucPhis(impl, nil, tund, b.Prog)
|
||||||
return b.newPhi(t, phis)
|
return b.newPhi(t, phis)
|
||||||
default:
|
default:
|
||||||
panic("todo")
|
log.Panicf("todo: %T\n", tund)
|
||||||
}
|
}
|
||||||
phi := llvm.CreatePHI(impl, t.ll)
|
phi := llvm.CreatePHI(impl, t.ll)
|
||||||
return &aPhi{Expr{phi, t}, nil}
|
return &aPhi{Expr{phi, t}, nil}
|
||||||
|
|||||||
@@ -88,7 +88,8 @@ func (b Builder) abiStructOf(t *types.Struct) Expr {
|
|||||||
params := strucAbi.raw.Type.(*types.Signature).Params()
|
params := strucAbi.raw.Type.(*types.Signature).Params()
|
||||||
tSlice := prog.rawType(params.At(params.Len() - 1).Type().(*types.Slice))
|
tSlice := prog.rawType(params.At(params.Len() - 1).Type().(*types.Slice))
|
||||||
fldSlice := b.SliceLit(tSlice, flds...)
|
fldSlice := b.SliceLit(tSlice, flds...)
|
||||||
return b.Call(pkgPath, strucAbi, fldSlice)
|
size := prog.IntVal(prog.SizeOf(typ), prog.Uintptr())
|
||||||
|
return b.Call(strucAbi, pkgPath, size, fldSlice)
|
||||||
}
|
}
|
||||||
|
|
||||||
// func StructField(name string, typ *abi.Type, off uintptr, tag string, exported, embedded bool) abi.StructField
|
// func StructField(name string, typ *abi.Type, off uintptr, tag string, exported, embedded bool) abi.StructField
|
||||||
@@ -296,21 +297,20 @@ func (b Builder) TypeAssert(x Expr, assertedTyp Type, commaOk bool) Expr {
|
|||||||
eq := b.BinOp(token.EQL, tx, tabi)
|
eq := b.BinOp(token.EQL, tx, tabi)
|
||||||
if commaOk {
|
if commaOk {
|
||||||
prog := b.Prog
|
prog := b.Prog
|
||||||
t := prog.Tuple(assertedTyp, prog.Bool())
|
t := prog.Struct(assertedTyp, prog.Bool())
|
||||||
blks := b.Func.MakeBlocks(3)
|
blks := b.Func.MakeBlocks(3)
|
||||||
b.If(eq, blks[0], blks[1])
|
b.If(eq, blks[0], blks[1])
|
||||||
|
|
||||||
b.SetBlockEx(blks[2], AtEnd, false)
|
b.SetBlockEx(blks[2], AtEnd, false)
|
||||||
phi := b.Phi(t)
|
phi := b.Phi(t)
|
||||||
phi.AddIncoming(b, blks[:2], func(i int) Expr {
|
phi.AddIncoming(b, blks[:2], func(i int, blk BasicBlock) Expr {
|
||||||
|
b.SetBlockEx(blk, AtEnd, false)
|
||||||
if i == 0 {
|
if i == 0 {
|
||||||
b.SetBlockEx(blks[0], AtEnd, false)
|
|
||||||
val := b.valFromData(assertedTyp, b.faceData(x.impl))
|
val := b.valFromData(assertedTyp, b.faceData(x.impl))
|
||||||
valTrue := aggregateValue(b.impl, t.ll, val.impl, prog.BoolVal(true).impl)
|
valTrue := aggregateValue(b.impl, t.ll, val.impl, prog.BoolVal(true).impl)
|
||||||
b.Jump(blks[2])
|
b.Jump(blks[2])
|
||||||
return Expr{valTrue, t}
|
return Expr{valTrue, t}
|
||||||
}
|
}
|
||||||
b.SetBlockEx(blks[1], AtEnd, false)
|
|
||||||
zero := prog.Zero(assertedTyp)
|
zero := prog.Zero(assertedTyp)
|
||||||
valFalse := aggregateValue(b.impl, t.ll, zero.impl, prog.BoolVal(false).impl)
|
valFalse := aggregateValue(b.impl, t.ll, zero.impl, prog.BoolVal(false).impl)
|
||||||
b.Jump(blks[2])
|
b.Jump(blks[2])
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ package ssa
|
|||||||
import (
|
import (
|
||||||
"go/token"
|
"go/token"
|
||||||
"go/types"
|
"go/types"
|
||||||
|
"strconv"
|
||||||
"unsafe"
|
"unsafe"
|
||||||
|
|
||||||
"github.com/goplus/llgo/ssa/abi"
|
"github.com/goplus/llgo/ssa/abi"
|
||||||
@@ -296,13 +297,13 @@ func (p Program) NewPackage(name, pkgPath string) Package {
|
|||||||
return ret
|
return ret
|
||||||
}
|
}
|
||||||
|
|
||||||
// Tuple returns a tuple type.
|
// Struct returns a struct type.
|
||||||
func (p Program) Tuple(typs ...Type) Type {
|
func (p Program) Struct(typs ...Type) Type {
|
||||||
els := make([]*types.Var, len(typs))
|
els := make([]*types.Var, len(typs))
|
||||||
for i, t := range typs {
|
for i, t := range typs {
|
||||||
els[i] = types.NewParam(token.NoPos, nil, "", t.raw.Type)
|
els[i] = types.NewParam(token.NoPos, nil, "_llgo_f"+strconv.Itoa(i), t.raw.Type)
|
||||||
}
|
}
|
||||||
return p.rawType(types.NewTuple(els...))
|
return p.rawType(types.NewStruct(els, nil))
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
@@ -80,6 +80,7 @@ type InsertPoint int
|
|||||||
const (
|
const (
|
||||||
AtEnd InsertPoint = iota
|
AtEnd InsertPoint = iota
|
||||||
AtStart
|
AtStart
|
||||||
|
BeforeLast
|
||||||
afterInit
|
afterInit
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -93,6 +94,8 @@ func (b Builder) SetBlockEx(blk BasicBlock, pos InsertPoint, setBlk bool) Builde
|
|||||||
b.impl.SetInsertPointAtEnd(blk.last)
|
b.impl.SetInsertPointAtEnd(blk.last)
|
||||||
case AtStart:
|
case AtStart:
|
||||||
b.impl.SetInsertPointBefore(blk.first.FirstInstruction())
|
b.impl.SetInsertPointBefore(blk.first.FirstInstruction())
|
||||||
|
case BeforeLast:
|
||||||
|
b.impl.SetInsertPointBefore(blk.last.LastInstruction())
|
||||||
case afterInit:
|
case afterInit:
|
||||||
b.impl.SetInsertPointBefore(instrAfterInit(blk.first))
|
b.impl.SetInsertPointBefore(instrAfterInit(blk.first))
|
||||||
default:
|
default:
|
||||||
|
|||||||
Reference in New Issue
Block a user