OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [insight/] [opcodes/] [or32.c] - Blame information for rev 1590

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 133 markom
/* Table of opcodes for the OpenRISC 1000 ISA.
2
   Copyright 1990, 1991, 1992, 1993 Free Software Foundation, Inc.
3
   Contributed by Damjan Lampret (lampret@opencores.org).
4
 
5 717 markom
This file is part of gen_or1k_isa, or1ksim, GDB and GAS.
6 133 markom
 
7
This program is free software; you can redistribute it and/or modify
8
it under the terms of the GNU General Public License as published by
9
the Free Software Foundation; either version 2 of the License, or
10
(at your option) any later version.
11
 
12
This program is distributed in the hope that it will be useful,
13
but WITHOUT ANY WARRANTY; without even the implied warranty of
14
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
GNU General Public License for more details.
16
 
17
You should have received a copy of the GNU General Public License
18
along with this program; if not, write to the Free Software
19
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
20
 
21 1114 lampret
/*
22
 * $Log: not supported by cvs2svn $
23 1590 lampret
 * Revision 1.47  2005/09/05 08:47:44  nogj
24
 * Fix most warnings issued by gcc4
25
 *
26 1557 nogj
 * Revision 1.46  2005/08/18 22:13:27  phoenix
27
 * fixed l.maci encoding
28
 *
29 1554 phoenix
 * Revision 1.45  2005/04/27 19:13:13  nogj
30
 * l.rfe does not have a delay slot.  Don't mark it as such.
31
 *
32 1475 nogj
 * Revision 1.44  2005/03/31 16:09:57  nogj
33
 * Implement a dynamic recompiler to speed up the execution
34
 *
35 1452 nogj
 * Revision 1.43  2005/03/31 16:01:59  nogj
36
 * Reclasify l.trap and l.sys to be an exception instruction
37
 *
38 1440 nogj
 * Revision 1.42  2005/03/16 12:25:56  nogj
39
 * Fix the parameters to the l.ff1/l.maci instructions
40
 *
41 1384 nogj
 * Revision 1.41  2005/02/09 17:41:03  nogj
42
 * Mark a simulated cpu address as such, by introducing the new oraddr_t type
43
 *
44 1350 nogj
 * Revision 1.40  2005/01/27 14:14:13  nogj
45
 * Remove the global op structure
46
 *
47 1346 nogj
 * Revision 1.39  2005/01/27 13:35:40  nogj
48
 *  * Fix generate.c to produce a execgen.c with less warnings.
49
 *  * Fix the --enable-simple configure option.
50
 *
51 1342 nogj
 * Revision 1.38  2005/01/27 13:15:50  nogj
52
 * Mark wich operand is the destination operand in the architechture definition
53
 *
54 1341 nogj
 * Revision 1.37  2005/01/11 15:41:58  andreje
55
 * l.ff1 instruction added
56
 *
57 1338 andreje
 * Revision 1.36  2004/07/22 20:17:23  phoenix
58
 * removed includes
59
 *
60 1309 phoenix
 * Revision 1.35  2004/07/19 23:07:37  phoenix
61
 * Gyorgy Jeney: extensive cleanup
62
 *
63 1308 phoenix
 * Revision 1.34  2004/06/27 22:56:48  lampret
64
 * Updated instruction set descriptions. Changed FP instructions encoding.
65
 *
66 1295 lampret
 * Revision 1.33  2004/05/09 19:52:31  lampret
67
 * Changed desciption of the l.cust5 insns
68
 *
69 1285 lampret
 * Revision 1.31  2003/07/01 19:34:49  csanchez
70
 * Added support for l.addc instruction.
71
 *
72 1169 csanchez
 * Revision 1.30  2003/01/28 03:49:24  lampret
73
 * Added cvs log keywords
74
 *
75 1114 lampret
 */
76
 
77 133 markom
#include <string.h>
78
#include <stdio.h>
79
#include <stdlib.h>
80 371 markom
#include <ctype.h>
81 133 markom
 
82 371 markom
 
83 138 markom
#ifdef HAVE_CONFIG_H
84
# include "config.h"
85
#endif
86 1342 nogj
#ifdef HAS_EXECUTION
87 1350 nogj
# ifdef HAVE_INTTYPES_H
88
#  include <inttypes.h> /* ...but to get arch.h we need uint{8,16,32}_t... */
89
# endif
90
# include "port.h"
91
# include "arch.h" /* ...but to get abstract.h, we need oraddr_t... */
92
# include "abstract.h" /* To get struct iqueue_entry... */
93 1557 nogj
# include "debug.h" /* To get debug() */
94 1342 nogj
#endif
95 133 markom
#include "opcode/or32.h"
96
 
97
/* **INDENT-OFF** */
98
 
99 1342 nogj
/* We treat all letters the same in encode/decode routines so
100
   we need to assign some characteristics to them like signess etc.*/
101 133 markom
CONST struct or32_letter or32_letters[] =
102
{
103
{ 'A', NUM_UNSIGNED },
104
{ 'B', NUM_UNSIGNED },
105
{ 'D', NUM_UNSIGNED },
106
{ 'I', NUM_SIGNED },
107
{ 'K', NUM_UNSIGNED },
108
{ 'L', NUM_UNSIGNED },
109
{ 'N', NUM_SIGNED },
110
{ '0', NUM_UNSIGNED },
111
{ '\0', 0 }     /* dummy entry */
112
};
113
 
114
/* Opcode encoding:
115
   machine[31:30]: first two bits of opcode
116
                   00 - neither of source operands is GPR
117
                   01 - second source operand is GPR (rB)
118
                   10 - first source operand is GPR (rA)
119
                   11 - both source operands are GPRs (rA and rB)
120
   machine[29:26]: next four bits of opcode
121
   machine[25:00]: instruction operands (specific to individual instruction)
122
 
123
  Recommendation: irrelevant instruction bits should be set with a value of
124
  bits in same positions of instruction preceding current instruction in the
125
  code (when assembling).
126
*/
127
 
128 1341 nogj
#ifdef HAS_EXECUTION
129
# if SIMPLE_EXECUTION
130
#  define EFN &l_none
131
#  define EF(func) &(func)
132
#  define EFI &l_invalid
133 1452 nogj
# elif COMPLEX_EXECUTION
134 1341 nogj
#  define EFN "l_none"
135
#  define EFI "l_invalid"
136
#  ifdef __GNUC__
137
#   define EF(func) #func
138
#  else
139
#   define EF(func) "func"
140
#  endif
141 1452 nogj
# else /* DYNAMIC_EXECUTION */
142
#  define EFN &l_none
143
#  define EF(func) &(gen_ ##func)
144
#  define EFI &gen_l_invalid
145
# endif
146 1341 nogj
#else /* HAS_EXECUTION */
147
# define EFN &l_none
148
# define EF(func) EFN
149
# define EFI EFN
150 133 markom
#endif /* HAS_EXECUTION */
151
 
