Skip to content

Commit a250510

Browse files
committed
Fix crossrefs for metadata spec, deduplicate conf and macros
1 parent 81d6ff7 commit a250510

File tree

8 files changed

+33
-1457
lines changed

8 files changed

+33
-1457
lines changed

document/core/appendix/custom.rst

Lines changed: 0 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -239,63 +239,6 @@ It may only be placed on a declaration that declares exactly one local.
239239
\end{array}
240240
241241
242-
.. index:: ! branch hints section, hint
243-
.. _binary-branchhintsec:
244-
245-
Branch Hint Section
246-
~~~~~~~~~~~~~~~~~~~~
247-
248-
The *branch hint section* is a :ref:`custom section <binary-customsec>` whose name string is :math:`\text{metadata.code.branch\_hint}`.
249-
The branch hints section should appear only once in a module, and only before the :ref:`code section <binary-codesec>`.
250-
251-
The purpose of this section is to aid the compilation of conditional branch instructions, by providing a hint that a branch is very likely (or unlikely) to be taken.
252-
253-
The section contains a vector of *function branch hints* each representing the branch hints for a single function.
254-
255-
Each *function branch hints* structure consists of
256-
257-
* the :ref:`function index <binary-funcidx>` of the function the hints are referring to,
258-
* a vector of *branch hint* for the function.
259-
260-
Elements of the vector of *function branch hints* must appear in increasing function index order,
261-
and a function index can appear at most once.
262-
263-
Each *branch hint* structure consists of
264-
265-
* the |U32| byte offset of the hinted instruction from the beginning of the function body,
266-
* A |U32| with value '1',
267-
* a |U32| indicating the meaning of the hint:
268-
269-
===== ===========================================
270-
Value Meaning
271-
===== ===========================================
272-
0x00 branch likely not taken
273-
0x01 branch likely taken
274-
===== ===========================================
275-
276-
Elements of the vector of *branch hint* must appear in increasing byte offset order,
277-
and a byte offset can appear at most once. A |BRIF| or |IF| instruction must be present
278-
in the code section at the specified offset.
279-
280-
.. math::
281-
\begin{array}{llcll}
282-
\production{branch hint section} & \Bbranchhintsec &::=&
283-
\Bsection_0(\Bbranchhintdata) \\
284-
\production{branch hint data} & \Bbranchhintdata &::=&
285-
n{:}\Bname & (\iff n = \text{metadata.code.branch\_hint}) \\ &&&
286-
\Bvec(\Bfuncbranchhints) \\
287-
\production{function branch hints} & \Bfuncbranchhints &::=&
288-
fidx{:}\Bfuncidx~\Bvec(\Bbranchhint) \\
289-
\production{branch hint} & \Bbranchhint &::=&
290-
\X{instoff}{:}\Bu32 ~~ 1{:}\Bu32 ~~ \Bbranchhintkind \\
291-
\production{branch hint kind} & \Bbranchhintkind &::=&
292-
\hex{00} \\ &&|&
293-
\hex{01} \\
294-
\end{array}
295-
.. index:: ! custom annotation, custom section
296-
.. _text-customannot:
297-
298-
299242
Custom Annotations
300243
~~~~~~~~~~~~~~~~~~
301244

@@ -394,26 +337,3 @@ Their relative placement will depend on the placement directive given for the :m
394337
custom section "A"
395338
custom section "D"
396339
397-
398-
.. index:: ! branch hints annotation, hint
399-
.. _text-branchhintannot:
400-
401-
Branch Hint Annotations
402-
~~~~~~~~~~~~~~~~~~~~~~~
403-
404-
*Branch Hint annotations* are the textual analogue to the :ref:`branch hint section <binary-branchhintsec>` and provide a textual representation for it.
405-
Consequently, their id is :math:`\T{@metadata.code.branch\_hint}`.
406-
407-
Branch hint annotations are allowed only on |BRIF| and |IF| instructions,
408-
and at most one branch hint annotation may be given per instruction.
409-
410-
Branch hint annotations have the following format:
411-
412-
.. math::
413-
\begin{array}{llclll}
414-
\production{branch hint annotation} & \Tbranchhintannot &::=&
415-
\text{(@metadata.code.branch\_hint}~\Tbranchhintstr~\text{)} \\
416-
\production{branch hint string} & \Tbranchhintstr &::=&
417-
\text{"\backslash 00"} \\ &&|&
418-
\text{"\backslash 01"} \\
419-
\end{array}

document/core/util/macros.def

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1271,14 +1271,6 @@
12711271
.. |Bfuncnamesubsec| mathdef:: \xref{appendix/custom}{binary-funcnamesec}{\B{funcnamesubsec}}
12721272
.. |Blocalnamesubsec| mathdef:: \xref{appendix/custom}{binary-localnamesec}{\B{localnamesubsec}}
12731273

