-
Notifications
You must be signed in to change notification settings - Fork 47
cl(feat): llgo.asm implement tinygo.AsmFull #1224
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
485dbe4
cl/instr:asm with two situation
luoliwoshang ae36ef4
cl/instr:replace register & build constraints
luoliwoshang f5d4f93
ssa:inlineAsmFull
luoliwoshang 9e0c50d
cl/instr:asmFull test case with input only
luoliwoshang 6beb50b
cl/instr:asmFull test case with multiple input & output
luoliwoshang 9dfc6d1
ssa:refine asmFull interface
luoliwoshang b428a8a
test:asmFull function test
luoliwoshang ef1f2bc
test:linux asmFull function test
luoliwoshang d548671
test:linux with leaq to confirm asmFull
luoliwoshang 26fb156
cl/instr:only permit interger at asmfull
luoliwoshang f6bc5ac
cl/instr:regexp compile one time
luoliwoshang 0faef11
cl/instr:refine register collect
luoliwoshang 04f613d
cl/test:asmFull error
luoliwoshang d9dc4d5
cl/instr:move to one asm
luoliwoshang 49b9b92
ci/instr:fix asmFull return type to match function signature when no …
luoliwoshang f3de14d
cl/instr:note for why asm not support pointer type:
luoliwoshang File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| package main | ||
|
|
||
| import ( | ||
| "fmt" | ||
| ) | ||
|
|
||
| //llgo:link asmFull llgo.asm | ||
| func asmFull(instruction string, regs map[string]any) uintptr { return 0 } | ||
|
|
||
| var testVar = 0 | ||
|
|
||
| func main() { | ||
| verify() | ||
| } | ||
|
|
||
| func check(expected, actual int) { | ||
| if expected != actual { | ||
| panic(fmt.Sprintf("Expected: %d, Got: %d\n", expected, actual)) | ||
| } | ||
| fmt.Println("asm check passed:", actual) | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| //go:build darwin && arm64 | ||
|
|
||
| package main | ||
|
|
||
| import "unsafe" | ||
|
|
||
| func verify() { | ||
| // 0 output & 0 input | ||
| asmFull("nop", nil) | ||
|
|
||
| // 0 output & 1 input with memory address | ||
| addr := uintptr(unsafe.Pointer(&testVar)) | ||
| asmFull("str {value}, [{addr}]", map[string]any{ | ||
| "addr": addr, | ||
| "value": 43, | ||
| }) | ||
| check(43, testVar) | ||
|
|
||
| // 1 output & 1 input | ||
| res1 := asmFull("mov {}, {value}", map[string]any{ | ||
| "value": 41, | ||
| }) | ||
| check(41, int(res1)) | ||
|
|
||
| // 1 output & 2 inputs | ||
| res2 := asmFull("add {}, {a}, {b}", map[string]any{ | ||
| "a": 25, | ||
| "b": 17, | ||
| }) | ||
| check(42, int(res2)) | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| //go:build linux && amd64 | ||
|
|
||
| package main | ||
|
|
||
| import "unsafe" | ||
|
|
||
| func verify() { | ||
| // 0 output & 0 input | ||
| asmFull("nop", nil) | ||
|
|
||
| // 0 output & 1 input with memory address | ||
| addr := uintptr(unsafe.Pointer(&testVar)) | ||
| asmFull("movq {value}, ({addr})", map[string]any{ | ||
| "addr": addr, | ||
| "value": 43, | ||
| }) | ||
| check(43, testVar) | ||
|
|
||
| // 1 output & 1 input | ||
| res1 := asmFull("movq {value}, {}", map[string]any{ | ||
| "value": 41, | ||
| }) | ||
| check(41, int(res1)) | ||
|
|
||
| res2 := asmFull("leaq ({a},{b}), {}", map[string]any{ | ||
| "a": 25, | ||
| "b": 17, | ||
| }) | ||
| check(42, int(res2)) | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| package main | ||
|
|
||
| import _ "unsafe" | ||
|
|
||
| //go:linkname asmFull llgo.asm | ||
| func asmFull(instruction string, regs map[string]any) uintptr | ||
|
|
||
| func main() { | ||
| // no input,no return value | ||
| asmFull("nop", nil) | ||
| // input only,no return value | ||
| asmFull("# test value {value}", map[string]any{"value": 42}) | ||
| // input with return value | ||
| res1 := asmFull("mov {}, {value}", map[string]any{ | ||
| "value": 42, | ||
| }) | ||
| println("Result:", res1) | ||
| // note(zzy): multiple inputs with return value | ||
| // only for test register & constraint,not have actual meaning | ||
| // the ir compare cannot crossplatform currently | ||
| // so just use a comment to test it | ||
| res2 := asmFull("# calc {x} + {y} -> {}", map[string]any{ | ||
| "x": 25, | ||
| "y": 17, | ||
| }) | ||
| println("Result:", res2) | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,203 @@ | ||
| ; ModuleID = 'github.com/goplus/llgo/cl/_testrt/asmfull' | ||
| source_filename = "github.com/goplus/llgo/cl/_testrt/asmfull" | ||
|
|
||
| %"github.com/goplus/llgo/runtime/internal/runtime.eface" = type { ptr, ptr } | ||
| %"github.com/goplus/llgo/runtime/internal/runtime.String" = type { ptr, i64 } | ||
| %"github.com/goplus/llgo/runtime/internal/runtime.Slice" = type { ptr, i64, i64 } | ||
| %"github.com/goplus/llgo/runtime/abi.StructField" = type { %"github.com/goplus/llgo/runtime/internal/runtime.String", ptr, i64, %"github.com/goplus/llgo/runtime/internal/runtime.String", i1 } | ||
|
|
||
| @"github.com/goplus/llgo/cl/_testrt/asmfull.init$guard" = global i1 false, align 1 | ||
| @_llgo_string = linkonce global ptr null, align 8 | ||
| @_llgo_any = linkonce global ptr null, align 8 | ||
| @0 = private unnamed_addr constant [41 x i8] c"github.com/goplus/llgo/cl/_testrt/asmfull", align 1 | ||
| @"map[_llgo_string]_llgo_any" = linkonce global ptr null, align 8 | ||
| @1 = private unnamed_addr constant [7 x i8] c"topbits", align 1 | ||
| @2 = private unnamed_addr constant [4 x i8] c"keys", align 1 | ||
| @3 = private unnamed_addr constant [5 x i8] c"elems", align 1 | ||
| @4 = private unnamed_addr constant [8 x i8] c"overflow", align 1 | ||
| @_llgo_int = linkonce global ptr null, align 8 | ||
| @5 = private unnamed_addr constant [5 x i8] c"value", align 1 | ||
| @6 = private unnamed_addr constant [7 x i8] c"Result:", align 1 | ||
| @7 = private unnamed_addr constant [1 x i8] c"x", align 1 | ||
| @8 = private unnamed_addr constant [1 x i8] c"y", align 1 | ||
|
|
||
| define void @"github.com/goplus/llgo/cl/_testrt/asmfull.init"() { | ||
| _llgo_0: | ||
| %0 = load i1, ptr @"github.com/goplus/llgo/cl/_testrt/asmfull.init$guard", align 1 | ||
| br i1 %0, label %_llgo_2, label %_llgo_1 | ||
|
|
||
| _llgo_1: ; preds = %_llgo_0 | ||
| store i1 true, ptr @"github.com/goplus/llgo/cl/_testrt/asmfull.init$guard", align 1 | ||
| call void @"github.com/goplus/llgo/cl/_testrt/asmfull.init$after"() | ||
| br label %_llgo_2 | ||
|
|
||
| _llgo_2: ; preds = %_llgo_1, %_llgo_0 | ||
| ret void | ||
| } | ||
|
|
||
| define void @"github.com/goplus/llgo/cl/_testrt/asmfull.main"() { | ||
| _llgo_0: | ||
| call void asm sideeffect "nop", ""() | ||
| %0 = load ptr, ptr @_llgo_string, align 8 | ||
| %1 = load ptr, ptr @_llgo_any, align 8 | ||
| %2 = load ptr, ptr @"map[_llgo_string]_llgo_any", align 8 | ||
| %3 = call ptr @"github.com/goplus/llgo/runtime/internal/runtime.MakeMap"(ptr %2, i64 1) | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove runtime dependency in another PR |
||
| %4 = load ptr, ptr @_llgo_int, align 8 | ||
| %5 = insertvalue %"github.com/goplus/llgo/runtime/internal/runtime.eface" undef, ptr %4, 0 | ||
| %6 = insertvalue %"github.com/goplus/llgo/runtime/internal/runtime.eface" %5, ptr inttoptr (i64 42 to ptr), 1 | ||
| %7 = load ptr, ptr @"map[_llgo_string]_llgo_any", align 8 | ||
| %8 = call ptr @"github.com/goplus/llgo/runtime/internal/runtime.AllocU"(i64 16) | ||
| store %"github.com/goplus/llgo/runtime/internal/runtime.String" { ptr @5, i64 5 }, ptr %8, align 8 | ||
| %9 = call ptr @"github.com/goplus/llgo/runtime/internal/runtime.MapAssign"(ptr %7, ptr %3, ptr %8) | ||
| store %"github.com/goplus/llgo/runtime/internal/runtime.eface" %6, ptr %9, align 8 | ||
| call void asm sideeffect "# test value ${0}", "r"(i64 42) | ||
| %10 = load ptr, ptr @"map[_llgo_string]_llgo_any", align 8 | ||
| %11 = call ptr @"github.com/goplus/llgo/runtime/internal/runtime.MakeMap"(ptr %10, i64 1) | ||
| %12 = load ptr, ptr @_llgo_int, align 8 | ||
| %13 = insertvalue %"github.com/goplus/llgo/runtime/internal/runtime.eface" undef, ptr %12, 0 | ||
| %14 = insertvalue %"github.com/goplus/llgo/runtime/internal/runtime.eface" %13, ptr inttoptr (i64 42 to ptr), 1 | ||
| %15 = load ptr, ptr @"map[_llgo_string]_llgo_any", align 8 | ||
| %16 = call ptr @"github.com/goplus/llgo/runtime/internal/runtime.AllocU"(i64 16) | ||
| store %"github.com/goplus/llgo/runtime/internal/runtime.String" { ptr @5, i64 5 }, ptr %16, align 8 | ||
| %17 = call ptr @"github.com/goplus/llgo/runtime/internal/runtime.MapAssign"(ptr %15, ptr %11, ptr %16) | ||
| store %"github.com/goplus/llgo/runtime/internal/runtime.eface" %14, ptr %17, align 8 | ||
| %18 = call i64 asm sideeffect "mov $0, ${1}", "=&r,r"(i64 42) | ||
| call void @"github.com/goplus/llgo/runtime/internal/runtime.PrintString"(%"github.com/goplus/llgo/runtime/internal/runtime.String" { ptr @6, i64 7 }) | ||
| call void @"github.com/goplus/llgo/runtime/internal/runtime.PrintByte"(i8 32) | ||
| call void @"github.com/goplus/llgo/runtime/internal/runtime.PrintUint"(i64 %18) | ||
| call void @"github.com/goplus/llgo/runtime/internal/runtime.PrintByte"(i8 10) | ||
| %19 = load ptr, ptr @"map[_llgo_string]_llgo_any", align 8 | ||
| %20 = call ptr @"github.com/goplus/llgo/runtime/internal/runtime.MakeMap"(ptr %19, i64 2) | ||
| %21 = load ptr, ptr @_llgo_int, align 8 | ||
| %22 = insertvalue %"github.com/goplus/llgo/runtime/internal/runtime.eface" undef, ptr %21, 0 | ||
| %23 = insertvalue %"github.com/goplus/llgo/runtime/internal/runtime.eface" %22, ptr inttoptr (i64 25 to ptr), 1 | ||
| %24 = load ptr, ptr @"map[_llgo_string]_llgo_any", align 8 | ||
| %25 = call ptr @"github.com/goplus/llgo/runtime/internal/runtime.AllocU"(i64 16) | ||
| store %"github.com/goplus/llgo/runtime/internal/runtime.String" { ptr @7, i64 1 }, ptr %25, align 8 | ||
| %26 = call ptr @"github.com/goplus/llgo/runtime/internal/runtime.MapAssign"(ptr %24, ptr %20, ptr %25) | ||
| store %"github.com/goplus/llgo/runtime/internal/runtime.eface" %23, ptr %26, align 8 | ||
| %27 = load ptr, ptr @_llgo_int, align 8 | ||
| %28 = insertvalue %"github.com/goplus/llgo/runtime/internal/runtime.eface" undef, ptr %27, 0 | ||
| %29 = insertvalue %"github.com/goplus/llgo/runtime/internal/runtime.eface" %28, ptr inttoptr (i64 17 to ptr), 1 | ||
| %30 = load ptr, ptr @"map[_llgo_string]_llgo_any", align 8 | ||
| %31 = call ptr @"github.com/goplus/llgo/runtime/internal/runtime.AllocU"(i64 16) | ||
| store %"github.com/goplus/llgo/runtime/internal/runtime.String" { ptr @8, i64 1 }, ptr %31, align 8 | ||
| %32 = call ptr @"github.com/goplus/llgo/runtime/internal/runtime.MapAssign"(ptr %30, ptr %20, ptr %31) | ||
| store %"github.com/goplus/llgo/runtime/internal/runtime.eface" %29, ptr %32, align 8 | ||
| %33 = call i64 asm sideeffect "# calc ${1} + ${2} -> $0", "=&r,r,r"(i64 25, i64 17) | ||
| call void @"github.com/goplus/llgo/runtime/internal/runtime.PrintString"(%"github.com/goplus/llgo/runtime/internal/runtime.String" { ptr @6, i64 7 }) | ||
| call void @"github.com/goplus/llgo/runtime/internal/runtime.PrintByte"(i8 32) | ||
| call void @"github.com/goplus/llgo/runtime/internal/runtime.PrintUint"(i64 %33) | ||
| call void @"github.com/goplus/llgo/runtime/internal/runtime.PrintByte"(i8 10) | ||
| ret void | ||
| } | ||
|
|
||
| define void @"github.com/goplus/llgo/cl/_testrt/asmfull.init$after"() { | ||
| _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/runtime/internal/runtime.Basic"(i64 24) | ||
| store ptr %2, ptr @_llgo_string, align 8 | ||
| br label %_llgo_2 | ||
|
|
||
| _llgo_2: ; preds = %_llgo_1, %_llgo_0 | ||
| %3 = load ptr, ptr @_llgo_any, 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/runtime/internal/runtime.AllocU"(i64 0) | ||
| %6 = insertvalue %"github.com/goplus/llgo/runtime/internal/runtime.Slice" undef, ptr %5, 0 | ||
| %7 = insertvalue %"github.com/goplus/llgo/runtime/internal/runtime.Slice" %6, i64 0, 1 | ||
| %8 = insertvalue %"github.com/goplus/llgo/runtime/internal/runtime.Slice" %7, i64 0, 2 | ||
| %9 = call ptr @"github.com/goplus/llgo/runtime/internal/runtime.Interface"(%"github.com/goplus/llgo/runtime/internal/runtime.String" { ptr @0, i64 41 }, %"github.com/goplus/llgo/runtime/internal/runtime.Slice" %8) | ||
| store ptr %9, ptr @_llgo_any, align 8 | ||
| br label %_llgo_4 | ||
|
|
||
| _llgo_4: ; preds = %_llgo_3, %_llgo_2 | ||
| %10 = load ptr, ptr @"map[_llgo_string]_llgo_any", align 8 | ||
| %11 = icmp eq ptr %10, null | ||
| br i1 %11, label %_llgo_5, label %_llgo_6 | ||
|
|
||
| _llgo_5: ; preds = %_llgo_4 | ||
| %12 = call ptr @"github.com/goplus/llgo/runtime/internal/runtime.Basic"(i64 24) | ||
| %13 = call ptr @"github.com/goplus/llgo/runtime/internal/runtime.AllocU"(i64 0) | ||
| %14 = insertvalue %"github.com/goplus/llgo/runtime/internal/runtime.Slice" undef, ptr %13, 0 | ||
| %15 = insertvalue %"github.com/goplus/llgo/runtime/internal/runtime.Slice" %14, i64 0, 1 | ||
| %16 = insertvalue %"github.com/goplus/llgo/runtime/internal/runtime.Slice" %15, i64 0, 2 | ||
| %17 = call ptr @"github.com/goplus/llgo/runtime/internal/runtime.Interface"(%"github.com/goplus/llgo/runtime/internal/runtime.String" { ptr @0, i64 41 }, %"github.com/goplus/llgo/runtime/internal/runtime.Slice" %16) | ||
| %18 = call ptr @"github.com/goplus/llgo/runtime/internal/runtime.Basic"(i64 40) | ||
| %19 = call ptr @"github.com/goplus/llgo/runtime/internal/runtime.ArrayOf"(i64 8, ptr %18) | ||
| %20 = call %"github.com/goplus/llgo/runtime/abi.StructField" @"github.com/goplus/llgo/runtime/internal/runtime.StructField"(%"github.com/goplus/llgo/runtime/internal/runtime.String" { ptr @1, i64 7 }, ptr %19, i64 0, %"github.com/goplus/llgo/runtime/internal/runtime.String" zeroinitializer, i1 false) | ||
| %21 = call ptr @"github.com/goplus/llgo/runtime/internal/runtime.Basic"(i64 24) | ||
| %22 = call ptr @"github.com/goplus/llgo/runtime/internal/runtime.ArrayOf"(i64 8, ptr %21) | ||
| %23 = call %"github.com/goplus/llgo/runtime/abi.StructField" @"github.com/goplus/llgo/runtime/internal/runtime.StructField"(%"github.com/goplus/llgo/runtime/internal/runtime.String" { ptr @2, i64 4 }, ptr %22, i64 8, %"github.com/goplus/llgo/runtime/internal/runtime.String" zeroinitializer, i1 false) | ||
| %24 = call ptr @"github.com/goplus/llgo/runtime/internal/runtime.AllocU"(i64 0) | ||
| %25 = insertvalue %"github.com/goplus/llgo/runtime/internal/runtime.Slice" undef, ptr %24, 0 | ||
| %26 = insertvalue %"github.com/goplus/llgo/runtime/internal/runtime.Slice" %25, i64 0, 1 | ||
| %27 = insertvalue %"github.com/goplus/llgo/runtime/internal/runtime.Slice" %26, i64 0, 2 | ||
| %28 = call ptr @"github.com/goplus/llgo/runtime/internal/runtime.Interface"(%"github.com/goplus/llgo/runtime/internal/runtime.String" { ptr @0, i64 41 }, %"github.com/goplus/llgo/runtime/internal/runtime.Slice" %27) | ||
| %29 = call ptr @"github.com/goplus/llgo/runtime/internal/runtime.ArrayOf"(i64 8, ptr %28) | ||
| %30 = call %"github.com/goplus/llgo/runtime/abi.StructField" @"github.com/goplus/llgo/runtime/internal/runtime.StructField"(%"github.com/goplus/llgo/runtime/internal/runtime.String" { ptr @3, i64 5 }, ptr %29, i64 136, %"github.com/goplus/llgo/runtime/internal/runtime.String" zeroinitializer, i1 false) | ||
| %31 = call ptr @"github.com/goplus/llgo/runtime/internal/runtime.Basic"(i64 58) | ||
| %32 = call %"github.com/goplus/llgo/runtime/abi.StructField" @"github.com/goplus/llgo/runtime/internal/runtime.StructField"(%"github.com/goplus/llgo/runtime/internal/runtime.String" { ptr @4, i64 8 }, ptr %31, i64 264, %"github.com/goplus/llgo/runtime/internal/runtime.String" zeroinitializer, i1 false) | ||
| %33 = call ptr @"github.com/goplus/llgo/runtime/internal/runtime.AllocU"(i64 224) | ||
| %34 = getelementptr %"github.com/goplus/llgo/runtime/abi.StructField", ptr %33, i64 0 | ||
| store %"github.com/goplus/llgo/runtime/abi.StructField" %20, ptr %34, align 8 | ||
| %35 = getelementptr %"github.com/goplus/llgo/runtime/abi.StructField", ptr %33, i64 1 | ||
| store %"github.com/goplus/llgo/runtime/abi.StructField" %23, ptr %35, align 8 | ||
| %36 = getelementptr %"github.com/goplus/llgo/runtime/abi.StructField", ptr %33, i64 2 | ||
| store %"github.com/goplus/llgo/runtime/abi.StructField" %30, ptr %36, align 8 | ||
| %37 = getelementptr %"github.com/goplus/llgo/runtime/abi.StructField", ptr %33, i64 3 | ||
| store %"github.com/goplus/llgo/runtime/abi.StructField" %32, ptr %37, align 8 | ||
| %38 = insertvalue %"github.com/goplus/llgo/runtime/internal/runtime.Slice" undef, ptr %33, 0 | ||
| %39 = insertvalue %"github.com/goplus/llgo/runtime/internal/runtime.Slice" %38, i64 4, 1 | ||
| %40 = insertvalue %"github.com/goplus/llgo/runtime/internal/runtime.Slice" %39, i64 4, 2 | ||
| %41 = call ptr @"github.com/goplus/llgo/runtime/internal/runtime.Struct"(%"github.com/goplus/llgo/runtime/internal/runtime.String" { ptr @0, i64 41 }, i64 272, %"github.com/goplus/llgo/runtime/internal/runtime.Slice" %40) | ||
| %42 = call ptr @"github.com/goplus/llgo/runtime/internal/runtime.MapOf"(ptr %12, ptr %17, ptr %41, i64 12) | ||
| call void @"github.com/goplus/llgo/runtime/internal/runtime.SetDirectIface"(ptr %42) | ||
| store ptr %42, ptr @"map[_llgo_string]_llgo_any", align 8 | ||
| br label %_llgo_6 | ||
|
|
||
| _llgo_6: ; preds = %_llgo_5, %_llgo_4 | ||
| %43 = load ptr, ptr @_llgo_int, align 8 | ||
| %44 = icmp eq ptr %43, null | ||
| br i1 %44, label %_llgo_7, label %_llgo_8 | ||
|
|
||
| _llgo_7: ; preds = %_llgo_6 | ||
| %45 = call ptr @"github.com/goplus/llgo/runtime/internal/runtime.Basic"(i64 34) | ||
| store ptr %45, ptr @_llgo_int, align 8 | ||
| br label %_llgo_8 | ||
|
|
||
| _llgo_8: ; preds = %_llgo_7, %_llgo_6 | ||
| ret void | ||
| } | ||
|
|
||
| declare ptr @"github.com/goplus/llgo/runtime/internal/runtime.Basic"(i64) | ||
|
|
||
| declare ptr @"github.com/goplus/llgo/runtime/internal/runtime.Interface"(%"github.com/goplus/llgo/runtime/internal/runtime.String", %"github.com/goplus/llgo/runtime/internal/runtime.Slice") | ||
|
|
||
| declare ptr @"github.com/goplus/llgo/runtime/internal/runtime.AllocU"(i64) | ||
|
|
||
| declare ptr @"github.com/goplus/llgo/runtime/internal/runtime.MapOf"(ptr, ptr, ptr, i64) | ||
|
|
||
| declare ptr @"github.com/goplus/llgo/runtime/internal/runtime.Struct"(%"github.com/goplus/llgo/runtime/internal/runtime.String", i64, %"github.com/goplus/llgo/runtime/internal/runtime.Slice") | ||
|
|
||
| declare %"github.com/goplus/llgo/runtime/abi.StructField" @"github.com/goplus/llgo/runtime/internal/runtime.StructField"(%"github.com/goplus/llgo/runtime/internal/runtime.String", ptr, i64, %"github.com/goplus/llgo/runtime/internal/runtime.String", i1) | ||
|
|
||
| declare ptr @"github.com/goplus/llgo/runtime/internal/runtime.ArrayOf"(i64, ptr) | ||
|
|
||
| declare void @"github.com/goplus/llgo/runtime/internal/runtime.SetDirectIface"(ptr) | ||
|
|
||
| declare ptr @"github.com/goplus/llgo/runtime/internal/runtime.MakeMap"(ptr, i64) | ||
|
|
||
| declare ptr @"github.com/goplus/llgo/runtime/internal/runtime.MapAssign"(ptr, ptr, ptr) | ||
|
|
||
| declare void @"github.com/goplus/llgo/runtime/internal/runtime.PrintString"(%"github.com/goplus/llgo/runtime/internal/runtime.String") | ||
|
|
||
| declare void @"github.com/goplus/llgo/runtime/internal/runtime.PrintByte"(i8) | ||
|
|
||
| declare void @"github.com/goplus/llgo/runtime/internal/runtime.PrintUint"(i64) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why pointer type is not supported?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Current logic is fully corespoding with
Tinygo,so panic with same case.And the reason TinyGo currently doesn't support pointer operands in inline assembly is due to LLVM's transition from typed pointers to opaque pointers starting with LLVM 14 (https://llvm.org/docs/OpaquePointers.html). This change requires inline assembly to explicitly declare pointer element types using the
elementtypeattribute (https://reviews.llvm.org/D116531). Rather than implementing the additional complexity, TinyGo chose to remove pointer support entirely (tinygo-org/tinygo@cad6a57).However, I believe it's possible to add back this pointer type support. As TinyGo's comment indicates, it would require modifying the go-llvm API. I think we should make this functionality available first, and then support this feature in a separate PR (after all, going from
uintptr(unsafe.Pointer(&val))to&valwouldn't introduce breaking changes).