1# RUN: llvm-mc -triple=wasm32-unknown-unknown -mattr=+simd128,+nontrapping-fptoint,+exception-handling < %s | FileCheck %s 2# this one is just here to see if it converts to .o without errors, but doesn't check any output: 3# RUN: llvm-mc -triple=wasm32-unknown-unknown -filetype=obj -mattr=+simd128,+nontrapping-fptoint,+exception-handling < %s 4 5 .text 6 .section .text.main,"",@ 7 .type test0,@function 8test0: 9 # Test all types: 10 .functype test0 (i32, i64) -> (i32) 11 .local f32, f64, v128, v128 12 # Explicit getlocal/setlocal: 13 get_local 2 14 set_local 2 15 # Immediates: 16 i32.const -1 17 f64.const 0x1.999999999999ap1 18 v128.const 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 19 v128.const 0, 1, 2, 3, 4, 5, 6, 7 20 # Indirect addressing: 21 get_local 0 22 f64.store 0 23 # Loops, conditionals, binary ops, calls etc: 24 block 25 i32.const 1 26 get_local 0 27 i32.ge_s 28 br_if 0 # 0: down to label0 29.LBB0_1: 30 loop # label1: 31 call something1@FUNCTION 32 i64.const 1234 33 i32.call something2@FUNCTION 34 i32.const 0 35 call_indirect 0 36 i32.const 1 37 i32.add 38 tee_local 0 39 get_local 0 40 i32.lt_s 41 br_if 0 # 0: up to label1 42.LBB0_2: 43 end_loop 44 end_block # label0: 45 get_local 4 46 get_local 5 47 f32x4.add 48 # Test correct parsing of instructions with / and : in them: 49 # TODO: enable once instruction has been added. 50 #i32x4.trunc_s/f32x4:sat 51 i32.trunc_s/f32 52 try 53.LBB0_3: 54 i32.catch 0 55.LBB0_4: 56 catch_all 57.LBB0_5: 58 end_try 59 #i32.trunc_s:sat/f32 60 get_global __stack_pointer@GLOBAL 61 end_function 62.Lfunc_end0: 63 .size test0, .Lfunc_end0-test0 64 .globaltype __stack_pointer, i32 65 66# CHECK: .text 67# CHECK-LABEL: test0: 68# CHECK-NEXT: .functype test0 (i32, i64) -> (i32) 69# CHECK-NEXT: .local f32, f64 70# CHECK-NEXT: get_local 2 71# CHECK-NEXT: set_local 2 72# CHECK-NEXT: i32.const -1 73# CHECK-NEXT: f64.const 0x1.999999999999ap1 74# CHECK-NEXT: v128.const 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 75# CHECK-NEXT: v128.const 0, 1, 2, 3, 4, 5, 6, 7 76# CHECK-NEXT: get_local 0 77# CHECK-NEXT: f64.store 0:p2align=0 78# CHECK-NEXT: block 79# CHECK-NEXT: i32.const 1 80# CHECK-NEXT: get_local 0 81# CHECK-NEXT: i32.ge_s 82# CHECK-NEXT: br_if 0 # 0: down to label0 83# CHECK-NEXT: .LBB0_1: 84# CHECK-NEXT: loop # label1: 85# CHECK-NEXT: call something1@FUNCTION 86# CHECK-NEXT: i64.const 1234 87# CHECK-NEXT: i32.call something2@FUNCTION 88# CHECK-NEXT: i32.const 0 89# CHECK-NEXT: call_indirect 0 90# CHECK-NEXT: i32.const 1 91# CHECK-NEXT: i32.add 92# CHECK-NEXT: tee_local 0 93# CHECK-NEXT: get_local 0 94# CHECK-NEXT: i32.lt_s 95# CHECK-NEXT: br_if 0 # 0: up to label1 96# CHECK-NEXT: .LBB0_2: 97# CHECK-NEXT: end_loop 98# CHECK-NEXT: end_block # label0: 99# CHECK-NEXT: get_local 4 100# CHECK-NEXT: get_local 5 101# CHECK-NEXT: f32x4.add 102# CHECK-NEXT: i32.trunc_s/f32 103# CHECK-NEXT: try 104# CHECK-NEXT: .LBB0_3: 105# CHECK-NEXT: i32.catch 0 106# CHECK-NEXT: .LBB0_4: 107# CHECK-NEXT: catch_all 108# CHECK-NEXT: .LBB0_5: 109# CHECK-NEXT: end_try 110# CHECK-NEXT: get_global __stack_pointer@GLOBAL 111# CHECK-NEXT: end_function 112 113# CHECK: .globaltype __stack_pointer, i32 114