WebAssembly Specification Release 1.1 (Draft 2021-12-18) - page 13

 

  Главная      Manuals     WebAssembly Specification Release 1.1 (Draft 2021-12-18)

 

Search            copyright infringement  

 

 

 

 

 

 

 

 

 

 

 

Content      ..     11      12      13      14     ..

 

 

 

WebAssembly Specification Release 1.1 (Draft 2021-12-18) - page 13

 

 

|

f32

.

abs

f32

.

abs

|

f32

.

neg

f32

.

neg

|

f32

.

ceil

f32

.

ceil

|

f32

.

floor

f32

.

floor

|

f32

.

trunc

f32

.

trunc

|

f32

.

nearest

f32

.

nearest

|

f32

.

sqrt

f32

.

sqrt

|

f32

.

add

f32

.

add

|

f32

.

sub

f32

.

sub

|

f32

.

mul

f32

.

mul

|

f32

.

div

f32

.

div

|

f32

.

min

f32

.

min

|

f32

.

max

f32

.

max

|

f32

.

copysign

f32

.

copysign

|

f64

.

abs

f64

.

abs

|

f64

.

neg

f64

.

neg

|

f64

.

ceil

f64

.

ceil

|

f64

.

floor

f64

.

floor

|

f64

.

trunc

f64

.

trunc

|

f64

.

nearest

f64

.

nearest

|

f64

.

sqrt

f64

.

sqrt

|

f64

.

add

f64

.

add

|

f64

.

sub

f64

.

sub

|

f64

.

mul

f64

.

mul

|

f64

.

div

f64

.

div

|

f64

.

min

f64

.

min

|

f64

.

max

f64

.

max

|

f64

.

copysign

f64

.

copysign

|

i32

.

eqz

i32

.

eqz

|

i32

.

eq

i32

.

eq

|

i32

.

ne

i32

.

ne

|

i32

.

lt

_

s

i32

.

lt

_

s

|

i32

.

lt

_

u

i32

.

lt

_

u

|

i32

.

gt

_

s

i32

.

gt

_

s

|

i32

.

gt

_

u

i32

.

gt

_

u

|

i32

.

le

_

s

i32

.

le

_

s

|

i32

.

le

_

u

i32

.

le

_

u

|

i32

.

ge

_

s

i32

.

ge

_

s

|

i32

.

ge

_

u

i32

.

ge

_

u

|

i64

.

eqz

i64

.

eqz

|

i64

.

eq

i64

.

eq

|

i64

.

ne

i64

.

ne

|

i64

.

lt

_

s

i64

.

lt

_

s

|

i64

.

lt

_

u

i64

.

lt

_

u

|

i64

.

gt

_

s

i64

.

gt

_

s

|

i64

.

gt

_

u

i64

.

gt

_

u

|

i64

.

le

_

s

i64

.

le

_

s

|

i64

.

le

_

u

i64

.

le

_

u

|

i64

.

ge

_

s

i64

.

ge

_

s

|

i64

.

ge

_

u

i64

.

ge

_

u

6.5. Instructions

167

|

f32

.

eq

f32

.

eq

|

f32

.

ne

f32

.

ne

|

f32

.

lt

f32

.

lt

|

f32

.

gt

f32

.

gt

|

f32

.

le

f32

.

le

|

f32

.

ge

f32

.

ge

|

f64

.

eq

f64

.

eq

|

f64

.

ne

f64

.

ne

|

f64

.

lt

f64

.

lt

|

f64

.

gt

f64

.

gt

|

f64

.

le

f64

.

le

|

f64

.

ge

f64

.

ge

|

i32

.

wrap

_

i64

i32

.

wrap

_

i64

|

i32

.

trunc

_

f32

_

s

i32

.

trunc

_

f32

_

s

|

i32

.

trunc

_

f32

_

u

i32

.

trunc

_

f32

_

u

|

i32

.

trunc

_

f64

_

s

i32

.

trunc

_

f64

_

s

|

i32

.

trunc

_

f64

_

u

i32

.

trunc

_

f64

_

u

|

i32

.

trunc

_

sat

_

f32

_

s

i32

.

trunc

_

sat

_

f32

_

s

|

i32

.

trunc

_

sat

_

f32

_

u

i32

.

trunc

_

sat

_

f32

_

u

|

i32

.

trunc

_

sat

_

f64

_

s

i32

.

trunc

_

sat

_

f64

_

s

|

i32

.

trunc

_

sat

_

f64

_

u

i32

.

trunc

_

sat

_

f64

_

u

|

i64

.

extend

_

i32

_

s

i64

.

extend

_

i32

_

s

|

i64

.

extend

_

i32

_

u

i64

.

extend

_

i32

_

u

|

i64

.

trunc

_

f32

_

s

i64

.

trunc

_

f32

_

s

|

i64

.

trunc

_

f32

_

u

i64

.

trunc

_

f32

_

u

|

i64

.

trunc

_

f64

_

s

i64

.

trunc

_

f64

_

s

|

i64

.

trunc

_

f64

_

u

i64

.

trunc

_

f64

_

u

|

i64

.

trunc

_

sat

_

f32

_

s

i64

.

trunc

_

sat

_

f32

_

s

|

i64

.

trunc

_

sat

_

f32

_

u

i64

.

trunc

_

sat

_

f32

_

u

|

i64

.

trunc

_

sat

_

f64

_

s

i64

.

trunc

_

sat

_

f64

_

s

|

i64

.

trunc

_

sat

_

f64

_

u

i64

.

trunc

_

sat

_

f64

_

u

|

f32

.

convert

_

i32

_

s

f32

.

convert

_

i32

_

s

|

f32

.

convert

_

i32

_

u

f32

.

convert

_

i32

_

u

|

f32

.

convert

_

i64

_

s

f32

.

convert

_

i64

_

s

|

f32

.

convert

_

i64

_

u

f32

.

convert

_

i64

_

u

|

f32

.

demote

_

f64

f32

.

demote

_

f64

|

f64

.

convert

_

i32

_

s

f64

.

convert

_

i32

_

s

|

f64

.

convert

_

i32

_

u

f64

.

convert

_

i32

_

u

|

f64

.

convert

_

i64

_

s

f64

.

convert

_

i64

_

s

|

f64

.

convert

_

i64

_

u

f64

.

convert

_

i64

_

u

|

f64

.

promote

_

f32

f64

.

promote

_

f32

|

i32

.

reinterpret

_

f32

i32

.

reinterpret

_

f32

|

i64

.

reinterpret

_

f64

i64

.

reinterpret

_

f64

|

f32

.

reinterpret

_

i32

f32

.

reinterpret

_

i32

|

f64

.

reinterpret

_

