3 * Test rig for bits header
5 * (c) 2000 Straylight/Edgeware
8 /*----- Licensing notice --------------------------------------------------*
10 * This file is part of the mLib utilities library.
12 * mLib is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU Library General Public License as
14 * published by the Free Software Foundation; either version 2 of the
15 * License, or (at your option) any later version.
17 * mLib is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU Library General Public License for more details.
22 * You should have received a copy of the GNU Library General Public
23 * License along with mLib; if not, write to the Free
24 * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
28 /*----- Header files ------------------------------------------------------*/
31 #include "tvec-types.h"
35 /*----- Main code ---------------------------------------------------------*/
43 static const struct tvec_urange ur_eight = { 8, 8 };
44 static const struct tvec_urange ur_shift = { 0, 63 };
46 static const struct tvec_regdef shift_regs[] = {
47 { "x", &tvty_bytes, RX, 0, { &ur_eight } },
48 { "n", &tvty_uint, RN, 0, { &ur_shift } },
49 { "z", &tvty_bytes, RZ, 0, { &ur_eight } },
53 #define SHIFTOPS(_) _(lsl, LSL) _(lsr, LSR) _(rol, ROL) _(ror, ROR)
54 #define TSHIFT(op, OP) \
55 static void test_##op(const struct tvec_reg *in, struct tvec_reg *out, \
60 LOAD64_(x, in[RX].v.bytes.p); \
61 OP##64_(x, x, in[RN].v.u); \
62 tvec_allocbytes(&out[RZ].v, 8); \
63 STORE64_(out[RZ].v.bytes.p, x); \
65 static const struct tvec_test op##_test = \
66 { #op "64", shift_regs, 0, test_##op };
70 static const struct tvec_regdef arith_regs[] = {
71 { "x", &tvty_bytes, RX, 0, { &ur_eight } },
72 { "y", &tvty_bytes, RY, 0, { &ur_eight } },
73 { "z", &tvty_bytes, RZ, 0, { &ur_eight } },
77 #define ARITHOPS(_) _(add, ADD) _(sub, SUB)
78 #define TARITH(op, OP) \
79 static void test_##op(const struct tvec_reg *in, struct tvec_reg *out, \
84 LOAD64_(x, in[RX].v.bytes.p); LOAD64_(y, in[RY].v.bytes.p); \
86 tvec_allocbytes(&out[RZ].v, 8); \
87 STORE64_(out[RZ].v.bytes.p, x); \
89 static const struct tvec_test op##_test = \
90 { #op "64", arith_regs, 0, test_##op };
95 static const struct tvec_test *const tests[] = {
96 #define TESTENT(op, OP) &op##_test,
103 static const struct tvec_config testconfig =
104 { tests, NROUT, NREG, sizeof(struct tvec_reg) };
106 int main(int argc, char *argv[])
107 { return (tvec_main(argc, argv, &testconfig, 0)); }
109 /*----- That's all, folks -------------------------------------------------*/