Files
avo/tests/fmt/asm.go
Michael McLoughlin 2e7d06bc7a pass: remove redundant jumps and dangling labels (#81)
In jump-table-like constructs, the natural way of writing the code can sometimes produce redundant jumps or labels. Therefore some basic cleanup steps have been proposed. This diff adds two transforms:

1. Remove unconditional jumps to a label immediately following.
2. Remove labels with no references at all.

Fixes #75
2019-04-15 19:42:11 -07:00

29 lines
501 B
Go

// +build ignore
package main
import (
. "github.com/mmcloughlin/avo/build"
. "github.com/mmcloughlin/avo/operand"
. "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)
JMP(LabelRef("label"))
RET()
Generate()
}