xref: /qemu/target/hexagon/insn.h (revision 4614b8f3)
13e474055STaylor Simpson /*
291963819STaylor Simpson  *  Copyright(c) 2019-2024 Qualcomm Innovation Center, Inc. All Rights Reserved.
33e474055STaylor Simpson  *
43e474055STaylor Simpson  *  This program is free software; you can redistribute it and/or modify
53e474055STaylor Simpson  *  it under the terms of the GNU General Public License as published by
63e474055STaylor Simpson  *  the Free Software Foundation; either version 2 of the License, or
73e474055STaylor Simpson  *  (at your option) any later version.
83e474055STaylor Simpson  *
93e474055STaylor Simpson  *  This program is distributed in the hope that it will be useful,
103e474055STaylor Simpson  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
113e474055STaylor Simpson  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
123e474055STaylor Simpson  *  GNU General Public License for more details.
133e474055STaylor Simpson  *
143e474055STaylor Simpson  *  You should have received a copy of the GNU General Public License
153e474055STaylor Simpson  *  along with this program; if not, see <http://www.gnu.org/licenses/>.
163e474055STaylor Simpson  */
173e474055STaylor Simpson 
183e474055STaylor Simpson #ifndef HEXAGON_INSN_H
193e474055STaylor Simpson #define HEXAGON_INSN_H
203e474055STaylor Simpson 
213e474055STaylor Simpson #include "cpu.h"
223e474055STaylor Simpson 
233e474055STaylor Simpson #define INSTRUCTIONS_MAX 7    /* 2 pairs + loopend */
243e474055STaylor Simpson #define REG_OPERANDS_MAX 5
253e474055STaylor Simpson #define IMMEDS_MAX 2
263e474055STaylor Simpson 
273e474055STaylor Simpson struct Instruction;
283e474055STaylor Simpson struct Packet;
293e474055STaylor Simpson struct DisasContext;
303e474055STaylor Simpson 
311e536334STaylor Simpson typedef void (*SemanticInsn)(struct DisasContext *ctx);
323e474055STaylor Simpson 
333e474055STaylor Simpson struct Instruction {
343e474055STaylor Simpson     SemanticInsn generate;            /* pointer to genptr routine */
353e474055STaylor Simpson     uint8_t regno[REG_OPERANDS_MAX];    /* reg operands including predicates */
363e474055STaylor Simpson     uint16_t opcode;
373e474055STaylor Simpson 
383e474055STaylor Simpson     uint32_t iclass:6;
393e474055STaylor Simpson     uint32_t slot:3;
4092cfa25fSTaylor Simpson     uint32_t which_extended:1;    /* If has an extender, which immediate */
4192cfa25fSTaylor Simpson     uint32_t new_value_producer_slot:4;
4291963819STaylor Simpson     int32_t new_read_idx;
43325a64afSTaylor Simpson     int32_t dest_idx;
444614b8f3STaylor Simpson     bool has_pred_dest;
4592cfa25fSTaylor Simpson 
4692cfa25fSTaylor Simpson     bool part1;              /*
473e474055STaylor Simpson                               * cmp-jumps are split into two insns.
483e474055STaylor Simpson                               * set for the compare and clear for the jump
493e474055STaylor Simpson                               */
5092cfa25fSTaylor Simpson     bool extension_valid;   /* Has a constant extender attached */
5192cfa25fSTaylor Simpson     bool is_endloop;   /* This is an end of loop */
523e474055STaylor Simpson     int32_t immed[IMMEDS_MAX];    /* immediate field */
533e474055STaylor Simpson };
543e474055STaylor Simpson 
553e474055STaylor Simpson typedef struct Instruction Insn;
563e474055STaylor Simpson 
573e474055STaylor Simpson struct Packet {
583e474055STaylor Simpson     uint16_t num_insns;
593e474055STaylor Simpson     uint16_t encod_pkt_size_in_bytes;
6040085901STaylor Simpson     uint32_t pc;
613e474055STaylor Simpson 
623e474055STaylor Simpson     /* Pre-decodes about COF */
6392cfa25fSTaylor Simpson     bool pkt_has_cof;          /* Has any change-of-flow */
64fb67c2bfSTaylor Simpson     bool pkt_has_multi_cof;    /* Has more than one change-of-flow */
6592cfa25fSTaylor Simpson     bool pkt_has_endloop;
663e474055STaylor Simpson 
6792cfa25fSTaylor Simpson     bool pkt_has_dczeroa;
683e474055STaylor Simpson 
6992cfa25fSTaylor Simpson     bool pkt_has_store_s0;
7092cfa25fSTaylor Simpson     bool pkt_has_store_s1;
713e474055STaylor Simpson 
72a1559537STaylor Simpson     bool pkt_has_hvx;
73a1559537STaylor Simpson     Insn *vhist_insn;
74a1559537STaylor Simpson 
753e474055STaylor Simpson     Insn insn[INSTRUCTIONS_MAX];
763e474055STaylor Simpson };
773e474055STaylor Simpson 
783e474055STaylor Simpson typedef struct Packet Packet;
793e474055STaylor Simpson 
803e474055STaylor Simpson #endif
81