Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

powerpc/test_emulate_step: Add testcases for divde[.] and divdeu[.] instructions

Add testcases for divde, divde., divdeu, divdeu. emulated instructions
to cover few scenarios,
- with same dividend and divisor to have undefine RT
for divdeu[.]
- with divide by zero to have undefine RT for both
divde[.] and divdeu[.]
- with negative dividend to cover -|divisor| < r <= 0 if
the dividend is negative for divde[.]
- normal case with proper dividend and divisor for both
divde[.] and divdeu[.]

Signed-off-by: Balamuruhan S <bala24@linux.ibm.com>
Reviewed-by: Sandipan Das <sandipan@linux.ibm.com>
Acked-by: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20200728130308.1790982-4-bala24@linux.ibm.com

authored by

Balamuruhan S and committed by
Michael Ellerman
b859c95c 151c32bf

+156
+156
arch/powerpc/lib/test_emulate_step.c
··· 1020 1020 } 1021 1021 }, 1022 1022 { 1023 + .mnemonic = "divde", 1024 + .subtests = { 1025 + { 1026 + .descr = "RA = LONG_MIN, RB = LONG_MIN", 1027 + .instr = ppc_inst(PPC_RAW_DIVDE(20, 21, 22)), 1028 + .regs = { 1029 + .gpr[21] = LONG_MIN, 1030 + .gpr[22] = LONG_MIN, 1031 + } 1032 + }, 1033 + { 1034 + .descr = "RA = 1L, RB = 0", 1035 + .instr = ppc_inst(PPC_RAW_DIVDE(20, 21, 22)), 1036 + .flags = IGNORE_GPR(20), 1037 + .regs = { 1038 + .gpr[21] = 1L, 1039 + .gpr[22] = 0, 1040 + } 1041 + }, 1042 + { 1043 + .descr = "RA = LONG_MIN, RB = LONG_MAX", 1044 + .instr = ppc_inst(PPC_RAW_DIVDE(20, 21, 22)), 1045 + .regs = { 1046 + .gpr[21] = LONG_MIN, 1047 + .gpr[22] = LONG_MAX, 1048 + } 1049 + } 1050 + } 1051 + }, 1052 + { 1053 + .mnemonic = "divde.", 1054 + .subtests = { 1055 + { 1056 + .descr = "RA = LONG_MIN, RB = LONG_MIN", 1057 + .instr = ppc_inst(PPC_RAW_DIVDE_DOT(20, 21, 22)), 1058 + .regs = { 1059 + .gpr[21] = LONG_MIN, 1060 + .gpr[22] = LONG_MIN, 1061 + } 1062 + }, 1063 + { 1064 + .descr = "RA = 1L, RB = 0", 1065 + .instr = ppc_inst(PPC_RAW_DIVDE_DOT(20, 21, 22)), 1066 + .flags = IGNORE_GPR(20), 1067 + .regs = { 1068 + .gpr[21] = 1L, 1069 + .gpr[22] = 0, 1070 + } 1071 + }, 1072 + { 1073 + .descr = "RA = LONG_MIN, RB = LONG_MAX", 1074 + .instr = ppc_inst(PPC_RAW_DIVDE_DOT(20, 21, 22)), 1075 + .regs = { 1076 + .gpr[21] = LONG_MIN, 1077 + .gpr[22] = LONG_MAX, 1078 + } 1079 + } 1080 + } 1081 + }, 1082 + { 1083 + .mnemonic = "divdeu", 1084 + .subtests = { 1085 + { 1086 + .descr = "RA = LONG_MIN, RB = LONG_MIN", 1087 + .instr = ppc_inst(PPC_RAW_DIVDEU(20, 21, 22)), 1088 + .flags = IGNORE_GPR(20), 1089 + .regs = { 1090 + .gpr[21] = LONG_MIN, 1091 + .gpr[22] = LONG_MIN, 1092 + } 1093 + }, 1094 + { 1095 + .descr = "RA = 1L, RB = 0", 1096 + .instr = ppc_inst(PPC_RAW_DIVDEU(20, 21, 22)), 1097 + .flags = IGNORE_GPR(20), 1098 + .regs = { 1099 + .gpr[21] = 1L, 1100 + .gpr[22] = 0, 1101 + } 1102 + }, 1103 + { 1104 + .descr = "RA = LONG_MIN, RB = LONG_MAX", 1105 + .instr = ppc_inst(PPC_RAW_DIVDEU(20, 21, 22)), 1106 + .regs = { 1107 + .gpr[21] = LONG_MIN, 1108 + .gpr[22] = LONG_MAX, 1109 + } 1110 + }, 1111 + { 1112 + .descr = "RA = LONG_MAX - 1, RB = LONG_MAX", 1113 + .instr = ppc_inst(PPC_RAW_DIVDEU(20, 21, 22)), 1114 + .regs = { 1115 + .gpr[21] = LONG_MAX - 1, 1116 + .gpr[22] = LONG_MAX, 1117 + } 1118 + }, 1119 + { 1120 + .descr = "RA = LONG_MIN + 1, RB = LONG_MIN", 1121 + .instr = ppc_inst(PPC_RAW_DIVDEU(20, 21, 22)), 1122 + .flags = IGNORE_GPR(20), 1123 + .regs = { 1124 + .gpr[21] = LONG_MIN + 1, 1125 + .gpr[22] = LONG_MIN, 1126 + } 1127 + } 1128 + } 1129 + }, 1130 + { 1131 + .mnemonic = "divdeu.", 1132 + .subtests = { 1133 + { 1134 + .descr = "RA = LONG_MIN, RB = LONG_MIN", 1135 + .instr = ppc_inst(PPC_RAW_DIVDEU_DOT(20, 21, 22)), 1136 + .flags = IGNORE_GPR(20), 1137 + .regs = { 1138 + .gpr[21] = LONG_MIN, 1139 + .gpr[22] = LONG_MIN, 1140 + } 1141 + }, 1142 + { 1143 + .descr = "RA = 1L, RB = 0", 1144 + .instr = ppc_inst(PPC_RAW_DIVDEU_DOT(20, 21, 22)), 1145 + .flags = IGNORE_GPR(20), 1146 + .regs = { 1147 + .gpr[21] = 1L, 1148 + .gpr[22] = 0, 1149 + } 1150 + }, 1151 + { 1152 + .descr = "RA = LONG_MIN, RB = LONG_MAX", 1153 + .instr = ppc_inst(PPC_RAW_DIVDEU_DOT(20, 21, 22)), 1154 + .regs = { 1155 + .gpr[21] = LONG_MIN, 1156 + .gpr[22] = LONG_MAX, 1157 + } 1158 + }, 1159 + { 1160 + .descr = "RA = LONG_MAX - 1, RB = LONG_MAX", 1161 + .instr = ppc_inst(PPC_RAW_DIVDEU_DOT(20, 21, 22)), 1162 + .regs = { 1163 + .gpr[21] = LONG_MAX - 1, 1164 + .gpr[22] = LONG_MAX, 1165 + } 1166 + }, 1167 + { 1168 + .descr = "RA = LONG_MIN + 1, RB = LONG_MIN", 1169 + .instr = ppc_inst(PPC_RAW_DIVDEU_DOT(20, 21, 22)), 1170 + .flags = IGNORE_GPR(20), 1171 + .regs = { 1172 + .gpr[21] = LONG_MIN + 1, 1173 + .gpr[22] = LONG_MIN, 1174 + } 1175 + } 1176 + } 1177 + }, 1178 + { 1023 1179 .mnemonic = "paddi", 1024 1180 .cpu_feature = CPU_FTR_ARCH_31, 1025 1181 .subtests = {