/*----- Header files ------------------------------------------------------*/
-#include "bits.h"
#include "tvec.h"
+#include "tvec-types.h"
+
+#include "bits.h"
/*----- Main code ---------------------------------------------------------*/
RN = RY
};
-#define TSHIFT(OP) \
- static void test_##OP(const struct tvec_reg *in, struct tvec_reg *out, \
+static const struct tvec_urange ur_eight = { 8, 8 };
+static const struct tvec_urange ur_shift = { 0, 63 };
+
+static const struct tvec_regdef shift_regs[] = {
+ { "x", &tvty_bytes, RX, 0, { &ur_eight } },
+ { "n", &tvty_uint, RN, 0, { &ur_shift } },
+ { "z", &tvty_bytes, RZ, 0, { &ur_eight } },
+ TVEC_ENDREGS
+};
+
+#define SHIFTOPS(_) _(lsl, LSL) _(lsr, LSR) _(rol, ROL) _(ror, ROR)
+#define TSHIFT(op, OP) \
+ static void test_##op(const struct tvec_reg *in, struct tvec_reg *out, \
void *ctx) \
{ \
kludge64 x; \
OP##64_(x, x, in[RN].v.u); \
tvec_allocbytes(&out[RZ].v, 8); \
STORE64_(out[RZ].v.bytes.p, x); \
- }
+ } \
+ static const struct tvec_test op##_test = \
+ { #op "64", shift_regs, 0, test_##op };
+SHIFTOPS(TSHIFT)
+#undef TSHIFT
-#define TARITH(OP) \
- static void test_##OP(const struct tvec_reg *in, struct tvec_reg *out, \
+static const struct tvec_regdef arith_regs[] = {
+ { "x", &tvty_bytes, RX, 0, { &ur_eight } },
+ { "y", &tvty_bytes, RY, 0, { &ur_eight } },
+ { "z", &tvty_bytes, RZ, 0, { &ur_eight } },
+ TVEC_ENDREGS
+};
+
+#define ARITHOPS(_) _(add, ADD) _(sub, SUB)
+#define TARITH(op, OP) \
+ static void test_##op(const struct tvec_reg *in, struct tvec_reg *out, \
void *ctx) \
{ \
kludge64 x, y; \
OP##64(x, x, y); \
tvec_allocbytes(&out[RZ].v, 8); \
STORE64_(out[RZ].v.bytes.p, x); \
- }
-
-TSHIFT(LSL)
-TSHIFT(LSR)
-TSHIFT(ROL)
-TSHIFT(ROR)
-TARITH(ADD)
-TARITH(SUB)
+ } \
+ static const struct tvec_test op##_test = \
+ { #op "64", arith_regs, 0, test_##op };
-static const struct tvec_urange ur_eight = { 8, 8 };
-static const struct tvec_urange ur_shift = { 0, 63 };
-static const struct tvec_regdef shift_regs[] = {
- { "x", RX, &tvty_bytes, 0, { &ur_eight } },
- { "n", RN, &tvty_uint, 0, { &ur_shift } },
- { "z", RZ, &tvty_bytes, 0, { &ur_eight } },
- { 0, 0, 0, 0 }
-};
-static const struct tvec_regdef arith_regs[] = {
- { "x", RX, &tvty_bytes, 0, { &ur_eight } },
- { "y", RY, &tvty_bytes, 0, { &ur_eight } },
- { "z", RZ, &tvty_bytes, 0, { &ur_eight } },
- { 0, 0, 0, 0 }
-};
+ARITHOPS(TARITH)
+#undef TARITH
-static const struct tvec_test tests[] = {
- { "lsl64", shift_regs, 0, test_LSL },
- { "lsr64", shift_regs, 0, test_LSR },
- { "rol64", shift_regs, 0, test_ROL },
- { "ror64", shift_regs, 0, test_ROR },
- { "add64", arith_regs, 0, test_ADD },
- { "sub64", arith_regs, 0, test_SUB },
- { 0, 0, 0, 0 }
+static const struct tvec_test *const tests[] = {
+#define TESTENT(op, OP) &op##_test,
+ SHIFTOPS(TESTENT)
+ ARITHOPS(TESTENT)
+#undef TESTENT
+ 0
};
static const struct tvec_config testconfig =