ssa:refine asmFull interface

This commit is contained in:
luoliwoshang
2025-08-21 00:15:59 +08:00
parent 6beb50b367
commit 9dfc6d1d52
2 changed files with 13 additions and 16 deletions

View File

@@ -145,7 +145,14 @@ func (p *context) asmFull(b llssa.Builder, args []ssa.Value) (ret llssa.Expr) {
log.Printf("asmFull: %q -> %q, constraints: %q", asmString, finalAsm, constraintStr)
}
return b.InlineAsmFull(finalAsm, constraintStr, hasOutput, inputValues)
var retType llssa.Type
if hasOutput {
retType = b.Prog.Uintptr()
} else {
retType = b.Prog.Void()
}
return b.InlineAsmFull(finalAsm, constraintStr, retType, inputValues)
}
// -----------------------------------------------------------------------------

View File

@@ -286,26 +286,16 @@ func (b Builder) InlineAsm(instruction string) {
b.impl.CreateCall(typ, asm, nil, "")
}
func (b Builder) InlineAsmFull(instruction, constraints string, output bool, exprs []Expr) (ret Expr) {
var rtType llvm.Type
if output {
rtType = b.Prog.Uintptr().ll
} else {
rtType = b.Prog.tyVoid()
}
func (b Builder) InlineAsmFull(instruction, constraints string, retType Type, exprs []Expr) Expr {
typs := make([]llvm.Type, len(exprs))
vals := make([]llvm.Value, len(exprs))
for i, expr := range exprs {
typs[i] = expr.Type.ll
vals[i] = expr.impl
typs[i], vals[i] = expr.Type.ll, expr.impl
}
typ := llvm.FunctionType(rtType, typs, false)
asm := llvm.InlineAsm(typ, instruction, constraints, true, false, llvm.InlineAsmDialectATT, false)
ret.Type = b.Prog.Uintptr()
ret.impl = b.impl.CreateCall(typ, asm, vals, "")
return
ftype := llvm.FunctionType(retType.ll, typs, false)
asm := llvm.InlineAsm(ftype, instruction, constraints, true, false, llvm.InlineAsmDialectATT, false)
return Expr{b.impl.CreateCall(ftype, asm, vals, ""), retType}
}
// GoString returns a Go string