Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

internal/opcodesextra: add PCALIGN pseudo-op #420

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions build/zinstructions.go

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

1 change: 1 addition & 0 deletions build/zinstructions_test.go

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

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

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

1 change: 1 addition & 0 deletions internal/opcodesextra/instructions.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (

// sets of extra instructions.
var sets = [][]*inst.Instruction{
pseudo,
movlqzx,
gfni,
vaes,
Expand Down
35 changes: 35 additions & 0 deletions internal/opcodesextra/pseudo.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package opcodesextra

import "github.com/mmcloughlin/avo/internal/inst"

// pseudo is pseudo-ops supported by the Go assembler.
var pseudo = []*inst.Instruction{
// Reference: https://github.com/golang/go/blob/go1.22rc1/doc/asm.html#L469-L482
//
// <p>
// The <code>PCALIGN</code> pseudo-instruction is used to indicate that the next instruction should be aligned
// to a specified boundary by padding with no-op instructions.
// </p>
//
// <p>
// It is currently supported on arm64, amd64, ppc64, loong64 and riscv64.
//
// For example, the start of the <code>MOVD</code> instruction below is aligned to 32 bytes:
// <pre>
// PCALIGN $32
// MOVD $2, R0
// </pre>
// </p>
//
{
Opcode: "PCALIGN",
Summary: "Align the next instruction to the specified boundary",
Forms: []inst.Form{
{
Operands: []inst.Operand{
{Type: "imm8"},

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the operand was in range 8 to 1024.

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Turns out it's power of 2 in the range 8 to 2048.

https://github.com/golang/go/blob/fa72f3e034fdabc5922ac019281f53ea0a8328cf/src/cmd/internal/obj/x86/asm6.go#L2048

I'll need to add a custom operand type for this.

},
},
},
},
}
9 changes: 9 additions & 0 deletions x86/zctors.go

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

6 changes: 6 additions & 0 deletions x86/zctors_test.go

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

Loading
Loading