152
CONST struct or32_opcode or32_opcodes[] =
153
{
154
 
155 1346 nogj
{ "l.j",       "N",            "00 0x0  NNNNN NNNNN NNNN NNNN NNNN NNNN",
156
  EF(l_j), OR32_IF_DELAY, it_jump },
157
{ "l.jal",     "N",            "00 0x1  NNNNN NNNNN NNNN NNNN NNNN NNNN",
158
  EF(l_jal), OR32_IF_DELAY, it_jump },
159
{ "l.bnf",     "N",            "00 0x3  NNNNN NNNNN NNNN NNNN NNNN NNNN",
160
  EF(l_bnf), OR32_IF_DELAY | OR32_R_FLAG, it_branch },
161
{ "l.bf",      "N",            "00 0x4  NNNNN NNNNN NNNN NNNN NNNN NNNN",
162
  EF(l_bf), OR32_IF_DELAY | OR32_R_FLAG, it_branch },
163
{ "l.nop",     "K",            "00 0x5  01--- ----- KKKK KKKK KKKK KKKK",
164
  EF(l_nop), 0, it_nop },
165
{ "l.movhi",   "rD,K",         "00 0x6  DDDDD ----0 KKKK KKKK KKKK KKKK",
166
  EF(l_movhi), 0, it_movimm },
167
{ "l.macrc",   "rD",           "00 0x6  DDDDD ----1 0000 0000 0000 0000",
168
  EF(l_macrc), 0, it_mac },
169
{ "l.sys",     "K",            "00 0x8  00000 00000 KKKK KKKK KKKK KKKK",
170 1440 nogj
  EF(l_sys), 0, it_exception },
171 1346 nogj
{ "l.trap",    "K",            "00 0x8  01000 00000 KKKK KKKK KKKK KKKK",
172 1440 nogj
  EF(l_trap), 0, it_exception },
173 1346 nogj
{ "l.msync",   "",             "00 0x8  10000 00000 0000 0000 0000 0000", EFN,
174
  0, it_unknown },
175
{ "l.psync",   "",             "00 0x8  10100 00000 0000 0000 0000 0000", EFN,
176
  0, it_unknown },
177
{ "l.csync",   "",             "00 0x8  11000 00000 0000 0000 0000 0000", EFN,
178
  0, it_unknown },
179
{ "l.rfe",     "",             "00 0x9  ----- ----- ---- ---- ---- ----",
180 1475 nogj
  EF(l_rfe), 0, it_exception },
181 1346 nogj
{ "lv.all_eq.b","rD,rA,rB",    "00 0xA  DDDDD AAAAA BBBB B--- 0x1 0x0", EFI, 0,
182
  it_unknown },
183
{ "lv.all_eq.h","rD,rA,rB",    "00 0xA  DDDDD AAAAA BBBB B--- 0x1 0x1", EFI, 0,
184
  it_unknown },
185
{ "lv.all_ge.b","rD,rA,rB",    "00 0xA  DDDDD AAAAA BBBB B--- 0x1 0x2", EFI, 0,
186
  it_unknown },
187
{ "lv.all_ge.h","rD,rA,rB",    "00 0xA  DDDDD AAAAA BBBB B--- 0x1 0x3", EFI, 0,
188
  it_unknown },
189
{ "lv.all_gt.b","rD,rA,rB",    "00 0xA  DDDDD AAAAA BBBB B--- 0x1 0x4", EFI, 0,
190
  it_unknown },
191
{ "lv.all_gt.h","rD,rA,rB",    "00 0xA  DDDDD AAAAA BBBB B--- 0x1 0x5", EFI, 0,
192
  it_unknown },
193
{ "lv.all_le.b","rD,rA,rB",    "00 0xA  DDDDD AAAAA BBBB B--- 0x1 0x6", EFI, 0,
194
  it_unknown },
195
{ "lv.all_le.h","rD,rA,rB",    "00 0xA  DDDDD AAAAA BBBB B--- 0x1 0x7", EFI, 0,
196
  it_unknown },
197
{ "lv.all_lt.b","rD,rA,rB",    "00 0xA  DDDDD AAAAA BBBB B--- 0x1 0x8", EFI, 0,
198
  it_unknown },
199
{ "lv.all_lt.h","rD,rA,rB",    "00 0xA  DDDDD AAAAA BBBB B--- 0x1 0x9", EFI, 0,
200
  it_unknown },
201
{ "lv.all_ne.b","rD,rA,rB",    "00 0xA  DDDDD AAAAA BBBB B--- 0x1 0xA", EFI, 0,
202
  it_unknown },
203
{ "lv.all_ne.h","rD,rA,rB",    "00 0xA  DDDDD AAAAA BBBB B--- 0x1 0xB", EFI, 0,
204
  it_unknown },
205
{ "lv.any_eq.b","rD,rA,rB",    "00 0xA  DDDDD AAAAA BBBB B--- 0x2 0x0", EFI, 0,
206
  it_unknown },
207
{ "lv.any_eq.h","rD,rA,rB",    "00 0xA  DDDDD AAAAA BBBB B--- 0x2 0x1", EFI, 0,
208
  it_unknown },
209
{ "lv.any_ge.b","rD,rA,rB",    "00 0xA  DDDDD AAAAA BBBB B--- 0x2 0x2", EFI, 0,
210
  it_unknown },
211
{ "lv.any_ge.h","rD,rA,rB",    "00 0xA  DDDDD AAAAA BBBB B--- 0x2 0x3", EFI, 0,
212
  it_unknown },
213
{ "lv.any_gt.b","rD,rA,rB",    "00 0xA  DDDDD AAAAA BBBB B--- 0x2 0x4", EFI, 0,
214
  it_unknown },
215
{ "lv.any_gt.h","rD,rA,rB",    "00 0xA  DDDDD AAAAA BBBB B--- 0x2 0x5", EFI, 0,
216
  it_unknown },
217
{ "lv.any_le.b","rD,rA,rB",    "00 0xA  DDDDD AAAAA BBBB B--- 0x2 0x6", EFI, 0,
218
  it_unknown },
219
{ "lv.any_le.h","rD,rA,rB",    "00 0xA  DDDDD AAAAA BBBB B--- 0x2 0x7", EFI, 0,
220
  it_unknown },
221
{ "lv.any_lt.b","rD,rA,rB",    "00 0xA  DDDDD AAAAA BBBB B--- 0x2 0x8", EFI, 0,
222
  it_unknown },
223
{ "lv.any_lt.h","rD,rA,rB",    "00 0xA  DDDDD AAAAA BBBB B--- 0x2 0x9", EFI, 0,
224
  it_unknown },
225
{ "lv.any_ne.b","rD,rA,rB",    "00 0xA  DDDDD AAAAA BBBB B--- 0x2 0xA", EFI, 0,
226
  it_unknown },
227
{ "lv.any_ne.h","rD,rA,rB",    "00 0xA  DDDDD AAAAA BBBB B--- 0x2 0xB", EFI, 0,
228
  it_unknown },
229
{ "lv.add.b",  "rD,rA,rB",     "00 0xA  DDDDD AAAAA BBBB B--- 0x3 0x0", EFI, 0,
230
  it_unknown },
231
{ "lv.add.h",  "rD,rA,rB",     "00 0xA  DDDDD AAAAA BBBB B--- 0x3 0x1", EFI, 0,
232
  it_unknown },
233
{ "lv.adds.b", "rD,rA,rB",     "00 0xA  DDDDD AAAAA BBBB B--- 0x3 0x2", EFI, 0,
234
  it_unknown },
235
{ "lv.adds.h", "rD,rA,rB",     "00 0xA  DDDDD AAAAA BBBB B--- 0x3 0x3", EFI, 0,
236
  it_unknown },
237
{ "lv.addu.b", "rD,rA,rB",     "00 0xA  DDDDD AAAAA BBBB B--- 0x3 0x4", EFI, 0,
238
  it_unknown },
239
{ "lv.addu.h", "rD,rA,rB",     "00 0xA  DDDDD AAAAA BBBB B--- 0x3 0x5", EFI, 0,
240
  it_unknown },
241
{ "lv.addus.b","rD,rA,rB",     "00 0xA  DDDDD AAAAA BBBB B--- 0x3 0x6", EFI, 0,
242
  it_unknown },
243
{ "lv.addus.h","rD,rA,rB",     "00 0xA  DDDDD AAAAA BBBB B--- 0x3 0x7", EFI, 0,
244
  it_unknown },
245
{ "lv.and",    "rD,rA,rB",     "00 0xA  DDDDD AAAAA BBBB B--- 0x3 0x8", EFI, 0,
246
  it_unknown },
247
{ "lv.avg.b",  "rD,rA,rB",     "00 0xA  DDDDD AAAAA BBBB B--- 0x3 0x9", EFI, 0,
248
  it_unknown },
249
{ "lv.avg.h",  "rD,rA,rB",     "00 0xA  DDDDD AAAAA BBBB B--- 0x3 0xA", EFI, 0,
250
  it_unknown },
251
{ "lv.cmp_eq.b","rD,rA,rB",    "00 0xA  DDDDD AAAAA BBBB B--- 0x4 0x0", EFI, 0,
252
  it_unknown },
253
{ "lv.cmp_eq.h","rD,rA,rB",    "00 0xA  DDDDD AAAAA BBBB B--- 0x4 0x1", EFI, 0,
254
  it_unknown },
255
{ "lv.cmp_ge.b","rD,rA,rB",    "00 0xA  DDDDD AAAAA BBBB B--- 0x4 0x2", EFI, 0,
256
  it_unknown },
257
{ "lv.cmp_ge.h","rD,rA,rB",    "00 0xA  DDDDD AAAAA BBBB B--- 0x4 0x3", EFI, 0,
258
  it_unknown },
259
{ "lv.cmp_gt.b","rD,rA,rB",    "00 0xA  DDDDD AAAAA BBBB B--- 0x4 0x4", EFI, 0,
260
  it_unknown },
261
{ "lv.cmp_gt.h","rD,rA,rB",    "00 0xA  DDDDD AAAAA BBBB B--- 0x4 0x5", EFI, 0,
262
  it_unknown },
263
{ "lv.cmp_le.b","rD,rA,rB",    "00 0xA  DDDDD AAAAA BBBB B--- 0x4 0x6", EFI, 0,
264
  it_unknown },
265
{ "lv.cmp_le.h","rD,rA,rB",    "00 0xA  DDDDD AAAAA BBBB B--- 0x4 0x7", EFI, 0,
266
  it_unknown },
267
{ "lv.cmp_lt.b","rD,rA,rB",    "00 0xA  DDDDD AAAAA BBBB B--- 0x4 0x8", EFI, 0,
268
  it_unknown },
269
{ "lv.cmp_lt.h","rD,rA,rB",    "00 0xA  DDDDD AAAAA BBBB B--- 0x4 0x9", EFI, 0,
270
  it_unknown },
271
{ "lv.cmp_ne.b","rD,rA,rB",    "00 0xA  DDDDD AAAAA BBBB B--- 0x4 0xA", EFI, 0,
272
  it_unknown },
273
{ "lv.cmp_ne.h","rD,rA,rB",    "00 0xA  DDDDD AAAAA BBBB B--- 0x4 0xB", EFI, 0,
274
  it_unknown },
275
{ "lv.madds.h","rD,rA,rB",     "00 0xA  DDDDD AAAAA BBBB B--- 0x5 0x4", EFI, 0,
276
  it_unknown },
277
{ "lv.max.b",  "rD,rA,rB",     "00 0xA  DDDDD AAAAA BBBB B--- 0x5 0x5", EFI, 0,
278
  it_unknown },
279
{ "lv.max.h",  "rD,rA,rB",     "00 0xA  DDDDD AAAAA BBBB B--- 0x5 0x6", EFI, 0,
280
  it_unknown },
281
{ "lv.merge.b","rD,rA,rB",     "00 0xA  DDDDD AAAAA BBBB B--- 0x5 0x7", EFI, 0,
282
  it_unknown },
283
{ "lv.merge.h","rD,rA,rB",     "00 0xA  DDDDD AAAAA BBBB B--- 0x5 0x8", EFI, 0,
284
  it_unknown },
285
{ "lv.min.b",  "rD,rA,rB",     "00 0xA  DDDDD AAAAA BBBB B--- 0x5 0x9", EFI, 0,
286
  it_unknown },
287
{ "lv.min.h",  "rD,rA,rB",     "00 0xA  DDDDD AAAAA BBBB B--- 0x5 0xA", EFI, 0,
288
  it_unknown },
289
{ "lv.msubs.h","rD,rA,rB",     "00 0xA  DDDDD AAAAA BBBB B--- 0x5 0xB", EFI, 0,
290
  it_unknown },
291
{ "lv.muls.h", "rD,rA,rB",     "00 0xA  DDDDD AAAAA BBBB B--- 0x5 0xC", EFI, 0,
292
  it_unknown },
293
{ "lv.nand",   "rD,rA,rB",     "00 0xA  DDDDD AAAAA BBBB B--- 0x5 0xD", EFI, 0,
294
  it_unknown },
295
{ "lv.nor",    "rD,rA,rB",     "00 0xA  DDDDD AAAAA BBBB B--- 0x5 0xE", EFI, 0,
296
  it_unknown },
297
{ "lv.or",     "rD,rA,rB",     "00 0xA  DDDDD AAAAA BBBB B--- 0x5 0xF", EFI, 0,
298
  it_unknown },
299
{ "lv.pack.b", "rD,rA,rB",     "00 0xA  DDDDD AAAAA BBBB B--- 0x6 0x0", EFI, 0,
300
  it_unknown },
301
{ "lv.pack.h", "rD,rA,rB",     "00 0xA  DDDDD AAAAA BBBB B--- 0x6 0x1", EFI, 0,
302
  it_unknown },
303
{ "lv.packs.b","rD,rA,rB",     "00 0xA  DDDDD AAAAA BBBB B--- 0x6 0x2", EFI, 0,
304
  it_unknown },
305
{ "lv.packs.h","rD,rA,rB",     "00 0xA  DDDDD AAAAA BBBB B--- 0x6 0x3", EFI, 0,
306
  it_unknown },
307
{ "lv.packus.b","rD,rA,rB",    "00 0xA  DDDDD AAAAA BBBB B--- 0x6 0x4", EFI, 0,
308
  it_unknown },
309
{ "lv.packus.h","rD,rA,rB",    "00 0xA  DDDDD AAAAA BBBB B--- 0x6 0x5", EFI, 0,
310
  it_unknown },
311
{ "lv.perm.n", "rD,rA,rB",     "00 0xA  DDDDD AAAAA BBBB B--- 0x6 0x6", EFI, 0,
312
  it_unknown },
313
{ "lv.rl.b",   "rD,rA,rB",     "00 0xA  DDDDD AAAAA BBBB B--- 0x6 0x7", EFI, 0,
314
  it_unknown },
315
{ "lv.rl.h",   "rD,rA,rB",     "00 0xA  DDDDD AAAAA BBBB B--- 0x6 0x8", EFI, 0,
316
  it_unknown },
317
{ "lv.sll.b",  "rD,rA,rB",     "00 0xA  DDDDD AAAAA BBBB B--- 0x6 0x9", EFI, 0,
318
  it_unknown },
319
{ "lv.sll.h",  "rD,rA,rB",     "00 0xA  DDDDD AAAAA BBBB B--- 0x6 0xA", EFI, 0,
320
  it_unknown },
321
{ "lv.sll",    "rD,rA,rB",     "00 0xA  DDDDD AAAAA BBBB B--- 0x6 0xB", EFI, 0,
322
  it_unknown },
323
{ "lv.srl.b",  "rD,rA,rB",     "00 0xA  DDDDD AAAAA BBBB B--- 0x6 0xC", EFI, 0,
324
  it_unknown },
325
{ "lv.srl.h",  "rD,rA,rB",     "00 0xA  DDDDD AAAAA BBBB B--- 0x6 0xD", EFI, 0,
326
  it_unknown },
327
{ "lv.sra.b",  "rD,rA,rB",     "00 0xA  DDDDD AAAAA BBBB B--- 0x6 0xE", EFI, 0,
328
  it_unknown },
329
{ "lv.sra.h",  "rD,rA,rB",     "00 0xA  DDDDD AAAAA BBBB B--- 0x6 0xF", EFI, 0,
330
  it_unknown },
331
{ "lv.srl",    "rD,rA,rB",     "00 0xA  DDDDD AAAAA BBBB B--- 0x7 0x0", EFI, 0,
332
  it_unknown },
333
{ "lv.sub.b",  "rD,rA,rB",     "00 0xA  DDDDD AAAAA BBBB B--- 0x7 0x1", EFI, 0,
334
  it_unknown },
335
{ "lv.sub.h",  "rD,rA,rB",     "00 0xA  DDDDD AAAAA BBBB B--- 0x7 0x2", EFI, 0,
336
  it_unknown },
337
{ "lv.subs.b", "rD,rA,rB",     "00 0xA  DDDDD AAAAA BBBB B--- 0x7 0x3", EFI, 0,
338
  it_unknown },
339
{ "lv.subs.h", "rD,rA,rB",     "00 0xA  DDDDD AAAAA BBBB B--- 0x7 0x4", EFI, 0,
340
  it_unknown },
341
{ "lv.subu.b", "rD,rA,rB",     "00 0xA  DDDDD AAAAA BBBB B--- 0x7 0x5", EFI, 0,
342
  it_unknown },
343
{ "lv.subu.h", "rD,rA,rB",     "00 0xA  DDDDD AAAAA BBBB B--- 0x7 0x6", EFI, 0,
344
  it_unknown },
345
{ "lv.subus.b","rD,rA,rB",     "00 0xA  DDDDD AAAAA BBBB B--- 0x7 0x7", EFI, 0,
346
  it_unknown },
347
{ "lv.subus.h","rD,rA,rB",     "00 0xA  DDDDD AAAAA BBBB B--- 0x7 0x8", EFI, 0,
348
  it_unknown },
349
{ "lv.unpack.b","rD,rA,rB",    "00 0xA  DDDDD AAAAA BBBB B--- 0x7 0x9", EFI, 0,
350
  it_unknown },
351
{ "lv.unpack.h","rD,rA,rB",    "00 0xA  DDDDD AAAAA BBBB B--- 0x7 0xA", EFI, 0,
352
  it_unknown },
353
{ "lv.xor",    "rD,rA,rB",     "00 0xA  DDDDD AAAAA BBBB B--- 0x7 0xB", EFI, 0,
354
  it_unknown },
355
{ "lv.cust1",  "",             "00 0xA  ----- ----- ---- ---- 0xC ----", EFI, 0,
356
  it_unknown },
357
{ "lv.cust2",  "",             "00 0xA  ----- ----- ---- ---- 0xD ----", EFI, 0,
358
  it_unknown },
359
{ "lv.cust3",  "",             "00 0xA  ----- ----- ---- ---- 0xE ----", EFI, 0,
360
  it_unknown },
361
{ "lv.cust4",  "",             "00 0xA  ----- ----- ---- ---- 0xF ----", EFI, 0,
362
  it_unknown },
363 676 markom
 
364 1346 nogj
{ "l.jr",      "rB",           "01 0x1  ----- ----- BBBB B--- ---- ----",
365
  EF(l_jr), OR32_IF_DELAY, it_jump },
366
{ "l.jalr",    "rB",           "01 0x2  ----- ----- BBBB B--- ---- ----",
367
  EF(l_jalr), OR32_IF_DELAY, it_jump },
368 1554 phoenix
{ "l.maci",    "rA,I",         "01 0x3  IIIII AAAAA ---- -III IIII IIII",
369 1346 nogj
  EF(l_mac), 0, it_mac },
370
{ "l.cust1",   "",             "01 0xC  ----- ----- ---- ---- ---- ----",
371
  EF(l_cust1), 0, it_unknown },
372
{ "l.cust2",   "",             "01 0xD  ----- ----- ---- ---- ---- ----",
373
  EF(l_cust2), 0, it_unknown },
374
{ "l.cust3",   "",             "01 0xE  ----- ----- ---- ---- ---- ----",
375
  EF(l_cust3), 0, it_unknown },
376
{ "l.cust4",   "",             "01 0xF  ----- ----- ---- ---- ---- ----",
377
  EF(l_cust4), 0, it_unknown },
378 133 markom
 
379 1346 nogj
{ "l.ld",      "rD,I(rA)",     "10 0x0  DDDDD AAAAA IIII IIII IIII IIII", EFI,
380
  0, it_load },
381
{ "l.lwz",     "rD,I(rA)",     "10 0x1  DDDDD AAAAA IIII IIII IIII IIII",
382
  EF(l_lwz), 0, it_load },
383
{ "l.lws",     "rD,I(rA)",     "10 0x2  DDDDD AAAAA IIII IIII IIII IIII", EFI,
384
  0, it_load },
385
{ "l.lbz",     "rD,I(rA)",     "10 0x3  DDDDD AAAAA IIII IIII IIII IIII",
386
  EF(l_lbz), 0, it_load },
387
{ "l.lbs",     "rD,I(rA)",     "10 0x4  DDDDD AAAAA IIII IIII IIII IIII",
388
  EF(l_lbs), 0, it_load },
389
{ "l.lhz",     "rD,I(rA)",     "10 0x5  DDDDD AAAAA IIII IIII IIII IIII",
390
  EF(l_lhz), 0, it_load },
391
{ "l.lhs",     "rD,I(rA)",     "10 0x6  DDDDD AAAAA IIII IIII IIII IIII",
392
  EF(l_lhs), 0, it_load },
393 133 markom
 
394 1346 nogj
{ "l.addi",    "rD,rA,I",      "10 0x7  DDDDD AAAAA IIII IIII IIII IIII",
395
  EF(l_add), OR32_W_FLAG, it_arith },
396
{ "l.addic",   "rD,rA,I",      "10 0x8  DDDDD AAAAA IIII IIII IIII IIII", EFI,
397
  0, it_arith },
398
{ "l.andi",    "rD,rA,K",      "10 0x9  DDDDD AAAAA KKKK KKKK KKKK KKKK",
399
  EF(l_and), OR32_W_FLAG, it_arith },
400
{ "l.ori",     "rD,rA,K",      "10 0xA  DDDDD AAAAA KKKK KKKK KKKK KKKK",
401
  EF(l_or), 0, it_arith },
402
{ "l.xori",    "rD,rA,I",      "10 0xB  DDDDD AAAAA IIII IIII IIII IIII",
403
  EF(l_xor), 0, it_arith },
404
{ "l.muli",    "rD,rA,I",      "10 0xC  DDDDD AAAAA IIII IIII IIII IIII",
405
  EF(l_mul), 0, it_arith },
406
{ "l.mfspr",   "rD,rA,K",      "10 0xD  DDDDD AAAAA KKKK KKKK KKKK KKKK",
407
  EF(l_mfspr), 0, it_move },
408
{ "l.slli",    "rD,rA,L",      "10 0xE  DDDDD AAAAA ---- ---- 00LL LLLL",
409
  EF(l_sll), 0, it_shift },
410
{ "l.srli",    "rD,rA,L",      "10 0xE  DDDDD AAAAA ---- ---- 01LL LLLL",
411
  EF(l_srl), 0, it_shift },
412
{ "l.srai",    "rD,rA,L",      "10 0xE  DDDDD AAAAA ---- ---- 10LL LLLL",
413
  EF(l_sra), 0, it_shift },
414
{ "l.rori",    "rD,rA,L",      "10 0xE  DDDDD AAAAA ---- ---- 11LL LLLL", EFI,
415
  0, it_shift },
416 133 markom
 
417 1346 nogj
{ "l.sfeqi",   "rA,I",         "10 0xF  00000 AAAAA IIII IIII IIII IIII",
418
  EF(l_sfeq), OR32_W_FLAG, it_compare },
419
{ "l.sfnei",   "rA,I",         "10 0xF  00001 AAAAA IIII IIII IIII IIII",
420
  EF(l_sfne), OR32_W_FLAG, it_compare },
421
{ "l.sfgtui",  "rA,I",         "10 0xF  00010 AAAAA IIII IIII IIII IIII",
422
  EF(l_sfgtu), OR32_W_FLAG, it_compare },
423
{ "l.sfgeui",  "rA,I",         "10 0xF  00011 AAAAA IIII IIII IIII IIII",
424
  EF(l_sfgeu), OR32_W_FLAG, it_compare },
425
{ "l.sfltui",  "rA,I",         "10 0xF  00100 AAAAA IIII IIII IIII IIII",
426
  EF(l_sfltu), OR32_W_FLAG, it_compare },
427
{ "l.sfleui",  "rA,I",         "10 0xF  00101 AAAAA IIII IIII IIII IIII",
428
  EF(l_sfleu), OR32_W_FLAG, it_compare },
429
{ "l.sfgtsi",  "rA,I",         "10 0xF  01010 AAAAA IIII IIII IIII IIII",
430
  EF(l_sfgts), OR32_W_FLAG, it_compare },
431
{ "l.sfgesi",  "rA,I",         "10 0xF  01011 AAAAA IIII IIII IIII IIII",
432
  EF(l_sfges), OR32_W_FLAG, it_compare },
433
{ "l.sfltsi",  "rA,I",         "10 0xF  01100 AAAAA IIII IIII IIII IIII",
434
  EF(l_sflts), OR32_W_FLAG, it_compare },
435
{ "l.sflesi",  "rA,I",         "10 0xF  01101 AAAAA IIII IIII IIII IIII",
436
  EF(l_sfles), OR32_W_FLAG, it_compare },
437 133 markom
 
438 1346 nogj
{ "l.mtspr",   "rA,rB,K",      "11 0x0  KKKKK AAAAA BBBB BKKK KKKK KKKK",
439
  EF(l_mtspr), 0, it_move },
440
{ "l.mac",     "rA,rB",        "11 0x1  ----- AAAAA BBBB B--- ---- 0x1",
441
  EF(l_mac), 0, it_mac },
442
{ "l.msb",     "rA,rB",        "11 0x1  ----- AAAAA BBBB B--- ---- 0x2",
443
  EF(l_msb), 0, it_mac },
444 133 markom
 
445 1346 nogj
{ "lf.add.s",   "rD,rA,rB",    "11 0x2  DDDDD AAAAA BBBB B--- 0x0 0x0",
446
  EF(lf_add_s), 0, it_float },
447
{ "lf.sub.s",   "rD,rA,rB",    "11 0x2  DDDDD AAAAA BBBB B--- 0x0 0x1",
448
  EF(lf_sub_s), 0, it_float },
449
{ "lf.mul.s",   "rD,rA,rB",    "11 0x2  DDDDD AAAAA BBBB B--- 0x0 0x2",
450
  EF(lf_mul_s), 0, it_float },
451
{ "lf.div.s",   "rD,rA,rB",    "11 0x2  DDDDD AAAAA BBBB B--- 0x0 0x3",
452
  EF(lf_div_s), 0, it_float },
453
{ "lf.itof.s",  "rD,rA",       "11 0x2  DDDDD AAAAA 0000 0--- 0x0 0x4",
454
  EF(lf_itof_s), 0, it_float },
455
{ "lf.ftoi.s",  "rD,rA",       "11 0x2  DDDDD AAAAA 0000 0--- 0x0 0x5",
456
  EF(lf_ftoi_s), 0, it_float },
457
{ "lf.rem.s",   "rD,rA,rB",    "11 0x2  DDDDD AAAAA BBBB B--- 0x0 0x6",
458
  EF(lf_rem_s), 0, it_float },
459
{ "lf.madd.s",  "rD,rA,rB",    "11 0x2  DDDDD AAAAA BBBB B--- 0x0 0x7",
460
  EF(lf_madd_s), 0, it_float },
461
{ "lf.sfeq.s",  "rA,rB",       "11 0x2  ----- AAAAA BBBB B--- 0x0 0x8",
462
  EF(lf_sfeq_s), 0, it_float },
463
{ "lf.sfne.s",  "rA,rB",       "11 0x2  ----- AAAAA BBBB B--- 0x0 0x9",
464
  EF(lf_sfne_s), 0, it_float },
465
{ "lf.sfgt.s",  "rA,rB",       "11 0x2  ----- AAAAA BBBB B--- 0x0 0xA",
466
  EF(lf_sfgt_s), 0, it_float },
467
{ "lf.sfge.s",  "rA,rB",       "11 0x2  ----- AAAAA BBBB B--- 0x0 0xB",
468
  EF(lf_sfge_s), 0, it_float },
469
{ "lf.sflt.s",  "rA,rB",       "11 0x2  ----- AAAAA BBBB B--- 0x0 0xC",
470
  EF(lf_sflt_s), 0, it_float },
471
{ "lf.sfle.s",  "rA,rB",       "11 0x2  ----- AAAAA BBBB B--- 0x0 0xD",
472
  EF(lf_sfle_s), 0, it_float },
473
{ "lf.cust1.s", "rA,rB",       "11 0x2  ----- AAAAA BBBB B--- 0xD ----", EFI,
474
  0, it_float },
475 133 markom
 
476 1346 nogj
{ "lf.add.d",   "rD,rA,rB",    "11 0x2  DDDDD AAAAA BBBB B--- 0x1 0x0", EFI, 0,
477
  it_float },
478
{ "lf.sub.d",   "rD,rA,rB",    "11 0x2  DDDDD AAAAA BBBB B--- 0x1 0x1", EFI, 0,
479
  it_float },
480
{ "lf.mul.d",   "rD,rA,rB",    "11 0x2  DDDDD AAAAA BBBB B--- 0x1 0x2", EFI, 0,
481
  it_float },
482
{ "lf.div.d",   "rD,rA,rB",    "11 0x2  DDDDD AAAAA BBBB B--- 0x1 0x3", EFI, 0,
483
  it_float },
484
{ "lf.itof.d",  "rD,rA",       "11 0x2  DDDDD AAAAA 0000 0--- 0x1 0x4", EFI, 0,
485
  it_float },
486
{ "lf.ftoi.d",  "rD,rA",       "11 0x2  DDDDD AAAAA 0000 0--- 0x1 0x5", EFI, 0,
487
  it_float },
488
{ "lf.rem.d",   "rD,rA,rB",    "11 0x2  DDDDD AAAAA BBBB B--- 0x1 0x6", EFI, 0,
489
  it_float },
490
{ "lf.madd.d",  "rD,rA,rB",    "11 0x2  DDDDD AAAAA BBBB B--- 0x1 0x7", EFI, 0,
491
  it_float },
492
{ "lf.sfeq.d",  "rA,rB",       "11 0x2  ----- AAAAA BBBB B--- 0x1 0x8", EFI, 0,
493
  it_float },
494
{ "lf.sfne.d",  "rA,rB",       "11 0x2  ----- AAAAA BBBB B--- 0x1 0x9", EFI, 0,
495
  it_float },
496
{ "lf.sfgt.d",  "rA,rB",       "11 0x2  ----- AAAAA BBBB B--- 0x1 0xA", EFI, 0,
497
  it_float },
498
{ "lf.sfge.d",  "rA,rB",       "11 0x2  ----- AAAAA BBBB B--- 0x1 0xB", EFI, 0,
499
  it_float },
500
{ "lf.sflt.d",  "rA,rB",       "11 0x2  ----- AAAAA BBBB B--- 0x1 0xC", EFI, 0,
501
  it_float },
502
{ "lf.sfle.d",  "rA,rB",       "11 0x2  ----- AAAAA BBBB B--- 0x1 0xD", EFI, 0,
503
  it_float },
504
{ "lf.cust1.d", "rA,rB",       "11 0x2  ----- AAAAA BBBB B--- 0xE ----", EFI, 0,
505
  it_float },
506 676 markom
 
507 1346 nogj
{ "l.sd",      "I(rD),rB",     "11 0x4  IIIII DDDDD BBBB BIII IIII IIII", EFI,
508
  0, it_store },
509
{ "l.sw",      "I(rD),rB",     "11 0x5  IIIII DDDDD BBBB BIII IIII IIII",
510
  EF(l_sw), 0, it_store },
511
{ "l.sb",      "I(rD),rB",     "11 0x6  IIIII DDDDD BBBB BIII IIII IIII",
512
  EF(l_sb), 0, it_store },
513
{ "l.sh",      "I(rD),rB",     "11 0x7  IIIII DDDDD BBBB BIII IIII IIII",
514
  EF(l_sh), 0, it_store },
515 1295 lampret
 
516 1346 nogj
{ "l.add",     "rD,rA,rB",     "11 0x8  DDDDD AAAAA BBBB B-00 ---- 0x0",
517
  EF(l_add), OR32_W_FLAG, it_arith },
518
{ "l.addc",    "rD,rA,rB",     "11 0x8  DDDDD AAAAA BBBB B-00 ---- 0x1",
519
  EF(l_addc), OR32_W_FLAG, it_arith },
520
{ "l.sub",     "rD,rA,rB",     "11 0x8  DDDDD AAAAA BBBB B-00 ---- 0x2",
521
  EF(l_sub), 0, it_arith },
522
{ "l.and",     "rD,rA,rB",     "11 0x8  DDDDD AAAAA BBBB B-00 ---- 0x3",
523
  EF(l_and), OR32_W_FLAG, it_arith },
524
{ "l.or",      "rD,rA,rB",     "11 0x8  DDDDD AAAAA BBBB B-00 ---- 0x4",
525
  EF(l_or), 0, it_arith },
526
{ "l.xor",     "rD,rA,rB",     "11 0x8  DDDDD AAAAA BBBB B-00 ---- 0x5",
527
  EF(l_xor), 0, it_arith },
528
{ "l.mul",     "rD,rA,rB",     "11 0x8  DDDDD AAAAA BBBB B-11 ---- 0x6",
529
  EF(l_mul), 0, it_arith },
530 1295 lampret
 
531 1346 nogj
{ "l.sll",     "rD,rA,rB",     "11 0x8  DDDDD AAAAA BBBB B-00 00-- 0x8",
532
  EF(l_sll), 0, it_shift },
533
{ "l.srl",     "rD,rA,rB",     "11 0x8  DDDDD AAAAA BBBB B-00 01-- 0x8",
534
  EF(l_srl), 0, it_shift },
535
{ "l.sra",     "rD,rA,rB",     "11 0x8  DDDDD AAAAA BBBB B-00 10-- 0x8",
536
  EF(l_sra), 0, it_shift },
537
{ "l.ror",     "rD,rA,rB",     "11 0x8  DDDDD AAAAA BBBB B-00 11-- 0x8", EFI,
538
  0, it_shift },
539
{ "l.div",     "rD,rA,rB",     "11 0x8  DDDDD AAAAA BBBB B-11 ---- 0x9",
540
  EF(l_div), 0, it_arith },
541
{ "l.divu",    "rD,rA,rB",     "11 0x8  DDDDD AAAAA BBBB B-11 ---- 0xA",
542
  EF(l_divu), 0, it_arith },
543
{ "l.mulu",    "rD,rA,rB",     "11 0x8  DDDDD AAAAA BBBB B-11 ---- 0xB", EFI,
544
  0, it_arith },
545
{ "l.extbs",   "rD,rA",     "11 0x8  DDDDD AAAAA ---- --00 01-- 0xC",
546
  EF(l_extbs), 0, it_move },
547
{ "l.exths",   "rD,rA",     "11 0x8  DDDDD AAAAA ---- --00 00-- 0xC",
548
  EF(l_exths), 0, it_move },
549
{ "l.extws",   "rD,rA",     "11 0x8  DDDDD AAAAA ---- --00 00-- 0xD",
550
  EF(l_extws), 0, it_move },
551
{ "l.extbz",   "rD,rA",     "11 0x8  DDDDD AAAAA ---- --00 11-- 0xC",
552
  EF(l_extbz), 0, it_move },
553
{ "l.exthz",   "rD,rA",     "11 0x8  DDDDD AAAAA ---- --00 10-- 0xC",
554
  EF(l_exthz), 0, it_move },
555
{ "l.extwz",   "rD,rA",     "11 0x8  DDDDD AAAAA ---- --00 01-- 0xD",
556
  EF(l_extwz), 0, it_move },
557
{ "l.cmov",    "rD,rA,rB",     "11 0x8  DDDDD AAAAA BBBB B-00 ---- 0xE",
558
  EF(l_cmov), OR32_R_FLAG, it_move },
559 1384 nogj
{ "l.ff1",     "rD,rA",     "11 0x8  DDDDD AAAAA ---- --00 ---- 0xF", EFI, 0,
560
  it_arith },
561 1590 lampret
{ "l.fl1",     "rD,rA",     "11 0x8  DDDDD AAAAA ---- --01 ---- 0xF", EFI, 0,
562
  it_arith },
563 133 markom
 
564 1346 nogj
{ "l.sfeq",    "rA,rB",        "11 0x9  00000 AAAAA BBBB B--- ---- ----",
565
  EF(l_sfeq), OR32_W_FLAG, it_compare },
566
{ "l.sfne",    "rA,rB",        "11 0x9  00001 AAAAA BBBB B--- ---- ----",
567
  EF(l_sfne), OR32_W_FLAG, it_compare },
568
{ "l.sfgtu",   "rA,rB",        "11 0x9  00010 AAAAA BBBB B--- ---- ----",
569
  EF(l_sfgtu), OR32_W_FLAG, it_compare },
570
{ "l.sfgeu",   "rA,rB",        "11 0x9  00011 AAAAA BBBB B--- ---- ----",
571
  EF(l_sfgeu), OR32_W_FLAG, it_compare },
572
{ "l.sfltu",   "rA,rB",        "11 0x9  00100 AAAAA BBBB B--- ---- ----",
573
  EF(l_sfltu), OR32_W_FLAG, it_compare },
574
{ "l.sfleu",   "rA,rB",        "11 0x9  00101 AAAAA BBBB B--- ---- ----",
575
  EF(l_sfleu), OR32_W_FLAG, it_compare },
576
{ "l.sfgts",   "rA,rB",        "11 0x9  01010 AAAAA BBBB B--- ---- ----",
577
  EF(l_sfgts), OR32_W_FLAG, it_compare },
578
{ "l.sfges",   "rA,rB",        "11 0x9  01011 AAAAA BBBB B--- ---- ----",
579
  EF(l_sfges), OR32_W_FLAG, it_compare },
580
{ "l.sflts",   "rA,rB",        "11 0x9  01100 AAAAA BBBB B--- ---- ----",
581
  EF(l_sflts), OR32_W_FLAG, it_compare },
582
{ "l.sfles",   "rA,rB",        "11 0x9  01101 AAAAA BBBB B--- ---- ----",
583
  EF(l_sfles), OR32_W_FLAG, it_compare },
584 676 markom
 
585 1346 nogj
{ "l.cust5",   "rD,rA,rB,L,K", "11 0xC  DDDDD AAAAA BBBB BLLL LLLK KKKK", EFI,
586
  0, it_unknown },
587
{ "l.cust6",   "",             "11 0xD  ----- ----- ---- ---- ---- ----", EFI,
588
  0, it_unknown },
589
{ "l.cust7",   "",             "11 0xE  ----- ----- ---- ---- ---- ----", EFI,
590
  0, it_unknown },
591
{ "l.cust8",   "",             "11 0xF  ----- ----- ---- ---- ---- ----", EFI,
592
  0, it_unknown },
593 133 markom
 
594 221 markom
/* This section should not be defined in or1ksim, since it contains duplicates,
595
   which would cause machine builder to complain.  */
596 374 simons
#ifdef HAS_CUST
597 1346 nogj
{ "l.cust5_1",   "rD",         "11 0xC  DDDDD ----- ---- ---- ---- ----", EFI,
598
  0, it_unknown },
599
{ "l.cust5_2",   "rD,rA"   ,   "11 0xC  DDDDD AAAAA ---- ---- ---- ----", EFI,
600
  0, it_unknown },
601
{ "l.cust5_3",   "rD,rA,rB",   "11 0xC  DDDDD AAAAA BBBB B--- ---- ----", EFI,
602
  0, it_unknown },
603 221 markom
 
604 1346 nogj
{ "l.cust6_1",   "rD",         "11 0xD  DDDDD ----- ---- ---- ---- ----", EFI,
605
  0, it_unknown },
606
{ "l.cust6_2",   "rD,rA"   ,   "11 0xD  DDDDD AAAAA ---- ---- ---- ----", EFI,
607
  0, it_unknown },
608
{ "l.cust6_3",   "rD,rA,rB",   "11 0xD  DDDDD AAAAA BBBB B--- ---- ----", EFI,
609
  0, it_unknown },
610 221 markom
 
611 1346 nogj
{ "l.cust7_1",   "rD",         "11 0xE  DDDDD ----- ---- ---- ---- ----", EFI,
612
  0, it_unknown },
613
{ "l.cust7_2",   "rD,rA"   ,   "11 0xE  DDDDD AAAAA ---- ---- ---- ----", EFI,
614
  0, it_unknown },
615
{ "l.cust7_3",   "rD,rA,rB",   "11 0xE  DDDDD AAAAA BBBB B--- ---- ----", EFI,
616
  0, it_unknown },
617 221 markom
 
618 1346 nogj
{ "l.cust8_1",   "rD",         "11 0xF  DDDDD ----- ---- ---- ---- ----", EFI,
619
  0, it_unknown },
620
{ "l.cust8_2",   "rD,rA"   ,   "11 0xF  DDDDD AAAAA ---- ---- ---- ----", EFI,
621
  0, it_unknown },
622
{ "l.cust8_3",   "rD,rA,rB",   "11 0xF  DDDDD AAAAA BBBB B--- ---- ----", EFI,
623
  0, it_unknown },
624 221 markom
#endif
625
 
626 1346 nogj
{ "", "", "", EFI, 0, 0 }  /* Dummy entry, not included in num_opcodes.  This
627
                            * lets code examine entry i+1 without checking
628
                            * if we've run off the end of the table.  */
629 133 markom
};
630
 
