examples/geohash: first version

Adds helper for constants as DATA sections.
This commit is contained in:
Michael McLoughlin
2018-12-27 15:44:52 -08:00
parent 5dea46407c
commit 6fc67c1fbc
6 changed files with 101 additions and 0 deletions

View File

@@ -58,3 +58,5 @@ func Load(src gotypes.Component, dst reg.Register) reg.Register { return ctx.Loa
func Store(src reg.Register, dst gotypes.Component) { ctx.Store(src, dst) }
func AllocLocal(size int) operand.Mem { return ctx.AllocLocal(size) }
func ConstData(name string, v operand.Constant) operand.Mem { return ctx.ConstData(name, v) }

View File

@@ -1,6 +1,7 @@
package build
import (
"github.com/mmcloughlin/avo/operand"
"github.com/mmcloughlin/avo/reg"
"github.com/mmcloughlin/avo/gotypes"
@@ -42,3 +43,9 @@ func (c *Context) Store(src reg.Register, dst gotypes.Component) {
}
c.mov(src, b.Addr, int(src.Bytes()), int(gotypes.Sizes.Sizeof(b.Type)), b.Type)
}
func (c *Context) ConstData(name string, v operand.Constant) operand.Mem {
g := c.StaticGlobal(name)
c.AppendDatum(v)
return g
}