Skip to content

wasm-as: select operator arguments emitted in reverse order. #131

@ghost

Description

Example:

(module
  (memory 0 0)
  (func $f1 (param $i1 i32) (result i32)
    (i32.select
     (i32.lt_s
      (get_local $i1)
      (i32.const 0)
      )
     (i32.sub
      (i32.const 0)
      (get_local $i1)
      )
     (get_local $i1)
     )
    (i32.const 0))
  )

sexp-wasm emits the select operator arguments in the wast order.

0000010: 05                                         ; OPCODE_SELECT
0000011: 4f                                         ; OPCODE_I32_LT_S
0000012: 0e                                         ; OPCODE_GET_LOCAL
0000013: 00                                         ; remapped local index
0000014: 09                                         ; OPCODE_I8_CONST
0000015: 00                                         ; u8 literal
0000016: 41                                         ; OPCODE_I32_SUB
0000017: 09                                         ; OPCODE_I8_CONST
0000018: 00                                         ; u8 literal
0000019: 0e                                         ; OPCODE_GET_LOCAL
000001a: 00                                         ; remapped local index
000001b: 0e                                         ; OPCODE_GET_LOCAL
000001c: 00                                         ; remapped local index
000001d: 09                                         ; OPCODE_I8_CONST
000001e: 00                                         ; u8 literal

Interestingly wasm-as emits them in the opposite order, that is the i32.sub first then the i32.lt_s.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions