xref: /netbsd-src/external/gpl3/binutils.old/dist/opcodes/arc-dis.h (revision e992f068c547fd6e84b3f104dc2340adcc955732)
175fd0b74Schristos /* Disassembler structures definitions for the ARC.
2*e992f068Schristos    Copyright (C) 1994-2022 Free Software Foundation, Inc.
375fd0b74Schristos 
475fd0b74Schristos    Contributed by Claudiu Zissulescu (claziss@synopsys.com)
575fd0b74Schristos 
675fd0b74Schristos    This file is part of libopcodes.
775fd0b74Schristos 
875fd0b74Schristos    This library is free software; you can redistribute it and/or modify
975fd0b74Schristos    it under the terms of the GNU General Public License as published by
1075fd0b74Schristos    the Free Software Foundation; either version 3, or (at your option)
1175fd0b74Schristos    any later version.
1275fd0b74Schristos 
1375fd0b74Schristos    It is distributed in the hope that it will be useful, but WITHOUT
1475fd0b74Schristos    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
1575fd0b74Schristos    or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public
1675fd0b74Schristos    License for more details.
1775fd0b74Schristos 
1875fd0b74Schristos    You should have received a copy of the GNU General Public License
1975fd0b74Schristos    along with this program; if not, write to the Free Software Foundation,
2075fd0b74Schristos    Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.  */
2175fd0b74Schristos 
2275fd0b74Schristos #ifndef ARCDIS_H
2375fd0b74Schristos #define ARCDIS_H
2475fd0b74Schristos 
25ede78133Schristos #ifdef __cplusplus
26ede78133Schristos extern "C" {
27ede78133Schristos #endif
28ede78133Schristos 
29ede78133Schristos enum arc_ldst_writeback_mode
3075fd0b74Schristos {
31ede78133Schristos   ARC_WRITEBACK_NO = 0,
32ede78133Schristos   ARC_WRITEBACK_AW = 1,
33ede78133Schristos   ARC_WRITEBACK_A = ARC_WRITEBACK_AW,
34ede78133Schristos   ARC_WRITEBACK_AB = 2,
35ede78133Schristos   ARC_WRITEBACK_AS = 3,
3675fd0b74Schristos };
3775fd0b74Schristos 
38ede78133Schristos 
39ede78133Schristos enum arc_ldst_data_size
4075fd0b74Schristos {
41ede78133Schristos   ARC_SCALING_NONE = 4,
42ede78133Schristos   ARC_SCALING_B = 1,
43ede78133Schristos   ARC_SCALING_H = 2,
44ede78133Schristos   ARC_SCALING_D = 8,
4575fd0b74Schristos };
4675fd0b74Schristos 
47ede78133Schristos 
48ede78133Schristos enum arc_condition_code
4975fd0b74Schristos {
50ede78133Schristos   ARC_CC_AL = 0x0,
51ede78133Schristos   ARC_CC_RA = ARC_CC_AL,
52ede78133Schristos   ARC_CC_EQ = 0x1,
53ede78133Schristos   ARC_CC_Z = ARC_CC_EQ,
54ede78133Schristos   ARC_CC_NE = 0x2,
55ede78133Schristos   ARC_CC_NZ = ARC_CC_NE,
56ede78133Schristos   ARC_CC_PL = 0x3,
57ede78133Schristos   ARC_CC_P = ARC_CC_PL,
58ede78133Schristos   ARC_CC_MI = 0x4,
59ede78133Schristos   ARC_CC_N = ARC_CC_MI,
60ede78133Schristos   ARC_CC_CS = 0x5,
61ede78133Schristos   ARC_CC_C = ARC_CC_CS,
62ede78133Schristos   ARC_CC_LO = ARC_CC_CS,
63ede78133Schristos   ARC_CC_CC = 0x6,
64ede78133Schristos   ARC_CC_NC = ARC_CC_CC,
65ede78133Schristos   ARC_CC_HS = ARC_CC_CC,
66ede78133Schristos   ARC_CC_VS = 0x7,
67ede78133Schristos   ARC_CC_V = ARC_CC_VS,
68ede78133Schristos   ARC_CC_VC = 0x8,
69ede78133Schristos   ARC_CC_NV = ARC_CC_VC,
70ede78133Schristos   ARC_CC_GT = 0x9,
71ede78133Schristos   ARC_CC_GE = 0xA,
72ede78133Schristos   ARC_CC_LT = 0xB,
73ede78133Schristos   ARC_CC_LE = 0xC,
74ede78133Schristos   ARC_CC_HI = 0xD,
75ede78133Schristos   ARC_CC_LS = 0xE,
76ede78133Schristos   ARC_CC_PNZ = 0xF,
77ede78133Schristos   ARC_CC_UNDEF0 = 0x10,
78ede78133Schristos   ARC_CC_UNDEF1 = 0x11,
79ede78133Schristos   ARC_CC_UNDEF2 = 0x12,
80ede78133Schristos   ARC_CC_UNDEF3 = 0x13,
81ede78133Schristos   ARC_CC_UNDEF4 = 0x14,
82ede78133Schristos   ARC_CC_UNDEF5 = 0x15,
83ede78133Schristos   ARC_CC_UNDEF6 = 0x16,
84ede78133Schristos   ARC_CC_UNDEF7 = 0x17,
85ede78133Schristos   ARC_CC_UNDEF8 = 0x18,
86ede78133Schristos   ARC_CC_UNDEF9 = 0x19,
87ede78133Schristos   ARC_CC_UNDEFA = 0x1A,
88ede78133Schristos   ARC_CC_UNDEFB = 0x1B,
89ede78133Schristos   ARC_CC_UNDEFC = 0x1C,
90ede78133Schristos   ARC_CC_UNDEFD = 0x1D,
91ede78133Schristos   ARC_CC_UNDEFE = 0x1E,
92ede78133Schristos   ARC_CC_UNDEFF = 0x1F
9375fd0b74Schristos };
9475fd0b74Schristos 
95ede78133Schristos enum arc_operand_kind
9675fd0b74Schristos {
97ede78133Schristos   ARC_OPERAND_KIND_UNKNOWN = 0,
98ede78133Schristos   ARC_OPERAND_KIND_REG,
99ede78133Schristos   ARC_OPERAND_KIND_SHIMM,
100ede78133Schristos   ARC_OPERAND_KIND_LIMM
10175fd0b74Schristos };
10275fd0b74Schristos 
103ede78133Schristos struct arc_insn_operand
104ede78133Schristos {
105ede78133Schristos   /* Operand value as encoded in instruction.  */
106ede78133Schristos   unsigned long value;
107ede78133Schristos 
108ede78133Schristos   enum arc_operand_kind kind;
109ede78133Schristos };
110ede78133Schristos 
111ede78133Schristos /* Container for information about instruction.  Provides a higher
112ede78133Schristos    level access to data that is contained in struct arc_opcode.  */
113ede78133Schristos 
114ede78133Schristos struct arc_instruction
115ede78133Schristos {
116ede78133Schristos   /* Address of this instruction.  */
117ede78133Schristos   bfd_vma address;
118ede78133Schristos 
119ede78133Schristos   /* Whether this is a valid instruction.  */
120*e992f068Schristos   bool valid;
121ede78133Schristos 
122ede78133Schristos   insn_class_t insn_class;
123ede78133Schristos 
124ede78133Schristos   /* Length (without LIMM).  */
125ede78133Schristos   unsigned length;
126ede78133Schristos 
127ede78133Schristos   /* Is there a LIMM in this instruction?  */
128ede78133Schristos   int limm_p;
129ede78133Schristos 
130ede78133Schristos   /* Long immediate value.  */
131ede78133Schristos   unsigned limm_value;
132ede78133Schristos 
133ede78133Schristos   /* Is it a branch/jump instruction?  */
134ede78133Schristos   int is_control_flow;
135ede78133Schristos 
136ede78133Schristos   /* Whether this instruction has a delay slot.  */
137ede78133Schristos   int has_delay_slot;
138ede78133Schristos 
139ede78133Schristos   /* Value of condition code field.  */
140ede78133Schristos   enum arc_condition_code condition_code;
141ede78133Schristos 
142ede78133Schristos   /* Load/store writeback mode.  */
143ede78133Schristos   enum arc_ldst_writeback_mode writeback_mode;
144ede78133Schristos 
145ede78133Schristos   /* Load/store data size.  */
146ede78133Schristos   enum arc_ldst_data_size data_size_mode;
147ede78133Schristos 
148ede78133Schristos   /* Amount of operands in instruction.  Note that amount of operands
149ede78133Schristos      reported by opcodes disassembler can be different from the one
150ede78133Schristos      encoded in the instruction.  Notable case is "ld a,[b,offset]",
151ede78133Schristos      when offset == 0.  In this case opcodes disassembler presents
152ede78133Schristos      this instruction as "ld a,[b]", hence there are *two* operands,
153ede78133Schristos      not three.  OPERANDS_COUNT and OPERANDS contain only those
154ede78133Schristos      explicit operands, hence it is up to invoker to handle the case
155ede78133Schristos      described above based on instruction opcodes.  Another notable
156ede78133Schristos      thing is that in opcodes disassembler representation square
157ede78133Schristos      brackets (`[' and `]') are so called fake-operands - they are in
158ede78133Schristos      the list of operands, but do not have any value of they own.
159ede78133Schristos      Those "operands" are not present in this array.  */
160ede78133Schristos   struct arc_insn_operand operands[MAX_INSN_ARGS];
161ede78133Schristos 
162ede78133Schristos   unsigned int operands_count;
163ede78133Schristos };
164ede78133Schristos 
165ede78133Schristos /* Fill INSN with data about instruction at specified ADDR.  */
166ede78133Schristos 
167ede78133Schristos void arc_insn_decode (bfd_vma addr,
168ede78133Schristos 		      struct disassemble_info *di,
169ede78133Schristos 		      disassembler_ftype func,
170ede78133Schristos 		      struct arc_instruction *insn);
171ede78133Schristos 
172ede78133Schristos #ifdef __cplusplus
173ede78133Schristos }
174ede78133Schristos #endif
175ede78133Schristos 
17675fd0b74Schristos #endif
177