631
#undef EFI
632
#undef EFN
633
#undef EF 
634
 
635
/* **INDENT-ON** */
636
 
637 371 markom
/* Define dummy, if debug is not defined.  */
638 1341 nogj
#ifndef HAS_DEBUG
639
#define debug(l, fmt...) ;
640 371 markom
#endif
641 133 markom
 
642 371 markom
CONST int num_opcodes = ((sizeof(or32_opcodes)) / (sizeof(struct or32_opcode))) - 1;
643
 
644 138 markom
/* Calculates instruction length in bytes. Always 4 for OR32. */
645
int
646
insn_len(int insn_index)
647 133 markom
{
648
  insn_index = 0; /* Just to get rid that warning.  */
649
  return 4;
650
}
651
 
652
/* Is individual insn's operand signed or unsigned? */
653 138 markom
int
654
letter_signed(char l)
655 133 markom
{
656
  CONST struct or32_letter *pletter;
657
 
658
  for(pletter = or32_letters; pletter->letter != '\0'; pletter++)
659
    if (pletter->letter == l)
660
      return pletter->sign;
661
 
662
  printf("letter_signed(%c): Unknown letter.\n", l);
663
  return 0;
664
}
665
 
666 703 markom
/* Simple cache for letter ranges */
667
static int range_cache[256] = {0};
668
 
