decode.c (4f9a4cd37eb2f0c4e6be83640fcc5c31d4bf99e3) decode.c (14edcf11e297252c995d5909144f3751b7383efc)
1/*
1/*
2 * Copyright(c) 2019-2022 Qualcomm Innovation Center, Inc. All Rights Reserved.
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

--- 781 unchanged lines hidden (view full) ---

792}
793
794static bool decode_parsebits_is_loopend(uint32_t encoding32)
795{
796 uint32_t bits = parse_bits(encoding32);
797 return bits == 0x2;
798}
799
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

--- 781 unchanged lines hidden (view full) ---

792}
793
794static bool decode_parsebits_is_loopend(uint32_t encoding32)
795{
796 uint32_t bits = parse_bits(encoding32);
797 return bits == 0x2;
798}
799
800static void
800static bool has_valid_slot_assignment(Packet *pkt)
801{
802 int used_slots = 0;
803 for (int i = 0; i < pkt->num_insns; i++) {
804 int slot_mask;
805 Insn *insn = &pkt->insn[i];
806 if (decode_opcode_ends_loop(insn->opcode)) {
807 /* We overload slot 0 for endloop. */
808 continue;
809 }
810 slot_mask = 1 << insn->slot;
811 if (used_slots & slot_mask) {
812 return false;
813 }
814 used_slots |= slot_mask;
815 }
816 return true;
817}
818
819static bool
801decode_set_slot_number(Packet *pkt)
802{
803 int slot;
804 int i;
805 bool hit_mem_insn = false;
806 bool hit_duplex = false;
807 bool slot0_found = false;
808 bool slot1_found = false;

--- 72 unchanged lines hidden (view full) ---

881 slot1_iidx = i;
882 }
883 }
884 /* Is slot0 empty and slot1 used? */
885 if ((!slot0_found) && slot1_found) {
886 /* Then push it to slot0 */
887 pkt->insn[slot1_iidx].slot = 0;
888 }
820decode_set_slot_number(Packet *pkt)
821{
822 int slot;
823 int i;
824 bool hit_mem_insn = false;
825 bool hit_duplex = false;
826 bool slot0_found = false;
827 bool slot1_found = false;

--- 72 unchanged lines hidden (view full) ---

900 slot1_iidx = i;
901 }
902 }
903 /* Is slot0 empty and slot1 used? */
904 if ((!slot0_found) && slot1_found) {
905 /* Then push it to slot0 */
906 pkt->insn[slot1_iidx].slot = 0;
907 }
908
909 return has_valid_slot_assignment(pkt);
889}
890
891/*
892 * decode_packet
893 * Decodes packet with given words
894 * Returns 0 on insufficient words,
895 * or number of words used on success
896 */

--- 59 unchanged lines hidden (view full) ---

956 } else if (has_loop0) {
957 decode_add_endloop_insn(&pkt->insn[pkt->num_insns++], 0);
958 }
959 }
960
961 decode_apply_extenders(pkt);
962 if (!disas_only) {
963 decode_remove_extenders(pkt);
910}
911
912/*
913 * decode_packet
914 * Decodes packet with given words
915 * Returns 0 on insufficient words,
916 * or number of words used on success
917 */

--- 59 unchanged lines hidden (view full) ---

977 } else if (has_loop0) {
978 decode_add_endloop_insn(&pkt->insn[pkt->num_insns++], 0);
979 }
980 }
981
982 decode_apply_extenders(pkt);
983 if (!disas_only) {
984 decode_remove_extenders(pkt);
985 if (!decode_set_slot_number(pkt)) {
986 /* Invalid packet */
987 return 0;
988 }
964 }
989 }
965 decode_set_slot_number(pkt);
966 decode_fill_newvalue_regno(pkt);
967
968 if (pkt->pkt_has_hvx) {
969 mmvec_ext_decode_checks(pkt, disas_only);
970 }
971
972 if (!disas_only) {
973 decode_shuffle_for_execution(pkt);

--- 21 unchanged lines hidden ---
990 decode_fill_newvalue_regno(pkt);
991
992 if (pkt->pkt_has_hvx) {
993 mmvec_ext_decode_checks(pkt, disas_only);
994 }
995
996 if (!disas_only) {
997 decode_shuffle_for_execution(pkt);

--- 21 unchanged lines hidden ---