1# RUN: llvm-mc -triple=wasm64-unknown-unknown -mattr=+atomics,+unimplemented-simd128,+nontrapping-fptoint,+exception-handling < %s | FileCheck %s 2# RUN: llvm-mc -triple=wasm64-unknown-unknown -filetype=obj -mattr=+atomics,+unimplemented-simd128,+nontrapping-fptoint,+exception-handling -o - < %s | obj2yaml | FileCheck %s -check-prefix=BIN 3 4# Most of our other tests are for wasm32, this one adds some wasm64 specific tests. 5 6test: 7 .functype test (i64) -> () 8 .local i64 9 10 ### basic loads 11 12 i64.const 0 # get i64 from constant. 13 f32.load 0 14 drop 15 16 local.get 0 # get i64 from local. 17 f32.load 0 18 drop 19 20 i64.const .L.str # get i64 relocatable. 21 f32.load 0 22 drop 23 24 global.get myglob64 # get i64 from global 25 f32.load 0 26 drop 27 28 i64.const 0 29 f32.load .L.str # relocatable offset! 30 drop 31 32 ### basic stores 33 34 f32.const 0.0 35 i64.const 0 # get i64 from constant. 36 f32.store 0 37 38 f32.const 0.0 39 local.get 0 # get i64 from local. 40 f32.store 0 41 42 f32.const 0.0 43 i64.const .L.str # get i64 relocatable. 44 f32.store 0 45 46 f32.const 0.0 47 global.get myglob64 # get i64 from global 48 f32.store 0 49 50 f32.const 0.0 51 i64.const 0 52 f32.store .L.str # relocatable offset! 53 54 ### 64-bit SP 55 56 global.get __stack_pointer 57 drop 58 59 end_function 60 61 .section .rodata..L.str,"",@ 62 .hidden .L.str 63 .type .L.str,@object 64.L.str: 65 .asciz "Hello, World!!!" 66 .int64 .L.str # relocatable inside data. 67 .size .L.str, 24 68 69 .globaltype myglob64, i64 70 .globaltype __stack_pointer, i64 71 72 73# CHECK: .functype test (i64) -> () 74# CHECK-NEXT: .local i64 75 76 77# CHECK: i64.const 0 78# CHECK-NEXT: f32.load 0 79# CHECK-NEXT: drop 80 81# CHECK: local.get 0 82# CHECK-NEXT: f32.load 0 83# CHECK-NEXT: drop 84 85# CHECK: i64.const .L.str 86# CHECK-NEXT: f32.load 0 87# CHECK-NEXT: drop 88 89# CHECK: global.get myglob64 90# CHECK-NEXT: f32.load 0 91# CHECK-NEXT: drop 92 93# CHECK: i64.const 0 94# CHECK-NEXT: f32.load .L.str 95# CHECK-NEXT: drop 96 97 98# CHECK: f32.const 0x0p0 99# CHECK-NEXT: i64.const 0 100# CHECK-NEXT: f32.store 0 101 102# CHECK: f32.const 0x0p0 103# CHECK-NEXT: local.get 0 104# CHECK-NEXT: f32.store 0 105 106# CHECK: f32.const 0x0p0 107# CHECK-NEXT: i64.const .L.str 108# CHECK-NEXT: f32.store 0 109 110# CHECK: f32.const 0x0p0 111# CHECK-NEXT: global.get myglob64 112# CHECK-NEXT: f32.store 0 113 114# CHECK: f32.const 0x0p0 115# CHECK-NEXT: i64.const 0 116# CHECK-NEXT: f32.store .L.str 117 118 119# CHECK: end_function 120# CHECK-NEXT: .Ltmp0: 121# CHECK-NEXT: .size test, .Ltmp0-test 122 123# CHECK: .section .rodata..L.str,"",@ 124# CHECK-NEXT: .hidden .L.str 125# CHECK-NEXT: .L.str: 126# CHECK-NEXT: .asciz "Hello, World!!!" 127# CHECK-NEXT: .int64 .L.str 128# CHECK-NEXT: .size .L.str, 24 129 130# CHECK: .globaltype myglob64, i64 131 132 133 134# BIN: --- !WASM 135# BIN-NEXT: FileHeader: 136# BIN-NEXT: Version: 0x00000001 137# BIN-NEXT: Sections: 138# BIN-NEXT: - Type: TYPE 139# BIN-NEXT: Signatures: 140# BIN-NEXT: - Index: 0 141# BIN-NEXT: ParamTypes: 142# BIN-NEXT: - I64 143# BIN-NEXT: ReturnTypes: [] 144# BIN-NEXT: - Type: IMPORT 145# BIN-NEXT: Imports: 146# BIN-NEXT: - Module: env 147# BIN-NEXT: Field: __linear_memory 148# BIN-NEXT: Kind: MEMORY 149# BIN-NEXT: Memory: 150# BIN-NEXT: Flags: [ IS_64 ] 151# BIN-NEXT: Initial: 0x00000001 152# BIN-NEXT: - Module: env 153# BIN-NEXT: Field: __indirect_function_table 154# BIN-NEXT: Kind: TABLE 155# BIN-NEXT: Table: 156# BIN-NEXT: Index: 0 157# BIN-NEXT: ElemType: FUNCREF 158# BIN-NEXT: Limits: 159# BIN-NEXT: Initial: 0x00000000 160# BIN-NEXT: - Module: env 161# BIN-NEXT: Field: myglob64 162# BIN-NEXT: Kind: GLOBAL 163# BIN-NEXT: GlobalType: I64 164# BIN-NEXT: GlobalMutable: true 165# BIN-NEXT: - Module: env 166# BIN-NEXT: Field: __stack_pointer 167# BIN-NEXT: Kind: GLOBAL 168# BIN-NEXT: GlobalType: I64 169# BIN-NEXT: GlobalMutable: true 170# BIN-NEXT: - Type: FUNCTION 171# BIN-NEXT: FunctionTypes: [ 0 ] 172# BIN-NEXT: - Type: DATACOUNT 173# BIN-NEXT: Count: 1 174# BIN-NEXT: - Type: CODE 175# BIN-NEXT: Relocations: 176# BIN-NEXT: - Type: R_WASM_MEMORY_ADDR_SLEB64 177# BIN-NEXT: Index: 1 178# BIN-NEXT: Offset: 0x00000013 179# BIN-NEXT: - Type: R_WASM_GLOBAL_INDEX_LEB 180# BIN-NEXT: Index: 2 181# BIN-NEXT: Offset: 0x00000022 182# BIN-NEXT: - Type: R_WASM_MEMORY_ADDR_LEB64 183# BIN-NEXT: Index: 1 184# BIN-NEXT: Offset: 0x0000002F 185# BIN-NEXT: - Type: R_WASM_MEMORY_ADDR_SLEB64 186# BIN-NEXT: Index: 1 187# BIN-NEXT: Offset: 0x00000054 188# BIN-NEXT: - Type: R_WASM_GLOBAL_INDEX_LEB 189# BIN-NEXT: Index: 2 190# BIN-NEXT: Offset: 0x00000067 191# BIN-NEXT: - Type: R_WASM_MEMORY_ADDR_LEB64 192# BIN-NEXT: Index: 1 193# BIN-NEXT: Offset: 0x00000078 194# BIN-NEXT: - Type: R_WASM_GLOBAL_INDEX_LEB 195# BIN-NEXT: Index: 3 196# BIN-NEXT: Offset: 0x00000083 197# BIN-NEXT: Functions: 198# BIN-NEXT: - Index: 0 199# BIN-NEXT: Locals: 200# BIN-NEXT: - Type: I64 201# BIN-NEXT: Count: 1 202# BIN-NEXT: Body: 42002A02001A20002A02001A42808080808080808080002A02001A2380808080002A02001A42002A02808080808080808080001A4300000000420038020043000000002000380200430000000042808080808080808080003802004300000000238080808000380200430000000042003802808080808080808080002381808080001A0B 203# BIN-NEXT: - Type: DATA 204# BIN-NEXT: Relocations: 205# BIN-NEXT: - Type: R_WASM_MEMORY_ADDR_I64 206# BIN-NEXT: Index: 1 207# BIN-NEXT: Offset: 0x00000016 208# BIN-NEXT: Segments: 209# BIN-NEXT: - SectionOffset: 6 210# BIN-NEXT: InitFlags: 0 211# BIN-NEXT: Offset: 212# BIN-NEXT: Opcode: I32_CONST 213# BIN-NEXT: Value: 0 214# BIN-NEXT: Content: 48656C6C6F2C20576F726C64212121000000000000000000 215# BIN-NEXT: - Type: CUSTOM 216# BIN-NEXT: Name: linking 217# BIN-NEXT: Version: 2 218# BIN-NEXT: SymbolTable: 219# BIN-NEXT: - Index: 0 220# BIN-NEXT: Kind: FUNCTION 221# BIN-NEXT: Name: test 222# BIN-NEXT: Flags: [ BINDING_LOCAL ] 223# BIN-NEXT: Function: 0 224# BIN-NEXT: - Index: 1 225# BIN-NEXT: Kind: DATA 226# BIN-NEXT: Name: .L.str 227# BIN-NEXT: Flags: [ BINDING_LOCAL, VISIBILITY_HIDDEN ] 228# BIN-NEXT: Segment: 0 229# BIN-NEXT: Size: 24 230# BIN-NEXT: - Index: 2 231# BIN-NEXT: Kind: GLOBAL 232# BIN-NEXT: Name: myglob64 233# BIN-NEXT: Flags: [ UNDEFINED ] 234# BIN-NEXT: Global: 0 235# BIN-NEXT: - Index: 3 236# BIN-NEXT: Kind: GLOBAL 237# BIN-NEXT: Name: __stack_pointer 238# BIN-NEXT: Flags: [ UNDEFINED ] 239# BIN-NEXT: Global: 1 240# BIN-NEXT: SegmentInfo: 241# BIN-NEXT: - Index: 0 242# BIN-NEXT: Name: .rodata..L.str 243# BIN-NEXT: Alignment: 0 244# BIN-NEXT: Flags: [ ] 245# BIN-NEXT: ... 246