From 6dae7ae7659444efc2149852e366ba97d3a6e449 Mon Sep 17 00:00:00 2001 From: Richard Sandiford Date: Fri, 19 Jul 2013 16:44:32 +0000 Subject: [PATCH] [SystemZ] Add tests for ALHSIK and ALGHSIK The insn definitions themselves crept into r186689, sorry. This should be the last of the distinct-ops instructions. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@186690 91177308-0d34-0410-b5e6-96231b3b80d8 --- test/CodeGen/SystemZ/int-add-16.ll | 71 ++++++++++++++++++++++++++ test/MC/Disassembler/SystemZ/insns.txt | 30 +++++++++++ test/MC/SystemZ/insn-bad.s | 10 ++++ test/MC/SystemZ/insn-good-z196.s | 36 +++++++++++++ 4 files changed, 147 insertions(+) diff --git a/test/CodeGen/SystemZ/int-add-16.ll b/test/CodeGen/SystemZ/int-add-16.ll index 409729f089f..36cc13e5fc6 100644 --- a/test/CodeGen/SystemZ/int-add-16.ll +++ b/test/CodeGen/SystemZ/int-add-16.ll @@ -20,3 +20,74 @@ define i64 @f1(i64 %a, i64 %b, i64 %c, i64 %d, i64 *%ptr) { %low = extractelement <2 x i64> %addv, i32 1 ret i64 %low } + +; Test addition of 1. +define void @f2(i64 %a, i64 %b, i128 *%ptr) { +; CHECK-LABEL: f2: +; CHECK: alghsik {{%r[0-5]}}, %r3, 1 +; CHECK: alcgr +; CHECK: br %r14 + %x1 = insertelement <2 x i64> undef, i64 %a, i32 0 + %x2 = insertelement <2 x i64> %x1, i64 %b, i32 1 + %x = bitcast <2 x i64> %x2 to i128 + %add = add i128 %x, 1 + store i128 %add, i128 *%ptr + ret void +} + +; Test the upper end of the ALGHSIK range. +define void @f3(i64 %a, i64 %b, i128 *%ptr) { +; CHECK-LABEL: f3: +; CHECK: alghsik {{%r[0-5]}}, %r3, 32767 +; CHECK: alcgr +; CHECK: br %r14 + %x1 = insertelement <2 x i64> undef, i64 %a, i32 0 + %x2 = insertelement <2 x i64> %x1, i64 %b, i32 1 + %x = bitcast <2 x i64> %x2 to i128 + %add = add i128 %x, 32767 + store i128 %add, i128 *%ptr + ret void +} + +; Test the next value up, which should use ALGFI instead. +define void @f4(i64 %a, i64 %b, i128 *%ptr) { +; CHECK-LABEL: f4: +; CHECK: algfi %r3, 32768 +; CHECK: alcgr +; CHECK: br %r14 + %x1 = insertelement <2 x i64> undef, i64 %a, i32 0 + %x2 = insertelement <2 x i64> %x1, i64 %b, i32 1 + %x = bitcast <2 x i64> %x2 to i128 + %add = add i128 %x, 32768 + store i128 %add, i128 *%ptr + ret void +} + +; Test the lower end of the ALGHSIK range. +define void @f5(i64 %a, i64 %b, i128 *%ptr) { +; CHECK-LABEL: f5: +; CHECK: alghsik {{%r[0-5]}}, %r3, -32768 +; CHECK: alcgr +; CHECK: br %r14 + %x1 = insertelement <2 x i64> undef, i64 %a, i32 0 + %x2 = insertelement <2 x i64> %x1, i64 %b, i32 1 + %x = bitcast <2 x i64> %x2 to i128 + %add = add i128 %x, -32768 + store i128 %add, i128 *%ptr + ret void +} + +; Test the next value down, which cannot use either ALGHSIK or ALGFI. +define void @f6(i64 %a, i64 %b, i128 *%ptr) { +; CHECK-LABEL: f6: +; CHECK-NOT: alghsik +; CHECK-NOT: algfi +; CHECK: alcgr +; CHECK: br %r14 + %x1 = insertelement <2 x i64> undef, i64 %a, i32 0 + %x2 = insertelement <2 x i64> %x1, i64 %b, i32 1 + %x = bitcast <2 x i64> %x2 to i128 + %add = add i128 %x, -32769 + store i128 %add, i128 *%ptr + ret void +} diff --git a/test/MC/Disassembler/SystemZ/insns.txt b/test/MC/Disassembler/SystemZ/insns.txt index 6e0c2559b2a..29ff69e52c7 100644 --- a/test/MC/Disassembler/SystemZ/insns.txt +++ b/test/MC/Disassembler/SystemZ/insns.txt @@ -541,6 +541,36 @@ # CHECK: alg %r15, 0 0xe3 0xf0 0x00 0x00 0x00 0x0a +# CHECK: alghsik %r0, %r1, -32768 +0xec 0x01 0x80 0x00 0x00 0xdb + +# CHECK: alghsik %r2, %r3, -1 +0xec 0x23 0xff 0xff 0x00 0xdb + +# CHECK: alghsik %r4, %r5, 0 +0xec 0x45 0x00 0x00 0x00 0xdb + +# CHECK: alghsik %r6, %r7, 1 +0xec 0x67 0x00 0x01 0x00 0xdb + +# CHECK: alghsik %r8, %r15, 32767 +0xec 0x8f 0x7f 0xff 0x00 0xdb + +# CHECK: alhsik %r0, %r1, -32768 +0xec 0x01 0x80 0x00 0x00 0xda + +# CHECK: alhsik %r2, %r3, -1 +0xec 0x23 0xff 0xff 0x00 0xda + +# CHECK: alhsik %r4, %r5, 0 +0xec 0x45 0x00 0x00 0x00 0xda + +# CHECK: alhsik %r6, %r7, 1 +0xec 0x67 0x00 0x01 0x00 0xda + +# CHECK: alhsik %r8, %r15, 32767 +0xec 0x8f 0x7f 0xff 0x00 0xda + # CHECK: alr %r0, %r0 0x1e 0x00 diff --git a/test/MC/SystemZ/insn-bad.s b/test/MC/SystemZ/insn-bad.s index 4caa5dc74a2..f8900566778 100644 --- a/test/MC/SystemZ/insn-bad.s +++ b/test/MC/SystemZ/insn-bad.s @@ -160,6 +160,16 @@ alfi %r0, -1 alfi %r0, (1 << 32) +#CHECK: error: {{(instruction requires: distinct-ops)?}} +#CHECK: alghsik %r1, %r2, 3 + + alghsik %r1, %r2, 3 + +#CHECK: error: {{(instruction requires: distinct-ops)?}} +#CHECK: alhsik %r1, %r2, 3 + + alhsik %r1, %r2, 3 + #CHECK: error: invalid operand #CHECK: alg %r0, -524289 #CHECK: error: invalid operand diff --git a/test/MC/SystemZ/insn-good-z196.s b/test/MC/SystemZ/insn-good-z196.s index 7a686a3f256..422c689e934 100644 --- a/test/MC/SystemZ/insn-good-z196.s +++ b/test/MC/SystemZ/insn-good-z196.s @@ -49,6 +49,24 @@ ahik %r15, %r0, 0 ahik %r7, %r8, -16 +#CHECK: alghsik %r0, %r0, -32768 # encoding: [0xec,0x00,0x80,0x00,0x00,0xdb] +#CHECK: alghsik %r0, %r0, -1 # encoding: [0xec,0x00,0xff,0xff,0x00,0xdb] +#CHECK: alghsik %r0, %r0, 0 # encoding: [0xec,0x00,0x00,0x00,0x00,0xdb] +#CHECK: alghsik %r0, %r0, 1 # encoding: [0xec,0x00,0x00,0x01,0x00,0xdb] +#CHECK: alghsik %r0, %r0, 32767 # encoding: [0xec,0x00,0x7f,0xff,0x00,0xdb] +#CHECK: alghsik %r0, %r15, 0 # encoding: [0xec,0x0f,0x00,0x00,0x00,0xdb] +#CHECK: alghsik %r15, %r0, 0 # encoding: [0xec,0xf0,0x00,0x00,0x00,0xdb] +#CHECK: alghsik %r7, %r8, -16 # encoding: [0xec,0x78,0xff,0xf0,0x00,0xdb] + + alghsik %r0, %r0, -32768 + alghsik %r0, %r0, -1 + alghsik %r0, %r0, 0 + alghsik %r0, %r0, 1 + alghsik %r0, %r0, 32767 + alghsik %r0, %r15, 0 + alghsik %r15, %r0, 0 + alghsik %r7, %r8, -16 + #CHECK: algrk %r0, %r0, %r0 # encoding: [0xb9,0xea,0x00,0x00] #CHECK: algrk %r0, %r0, %r15 # encoding: [0xb9,0xea,0xf0,0x00] #CHECK: algrk %r0, %r15, %r0 # encoding: [0xb9,0xea,0x00,0x0f] @@ -61,6 +79,24 @@ algrk %r15,%r0,%r0 algrk %r7,%r8,%r9 +#CHECK: alhsik %r0, %r0, -32768 # encoding: [0xec,0x00,0x80,0x00,0x00,0xda] +#CHECK: alhsik %r0, %r0, -1 # encoding: [0xec,0x00,0xff,0xff,0x00,0xda] +#CHECK: alhsik %r0, %r0, 0 # encoding: [0xec,0x00,0x00,0x00,0x00,0xda] +#CHECK: alhsik %r0, %r0, 1 # encoding: [0xec,0x00,0x00,0x01,0x00,0xda] +#CHECK: alhsik %r0, %r0, 32767 # encoding: [0xec,0x00,0x7f,0xff,0x00,0xda] +#CHECK: alhsik %r0, %r15, 0 # encoding: [0xec,0x0f,0x00,0x00,0x00,0xda] +#CHECK: alhsik %r15, %r0, 0 # encoding: [0xec,0xf0,0x00,0x00,0x00,0xda] +#CHECK: alhsik %r7, %r8, -16 # encoding: [0xec,0x78,0xff,0xf0,0x00,0xda] + + alhsik %r0, %r0, -32768 + alhsik %r0, %r0, -1 + alhsik %r0, %r0, 0 + alhsik %r0, %r0, 1 + alhsik %r0, %r0, 32767 + alhsik %r0, %r15, 0 + alhsik %r15, %r0, 0 + alhsik %r7, %r8, -16 + #CHECK: alrk %r0, %r0, %r0 # encoding: [0xb9,0xfa,0x00,0x00] #CHECK: alrk %r0, %r0, %r15 # encoding: [0xb9,0xfa,0xf0,0x00] #CHECK: alrk %r0, %r15, %r0 # encoding: [0xb9,0xfa,0x00,0x0f] -- 2.34.1