669 133 markom
/* Number of letters in the individual lettered operand. */
670 138 markom
int
671
letter_range(char l)
672 133 markom
{
673
  CONST struct or32_opcode *pinsn;
674
  char *enc;
675
  int range = 0;
676 703 markom
 
677
  /* Is value cached? */
678 1308 phoenix
  if ((range = range_cache[(unsigned char)l])) return range;
679 133 markom
 
680 138 markom
  for(pinsn = or32_opcodes; strlen(pinsn->name); pinsn++)
681
    {
682
      if (strchr(pinsn->encoding,l))
683
        {
684
          for (enc = pinsn->encoding; *enc != '\0'; enc++)
685
            if ((*enc == '0') && (*(enc+1) == 'x'))
686
              enc += 2;
687
            else if (*enc == l)
688
              range++;
689 703 markom
          return range_cache[(unsigned char)l] = range;
690 133 markom
        }
691
    }
692 703 markom
 
693 133 markom
  printf("\nABORT: letter_range(%c): Never used letter.\n", l);
694
  exit(1);
695
}
696
 
697
/* MM: Returns index of given instruction name.  */
698 138 markom
int
699
insn_index (char *insn)
700
{
701 133 markom
  int i, found = -1;
702 371 markom
  for (i = 0; i < num_opcodes; i++)
703 138 markom
    if (!strcmp (or32_opcodes[i].name, insn))
704
      {
705
        found = i;
706
        break;
707
      }
708 133 markom
  return found;
709
}
710
 
