cl/instr:regexp compile one time

This commit is contained in:
luoliwoshang
2025-08-21 19:20:09 +08:00
parent 26fb156d6b
commit f6bc5ac538

View File

@@ -29,6 +29,8 @@ import (
llssa "github.com/goplus/llgo/ssa" llssa "github.com/goplus/llgo/ssa"
) )
var asmRegisterRegex = regexp.MustCompile(`\{[a-zA-Z]+\}`)
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
func constStr(v ssa.Value) (ret string, ok bool) { func constStr(v ssa.Value) (ret string, ok bool) {
@@ -124,7 +126,7 @@ func (p *context) asmFull(b llssa.Builder, args []ssa.Value) (ret llssa.Expr) {
hasOutput = true hasOutput = true
} }
finalAsm = regexp.MustCompile(`\{[a-zA-Z]+\}`).ReplaceAllStringFunc(finalAsm, func(s string) string { finalAsm = asmRegisterRegex.ReplaceAllStringFunc(finalAsm, func(s string) string {
// TODO: skip strings like {r4} etc. that look like ARM push/pop // TODO: skip strings like {r4} etc. that look like ARM push/pop
// instructions. // instructions.
name := s[1 : len(s)-1] name := s[1 : len(s)-1]