1 /* Copyright (C) 2000-2016 Free Software Foundation, Inc.
2 Contributed by Alexandre Oliva <aoliva@cygnus.com>
3
4 This file is free software; you can redistribute it and/or modify it
5 under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 3 of the License, or
7 (at your option) any later version.
8
9 This program is distributed in the hope that it will be useful, but
10 WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */
17
18 /* Generator of tests for insns introduced in AM33 2.0.
19
20 See the following file for usage and documentation. */
21 #include "../all/test-gen.c"
22
23 /* Define any char*[]s you may need here. */
24 char *named_regs[] = { "a", "b", "c", "d" };
25
26 /* Define helper macros to generate register accesses here. */
27 #define namedregs(shift) \
28 reg_r (named_regs, shift, 0x3, mk_get_bits (2u))
29 #define numberedregs(shift) \
30 reg_p ("f", shift, mk_get_bits (2u))
31
32 /* Define helper functions here. */
33 int
jmp_cond(func_arg * arg,insn_data * data)34 jmp_cond (func_arg * arg, insn_data * data)
35 #define jmp_cond(shift) { jmp_cond, { i1: shift } }
36 {
37 static const char conds[4][2] = { "z", "n", "g", "l" };
38 unsigned val = get_bits (2u);
39
40 data->as_in = data->dis_out = strdup (conds[val]);
41 data->bits = val << arg->i1;
42
43 /* Do not forget to return 0, otherwise the insn will be skipped. */
44 return 0;
45 }
46
47 /* Define convenience wrappers to define_insn. */
48 #define cond_jmp_insn(insname, word, funcs...) \
49 define_insn (insname, \
50 insn_size_bits (insname, 1, word), \
51 jmp_cond (4), \
52 tab, \
53 ## funcs)
54
55 /* Define insns. */
56 cond_jmp_insn (j, 0x40, numberedregs(2), comma, namedregs (0));
57
58 /* Define an insn group. */
59 func *jmp_insns[] =
60 {
61 insn (j),
62 0
63 };
64
65 /* Define the set of all groups. */
66 group_t
67 groups[] =
68 {
69 { "jumps", jmp_insns },
70 { 0 }
71 };
72
73 int
main(int argc,char * argv[])74 main (int argc, char *argv[])
75 {
76 FILE *as_in = stdout, *dis_out = stderr;
77
78 /* Check whether we're filtering insns. */
79 if (argc > 1)
80 skip_list = argv + 1;
81
82 /* Output assembler header. */
83 fputs ("\t.text\n"
84 "\t.align\n",
85 as_in);
86 /* Output comments for the testsuite-driver and the initial
87 disassembler output. */
88 fputs ("#objdump: -dr --prefix-address --show-raw-insn\n"
89 "#name: Foo Digital Processor\n"
90 "#as: -mfood\n"
91 "\n"
92 "# Test the instructions of FooD\n"
93 "\n"
94 ".*: +file format.*food.*\n"
95 "\n"
96 "Disassembly of section .text:\n",
97 dis_out);
98
99 /* Now emit all (selected) insns. */
100 output_groups (groups, as_in, dis_out);
101
102 exit (0);
103 }
104