diff --git a/document/core/binary/instructions.rst b/document/core/binary/instructions.rst index e13a03236..b6a9eafcd 100644 --- a/document/core/binary/instructions.rst +++ b/document/core/binary/instructions.rst @@ -196,7 +196,7 @@ Each variant of :ref:`memory instruction ` is encoded with .. math:: \begin{array}{llclll} \production{memory argument} & \Bmemarg &::=& - a{:}\Bu32~~o{:}\Bu32 &\Rightarrow& \{ \ALIGN~a,~\OFFSET~o \} \\ + a{:}\Bu32~~o{:}\Bu64 &\Rightarrow& \{ \ALIGN~a,~\OFFSET~o \} \\ \production{instruction} & \Binstr &::=& \dots \\ &&|& \hex{28}~~m{:}\Bmemarg &\Rightarrow& \I32.\LOAD~m \\ &&|& \hex{29}~~m{:}\Bmemarg &\Rightarrow& \I64.\LOAD~m \\ &&|& diff --git a/document/core/binary/types.rst b/document/core/binary/types.rst index 4df661839..83132e81b 100644 --- a/document/core/binary/types.rst +++ b/document/core/binary/types.rst @@ -130,7 +130,9 @@ Limits \begin{array}{llclll} \production{limits} & \Blimits &::=& \hex{00}~~n{:}\Bu32 &\Rightarrow& \{ \LMIN~n, \LMAX~\epsilon \} \\ &&|& - \hex{01}~~n{:}\Bu32~~m{:}\Bu32 &\Rightarrow& \{ \LMIN~n, \LMAX~m \} \\ + \hex{01}~~n{:}\Bu32~~m{:}\Bu32 &\Rightarrow& \{ \LMIN~n, \LMAX~m \} \\ &&|& + \hex{04}~~n{:}\Bu64 &\Rightarrow& \{ \LMIN~n, \LMAX~\epsilon \} \\ &&|& + \hex{05}~~n{:}\Bu64~~m{:}\Bu64 &\Rightarrow& \{ \LMIN~n, \LMAX~m \} \end{array} @@ -146,7 +148,7 @@ Memory Types .. math:: \begin{array}{llclll@{\qquad\qquad}l} \production{memory type} & \Bmemtype &::=& - \X{lim}{:}\Blimits &\Rightarrow& \X{lim} \\ + (\X{it}, \X{lim}){:}\Blimits &\Rightarrow& \X{it}~~\X{lim} \\ \end{array} @@ -162,7 +164,7 @@ Table Types .. math:: \begin{array}{llclll} \production{table type} & \Btabletype &::=& - \X{et}{:}\Breftype~~\X{lim}{:}\Blimits &\Rightarrow& \X{lim}~\X{et} \\ + \X{et}{:}\Breftype~~(\X{it}, \X{lim}){:}\Blimits &\Rightarrow& \X{it}~~\X{lim}~\X{et} \\ \end{array} diff --git a/document/core/syntax/instructions.rst b/document/core/syntax/instructions.rst index 2b76f37ae..92f0c0207 100644 --- a/document/core/syntax/instructions.rst +++ b/document/core/syntax/instructions.rst @@ -547,10 +547,8 @@ Instructions in this group are concerned with linear :ref:`memory `. .. math:: \begin{array}{llcl} - \production{index type} & \X{it} &::=& - \idxtype \\ \production{memory immediate} & \memarg &::=& - \{ \OFFSET~\X{it}, \ALIGN~\u32 \} \\ + \{ \OFFSET~\u64, \ALIGN~\u32 \} \\ \production{lane width} & \X{ww} &::=& 8 ~|~ 16 ~|~ 32 ~|~ 64 \\ \production{instruction} & \instr &::=& @@ -585,18 +583,13 @@ Instructions in this group are concerned with linear :ref:`memory `. Memory is accessed with |LOAD| and |STORE| instructions for the different :ref:`number types `. They all take a *memory immediate* |memarg| that contains an address *offset* and the expected *alignment* (expressed as the exponent of a power of 2). -The type of the *offset* corresponds to the *index type* of the memory which will -be either |U32| (for 32-bit memories) or |U64| (for 64-bit memories). Integer loads and stores can optionally specify a *storage size* that is smaller than the :ref:`bit width ` of the respective value type. In the case of loads, a sign extension mode |sx| is then required to select appropriate behavior. Vector loads can specify a shape that is half the :ref:`bit width ` of |V128|. Each lane is half its usual size, and the sign extension mode |sx| then specifies how the smaller lane is extended to the larger lane. Alternatively, vector loads can perform a *splat*, such that only a single lane of the specified storage size is loaded, and the result is duplicated to all lanes. -The static address offset is added to the dynamic address operand. The type of -the dynamic, like the static offset, corresponds to the *index type* of -memory. The result of this addition is a 33 bit or 65 bit *effective address* -that is the zero-based index at which the memory is accessed. +The static address offset is added to the dynamic address operand, yielding a 33 bit *effective address* that is the zero-based index at which the memory is accessed. All values are read and written in |LittleEndian|_ byte order. A :ref:`trap ` results if any of the accessed memory bytes lies outside the address range implied by the memory's current size. diff --git a/document/core/syntax/types.rst b/document/core/syntax/types.rst index 61ce5910c..f9de2bb6c 100644 --- a/document/core/syntax/types.rst +++ b/document/core/syntax/types.rst @@ -156,12 +156,23 @@ They are also used to classify the inputs and outputs of :ref:`instructions ` can be given inline with a memory definition, .. math:: \begin{array}{llclll} \production{module field} & - \text{(}~\text{memory}~~\Tid^?~~\text{(}~\text{data}~~b^n{:}\Tdatastring~\text{)}~~\text{)} \quad\equiv \\ & \qquad + \text{(}~\text{memory}~~\Tid^?~~\Tidxtype^?~~\text{(}~\text{data}~~b^n{:}\Tdatastring~\text{)}~~\text{)} \quad\equiv \\ & \qquad \text{(}~\text{memory}~~\Tid'~~m~~m~\text{)} \\ & \qquad \text{(}~\text{data}~~\text{(}~\text{memory}~~\Tid'~\text{)}~~\text{(}~\text{i32.const}~~\text{0}~\text{)}~~\Tdatastring~\text{)} \\ & \qquad\qquad diff --git a/document/core/text/types.rst b/document/core/text/types.rst index 7705cc575..5f7ea9dd0 100644 --- a/document/core/text/types.rst +++ b/document/core/text/types.rst @@ -113,6 +113,19 @@ Multiple anonymous parameters or results may be combined into a single declarati (\text{(}~~\text{result}~~\Tvaltype~~\text{)})^\ast \\ \end{array} +.. index:: index type + pair: text format; index type +.. _text-idxtype: + +Index Type +~~~~~~~~~~ + +.. math:: + \begin{array}{llclll} + \production{index type} & \Tidxtype &::=& + \text{i32} &\Rightarrow& \I32 \\ &&|& + \text{i64} &\Rightarrow& \I64 \\ + \end{array} .. index:: limits pair: text format; limits @@ -139,7 +152,8 @@ Memory Types .. math:: \begin{array}{llclll@{\qquad\qquad}l} \production{memory type} & \Tmemtype &::=& - \X{lim}{:}\Tlimits &\Rightarrow& \X{lim} \\ + \X{lim}{:}\Tlimits &\Rightarrow& \I32~\X{lim} \\ &&|& + \X{it}{:}\Tidxtype~~\X{lim}{:}\Tlimits &\Rightarrow& \X{it}~\X{lim} \\ \end{array} @@ -153,7 +167,8 @@ Table Types .. math:: \begin{array}{llclll} \production{table type} & \Ttabletype &::=& - \X{lim}{:}\Tlimits~~\X{et}{:}\Treftype &\Rightarrow& \X{lim}~\X{et} \\ + \X{lim}{:}\Tlimits~~\X{et}{:}\Treftype &\Rightarrow& \I32~\X{lim}~\X{et} \\ &&|& + \X{it}{:}\Tidxtype~~\X{lim}{:}\Tlimits~~\X{et}{:}\Treftype &\Rightarrow& \X{it}~\X{lim}~\X{et} \end{array} diff --git a/document/core/util/macros.def b/document/core/util/macros.def index 8c5910c52..87cbba4bf 100644 --- a/document/core/util/macros.def +++ b/document/core/util/macros.def @@ -775,6 +775,7 @@ .. |Tglobaltype| mathdef:: \xref{text/types}{text-globaltype}{\T{globaltype}} .. |Ttabletype| mathdef:: \xref{text/types}{text-tabletype}{\T{tabletype}} +.. |Tidxtype| mathdef:: \xref{text/types}{text-idxtype}{\T{idxtype}} .. |Tmemtype| mathdef:: \xref{text/types}{text-memtype}{\T{memtype}} .. |Tlimits| mathdef:: \xref{text/types}{text-limits}{\T{limits}}