| 1 |
|
| 2 |
|
| 3 |
package main |
| 4 |
|
| 5 |
import ( |
| 6 |
"fmt" |
| 7 |
|
| 8 |
. "github.com/mmcloughlin/avo/build" |
| 9 |
. "github.com/mmcloughlin/avo/operand" |
| 10 |
. "github.com/mmcloughlin/avo/reg" |
| 11 |
) |
| 12 |
|
| 13 |
func main() { |
| 14 |
variants := []struct { |
| 15 |
Size int |
| 16 |
Register func() GPVirtual |
| 17 |
XOR func(Op, Op) |
| 18 |
}{ |
| 19 |
{8, GP8L, XORB}, |
| 20 |
{16, GP16, XORW}, |
| 21 |
{32, GP32, XORL}, |
| 22 |
{64, GP64, XORQ}, |
| 23 |
} |
| 24 |
|
| 25 |
for _, v := range variants { |
| 26 |
name := fmt.Sprintf("Not%d", v.Size) |
| 27 |
TEXT(name, NOSPLIT, "func(x bool) bool") |
| 28 |
Doc(fmt.Sprintf("%s returns the boolean negation of x using a %d-bit intermediate.", name, v.Size)) |
| 29 |
x := v.Register() |
| 30 |
Load(Param("x"), x) |
| 31 |
v.XOR(U8(1), x) |
| 32 |
Store(x.As8L(), ReturnIndex(0)) |
| 33 |
RET() |
| 34 |
} |
| 35 |
|
| 36 |
Generate() |
| 37 |
} |