Commit c0d82bb0 authored by Richard Musiol's avatar Richard Musiol Committed by Richard Musiol

all: rename WebAssembly instructions according to spec changes

The names of some instructions have been updated in the WebAssembly
specification to be more consistent, see
https://github.com/WebAssembly/spec/commit/994591e51c9df9e7ef980b04d660709b79982f75.
This change to the spec is possible because it is still in a draft
state.

Go's support for WebAssembly is still experimental and thus excempt from
the compatibility promise. Being consistent with the spec should
warrant this breaking change to the assembly instruction names.

Change-Id: Iafb8b18ee7f55dd0e23c6c7824aa1fad43117ef1
Reviewed-on: https://go-review.googlesource.com/c/153797
Run-TryBot: Richard Musiol <neelance@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: default avatarCherry Zhang <cherryyz@google.com>
parent 159b2de4
...@@ -72,23 +72,23 @@ ...@@ -72,23 +72,23 @@
(Trunc16to8 x) -> x (Trunc16to8 x) -> x
// Lowering float <-> int // Lowering float <-> int
(Cvt32to32F x) -> (LoweredRound32F (F64ConvertSI64 (SignExt32to64 x))) (Cvt32to32F x) -> (LoweredRound32F (F64ConvertI64S (SignExt32to64 x)))
(Cvt32to64F x) -> (F64ConvertSI64 (SignExt32to64 x)) (Cvt32to64F x) -> (F64ConvertI64S (SignExt32to64 x))
(Cvt64to32F x) -> (LoweredRound32F (F64ConvertSI64 x)) (Cvt64to32F x) -> (LoweredRound32F (F64ConvertI64S x))
(Cvt64to64F x) -> (F64ConvertSI64 x) (Cvt64to64F x) -> (F64ConvertI64S x)
(Cvt32Uto32F x) -> (LoweredRound32F (F64ConvertUI64 (ZeroExt32to64 x))) (Cvt32Uto32F x) -> (LoweredRound32F (F64ConvertI64U (ZeroExt32to64 x)))
(Cvt32Uto64F x) -> (F64ConvertUI64 (ZeroExt32to64 x)) (Cvt32Uto64F x) -> (F64ConvertI64U (ZeroExt32to64 x))
(Cvt64Uto32F x) -> (LoweredRound32F (F64ConvertUI64 x)) (Cvt64Uto32F x) -> (LoweredRound32F (F64ConvertI64U x))
(Cvt64Uto64F x) -> (F64ConvertUI64 x) (Cvt64Uto64F x) -> (F64ConvertI64U x)
(Cvt32Fto32 x) -> (I64TruncSF64 x) (Cvt32Fto32 x) -> (I64TruncF64S x)
(Cvt32Fto64 x) -> (I64TruncSF64 x) (Cvt32Fto64 x) -> (I64TruncF64S x)
(Cvt64Fto32 x) -> (I64TruncSF64 x) (Cvt64Fto32 x) -> (I64TruncF64S x)
(Cvt64Fto64 x) -> (I64TruncSF64 x) (Cvt64Fto64 x) -> (I64TruncF64S x)
(Cvt32Fto32U x) -> (I64TruncUF64 x) (Cvt32Fto32U x) -> (I64TruncF64U x)
(Cvt32Fto64U x) -> (I64TruncUF64 x) (Cvt32Fto64U x) -> (I64TruncF64U x)
(Cvt64Fto32U x) -> (I64TruncUF64 x) (Cvt64Fto32U x) -> (I64TruncF64U x)
(Cvt64Fto64U x) -> (I64TruncUF64 x) (Cvt64Fto64U x) -> (I64TruncF64U x)
(Cvt32Fto64F x) -> x (Cvt32Fto64F x) -> x
(Cvt64Fto32F x) -> (LoweredRound32F x) (Cvt64Fto32F x) -> (LoweredRound32F x)
......
...@@ -187,10 +187,10 @@ func init() { ...@@ -187,10 +187,10 @@ func init() {
{name: "F64Mul", asm: "F64Mul", argLength: 2, reg: fp21, typ: "Float64"}, // arg0 * arg1 {name: "F64Mul", asm: "F64Mul", argLength: 2, reg: fp21, typ: "Float64"}, // arg0 * arg1
{name: "F64Div", asm: "F64Div", argLength: 2, reg: fp21, typ: "Float64"}, // arg0 / arg1 {name: "F64Div", asm: "F64Div", argLength: 2, reg: fp21, typ: "Float64"}, // arg0 / arg1
{name: "I64TruncSF64", asm: "I64TruncSF64", argLength: 1, reg: regInfo{inputs: []regMask{fp}, outputs: []regMask{gp}}, typ: "Int64"}, // truncates the float arg0 to a signed integer {name: "I64TruncF64S", asm: "I64TruncF64S", argLength: 1, reg: regInfo{inputs: []regMask{fp}, outputs: []regMask{gp}}, typ: "Int64"}, // truncates the float arg0 to a signed integer
{name: "I64TruncUF64", asm: "I64TruncUF64", argLength: 1, reg: regInfo{inputs: []regMask{fp}, outputs: []regMask{gp}}, typ: "Int64"}, // truncates the float arg0 to an unsigned integer {name: "I64TruncF64U", asm: "I64TruncF64U", argLength: 1, reg: regInfo{inputs: []regMask{fp}, outputs: []regMask{gp}}, typ: "Int64"}, // truncates the float arg0 to an unsigned integer
{name: "F64ConvertSI64", asm: "F64ConvertSI64", argLength: 1, reg: regInfo{inputs: []regMask{gp}, outputs: []regMask{fp}}, typ: "Float64"}, // converts the signed integer arg0 to a float {name: "F64ConvertI64S", asm: "F64ConvertI64S", argLength: 1, reg: regInfo{inputs: []regMask{gp}, outputs: []regMask{fp}}, typ: "Float64"}, // converts the signed integer arg0 to a float
{name: "F64ConvertUI64", asm: "F64ConvertUI64", argLength: 1, reg: regInfo{inputs: []regMask{gp}, outputs: []regMask{fp}}, typ: "Float64"}, // converts the unsigned integer arg0 to a float {name: "F64ConvertI64U", asm: "F64ConvertI64U", argLength: 1, reg: regInfo{inputs: []regMask{gp}, outputs: []regMask{fp}}, typ: "Float64"}, // converts the unsigned integer arg0 to a float
} }
archs = append(archs, arch{ archs = append(archs, arch{
......
...@@ -2075,10 +2075,10 @@ const ( ...@@ -2075,10 +2075,10 @@ const (
OpWasmF64Sub OpWasmF64Sub
OpWasmF64Mul OpWasmF64Mul
OpWasmF64Div OpWasmF64Div
OpWasmI64TruncSF64 OpWasmI64TruncF64S
OpWasmI64TruncUF64 OpWasmI64TruncF64U
OpWasmF64ConvertSI64 OpWasmF64ConvertI64S
OpWasmF64ConvertUI64 OpWasmF64ConvertI64U
OpAdd8 OpAdd8
OpAdd16 OpAdd16
...@@ -28000,9 +28000,9 @@ var opcodeTable = [...]opInfo{ ...@@ -28000,9 +28000,9 @@ var opcodeTable = [...]opInfo{
}, },
}, },
{ {
name: "I64TruncSF64", name: "I64TruncF64S",
argLen: 1, argLen: 1,
asm: wasm.AI64TruncSF64, asm: wasm.AI64TruncF64S,
reg: regInfo{ reg: regInfo{
inputs: []inputInfo{ inputs: []inputInfo{
{0, 4294901760}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 {0, 4294901760}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15
...@@ -28013,9 +28013,9 @@ var opcodeTable = [...]opInfo{ ...@@ -28013,9 +28013,9 @@ var opcodeTable = [...]opInfo{
}, },
}, },
{ {
name: "I64TruncUF64", name: "I64TruncF64U",
argLen: 1, argLen: 1,
asm: wasm.AI64TruncUF64, asm: wasm.AI64TruncF64U,
reg: regInfo{ reg: regInfo{
inputs: []inputInfo{ inputs: []inputInfo{
{0, 4294901760}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 {0, 4294901760}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15
...@@ -28026,9 +28026,9 @@ var opcodeTable = [...]opInfo{ ...@@ -28026,9 +28026,9 @@ var opcodeTable = [...]opInfo{
}, },
}, },
{ {
name: "F64ConvertSI64", name: "F64ConvertI64S",
argLen: 1, argLen: 1,
asm: wasm.AF64ConvertSI64, asm: wasm.AF64ConvertI64S,
reg: regInfo{ reg: regInfo{
inputs: []inputInfo{ inputs: []inputInfo{
{0, 65535}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 {0, 65535}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15
...@@ -28039,9 +28039,9 @@ var opcodeTable = [...]opInfo{ ...@@ -28039,9 +28039,9 @@ var opcodeTable = [...]opInfo{
}, },
}, },
{ {
name: "F64ConvertUI64", name: "F64ConvertI64U",
argLen: 1, argLen: 1,
asm: wasm.AF64ConvertUI64, asm: wasm.AF64ConvertI64U,
reg: regInfo{ reg: regInfo{
inputs: []inputInfo{ inputs: []inputInfo{
{0, 65535}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 {0, 65535}, // R0 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15
......
...@@ -913,10 +913,10 @@ func rewriteValueWasm_OpConvert_0(v *Value) bool { ...@@ -913,10 +913,10 @@ func rewriteValueWasm_OpConvert_0(v *Value) bool {
func rewriteValueWasm_OpCvt32Fto32_0(v *Value) bool { func rewriteValueWasm_OpCvt32Fto32_0(v *Value) bool {
// match: (Cvt32Fto32 x) // match: (Cvt32Fto32 x)
// cond: // cond:
// result: (I64TruncSF64 x) // result: (I64TruncF64S x)
for { for {
x := v.Args[0] x := v.Args[0]
v.reset(OpWasmI64TruncSF64) v.reset(OpWasmI64TruncF64S)
v.AddArg(x) v.AddArg(x)
return true return true
} }
...@@ -924,10 +924,10 @@ func rewriteValueWasm_OpCvt32Fto32_0(v *Value) bool { ...@@ -924,10 +924,10 @@ func rewriteValueWasm_OpCvt32Fto32_0(v *Value) bool {
func rewriteValueWasm_OpCvt32Fto32U_0(v *Value) bool { func rewriteValueWasm_OpCvt32Fto32U_0(v *Value) bool {
// match: (Cvt32Fto32U x) // match: (Cvt32Fto32U x)
// cond: // cond:
// result: (I64TruncUF64 x) // result: (I64TruncF64U x)
for { for {
x := v.Args[0] x := v.Args[0]
v.reset(OpWasmI64TruncUF64) v.reset(OpWasmI64TruncF64U)
v.AddArg(x) v.AddArg(x)
return true return true
} }
...@@ -935,10 +935,10 @@ func rewriteValueWasm_OpCvt32Fto32U_0(v *Value) bool { ...@@ -935,10 +935,10 @@ func rewriteValueWasm_OpCvt32Fto32U_0(v *Value) bool {
func rewriteValueWasm_OpCvt32Fto64_0(v *Value) bool { func rewriteValueWasm_OpCvt32Fto64_0(v *Value) bool {
// match: (Cvt32Fto64 x) // match: (Cvt32Fto64 x)
// cond: // cond:
// result: (I64TruncSF64 x) // result: (I64TruncF64S x)
for { for {
x := v.Args[0] x := v.Args[0]
v.reset(OpWasmI64TruncSF64) v.reset(OpWasmI64TruncF64S)
v.AddArg(x) v.AddArg(x)
return true return true
} }
...@@ -958,10 +958,10 @@ func rewriteValueWasm_OpCvt32Fto64F_0(v *Value) bool { ...@@ -958,10 +958,10 @@ func rewriteValueWasm_OpCvt32Fto64F_0(v *Value) bool {
func rewriteValueWasm_OpCvt32Fto64U_0(v *Value) bool { func rewriteValueWasm_OpCvt32Fto64U_0(v *Value) bool {
// match: (Cvt32Fto64U x) // match: (Cvt32Fto64U x)
// cond: // cond:
// result: (I64TruncUF64 x) // result: (I64TruncF64U x)
for { for {
x := v.Args[0] x := v.Args[0]
v.reset(OpWasmI64TruncUF64) v.reset(OpWasmI64TruncF64U)
v.AddArg(x) v.AddArg(x)
return true return true
} }
...@@ -973,11 +973,11 @@ func rewriteValueWasm_OpCvt32Uto32F_0(v *Value) bool { ...@@ -973,11 +973,11 @@ func rewriteValueWasm_OpCvt32Uto32F_0(v *Value) bool {
_ = typ _ = typ
// match: (Cvt32Uto32F x) // match: (Cvt32Uto32F x)
// cond: // cond:
// result: (LoweredRound32F (F64ConvertUI64 (ZeroExt32to64 x))) // result: (LoweredRound32F (F64ConvertI64U (ZeroExt32to64 x)))
for { for {
x := v.Args[0] x := v.Args[0]
v.reset(OpWasmLoweredRound32F) v.reset(OpWasmLoweredRound32F)
v0 := b.NewValue0(v.Pos, OpWasmF64ConvertUI64, typ.Float64) v0 := b.NewValue0(v.Pos, OpWasmF64ConvertI64U, typ.Float64)
v1 := b.NewValue0(v.Pos, OpZeroExt32to64, typ.UInt64) v1 := b.NewValue0(v.Pos, OpZeroExt32to64, typ.UInt64)
v1.AddArg(x) v1.AddArg(x)
v0.AddArg(v1) v0.AddArg(v1)
...@@ -992,10 +992,10 @@ func rewriteValueWasm_OpCvt32Uto64F_0(v *Value) bool { ...@@ -992,10 +992,10 @@ func rewriteValueWasm_OpCvt32Uto64F_0(v *Value) bool {
_ = typ _ = typ
// match: (Cvt32Uto64F x) // match: (Cvt32Uto64F x)
// cond: // cond:
// result: (F64ConvertUI64 (ZeroExt32to64 x)) // result: (F64ConvertI64U (ZeroExt32to64 x))
for { for {
x := v.Args[0] x := v.Args[0]
v.reset(OpWasmF64ConvertUI64) v.reset(OpWasmF64ConvertI64U)
v0 := b.NewValue0(v.Pos, OpZeroExt32to64, typ.UInt64) v0 := b.NewValue0(v.Pos, OpZeroExt32to64, typ.UInt64)
v0.AddArg(x) v0.AddArg(x)
v.AddArg(v0) v.AddArg(v0)
...@@ -1009,11 +1009,11 @@ func rewriteValueWasm_OpCvt32to32F_0(v *Value) bool { ...@@ -1009,11 +1009,11 @@ func rewriteValueWasm_OpCvt32to32F_0(v *Value) bool {
_ = typ _ = typ
// match: (Cvt32to32F x) // match: (Cvt32to32F x)
// cond: // cond:
// result: (LoweredRound32F (F64ConvertSI64 (SignExt32to64 x))) // result: (LoweredRound32F (F64ConvertI64S (SignExt32to64 x)))
for { for {
x := v.Args[0] x := v.Args[0]
v.reset(OpWasmLoweredRound32F) v.reset(OpWasmLoweredRound32F)
v0 := b.NewValue0(v.Pos, OpWasmF64ConvertSI64, typ.Float64) v0 := b.NewValue0(v.Pos, OpWasmF64ConvertI64S, typ.Float64)
v1 := b.NewValue0(v.Pos, OpSignExt32to64, typ.Int64) v1 := b.NewValue0(v.Pos, OpSignExt32to64, typ.Int64)
v1.AddArg(x) v1.AddArg(x)
v0.AddArg(v1) v0.AddArg(v1)
...@@ -1028,10 +1028,10 @@ func rewriteValueWasm_OpCvt32to64F_0(v *Value) bool { ...@@ -1028,10 +1028,10 @@ func rewriteValueWasm_OpCvt32to64F_0(v *Value) bool {
_ = typ _ = typ
// match: (Cvt32to64F x) // match: (Cvt32to64F x)
// cond: // cond:
// result: (F64ConvertSI64 (SignExt32to64 x)) // result: (F64ConvertI64S (SignExt32to64 x))
for { for {
x := v.Args[0] x := v.Args[0]
v.reset(OpWasmF64ConvertSI64) v.reset(OpWasmF64ConvertI64S)
v0 := b.NewValue0(v.Pos, OpSignExt32to64, typ.Int64) v0 := b.NewValue0(v.Pos, OpSignExt32to64, typ.Int64)
v0.AddArg(x) v0.AddArg(x)
v.AddArg(v0) v.AddArg(v0)
...@@ -1041,10 +1041,10 @@ func rewriteValueWasm_OpCvt32to64F_0(v *Value) bool { ...@@ -1041,10 +1041,10 @@ func rewriteValueWasm_OpCvt32to64F_0(v *Value) bool {
func rewriteValueWasm_OpCvt64Fto32_0(v *Value) bool { func rewriteValueWasm_OpCvt64Fto32_0(v *Value) bool {
// match: (Cvt64Fto32 x) // match: (Cvt64Fto32 x)
// cond: // cond:
// result: (I64TruncSF64 x) // result: (I64TruncF64S x)
for { for {
x := v.Args[0] x := v.Args[0]
v.reset(OpWasmI64TruncSF64) v.reset(OpWasmI64TruncF64S)
v.AddArg(x) v.AddArg(x)
return true return true
} }
...@@ -1063,10 +1063,10 @@ func rewriteValueWasm_OpCvt64Fto32F_0(v *Value) bool { ...@@ -1063,10 +1063,10 @@ func rewriteValueWasm_OpCvt64Fto32F_0(v *Value) bool {
func rewriteValueWasm_OpCvt64Fto32U_0(v *Value) bool { func rewriteValueWasm_OpCvt64Fto32U_0(v *Value) bool {
// match: (Cvt64Fto32U x) // match: (Cvt64Fto32U x)
// cond: // cond:
// result: (I64TruncUF64 x) // result: (I64TruncF64U x)
for { for {
x := v.Args[0] x := v.Args[0]
v.reset(OpWasmI64TruncUF64) v.reset(OpWasmI64TruncF64U)
v.AddArg(x) v.AddArg(x)
return true return true
} }
...@@ -1074,10 +1074,10 @@ func rewriteValueWasm_OpCvt64Fto32U_0(v *Value) bool { ...@@ -1074,10 +1074,10 @@ func rewriteValueWasm_OpCvt64Fto32U_0(v *Value) bool {
func rewriteValueWasm_OpCvt64Fto64_0(v *Value) bool { func rewriteValueWasm_OpCvt64Fto64_0(v *Value) bool {
// match: (Cvt64Fto64 x) // match: (Cvt64Fto64 x)
// cond: // cond:
// result: (I64TruncSF64 x) // result: (I64TruncF64S x)
for { for {
x := v.Args[0] x := v.Args[0]
v.reset(OpWasmI64TruncSF64) v.reset(OpWasmI64TruncF64S)
v.AddArg(x) v.AddArg(x)
return true return true
} }
...@@ -1085,10 +1085,10 @@ func rewriteValueWasm_OpCvt64Fto64_0(v *Value) bool { ...@@ -1085,10 +1085,10 @@ func rewriteValueWasm_OpCvt64Fto64_0(v *Value) bool {
func rewriteValueWasm_OpCvt64Fto64U_0(v *Value) bool { func rewriteValueWasm_OpCvt64Fto64U_0(v *Value) bool {
// match: (Cvt64Fto64U x) // match: (Cvt64Fto64U x)
// cond: // cond:
// result: (I64TruncUF64 x) // result: (I64TruncF64U x)
for { for {
x := v.Args[0] x := v.Args[0]
v.reset(OpWasmI64TruncUF64) v.reset(OpWasmI64TruncF64U)
v.AddArg(x) v.AddArg(x)
return true return true
} }
...@@ -1100,11 +1100,11 @@ func rewriteValueWasm_OpCvt64Uto32F_0(v *Value) bool { ...@@ -1100,11 +1100,11 @@ func rewriteValueWasm_OpCvt64Uto32F_0(v *Value) bool {
_ = typ _ = typ
// match: (Cvt64Uto32F x) // match: (Cvt64Uto32F x)
// cond: // cond:
// result: (LoweredRound32F (F64ConvertUI64 x)) // result: (LoweredRound32F (F64ConvertI64U x))
for { for {
x := v.Args[0] x := v.Args[0]
v.reset(OpWasmLoweredRound32F) v.reset(OpWasmLoweredRound32F)
v0 := b.NewValue0(v.Pos, OpWasmF64ConvertUI64, typ.Float64) v0 := b.NewValue0(v.Pos, OpWasmF64ConvertI64U, typ.Float64)
v0.AddArg(x) v0.AddArg(x)
v.AddArg(v0) v.AddArg(v0)
return true return true
...@@ -1113,10 +1113,10 @@ func rewriteValueWasm_OpCvt64Uto32F_0(v *Value) bool { ...@@ -1113,10 +1113,10 @@ func rewriteValueWasm_OpCvt64Uto32F_0(v *Value) bool {
func rewriteValueWasm_OpCvt64Uto64F_0(v *Value) bool { func rewriteValueWasm_OpCvt64Uto64F_0(v *Value) bool {
// match: (Cvt64Uto64F x) // match: (Cvt64Uto64F x)
// cond: // cond:
// result: (F64ConvertUI64 x) // result: (F64ConvertI64U x)
for { for {
x := v.Args[0] x := v.Args[0]
v.reset(OpWasmF64ConvertUI64) v.reset(OpWasmF64ConvertI64U)
v.AddArg(x) v.AddArg(x)
return true return true
} }
...@@ -1128,11 +1128,11 @@ func rewriteValueWasm_OpCvt64to32F_0(v *Value) bool { ...@@ -1128,11 +1128,11 @@ func rewriteValueWasm_OpCvt64to32F_0(v *Value) bool {
_ = typ _ = typ
// match: (Cvt64to32F x) // match: (Cvt64to32F x)
// cond: // cond:
// result: (LoweredRound32F (F64ConvertSI64 x)) // result: (LoweredRound32F (F64ConvertI64S x))
for { for {
x := v.Args[0] x := v.Args[0]
v.reset(OpWasmLoweredRound32F) v.reset(OpWasmLoweredRound32F)
v0 := b.NewValue0(v.Pos, OpWasmF64ConvertSI64, typ.Float64) v0 := b.NewValue0(v.Pos, OpWasmF64ConvertI64S, typ.Float64)
v0.AddArg(x) v0.AddArg(x)
v.AddArg(v0) v.AddArg(v0)
return true return true
...@@ -1141,10 +1141,10 @@ func rewriteValueWasm_OpCvt64to32F_0(v *Value) bool { ...@@ -1141,10 +1141,10 @@ func rewriteValueWasm_OpCvt64to32F_0(v *Value) bool {
func rewriteValueWasm_OpCvt64to64F_0(v *Value) bool { func rewriteValueWasm_OpCvt64to64F_0(v *Value) bool {
// match: (Cvt64to64F x) // match: (Cvt64to64F x)
// cond: // cond:
// result: (F64ConvertSI64 x) // result: (F64ConvertI64S x)
for { for {
x := v.Args[0] x := v.Args[0]
v.reset(OpWasmF64ConvertSI64) v.reset(OpWasmF64ConvertI64S)
v.AddArg(x) v.AddArg(x)
return true return true
} }
......
...@@ -283,13 +283,13 @@ func ssaGenValueOnStack(s *gc.SSAGenState, v *ssa.Value) { ...@@ -283,13 +283,13 @@ func ssaGenValueOnStack(s *gc.SSAGenState, v *ssa.Value) {
case ssa.OpWasmI64Eqz: case ssa.OpWasmI64Eqz:
getValue64(s, v.Args[0]) getValue64(s, v.Args[0])
s.Prog(v.Op.Asm()) s.Prog(v.Op.Asm())
s.Prog(wasm.AI64ExtendUI32) s.Prog(wasm.AI64ExtendI32U)
case ssa.OpWasmI64Eq, ssa.OpWasmI64Ne, ssa.OpWasmI64LtS, ssa.OpWasmI64LtU, ssa.OpWasmI64GtS, ssa.OpWasmI64GtU, ssa.OpWasmI64LeS, ssa.OpWasmI64LeU, ssa.OpWasmI64GeS, ssa.OpWasmI64GeU, ssa.OpWasmF64Eq, ssa.OpWasmF64Ne, ssa.OpWasmF64Lt, ssa.OpWasmF64Gt, ssa.OpWasmF64Le, ssa.OpWasmF64Ge: case ssa.OpWasmI64Eq, ssa.OpWasmI64Ne, ssa.OpWasmI64LtS, ssa.OpWasmI64LtU, ssa.OpWasmI64GtS, ssa.OpWasmI64GtU, ssa.OpWasmI64LeS, ssa.OpWasmI64LeU, ssa.OpWasmI64GeS, ssa.OpWasmI64GeU, ssa.OpWasmF64Eq, ssa.OpWasmF64Ne, ssa.OpWasmF64Lt, ssa.OpWasmF64Gt, ssa.OpWasmF64Le, ssa.OpWasmF64Ge:
getValue64(s, v.Args[0]) getValue64(s, v.Args[0])
getValue64(s, v.Args[1]) getValue64(s, v.Args[1])
s.Prog(v.Op.Asm()) s.Prog(v.Op.Asm())
s.Prog(wasm.AI64ExtendUI32) s.Prog(wasm.AI64ExtendI32U)
case ssa.OpWasmI64Add, ssa.OpWasmI64Sub, ssa.OpWasmI64Mul, ssa.OpWasmI64DivU, ssa.OpWasmI64RemS, ssa.OpWasmI64RemU, ssa.OpWasmI64And, ssa.OpWasmI64Or, ssa.OpWasmI64Xor, ssa.OpWasmI64Shl, ssa.OpWasmI64ShrS, ssa.OpWasmI64ShrU, ssa.OpWasmF64Add, ssa.OpWasmF64Sub, ssa.OpWasmF64Mul, ssa.OpWasmF64Div: case ssa.OpWasmI64Add, ssa.OpWasmI64Sub, ssa.OpWasmI64Mul, ssa.OpWasmI64DivU, ssa.OpWasmI64RemS, ssa.OpWasmI64RemU, ssa.OpWasmI64And, ssa.OpWasmI64Or, ssa.OpWasmI64Xor, ssa.OpWasmI64Shl, ssa.OpWasmI64ShrS, ssa.OpWasmI64ShrU, ssa.OpWasmF64Add, ssa.OpWasmF64Sub, ssa.OpWasmF64Mul, ssa.OpWasmF64Div:
getValue64(s, v.Args[0]) getValue64(s, v.Args[0])
...@@ -307,17 +307,17 @@ func ssaGenValueOnStack(s *gc.SSAGenState, v *ssa.Value) { ...@@ -307,17 +307,17 @@ func ssaGenValueOnStack(s *gc.SSAGenState, v *ssa.Value) {
} }
s.Prog(wasm.AI64DivS) s.Prog(wasm.AI64DivS)
case ssa.OpWasmI64TruncSF64: case ssa.OpWasmI64TruncF64S:
getValue64(s, v.Args[0]) getValue64(s, v.Args[0])
p := s.Prog(wasm.ACall) p := s.Prog(wasm.ACall)
p.To = obj.Addr{Type: obj.TYPE_MEM, Name: obj.NAME_EXTERN, Sym: gc.WasmTruncS} p.To = obj.Addr{Type: obj.TYPE_MEM, Name: obj.NAME_EXTERN, Sym: gc.WasmTruncS}
case ssa.OpWasmI64TruncUF64: case ssa.OpWasmI64TruncF64U:
getValue64(s, v.Args[0]) getValue64(s, v.Args[0])
p := s.Prog(wasm.ACall) p := s.Prog(wasm.ACall)
p.To = obj.Addr{Type: obj.TYPE_MEM, Name: obj.NAME_EXTERN, Sym: gc.WasmTruncU} p.To = obj.Addr{Type: obj.TYPE_MEM, Name: obj.NAME_EXTERN, Sym: gc.WasmTruncU}
case ssa.OpWasmF64Neg, ssa.OpWasmF64ConvertSI64, ssa.OpWasmF64ConvertUI64: case ssa.OpWasmF64Neg, ssa.OpWasmF64ConvertI64S, ssa.OpWasmF64ConvertI64U:
getValue64(s, v.Args[0]) getValue64(s, v.Args[0])
s.Prog(v.Op.Asm()) s.Prog(v.Op.Asm())
...@@ -362,7 +362,7 @@ func getValue64(s *gc.SSAGenState, v *ssa.Value) { ...@@ -362,7 +362,7 @@ func getValue64(s *gc.SSAGenState, v *ssa.Value) {
reg := v.Reg() reg := v.Reg()
getReg(s, reg) getReg(s, reg)
if reg == wasm.REG_SP { if reg == wasm.REG_SP {
s.Prog(wasm.AI64ExtendUI32) s.Prog(wasm.AI64ExtendI32U)
} }
} }
......
...@@ -186,25 +186,25 @@ const ( ...@@ -186,25 +186,25 @@ const (
AF64Copysign AF64Copysign
AI32WrapI64 AI32WrapI64
AI32TruncSF32 AI32TruncF32S
AI32TruncUF32 AI32TruncF32U
AI32TruncSF64 AI32TruncF64S
AI32TruncUF64 AI32TruncF64U
AI64ExtendSI32 AI64ExtendI32S
AI64ExtendUI32 AI64ExtendI32U
AI64TruncSF32 AI64TruncF32S
AI64TruncUF32 AI64TruncF32U
AI64TruncSF64 AI64TruncF64S
AI64TruncUF64 AI64TruncF64U
AF32ConvertSI32 AF32ConvertI32S
AF32ConvertUI32 AF32ConvertI32U
AF32ConvertSI64 AF32ConvertI64S
AF32ConvertUI64 AF32ConvertI64U
AF32DemoteF64 AF32DemoteF64
AF64ConvertSI32 AF64ConvertI32S
AF64ConvertUI32 AF64ConvertI32U
AF64ConvertSI64 AF64ConvertI64S
AF64ConvertUI64 AF64ConvertI64U
AF64PromoteF32 AF64PromoteF32
AI32ReinterpretF32 AI32ReinterpretF32
AI64ReinterpretF64 AI64ReinterpretF64
......
...@@ -153,25 +153,25 @@ var Anames = []string{ ...@@ -153,25 +153,25 @@ var Anames = []string{
"F64Max", "F64Max",
"F64Copysign", "F64Copysign",
"I32WrapI64", "I32WrapI64",
"I32TruncSF32", "I32TruncF32S",
"I32TruncUF32", "I32TruncF32U",
"I32TruncSF64", "I32TruncF64S",
"I32TruncUF64", "I32TruncF64U",
"I64ExtendSI32", "I64ExtendI32S",
"I64ExtendUI32", "I64ExtendI32U",
"I64TruncSF32", "I64TruncF32S",
"I64TruncUF32", "I64TruncF32U",
"I64TruncSF64", "I64TruncF64S",
"I64TruncUF64", "I64TruncF64U",
"F32ConvertSI32", "F32ConvertI32S",
"F32ConvertUI32", "F32ConvertI32U",
"F32ConvertSI64", "F32ConvertI64S",
"F32ConvertUI64", "F32ConvertI64U",
"F32DemoteF64", "F32DemoteF64",
"F64ConvertSI32", "F64ConvertI32S",
"F64ConvertUI32", "F64ConvertI32U",
"F64ConvertSI64", "F64ConvertI64S",
"F64ConvertUI64", "F64ConvertI64U",
"F64PromoteF32", "F64PromoteF32",
"I32ReinterpretF32", "I32ReinterpretF32",
"I64ReinterpretF64", "I64ReinterpretF64",
......
...@@ -181,7 +181,7 @@ func preprocess(ctxt *obj.Link, s *obj.LSym, newprog obj.ProgAlloc) { ...@@ -181,7 +181,7 @@ func preprocess(ctxt *obj.Link, s *obj.LSym, newprog obj.ProgAlloc) {
// Not // Not
// If // If
// Get SP // Get SP
// I64ExtendUI32 // I64ExtendI32U
// I64Const $framesize+8 // I64Const $framesize+8
// I64Add // I64Add
// I64Load panic_argp(R0) // I64Load panic_argp(R0)
...@@ -212,7 +212,7 @@ func preprocess(ctxt *obj.Link, s *obj.LSym, newprog obj.ProgAlloc) { ...@@ -212,7 +212,7 @@ func preprocess(ctxt *obj.Link, s *obj.LSym, newprog obj.ProgAlloc) {
p = appendp(p, AIf) p = appendp(p, AIf)
p = appendp(p, AGet, regAddr(REG_SP)) p = appendp(p, AGet, regAddr(REG_SP))
p = appendp(p, AI64ExtendUI32) p = appendp(p, AI64ExtendI32U)
p = appendp(p, AI64Const, constAddr(framesize+8)) p = appendp(p, AI64Const, constAddr(framesize+8))
p = appendp(p, AI64Add) p = appendp(p, AI64Add)
p = appendp(p, AI64Load, panicargp) p = appendp(p, AI64Load, panicargp)
...@@ -584,7 +584,7 @@ func preprocess(ctxt *obj.Link, s *obj.LSym, newprog obj.ProgAlloc) { ...@@ -584,7 +584,7 @@ func preprocess(ctxt *obj.Link, s *obj.LSym, newprog obj.ProgAlloc) {
case obj.NAME_AUTO, obj.NAME_PARAM: case obj.NAME_AUTO, obj.NAME_PARAM:
p = appendp(p, AGet, regAddr(get.From.Reg)) p = appendp(p, AGet, regAddr(get.From.Reg))
if get.From.Reg == REG_SP { if get.From.Reg == REG_SP {
p = appendp(p, AI64ExtendUI32) p = appendp(p, AI64ExtendI32U)
} }
if get.From.Offset != 0 { if get.From.Offset != 0 {
p = appendp(p, AI64Const, constAddr(get.From.Offset)) p = appendp(p, AI64Const, constAddr(get.From.Offset))
...@@ -641,7 +641,7 @@ func preprocess(ctxt *obj.Link, s *obj.LSym, newprog obj.ProgAlloc) { ...@@ -641,7 +641,7 @@ func preprocess(ctxt *obj.Link, s *obj.LSym, newprog obj.ProgAlloc) {
case obj.NAME_NONE, obj.NAME_PARAM, obj.NAME_AUTO: case obj.NAME_NONE, obj.NAME_PARAM, obj.NAME_AUTO:
p = appendp(p, AGet, regAddr(mov.From.Reg)) p = appendp(p, AGet, regAddr(mov.From.Reg))
if mov.From.Reg == REG_SP { if mov.From.Reg == REG_SP {
p = appendp(p, AI64ExtendUI32) p = appendp(p, AI64ExtendI32U)
} }
p = appendp(p, AI64Const, constAddr(mov.From.Offset)) p = appendp(p, AI64Const, constAddr(mov.From.Offset))
p = appendp(p, AI64Add) p = appendp(p, AI64Add)
...@@ -654,7 +654,7 @@ func preprocess(ctxt *obj.Link, s *obj.LSym, newprog obj.ProgAlloc) { ...@@ -654,7 +654,7 @@ func preprocess(ctxt *obj.Link, s *obj.LSym, newprog obj.ProgAlloc) {
case obj.TYPE_REG: case obj.TYPE_REG:
p = appendp(p, AGet, mov.From) p = appendp(p, AGet, mov.From)
if mov.From.Reg == REG_SP { if mov.From.Reg == REG_SP {
p = appendp(p, AI64ExtendUI32) p = appendp(p, AI64ExtendI32U)
} }
case obj.TYPE_MEM: case obj.TYPE_MEM:
...@@ -788,13 +788,13 @@ func assemble(ctxt *obj.Link, s *obj.LSym, newprog obj.ProgAlloc) { ...@@ -788,13 +788,13 @@ func assemble(ctxt *obj.Link, s *obj.LSym, newprog obj.ProgAlloc) {
reg := p.From.Reg reg := p.From.Reg
switch { switch {
case reg >= REG_PC_F && reg <= REG_PAUSE: case reg >= REG_PC_F && reg <= REG_PAUSE:
w.WriteByte(0x23) // get_global w.WriteByte(0x23) // global.get
writeUleb128(w, uint64(reg-REG_PC_F)) writeUleb128(w, uint64(reg-REG_PC_F))
case reg >= REG_R0 && reg <= REG_R15: case reg >= REG_R0 && reg <= REG_R15:
w.WriteByte(0x20) // get_local (i64) w.WriteByte(0x20) // local.get (i64)
writeUleb128(w, uint64(reg-REG_R0)) writeUleb128(w, uint64(reg-REG_R0))
case reg >= REG_F0 && reg <= REG_F15: case reg >= REG_F0 && reg <= REG_F15:
w.WriteByte(0x20) // get_local (f64) w.WriteByte(0x20) // local.get (f64)
writeUleb128(w, uint64(numI+(reg-REG_F0))) writeUleb128(w, uint64(numI+(reg-REG_F0)))
default: default:
panic("bad Get: invalid register") panic("bad Get: invalid register")
...@@ -808,14 +808,14 @@ func assemble(ctxt *obj.Link, s *obj.LSym, newprog obj.ProgAlloc) { ...@@ -808,14 +808,14 @@ func assemble(ctxt *obj.Link, s *obj.LSym, newprog obj.ProgAlloc) {
reg := p.To.Reg reg := p.To.Reg
switch { switch {
case reg >= REG_PC_F && reg <= REG_PAUSE: case reg >= REG_PC_F && reg <= REG_PAUSE:
w.WriteByte(0x24) // set_global w.WriteByte(0x24) // global.set
writeUleb128(w, uint64(reg-REG_PC_F)) writeUleb128(w, uint64(reg-REG_PC_F))
case reg >= REG_R0 && reg <= REG_F15: case reg >= REG_R0 && reg <= REG_F15:
if p.Link.As == AGet && p.Link.From.Reg == reg { if p.Link.As == AGet && p.Link.From.Reg == reg {
w.WriteByte(0x22) // tee_local w.WriteByte(0x22) // local.tee
p = p.Link p = p.Link
} else { } else {
w.WriteByte(0x21) // set_local w.WriteByte(0x21) // local.set
} }
if reg <= REG_R15 { if reg <= REG_R15 {
writeUleb128(w, uint64(reg-REG_R0)) writeUleb128(w, uint64(reg-REG_R0))
...@@ -834,10 +834,10 @@ func assemble(ctxt *obj.Link, s *obj.LSym, newprog obj.ProgAlloc) { ...@@ -834,10 +834,10 @@ func assemble(ctxt *obj.Link, s *obj.LSym, newprog obj.ProgAlloc) {
reg := p.To.Reg reg := p.To.Reg
switch { switch {
case reg >= REG_R0 && reg <= REG_R15: case reg >= REG_R0 && reg <= REG_R15:
w.WriteByte(0x22) // tee_local (i64) w.WriteByte(0x22) // local.tee (i64)
writeUleb128(w, uint64(reg-REG_R0)) writeUleb128(w, uint64(reg-REG_R0))
case reg >= REG_F0 && reg <= REG_F15: case reg >= REG_F0 && reg <= REG_F15:
w.WriteByte(0x22) // tee_local (f64) w.WriteByte(0x22) // local.tee (f64)
writeUleb128(w, uint64(numI+(reg-REG_F0))) writeUleb128(w, uint64(numI+(reg-REG_F0)))
default: default:
panic("bad Tee: invalid register") panic("bad Tee: invalid register")
......
...@@ -44,7 +44,7 @@ TEXT cmpbody<>(SB), NOSPLIT, $0-0 ...@@ -44,7 +44,7 @@ TEXT cmpbody<>(SB), NOSPLIT, $0-0
Get R4 Get R4
I32WrapI64 I32WrapI64
Call memcmp<>(SB) Call memcmp<>(SB)
I64ExtendSI32 I64ExtendI32S
Set R5 Set R5
Get R5 Get R5
......
...@@ -12,7 +12,7 @@ TEXT ·IndexByte(SB), NOSPLIT, $0-40 ...@@ -12,7 +12,7 @@ TEXT ·IndexByte(SB), NOSPLIT, $0-40
I64Load b_len+8(FP) I64Load b_len+8(FP)
I32WrapI64 I32WrapI64
Call memchr<>(SB) Call memchr<>(SB)
I64ExtendSI32 I64ExtendI32S
Set R0 Set R0
Get SP Get SP
...@@ -35,7 +35,7 @@ TEXT ·IndexByteString(SB), NOSPLIT, $0-32 ...@@ -35,7 +35,7 @@ TEXT ·IndexByteString(SB), NOSPLIT, $0-32
I64Load s_len+8(FP) I64Load s_len+8(FP)
I32WrapI64 I32WrapI64
Call memchr<>(SB) Call memchr<>(SB)
I64ExtendSI32 I64ExtendI32S
Set R0 Set R0
I64Const $-1 I64Const $-1
......
...@@ -16,7 +16,7 @@ TEXT ·makeFuncStub(SB),(NOSPLIT|WRAPPER),$32 ...@@ -16,7 +16,7 @@ TEXT ·makeFuncStub(SB),(NOSPLIT|WRAPPER),$32
Get SP Get SP
Get SP Get SP
I64ExtendUI32 I64ExtendI32U
I64Const $argframe+0(FP) I64Const $argframe+0(FP)
I64Add I64Add
I64Store $8 I64Store $8
...@@ -38,7 +38,7 @@ TEXT ·methodValueCall(SB),(NOSPLIT|WRAPPER),$32 ...@@ -38,7 +38,7 @@ TEXT ·methodValueCall(SB),(NOSPLIT|WRAPPER),$32
Get SP Get SP
Get SP Get SP
I64ExtendUI32 I64ExtendI32U
I64Const $argframe+0(FP) I64Const $argframe+0(FP)
I64Add I64Add
I64Store $8 I64Store $8
......
...@@ -366,7 +366,7 @@ TEXT NAME(SB), WRAPPER, $MAXSIZE-32; \ ...@@ -366,7 +366,7 @@ TEXT NAME(SB), WRAPPER, $MAXSIZE-32; \
Set RET1; \ Set RET1; \
\ \
Get SP; \ Get SP; \
I64ExtendUI32; \ I64ExtendI32U; \
Get R0; \ Get R0; \
I64Add; \ I64Add; \
Set RET2; \ Set RET2; \
......
...@@ -23,12 +23,12 @@ TEXT wasm_export_run(SB),NOSPLIT,$0 ...@@ -23,12 +23,12 @@ TEXT wasm_export_run(SB),NOSPLIT,$0
Get SP Get SP
Get R0 // argc Get R0 // argc
I64ExtendUI32 I64ExtendI32U
I64Store $0 I64Store $0
Get SP Get SP
Get R1 // argv Get R1 // argv
I64ExtendUI32 I64ExtendI32U
I64Store $8 I64Store $8
I32Const $runtime·rt0_go(SB) I32Const $runtime·rt0_go(SB)
......
...@@ -117,7 +117,7 @@ TEXT runtime·wasmTruncS(SB), NOSPLIT, $0-0 ...@@ -117,7 +117,7 @@ TEXT runtime·wasmTruncS(SB), NOSPLIT, $0-0
End End
Get R0 Get R0
I64TruncSF64 I64TruncF64S
Return Return
TEXT runtime·wasmTruncU(SB), NOSPLIT, $0-0 TEXT runtime·wasmTruncU(SB), NOSPLIT, $0-0
...@@ -146,7 +146,7 @@ TEXT runtime·wasmTruncU(SB), NOSPLIT, $0-0 ...@@ -146,7 +146,7 @@ TEXT runtime·wasmTruncU(SB), NOSPLIT, $0-0
End End
Get R0 Get R0
I64TruncUF64 I64TruncF64U
Return Return
TEXT runtime·exitThread(SB), NOSPLIT, $0-0 TEXT runtime·exitThread(SB), NOSPLIT, $0-0
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment