ssa: index take addr

This commit is contained in:
visualfc
2024-07-02 21:14:36 +08:00
parent 46423ed166
commit 28d8c56534
9 changed files with 466 additions and 91 deletions

View File

@@ -493,17 +493,12 @@ func (p *context) compileInstrOrValue(b llssa.Builder, iv instrOrValue, asValue
case *ssa.Index:
x := p.compileValue(b, v.X)
idx := p.compileValue(b, v.Index)
ret = b.Index(x, idx, func(e llssa.Expr) (ret llssa.Expr, zero bool) {
if e == x {
switch n := v.X.(type) {
case *ssa.Const:
zero = true
return
case *ssa.UnOp:
return p.compileValue(b, n.X), false
}
ret = b.Index(x, idx, func() (r llssa.Expr) {
switch n := v.X.(type) {
case *ssa.UnOp:
return p.compileValue(b, n.X)
}
panic(fmt.Errorf("todo: addr of %v", e))
return
})
case *ssa.Lookup:
x := p.compileValue(b, v.X)