iclass.c (2541B)
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#include "qemu/osdep.h" 19#include "iclass.h" 20 21static 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 32SlotMask 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) || (opcode == J4_hintjumpr)) { 55 return SLOTS_2; 56 } else if (GET_ATTRIB(opcode, A_CRSLOT23)) { 57 return SLOTS_23; 58 } else if (GET_ATTRIB(opcode, A_RESTRICT_PREFERSLOT0)) { 59 return SLOTS_0; 60 } else if (GET_ATTRIB(opcode, A_SUBINSN)) { 61 return SLOTS_01; 62 } else if (GET_ATTRIB(opcode, A_CALL)) { 63 return SLOTS_23; 64 } else if ((opcode == J4_jumpseti) || (opcode == J4_jumpsetr)) { 65 return SLOTS_23; 66 } else { 67 return iclass_info[itype]; 68 } 69}