i64

f64

.

reinterpret

_

i64

|

i32

.

extend8

_

s

i32

.

extend

8

_

s

|

i32

.

extend16

_

s

i32

.

extend

16

_

s

|

i64

.

extend8

_

s

i64

.

extend

8

_

s

|

i64

.

extend16

_

s

i64

.

extend

16

_

s

|

i64

.

extend32

_

s

i64

.

extend

32

_

s

168

Chapter 6. Text Format

6.5.9 Vector Instructions

Vector memory instructions have optional offset and alignment immediates, like the

memory instructions

.

plaininstr

𝐼

::=

. . .

|

v128

.

load

𝑚

:

memarg

16

v128

.

load

𝑚

|

v128

.

load8x8

_

s

𝑚

:

memarg

8

v128

.

load

8x8

_

s

𝑚

|

v128

.

load8x8

_

u

𝑚

:

memarg

8

v128

.

load

8x8

_

u

𝑚

|

v128

.

load16x4

_

s

𝑚

:

memarg

8

v128

.

load

16x4

_

s

𝑚

|

v128

.

load16x4

_

u

𝑚

:

memarg

8

v128

.

load

16x4

_

u

𝑚

|

v128

.

load32x2

_

s

𝑚

:

memarg

8

v128

.

load

32x2

_

s

𝑚

|

v128

.

load32x2

_

u

𝑚

:

memarg

8

v128

.

load

32x2

_

u

𝑚

|

v128

.

load8

_

splat

𝑚

:

memarg

1

v128

.

load

8

_

splat

𝑚

|

v128

.

load16

_

splat

𝑚

:

memarg

2

v128

.

load

16

_

splat

𝑚

|

v128

.

load32

_

splat

𝑚

:

memarg

4

v128

.

load

32

_

splat

𝑚

|

v128

.

load64

_

splat

𝑚

:

memarg

8

v128

.

load

64

_

splat

𝑚

|

v128

.

load32

_

zero

𝑚

:

memarg

4

v128

.

load

32

_

zero

𝑚

|

v128

.

load64

_

zero

𝑚

:

memarg

8

v128

.

load

64

_

zero

𝑚

|

v128

.

store

𝑚

:

memarg

16

v128

.

store

𝑚

|

v128

.

load8

_

lane

𝑚

:

memarg

1

𝑙𝑎𝑛𝑒𝑖𝑑𝑥

:

u8

v128

.

load

8

_

lane

𝑚 𝑙𝑎𝑛𝑒𝑖𝑑𝑥

|

v128

.

load16

_

lane

𝑚

:

memarg

2

𝑙𝑎𝑛𝑒𝑖𝑑𝑥

:

u8

v128

.

load

16

_

lane

𝑚 𝑙𝑎𝑛𝑒𝑖𝑑𝑥

|

v128

.

load32

_

lane

𝑚

:

memarg

4

𝑙𝑎𝑛𝑒𝑖𝑑𝑥

:

u8

v128

.

load

32

_

lane

𝑚 𝑙𝑎𝑛𝑒𝑖𝑑𝑥

|

v128

.

load64

_

lane

𝑚

:

memarg

8

𝑙𝑎𝑛𝑒𝑖𝑑𝑥

:

u8

v128

.

load

64

_

lane

𝑚 𝑙𝑎𝑛𝑒𝑖𝑑𝑥

|

v128

.

store8

_

lane

𝑚

:

memarg

1

𝑙𝑎𝑛𝑒𝑖𝑑𝑥

:

u8

v128

.

store

8

_

lane

𝑚 𝑙𝑎𝑛𝑒𝑖𝑑𝑥

|

v128

.

store16

_

lane

𝑚

:

memarg

2

𝑙𝑎𝑛𝑒𝑖𝑑𝑥

:

u8

v128

.

store

16

_

lane

𝑚 𝑙𝑎𝑛𝑒𝑖𝑑𝑥

|

v128

.

store32

_

lane

𝑚

:

memarg

4

𝑙𝑎𝑛𝑒𝑖𝑑𝑥

:

u8

v128

.

store

32

_

lane

𝑚 𝑙𝑎𝑛𝑒𝑖𝑑𝑥

|

v128

.

store64

_

lane

𝑚

:

memarg

8

𝑙𝑎𝑛𝑒𝑖𝑑𝑥

:

u8

v128

.

store

64

_

lane

𝑚 𝑙𝑎𝑛𝑒𝑖𝑑𝑥

Vector constant instructions have a mandatory

shape

descriptor, which determines how the following values are

parsed.

|

v128

.

const

’ ‘

i8x16

(

𝑛

:

i8

)

16

v128

.

const

bytes

1

𝑖

128

(

bytes

𝑖

8

(

𝑛

)

16

)

|

v128

.

const

’ ‘

i16x8

(

𝑛

:

i16

)

8

v128

.

const

bytes

1

𝑖

128

(

bytes

𝑖

16

(

𝑛

)

8

)

|

v128

.

const

’ ‘

i32x4

(

𝑛

:

i32

)

4

v128

.

const

bytes

1

𝑖

128

(

bytes

𝑖

32

(

𝑛

)

4

)

|

v128

.

const

’ ‘

i64x2

(

𝑛

:

i64

)

2

v128

.

const

bytes

1

𝑖

128

(

bytes

𝑖

64

(

𝑛

)

2

)

|

v128

.

const

’ ‘

f32x4

(

𝑧

:

f32

)

4

v128

.

const

bytes

1

𝑖

128

(

bytes

𝑓

32

(

𝑧

)

4

)

|

v128

.

const

’ ‘

f64x2

(

𝑧

:

f64

)

2

v128

.

const

bytes

1

𝑖

128

(

bytes

𝑓

64

(

𝑧

)

2

)

|

i8x16

.

shuffle

(

𝑙𝑎𝑛𝑒𝑖𝑑𝑥

:

u8

)

16

i8x16

.

shuffle

𝑙𝑎𝑛𝑒𝑖𝑑𝑥

16

|

i8x16

.

swizzle

i8x16

.

swizzle

|

i8x16

.

splat

i8x16

.

splat

|

i16x8

.

splat

i16x8

.

splat

|

i32x4

.

splat

i32x4

.

splat

|

i64x2

.

splat

i64x2

.

splat

|

f32x4

.

splat

f32x4

.

splat

|

f64x2

.

splat

f64x2

.

splat

6.5. Instructions

169

|

i8x16

.

extract

_

lane

_

s

𝑙𝑎𝑛𝑒𝑖𝑑𝑥

:

u8

i8x16

.

extract

_

lane

_

s

𝑙𝑎𝑛𝑒𝑖𝑑𝑥

|

i8x16

.

