[WASM] Renew to Milestone 6 instructions set

This commit is contained in:
Igor Yakovlev
2022-08-18 14:55:26 +02:00
committed by teamcity
parent 780fdd44b3
commit c94a051c19
11 changed files with 22 additions and 45 deletions
@@ -360,26 +360,25 @@ enum class WasmOp(
I31_GET_S("i31.get_s", 0xFB_21),
I31_GET_U("i31.get_u", 0xFB_22),
REF_TEST_STATIC("ref.test_static", 0xFB_44, STRUCT_TYPE_IDX),
REF_CAST_STATIC("ref.cast_static", 0xFB_45, STRUCT_TYPE_IDX),
REF_TEST("ref.test", 0xFB_44, STRUCT_TYPE_IDX),
REF_CAST("ref.cast", 0xFB_45, STRUCT_TYPE_IDX),
BR_ON_CAST_STATIC_FAIL("br_on_cast_static_fail", 0xfb47, listOf(LABEL_IDX, STRUCT_TYPE_IDX)),
BR_ON_CAST_FAIL("br_on_cast_fail", 0xfb47, listOf(LABEL_IDX, STRUCT_TYPE_IDX)),
REF_IS_FUNC("ref.is_func", 0xfb50),
REF_IS_DATA("ref.is_data", 0xfb51),
REF_IS_I31("ref.is_i31", 0xfb52),
REF_AS_FUNC("ref.as_func", 0xfb58),
REF_AS_DATA("ref.as_data", 0xfb59),
REF_AS_I31("ref.as_i31", 0xfb5a),
BR_ON_FUNC("br_on_func", 0xfb60, listOf(LABEL_IDX)),
BR_ON_DATA("br_on_data", 0xfb61, listOf(LABEL_IDX)),
BR_ON_I31("br_on_i31", 0xfb62, listOf(LABEL_IDX)),
BR_ON_NON_FUNC("br_on_non_func", 0xfb63, listOf(LABEL_IDX)),
BR_ON_NON_DATA("br_on_non_data", 0xfb64, listOf(LABEL_IDX)),
BR_ON_NON_I31("br_on_non_i31", 0xfb65, listOf(LABEL_IDX)),
EXTERN_INTERNALIZE("extern.internalize", 0xfb70), // externref -> anyref
EXTERN_EXTERNALIZE("extern.externalize", 0xfb71), // anyref -> externref
// Pseudo-instruction, just alias for a normal call. It's used to easily spot get_unit on the wasm level.
GET_UNIT("call", 0x10, FUNC_IDX)
;
@@ -31,7 +31,6 @@ data class WasmRefType(val heapType: WasmHeapType) : WasmType("ref", -0x15)
@Suppress("unused")
object WasmI31Ref : WasmType("i31ref", -0x16)
data class WasmRtt(val type: WasmSymbolReadOnly<WasmTypeDeclaration>) : WasmType("rtt", -0x18)
@Suppress("unused")
object WasmDataRef : WasmType("dataref", -0x19)
@@ -49,9 +48,6 @@ sealed class WasmHeapType {
object Any : Simple("any", -0x12)
object Eq : Simple("eq", -0x13)
@Suppress("unused")
object ExnH : Simple("exn", -0x18)
object Data : Simple("data", -0x19)
override fun toString(): String {
@@ -157,11 +157,11 @@ abstract class WasmExpressionBuilder {
}
fun buildRefCastStatic(toType: WasmSymbolReadOnly<WasmTypeDeclaration>) {
buildInstr(WasmOp.REF_CAST_STATIC, WasmImmediate.TypeIdx(toType))
buildInstr(WasmOp.REF_CAST, WasmImmediate.TypeIdx(toType))
}
fun buildRefTestStatic(toType: WasmSymbolReadOnly<WasmTypeDeclaration>) {
buildInstr(WasmOp.REF_TEST_STATIC, WasmImmediate.TypeIdx(toType))
buildInstr(WasmOp.REF_TEST, WasmImmediate.TypeIdx(toType))
}
fun buildRefNull(type: WasmHeapType) {
@@ -491,9 +491,6 @@ class WasmIrToBinary(outputStream: OutputStream, val module: WasmModule, val mod
if (type is WasmRefNullType) {
appendHeapType(type.heapType)
}
if (type is WasmRtt) {
appendModuleFieldReference(type.type.owner)
}
}
fun appendLocalReference(local: WasmLocal) {
@@ -470,11 +470,6 @@ class WasmIrToText : SExpressionBuilder() {
appendHeapType(type.heapType)
}
is WasmRtt ->
sameLineList("rtt") {
appendModuleFieldReference(type.type.owner)
}
WasmUnreachableType -> {
}