xref: /openbmc/qemu/target/hexagon/opcodes.c (revision 2f95279a)
1 /*
2  *  Copyright(c) 2019-2021 Qualcomm Innovation Center, Inc. All Rights Reserved.
3  *
4  *  This program is free software; you can redistribute it and/or modify
5  *  it under the terms of the GNU General Public License as published by
6  *  the Free Software Foundation; either version 2 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,
10  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  *  GNU 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, see <http://www.gnu.org/licenses/>.
16  */
17 
18 /*
19  * opcodes.c
20  *
21  * data tables generated automatically
22  * Maybe some functions too
23  */
24 
25 #include "qemu/osdep.h"
26 #include "attribs.h"
27 #include "decode.h"
28 
29 #define VEC_DESCR(A, B, C) DESCR(A, B, C)
30 #define DONAME(X) #X
31 
32 const char * const opcode_names[] = {
33 #define OPCODE(IID) DONAME(IID)
34 #include "opcodes_def_generated.h.inc"
35     NULL
36 #undef OPCODE
37 };
38 
39 
40 DECLARE_BITMAP(opcode_attribs[XX_LAST_OPCODE], A_ZZ_LASTATTRIB);
41 
42 static void init_attribs(int tag, ...)
43 {
44     va_list ap;
45     int attr;
46     va_start(ap, tag);
47     while ((attr = va_arg(ap, int)) != 0) {
48         set_bit(attr, opcode_attribs[tag]);
49     }
50     va_end(ap);
51 }
52 
53 const OpcodeEncoding opcode_encodings[] = {
54 #define DEF_ENC32(OPCODE, ENCSTR) \
55     [OPCODE] = { .encoding = ENCSTR },
56 
57 #define DEF_ENC_SUBINSN(OPCODE, CLASS, ENCSTR) \
58     [OPCODE] = { .encoding = ENCSTR, .enc_class = CLASS },
59 
60 #define DEF_EXT_ENC(OPCODE, CLASS, ENCSTR) \
61     [OPCODE] = { .encoding = ENCSTR, .enc_class = CLASS },
62 
63 #include "imported/encode.def"
64 
65 #undef DEF_ENC32
66 #undef DEF_ENC_SUBINSN
67 #undef DEF_EXT_ENC
68 };
69 
70 void opcode_init(void)
71 {
72     init_attribs(0, 0);
73 
74 #define ATTRIBS(...) , ## __VA_ARGS__, 0
75 #define OP_ATTRIB(TAG, ARGS) init_attribs(TAG ARGS);
76 #include "op_attribs_generated.h.inc"
77 #undef OP_ATTRIB
78 #undef ATTRIBS
79 }
80