1471d4b2dSTaylor Simpson /*
2*ed9b28fbSMatheus Tavares Bernardino * Copyright(c) 2019-2023 Qualcomm Innovation Center, Inc. All Rights Reserved.
3471d4b2dSTaylor Simpson *
4471d4b2dSTaylor Simpson * This program is free software; you can redistribute it and/or modify
5471d4b2dSTaylor Simpson * it under the terms of the GNU General Public License as published by
6471d4b2dSTaylor Simpson * the Free Software Foundation; either version 2 of the License, or
7471d4b2dSTaylor Simpson * (at your option) any later version.
8471d4b2dSTaylor Simpson *
9471d4b2dSTaylor Simpson * This program is distributed in the hope that it will be useful,
10471d4b2dSTaylor Simpson * but WITHOUT ANY WARRANTY; without even the implied warranty of
11471d4b2dSTaylor Simpson * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12471d4b2dSTaylor Simpson * GNU General Public License for more details.
13471d4b2dSTaylor Simpson *
14471d4b2dSTaylor Simpson * You should have received a copy of the GNU General Public License
15471d4b2dSTaylor Simpson * along with this program; if not, see <http://www.gnu.org/licenses/>.
16471d4b2dSTaylor Simpson */
17471d4b2dSTaylor Simpson
18471d4b2dSTaylor Simpson #include "qemu/osdep.h"
19471d4b2dSTaylor Simpson #include "iclass.h"
20471d4b2dSTaylor Simpson
21471d4b2dSTaylor Simpson static const SlotMask iclass_info[] = {
22471d4b2dSTaylor Simpson
23471d4b2dSTaylor Simpson #define DEF_PP_ICLASS32(TYPE, SLOTS, UNITS) \
24471d4b2dSTaylor Simpson [ICLASS_FROM_TYPE(TYPE)] = SLOTS_##SLOTS,
25471d4b2dSTaylor Simpson #define DEF_EE_ICLASS32(TYPE, SLOTS, UNITS) \
26471d4b2dSTaylor Simpson [ICLASS_FROM_TYPE(TYPE)] = SLOTS_##SLOTS,
27471d4b2dSTaylor Simpson #include "imported/iclass.def"
28471d4b2dSTaylor Simpson #undef DEF_PP_ICLASS32
29471d4b2dSTaylor Simpson #undef DEF_EE_ICLASS32
30471d4b2dSTaylor Simpson };
31471d4b2dSTaylor Simpson
find_iclass_slots(Opcode opcode,int itype)32471d4b2dSTaylor Simpson SlotMask find_iclass_slots(Opcode opcode, int itype)
33471d4b2dSTaylor Simpson {
34471d4b2dSTaylor Simpson /* There are some exceptions to what the iclass dictates */
35471d4b2dSTaylor Simpson if (GET_ATTRIB(opcode, A_ICOP)) {
36471d4b2dSTaylor Simpson return SLOTS_2;
37471d4b2dSTaylor Simpson } else if (GET_ATTRIB(opcode, A_RESTRICT_SLOT0ONLY)) {
38471d4b2dSTaylor Simpson return SLOTS_0;
39471d4b2dSTaylor Simpson } else if (GET_ATTRIB(opcode, A_RESTRICT_SLOT1ONLY)) {
40471d4b2dSTaylor Simpson return SLOTS_1;
41471d4b2dSTaylor Simpson } else if (GET_ATTRIB(opcode, A_RESTRICT_SLOT2ONLY)) {
42471d4b2dSTaylor Simpson return SLOTS_2;
43471d4b2dSTaylor Simpson } else if (GET_ATTRIB(opcode, A_RESTRICT_SLOT3ONLY)) {
44471d4b2dSTaylor Simpson return SLOTS_3;
45471d4b2dSTaylor Simpson } else if (GET_ATTRIB(opcode, A_COF) &&
46471d4b2dSTaylor Simpson GET_ATTRIB(opcode, A_INDIRECT) &&
47471d4b2dSTaylor Simpson !GET_ATTRIB(opcode, A_MEMLIKE) &&
48471d4b2dSTaylor Simpson !GET_ATTRIB(opcode, A_MEMLIKE_PACKET_RULES)) {
49471d4b2dSTaylor Simpson return SLOTS_2;
50471d4b2dSTaylor Simpson } else if (GET_ATTRIB(opcode, A_RESTRICT_NOSLOT1)) {
51471d4b2dSTaylor Simpson return SLOTS_0;
52471d4b2dSTaylor Simpson } else if ((opcode == J2_trap0) ||
53471d4b2dSTaylor Simpson (opcode == Y2_isync) ||
54*ed9b28fbSMatheus Tavares Bernardino (opcode == J2_pause)) {
55471d4b2dSTaylor Simpson return SLOTS_2;
56*ed9b28fbSMatheus Tavares Bernardino } else if (opcode == J4_hintjumpr) {
57*ed9b28fbSMatheus Tavares Bernardino return SLOTS_23;
58471d4b2dSTaylor Simpson } else if (GET_ATTRIB(opcode, A_CRSLOT23)) {
59471d4b2dSTaylor Simpson return SLOTS_23;
60471d4b2dSTaylor Simpson } else if (GET_ATTRIB(opcode, A_RESTRICT_PREFERSLOT0)) {
61471d4b2dSTaylor Simpson return SLOTS_0;
62471d4b2dSTaylor Simpson } else if (GET_ATTRIB(opcode, A_SUBINSN)) {
63471d4b2dSTaylor Simpson return SLOTS_01;
64471d4b2dSTaylor Simpson } else if (GET_ATTRIB(opcode, A_CALL)) {
65471d4b2dSTaylor Simpson return SLOTS_23;
66471d4b2dSTaylor Simpson } else if ((opcode == J4_jumpseti) || (opcode == J4_jumpsetr)) {
67471d4b2dSTaylor Simpson return SLOTS_23;
68471d4b2dSTaylor Simpson } else {
69471d4b2dSTaylor Simpson return iclass_info[itype];
70471d4b2dSTaylor Simpson }
71471d4b2dSTaylor Simpson }
72