extract

_

lane

_

u

𝑙𝑎𝑛𝑒𝑖𝑑𝑥

:

u8

i8x16

.

extract

_

lane

_

u

𝑙𝑎𝑛𝑒𝑖𝑑𝑥

|

i8x16

.

replace

_

lane

𝑙𝑎𝑛𝑒𝑖𝑑𝑥

:

u8

i8x16

.

replace

_

lane

𝑙𝑎𝑛𝑒𝑖𝑑𝑥

|

i16x8

.

extract

_

lane

_

s

𝑙𝑎𝑛𝑒𝑖𝑑𝑥

:

u8

i16x8

.

extract

_

lane

_

s

𝑙𝑎𝑛𝑒𝑖𝑑𝑥

|

i16x8

.

extract

_

lane

_

u

𝑙𝑎𝑛𝑒𝑖𝑑𝑥

:

u8

i16x8

.

extract

_

lane

_

u

𝑙𝑎𝑛𝑒𝑖𝑑𝑥

|

i16x8

.

replace

_

lane

𝑙𝑎𝑛𝑒𝑖𝑑𝑥

:

u8

i16x8

.

replace

_

lane

𝑙𝑎𝑛𝑒𝑖𝑑𝑥

|

i32x4

.

extract

_

lane

𝑙𝑎𝑛𝑒𝑖𝑑𝑥

:

u8

i32x4

.

extract

_

lane

𝑙𝑎𝑛𝑒𝑖𝑑𝑥

|

i32x4

.

replace

_

lane

𝑙𝑎𝑛𝑒𝑖𝑑𝑥

:

u8

i32x4

.

replace

_

lane

𝑙𝑎𝑛𝑒𝑖𝑑𝑥

|

i64x2

.

extract

_

lane

𝑙𝑎𝑛𝑒𝑖𝑑𝑥

:

u8

i64x2

.

extract

_

lane

𝑙𝑎𝑛𝑒𝑖𝑑𝑥

|

i64x2

.

replace

_

lane

𝑙𝑎𝑛𝑒𝑖𝑑𝑥

:

u8

i64x2

.

replace

_

lane

𝑙𝑎𝑛𝑒𝑖𝑑𝑥

|

f32x4

.

extract

_

lane

𝑙𝑎𝑛𝑒𝑖𝑑𝑥

:

u8

f32x4

.

extract

_

lane

𝑙𝑎𝑛𝑒𝑖𝑑𝑥

|

f32x4

.

replace

_

lane

𝑙𝑎𝑛𝑒𝑖𝑑𝑥

:

u8

f32x4

.

replace

_

lane

𝑙𝑎𝑛𝑒𝑖𝑑𝑥

|

f64x2

.

extract

_

lane

𝑙𝑎𝑛𝑒𝑖𝑑𝑥

:

u8

f64x2

.

extract

_

lane

𝑙𝑎𝑛𝑒𝑖𝑑𝑥

|

f64x2

.

replace

_

lane

𝑙𝑎𝑛𝑒𝑖𝑑𝑥

:

u8

f64x2

.

replace

_

lane

𝑙𝑎𝑛𝑒𝑖𝑑𝑥

|

i8x16

.

eq

i8x16

.

eq

|

i8x16

.

ne

i8x16

.

ne

|

i8x16

.

lt

_

s

i8x16

.

lt

_

s

|

i8x16

.

lt

_

u

i8x16

.

lt

_

u

|

i8x16

.

gt

_

s

i8x16

.

gt

_

s

|

i8x16

.

gt

_

u

i8x16

.

gt

_

u

|

i8x16

.

le

_

s

i8x16

.

le

_

s

|

i8x16

.

le

_

u

i8x16

.

le

_

u

|

i8x16

.

ge

_

s

i8x16

.

ge

_

s

|

i8x16

.

ge

_

u

i8x16

.

ge

_

u

|

i16x8

.

eq

i16x8

.

eq

|

i16x8

.

ne

i16x8

.

ne

|

i16x8

.

lt

_

s

i16x8

.

lt

_

s

|

i16x8

.

lt

_

u

i16x8

.

lt

_

u

|

i16x8

.

gt

_

s

i16x8

.

gt

_

s

|

i16x8

.

gt

_

u

i16x8

.

gt

_

u

|

i16x8

.

le

_

s

i16x8

.

le

_

s

|

i16x8

.

le

_

u

i16x8

.

le

_

u

|

i16x8

.

ge

_

s

i16x8

.

ge

_

s

|

i16x8

.

ge

_

u

i16x8

.

ge

_

u

|

i32x4

.

eq

i32x4

.

eq

|

i32x4

.

ne

i32x4

.

ne

|

i32x4

.

lt

_

s

i32x4

.

lt

_

s

|

i32x4

.

lt

_

u

i32x4

.

lt

_

u

|

i32x4

.

gt

_

s

i32x4

.

gt

_

s

|

i32x4

.

gt

_

u

i32x4

.

gt

_

u

|

i32x4

.

le

_

s

i32x4

.

le

_

s

|

i32x4

.

le

_

u

i32x4

.

le

_

u

|

i32x4

.

ge

_

s

i32x4

.

ge

_

s

|

i32x4

.

ge

_

u

i32x4

.

ge

_

u

|

i64x2

.

eq

i64x2

.

eq

|

i64x2

.

ne

i64x2

.

ne

|

i64x2

.

lt

_

s

i64x2

.

lt

_

s

|

i64x2

.

gt

_

s

i64x2

.

gt

_

s

|

i64x2

.

le

_

s

i64x2

.

le

_

s

|

i64x2

.

ge

_

s

i64x2

.

ge

_

s

|

170

Chapter 6. Text Format

|

f32x4

.

eq

f32x4

.

eq

|

f32x4

.

ne

f32x4

.

ne

|

f32x4

.

lt

f32x4

.

lt

|

f32x4

.

gt

f32x4

.

gt

|

f32x4

.

le

f32x4

.

le

|

f32x4

.

ge

f32x4

.

ge

|

f64x2

.

eq

f64x2

.

eq

|

f64x2

.

ne

f64x2

.

ne

|

f64x2

.

lt

f64x2

.

lt

|

f64x2

.

gt

f64x2

.

gt

|

f64x2

.

le

f64x2

.

le

|

f64x2

.

ge

f64x2

.

ge

|

v128

.

not

v128

.

not

|

v128

.

and

v128

.

and

|

v128

.

andnot

v128

.

andnot

|

v128

.

or

v128

.

or

|

v128

.

xor

v128

.

xor

|

v128

.

bitselect

v128

.

bitselect

|

v128

.

any

_

true

v128

.

any

_

true

|

i8x16

.

abs

i8x16

