From 26fb156d6b59d8be2f4875a798daffb31af8bdfd Mon Sep 17 00:00:00 2001 From: luoliwoshang <2643523683@qq.com> Date: Thu, 21 Aug 2025 16:30:52 +0800 Subject: [PATCH] cl/instr:only permit interger at asmfull --- cl/instr.go | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/cl/instr.go b/cl/instr.go index 5ea09e9a..82c3b620 100644 --- a/cl/instr.go +++ b/cl/instr.go @@ -133,9 +133,24 @@ func (p *context) asmFull(b llssa.Builder, args []ssa.Value) (ret llssa.Expr) { panic("asmFull: register not found: " + name) } if _, ok := registerNumbers[name]; !ok { - registerNumbers[name] = len(registerNumbers) - inputValues = append(inputValues, value) - constraints = append(constraints, "r") + // Type checking based on Go types - similar to TinyGo's implementation + rawType := value.Type.RawType() + switch typ := rawType.Underlying().(type) { + case *types.Basic: + if typ.Info()&types.IsInteger != 0 { + registerNumbers[name] = len(registerNumbers) + inputValues = append(inputValues, value) + constraints = append(constraints, "r") + } else { + panic("asmFull: unsupported basic type in inline assembly for operand: " + name + ", only integer types are supported") + } + case *types.Pointer: + // Pointer operands support was dropped, following TinyGo 0.23 + panic("asmFull: not support for pointer operands: " + name + ", only integer types are supported") + default: + panic("asmFull: unsupported type in inline assembly for operand: " + name + ", only integer types are supported") + } + } return fmt.Sprintf("${%v}", registerNumbers[name]) })