1 ; RUN: llc < %s -asm-verbose=false | FileCheck %s 2 ; RUN: llc < %s -asm-verbose=false -fast-isel | FileCheck %s 3 4 5 target datalayout = "e-p:32:32-i64:64-n32:64-S128" 6 target triple = "wasm32-unknown-unknown" 7 8 ; CHECK-LABEL: alloca32: 9 ; Check that there is an extra local for the stack pointer. 10 ; CHECK: .local i32, i32, i32, i32{{$}} 11 define void @alloca32() { 12 ; CHECK: i32.const [[L1:.+]]=, __stack_pointer 13 ; CHECK-NEXT: i32.load [[L1]]=, 0([[L1]]) 14 ; CHECK-NEXT: i32.const [[L2:.+]]=, 16 15 ; CHECK-NEXT: i32.sub [[SP:.+]]=, [[L1]], [[L2]] 16 %retval = alloca i32 17 ; CHECK: i32.const $push[[L3:.+]]=, 0 18 ; CHECK: i32.store {{.*}}=, 12([[SP]]), $pop[[L3]] 19 store i32 0, i32* %retval 20 ; CHECK: i32.const [[L4:.+]]=, 16 21 ; CHECK-NEXT: i32.add [[SP]]=, [[SP]], [[L4]] 22 ; CHECK-NEXT: i32.const [[L5:.+]]=, __stack_pointer 23 ; CHECK-NEXT: i32.store [[SP]]=, 0([[L5]]), [[SP]] 24 ret void 25 } 26 27 ; CHECK-LABEL: alloca3264: 28 ; CHECK: .local i32, i32, i32, i32{{$}} 29 define void @alloca3264() { 30 ; CHECK: i32.const [[L1:.+]]=, __stack_pointer 31 ; CHECK-NEXT: i32.load [[L1]]=, 0([[L1]]) 32 ; CHECK-NEXT: i32.const [[L2:.+]]=, 16 33 ; CHECK-NEXT: i32.sub [[SP:.+]]=, [[L1]], [[L2]] 34 %r1 = alloca i32 35 %r2 = alloca double 36 ; CHECK: i32.const $push[[L3:.+]]=, 0 37 ; CHECK: i32.store {{.*}}=, 12([[SP]]), $pop[[L3]] 38 store i32 0, i32* %r1 39 ; CHECK: i64.const $push[[L4:.+]]=, 0 40 ; CHECK: i64.store {{.*}}=, 0([[SP]]), $pop[[L4]] 41 store double 0.0, double* %r2 42 ; CHECK: i32.const [[L4:.+]]=, 16 43 ; CHECK-NEXT: i32.add [[SP]]=, [[SP]], [[L4]] 44 ; CHECK-NEXT: i32.const [[L5:.+]]=, __stack_pointer 45 ; CHECK-NEXT: i32.store [[SP]]=, 0([[L5]]), [[SP]] 46 ret void 47 } 48 49 ; CHECK-LABEL: allocarray: 50 ; CHECK: .local i32, i32, i32, i32, i32, i32{{$}} 51 define void @allocarray() { 52 ; CHECK: i32.const [[L1:.+]]=, __stack_pointer 53 ; CHECK-NEXT: i32.load [[L1]]=, 0([[L1]]) 54 ; CHECK-NEXT: i32.const [[L2:.+]]=, 32 55 ; CHECK-NEXT: i32.sub [[SP:.+]]=, [[L1]], [[L2]] 56 %r = alloca [5 x i32] 57 ; CHECK: i32.const $push[[L3:.+]]=, 1 58 ; CHECK: i32.store {{.*}}=, 12([[SP]]), $pop[[L3]] 59 %p = getelementptr [5 x i32], [5 x i32]* %r, i32 0, i32 0 60 store i32 1, i32* %p 61 ; CHECK: i32.const $push[[L4:.+]]=, 4 62 ; CHECK: i32.const [[L5:.+]]=, 12 63 ; CHECK: i32.add [[L5]]=, [[SP]], [[L5]] 64 ; CHECK: i32.add $push[[L6:.+]]=, [[L5]], $pop[[L4]] 65 ; CHECK: i32.store {{.*}}=, 0($pop[[L6]]), ${{.+}} 66 %p2 = getelementptr [5 x i32], [5 x i32]* %r, i32 0, i32 1 67 store i32 1, i32* %p2 68 ; CHECK: i32.const [[L7:.+]]=, 32 69 ; CHECK-NEXT: i32.add [[SP]]=, [[SP]], [[L7]] 70 ; CHECK-NEXT: i32.const [[L8:.+]]=, __stack_pointer 71 ; CHECK-NEXT: i32.store [[SP]]=, 0([[L7]]), [[SP]] 72 ret void 73 } 74 75 define void @dynamic_alloca(i32 %alloc) { 76 ; TODO: Support frame pointers 77 ;%r = alloca i32, i32 %alloc 78 ;store i32 0, i32* %r 79 ret void 80 } 81 ; TODO: test aligned alloc 82