build: support comments in functions (#41)

This commit is contained in:
Michael McLoughlin
2019-01-11 10:33:41 -08:00
parent 27cea3be8b
commit 284ee13ada
10 changed files with 117 additions and 23 deletions

26
tests/fmt/asm.go Normal file
View File

@@ -0,0 +1,26 @@
// +build ignore
package main
import (
. "github.com/mmcloughlin/avo/build"
. "github.com/mmcloughlin/avo/reg"
)
func main() {
TEXT("Formatting", NOSPLIT, "func()")
Doc("Formatting contains various cases to test the formatter.")
ADDQ(R8, R8)
Comment("One comment line between instructions.")
ADDQ(R8, R8)
Comment("Comment before label.")
Label("label")
Comment("Comment after label.")
ADDQ(R8, R8)
RET()
Generate()
}

16
tests/fmt/fmt.s Normal file
View File

@@ -0,0 +1,16 @@
// Code generated by command: go run asm.go -out fmt.s -stubs stub.go. DO NOT EDIT.
#include "textflag.h"
// func Formatting()
TEXT ·Formatting(SB), NOSPLIT, $0
ADDQ R8, R8
// One comment line between instructions.
ADDQ R8, R8
// Comment before label.
label:
// Comment after label.
ADDQ R8, R8
RET

4
tests/fmt/gen.go Normal file
View File

@@ -0,0 +1,4 @@
// Package fmt tests assembly printer formatting.
package fmt
//go:generate go run asm.go -out fmt.s -stubs stub.go

6
tests/fmt/stub.go Normal file
View File

@@ -0,0 +1,6 @@
// Code generated by command: go run asm.go -out fmt.s -stubs stub.go. DO NOT EDIT.
package fmt
// Formatting contains various cases to test the formatter.
func Formatting()