powerpc: sstep: Add tests for add[.] instruction
authorSandipan Das <sandipan@linux.ibm.com>
Wed, 20 Feb 2019 06:56:59 +0000 (12:26 +0530)
committerMichael Ellerman <mpe@ellerman.id.au>
Sat, 23 Feb 2019 10:04:31 +0000 (21:04 +1100)
This adds test cases for the add[.] instruction.

Signed-off-by: Sandipan Das <sandipan@linux.ibm.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
arch/powerpc/lib/test_emulate_step.c

index e9f762ac825ff30a9d1ede61a8da9262496cee2f..ee6d5ac3b6157f7fd3a6065320fe0e74a8c8c2a8 100644 (file)
                                        ___PPC_RA(a) | ___PPC_RB(b))
 #define TEST_LXVD2X(s, a, b)   (PPC_INST_LXVD2X | VSX_XX1((s), R##a, R##b))
 #define TEST_STXVD2X(s, a, b)  (PPC_INST_STXVD2X | VSX_XX1((s), R##a, R##b))
+#define TEST_ADD(t, a, b)      (PPC_INST_ADD | ___PPC_RT(t) |          \
+                                       ___PPC_RA(a) | ___PPC_RB(b))
+#define TEST_ADD_DOT(t, a, b)  (PPC_INST_ADD | ___PPC_RT(t) |          \
+                                       ___PPC_RA(a) | ___PPC_RB(b) | 0x1)
 
 #define MAX_SUBTESTS   16
 
@@ -473,6 +477,178 @@ static struct compute_test compute_tests[] = {
                                }
                        }
                }