711 717 markom
/* Returns name of the specified instruction index */
712
CONST char *
713
insn_name(int index)
714 138 markom
{
715 371 markom
  if (index >= 0 && index < num_opcodes)
716 133 markom
    return or32_opcodes[index].name;
717
  else
718
    return "???";
719
}
720
 
721 1342 nogj
#if defined(HAS_EXECUTION) && SIMPLE_EXECUTION
722 717 markom
void
723 1342 nogj
l_none(struct iqueue_entry *current)
724
{
725
}
726 1452 nogj
#elif defined(HAS_EXECUTION) && DYNAMIC_EXECUTION
727
void
728
l_none(struct op_queue *opq, int *param_t, orreg_t *param, int delay_slot)
729
{
730
}
731 1342 nogj
#else
732
void
733 717 markom
l_none()
734 138 markom
{
735 133 markom
}
736 1342 nogj
#endif
737 133 markom
 
738
/*** Finite automata for instruction decoding building code ***/
739
 
740 1341 nogj
/* Find symbols in encoding.  */
741 706 markom
unsigned long
742 133 markom
insn_extract(param_ch, enc_initial)
743
     char param_ch;
744
     char *enc_initial;
745
{
746
  char *enc;
747
  unsigned long ret = 0;
748
  unsigned opc_pos = 32;
749
  for (enc = enc_initial; *enc != '\0'; )
750
    if ((*enc == '0') && (*(enc+1) == 'x'))
751
      {
752
        unsigned long tmp = strtol(enc+2, NULL, 16);
753
        opc_pos -= 4;
754 138 markom
        if (param_ch == '0' || param_ch == '1')
755
          {
756
            if (param_ch == '0')
757
              tmp = 15 - tmp;
758
            ret |= tmp << opc_pos;
759
          }
760 133 markom
        enc += 3;
761
      }
762 138 markom
    else
763
      {
764
        if (*enc == '0' || *enc == '1' || *enc == '-' || isalpha(*enc) )
765
          {
766
            opc_pos--;
767
            if (param_ch == *enc)
768
              ret |= 1 << opc_pos;
769
          }
770
        enc++;
771 133 markom
      }
772
  return ret;
773
}
774
 
