236 lines · plain
1# RUN: llvm-mc -triple=wasm64-unknown-unknown -mattr=+atomics,+simd128,+nontrapping-fptoint,+exception-handling < %s | FileCheck %s2# RUN: llvm-mc -triple=wasm64-unknown-unknown -filetype=obj -mattr=+atomics,+simd128,+nontrapping-fptoint,+exception-handling -o - < %s | obj2yaml | FileCheck %s -check-prefix=BIN3 4# Most of our other tests are for wasm32, this one adds some wasm64 specific tests.5 6.globaltype myglob64, i647.globaltype __stack_pointer, i648 9test:10 .functype test (i64) -> ()11 .local i6412 13 ### basic loads14 15 i64.const 0 # get i64 from constant.16 f32.load 017 drop18 19 local.get 0 # get i64 from local.20 f32.load 021 drop22 23 i64.const .L.str # get i64 relocatable.24 f32.load 025 drop26 27 global.get myglob64 # get i64 from global28 f32.load 029 drop30 31 i64.const 032 f32.load .L.str # relocatable offset!33 drop34 35 ### basic stores36 37 i64.const 0 # get i64 from constant.38 f32.const 0.039 f32.store 040 41 local.get 0 # get i64 from local.42 f32.const 0.043 f32.store 044 45 i64.const .L.str # get i64 relocatable.46 f32.const 0.047 f32.store 048 49 global.get myglob64 # get i64 from global50 f32.const 0.051 f32.store 052 53 i64.const 054 f32.const 0.055 f32.store .L.str # relocatable offset!56 57 ### 64-bit SP58 59 global.get __stack_pointer60 drop61 62 end_function63 64 .section .rodata..L.str,"",@65 .hidden .L.str66 .type .L.str,@object67.L.str:68 .asciz "Hello, World!!!"69 .int64 .L.str # relocatable inside data.70 .size .L.str, 2471 72 73# CHECK: .globaltype myglob64, i6474 75# CHECK: .functype test (i64) -> ()76# CHECK-NEXT: .local i6477 78 79# CHECK: i64.const 080# CHECK-NEXT: f32.load 081# CHECK-NEXT: drop82 83# CHECK: local.get 084# CHECK-NEXT: f32.load 085# CHECK-NEXT: drop86 87# CHECK: i64.const .L.str88# CHECK-NEXT: f32.load 089# CHECK-NEXT: drop90 91# CHECK: global.get myglob6492# CHECK-NEXT: f32.load 093# CHECK-NEXT: drop94 95# CHECK: i64.const 096# CHECK-NEXT: f32.load .L.str97# CHECK-NEXT: drop98 99 100# CHECK: i64.const 0101# CHECK-NEXT: f32.const 0x0p0102# CHECK-NEXT: f32.store 0103 104# CHECK: local.get 0105# CHECK-NEXT: f32.const 0x0p0106# CHECK-NEXT: f32.store 0107 108# CHECK: i64.const .L.str109# CHECK-NEXT: f32.const 0x0p0110# CHECK-NEXT: f32.store 0111 112# CHECK: global.get myglob64113# CHECK-NEXT: f32.const 0x0p0114# CHECK-NEXT: f32.store 0115 116# CHECK: i64.const 0117# CHECK-NEXT: f32.const 0x0p0118# CHECK-NEXT: f32.store .L.str119 120 121# CHECK: end_function122 123# CHECK: .section .rodata..L.str,"",@124# CHECK-NEXT: .hidden .L.str125# CHECK-NEXT: .L.str:126# CHECK-NEXT: .asciz "Hello, World!!!"127# CHECK-NEXT: .int64 .L.str128# CHECK-NEXT: .size .L.str, 24129 130 131 132# BIN: --- !WASM133# BIN-NEXT: FileHeader:134# BIN-NEXT: Version: 0x1135# BIN-NEXT: Sections:136# BIN-NEXT: - Type: TYPE137# BIN-NEXT: Signatures:138# BIN-NEXT: - Index: 0139# BIN-NEXT: ParamTypes:140# BIN-NEXT: - I64141# BIN-NEXT: ReturnTypes: []142# BIN-NEXT: - Type: IMPORT143# BIN-NEXT: Imports:144# BIN-NEXT: - Module: env145# BIN-NEXT: Field: __linear_memory146# BIN-NEXT: Kind: MEMORY147# BIN-NEXT: Memory:148# BIN-NEXT: Flags: [ IS_64 ]149# BIN-NEXT: Minimum: 0x1150# BIN-NEXT: - Module: env151# BIN-NEXT: Field: myglob64152# BIN-NEXT: Kind: GLOBAL153# BIN-NEXT: GlobalType: I64154# BIN-NEXT: GlobalMutable: true155# BIN-NEXT: - Module: env156# BIN-NEXT: Field: __stack_pointer157# BIN-NEXT: Kind: GLOBAL158# BIN-NEXT: GlobalType: I64159# BIN-NEXT: GlobalMutable: true160# BIN-NEXT: - Type: FUNCTION161# BIN-NEXT: FunctionTypes: [ 0 ]162# BIN-NEXT: - Type: DATACOUNT163# BIN-NEXT: Count: 1164# BIN-NEXT: - Type: CODE165# BIN-NEXT: Relocations:166# BIN-NEXT: - Type: R_WASM_MEMORY_ADDR_SLEB64167# BIN-NEXT: Index: 1168# BIN-NEXT: Offset: 0x13169# BIN-NEXT: - Type: R_WASM_GLOBAL_INDEX_LEB170# BIN-NEXT: Index: 2171# BIN-NEXT: Offset: 0x22172# BIN-NEXT: - Type: R_WASM_MEMORY_ADDR_LEB64173# BIN-NEXT: Index: 1174# BIN-NEXT: Offset: 0x2F175# BIN-NEXT: - Type: R_WASM_MEMORY_ADDR_SLEB64176# BIN-NEXT: Index: 1177# BIN-NEXT: Offset: 0x4F178# BIN-NEXT: - Type: R_WASM_GLOBAL_INDEX_LEB179# BIN-NEXT: Index: 2180# BIN-NEXT: Offset: 0x62181# BIN-NEXT: - Type: R_WASM_MEMORY_ADDR_LEB64182# BIN-NEXT: Index: 1183# BIN-NEXT: Offset: 0x78184# BIN-NEXT: - Type: R_WASM_GLOBAL_INDEX_LEB185# BIN-NEXT: Index: 3186# BIN-NEXT: Offset: 0x83187# BIN-NEXT: Functions:188# BIN-NEXT: - Index: 0189# BIN-NEXT: Locals:190# BIN-NEXT: - Type: I64191# BIN-NEXT: Count: 1192# BIN-NEXT: Body: 42002A02001A20002A02001A42808080808080808080002A02001A2380808080002A02001A42002A02808080808080808080001A4200430000000038020020004300000000380200428080808080808080800043000000003802002380808080004300000000380200420043000000003802808080808080808080002381808080001A0B193# BIN-NEXT: - Type: DATA194# BIN-NEXT: Relocations:195# BIN-NEXT: - Type: R_WASM_MEMORY_ADDR_I64196# BIN-NEXT: Index: 1197# BIN-NEXT: Offset: 0x16198# BIN-NEXT: Segments:199# BIN-NEXT: - SectionOffset: 6200# BIN-NEXT: InitFlags: 0201# BIN-NEXT: Offset:202# BIN-NEXT: Opcode: I64_CONST203# BIN-NEXT: Value: 0204# BIN-NEXT: Content: 48656C6C6F2C20576F726C64212121000000000000000000205# BIN-NEXT: - Type: CUSTOM206# BIN-NEXT: Name: linking207# BIN-NEXT: Version: 2208# BIN-NEXT: SymbolTable:209# BIN-NEXT: - Index: 0210# BIN-NEXT: Kind: FUNCTION211# BIN-NEXT: Name: test212# BIN-NEXT: Flags: [ BINDING_LOCAL ]213# BIN-NEXT: Function: 0214# BIN-NEXT: - Index: 1215# BIN-NEXT: Kind: DATA216# BIN-NEXT: Name: .L.str217# BIN-NEXT: Flags: [ BINDING_LOCAL, VISIBILITY_HIDDEN ]218# BIN-NEXT: Segment: 0219# BIN-NEXT: Size: 24220# BIN-NEXT: - Index: 2221# BIN-NEXT: Kind: GLOBAL222# BIN-NEXT: Name: myglob64223# BIN-NEXT: Flags: [ UNDEFINED ]224# BIN-NEXT: Global: 0225# BIN-NEXT: - Index: 3226# BIN-NEXT: Kind: GLOBAL227# BIN-NEXT: Name: __stack_pointer228# BIN-NEXT: Flags: [ UNDEFINED ]229# BIN-NEXT: Global: 1230# BIN-NEXT: SegmentInfo:231# BIN-NEXT: - Index: 0232# BIN-NEXT: Name: .rodata..L.str233# BIN-NEXT: Alignment: 0234# BIN-NEXT: Flags: [ ]235# BIN-NEXT: ...236