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 .eventtype __cpp_exception i32 12 .local f32, f64, v128, v128 13 # Explicit getlocal/setlocal: 14 local.get 2 15 local.set 2 16 # Immediates: 17 i32.const -1 18 f64.const 0x1.999999999999ap1 19 v128.const 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 20 v128.const 0, 1, 2, 3, 4, 5, 6, 7 21 # Indirect addressing: 22 local.get 0 23 f64.store 0 24 # Loops, conditionals, binary ops, calls etc: 25 block i32 26 i32.const 1 27 local.get 0 28 i32.ge_s 29 br_if 0 # 0: down to label0 30.LBB0_1: 31 loop i32 # label1: 32 call something1@FUNCTION 33 i64.const 1234 34 i32.call something2@FUNCTION 35 i32.const 0 36 call_indirect 0 37 i32.const 1 38 i32.add 39 local.tee 0 40 local.get 0 41 i32.lt_s 42 br_if 0 # 0: up to label1 43.LBB0_2: 44 end_loop 45 end_block # label0: 46 local.get 4 47 local.get 5 48 block void 49 block i64 50 block f32 51 block f64 52 br_table {0, 1, 2} # 2 entries, default 53 end_block # first entry jumps here. 54 i32.const 1 55 br 2 56 end_block # second entry jumps here. 57 i32.const 2 58 br 1 59 end_block # default jumps here. 60 i32.const 3 61 end_block # "switch" exit. 62 if # void 63 if i32 64 end_if 65 else 66 end_if 67 f32x4.add 68 # Test correct parsing of instructions with / and : in them: 69 # TODO: enable once instruction has been added. 70 #i32x4.trunc_sat_f32x4_s 71 i32.trunc_f32_s 72 try except_ref 73.LBB0_3: 74 i32.catch 0 75.LBB0_4: 76 catch_all 77.LBB0_5: 78 end_try 79 #i32.trunc_sat_f32_s 80 global.get __stack_pointer@GLOBAL 81 end_function 82.Lfunc_end0: 83 .size test0, .Lfunc_end0-test0 84 .globaltype __stack_pointer, i32 85 86# CHECK: .text 87# CHECK-LABEL: test0: 88# CHECK-NEXT: .functype test0 (i32, i64) -> (i32) 89# CHECK-NEXT: .eventtype __cpp_exception i32 90# CHECK-NEXT: .local f32, f64 91# CHECK-NEXT: local.get 2 92# CHECK-NEXT: local.set 2 93# CHECK-NEXT: i32.const -1 94# CHECK-NEXT: f64.const 0x1.999999999999ap1 95# CHECK-NEXT: v128.const 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 96# CHECK-NEXT: v128.const 0, 1, 2, 3, 4, 5, 6, 7 97# CHECK-NEXT: local.get 0 98# CHECK-NEXT: f64.store 0:p2align=0 99# CHECK-NEXT: block i32 100# CHECK-NEXT: i32.const 1 101# CHECK-NEXT: local.get 0 102# CHECK-NEXT: i32.ge_s 103# CHECK-NEXT: br_if 0 # 0: down to label0 104# CHECK-NEXT: .LBB0_1: 105# CHECK-NEXT: loop i32 # label1: 106# CHECK-NEXT: call something1@FUNCTION 107# CHECK-NEXT: i64.const 1234 108# CHECK-NEXT: i32.call something2@FUNCTION 109# CHECK-NEXT: i32.const 0 110# CHECK-NEXT: call_indirect 0 111# CHECK-NEXT: i32.const 1 112# CHECK-NEXT: i32.add 113# CHECK-NEXT: local.tee 0 114# CHECK-NEXT: local.get 0 115# CHECK-NEXT: i32.lt_s 116# CHECK-NEXT: br_if 0 # 0: up to label1 117# CHECK-NEXT: .LBB0_2: 118# CHECK-NEXT: end_loop 119# CHECK-NEXT: end_block # label0: 120# CHECK-NEXT: local.get 4 121# CHECK-NEXT: local.get 5 122# CHECK-NEXT: block 123# CHECK-NEXT: block i64 124# CHECK-NEXT: block f32 125# CHECK-NEXT: block f64 126# CHECK-NEXT: br_table {0, 1, 2} # 1: down to label4 127# CHECK-NEXT: # 2: down to label3 128# CHECK-NEXT: end_block # label5: 129# CHECK-NEXT: i32.const 1 130# CHECK-NEXT: br 2 # 2: down to label2 131# CHECK-NEXT: end_block # label4: 132# CHECK-NEXT: i32.const 2 133# CHECK-NEXT: br 1 # 1: down to label2 134# CHECK-NEXT: end_block # label3: 135# CHECK-NEXT: i32.const 3 136# CHECK-NEXT: end_block # label2: 137# CHECK-NEXT: if 138# CHECK-NEXT: if i32 139# CHECK-NEXT: end_if 140# CHECK-NEXT: else 141# CHECK-NEXT: end_if 142# CHECK-NEXT: f32x4.add 143# CHECK-NEXT: i32.trunc_f32_s 144# CHECK-NEXT: try except_ref 145# CHECK-NEXT: .LBB0_3: 146# CHECK-NEXT: i32.catch 0 147# CHECK-NEXT: .LBB0_4: 148# CHECK-NEXT: catch_all 149# CHECK-NEXT: .LBB0_5: 150# CHECK-NEXT: end_try 151# CHECK-NEXT: global.get __stack_pointer@GLOBAL 152# CHECK-NEXT: end_function 153 154# CHECK: .globaltype __stack_pointer, i32 155