775 138 markom
#define MAX_AUTOMATA_SIZE (1200)
776
#define MAX_OP_TABLE_SIZE (1200)
777 133 markom
#define MAX_LEN           (8)
778
 
779
#ifndef MIN
780
# define MIN(x,y)          ((x) < (y) ? (x) : (y))
781
#endif
782
 
783
unsigned long *automata;
784
int nuncovered;
785
int curpass = 0;
786
 
787 1341 nogj
/* MM: Struct that holds runtime build information about instructions.  */
788 1342 nogj
struct temp_insn_struct *ti;
789 138 markom
 
790
struct insn_op_struct *op_data, **op_start;
791
 
792
/* Recursive utility function used to find best match and to build automata.  */
793
 
794
static unsigned long *
795
cover_insn (unsigned long *cur, int pass, unsigned int mask)
796
{
797 133 markom
  int best_first = 0, best_len = 0, i, last_match = -1, ninstr = 0;
798
  unsigned long cur_mask = mask;
799
  unsigned long *next;
800
 
801
  for (i = 0; i < num_opcodes; i++)
802 138 markom
    if (ti[i].in_pass == pass)
803
      {
804
        cur_mask &= ti[i].insn_mask;
805
        ninstr++;
806
        last_match = i;
807
      }
808
 
809 344 markom
  debug(8, "%08X %08X\n", mask, cur_mask);
810 138 markom
  if (ninstr == 0)
811
    return 0;
812
  if (ninstr == 1)
813
    {
814
      /* Leaf holds instruction index. */
815 344 markom
      debug(8, "%i>I%i %s\n", cur - automata, last_match, or32_opcodes[last_match].name);
816 138 markom
      *cur = LEAF_FLAG | last_match;
817
      cur++;
818
      nuncovered--;
819
    } else {
820
      /* Find longest match.  */
821
      for (i = 0; i < 32; i++)
822
        {
823
          int len;
824
          for (len = best_len + 1; len < MIN(MAX_LEN, 33 - i); len++)
825
            {
826
              unsigned long m = (1UL << ((unsigned long)len)) - 1;
827 344 markom
              debug(9, " (%i(%08X & %08X>>%i = %08X, %08X)",len,m, cur_mask, i, (cur_mask >> (unsigned)i), (cur_mask >> (unsigned)i) & m);
828 138 markom
              if ((m & (cur_mask >> (unsigned)i)) == m)
829
                {
830
                  best_len = len;
831
                  best_first = i;
832 344 markom
                  debug(9, "!");
833 138 markom
                }
834
              else
835
                break;
836
            }
837
        }
838 344 markom
      debug(9, "\n");
839 138 markom
      if (!best_len)
840
        {
841
          fprintf (stderr, "%i instructions match mask 0x%08X:\n", ninstr, mask);
842
          for (i = 0; i < num_opcodes; i++)
843
            if (ti[i].in_pass == pass)
844
              fprintf (stderr, "%s ", or32_opcodes[i].name);
845
 
846
          fprintf (stderr, "\n");
847
          exit (1);
848
        }
849 344 markom
      debug(8, "%i> #### %i << %i (%i) ####\n", cur - automata, best_len, best_first, ninstr);
850 138 markom
      *cur = best_first;
851
      cur++;
852
      *cur = (1 << best_len) - 1;
853
      cur++;
854
      next = cur;
855
      /* Allocate space for pointers.  */
856
      cur += 1 << best_len;
857
      cur_mask = (1 << (unsigned long)best_len) - 1;
858
 
859
      for (i = 0; i < (1 << (unsigned long)best_len); i++)
860
        {
861
          int j;
862
          unsigned long *c;
863
          curpass++;
864
          for (j = 0; j < num_opcodes; j++)
865
            if (ti[j].in_pass == pass
866 371 markom
                && ((ti[j].insn >> best_first) & cur_mask) == (unsigned long) i
867 138 markom
                && ((ti[j].insn_mask >> best_first) & cur_mask) == cur_mask)
868
              ti[j].in_pass = curpass;
869
 
870 344 markom
          debug(9, "%08X %08X %i\n", mask, cur_mask, best_first);
871 138 markom
          c = cover_insn (cur, curpass, mask & (~(cur_mask << best_first)));
872
          if (c)
873
            {
874 344 markom
              debug(8, "%i> #%X -> %u\n", next - automata, i, cur - automata);
875 138 markom
              *next = cur - automata;
876
              cur = c;
877
            }
878
          else
879
            {
880 344 markom
              debug(8, "%i> N/A\n", next - automata);
881 138 markom
              *next = 0;
882
            }
883
          next++;
884
        }
885 133 markom
    }
886 138 markom
  return cur;
887
}
888 133 markom
 