.

abs

|

i8x16

.

neg

i8x16

.

neg

|

i8x16

.

all

_

true

i8x16

.

all

_

true

|

i8x16

.

bitmask

i8x16

.

bitmask

|

i8x16

.

narrow

_

i16x8

_

s

i8x16

.

narrow

_

i16x8

_

s

|

i8x16

.

narrow

_

i16x8

_

u

i8x16

.

narrow

_

i16x8

_

u

|

i8x16

.

shl

i8x16

.

shl

|

i8x16

.

shr

_

s

i8x16

.

shr

_

s

|

i8x16

.

shr

_

u

i8x16

.

shr

_

u

|

i8x16

.

add

i8x16

.

add

|

i8x16

.

add

_

sat

_

s

i8x16

.

add

_

sat

_

s

|

i8x16

.

add

_

sat

_

u

i8x16

.

add

_

sat

_

u

|

i8x16

.

sub

i8x16

.

sub

|

i8x16

.

sub

_

sat

_

s

i8x16

.

sub

_

sat

_

s

|

i8x16

.

sub

_

sat

_

u

i8x16

.

sub

_

sat

_

u

|

i8x16

.

min

_

s

i8x16

.

min

_

s

|

i8x16

.

min

_

u

i8x16

.

min

_

u

|

i8x16

.

max

_

s

i8x16

.

max

_

s

|

i8x16

.

max

_

u

i8x16

.

max

_

u

|

i8x16

.

avgr

_

u

i8x16

.

avgr

_

u

|

i8x16

.

popcnt

i8x16

.

popcnt

6.5. Instructions

171

|

i16x8

.

abs

i16x8

.

abs

|

i16x8

.

neg

i16x8

.

neg

|

i16x8

.

all

_

true

i16x8

.

all

_

true

|

i16x8

.

bitmask

i16x8

.

bitmask

|

i16x8

.

narrow

_

i32x4

_

s

i16x8

.

narrow

_

i32x4

_

s

|

i16x8

.

narrow

_

i32x4

_

u

i16x8

.

narrow

_

i32x4

_

u

|

i16x8

.

extend

_

low

_

i8x16

_

s

i16x8

.

extend

_

low

_

i8x16

_

s

|

i16x8

.

extend

_

high

_

i8x16

_

s

i16x8

.

extend

_

high

_

i8x16

_

s

|

i16x8

.

extend

_

low

_

i8x16

_

u

i16x8

.

extend

_

low

_

i8x16

_

u

|

i16x8

.

extend

_

high

_

i8x16

_

u

i16x8

.

extend

_

high

_

i8x16

_

u

|

i16x8

.

shl

i16x8

.

shl

|

i16x8

.

shr

_

s

i16x8

.

shr

_

s

|

i16x8

.

shr

_

u

i16x8

.

shr

_

u

|

i16x8

.

add

i16x8

.

add

|

i16x8

.

add

_

sat

_

s

i16x8

.

add

_

sat

_

s

|

i16x8

.

add

_

sat

_

u

i16x8

.

add

_

sat

_

u

|

i16x8

.

sub

i16x8

.

sub

|

i16x8

.

sub

_

sat

_

s

i16x8

.

sub

_

sat

_

s

|

i16x8

.

sub

_

sat

_

u

i16x8

.

sub

_

sat

_

u

|

i16x8

.

mul

i16x8

.

mul

|

i16x8

.

min

_

s

i16x8

.

min

_

s

|

i16x8

.

min

_

u

i16x8

.

min

_

u

|

i16x8

.

max

_

s

i16x8

.

max

_

s

|

i16x8

.

max

_

u

i16x8

.

max

_

u

|

i16x8

.

avgr

_

u

i16x8

.

avgr

_

u

|

i16x8

.

q15mulr

_

sat

_

s

i16x8

.

q15mulr

_

sat

_

s

|

i16x8

.

extmul

_

low

_

i8x16

_

s

i16x8

.

extmul

_

low

_

i8x16

_

s

|

i16x8

.

extmul

_

high

_

i8x16

_

s

i16x8

.

extmul

_

high

_

i8x16

_

s

|

i16x8

.

extmul

_

low

_

i8x16

_

u

i16x8

.

extmul

_

low

_

i8x16

_

u

|

i16x8

.

extmul

_

high

_

i8x16

_

u

i16x8

.

extmul

_

high

_

i8x16

_

u

|

i16x8

.

extadd

_

pairwise

_

i8x16

_

s

i16x8

.

extadd

_

pairwise

_

i8x16

_

s

|

i16x8

.

extadd

_

pairwise

_

i8x16

_

u

i16x8

.

extadd

_

pairwise

_

i8x16

_

u

|

i32x4

.

abs

i32x4

.

abs

|

i32x4

.

neg

i32x4

.

neg

|

i32x4

.

all

_

true

i32x4

.

all

_

true

|

i32x4

.

bitmask

i32x4

.

bitmask

|

i32x4

.

extadd

_

pairwise

_

i16x8

_

s

i32x4

.

extadd

_

pairwise

_

i16x8

_

s

|

i32x4

.

extend

_

low

_

i16x8

_

s

i32x4

.

extend

_

low

_

i16x8

_

s

|

i32x4

.

extend

_

high

_

i16x8

_

s

i32x4

.

extend

_

high

_

i16x8

_

s

|

i32x4

.

extend

_

low

_

i16x8

_

u

i32x4

.

extend

_

low

_

i16x8

_

u

|

i32x4

.

extend

_

high

_

i16x8

_

u

i32x4

.

extend

_

high

_

i16x8

_

u

|

i32x4

.

shl

i32x4

.

shl

|

i32x4

.

shr

_

s

i32x4

.

shr

_

s

|

i32x4

.

shr

_

u

i32x4

.

shr

_

u

|

i32x4

.

add

i32x4

.

add

|

i32x4

.

sub

i32x4

.

sub

|

i32x4

.

mul

i32x4

.

mul

|

i32x4

.

min

_

s

i32x4

.

min

_

s

|

i32x4

.

min

_

u

i32x4

.

min

_

u

|

i32x4

.

max

_

s

i32x4

.

max

_

s

|

i32x4

.

max

_

u

i32x4

.

max

_

u

|

i32x4

.

dot

_

i16x8

_

s

i32x4

.

dot

_

i16x8

_

s

|

i32x4

.

extmul

_

low

_

i16x8

_

s

i32x4

.

extmul

_

low

_

i16x8

_

s

|

i32x4

.

extmul

_

high

_

i16x8

_

s

i32x4

.

extmul

_

high

_

i16x8

_

s

|

i32x4

.

extmul

_

low

_

i16x8

_

u

i32x4

.

