[WebAssembly] Use the new offset syntax for memory operands in inline asm.
[oota-llvm.git] / test / CodeGen / WebAssembly / offset-folding.ll
1 ; RUN: llc < %s -asm-verbose=false | FileCheck %s
2
3 ; Test that constant offsets can be folded into global addresses.
4
5 target datalayout = "e-p:32:32-i64:64-n32:64-S128"
6 target triple = "wasm32-unknown-unknown"
7
8 @x = external global [0 x i32]
9 @y = global [50 x i32] zeroinitializer
10
11 ; Test basic constant offsets of both defined and external symbols.
12
13 ; CHECK-LABEL: test0:
14 ; CHECK-NEXT: .result i32{{$}}
15 ; CHECK-NEXT: i32.const $push0=, x+188{{$}}
16 ; CHECK=NEXT: return $pop0{{$}}
17 define i32* @test0() {
18   ret i32* getelementptr ([0 x i32], [0 x i32]* @x, i32 0, i32 47)
19 }
20
21 ; CHECK-LABEL: test1:
22 ; CHECK-NEXT: .result i32{{$}}
23 ; CHECK-NEXT: i32.const $push0=, y+188{{$}}
24 ; CHECK=NEXT: return $pop0{{$}}
25 define i32* @test1() {
26   ret i32* getelementptr ([50 x i32], [50 x i32]* @y, i32 0, i32 47)
27 }
28
29 ; Test zero offsets.
30
31 ; CHECK-LABEL: test2:
32 ; CHECK-NEXT: .result i32{{$}}
33 ; CHECK-NEXT: i32.const $push0=, x{{$}}
34 ; CHECK=NEXT: return $pop0{{$}}
35 define i32* @test2() {
36   ret i32* getelementptr ([0 x i32], [0 x i32]* @x, i32 0, i32 0)
37 }
38
39 ; CHECK-LABEL: test3:
40 ; CHECK-NEXT: .result i32{{$}}
41 ; CHECK-NEXT: i32.const $push0=, y{{$}}
42 ; CHECK=NEXT: return $pop0{{$}}
43 define i32* @test3() {
44   ret i32* getelementptr ([50 x i32], [50 x i32]* @y, i32 0, i32 0)
45 }