|
From: <sv...@va...> - 2012-11-16 18:58:17
|
carll 2012-11-16 18:58:08 +0000 (Fri, 16 Nov 2012)
New Revision: 13123
Log:
Valgrind, V-bit tester: Add support for Iop_CmpORD class iops
The Iop_CmpORD class of iops support the POWER specific comparison
instructions. The instructions take two 32-bit or 64-bit operands
and produce a result of the same size. However, only the lower bits
of the result are set by the instruction. The bits are set by the instruction
to indicate if the comparison is "less then", "greater then", or "equal".
This patch adds support to the V-bit tester to verify the propagation
of the undefined bits in the inputs to the output for the Iop_CmpORd iops.
The output bits are always set to undefined if any of the input bits are not
defined.
This patch is for bugzilla 310169
Modified files:
trunk/memcheck/tests/vbit-test/binary.c
trunk/memcheck/tests/vbit-test/irops.c
trunk/memcheck/tests/vbit-test/vbits.c
trunk/memcheck/tests/vbit-test/vbits.h
trunk/memcheck/tests/vbit-test/vtest.h
Modified: trunk/memcheck/tests/vbit-test/vbits.h (+1 -0)
===================================================================
--- trunk/memcheck/tests/vbit-test/vbits.h 2012-11-15 04:27:04 +00:00 (rev 13122)
+++ trunk/memcheck/tests/vbit-test/vbits.h 2012-11-16 18:58:08 +00:00 (rev 13123)
@@ -53,5 +53,6 @@
vbits_t shr_vbits(vbits_t, unsigned amount);
vbits_t sar_vbits(vbits_t, unsigned amount);
int completely_defined_vbits(vbits_t);
+vbits_t cmpord_vbits(unsigned v1_num_bits, unsigned v2_num_bits);
#endif // VBITS_H
Modified: trunk/memcheck/tests/vbit-test/vbits.c (+28 -0)
===================================================================
--- trunk/memcheck/tests/vbit-test/vbits.c 2012-11-15 04:27:04 +00:00 (rev 13122)
+++ trunk/memcheck/tests/vbit-test/vbits.c 2012-11-16 18:58:08 +00:00 (rev 13123)
@@ -740,3 +740,31 @@
new = left_vbits(new, new.num_bits);
return new;
}
+
+/* Return a value for the POWER Iop_CmpORD class iops */
+vbits_t
+cmpord_vbits(unsigned v1_num_bits, unsigned v2_num_bits)
+{
+ vbits_t new = { .num_bits = v1_num_bits };
+
+ /* Size of values being compared must be the same */
+ assert( v1_num_bits == v2_num_bits);
+
+ /* Comparison only produces 32-bit or 64-bit value where
+ * the lower 3 bits are set to indicate, less than, equal and greater then.
+ */
+ switch (v1_num_bits) {
+ case 32:
+ new.bits.u32 = 0xE;
+ break;
+
+ case 64:
+ new.bits.u64 = 0xE;
+ break;
+
+ default:
+ panic(__func__);
+ }
+
+ return new;
+}
Modified: trunk/memcheck/tests/vbit-test/irops.c (+4 -4)
===================================================================
--- trunk/memcheck/tests/vbit-test/irops.c 2012-11-15 04:27:04 +00:00 (rev 13122)
+++ trunk/memcheck/tests/vbit-test/irops.c 2012-11-16 18:58:08 +00:00 (rev 13123)
@@ -104,10 +104,10 @@
{ DEFOP(Iop_Left32, UNDEF_UNKNOWN), }, // not supported by mc_translate
{ DEFOP(Iop_Left64, UNDEF_UNKNOWN), }, // not supported by mc_translate
{ DEFOP(Iop_Max32U, UNDEF_UNKNOWN), }, // not supported by mc_translate
- { DEFOP(Iop_CmpORD32U, UNDEF_UNKNOWN), .s390x = 0, .amd64 = 0, .x86 = 0, .arm = 0, .ppc64 = 0, .ppc32 = 0, .mips32 = 0 }, // FIXME: add support in vbit-test
- { DEFOP(Iop_CmpORD64U, UNDEF_UNKNOWN), .s390x = 0, .amd64 = 0, .x86 = 0, .arm = 0, .ppc64 = 0, .ppc32 = 0, .mips32 = 0 }, // FIXME: add support in vbit-test
- { DEFOP(Iop_CmpORD32S, UNDEF_UNKNOWN), .s390x = 0, .amd64 = 0, .x86 = 0, .arm = 0, .ppc64 = 0, .ppc32 = 0, .mips32 = 0 }, // FIXME: add support in vbit-test
- { DEFOP(Iop_CmpORD64S, UNDEF_UNKNOWN), .s390x = 0, .amd64 = 0, .x86 = 0, .arm = 0, .ppc64 = 0, .ppc32 = 0, .mips32 = 0 }, // FIXME: add support in vbit-test
+ { DEFOP(Iop_CmpORD32U, UNDEF_ORD), .s390x = 0, .amd64 = 0, .x86 = 0, .arm = 0, .ppc64 = 1, .ppc32 = 1, .mips32 = 0 }, // support added in vbit-test
+ { DEFOP(Iop_CmpORD64U, UNDEF_ORD), .s390x = 0, .amd64 = 0, .x86 = 0, .arm = 0, .ppc64 = 1, .ppc32 = 0, .mips32 = 0 }, // support added in vbit-test
+ { DEFOP(Iop_CmpORD32S, UNDEF_ORD), .s390x = 0, .amd64 = 0, .x86 = 0, .arm = 0, .ppc64 = 1, .ppc32 = 1, .mips32 = 0 }, // support added in vbit-test
+ { DEFOP(Iop_CmpORD64S, UNDEF_ORD), .s390x = 0, .amd64 = 0, .x86 = 0, .arm = 0, .ppc64 = 1, .ppc32 = 0, .mips32 = 0 }, // support added in vbit-test
{ DEFOP(Iop_DivU32, UNDEF_ALL), .s390x = 0, .amd64 = 0, .x86 = 0, .arm = 0, .ppc64 = 1, .ppc32 = 1, .mips32 = 0 },
{ DEFOP(Iop_DivS32, UNDEF_ALL), .s390x = 0, .amd64 = 0, .x86 = 0, .arm = 0, .ppc64 = 1, .ppc32 = 1, .mips32 = 0 },
{ DEFOP(Iop_DivU64, UNDEF_ALL), .s390x = 0, .amd64 = 0, .x86 = 0, .arm = 0, .ppc64 = 1, .ppc32 = 0, .mips32 = 0 }, // ppc32 asserts
Modified: trunk/memcheck/tests/vbit-test/vtest.h (+2 -0)
===================================================================
--- trunk/memcheck/tests/vbit-test/vtest.h 2012-11-15 04:27:04 +00:00 (rev 13122)
+++ trunk/memcheck/tests/vbit-test/vtest.h 2012-11-16 18:58:08 +00:00 (rev 13123)
@@ -53,6 +53,8 @@
UNDEF_OR, // bitwise OR operation
UNDEF_AND, // bitwise AND operation
+ UNDEF_ORD, // Iop_CmpORD compare
+
// For IROps I don't know anything about
UNDEF_UNKNOWN
} undef_t;
Modified: trunk/memcheck/tests/vbit-test/binary.c (+9 -1)
===================================================================
--- trunk/memcheck/tests/vbit-test/binary.c 2012-11-15 04:27:04 +00:00 (rev 13122)
+++ trunk/memcheck/tests/vbit-test/binary.c 2012-11-16 18:58:08 +00:00 (rev 13123)
@@ -44,7 +44,6 @@
return new;
}
-
/* Check the result of a binary operation. */
static void
check_result_for_binary(const irop_t *op, const test_data_t *data)
@@ -155,6 +154,15 @@
break;
}
+ case UNDEF_ORD:
+ /* Set expected_vbits for the Iop_CmpORD category of iops.
+ * If any of the input bits is undefined the least significant
+ * three bits in the result will be set, i.e. 0xe.
+ */
+ expected_vbits = cmpord_vbits(opnd1->vbits.num_bits,
+ opnd2->vbits.num_bits);
+ break;
+
default:
panic(__func__);
}
|