Skip to content

Commit f664288

Browse files
authored
[spec] Fix alignment immediate in text format (#562)
1 parent 4f1d311 commit f664288

2 files changed

Lines changed: 9 additions & 6 deletions

File tree

‎document/core/exec/instructions.rst‎

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -372,6 +372,14 @@ Variable Instructions
372372
Memory Instructions
373373
~~~~~~~~~~~~~~~~~~~
374374

375+
.. note::
376+
The alignment :math:`\memarg.\ALIGN` in load and store instructions does not affect the semantics.
377+
It is an indication that the offset :math:`\X{ea}` at which the memory is accessed is intended to satisfy the property :math:`\X{ea} \mod 2^{\memarg.\ALIGN} = 0`.
378+
A WebAssembly implementation can use this hint to optimize for the intended use.
379+
Unaligned access violating that property is still allowed and must succeed regardless of the annotation.
380+
However, it may be substantially slower on some hardware.
381+
382+
375383
.. _exec-load:
376384
.. _exec-loadn:
377385

@@ -447,11 +455,6 @@ Memory Instructions
447455
(\otherwise) \\
448456
\end{array}
449457
450-
.. note::
451-
The alignment :math:`\memarg.\ALIGN` does not affect the semantics.
452-
Unaligned access is supported for all types, and succeeds regardless of the annotation.
453-
The only purpose of the annotation is to provide optimizatons hints.
454-
455458
456459
.. _exec-store:
457460
.. _exec-storen:

‎document/core/text/instructions.rst‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ Lexically, an |Toffset| or |Talign| phrase is considered a single :ref:`keyword
179179
.. math::
180180
\begin{array}{llclll}
181181
\production{memory argument} & \Tmemarg_N &::=&
182-
o{:}\Toffset~~a{:}\Talign_N &\Rightarrow& \{ \ALIGN~a,~\OFFSET~o \} \\
182+
o{:}\Toffset~~a{:}\Talign_N &\Rightarrow& \{ \ALIGN~n,~\OFFSET~o \} & (\iff a = 2^n) \\
183183
\production{memory offset} & \Toffset &::=&
184184
\text{offset{=}}o{:}\Tu32 &\Rightarrow& o \\ &&|&
185185
\epsilon &\Rightarrow& 0 \\

0 commit comments

Comments
 (0)