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

Add DSL methods for representing operand decorators #106

Open
postmodern opened this issue Feb 28, 2025 · 1 comment
Open

Add DSL methods for representing operand decorators #106

postmodern opened this issue Feb 28, 2025 · 1 comment
Labels
dsl Ruby ASM DSL feature New Feature x86-64 x86-64 architecture x86 x86

Comments

@postmodern
Copy link
Member

postmodern commented Feb 28, 2025

Some assembly instructions permit decorations on certain operands.

Examples

Write mask of k1 onto the memory operand [rax] which results in operand type (ex: m64{k}).

vmovss [rax]{k1}, xmm0

Write mask of k1 with z mode enabled on the destination register zmm0 resulting in an operand type zmm{k}{z}.

vpsubb zmm0{k1}{z}, zmm0, zmm1

Broadcast decorator on one of the source 64bit memory operands resulting into the operand type m256/m64bcst; the instruction operates on packed double-word integers (32bit), the memory operand is 64bit and the source operands are 256bit, so 256 / 64 == {1to8} == m256/m64bcst.

vpaddd ymm0, ymm0, [rdi] {1to8}
@postmodern postmodern added dsl Ruby ASM DSL feature New Feature x86 x86 x86-64 x86-64 architecture labels Feb 28, 2025
@postmodern
Copy link
Member Author

postmodern commented Feb 28, 2025

Some ideas of how the Ruby syntax might look like:

Faux Array access methods:

vpsubb zmm0[k1][z], zmm0, zmm1

Downside: we will have to define a z method to represent the zero-mode flag.

Yielding blocks

vpsubb zmm0 { k1 }, zmm0, zmm1

Upside: easy to implement!
Downside: cannot chain together { } methods (ex: zmm0{k1}{z}). No possible way to use this technique on memory operands that are defined as Arrays (ex: [rdi]).

Operand Methods

vpsubb zmm0.k1.z, zmm0, zmm1

Downside: readability is not great and have to define k0 - k5 methods.

Override The Register Methods

vpsubb zmm0(k1, z), zmm0, zmm1

Downside: still requires defining a z method.

Override The Register Methods With Keyword Arguments

vpsubb zmm0(k: k1, z: true), zmm0, zmm1

Downside: k: k1 seems a bit redundant and z: true feels too explicit?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dsl Ruby ASM DSL feature New Feature x86-64 x86-64 architecture x86 x86
Projects
None yet
Development

No branches or pull requests

1 participant