extmul

_

low

_

i16x8

_

u

|

i32x4

.

extmul

_

high

_

i16x8

_

u

i32x4

.

extmul

_

high

_

i16x8

_

u

172

Chapter 6. Text Format

|

i64x2

.

abs

i64x2

.

abs

|

i64x2

.

neg

i64x2

.

neg

|

i64x2

.

all

_

true

i64x2

.

all

_

true

|

i64x2

.

bitmask

i64x2

.

bitmask

|

i64x2

.

extend

_

low

_

i32x4

_

s

i64x2

.

extend

_

low

_

i32x4

_

s

|

i64x2

.

extend

_

high

_

i32x4

_

s

i64x2

.

extend

_

high

_

i32x4

_

s

|

i64x2

.

extend

_

low

_

i32x4

_

u

i64x2

.

extend

_

low

_

i32x4

_

u

|

i64x2

.

extend

_

high

_

i32x4

_

u

i64x2

.

extend

_

high

_

i32x4

_

u

|

i64x2

.

shl

i64x2

.

shl

|

i64x2

.

shr

_

s

i64x2

.

shr

_

s

|

i64x2

.

shr

_

u

i64x2

.

shr

_

u

|

i64x2

.

add

i64x2

.

add

|

i64x2

.

sub

i64x2

.

sub

|

i64x2

.

mul

i64x2

.

mul

|

i64x2

.

extmul

_

low

_

i32x4

_

s

i64x2

.

extmul

_

low

_

i32x4

_

s

|

i64x2

.

extmul

_

high

_

i32x4

_

s

i64x2

.

extmul

_

high

_

i32x4

_

s

|

i64x2

.

extmul

_

low

_

i32x4

_

u

i64x2

.

extmul

_

low

_

i32x4

_

u

|

i64x2

.

extmul

_

high

_

i32x4

_

u

i64x2

.

extmul

_

high

_

i32x4

_

u

|

f32x4

.

abs

f32x4

.

abs

|

f32x4

.

neg

f32x4

.

neg

|

f32x4

.

sqrt

f32x4

.

sqrt

|

f32x4

.

add

f32x4

.

add

|

f32x4

.

sub

f32x4

.

sub

|

f32x4

.

mul

f32x4

.

mul

|

f32x4

.

div

f32x4

.

div

|

f32x4

.

min

f32x4

.

min

|

f32x4

.

max

f32x4

.

max

|

f32x4

.

pmin

f32x4

.

pmin

|

f32x4

.

pmax

f32x4

.

pmax

|

f64x2

.

abs

f64x2

.

abs

|

f64x2

.

neg

f64x2

.

neg

|

f64x2

.

sqrt

f64x2

.

sqrt

|

f64x2

.

add

f64x2

.

add

|

f64x2

.

sub

f64x2

.

sub

|

f64x2

.

mul

f64x2

.

mul

|

f64x2

.

div

f64x2

.

div

|

f64x2

.

min

f64x2

.

min

|

f64x2

.

max

f64x2

.

max

|

f64x2

.

pmin

f64x2

.

pmin

|

f64x2

.

pmax

f64x2

.

pmax

|

i32x4

.

trunc

_

sat

_

f32x4

_

s

i32x4

.

trunc

_

sat

_

f32x4

_

s

|

i32x4

.

trunc

_

sat

_

f32x4

_

u

i32x4

.

trunc

_

sat

_

f32x4

_

u

|

i32x4

.

trunc

_

sat

_

f64x2

_

s

_

zero

i32x4

.

trunc

_

sat

_

f64x2

_

s

_

zero

|

i32x4

.

trunc

_

sat

_

f64x2

_

u

_

zero

i32x4

.

trunc

_

sat

_

f64x2

_

u

_

zero

|

f32x4

.

convert

_

i32x4

_

s

f32x4

.

convert

_

i32x4

_

s

|

f32x4

.

convert

_

i32x4

_

u

f32x4

.

convert

_

i32x4

_

u

|

f64x2

.

convert

_

low

_

i32x4

_

s

f64x2

.

convert

_

low

_

i32x4

_

s

|

f64x2

.

convert

_

low

_

i32x4

_

u

f64x2

.

convert

_

low

_

i32x4

_

u

|

f32x4

.

demote

_

f64x2

_

zero

f32x4

.

demote

_

f64x2

_

zero

|

f64x2

.

promote

_

low

_

f32x4

f64x2

.

promote

_

low

_

f32x4

|

6.5. Instructions

173

6.5.10 Folded Instructions

Instructions can be written as S-expressions by grouping them into

folded

form. In that notation, an instruction is

wrapped in parentheses and optionally includes nested folded instructions to indicate its operands.
In the case of

block instructions

the folded form omits the ‘

end

’ delimiter. For

if

instructions, both branches have

to be wrapped into nested S-expressions, headed by the keywords ‘

then

’ and ‘

else

’.

The set of all phrases defined by the following abbreviations recursively forms the auxiliary syntactic class

foldedinstr

Such a folded instruction can appear anywhere a regular instruction can.

(

plaininstr foldedinstr

*

)

foldedinstr

*

plaininstr

(

’ ‘

block

label blocktype instr

*

)

block

label blocktype instr

*

end

(

’ ‘

loop

label blocktype instr

*

)

loop

label blocktype instr

*

end

(

’ ‘

if

label blocktype foldedinstr

*

(

’ ‘

then

instr

*

1

)

’ ‘

(

’ ‘

else

instr

*

2

)

?

)

foldedinstr

*

if

label blocktype instr

*

1

else

(

instr

*

2

)

?

end

Note:

For example, the instruction sequence

(

local

.

get

$

x

) (

i32

.

const 2

)

i32

.

add

(

i32

.

const 3

)

i32

.

mul

can be folded into

(

i32

.

mul

(

i32

.

add

(

local

.

get

$

x

) (

i32

.

const 2

)) (

i32

.

const 3

))

Folded instructions are solely syntactic sugar, no additional syntactic or type-based checking is implied.

6.5.11 Expressions

Expressions are written as instruction sequences. No explicit ‘

end

’ keyword is included, since they only occur in

bracketed positions.

expr

𝐼

::=

(

in

:

instr

𝐼

)

*

in

*

end

174

Chapter 6. Text Format

6.6 Modules

6.6.1 Indices

Indices

can be given either in raw numeric form or as symbolic

identifiers

when bound by a respective construct.

Such identifiers are looked up in the suitable space of the

identifier context

𝐼

.

typeidx

𝐼

::=

𝑥

:

u32

𝑥

|

𝑣

:

id

𝑥

(

if

𝐼.

types

[

𝑥

] =

𝑣

)

funcidx

𝐼

::=