889 138 markom
/* Returns number of nonzero bits. */
890
static int
891
num_ones (unsigned long value)
892
{
893
  int c = 0;
894
  while (value)
895
    {
896
      if (value & 1)
897
        c++;
898
      value >>= 1;
899 133 markom
    }
900 138 markom
  return c;
901
}
902 133 markom
 
903 138 markom
/* Utility function, which converts parameters from or32_opcode format to more binary form.
904
   Parameters are stored in ti struct.  */
905
 
906
static struct insn_op_struct *
907
parse_params (CONST struct or32_opcode *opcode, struct insn_op_struct *cur)
908
{
909
  char *args = opcode->args;
910
  int i, type;
911 1346 nogj
  int num_cur_op = 0;;
912 138 markom
 
913
  i = 0;
914
  type = 0;
915 262 markom
  /* In case we don't have any parameters, we add dummy read from r0.  */
916
  if (!(*args)) {
917 263 markom
    cur->type = OPTYPE_REG | OPTYPE_OP | OPTYPE_LAST;
918 262 markom
    cur->data = 0;
919 355 markom
    debug(9, "#%08X %08X\n", cur->type, cur->data);
920 262 markom
    cur++;
921
    return cur;
922
  }
923
 
924 138 markom
  while (*args != '\0')
925
    {
926
      if (*args == 'r')
927
        {
928
          args++;
929
          type |= OPTYPE_REG;
930 1341 nogj
          if(args[1] == 'D')
931
            type |= OPTYPE_DST;
932 133 markom
        }
933 138 markom
      else if (isalpha (*args))
934
        {
935
          unsigned long arg;
936
          arg = insn_extract(*args, opcode->encoding);
937 355 markom
          debug(9, "%s : %08X ------\n", opcode->name, arg);
938 138 markom
          if (letter_signed (*args))
939
            {
940
              type |= OPTYPE_SIG;
941
              type |= ((num_ones (arg) - 1) << OPTYPE_SBIT_SHR) & OPTYPE_SBIT;
942
            }
943
 
944 1346 nogj
          num_cur_op = 0;
945 138 markom
          /* Split argument to sequences of consecutive ones.  */
946
          while (arg)
947
            {
948
              int shr = 0;
949
              unsigned long tmp = arg, mask = 0;
950
              while ((tmp & 1) == 0)
951
                {
952
                  shr++;
953
                  tmp >>= 1;
954
                }
955
              while (tmp & 1)
956
                {
957
                  mask++;
958
                  tmp >>= 1;
959
                }
960
              cur->type = type | shr;
961
              cur->data = mask;
962
              arg &= ~(((1 << mask) - 1) << shr);
963 355 markom
              debug(6, "|%08X %08X\n", cur->type, cur->data);
964 138 markom
              cur++;
965 1346 nogj
              num_cur_op++;
966 138 markom
            }
967
          args++;
968
        }
969
      else if (*args == '(')
970
        {
971
          /* Next param is displacement.  Later we will treat them as one operand.  */
972 1346 nogj
          /* Set the OPTYPE_DIS flag on all insn_op_structs that belong to this
973
           * operand */
974
          while(num_cur_op > 0) {
975
            cur[-num_cur_op].type |= type | OPTYPE_DIS;
976
            num_cur_op--;
977
          }
978
          cur[-1].type |= OPTYPE_OP;
979 355 markom
          debug(9, ">%08X %08X\n", cur->type, cur->data);
980 138 markom
          type = 0;
981
          i++;
982
          args++;
983
        }
984
      else if (*args == OPERAND_DELIM)
985
        {
986
          cur--;
987
          cur->type = type | cur->type | OPTYPE_OP;
988 355 markom
          debug(9, ">%08X %08X\n", cur->type, cur->data);
989 138 markom
          cur++;
990
          type = 0;
991
          i++;
992
          args++;
993
        }
994
      else if (*args == '0')
995
        {
996
          cur->type = type;
997
          cur->data = 0;
998 355 markom
          debug(9, ">%08X %08X\n", cur->type, cur->data);
999 138 markom
          cur++;
1000
          type = 0;
1001
          i++;
1002
          args++;
1003
        }
1004
      else if (*args == ')')
1005
        args++;
1006
      else
1007
        {
1008
          fprintf (stderr, "%s : parse error in args.\n", opcode->name);
1009
          exit (1);
1010
        }
1011 133 markom
    }
1012 138 markom
  cur--;
1013
  cur->type = type | cur->type | OPTYPE_OP | OPTYPE_LAST;
1014 355 markom
  debug(9, "#%08X %08X\n", cur->type, cur->data);
1015 138 markom
  cur++;
1016 133 markom
  return cur;
1017
}
1018
 
1019 138 markom
/* Constructs new automata based on or32_opcodes array.  */
1020
 
1021
void
1022
build_automata()
1023
{
1024 371 markom
  int i;
1025 133 markom
  unsigned long *end;
1026 138 markom
  struct insn_op_struct *cur;
1027
 
1028 133 markom
  automata = (unsigned long *) malloc (MAX_AUTOMATA_SIZE * sizeof (unsigned long));
1029 138 markom
  ti = (struct temp_insn_struct *) malloc (sizeof (struct temp_insn_struct) * num_opcodes);
1030 133 markom
 
1031
  nuncovered = num_opcodes;
1032 709 markom
 
1033
#ifdef HAS_EXECUTION
1034 138 markom
  printf("Building automata... ");
1035 709 markom
#endif
1036
 
1037 133 markom
  /* Build temporary information about instructions.  */
1038 138 markom
  for (i = 0; i < num_opcodes; i++)
1039
    {
1040
      unsigned long ones, zeros;
1041
      char *encoding = or32_opcodes[i].encoding;
1042
      ones  = insn_extract('1', encoding);
1043
      zeros = insn_extract('0', encoding);
1044
      ti[i].insn_mask = ones | zeros;
1045
      ti[i].insn = ones;
1046
      ti[i].in_pass = curpass = 0;
1047 344 markom
      /*debug(9, "%s: %s %08X %08X\n", or32_opcodes[i].name,
1048 138 markom
        or32_opcodes[i].encoding, ti[i].insn_mask, ti[i].insn);*/
1049
    }
1050 133 markom
 
1051
  /* Until all are covered search for best criteria to separate them.  */
1052 138 markom
  end = cover_insn (automata, curpass, 0xFFFFFFFF);
1053
  if (end - automata > MAX_AUTOMATA_SIZE)
1054
    {
1055
      fprintf (stderr, "Automata too large. Increase MAX_AUTOMATA_SIZE.");
1056
      exit (1);
1057
    }
1058 709 markom
#ifdef HAS_EXECUTION
1059 138 markom
  printf("done, num uncovered: %i/%i.\n", nuncovered, num_opcodes);
1060 709 markom
#endif
1061 371 markom
 
1062 709 markom
#ifdef HAS_EXECUTION
1063 138 markom
  printf("Parsing operands data... ");
1064 709 markom
#endif
1065 138 markom
  op_data = (struct insn_op_struct *) malloc (MAX_OP_TABLE_SIZE * sizeof (struct insn_op_struct));
1066
  op_start = (struct insn_op_struct **) malloc (num_opcodes * sizeof (struct insn_op_struct *));
1067
  cur = op_data;
1068
  for (i = 0; i < num_opcodes; i++)
1069
    {
1070
      op_start[i] = cur;
1071
      cur = parse_params (&or32_opcodes[i], cur);
1072
      if (cur - op_data > MAX_OP_TABLE_SIZE)
1073
        {
1074
          fprintf (stderr, "Operands table too small, increase MAX_OP_TABLE_SIZE.\n");
1075
          exit (1);
1076
        }
1077
    }
1078 709 markom
#ifdef HAS_EXECUTION
1079 138 markom
  printf("done.\n");
1080 709 markom
#endif
1081 133 markom
}
1082
 
