Skip to content

Commit

Permalink
internal/load: support additional MOVQ forms
Browse files Browse the repository at this point in the history
The Go assembler merges MOVD/MOVQ instruction forms. The logic in the
avo instruction loader was discarding the MOVD forms. This diff should
merge them correctly.

Updates mmcloughlin#50
  • Loading branch information
mmcloughlin committed Jan 21, 2019
1 parent 5dc9498 commit 220969f
Show file tree
Hide file tree
Showing 11 changed files with 280 additions and 1 deletion.
24 changes: 24 additions & 0 deletions build/zinstructions.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions build/zmov.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

56 changes: 56 additions & 0 deletions internal/inst/ztable.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion internal/inst/ztable_test.go

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions internal/load/load.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@ func (l *Loader) Load() ([]inst.Instruction, error) {

// Apply list of aliases.
for from, to := range aliases {
if existing, found := im[from]; found {
im[to].Forms = append(im[to].Forms, existing.Forms...)
}
cpy := *im[to]
cpy.Opcode = from
cpy.AliasOf = to
Expand Down
21 changes: 21 additions & 0 deletions tests/fixedbugs/issue50/asm.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// +build ignore

package main

import (
. "github.com/mmcloughlin/avo/build"
)

func main() {
TEXT("Issue50", NOSPLIT, "func(x uint32) uint32")
Doc(
"Issue50 reported that MOVD/MOVQ was missing the r32, xmm form.",
"This function deliberately exercises this instruction form.",
)
x := Load(Param("x"), GP32())
xmm := XMM()
MOVQ(x, xmm)
Store(xmm, ReturnIndex(0))
RET()
Generate()
}
Empty file.
15 changes: 15 additions & 0 deletions tests/fixedbugs/issue50/issue50_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package issue50

import (
"testing"
"testing/quick"
)

//go:generate go run asm.go -out issue50.s -stubs stub.go

func TestIssue50(t *testing.T) {
expect := func(x uint32) uint32 { return x }
if err := quick.CheckEqual(Issue50, expect, nil); err != nil {
t.Fatal(err)
}
}
Empty file added tests/fixedbugs/issue50/stub.go
Empty file.
96 changes: 96 additions & 0 deletions x86/zctors.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 220969f

Please sign in to comment.