ssa:refine asmFull interface
This commit is contained in:
@@ -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)
|
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)
|
||||||
}
|
}
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|||||||
20
ssa/expr.go
20
ssa/expr.go
@@ -286,26 +286,16 @@ func (b Builder) InlineAsm(instruction string) {
|
|||||||
b.impl.CreateCall(typ, asm, nil, "")
|
b.impl.CreateCall(typ, asm, nil, "")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b Builder) InlineAsmFull(instruction, constraints string, output bool, exprs []Expr) (ret Expr) {
|
func (b Builder) InlineAsmFull(instruction, constraints string, retType Type, exprs []Expr) Expr {
|
||||||
var rtType llvm.Type
|
|
||||||
if output {
|
|
||||||
rtType = b.Prog.Uintptr().ll
|
|
||||||
} else {
|
|
||||||
rtType = b.Prog.tyVoid()
|
|
||||||
}
|
|
||||||
|
|
||||||
typs := make([]llvm.Type, len(exprs))
|
typs := make([]llvm.Type, len(exprs))
|
||||||
vals := make([]llvm.Value, len(exprs))
|
vals := make([]llvm.Value, len(exprs))
|
||||||
for i, expr := range exprs {
|
for i, expr := range exprs {
|
||||||
typs[i] = expr.Type.ll
|
typs[i], vals[i] = expr.Type.ll, expr.impl
|
||||||
vals[i] = expr.impl
|
|
||||||
}
|
}
|
||||||
|
|
||||||
typ := llvm.FunctionType(rtType, typs, false)
|
ftype := llvm.FunctionType(retType.ll, typs, false)
|
||||||
asm := llvm.InlineAsm(typ, instruction, constraints, true, false, llvm.InlineAsmDialectATT, false)
|
asm := llvm.InlineAsm(ftype, instruction, constraints, true, false, llvm.InlineAsmDialectATT, false)
|
||||||
ret.Type = b.Prog.Uintptr()
|
return Expr{b.impl.CreateCall(ftype, asm, vals, ""), retType}
|
||||||
ret.impl = b.impl.CreateCall(typ, asm, vals, "")
|
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// GoString returns a Go string
|
// GoString returns a Go string
|
||||||
|
|||||||
Reference in New Issue
Block a user