@@ -3,6 +3,7 @@ package printer_test
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/mmcloughlin/avo"
|
||||
"github.com/mmcloughlin/avo/build"
|
||||
"github.com/mmcloughlin/avo/printer"
|
||||
"github.com/mmcloughlin/avo/reg"
|
||||
@@ -24,7 +25,7 @@ func TestBasic(t *testing.T) {
|
||||
"#include \"textflag.h\"",
|
||||
"",
|
||||
"// func add(x uint64, y uint64) uint64",
|
||||
"TEXT ·add(SB), 0, $0-24",
|
||||
"TEXT ·add(SB), $0-24",
|
||||
"\tMOVQ\tx(FP), AX",
|
||||
"\tMOVQ\ty+8(FP), R9",
|
||||
"\tADDQ\tAX, R9",
|
||||
@@ -34,7 +35,7 @@ func TestBasic(t *testing.T) {
|
||||
})
|
||||
}
|
||||
|
||||
func TestTextSize(t *testing.T) {
|
||||
func TestTextDecl(t *testing.T) {
|
||||
ctx := build.NewContext()
|
||||
|
||||
ctx.Function("noargs")
|
||||
@@ -46,17 +47,26 @@ func TestTextSize(t *testing.T) {
|
||||
ctx.SignatureExpr("func(x, y uint64) uint64")
|
||||
ctx.RET()
|
||||
|
||||
ctx.Function("withattr")
|
||||
ctx.SignatureExpr("func()")
|
||||
ctx.Attributes(avo.NOSPLIT | avo.TLSBSS)
|
||||
ctx.RET()
|
||||
|
||||
AssertPrintsLines(t, ctx, printer.NewGoAsm, []string{
|
||||
"// Code generated by avo. DO NOT EDIT.",
|
||||
"",
|
||||
"#include \"textflag.h\"",
|
||||
"",
|
||||
"// func noargs()",
|
||||
"TEXT ·noargs(SB), 0, $16", // expect only the frame size
|
||||
"TEXT ·noargs(SB), $16", // expect only the frame size
|
||||
"\tRET",
|
||||
"",
|
||||
"// func withargs(x uint64, y uint64) uint64",
|
||||
"TEXT ·withargs(SB), 0, $0-24", // expect both frame size and argument size
|
||||
"TEXT ·withargs(SB), $0-24", // expect both frame size and argument size
|
||||
"\tRET",
|
||||
"",
|
||||
"// func withattr()",
|
||||
"TEXT ·withattr(SB), NOSPLIT|TLSBSS, $0", // expect to see attributes
|
||||
"\tRET",
|
||||
"",
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user