ssa: add llgo:link support to Builder.abiMthd

This commit is contained in:
Aofei Sheng
2024-08-03 08:35:19 +08:00
parent 0bd259403c
commit 482f796bad
4 changed files with 87 additions and 0 deletions

View File

@@ -154,6 +154,9 @@ func (b Builder) abiMethodOf(mPkg *types.Package, mName string, mSig *types.Sign
func (b Builder) abiMthd(mPkg *types.Package, mName string, mSig *types.Signature, name, abiTyp, ifn llvm.Value) (ret Expr, tfn llvm.Value) {
fullName := FuncName(mPkg, mName, mSig.Recv())
if b.Pkg.fnlink != nil {
fullName = b.Pkg.fnlink(fullName)
}
tfn = b.Pkg.NewFunc(fullName, mSig, InGo).impl // TODO(xsw): use rawType to speed up
if ifn.IsNil() {
ifn = tfn

View File

@@ -586,6 +586,7 @@ type aPackage struct {
named map[types.Type]Expr
afterb unsafe.Pointer
patch func(types.Type) types.Type
fnlink func(string) string
iRoutine int
}
@@ -658,6 +659,11 @@ func (p Package) SetPatch(fn func(types.Type) types.Type) {
p.patch = fn
}
// SetResolveLinkname sets a function to resolve linkname.
func (p Package) SetResolveLinkname(fn func(string) string) {
p.fnlink = fn
}
// -----------------------------------------------------------------------------
func (p Package) afterBuilder() Builder {