| 1 | /* |
| 2 | * Copyright(c) 2019-2023 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 | #include "qemu/osdep.h" |
| 19 | #include "iclass.h" |
| 20 | |
| 21 | static const SlotMask iclass_info[] = { |
| 22 | |
| 23 | #define DEF_PP_ICLASS32(TYPE, SLOTS, UNITS) \ |
| 24 | [ICLASS_FROM_TYPE(TYPE)] = SLOTS_##SLOTS, |
| 25 | #define DEF_EE_ICLASS32(TYPE, SLOTS, UNITS) \ |
| 26 | [ICLASS_FROM_TYPE(TYPE)] = SLOTS_##SLOTS, |
| 27 | #include "imported/iclass.def" |
| 28 | #undef DEF_PP_ICLASS32 |
| 29 | #undef DEF_EE_ICLASS32 |
| 30 | }; |
| 31 | |
| 32 | SlotMask find_iclass_slots(Opcode opcode, int itype) |
| 33 | { |
| 34 | /* There are some exceptions to what the iclass dictates */ |
| 35 | if (GET_ATTRIB(opcode, A_ICOP)) { |
| 36 | return SLOTS_2; |
| 37 | } else if (GET_ATTRIB(opcode, A_RESTRICT_SLOT0ONLY)) { |
| 38 | return SLOTS_0; |
| 39 | } else if (GET_ATTRIB(opcode, A_RESTRICT_SLOT1ONLY)) { |
| 40 | return SLOTS_1; |
| 41 | } else if (GET_ATTRIB(opcode, A_RESTRICT_SLOT2ONLY)) { |
| 42 | return SLOTS_2; |
| 43 | } else if (GET_ATTRIB(opcode, A_RESTRICT_SLOT3ONLY)) { |
| 44 | return SLOTS_3; |
| 45 | } else if (GET_ATTRIB(opcode, A_COF) && |
| 46 | GET_ATTRIB(opcode, A_INDIRECT) && |
| 47 | !GET_ATTRIB(opcode, A_MEMLIKE) && |
| 48 | !GET_ATTRIB(opcode, A_MEMLIKE_PACKET_RULES)) { |
| 49 | return SLOTS_2; |
| 50 | } else if (GET_ATTRIB(opcode, A_RESTRICT_NOSLOT1)) { |
| 51 | return SLOTS_0; |
| 52 | } else if ((opcode == J2_trap0) || |
| 53 | (opcode == Y2_isync) || |
| 54 | (opcode == J2_pause)) { |
| 55 | return SLOTS_2; |
| 56 | } else if (opcode == J4_hintjumpr) { |
| 57 | return SLOTS_23; |
| 58 | } else if (GET_ATTRIB(opcode, A_CRSLOT23)) { |
| 59 | return SLOTS_23; |
| 60 | } else if (GET_ATTRIB(opcode, A_RESTRICT_PREFERSLOT0)) { |
| 61 | return SLOTS_0; |
| 62 | } else if (GET_ATTRIB(opcode, A_SUBINSN)) { |
| 63 | return SLOTS_01; |
| 64 | } else if (GET_ATTRIB(opcode, A_CALL)) { |
| 65 | return SLOTS_23; |
| 66 | } else if ((opcode == J4_jumpseti) || (opcode == J4_jumpsetr)) { |
| 67 | return SLOTS_23; |
| 68 | } else { |
| 69 | return iclass_info[itype]; |
| 70 | } |
| 71 | } |