1 ; RUN: llc < %s -asm-verbose=false -disable-wasm-fallthrough-return-opt -disable-wasm-explicit-locals | FileCheck %s 2 3 ; Test that basic memory operations assemble as expected with 32-bit addresses. 4 5 target datalayout = "e-m:e-p:32:32-i64:64-n32:64-S128" 6 target triple = "wasm32-unknown-unknown" 7 8 declare i32 @llvm.wasm.memory.size.i32(i32) nounwind readonly 9 declare i32 @llvm.wasm.memory.grow.i32(i32, i32) nounwind 10 declare i32 @llvm.wasm.mem.size.i32(i32) nounwind readonly 11 declare i32 @llvm.wasm.mem.grow.i32(i32, i32) nounwind 12 declare i32 @llvm.wasm.current.memory.i32() nounwind readonly 13 declare i32 @llvm.wasm.grow.memory.i32(i32) nounwind 14 15 ; CHECK-LABEL: memory_size: 16 ; CHECK-NEXT: .result i32{{$}} 17 ; CHECK-NEXT: memory.size $push0=, 0{{$}} 18 ; CHECK-NEXT: return $pop0{{$}} 19 define i32 @memory_size() { 20 %a = call i32 @llvm.wasm.memory.size.i32(i32 0) 21 ret i32 %a 22 } 23 24 ; CHECK-LABEL: memory_grow: 25 ; CHECK-NEXT: .param i32{{$}} 26 ; CHECK-NEXT: .result i32{{$}} 27 ; CHECK: memory.grow $push0=, 0, $0{{$}} 28 ; CHECK-NEXT: return $pop0{{$}} 29 define i32 @memory_grow(i32 %n) { 30 %a = call i32 @llvm.wasm.memory.grow.i32(i32 0, i32 %n) 31 ret i32 %a 32 } 33 34 ; CHECK-LABEL: mem_size: 35 ; CHECK-NEXT: .result i32{{$}} 36 ; CHECK-NEXT: mem.size $push0=, 0{{$}} 37 ; CHECK-NEXT: return $pop0{{$}} 38 define i32 @mem_size() { 39 %a = call i32 @llvm.wasm.mem.size.i32(i32 0) 40 ret i32 %a 41 } 42 43 ; CHECK-LABEL: mem_grow: 44 ; CHECK-NEXT: .param i32{{$}} 45 ; CHECK-NEXT: .result i32{{$}} 46 ; CHECK: mem.grow $push0=, 0, $0{{$}} 47 ; CHECK-NEXT: return $pop0{{$}} 48 define i32 @mem_grow(i32 %n) { 49 %a = call i32 @llvm.wasm.mem.grow.i32(i32 0, i32 %n) 50 ret i32 %a 51 } 52 53 ; CHECK-LABEL: current_memory: 54 ; CHECK-NEXT: .result i32{{$}} 55 ; CHECK-NEXT: current_memory $push0={{$}} 56 ; CHECK-NEXT: return $pop0{{$}} 57 define i32 @current_memory() { 58 %a = call i32 @llvm.wasm.current.memory.i32() 59 ret i32 %a 60 } 61 62 ; CHECK-LABEL: grow_memory: 63 ; CHECK-NEXT: .param i32{{$}} 64 ; CHECK-NEXT: .result i32{{$}} 65 ; CHECK: grow_memory $push0=, $0{{$}} 66 ; CHECK-NEXT: return $pop0{{$}} 67 define i32 @grow_memory(i32 %n) { 68 %a = call i32 @llvm.wasm.grow.memory.i32(i32 %n) 69 ret i32 %a 70 } 71