+       },
+       {
+               .mnemonic = "add",
+               .subtests = {
+                       {
+                               .descr = "RA = LONG_MIN, RB = LONG_MIN",
+                               .instr = TEST_ADD(20, 21, 22),
+                               .regs = {
+                                       .gpr[21] = LONG_MIN,
+                                       .gpr[22] = LONG_MIN,
+                               }
+                       },
+                       {
+                               .descr = "RA = LONG_MIN, RB = LONG_MAX",
+                               .instr = TEST_ADD(20, 21, 22),
+                               .regs = {
+                                       .gpr[21] = LONG_MIN,
+                                       .gpr[22] = LONG_MAX,
+                               }
+                       },
+                       {
+                               .descr = "RA = LONG_MAX, RB = LONG_MAX",
+                               .instr = TEST_ADD(20, 21, 22),
+                               .regs = {
+                                       .gpr[21] = LONG_MAX,
+                                       .gpr[22] = LONG_MAX,
+                               }
+                       },
+                       {
+                               .descr = "RA = ULONG_MAX, RB = ULONG_MAX",
+                               .instr = TEST_ADD(20, 21, 22),
+                               .regs = {
+                                       .gpr[21] = ULONG_MAX,
+                                       .gpr[22] = ULONG_MAX,
+                               }
+                       },
+                       {
+                               .descr = "RA = ULONG_MAX, RB = 0x1",
+                               .instr = TEST_ADD(20, 21, 22),
+                               .regs = {
+                                       .gpr[21] = ULONG_MAX,
+                                       .gpr[22] = 0x1,
+                               }
+                       },
+                       {
+                               .descr = "RA = INT_MIN, RB = INT_MIN",
+                               .instr = TEST_ADD(20, 21, 22),
+                               .regs = {
+                                       .gpr[21] = INT_MIN,
+                                       .gpr[22] = INT_MIN,
+                               }
+                       },
+                       {
+                               .descr = "RA = INT_MIN, RB = INT_MAX",
+                               .instr = TEST_ADD(20, 21, 22),
+                               .regs = {
+                                       .gpr[21] = INT_MIN,
+                                       .gpr[22] = INT_MAX,
+                               }
+                       },
+                       {
+                               .descr = "RA = INT_MAX, RB = INT_MAX",
+                               .instr = TEST_ADD(20, 21, 22),
+                               .regs = {
+                                       .gpr[21] = INT_MAX,
+                                       .gpr[22] = INT_MAX,
+                               }
+                       },
+                       {
+                               .descr = "RA = UINT_MAX, RB = UINT_MAX",
+                               .instr = TEST_ADD(20, 21, 22),
+                               .regs = {
+                                       .gpr[21] = UINT_MAX,
+                                       .gpr[22] = UINT_MAX,
+                               }
+                       },
+                       {
+                               .descr = "RA = UINT_MAX, RB = 0x1",
+                               .instr = TEST_ADD(20, 21, 22),
+                               .regs = {
+                                       .gpr[21] = UINT_MAX,
+                                       .gpr[22] = 0x1,
+                               }
+                       }
+               }
+       },
+       {
+               .mnemonic = "add.",
+               .subtests = {
+                       {
+                               .descr = "RA = LONG_MIN, RB = LONG_MIN",
+                               .flags = IGNORE_CCR,
+                               .instr = TEST_ADD_DOT(20, 21, 22),
+                               .regs = {
+                                       .gpr[21] = LONG_MIN,
+                                       .gpr[22] = LONG_MIN,
+                               }
+                       },
+                       {
+                               .descr = "RA = LONG_MIN, RB = LONG_MAX",
+                               .instr = TEST_ADD_DOT(20, 21, 22),
+                               .regs = {
+                                       .gpr[21] = LONG_MIN,
+                                       .gpr[22] = LONG_MAX,
+                               }
+                       },
+                       {
+                               .descr = "RA = LONG_MAX, RB = LONG_MAX",
+                               .flags = IGNORE_CCR,
+                               .instr = TEST_ADD_DOT(20, 21, 22),
+                               .regs = {
+                                       .gpr[21] = LONG_MAX,
+                                       .gpr[22] = LONG_MAX,
+                               }
+                       },
+                       {
+                               .descr = "RA = ULONG_MAX, RB = ULONG_MAX",
+                               .instr = TEST_ADD_DOT(20, 21, 22),
+                               .regs = {
+                                       .gpr[21] = ULONG_MAX,
+                                       .gpr[22] = ULONG_MAX,
+                               }
+                       },
+                       {
+                               .descr = "RA = ULONG_MAX, RB = 0x1",
+                               .instr = TEST_ADD_DOT(20, 21, 22),
+                               .regs = {
+                                       .gpr[21] = ULONG_MAX,
+                                       .gpr[22] = 0x1,
+                               }
+                       },
+                       {
+                               .descr = "RA = INT_MIN, RB = INT_MIN",
+                               .instr = TEST_ADD_DOT(20, 21, 22),
+                               .regs = {
+                                       .gpr[21] = INT_MIN,
+                                       .gpr[22] = INT_MIN,
+                               }
+                       },
+                       {
+                               .descr = "RA = INT_MIN, RB = INT_MAX",
+                               .instr = TEST_ADD_DOT(20, 21, 22),
+                               .regs = {
+                                       .gpr[21] = INT_MIN,
+                                       .gpr[22] = INT_MAX,
+                               }
+                       },
+                       {
+                               .descr = "RA = INT_MAX, RB = INT_MAX",
+                               .instr = TEST_ADD_DOT(20, 21, 22),
+                               .regs = {
+                                       .gpr[21] = INT_MAX,
+                                       .gpr[22] = INT_MAX,
+                               }
+                       },
+                       {
+                               .descr = "RA = UINT_MAX, RB = UINT_MAX",
+                               .instr = TEST_ADD_DOT(20, 21, 22),
+                               .regs = {
+                                       .gpr[21] = UINT_MAX,
+                                       .gpr[22] = UINT_MAX,
+                               }
+                       },
+                       {
+                               .descr = "RA = UINT_MAX, RB = 0x1",
+                               .instr = TEST_ADD_DOT(20, 21, 22),
+                               .regs = {
+                                       .gpr[21] = UINT_MAX,
+                                       .gpr[22] = 0x1,
+                               }
+                       }
+               }
        }
 };