1274-
.. Branch Hints Section, non-terminals
1275-
1276-
.. |Bbranchhintsec| mathdef:: \xref{appendix/custom}{binary-branchhintsec}{\B{branchhintsec}}
1277-
.. |Bbranchhintdata| mathdef:: \xref{appendix/custom}{binary-branchhintsec}{\B{branchhintdata}}
1278-
.. |Bfuncbranchhints| mathdef:: \xref{appendix/custom}{binary-branchhintssec}{\B{funcbranchhints}}
1279-
.. |Bbranchhint| mathdef:: \xref{appendix/custom}{binary-branchhintsec}{\B{branchhint}}
1280-
.. |Bbranchhintkind| mathdef:: \xref{appendix/custom}{binary-branchhintsec}{\B{branchhintkind}}
1281-
12821274
.. Annotations
12831275
.. -----------
12841276

@@ -1297,11 +1289,6 @@
12971289
.. |Tparamnameannot| mathdef:: \xref{appendix/custom}{text-paramnameannot}{\T{paramnameannot}}
12981290
.. |Tlocalnameannot| mathdef:: \xref{appendix/custom}{text-localnameannot}{\T{localnameannot}}
12991291

1300-
.. Branch Hint annotations, non-terminals
1301-
1302-
.. |Tbranchhintannot| mathdef:: \xref{appendix/custom}{text-branchhintannot}{\T{branchhintannot}}
1303-
.. |Tbranchhintstr| mathdef:: \xref{appendix/custom}{text-branchhintannot}{\T{branchhintstr}}
1304-
13051292

13061293
.. Embedding
13071294
.. ---------

document/metadata/code/binary.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
Binary Format
44
=============
55

6+
.. _binary-codemetadata:
7+
68
Code Metadata
79
-------------
810

@@ -30,6 +32,8 @@ Where *funcpos* is the byte offset of the annotation starting from the beginning
3032

3133
*code metadata function* entries must appear in order of increasing *function id*, and duplicate id values are not allowed. *code metadata item* entries must appear in order of increasing *instruction offset*, and duplicate offset values are not allowed.
3234

35+
.. _binary-branchhints:
36+
3337
Branch Hints
3438
~~~~~~~~~~~~
3539

document/metadata/code/conf.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
import sys
2020
from datetime import date
2121

22+
core_dir = os.path.abspath('../../core')
23+
sys.path.insert(0, core_dir)
2224
pwd = os.path.abspath('.')
2325
sys.path.insert(0, pwd)
2426

@@ -294,7 +296,7 @@
294296

295297
# Additional stuff for the LaTeX preamble.
296298
# Don't type-set cross references with emphasis.
297-
'preamble': '\\renewcommand\\sphinxcrossref[1]{#1}\n',
299+
'preamble': '\\renewcommand\\sphinxcrossref[1]{#1}\n\\externaldocument[Core-]{'+core_dir+'/_build/latex/WebAssembly}[https://webassembly.github.io//'+repo+'/core/_download/WebAssembly.pdf]\n',
298300

299301
# Latex figure (float) alignment
300302
'figure_align': 'htbp',
@@ -303,7 +305,9 @@
303305
'fncychap': '\\usepackage[Sonny]{fncychap}',
304306

305307
# Allow chapters to start on even pages
306-
'extraclassoptions': 'openany'
308+
'extraclassoptions': 'openany',
309+
310+
'extrapackages': '\\usepackage{xr-hyper}',
307311
}
308312

309313
# Grouping the document tree into LaTeX files. List of tuples
@@ -489,6 +493,7 @@
489493
rst_prolog = """
490494
.. |issuelink| replace:: https://github.com/webassembly/""" + repo + """/issues/
491495
.. |pagelink| replace:: https://webassembly.github.io/""" + repo + """/core/
496+
.. include:: /""" + core_dir + """/util/macros.def
492497
.. include:: /""" + pwd + """/util/macros.def
493498
"""
494499

document/metadata/code/text.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
Text Format
44
===========
55

6+
.. _text-codemetadata:
7+
68
Code Metadata
79
-------------
810

@@ -15,6 +17,7 @@ attached to the first instruction that follows them.
1517
\production{code metadata annotation} & \Tcodemetadataannot(\B{T}) &::=&
1618
\text{(@metadata.code.T}~\X{data}{:}\B{T}~\text{)} \\
1719
\end{array}
20+
.. index:: ! code metadata annotation
1821

1922
Where `T` is the type of the item, and `data` is a byte string containing the same
2023
payload as in the binary format.

0 commit comments

Comments
 (0)