Skip to content

Commit

Permalink
add support for go 123
Browse files Browse the repository at this point in the history
  • Loading branch information
ovechkin-dm authored Aug 27, 2024
1 parent 7cd1f54 commit a4ba0b8
Show file tree
Hide file tree
Showing 13 changed files with 4,614 additions and 12,541 deletions.
31 changes: 0 additions & 31 deletions cmd/arm/hello.go

This file was deleted.

62 changes: 0 additions & 62 deletions cmd/cache_example/cache.go

This file was deleted.

76 changes: 26 additions & 50 deletions cmd/generate/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,33 +34,15 @@ var asmTemplate = `
#define LOCAL_REGARGS 40
{{range $idx,$_:= .}}
TEXT ·makeFuncStub{{$idx}}(SB),(NOSPLIT|WRAPPER),$312
TEXT ·makeFuncStub{{$idx}}(SB),(NOSPLIT|NOFRAME|WRAPPER),$0
NO_LOCAL_POINTERS
LEAQ LOCAL_REGARGS(SP), R12
CALL runtime·spillArgs(SB)
MOVQ AX, 24(SP)
MOVQ AX, 0(SP)
MOVQ R12, 8(SP)
MOVQ ${{$idx}}, 16(SP)
CALL ·moveMakeFuncArgPtrsCustom(SB)
MOVQ 24(SP), AX
MOVQ AX, 0(SP)
LEAQ argframe+0(FP), AX
MOVQ AX, 8(SP)
MOVB $0, LOCAL_RETVALID(SP)
LEAQ LOCAL_RETVALID(SP), AX
MOVQ AX, 16(SP)
LEAQ LOCAL_REGARGS(SP), AX
MOVQ AX, 24(SP)
MOVQ ${{$idx}}, 32(SP)
CALL ·callReflectCustom(SB)
LEAQ LOCAL_REGARGS(SP), R12
CALL runtime·unspillArgs(SB)
MOVQ 0(AX), DX
MOVQ 0(DX), DX
MOVQ {{mul $idx 8}}(DX), DX
MOVQ (DX), AX
CALL AX
RET
{{end}}
`
{{end}}`

var armTemplate = `
#include "textflag.h"
Expand All @@ -70,35 +52,29 @@ var armTemplate = `
#define LOCAL_REGARGS 48
{{range $idx,$_:= .}}
TEXT ·makeFuncStub{{$idx}}(SB),(NOSPLIT|WRAPPER),$432
NO_LOCAL_POINTERS
ADD $LOCAL_REGARGS, RSP, R20
CALL runtime·spillArgs(SB)
MOVD R20, 16(RSP)
MOVD R0, 8(RSP)
MOVD ${{$idx}}, R26
MOVD R26, 24(RSP)
CALL ·moveMakeFuncArgPtrsCustom(SB)
MOVD $argframe+0(FP), R3
MOVD R3, 16(RSP)
MOVB $0, LOCAL_RETVALID(RSP)
ADD $LOCAL_RETVALID, RSP, R3
MOVD R3, 24(RSP)
ADD $LOCAL_REGARGS, RSP, R3
MOVD R3, 32(RSP)
MOVD ${{$idx}}, R3
MOVD R3, 40(RSP)
CALL ·callReflectCustom(SB)
ADD $LOCAL_REGARGS, RSP, R20
CALL runtime·unspillArgs(SB)
RET
TEXT ·makeFuncStub{{$idx}}(SB),(NOSPLIT|WRAPPER),$0
NO_LOCAL_POINTERS
MOVD 0(R0), R26
MOVD 0(R26), R26
MOVD {{mul $idx 8}}(R26), R26
MOVD (R26), R0
CALL R0
RET
{{end}}
`

var num = flag.Int("m", 250, "")

func mul(a, b int) int {
return a * b
}

var funcMap = template.FuncMap{
"mul": mul,
}

func main() {
goT := template.Must(template.New("").Parse(goTemplate))
goT := template.Must(template.New("").Funcs(funcMap).Parse(goTemplate))
mg, err := os.Create("./proxy/gen.go")
if err != nil {
panic(err)
Expand All @@ -107,12 +83,12 @@ func main() {

goT.Execute(mg, make([]struct{}, *num))

amdasmT := template.Must(template.New("").Parse(asmTemplate))
amdasmT := template.Must(template.New("").Funcs(funcMap).Parse(asmTemplate))
ag2, _ := os.Create("./proxy/asm_amd64.s")
defer ag2.Close()
amdasmT.Execute(ag2, make([]struct{}, *num))

armasmT := template.Must(template.New("").Parse(armTemplate))
armasmT := template.Must(template.New("").Funcs(funcMap).Parse(armTemplate))
ag3, _ := os.Create("./proxy/asm_arm64.s")
defer ag3.Close()
armasmT.Execute(ag3, make([]struct{}, *num))
Expand Down
29 changes: 0 additions & 29 deletions cmd/varargs/main.go

This file was deleted.

Loading

0 comments on commit a4ba0b8

Please sign in to comment.