𝑥

:

u32

𝑥

|

𝑣

:

id

𝑥

(

if

𝐼.

funcs

[

𝑥

] =

𝑣

)

tableidx

𝐼

::=

𝑥

:

u32

𝑥

|

𝑣

:

id

𝑥

(

if

𝐼.

tables

[

𝑥

] =

𝑣

)

memidx

𝐼

::=

𝑥

:

u32

𝑥

|

𝑣

:

id

𝑥

(

if

𝐼.

mems

[

𝑥

] =

𝑣

)

globalidx

𝐼

::=

𝑥

:

u32

𝑥

|

𝑣

:

id

𝑥

(

if

𝐼.

globals

[

𝑥

] =

𝑣

)

elemidx

𝐼

::=

𝑥

:

u32

𝑥

|

𝑣

:

id

𝑥

(

if

𝐼.

elem

[

𝑥

] =

𝑣

)

dataidx

𝐼

::=

𝑥

:

u32

𝑥

|

𝑣

:

id

𝑥

(

if

𝐼.

data

[

𝑥

] =

𝑣

)

localidx

𝐼

::=

𝑥

:

u32

𝑥

|

𝑣

:

id

𝑥

(

if

𝐼.

locals

[

𝑥

] =

𝑣

)

labelidx

𝐼

::=

𝑙

:

u32

𝑙

|

𝑣

:

id

𝑙

(

if

𝐼.

labels

[

𝑙

] =

𝑣

)

6.6.2 Types

Type definitions can bind a symbolic

type identifier

.

type

::=

(

’ ‘

type

id

?

ft

:

functype

)

ft

6.6.3 Type Uses

A

type use

is a reference to a

type definition

It may optionally be augmented by explicit inlined

parameter

and

result

declarations. That allows binding symbolic

identifiers

to name the

local indices

of parameters. If inline

declarations are given, then their types must match the referenced

function type

.

typeuse

𝐼

::=

(

’ ‘

type

𝑥

:

typeidx

𝐼

)

𝑥, 𝐼

(

if

𝐼.

typedefs

[

𝑥

] = [

𝑡

𝑛

1

]

[

𝑡

*

2

]

𝐼

=

{

locals

(

𝜖

)

𝑛

}

)

|

(

’ ‘

type

𝑥

:

typeidx

𝐼

)

(

𝑡

1

:

param

)

*

(

𝑡

2

:

result

)

*

𝑥, 𝐼

(

if

𝐼.

typedefs

[

𝑥

] = [

𝑡

*

1

]

[

𝑡

*

2

]

𝐼

=

{

locals

id(

param

)

*

}

well-formed

)

The synthesized attribute of a

typeuse

is a pair consisting of both the used

type index

and the updated

identifier

context

including possible parameter identifiers. The following auxiliary function extracts optional identifiers from

parameters:

id(

(

’ ‘

param

id

?

. . .

)

)

=

id

?

Note:

Both productions overlap for the case that the function type is

[]

[]

. However, in that case, they also

produce the same results, so that the choice is immaterial.
The

well-formedness

condition on

𝐼

ensures that the parameters do not contain duplicate identifier.

6.6. Modules

175

Abbreviations

A

typeuse

may also be replaced entirely by inline

parameter

and

result

declarations. In that case, a

type index

is

automatically inserted:

(

𝑡

1

:

param

)

*

(

𝑡

2

:

result

)

*

(

’ ‘

type

𝑥

)

param

*

result

*

where

𝑥

is the smallest existing

type index

whose definition in the current module is the

function type

[

𝑡

*

1

]

[

𝑡

*

2

]

.

If no such index exists, then a new

type definition

of the form

(

’ ‘

type

’ ‘

(

’ ‘

func

param

*

result

*

)

’ ‘

)

is inserted at the end of the module.
Abbreviations are expanded in the order they appear, such that previously inserted type definitions are reused by

consecutive expansions.

6.6.4 Imports

The descriptors in imports can bind a symbolic function, table, memory, or global

identifier

.

import

𝐼

::=

(

’ ‘

import

mod

:

name

nm

:

name

𝑑

:

importdesc

𝐼

)

{

module

mod

,

name

nm

,

desc

𝑑

}

importdesc

𝐼

::=

(

’ ‘

func

id

?

𝑥, 𝐼

:

typeuse

𝐼

)

func

𝑥

|

(

’ ‘

table

id

?

tt

:

tabletype

)

table

tt

|

(

’ ‘

memory

id

?

mt

:

memtype

)

mem

mt

|

(

’ ‘

global

id

?

gt

:

globaltype

)

global

gt

Abbreviations

As an abbreviation, imports may also be specified inline with

function

,

table

,

memory

or

global

definitions; see

the respective sections.

6.6.5 Functions

Function definitions can bind a symbolic

function identifier

and

local identifiers

for its

parameters

and locals.

func

𝐼

::=

(

’ ‘

func

id

?

𝑥, 𝐼

:

typeuse

𝐼

(

𝑡

:

local

)

*

(

in

:

instr

𝐼

′′

)

*

)

{

type

𝑥,

locals

𝑡

*

,

body

in

*

end

}

(

if

𝐼

′′

=

𝐼

{

locals

id(

local

)

*

}

well-formed

)

local

::=

(

’ ‘

local

id

?

𝑡

:

valtype

)

𝑡

The definition of the local

identifier context

𝐼

′′

uses the following auxiliary function to extract optional identifiers

from locals:

id(

(

’ ‘

local

id

?

. . .

)

)

=

id

?

Note:

The

well-formedness

condition on

𝐼

′′

ensures that parameters and locals do not contain duplicate identifiers.

176

Chapter 6. Text Format

Abbreviations

Multiple anonymous locals may be combined into a single declaration:

(

’ ‘

local

valtype

*

)

(

(

’ ‘

local

valtype

)

)

*

Functions can be defined as

imports

or

exports

inline:

(

’ ‘

func

id

?

(

’ ‘

import

name

1

name

2

)

typeuse

)

(

’ ‘

import

name

1

name

2

(

’ ‘

func

id

?

typeuse

)

’ ‘

)

(

’ ‘

func

id

?

(

’ ‘

export

name

)

. . .

)

(

’ ‘

export

name

(

’ ‘

func

id

)

’ ‘

)

’ ‘

(

’ ‘

func

id

. . .

)

(

if

id

?

̸

=

𝜖

id

=

id

?

id

?

=

𝜖

id

fresh

)

The latter abbreviation can be applied repeatedly, with “

. . .

” containing another import or export.

6.6.6 Tables

Table definitions can bind a symbolic

table identifier

.

table

𝐼

::=

(

’ ‘

table

id

?

tt

:

tabletype

)

