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