xref: /aosp_15_r20/external/llvm/test/CodeGen/SystemZ/asm-02.ll (revision 9880d6810fe72a1726cb53787c6711e909410d58)
1*9880d681SAndroid Build Coastguard Worker; Test the "R" asm constraint, which accepts addresses that have a base,
2*9880d681SAndroid Build Coastguard Worker; an index and a 12-bit displacement.
3*9880d681SAndroid Build Coastguard Worker;
4*9880d681SAndroid Build Coastguard Worker; RUN: llc < %s -mtriple=s390x-linux-gnu -no-integrated-as | FileCheck %s
5*9880d681SAndroid Build Coastguard Worker
6*9880d681SAndroid Build Coastguard Worker; Check the lowest range.
7*9880d681SAndroid Build Coastguard Workerdefine void @f1(i64 %base) {
8*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: f1:
9*9880d681SAndroid Build Coastguard Worker; CHECK: blah 0(%r2)
10*9880d681SAndroid Build Coastguard Worker; CHECK: br %r14
11*9880d681SAndroid Build Coastguard Worker  %addr = inttoptr i64 %base to i64 *
12*9880d681SAndroid Build Coastguard Worker  call void asm "blah $0", "=*R" (i64 *%addr)
13*9880d681SAndroid Build Coastguard Worker  ret void
14*9880d681SAndroid Build Coastguard Worker}
15*9880d681SAndroid Build Coastguard Worker
16*9880d681SAndroid Build Coastguard Worker; Check the next lowest byte.
17*9880d681SAndroid Build Coastguard Workerdefine void @f2(i64 %base) {
18*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: f2:
19*9880d681SAndroid Build Coastguard Worker; CHECK: aghi %r2, -1
20*9880d681SAndroid Build Coastguard Worker; CHECK: blah 0(%r2)
21*9880d681SAndroid Build Coastguard Worker; CHECK: br %r14
22*9880d681SAndroid Build Coastguard Worker  %add = add i64 %base, -1
23*9880d681SAndroid Build Coastguard Worker  %addr = inttoptr i64 %add to i64 *
24*9880d681SAndroid Build Coastguard Worker  call void asm "blah $0", "=*R" (i64 *%addr)
25*9880d681SAndroid Build Coastguard Worker  ret void
26*9880d681SAndroid Build Coastguard Worker}
27*9880d681SAndroid Build Coastguard Worker
28*9880d681SAndroid Build Coastguard Worker; Check the highest range.
29*9880d681SAndroid Build Coastguard Workerdefine void @f3(i64 %base) {
30*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: f3:
31*9880d681SAndroid Build Coastguard Worker; CHECK: blah 4095(%r2)
32*9880d681SAndroid Build Coastguard Worker; CHECK: br %r14
33*9880d681SAndroid Build Coastguard Worker  %add = add i64 %base, 4095
34*9880d681SAndroid Build Coastguard Worker  %addr = inttoptr i64 %add to i64 *
35*9880d681SAndroid Build Coastguard Worker  call void asm "blah $0", "=*R" (i64 *%addr)
36*9880d681SAndroid Build Coastguard Worker  ret void
37*9880d681SAndroid Build Coastguard Worker}
38*9880d681SAndroid Build Coastguard Worker
39*9880d681SAndroid Build Coastguard Worker; Check the next highest byte.
40*9880d681SAndroid Build Coastguard Workerdefine void @f4(i64 %base) {
41*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: f4:
42*9880d681SAndroid Build Coastguard Worker; CHECK: aghi %r2, 4096
43*9880d681SAndroid Build Coastguard Worker; CHECK: blah 0(%r2)
44*9880d681SAndroid Build Coastguard Worker; CHECK: br %r14
45*9880d681SAndroid Build Coastguard Worker  %add = add i64 %base, 4096
46*9880d681SAndroid Build Coastguard Worker  %addr = inttoptr i64 %add to i64 *
47*9880d681SAndroid Build Coastguard Worker  call void asm "blah $0", "=*R" (i64 *%addr)
48*9880d681SAndroid Build Coastguard Worker  ret void
49*9880d681SAndroid Build Coastguard Worker}
50*9880d681SAndroid Build Coastguard Worker
51*9880d681SAndroid Build Coastguard Worker; Check that indices are allowed
52*9880d681SAndroid Build Coastguard Workerdefine void @f5(i64 %base, i64 %index) {
53*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: f5:
54*9880d681SAndroid Build Coastguard Worker; CHECK: blah 0(%r3,%r2)
55*9880d681SAndroid Build Coastguard Worker; CHECK: br %r14
56*9880d681SAndroid Build Coastguard Worker  %add = add i64 %base, %index
57*9880d681SAndroid Build Coastguard Worker  %addr = inttoptr i64 %add to i64 *
58*9880d681SAndroid Build Coastguard Worker  call void asm "blah $0", "=*R" (i64 *%addr)
59*9880d681SAndroid Build Coastguard Worker  ret void
60*9880d681SAndroid Build Coastguard Worker}
61*9880d681SAndroid Build Coastguard Worker
62*9880d681SAndroid Build Coastguard Worker; Check that indices and displacements are allowed simultaneously
63*9880d681SAndroid Build Coastguard Workerdefine void @f6(i64 %base, i64 %index) {
64*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: f6:
65*9880d681SAndroid Build Coastguard Worker; CHECK: blah 4095(%r3,%r2)
66*9880d681SAndroid Build Coastguard Worker; CHECK: br %r14
67*9880d681SAndroid Build Coastguard Worker  %add = add i64 %base, 4095
68*9880d681SAndroid Build Coastguard Worker  %addi = add i64 %add, %index
69*9880d681SAndroid Build Coastguard Worker  %addr = inttoptr i64 %addi to i64 *
70*9880d681SAndroid Build Coastguard Worker  call void asm "blah $0", "=*R" (i64 *%addr)
71*9880d681SAndroid Build Coastguard Worker  ret void
72*9880d681SAndroid Build Coastguard Worker}
73*9880d681SAndroid Build Coastguard Worker
74*9880d681SAndroid Build Coastguard Worker; Check that LAY is used if there is an index but the displacement is too large
75*9880d681SAndroid Build Coastguard Workerdefine void @f7(i64 %base, i64 %index) {
76*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: f7:
77*9880d681SAndroid Build Coastguard Worker; CHECK: lay %r0, 4096(%r3,%r2)
78*9880d681SAndroid Build Coastguard Worker; CHECK: blah 0(%r0)
79*9880d681SAndroid Build Coastguard Worker; CHECK: br %r14
80*9880d681SAndroid Build Coastguard Worker  %add = add i64 %base, 4096
81*9880d681SAndroid Build Coastguard Worker  %addi = add i64 %add, %index
82*9880d681SAndroid Build Coastguard Worker  %addr = inttoptr i64 %addi to i64 *
83*9880d681SAndroid Build Coastguard Worker  call void asm "blah $0", "=*R" (i64 *%addr)
84*9880d681SAndroid Build Coastguard Worker  ret void
85*9880d681SAndroid Build Coastguard Worker}
86