{

type

tt

}

Abbreviations

An

element segment

can be given inline with a table definition, in which case its offset is

0

and the

limits

of the

table type

are inferred from the length of the given segment:

(

’ ‘

table

id

?

reftype

(

’ ‘

elem

expr

𝑛

:

vec

(

elemexpr

)

)

’ ‘

)

(

’ ‘

table

id

𝑛 𝑛

reftype

)

(

’ ‘

elem

’ ‘

(

’ ‘

table

id

)

’ ‘

(

’ ‘

i32

.

const

’ ‘

0

’ ‘

)

vec

(

elemexpr

)

)

(

if

id

?

̸

=

𝜖

id

=

id

?

id

?

=

𝜖

id

fresh

)

(

’ ‘

table

id

?

reftype

(

’ ‘

elem

𝑥

𝑛

:

vec

(

funcidx

)

)

(

’ ‘

table

id

𝑛 𝑛

reftype

)

(

’ ‘

elem

’ ‘

(

’ ‘

table

id

)

’ ‘

(

’ ‘

i32

.

const

’ ‘

0

’ ‘

)

vec

(

funcidx

)

)

(

if

id

?

̸

=

𝜖

id

=

id

?

id

?

=

𝜖

id

fresh

)

Tables can be defined as

imports

or

exports

inline:

(

’ ‘

table

id

?

(

’ ‘

import

name

1

name

2

)

tabletype

)

(

’ ‘

import

name

1

name

2

(

’ ‘

table

id

?

tabletype

)

’ ‘

)

(

’ ‘

table

id

?

(

’ ‘

export

name

)

. . .

)

(

’ ‘

export

name

(

’ ‘

table

id

)

’ ‘

)

’ ‘

(

’ ‘

table

id

. . .

)

(

if

id

?

̸

=

𝜖

id

=

id

?

id

?

=

𝜖

id

fresh

)

The latter abbreviation can be applied repeatedly, with “

. . .

” containing another import or export or an inline

elements segment.

6.6.7 Memories

Memory definitions can bind a symbolic

memory identifier

.

mem

𝐼

::=

(

’ ‘

memory

id

?

mt

:

memtype

)

{

type

mt

}

6.6. Modules

177

Abbreviations

A

data segment

can be given inline with a memory definition, in which case its offset is

0

the

limits

of the

memory

type

are inferred from the length of the data, rounded up to

page size

:

(

’ ‘

memory

id

?

(

’ ‘

data

𝑏

𝑛

:

datastring

)

’ ‘

)

(

’ ‘

memory

id

𝑚 𝑚

)

(

’ ‘

data

’ ‘

(

’ ‘

memory

id

)

’ ‘

(

’ ‘

i32

.

const

’ ‘

0

’ ‘

)

datastring

)

(

if

id

?

̸

=

𝜖

id

=

id

?

id

?

=

𝜖

id

fresh

𝑚

= ceil(

𝑛/

64Ki))

Memories can be defined as

imports

or

exports

inline:

(

’ ‘

memory

id

?

(

’ ‘

import

name

1

name

2

)

memtype

)

(

’ ‘

import

name

1

name

2

(

’ ‘

memory

id

?

memtype

)

’ ‘

)

(

’ ‘

memory

id

?

(

’ ‘

export

name

)

. . .

)

(

’ ‘

export

name

(

’ ‘

memory

id

)

’ ‘

)

’ ‘

(

’ ‘

memory

id

. . .

)

(

if

id

?

̸

=

𝜖

id

=

id

?

id

?

=

𝜖

id

fresh

)

The latter abbreviation can be applied repeatedly, with “

. . .

” containing another import or export or an inline data

segment.

6.6.8 Globals

Global definitions can bind a symbolic

global identifier

.

global

𝐼

::=

(

’ ‘

global

id

?

gt

:

globaltype

𝑒

:

expr

𝐼

)

{

type

gt

,

init

𝑒

}

Abbreviations

Globals can be defined as

imports

or

exports

inline:

(

’ ‘

global

id

?

(

’ ‘

import

name

1

name

2

)

globaltype

)

(

’ ‘

import

name

1

name

2

(

’ ‘

global

id

?

globaltype

)

’ ‘

)

(

’ ‘

global

id

?

(

’ ‘

export

name

)

. . .

)

(

’ ‘

export

name

(

’ ‘

global

id

)

’ ‘

)

’ ‘

(

’ ‘

global

id

. . .

)

(

if

id

?

̸

=

𝜖

id

=

id

?

id

?

=

𝜖

id

fresh

)

The latter abbreviation can be applied repeatedly, with “

. . .

” containing another import or export.

6.6.9 Exports

The syntax for exports mirrors their

abstract syntax

directly.

export

𝐼

::=

(

’ ‘

export

nm

:

name

𝑑

:

exportdesc

𝐼

)

{

name

nm

,

desc

𝑑

}

exportdesc

𝐼

::=

(

’ ‘

func

𝑥

:

funcidx

𝐼

)

func

𝑥

|

(

’ ‘

table

𝑥

:

tableidx

𝐼

)

table

𝑥

|

(

’ ‘

memory

𝑥

:

memidx

𝐼

)

mem

𝑥

|

(

’ ‘

global

𝑥

:

globalidx

𝐼

)

global

𝑥

178

Chapter 6. Text Format

Abbreviations

As an abbreviation, exports may also be specified inline with

function

,

table

,

memory

or

global

definitions; see

the respective sections.

6.6.10 Start Function

A

start function

is defined in terms of its index.

start

𝐼

::=

(

’ ‘

start

𝑥

:

funcidx

𝐼

)

{

func

𝑥

}

Note:

At most one start function may occur in a module, which is ensured by a suitable side condition on the

module

grammar.

6.6.11 Element Segments

Element segments allow for an optional

table index

to identify the table to initialize.

elem

𝐼

::=

(

’ ‘

elem

id

?

(

𝑒𝑡, 𝑦

*

):

elemlist

𝐼

)

{

type

𝑒𝑡,

init

𝑦

*

,

mode passive

}

|

(

’ ‘

elem

id

?

𝑥

:

tableuse

𝐼

(

’ ‘

offset

𝑒

:

expr

𝐼

)

(

𝑒𝑡, 𝑦

*

):

elemlist

𝐼

)

{

type

𝑒𝑡,

init

𝑦

*

,

mode active

{

table

𝑥,

offset

𝑒

}}

(

’ ‘

elem

id

?

declare

(

𝑒𝑡, 𝑦

*

):

elemlist

𝐼

)

{

type

𝑒𝑡,

init

𝑦

*

,

mode declarative

}

elemlist

𝐼

::=

𝑡

:

reftype

𝑦

*

:

vec

(

elemexpr

𝐼

)

(

type

𝑡,

init

𝑦

*

)

elemexpr

𝐼

::=

(

’ ‘

item

𝑒

:

expr

𝐼

)

𝑒

tableuse

𝐼

::=

(

’ ‘

table

𝑥

:

tableidx

𝐼

)

𝑥

Abbreviations

As an abbreviation, a single instruction may occur in place of the offset of an active element segment or as an

element expression:

(

instr

)

(

’ ‘

offset

instr

)

(

instr

)

(

’ ‘

item

instr

)

Also, the element list may be written as just a sequence of

function indices

:

func

vec

(

funcidx

𝐼

)

funcref

vec

(

(

’ ‘

ref

.

func

funcidx

𝐼

)

)

A table use can be omitted, defaulting to

0

. Furthermore, for backwards compatibility with earlier versions of

WebAssembly, if the table use is omitted, the ‘

func

’ keyword can be omitted as well.

𝜖

(

’ ‘

table

’ ‘

0

’ ‘

)

(

’ ‘

elem

id

?

(

’ ‘

offset

expr

𝐼

)

vec

(

funcidx

𝐼

)

)

(

’ ‘

elem

id

?

(

’ ‘

table

’ ‘

0

’ ‘

)

’ ‘

(

’ ‘

offset

expr

𝐼

)

’ ‘

func

vec

(

funcidx

𝐼

)

)

As another abbreviation, element segments may also be specified inline with

table

definitions; see the respective

section.

6.6. Modules

179

6.6.12 Data Segments

Data segments allow for an optional

memory index

to identify the memory to initialize. The data is written as a

string

which may be split up into a possibly empty sequence of individual string literals.

data

𝐼

::=

(

’ ‘

data

id

?

𝑏

*

:

datastring

)

{

init

𝑏

*

,

mode passive

}

|

(

’ ‘

data

id

?

𝑥

:

memuse

𝐼

(

’ ‘

offset

𝑒

:

expr

𝐼

)

𝑏

*

:

datastring

)

{

init

𝑏

*

,

mode active

{

memory

𝑥

,

offset

𝑒

}}

datastring

::=

(

𝑏

*

:

string

)

*

concat

((

𝑏

*

)

*

)

memuse

𝐼

::=

(

’ ‘

memory

𝑥

:

memidx

𝐼

)

𝑥

Note:

In the current version of WebAssembly, the only valid memory index is 0 or a symbolic

memory identifier

resolving to the same value.

Abbreviations

As an abbreviation, a single instruction may occur in place of the offset of an active data segment:

(

instr

)

(

’ ‘

offset

instr

)

Also, a memory use can be omitted, defaulting to

0

.

𝜖

(

’ ‘

memory

’ ‘

0

’ ‘

)

As another abbreviation, data segments may also be specified inline with

memory

definitions; see the respective

section.

6.6.13 Modules

A module consists of a sequence of fields that can occur in any order. All definitions and their respective bound

identifiers

scope over the entire module, including the text preceding them.

A module may optionally bind an

identifier

that names the module. The name serves a documentary role only.

Note:

Tools may include the module name in the

name section

of the

binary format

.

module

::=

(

’ ‘

module

id

?

(

𝑚

:

modulefield

𝐼

)

*

)

⨁︀

𝑚

*

(

if

𝐼

=

⨁︀

idc(

modulefield

)

*

well-formed

)

modulefield

𝐼

::=

ty

:

type

{

types

ty

}

|

im

:

import

𝐼

{

imports

im

}

|

fn

:

func

𝐼

{

funcs

fn

}

|

ta

:

table

𝐼

{

tables

ta

}

|

me

:

mem

𝐼

{

mems

me

}

|

gl

:

global

𝐼

{

globals

gl

}

|

ex

:

export

𝐼

{

exports

ex

}

|

st

:

start

𝐼

{

start

st

}

|

el

:

elem

𝐼

{

elems

el

}

|

da

:

data

𝐼

{

datas

da

}

The following restrictions are imposed on the composition of

modules

:

𝑚

1

𝑚

2

is defined if and only if

𝑚

1

.

start

=

𝜖

𝑚

2

.

start

=

𝜖

𝑚

1

.

funcs

=

𝑚

1

.

tables

=

𝑚

1

.

mems

=

𝑚

1

.

globals

=

𝜖

𝑚

2

.

imports

=

𝜖

180

Chapter 6. Text Format

Note:

The first condition ensures that there is at most one start function. The second condition enforces that all

imports

must occur before any regular definition of a

function

,

table

,

memory

or

global

thereby maintaining the

ordering of the respective

index spaces

.

The

well-formedness

condition on

𝐼

in the grammar for

module

ensures that no namespace contains duplicate

identifiers.

The definition of the initial

identifier context

𝐼

uses the following auxiliary definition which maps each relevant

definition to a singular context with one (possibly empty) identifier:

idc(

(

’ ‘

type

id

?

ft

:

functype

)

)

=

{

types

(

id

?

)

,

typedefs

ft

}

idc(

(

’ ‘

func

id

?

. . .

)

)

=

{

funcs

(

id

?

)

}

idc(

(

’ ‘

table

id

?

. . .

)

)

=

{

tables

(

id

?

)

}

idc(

(

’ ‘

memory

id

?

. . .

)

)

=

{

mems

(

id

?

)

}

idc(

(

’ ‘

global

id

?

. . .

)

)

=

{

globals

(

id

?

)

}

idc(

(

’ ‘

elem

id

?

. . .

)

)

=

{

elem

(

id

?

)

}

idc(

(

’ ‘

data

id

?

. . .

)

)

=

{

data

(

id

?

)

}

idc(

(

’ ‘

import

. . .

(

’ ‘

func

id

?

. . .

)

’ ‘

)

)

=

{

funcs

(

id

?

)

}

idc(

(

’ ‘

import

. . .

(

’ ‘

table

id

?

. . .

)

’ ‘

)

)

=

{

tables

(

id

?

)

}

idc(

(

’ ‘

import

. . .

(

’ ‘

memory

id

?

. . .

)

’ ‘

)

)

=

{

mems

(

id

?

)

}

idc(

(

’ ‘

import

. . .

(

’ ‘

global

id

?

. . .

)

’ ‘

)

)

=

{

globals

(

id

?

)

}

idc(

(

. . .

)

)

=

{}

Abbreviations

In a source file, the toplevel

(

module

. . .

)

surrounding the module body may be omitted.

modulefield

*

(

’ ‘

module

modulefield

*

)

6.6. Modules

181

182

Chapter 6. Text Format

 

 

 

 

 

 

 

Content      ..     11      12      13      14     ..