• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; Test variable-sized allocas and addresses based on them in cases where
2; stack arguments are needed.
3;
4; RUN: llc < %s -mtriple=s390x-linux-gnu | FileCheck %s
5; RUN: llc < %s -mtriple=s390x-linux-gnu | FileCheck %s -check-prefix=CHECK-A
6; RUN: llc < %s -mtriple=s390x-linux-gnu | FileCheck %s -check-prefix=CHECK-B
7; RUN: llc < %s -mtriple=s390x-linux-gnu | FileCheck %s -check-prefix=CHECK-C
8; RUN: llc < %s -mtriple=s390x-linux-gnu | FileCheck %s -check-prefix=CHECK-D
9; RUN: llc < %s -mtriple=s390x-linux-gnu | FileCheck %s -check-prefix=CHECK-FP
10
11declare i64 @bar(i8 *%a, i8 *%b, i8 *%c, i8 *%d, i8 *%e, i64 %f, i64 %g)
12
13; Allocate %length bytes and take addresses based on the result.
14; There are two stack arguments, so an offset of 160 + 2 * 8 == 176
15; is added to the copy of %r15.
16define i64 @f1(i64 %length, i64 %index) {
17; FIXME: a better sequence would be:
18;
19;    lgr %r1, %r15
20;    sgr %r1, %r2
21;    nill %r1, 0xfff8
22;    lgr %r15, %r1
23;
24; CHECK-LABEL: f1:
25; CHECK-DAG: la [[REG1:%r[0-5]]], 7(%r2)
26; CHECK-DAG: nill [[REG1]], 65528
27; CHECK-DAG: lgr [[REG2:%r[0-5]]], %r15
28; CHECK: sgr [[REG2]], [[REG1]]
29; CHECK: lgr %r15, [[REG2]]
30;
31; CHECK-A-LABEL: f1:
32; CHECK-A: lgr %r15, %r1
33; CHECK-A: la %r2, 176(%r1)
34;
35; CHECK-B-LABEL: f1:
36; CHECK-B: lgr %r15, %r1
37; CHECK-B: la %r3, 177(%r1)
38;
39; CHECK-C-LABEL: f1:
40; CHECK-C: lgr %r15, %r1
41; CHECK-C: la %r4, 4095({{%r3,%r1|%r1,%r3}})
42;
43; CHECK-D-LABEL: f1:
44; CHECK-D: lgr %r15, %r1
45; CHECK-D: lay %r5, 4096({{%r3,%r1|%r1,%r3}})
46;
47; CHECK-E-LABEL: f1:
48; CHECK-E: lgr %r15, %r1
49; CHECK-E: lay %r6, 4271({{%r3,%r1|%r1,%r3}})
50;
51; CHECK-FP-LABEL: f1:
52; CHECK-FP: lgr %r11, %r15
53; CHECK-FP: lmg %r6, %r15, 224(%r11)
54  %a = alloca i8, i64 %length
55  %b = getelementptr i8, i8 *%a, i64 1
56  %cindex = add i64 %index, 3919
57  %c = getelementptr i8, i8 *%a, i64 %cindex
58  %dindex = add i64 %index, 3920
59  %d = getelementptr i8, i8 *%a, i64 %dindex
60  %eindex = add i64 %index, 4095
61  %e = getelementptr i8, i8 *%a, i64 %eindex
62  %count = call i64 @bar(i8 *%a, i8 *%b, i8 *%c, i8 *%d, i8 *%e, i64 0, i64 0)
63  %res = add i64 %count, 1
64  ret i64 %res
65}
66