llgo/ssa: PyList

This commit is contained in:
xushiwei
2024-05-15 14:49:00 +08:00
parent c1bf895674
commit 59d68c6438
9 changed files with 100 additions and 35 deletions

View File

@@ -313,6 +313,8 @@ func (p *context) funcOf(fn *ssa.Function) (aFn llssa.Function, pyFn llssa.PyObj
ftype = llgoAllocaCStr
case "stringData":
ftype = llgoStringData
case "pyList":
ftype = llgoPyList
case "unreachable":
ftype = llgoUnreachable
default:
@@ -519,6 +521,14 @@ func (p *context) stringData(b llssa.Builder, args []ssa.Value) (ret llssa.Expr)
panic("stringData(s string): invalid arguments")
}
func (p *context) pyList(b llssa.Builder, args []ssa.Value) (ret llssa.Expr) {
vals := make([]llssa.Expr, len(args))
for i, arg := range args {
vals[i] = p.compileValue(b, arg)
}
return b.PyList(vals...)
}
func isPhi(i ssa.Instruction) bool {
_, ok := i.(*ssa.Phi)
return ok
@@ -615,6 +625,8 @@ func (p *context) compileInstrOrValue(b llssa.Builder, iv instrOrValue, asValue
ret = p.allocaCStr(b, args)
case llgoStringData:
ret = p.stringData(b, args)
case llgoPyList:
ret = p.pyList(b, args)
case llgoUnreachable: // func unreachable()
b.Unreachable()
default: