Exemplo n.º 1
0
func addTestStart(b *builder, testList ir.Ref, n int) {
	b.f = b.p.NewFunc(testStartName, nil, ir.VoidFuncSig)
	b.b = b.f.NewBlock(nil)

	argAddr := ir.Num(arch8.AddrBootArg) // the arg
	index := b.newTempIR(types.Uint)     // to save the index
	b.b.Assign(index, ir.NewAddrRef(argAddr, arch8.RegSize, 0, false, true))

	size := ir.Num(uint32(n))
	checkInRange(b, index, size, "u<")

	base := b.newPtr()
	b.b.Arith(base, nil, "&", testList)
	addr := b.newPtr()
	b.b.Arith(addr, index, "*", ir.Num(arch8.RegSize))
	b.b.Arith(addr, base, "+", addr)

	f := ir.NewFuncPtr(
		ir.VoidFuncSig,
		ir.NewAddrRef(addr, arch8.RegSize, 0, false, true),
	)

	testMain := findFunc(b, "testMain", testMainFuncType)
	if testMain == nil {
		b.b.Call(nil, f)
	} else {
		b.b.Call(nil, testMain.ref.IR(), f)
	}
}
Exemplo n.º 2
0
func wrapFuncPtr(f ir.Ref, t *types.Func) ir.Ref {
	switch f := f.(type) {
	case *ir.FuncSym:
		return f
	case *ir.Func:
		return f
	}
	return ir.NewFuncPtr(makeFuncSig(t), f)
}