xref: /openbmc/qemu/target/hexagon/iclass.c (revision 471d4b2d)
1*471d4b2dSTaylor Simpson /*
2*471d4b2dSTaylor Simpson  *  Copyright(c) 2019-2021 Qualcomm Innovation Center, Inc. All Rights Reserved.
3*471d4b2dSTaylor Simpson  *
4*471d4b2dSTaylor Simpson  *  This program is free software; you can redistribute it and/or modify
5*471d4b2dSTaylor Simpson  *  it under the terms of the GNU General Public License as published by
6*471d4b2dSTaylor Simpson  *  the Free Software Foundation; either version 2 of the License, or
7*471d4b2dSTaylor Simpson  *  (at your option) any later version.
8*471d4b2dSTaylor Simpson  *
9*471d4b2dSTaylor Simpson  *  This program is distributed in the hope that it will be useful,
10*471d4b2dSTaylor Simpson  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
11*471d4b2dSTaylor Simpson  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12*471d4b2dSTaylor Simpson  *  GNU General Public License for more details.
13*471d4b2dSTaylor Simpson  *
14*471d4b2dSTaylor Simpson  *  You should have received a copy of the GNU General Public License
15*471d4b2dSTaylor Simpson  *  along with this program; if not, see <http://www.gnu.org/licenses/>.
16*471d4b2dSTaylor Simpson  */
17*471d4b2dSTaylor Simpson 
18*471d4b2dSTaylor Simpson #include "qemu/osdep.h"
19*471d4b2dSTaylor Simpson #include "iclass.h"
20*471d4b2dSTaylor Simpson 
21*471d4b2dSTaylor Simpson static const SlotMask iclass_info[] = {
22*471d4b2dSTaylor Simpson 
23*471d4b2dSTaylor Simpson #define DEF_PP_ICLASS32(TYPE, SLOTS, UNITS) \
24*471d4b2dSTaylor Simpson     [ICLASS_FROM_TYPE(TYPE)] = SLOTS_##SLOTS,
25*471d4b2dSTaylor Simpson #define DEF_EE_ICLASS32(TYPE, SLOTS, UNITS) \
26*471d4b2dSTaylor Simpson     [ICLASS_FROM_TYPE(TYPE)] = SLOTS_##SLOTS,
27*471d4b2dSTaylor Simpson #include "imported/iclass.def"
28*471d4b2dSTaylor Simpson #undef DEF_PP_ICLASS32
29*471d4b2dSTaylor Simpson #undef DEF_EE_ICLASS32
30*471d4b2dSTaylor Simpson };
31*471d4b2dSTaylor Simpson 
32*471d4b2dSTaylor Simpson SlotMask find_iclass_slots(Opcode opcode, int itype)
33*471d4b2dSTaylor Simpson {
34*471d4b2dSTaylor Simpson     /* There are some exceptions to what the iclass dictates */
35*471d4b2dSTaylor Simpson     if (GET_ATTRIB(opcode, A_ICOP)) {
36*471d4b2dSTaylor Simpson         return SLOTS_2;
37*471d4b2dSTaylor Simpson     } else if (GET_ATTRIB(opcode, A_RESTRICT_SLOT0ONLY)) {
38*471d4b2dSTaylor Simpson         return SLOTS_0;
39*471d4b2dSTaylor Simpson     } else if (GET_ATTRIB(opcode, A_RESTRICT_SLOT1ONLY)) {
40*471d4b2dSTaylor Simpson         return SLOTS_1;
41*471d4b2dSTaylor Simpson     } else if (GET_ATTRIB(opcode, A_RESTRICT_SLOT2ONLY)) {
42*471d4b2dSTaylor Simpson         return SLOTS_2;
43*471d4b2dSTaylor Simpson     } else if (GET_ATTRIB(opcode, A_RESTRICT_SLOT3ONLY)) {
44*471d4b2dSTaylor Simpson         return SLOTS_3;
45*471d4b2dSTaylor Simpson     } else if (GET_ATTRIB(opcode, A_COF) &&
46*471d4b2dSTaylor Simpson                GET_ATTRIB(opcode, A_INDIRECT) &&
47*471d4b2dSTaylor Simpson                !GET_ATTRIB(opcode, A_MEMLIKE) &&
48*471d4b2dSTaylor Simpson                !GET_ATTRIB(opcode, A_MEMLIKE_PACKET_RULES)) {
49*471d4b2dSTaylor Simpson         return SLOTS_2;
50*471d4b2dSTaylor Simpson     } else if (GET_ATTRIB(opcode, A_RESTRICT_NOSLOT1)) {
51*471d4b2dSTaylor Simpson         return SLOTS_0;
52*471d4b2dSTaylor Simpson     } else if ((opcode == J2_trap0) ||
53*471d4b2dSTaylor Simpson                (opcode == Y2_isync) ||
54*471d4b2dSTaylor Simpson                (opcode == J2_pause) || (opcode == J4_hintjumpr)) {
55*471d4b2dSTaylor Simpson         return SLOTS_2;
56*471d4b2dSTaylor Simpson     } else if ((itype == ICLASS_V2LDST) && (GET_ATTRIB(opcode, A_STORE))) {
57*471d4b2dSTaylor Simpson         return SLOTS_01;
58*471d4b2dSTaylor Simpson     } else if ((itype == ICLASS_V2LDST) && (!GET_ATTRIB(opcode, A_STORE))) {
59*471d4b2dSTaylor Simpson         return SLOTS_01;
60*471d4b2dSTaylor Simpson     } else if (GET_ATTRIB(opcode, A_CRSLOT23)) {
61*471d4b2dSTaylor Simpson         return SLOTS_23;
62*471d4b2dSTaylor Simpson     } else if (GET_ATTRIB(opcode, A_RESTRICT_PREFERSLOT0)) {
63*471d4b2dSTaylor Simpson         return SLOTS_0;
64*471d4b2dSTaylor Simpson     } else if (GET_ATTRIB(opcode, A_SUBINSN)) {
65*471d4b2dSTaylor Simpson         return SLOTS_01;
66*471d4b2dSTaylor Simpson     } else if (GET_ATTRIB(opcode, A_CALL)) {
67*471d4b2dSTaylor Simpson         return SLOTS_23;
68*471d4b2dSTaylor Simpson     } else if ((opcode == J4_jumpseti) || (opcode == J4_jumpsetr)) {
69*471d4b2dSTaylor Simpson         return SLOTS_23;
70*471d4b2dSTaylor Simpson     } else {
71*471d4b2dSTaylor Simpson         return iclass_info[itype];
72*471d4b2dSTaylor Simpson     }
73*471d4b2dSTaylor Simpson }
74