Skip to content

Commit

Permalink
Split sx for uniformity
Browse files Browse the repository at this point in the history
  • Loading branch information
rossberg committed Jul 19, 2024
1 parent 4a13994 commit 62c9412
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 27 deletions.
4 changes: 2 additions & 2 deletions spectec/spec/wasm-2.0/1-syntax.watsup
Original file line number Diff line number Diff line change
Expand Up @@ -296,8 +296,8 @@ syntax vbinop_(Jnn X N) =
| ADD_SAT sx hint(show ADD_SAT#_#%) -- if $sizemm(Jnn) <= `16
| SUB_SAT sx hint(show SUB_SAT#_#%) -- if $sizemm(Jnn) <= `16
| MUL -- if $sizemm(Jnn) >= `16
| AVGR_U -- if $sizemm(Jnn) <= `16
| Q15MULR_SAT_S -- if $sizemm(Jnn) = `16
| AVGR U -- if $sizemm(Jnn) <= `16
| Q15MULR_SAT S -- if $sizemm(Jnn) = `16
| MIN sx hint(show MIN#_#%) -- if $sizemm(Jnn) <= `32
| MAX sx hint(show MAX#_#%) -- if $sizemm(Jnn) <= `32
syntax vbinop_(Fnn X N) = ADD | SUB | MUL | DIV | MIN | MAX | PMIN | PMAX
Expand Down
4 changes: 2 additions & 2 deletions spectec/spec/wasm-2.0/3-numerics.watsup
Original file line number Diff line number Diff line change
Expand Up @@ -262,11 +262,11 @@ def $vbinop(Jnn X N, MUL, v128_1, v128_2) = v128
-- if lane_1* = $lanes_(Jnn X N, v128_1)
-- if lane_2* = $lanes_(Jnn X N, v128_2)
-- if v128 = $invlanes_(Jnn X N, $imul($lsize(Jnn), lane_1, lane_2)*)
def $vbinop(Jnn X N, AVGR_U, v128_1, v128_2) = v128
def $vbinop(Jnn X N, AVGR U, v128_1, v128_2) = v128
-- if lane_1* = $lanes_(Jnn X N, v128_1)
-- if lane_2* = $lanes_(Jnn X N, v128_2)
-- if v128 = $invlanes_(Jnn X N, $iavgr_u($lsize(Jnn), lane_1, lane_2)*)
def $vbinop(Jnn X N, Q15MULR_SAT_S, v128_1, v128_2) = v128
def $vbinop(Jnn X N, Q15MULR_SAT S, v128_1, v128_2) = v128
-- if lane_1* = $lanes_(Jnn X N, v128_1)
-- if lane_2* = $lanes_(Jnn X N, v128_2)
-- if v128 = $invlanes_(Jnn X N, $iq15mulrsat_s($lsize(Jnn), lane_1, lane_2)*)
Expand Down
6 changes: 3 additions & 3 deletions spectec/spec/wasm-2.0/A-binary.watsup
Original file line number Diff line number Diff line change
Expand Up @@ -612,15 +612,15 @@ grammar Binstr/vector-v-i8x16 : instr = ...
| 0xFD 119:Bu32 => VBINOP (I8 X 16) (MIN U)
| 0xFD 120:Bu32 => VBINOP (I8 X 16) (MAX S)
| 0xFD 121:Bu32 => VBINOP (I8 X 16) (MAX U)
| 0xFD 123:Bu32 => VBINOP (I8 X 16) AVGR_U
| 0xFD 123:Bu32 => VBINOP (I8 X 16) (AVGR U)
| ...

grammar Binstr/vector-v-i16x8 : instr = ...
| 0xFD 124:Bu32 => VEXTUNOP (I16 X 8) (I8 X 16) (EXTADD_PAIRWISE S)
| 0xFD 125:Bu32 => VEXTUNOP (I16 X 8) (I8 X 16) (EXTADD_PAIRWISE U)
| 0xFD 128:Bu32 => VUNOP (I16 X 8) ABS
| 0xFD 129:Bu32 => VUNOP (I16 X 8) NEG
| 0xFD 130:Bu32 => VBINOP (I16 X 8) Q15MULR_SAT_S
| 0xFD 130:Bu32 => VBINOP (I16 X 8) (Q15MULR_SAT S)
| 0xFD 131:Bu32 => VTESTOP (I16 X 8) ALL_TRUE
| 0xFD 132:Bu32 => VBITMASK (I16 X 8)
| 0xFD 133:Bu32 => VNARROW (I16 X 8) (I32 X 4) S
Expand All @@ -643,7 +643,7 @@ grammar Binstr/vector-v-i16x8 : instr = ...
| 0xFD 151:Bu32 => VBINOP (I16 X 8) (MIN U)
| 0xFD 152:Bu32 => VBINOP (I16 X 8) (MAX S)
| 0xFD 153:Bu32 => VBINOP (I16 X 8) (MAX U)
| 0xFD 155:Bu32 => VBINOP (I16 X 8) AVGR_U
| 0xFD 155:Bu32 => VBINOP (I16 X 8) (AVGR U)
| 0xFD 156:Bu32 => VEXTBINOP (I16 X 8) (I8 X 16) (EXTMUL S LOW)
| 0xFD 157:Bu32 => VEXTBINOP (I16 X 8) (I8 X 16) (EXTMUL S HIGH)
| 0xFD 158:Bu32 => VEXTBINOP (I16 X 8) (I8 X 16) (EXTMUL U LOW)
Expand Down
14 changes: 7 additions & 7 deletions spectec/spec/wasm-3.0/1-syntax.watsup
Original file line number Diff line number Diff line change
Expand Up @@ -405,13 +405,13 @@ syntax vbinop_(shape) hint(macro "%" "V%")
syntax vbinop_(Jnn X M) =
| ADD
| SUB
| ADD_SAT sx hint(show ADD_SAT#_#%) -- if $lsizenn(Jnn) <= `16
| SUB_SAT sx hint(show SUB_SAT#_#%) -- if $lsizenn(Jnn) <= `16
| MUL -- if $lsizenn(Jnn) >= `16
| AVGR_U -- if $lsizenn(Jnn) <= `16 ;; TODO(2, rossberg): AVGR U
| Q15MULR_SAT_S -- if $lsizenn(Jnn) = `16 ;; TODO(2, rossberg): Q15MULR_SAT S
| MIN sx hint(show MIN#_#%) -- if $lsizenn(Jnn) <= `32
| MAX sx hint(show MAX#_#%) -- if $lsizenn(Jnn) <= `32
| ADD_SAT sx hint(show ADD_SAT#_#%) -- if $lsizenn(Jnn) <= `16
| SUB_SAT sx hint(show SUB_SAT#_#%) -- if $lsizenn(Jnn) <= `16
| MUL -- if $lsizenn(Jnn) >= `16
| AVGR U hint(show AVGR#_#%) -- if $lsizenn(Jnn) <= `16
| Q15MULR_SAT S hint(show Q15MULR_SAT#_#%) -- if $lsizenn(Jnn) = `16
| MIN sx hint(show MIN#_#%) -- if $lsizenn(Jnn) <= `32
| MAX sx hint(show MAX#_#%) -- if $lsizenn(Jnn) <= `32
syntax vbinop_(Fnn X M) = ADD | SUB | MUL | DIV | MIN | MAX | PMIN | PMAX

syntax vtestop_(shape) hint(macro "%" "V%")
Expand Down
4 changes: 2 additions & 2 deletions spectec/spec/wasm-3.0/3-numerics.watsup
Original file line number Diff line number Diff line change
Expand Up @@ -279,11 +279,11 @@ def $vbinop(Jnn X N, MUL, v128_1, v128_2) = v128
-- if lane_1* = $lanes_(Jnn X N, v128_1)
-- if lane_2* = $lanes_(Jnn X N, v128_2)
-- if v128 = $invlanes_(Jnn X N, $imul($lsize(Jnn), lane_1, lane_2)*)
def $vbinop(Jnn X N, AVGR_U, v128_1, v128_2) = v128
def $vbinop(Jnn X N, AVGR U, v128_1, v128_2) = v128
-- if lane_1* = $lanes_(Jnn X N, v128_1)
-- if lane_2* = $lanes_(Jnn X N, v128_2)
-- if v128 = $invlanes_(Jnn X N, $iavgr_u($lsize(Jnn), lane_1, lane_2)*)
def $vbinop(Jnn X N, Q15MULR_SAT_S, v128_1, v128_2) = v128
def $vbinop(Jnn X N, Q15MULR_SAT S, v128_1, v128_2) = v128
-- if lane_1* = $lanes_(Jnn X N, v128_1)
-- if lane_2* = $lanes_(Jnn X N, v128_2)
-- if v128 = $invlanes_(Jnn X N, $iq15mulrsat_s($lsize(Jnn), lane_1, lane_2)*)
Expand Down
6 changes: 3 additions & 3 deletions spectec/spec/wasm-3.0/A-binary.watsup
Original file line number Diff line number Diff line change
Expand Up @@ -756,7 +756,7 @@ grammar Binstr/vec-bin-i8x16 : instr = ...
| 0xFD 119:Bu32 => VBINOP (I8 X `16) (MIN U)
| 0xFD 120:Bu32 => VBINOP (I8 X `16) (MAX S)
| 0xFD 121:Bu32 => VBINOP (I8 X `16) (MAX U)
| 0xFD 123:Bu32 => VBINOP (I8 X `16) AVGR_U
| 0xFD 123:Bu32 => VBINOP (I8 X `16) (AVGR U)
| ...

grammar Binstr/vec-extun-i16x8 : instr = ...
Expand All @@ -770,7 +770,7 @@ grammar Binstr/vec-un-i16x8 : instr = ...
| ...

grammar Binstr/vec-bin-i16x8 : instr = ...
| 0xFD 130:Bu32 => VBINOP (I16 X `8) Q15MULR_SAT_S
| 0xFD 130:Bu32 => VBINOP (I16 X `8) (Q15MULR_SAT S)
| ...

grammar Binstr/vec-test-i16x8 : instr = ...
Expand Down Expand Up @@ -811,7 +811,7 @@ grammar Binstr/vec-bin-i16x8 : instr = ...
| 0xFD 151:Bu32 => VBINOP (I16 X `8) (MIN U)
| 0xFD 152:Bu32 => VBINOP (I16 X `8) (MAX S)
| 0xFD 153:Bu32 => VBINOP (I16 X `8) (MAX U)
| 0xFD 155:Bu32 => VBINOP (I16 X `8) AVGR_U
| 0xFD 155:Bu32 => VBINOP (I16 X `8) (AVGR U)
| ...

grammar Binstr/vec-extbin-i16x8 : instr = ...
Expand Down
16 changes: 8 additions & 8 deletions spectec/src/backend-interpreter/construct.ml
Original file line number Diff line number Diff line change
Expand Up @@ -503,13 +503,13 @@ let al_to_int_vbinop : value -> V128Op.ibinop = function
| CaseV ("MIN", [CaseV ("U", [])]) -> V128Op.MinU
| CaseV ("MAX", [CaseV ("S", [])]) -> V128Op.MaxS
| CaseV ("MAX", [CaseV ("U", [])]) -> V128Op.MaxU
| CaseV ("AVGR_U", []) -> V128Op.AvgrU
| CaseV ("AVGR", [CaseV ("U", [])]) -> V128Op.AvgrU
| CaseV ("ADD_SAT", [CaseV ("S", [])]) -> V128Op.AddSatS
| CaseV ("ADD_SAT", [CaseV ("U", [])]) -> V128Op.AddSatU
| CaseV ("SUB_SAT", [CaseV ("S", [])]) -> V128Op.SubSatS
| CaseV ("SUB_SAT", [CaseV ("U", [])]) -> V128Op.SubSatU
| CaseV ("DOT", [CaseV ("S", [])]) -> V128Op.DotS
| CaseV ("Q15MULR_SAT_S", []) -> V128Op.Q15MulRSatS
| CaseV ("Q15MULR_SAT", [CaseV ("S", [])]) -> V128Op.Q15MulRSatS
| CaseV ("SWIZZLE", []) -> V128Op.Swizzle
(*TODO *)
| CaseV ("Shuffle", [ l ]) -> V128Op.Shuffle (al_to_list al_to_int l)
Expand Down Expand Up @@ -1412,12 +1412,12 @@ let al_of_int_vbinop : V128Op.ibinop -> value option = function
| V128Op.MinU -> Some (caseV ("MIN", [nullary "U"]))
| V128Op.MaxS -> Some (caseV ("MAX", [nullary "S"]))
| V128Op.MaxU -> Some (caseV ("MAX", [nullary "U"]))
| V128Op.AvgrU -> Some (nullary "AVGR_U")
| V128Op.AddSatS -> Some (CaseV ("ADD_SAT", [nullary "S"]))
| V128Op.AddSatU -> Some (CaseV ("ADD_SAT", [nullary "U"]))
| V128Op.SubSatS -> Some (CaseV ("SUB_SAT", [nullary "S"]))
| V128Op.SubSatU -> Some (CaseV ("SUB_SAT", [nullary "U"]))
| V128Op.Q15MulRSatS -> Some (nullary "Q15MULR_SAT_S")
| V128Op.AvgrU -> Some (caseV ("AVGR", [nullary "U"]))
| V128Op.AddSatS -> Some (caseV ("ADD_SAT", [nullary "S"]))
| V128Op.AddSatU -> Some (caseV ("ADD_SAT", [nullary "U"]))
| V128Op.SubSatS -> Some (caseV ("SUB_SAT", [nullary "S"]))
| V128Op.SubSatU -> Some (caseV ("SUB_SAT", [nullary "U"]))
| V128Op.Q15MulRSatS -> Some (caseV ("Q15MULR_SAT", [nullary "S"]))
| _ -> None

let al_of_float_vbinop : V128Op.fbinop -> value = function
Expand Down

0 comments on commit 62c9412

Please sign in to comment.