1083 138 markom
void destruct_automata ()
1084
{
1085
  free (ti);
1086 133 markom
  free (automata);
1087 138 markom
  free (op_data);
1088
  free (op_start);
1089 133 markom
}
1090
 
1091
/* Decodes instruction and returns instruction index.  */
1092 138 markom
int insn_decode (unsigned int insn)
1093
{
1094 133 markom
  unsigned long *a = automata;
1095 138 markom
  int i;
1096
  while (!(*a & LEAF_FLAG))
1097
    {
1098
      unsigned int first = *a;
1099 703 markom
      //debug(9, "%i ", a - automata);
1100 138 markom
      a++;
1101
      i = (insn >> first) & *a;
1102
      a++;
1103
      if (!*(a + i))
1104
        { /* Invalid instruction found?  */
1105 703 markom
          //debug(9, "XXX\n", i);
1106 138 markom
          return -1;
1107
        }
1108
      a = automata + *(a + i);
1109
    }
1110
  i = *a & ~LEAF_FLAG;
1111 703 markom
  //debug(9, "%i\n", i);
1112 138 markom
  /* Final check - do we have direct match?
1113
     (based on or32_opcodes this should be the only possibility,
1114
     but in case of invalid/missing instruction we must perform a check)  */
1115
  if ((ti[i].insn_mask & insn) == ti[i].insn)
1116
    return i;
1117
  else
1118
    return -1;
1119 133 markom
}
1120 371 markom
 
1121
static char disassembled_str[50];
1122
char *disassembled = &disassembled_str[0];
1123
 
1124
/* Automagically does zero- or sign- extension and also finds correct
1125
   sign bit position if sign extension is correct extension. Which extension
1126
   is proper is figured out from letter description. */
1127
 
1128 879 markom
unsigned long
1129 371 markom
extend_imm(unsigned long imm, char l)
1130
{
1131
  unsigned long mask;
1132
  int letter_bits;
1133
 
1134
  /* First truncate all bits above valid range for this letter
1135
     in case it is zero extend. */
1136
  letter_bits = letter_range(l);
1137
  mask = (1 << letter_bits) - 1;
1138
  imm &= mask;
1139
 
1140
  /* Do sign extend if this is the right one. */
1141
  if (letter_signed(l) && (imm >> (letter_bits - 1)))
1142
    imm |= (~mask);
1143
 
1144
  return imm;
1145
}
1146
 
1147 879 markom
unsigned long
1148 371 markom
or32_extract(param_ch, enc_initial, insn)
1149
     char param_ch;
1150
     char *enc_initial;
1151
     unsigned long insn;
1152
{
1153
  char *enc;
1154
  unsigned long ret = 0;
1155
  int opc_pos = 0;
1156
  int param_pos = 0;
1157
 
1158
  for (enc = enc_initial; *enc != '\0'; enc++)
1159
    if (*enc == param_ch)
1160
      {
1161
        if (enc - 2 >= enc_initial && (*(enc - 2) == '0') && (*(enc - 1) == 'x'))
1162
          continue;
1163
        else
1164
          param_pos++;
1165
      }
1166
 
1167
#if DEBUG
1168
  printf("or32_extract: %x ", param_pos);
1169
#endif
1170
  opc_pos = 32;
1171
  for (enc = enc_initial; *enc != '\0'; )
1172
    if ((*enc == '0') && (*(enc+1) == 'x'))
1173
      {
1174
        opc_pos -= 4;
1175
        if ((param_ch == '0') || (param_ch == '1'))
1176
          {
1177
            unsigned long tmp = strtol(enc, NULL, 16);
1178
#if DEBUG
1179
            printf(" enc=%s, tmp=%x ", enc, tmp);
1180
#endif
1181
            if (param_ch == '0')
1182
              tmp = 15 - tmp;
1183
            ret |= tmp << opc_pos;
1184
          }
1185
        enc += 3;
1186
      }
1187
    else if ((*enc == '0') || (*enc == '1'))
1188
      {
1189
        opc_pos--;
1190
        if (param_ch == *enc)
1191
          ret |= 1 << opc_pos;
1192
        enc++;
1193
      }
1194
    else if (*enc == param_ch)
1195
      {
1196
        opc_pos--;
1197
        param_pos--;
1198
#if DEBUG
1199
        printf("\n  ret=%x opc_pos=%x, param_pos=%x\n", ret, opc_pos, param_pos);
1200
#endif  
1201
        if (islower(param_ch))
1202
          ret -= ((insn >> opc_pos) & 0x1) << param_pos;
1203
        else
1204
          ret += ((insn >> opc_pos) & 0x1) << param_pos;
1205
        enc++;
1206
      }
1207
    else if (isalpha(*enc))
1208
      {
1209
        opc_pos--;
1210
        enc++;
1211
      }
1212
    else if (*enc == '-')
1213
      {
1214
        opc_pos--;
1215
        enc++;
1216
      }
1217
    else
1218
      enc++;
1219
 
1220
#if DEBUG
1221
  printf ("ret=%x\n", ret);
1222
#endif
1223
  return ret;
1224
}
1225
 
1226
/* Print register. Used only by print_insn. */
1227
 
1228 703 markom
static char *
1229
or32_print_register (dest, param_ch, encoding, insn)
1230
     char *dest;
1231 371 markom
     char param_ch;
1232
     char *encoding;
1233
     unsigned long insn;
1234
{
1235
  int regnum = or32_extract(param_ch, encoding, insn);
1236
 
1237 703 markom
  sprintf (dest, "r%d", regnum);
1238
  while (*dest) dest++;
1239
  return dest;
1240 371 markom
}
1241
 
1242
/* Print immediate. Used only by print_insn. */
1243
 
1244 703 markom
static char *
1245
or32_print_immediate (dest, param_ch, encoding, insn)
1246
     char *dest;
1247 371 markom
     char param_ch;
1248
     char *encoding;
1249
     unsigned long insn;
1250
{
1251
  int imm = or32_extract (param_ch, encoding, insn);
1252
 
1253
  imm = extend_imm(imm, param_ch);
1254
 
1255
  if (letter_signed(param_ch))
1256
    {
1257
      if (imm < 0)
1258 703 markom
        sprintf (dest, "%d", imm);
1259 371 markom
      else
1260 703 markom
        sprintf (dest, "0x%x", imm);
1261 371 markom
    }
1262
  else
1263 703 markom
    sprintf (dest, "%#x", imm);
1264
  while (*dest) dest++;
1265
  return dest;
1266 371 markom
}
1267
 
1268
/* Disassemble one instruction from insn to disassemble.
1269
   Return the size of the instruction.  */
1270
 
1271
int
1272
disassemble_insn (insn)
1273
     unsigned long insn;
1274
{
1275 703 markom
  return disassemble_index (insn, insn_decode (insn));
1276
}
1277 371 markom
 
1278 703 markom
/* Disassemble one instruction from insn index.
1279
   Return the size of the instruction.  */
1280
 
1281
int
1282
disassemble_index (insn, index)
1283
     unsigned long insn;
1284
     int index;
1285
{
1286
  char *dest = disassembled;
1287 371 markom
  if (index >= 0)
1288
    {
1289
      struct or32_opcode const *opcode = &or32_opcodes[index];
1290
      char *s;
1291
 
1292 703 markom
      strcpy (dest, opcode->name);
1293
      while (*dest) dest++;
1294
      *dest++ = ' ';
1295
      *dest = 0;
1296
 
1297 371 markom
      for (s = opcode->args; *s != '\0'; ++s)
1298
        {
1299
          switch (*s)
1300
            {
1301
            case '\0':
1302 703 markom
              return insn_len (insn);
1303 714 markom
 
1304 371 markom
            case 'r':
1305 703 markom
              dest = or32_print_register(dest, *++s, opcode->encoding, insn);
1306 371 markom
              break;
1307 714 markom
 
1308 371 markom
            default:
1309
              if (strchr (opcode->encoding, *s))
1310 703 markom
                dest = or32_print_immediate (dest, *s, opcode->encoding, insn);
1311
              else {
1312
                *dest++ = *s;
1313
                *dest = 0;
1314
              }
1315 371 markom
            }
1316
        }
1317
    }
1318
  else
1319
    {
1320
      /* This used to be %8x for binutils.  */
1321 1308 phoenix
      sprintf(dest, ".word 0x%08lx", insn);
1322 703 markom
      while (*dest) dest++;
1323 371 markom
    }
1324
  return insn_len (insn);
1325
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.