From beb8fb572c9d3ebf5c090a7c0e9a21c7b11893a0 Mon Sep 17 00:00:00 2001 From: Sam Clegg Date: Wed, 24 Apr 2024 15:03:24 -0700 Subject: [PATCH 1/2] [test] Remove stray tabs from test files (#1745) --- test/core/elem.wast | 10 +++++----- test/core/memory.wast | 40 ++++++++++++++++++++-------------------- 2 files changed, 25 insertions(+), 25 deletions(-) diff --git a/test/core/elem.wast b/test/core/elem.wast index 33b3f67bc..68a244b99 100644 --- a/test/core/elem.wast +++ b/test/core/elem.wast @@ -644,11 +644,11 @@ ;; Initializing a table with an externref-type element segment (module $m - (table $t (export "table") 2 externref) - (func (export "get") (param $i i32) (result externref) - (table.get $t (local.get $i))) - (func (export "set") (param $i i32) (param $x externref) - (table.set $t (local.get $i) (local.get $x)))) + (table $t (export "table") 2 externref) + (func (export "get") (param $i i32) (result externref) + (table.get $t (local.get $i))) + (func (export "set") (param $i i32) (param $x externref) + (table.set $t (local.get $i) (local.get $x)))) (register "exporter" $m) diff --git a/test/core/memory.wast b/test/core/memory.wast index 497b69fc9..6cd2560c6 100644 --- a/test/core/memory.wast +++ b/test/core/memory.wast @@ -136,44 +136,44 @@ ;; Sign and zero extending memory loads (func (export "i32_load8_s") (param $i i32) (result i32) - (i32.store8 (i32.const 8) (local.get $i)) - (i32.load8_s (i32.const 8)) + (i32.store8 (i32.const 8) (local.get $i)) + (i32.load8_s (i32.const 8)) ) (func (export "i32_load8_u") (param $i i32) (result i32) - (i32.store8 (i32.const 8) (local.get $i)) - (i32.load8_u (i32.const 8)) + (i32.store8 (i32.const 8) (local.get $i)) + (i32.load8_u (i32.const 8)) ) (func (export "i32_load16_s") (param $i i32) (result i32) - (i32.store16 (i32.const 8) (local.get $i)) - (i32.load16_s (i32.const 8)) + (i32.store16 (i32.const 8) (local.get $i)) + (i32.load16_s (i32.const 8)) ) (func (export "i32_load16_u") (param $i i32) (result i32) - (i32.store16 (i32.const 8) (local.get $i)) - (i32.load16_u (i32.const 8)) + (i32.store16 (i32.const 8) (local.get $i)) + (i32.load16_u (i32.const 8)) ) (func (export "i64_load8_s") (param $i i64) (result i64) - (i64.store8 (i32.const 8) (local.get $i)) - (i64.load8_s (i32.const 8)) + (i64.store8 (i32.const 8) (local.get $i)) + (i64.load8_s (i32.const 8)) ) (func (export "i64_load8_u") (param $i i64) (result i64) - (i64.store8 (i32.const 8) (local.get $i)) - (i64.load8_u (i32.const 8)) + (i64.store8 (i32.const 8) (local.get $i)) + (i64.load8_u (i32.const 8)) ) (func (export "i64_load16_s") (param $i i64) (result i64) - (i64.store16 (i32.const 8) (local.get $i)) - (i64.load16_s (i32.const 8)) + (i64.store16 (i32.const 8) (local.get $i)) + (i64.load16_s (i32.const 8)) ) (func (export "i64_load16_u") (param $i i64) (result i64) - (i64.store16 (i32.const 8) (local.get $i)) - (i64.load16_u (i32.const 8)) + (i64.store16 (i32.const 8) (local.get $i)) + (i64.load16_u (i32.const 8)) ) (func (export "i64_load32_s") (param $i i64) (result i64) - (i64.store32 (i32.const 8) (local.get $i)) - (i64.load32_s (i32.const 8)) + (i64.store32 (i32.const 8) (local.get $i)) + (i64.load32_s (i32.const 8)) ) (func (export "i64_load32_u") (param $i i64) (result i64) - (i64.store32 (i32.const 8) (local.get $i)) - (i64.load32_u (i32.const 8)) + (i64.store32 (i32.const 8) (local.get $i)) + (i64.load32_u (i32.const 8)) ) ) From 242847319caa342faac3903c9107a851f11ac141 Mon Sep 17 00:00:00 2001 From: Andreas Rossberg Date: Sun, 28 Apr 2024 09:09:30 +0200 Subject: [PATCH 2/2] [spec] Check and fix cross-references (#1746) --- document/core/Makefile | 6 ++++- document/core/text/lexical.rst | 3 ++- document/core/text/modules.rst | 2 +- document/core/util/check_macros.sh | 32 ++++++++++++++++++++++++ document/core/util/macros.def | 40 ++++++++++-------------------- 5 files changed, 53 insertions(+), 30 deletions(-) create mode 100644 document/core/util/check_macros.sh diff --git a/document/core/Makefile b/document/core/Makefile index 74c9daeea..3ac2f1c81 100644 --- a/document/core/Makefile +++ b/document/core/Makefile @@ -80,7 +80,7 @@ publish-main: clean main bikeshed-keep deploy all: pdf html bikeshed .PHONY: main -main: pdf html +main: macrosok pdf html # Dirty hack to avoid rebuilding the Bikeshed version for every push. .PHONY: bikeshed-keep @@ -97,6 +97,10 @@ GENERATED = appendix/index-instructions.rst %.rst: %.py (cd `dirname $@`; ./`basename $^`) +.PHONY: macrosok +macrosok: $(GENERATED) + sh util/check_macros.sh + .PHONY: pdf pdf: $(GENERATED) latexpdf mkdir -p $(BUILDDIR)/html/$(DOWNLOADDIR) diff --git a/document/core/text/lexical.rst b/document/core/text/lexical.rst index 4584b0c42..684688d49 100644 --- a/document/core/text/lexical.rst +++ b/document/core/text/lexical.rst @@ -71,8 +71,9 @@ Any token that does not fall into any of the other categories is considered *res .. index:: ! white space, character, ASCII single: text format; white space -.. _text-format: .. _text-space: +.. _text-format: +.. _text-newline: White Space ~~~~~~~~~~~ diff --git a/document/core/text/modules.rst b/document/core/text/modules.rst index 5aab9b32c..5be5ce844 100644 --- a/document/core/text/modules.rst +++ b/document/core/text/modules.rst @@ -569,7 +569,7 @@ As another abbreviation, element segments may also be specified inline with :ref single: data; segment .. _text-datastring: .. _text-data: -.. _test-memuse: +.. _text-memuse: Data Segments ~~~~~~~~~~~~~ diff --git a/document/core/util/check_macros.sh b/document/core/util/check_macros.sh new file mode 100644 index 000000000..46d9d7680 --- /dev/null +++ b/document/core/util/check_macros.sh @@ -0,0 +1,32 @@ +#!/bin/sh + +cd `dirname $0`/.. + +FILES=`ls */*.rst` +ERRORS=0 + +for XREF in `grep xref util/macros.def`; do + if echo $XREF | grep -q "[|]"; then + MACRO=`echo $XREF | sed 's/^[^|]*[|]//g' | sed 's/[|].*$//g'` + elif echo $XREF | grep -q xref; then + FILE=`echo $XREF | sed 's/^.*xref{//g' | sed 's/}.*$//g'`.rst + LABEL=`echo $XREF | sed 's/^[^}]*}{//g' | sed 's/}.*$//g'` + TARGET=".. _$LABEL:" + if ! [ -f $FILE ] || ! grep -q "$TARGET" $FILE; then + ERRORS=1 + echo Undefined cross-reference $FILE:$LABEL in macro "|$MACRO|" + if ! [ -f $FILE ]; then + echo ...non-existent file $FILE + fi + if grep -q "$TARGET" $FILES; then + echo ...defined in `grep -l "$TARGET" $FILES` + fi + fi + fi +done + +if [ $ERRORS -eq 0 ]; then + echo All cross-references okay. +else + exit 1; +fi diff --git a/document/core/util/macros.def b/document/core/util/macros.def index 1dcec42d2..06b60fd6f 100644 --- a/document/core/util/macros.def +++ b/document/core/util/macros.def @@ -177,8 +177,6 @@ .. |to| mathdef:: \xref{syntax/types}{syntax-functype}{\rightarrow} -.. |I8| mathdef:: \xref{exec/runtime}{syntax-storagetype}{\K{i8}} -.. |I16| mathdef:: \xref{exec/runtime}{syntax-storagetype}{\K{i16}} .. |I32| mathdef:: \xref{syntax/types}{syntax-valtype}{\K{i32}} .. |I64| mathdef:: \xref{syntax/types}{syntax-valtype}{\K{i64}} .. |F32| mathdef:: \xref{syntax/types}{syntax-valtype}{\K{f32}} @@ -227,8 +225,8 @@ .. |externtype| mathdef:: \xref{syntax/types}{syntax-externtype}{\X{externtype}} -.. |stacktype| mathdef:: \xref{syntax/types}{syntax-stacktype}{\X{stacktype}} -.. |opdtype| mathdef:: \xref{syntax/types}{syntax-opdtype}{\X{opdtype}} +.. |stacktype| mathdef:: \xref{valid/instructions}{syntax-stacktype}{\X{stacktype}} +.. |opdtype| mathdef:: \xref{valid/instructions}{syntax-opdtype}{\X{opdtype}} .. Types, meta functions @@ -523,9 +521,7 @@ .. |vunop| mathdef:: \xref{syntax/instructions}{syntax-vunop}{\X{vunop}} .. |vbinop| mathdef:: \xref{syntax/instructions}{syntax-vbinop}{\X{vbinop}} .. |vrelop| mathdef:: \xref{syntax/instructions}{syntax-vrelop}{\X{vrelop}} -.. |vternop| mathdef:: \xref{syntax/instructions}{syntax-vternop}{\X{vternop}} .. |vcvtop| mathdef:: \xref{syntax/instructions}{syntax-vcvtop}{\X{vcvtop}} -.. |vextmul| mathdef:: \xref{syntax/instructions}{syntax-vextmul}{\X{vextmul}} .. |laneidx| mathdef:: \xref{syntax/instructions}{syntax-laneidx}{\X{laneidx}} .. |vvunop| mathdef:: \xref{syntax/instructions}{syntax-vvunop}{\X{vvunop}} @@ -797,19 +793,10 @@ .. |Tlocalidx| mathdef:: \xref{text/modules}{text-localidx}{\T{localidx}} .. |Tlabelidx| mathdef:: \xref{text/modules}{text-labelidx}{\T{labelidx}} -.. |Ttypebind| mathdef:: \xref{text/modules}{text-typebind}{\T{typebind}} -.. |Tfuncbind| mathdef:: \xref{text/modules}{text-funcbind}{\T{funcbind}} -.. |Ttablebind| mathdef:: \xref{text/modules}{text-tablebind}{\T{tablebind}} -.. |Tmembind| mathdef:: \xref{text/modules}{text-membind}{\T{membind}} -.. |Tglobalbind| mathdef:: \xref{text/modules}{text-globalbind}{\T{globalbind}} -.. |Tlocalbind| mathdef:: \xref{text/modules}{text-localbind}{\T{localbind}} -.. |Tlabelbind| mathdef:: \xref{text/modules}{text-labelbind}{\T{labelbind}} - .. Modules, non-terminals .. |Tmodule| mathdef:: \xref{text/modules}{text-module}{\T{module}} -.. |Tmodulebody| mathdef:: \xref{text/modules}{text-modulebody}{\T{modulebody}} .. |Tmodulefield| mathdef:: \xref{text/modules}{text-modulefield}{\T{modulefield}} .. |Ttype| mathdef:: \xref{text/modules}{text-typedef}{\T{type}} .. |Ttypeuse| mathdef:: \xref{text/modules}{text-typeuse}{\T{typeuse}} @@ -825,7 +812,6 @@ .. |Telemlist| mathdef:: \xref{text/modules}{text-elemlist}{\T{elemlist}} .. |Telemexpr| mathdef:: \xref{text/modules}{text-elemexpr}{\T{elemexpr}} .. |Ttableuse| mathdef:: \xref{text/modules}{text-tableuse}{\T{tableuse}} -.. |Tcode| mathdef:: \xref{text/modules}{text-code}{\T{code}} .. |Tlocal| mathdef:: \xref{text/modules}{text-local}{\T{local}} .. |Tlocals| mathdef:: \xref{text/modules}{text-local}{\T{locals}} .. |Tdata| mathdef:: \xref{text/modules}{text-data}{\T{data}} @@ -940,10 +926,10 @@ .. Notation -.. |stepto| mathdef:: \xref{exec/conventions}{formal-notation}{\hookrightarrow} +.. |stepto| mathdef:: \xref{exec/conventions}{exec-notation}{\hookrightarrow} .. |extendsto| mathdef:: \xref{appendix/properties}{extend}{\preceq} -.. |matchesexterntype| mathdef:: \xref{exec/modules}{match-externtype}{\leq} -.. |matcheslimits| mathdef:: \xref{exec/modules}{match-limits}{\leq} +.. |matchesexterntype| mathdef:: \xref{valid/types}{match-externtype}{\leq} +.. |matcheslimits| mathdef:: \xref{valid/types}{match-limits}{\leq} .. Allocation @@ -1081,7 +1067,7 @@ .. Values & Results, non-terminals .. |num| mathdef:: \xref{exec/runtime}{syntax-num}{\X{num}} -.. |vecc| mathdef:: \xref{exec/runtime}{syntax-vec}{\X{vec}} +.. |vecc| mathdef:: \xref{exec/runtime}{syntax-vecc}{\X{vec}} .. |reff| mathdef:: \xref{exec/runtime}{syntax-ref}{\X{ref}} .. |val| mathdef:: \xref{exec/runtime}{syntax-val}{\X{val}} .. |result| mathdef:: \xref{exec/runtime}{syntax-result}{\X{result}} @@ -1144,10 +1130,10 @@ .. |imins| mathdef:: \xref{exec/numerics}{op-imin_s}{\F{imin\_s}} .. |imaxu| mathdef:: \xref{exec/numerics}{op-imax_u}{\F{imax\_u}} .. |imaxs| mathdef:: \xref{exec/numerics}{op-imax_s}{\F{imax\_s}} -.. |iaddsatu| mathdef:: \xref{exec/numerics}{op-iaddsat_u}{\F{iaddsat\_u}} -.. |iaddsats| mathdef:: \xref{exec/numerics}{op-iaddsat_s}{\F{iaddsat\_s}} -.. |isubsatu| mathdef:: \xref{exec/numerics}{op-isubsat_u}{\F{isubsat\_u}} -.. |isubsats| mathdef:: \xref{exec/numerics}{op-isubsat_s}{\F{isubsat\_s}} +.. |iaddsatu| mathdef:: \xref{exec/numerics}{op-iadd_sat_u}{\F{iadd\_sat\_u}} +.. |iaddsats| mathdef:: \xref{exec/numerics}{op-iadd_sat_s}{\F{iadd\_sat\_s}} +.. |isubsatu| mathdef:: \xref{exec/numerics}{op-isub_sat_u}{\F{isub\_sat\_u}} +.. |isubsats| mathdef:: \xref{exec/numerics}{op-isub_sat_s}{\F{isub\_sat\_s}} .. |iavgru| mathdef:: \xref{exec/numerics}{op-iavgr_u}{\F{iavgr\_u}} .. |iq15mulrsats| mathdef:: \xref{exec/numerics}{op-iq15mulrsat_s}{\F{iq15mulrsat\_s}} @@ -1223,8 +1209,8 @@ .. |vdashexternval| mathdef:: \xref{exec/modules}{valid-externval}{\vdash} -.. |vdashlimitsmatch| mathdef:: \xref{exec/modules}{match-limits}{\vdash} -.. |vdashexterntypematch| mathdef:: \xref{exec/modules}{match-externtype}{\vdash} +.. |vdashlimitsmatch| mathdef:: \xref{valid/types}{match-limits}{\vdash} +.. |vdashexterntypematch| mathdef:: \xref{valid/types}{match-externtype}{\vdash} .. Soundness @@ -1234,7 +1220,7 @@ .. |vdashadmininstr| mathdef:: \xref{appendix/properties}{valid-instr-admin}{\vdash} -.. |vdashval| mathdef:: \xref{appendix/properties}{valid-val}{\vdash} +.. |vdashval| mathdef:: \xref{exec/modules}{valid-val}{\vdash} .. |vdashresult| mathdef:: \xref{appendix/properties}{valid-result}{\vdash} .. |vdashfuncinst| mathdef:: \xref{appendix/properties}{valid-funcinst}{\vdash}