2018-11-30 20:43:31 -08:00
|
|
|
package build
|
|
|
|
|
|
2018-11-30 20:58:51 -08:00
|
|
|
import (
|
|
|
|
|
"flag"
|
|
|
|
|
"os"
|
2018-11-30 21:37:17 -08:00
|
|
|
|
2018-12-08 22:02:02 -08:00
|
|
|
"github.com/mmcloughlin/avo/gotypes"
|
2018-12-21 00:30:59 -08:00
|
|
|
"github.com/mmcloughlin/avo/operand"
|
2018-12-08 22:02:02 -08:00
|
|
|
|
|
|
|
|
"github.com/mmcloughlin/avo/reg"
|
|
|
|
|
|
2018-11-30 21:37:17 -08:00
|
|
|
"github.com/mmcloughlin/avo"
|
2018-11-30 20:58:51 -08:00
|
|
|
)
|
2018-11-30 20:43:31 -08:00
|
|
|
|
|
|
|
|
// ctx provides a global build context.
|
|
|
|
|
var ctx = NewContext()
|
|
|
|
|
|
2018-12-17 20:52:26 -08:00
|
|
|
func Package(path string) { ctx.Package(path) }
|
|
|
|
|
|
2018-12-08 21:16:03 -08:00
|
|
|
func TEXT(name, signature string) {
|
|
|
|
|
ctx.Function(name)
|
|
|
|
|
ctx.SignatureExpr(signature)
|
|
|
|
|
}
|
|
|
|
|
|
2018-11-30 21:37:17 -08:00
|
|
|
func LABEL(name string) { ctx.Label(avo.Label(name)) }
|
2018-11-30 20:58:51 -08:00
|
|
|
|
2018-12-31 19:04:14 -08:00
|
|
|
func GLOBL(name string, a avo.Attribute) operand.Mem {
|
|
|
|
|
g := ctx.StaticGlobal(name)
|
|
|
|
|
ctx.DataAttributes(a)
|
|
|
|
|
return g
|
2018-12-27 11:57:46 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func DATA(offset int, v operand.Constant) {
|
|
|
|
|
ctx.AddDatum(offset, v)
|
|
|
|
|
}
|
|
|
|
|
|
2018-12-11 00:18:22 -08:00
|
|
|
var flags = NewFlags(flag.CommandLine)
|
2018-11-30 20:58:51 -08:00
|
|
|
|
2018-12-11 00:18:22 -08:00
|
|
|
func Generate() {
|
2018-11-30 20:58:51 -08:00
|
|
|
if !flag.Parsed() {
|
|
|
|
|
flag.Parse()
|
|
|
|
|
}
|
2018-12-11 00:18:22 -08:00
|
|
|
cfg := flags.Config()
|
2019-01-02 20:04:45 -08:00
|
|
|
|
|
|
|
|
status := Main(cfg, ctx)
|
|
|
|
|
|
|
|
|
|
// To record coverage of integration tests we wrap main() functions in a test
|
|
|
|
|
// functions. In this case we need the main function to terminate, therefore we
|
|
|
|
|
// only exit for failure status codes.
|
|
|
|
|
if status != 0 {
|
|
|
|
|
os.Exit(status)
|
|
|
|
|
}
|
2018-11-30 20:58:51 -08:00
|
|
|
}
|
2018-12-08 22:02:02 -08:00
|
|
|
|
2018-12-30 18:40:45 -08:00
|
|
|
func GP8v() reg.GPVirtual { return ctx.GP8v() }
|
|
|
|
|
func GP16v() reg.GPVirtual { return ctx.GP16v() }
|
|
|
|
|
func GP32v() reg.GPVirtual { return ctx.GP32v() }
|
|
|
|
|
func GP64v() reg.GPVirtual { return ctx.GP64v() }
|
|
|
|
|
func Xv() reg.VecVirtual { return ctx.Xv() }
|
|
|
|
|
func Yv() reg.VecVirtual { return ctx.Yv() }
|
|
|
|
|
func Zv() reg.VecVirtual { return ctx.Zv() }
|
2018-12-08 22:02:02 -08:00
|
|
|
|
|
|
|
|
func Param(name string) gotypes.Component { return ctx.Param(name) }
|
|
|
|
|
func ParamIndex(i int) gotypes.Component { return ctx.ParamIndex(i) }
|
|
|
|
|
func Return(name string) gotypes.Component { return ctx.Return(name) }
|
|
|
|
|
func ReturnIndex(i int) gotypes.Component { return ctx.ReturnIndex(i) }
|
|
|
|
|
|
|
|
|
|
func Load(src gotypes.Component, dst reg.Register) reg.Register { return ctx.Load(src, dst) }
|
|
|
|
|
func Store(src reg.Register, dst gotypes.Component) { ctx.Store(src, dst) }
|
2018-12-21 00:30:59 -08:00
|
|
|
|
2018-12-30 23:35:49 -08:00
|
|
|
func Doc(lines ...string) { ctx.Doc(lines...) }
|
|
|
|
|
func Attributes(a avo.Attribute) { ctx.Attributes(a) }
|
2018-12-27 23:01:27 -08:00
|
|
|
|
2018-12-21 00:30:59 -08:00
|
|
|
func AllocLocal(size int) operand.Mem { return ctx.AllocLocal(size) }
|
2018-12-27 15:44:52 -08:00
|
|
|
|
|
|
|
|
func ConstData(name string, v operand.Constant) operand.Mem { return ctx.ConstData(name, v) }
|