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

Subversion Repositories or1k

[/] [or1k/] [trunk/] [binutils/] [binutils-2.16.1/] [binutils-2.16.1.diff] - Blame information for rev 1777

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

Line No. Rev Author Line
1 1616 phoenix
diff --unified -N -r ../binutils-2.16.1/bfd/bfd-in2.h binutils-2.16.1/bfd/bfd-in2.h
2
--- ../binutils-2.16.1/bfd/bfd-in2.h    2005-03-02 22:23:20.000000000 +0100
3
+++ binutils-2.16.1/bfd/bfd-in2.h       2005-12-13 15:51:29.000000000 +0100
4
@@ -2145,11 +2145,13 @@
5
 i.e., byte displacements shifted right two bits.  The 30-bit word
6
 displacement (<<32_PCREL_S2>> -- 32 bits, shifted 2) is used on the
7
 SPARC.  (SPARC tools generally refer to this as <<WDISP30>>.)  The
8
-signed 16-bit displacement is used on the MIPS, and the 23-bit
9
-displacement is used on the Alpha.  */
10
+signed 16-bit displacement is used on the MIPS, the 23-bit
11
+displacement is used on the Alpha and the 26-bit displacement is used
12
+on openrisc.  */
13
   BFD_RELOC_32_PCREL_S2,
14
   BFD_RELOC_16_PCREL_S2,
15
   BFD_RELOC_23_PCREL_S2,
16
+  BFD_RELOC_28_PCREL_S2,
17
 
18
 /* High 22 bits and low 10 bits of 32-bit value, placed into lower bits of
19
 the target word.  These are used on the SPARC.  */
20
diff --unified -N -r ../binutils-2.16.1/bfd/config.bfd binutils-2.16.1/bfd/config.bfd
21
--- ../binutils-2.16.1/bfd/config.bfd   2005-01-31 18:18:47.000000000 +0100
22
+++ binutils-2.16.1/bfd/config.bfd      2005-12-13 15:51:29.000000000 +0100
23
@@ -924,16 +924,13 @@
24
     targ_underscore=yes
25
     ;;
26
 
27
-  openrisc-*-elf)
28
-    targ_defvec=bfd_elf32_openrisc_vec
29
-    ;;
30
 
31
   or32-*-coff)
32
     targ_defvec=or32coff_big_vec
33
     targ_underscore=yes
34
     ;;
35
 
36
-  or32-*-elf | or32-*-rtems*)
37
+  or32-*-rtems | or32-*-elf | or32-*-*linux*)
38
     targ_defvec=bfd_elf32_or32_big_vec
39
     ;;
40
 
41
diff --unified -N -r ../binutils-2.16.1/bfd/configure binutils-2.16.1/bfd/configure
42
--- ../binutils-2.16.1/bfd/configure    2005-06-12 20:58:46.000000000 +0200
43
+++ binutils-2.16.1/bfd/configure       2005-12-13 15:51:29.000000000 +0100
44
@@ -11588,7 +11588,6 @@
45
     bfd_elf32_nlittlemips_vec) tb="$tb elfn32-mips.lo elfxx-mips.lo elf32.lo $elf ecofflink.lo"; target_size=64 ;;
46
     bfd_elf32_ntradbigmips_vec)        tb="$tb elfn32-mips.lo elfxx-mips.lo elf32.lo $elf ecofflink.lo"; target_size=64 ;;
47
     bfd_elf32_ntradlittlemips_vec) tb="$tb elfn32-mips.lo elfxx-mips.lo elf32.lo $elf ecofflink.lo"; target_size=64 ;;
48
-    bfd_elf32_openrisc_vec)    tb="$tb elf32-openrisc.lo elf32.lo $elf" ;;
49
     bfd_elf32_or32_big_vec)    tb="$tb elf32-or32.lo elf32.lo $elf" ;;
50
     bfd_elf32_pj_vec)           tb="$tb elf32-pj.lo elf32.lo $elf";;
51
     bfd_elf32_pjl_vec)          tb="$tb elf32-pj.lo elf32.lo $elf";;
52
diff --unified -N -r ../binutils-2.16.1/bfd/configure.in binutils-2.16.1/bfd/configure.in
53
--- ../binutils-2.16.1/bfd/configure.in 2005-06-12 20:58:40.000000000 +0200
54
+++ binutils-2.16.1/bfd/configure.in    2005-12-13 15:51:29.000000000 +0100
55
@@ -635,7 +635,6 @@
56
     bfd_elf32_nlittlemips_vec) tb="$tb elfn32-mips.lo elfxx-mips.lo elf32.lo $elf ecofflink.lo"; target_size=64 ;;
57
     bfd_elf32_ntradbigmips_vec)        tb="$tb elfn32-mips.lo elfxx-mips.lo elf32.lo $elf ecofflink.lo"; target_size=64 ;;
58
     bfd_elf32_ntradlittlemips_vec) tb="$tb elfn32-mips.lo elfxx-mips.lo elf32.lo $elf ecofflink.lo"; target_size=64 ;;
59
-    bfd_elf32_openrisc_vec)    tb="$tb elf32-openrisc.lo elf32.lo $elf" ;;
60
     bfd_elf32_or32_big_vec)    tb="$tb elf32-or32.lo elf32.lo $elf" ;;
61
     bfd_elf32_pj_vec)           tb="$tb elf32-pj.lo elf32.lo $elf";;
62
     bfd_elf32_pjl_vec)          tb="$tb elf32-pj.lo elf32.lo $elf";;
63
diff --unified -N -r ../binutils-2.16.1/bfd/cpu-openrisc.c binutils-2.16.1/bfd/cpu-openrisc.c
64
--- ../binutils-2.16.1/bfd/cpu-openrisc.c       2002-11-30 09:39:36.000000000 +0100
65
+++ binutils-2.16.1/bfd/cpu-openrisc.c  1970-01-01 01:00:00.000000000 +0100
66
@@ -1,42 +0,0 @@
67
-/* BFD support for the OpenRISC architecture.
68
-   Copyright 2001, 2002 Free Software Foundation, Inc.
69
-   Contributed by Johan Rydberg, jrydberg@opencores.org
70
-
71
-This file is part of BFD, the Binary File Descriptor library.
72
-
73
-This program is free software; you can redistribute it and/or modify
74
-it under the terms of the GNU General Public License as published by
75
-the Free Software Foundation; either version 2 of the License, or
76
-(at your option) any later version.
77
-
78
-This program is distributed in the hope that it will be useful,
79
-but WITHOUT ANY WARRANTY; without even the implied warranty of
80
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
81
-GNU General Public License for more details.
82
-
83
-You should have received a copy of the GNU General Public License
84
-along with this program; if not, write to the Free Software
85
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
86
-
87
-#include "bfd.h"
88
-#include "sysdep.h"
89
-#include "libbfd.h"
90
-
91
-#define N(BITS_WORD, BITS_ADDR, NUMBER, PRINT, DEFAULT, NEXT) \
92
-  {                                                           \
93
-    BITS_WORD,           /* bits in a word */                 \
94
-    BITS_ADDR,           /* bits in an address */             \
95
-    8,                   /* 8 bits in a byte */               \
96
-    bfd_arch_openrisc,                                        \
97
-    NUMBER,                                                   \
98
-    "openrisc",                                               \
99
-    PRINT,                                                    \
100
-    2,                                                        \
101
-    DEFAULT,                                                  \
102
-    bfd_default_compatible,                                   \
103
-    bfd_default_scan,                                         \
104
-    NEXT,                                                     \
105
-  }
106
-
107
-const bfd_arch_info_type bfd_openrisc_arch =
108
-  N (32, 32, 0, "openrisc", TRUE, 0);
109
Binary files ../binutils-2.16.1/bfd/doc/bfd.info-2 and binutils-2.16.1/bfd/doc/bfd.info-2 differ
110
diff --unified -N -r ../binutils-2.16.1/bfd/elf32-openrisc.c binutils-2.16.1/bfd/elf32-openrisc.c
111
--- ../binutils-2.16.1/bfd/elf32-openrisc.c     2004-10-21 17:28:23.000000000 +0200
112
+++ binutils-2.16.1/bfd/elf32-openrisc.c        1970-01-01 01:00:00.000000000 +0100
113
@@ -1,613 +0,0 @@
114
-/* OpenRISC-specific support for 32-bit ELF.
115
-   Copyright 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
116
-   Contributed by Johan Rydberg, jrydberg@opencores.org
117
-
118
-This file is part of BFD, the Binary File Descriptor library.
119
-
120
-This program is free software; you can redistribute it and/or modify
121
-it under the terms of the GNU General Public License as published by
122
-the Free Software Foundation; either version 2 of the License, or
123
-(at your option) any later version.
124
-
125
-This program is distributed in the hope that it will be useful,
126
-but WITHOUT ANY WARRANTY; without even the implied warranty of
127
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
128
-GNU General Public License for more details.
129
-
130
-You should have received a copy of the GNU General Public License
131
-along with this program; if not, write to the Free Software
132
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
133
-
134
-#include "bfd.h"
135
-#include "sysdep.h"
136
-#include "libbfd.h"
137
-#include "elf-bfd.h"
138
-#include "elf/openrisc.h"
139
-#include "libiberty.h"
140
-
141
-/* Forward declarations.  */
142
-
143
-static reloc_howto_type *openrisc_reloc_type_lookup
144
-  PARAMS ((bfd * , bfd_reloc_code_real_type));
145
-static void openrisc_info_to_howto_rela
146
-  PARAMS ((bfd *, arelent *, Elf_Internal_Rela *));
147
-static bfd_boolean openrisc_elf_relocate_section
148
-  PARAMS ((bfd *, struct bfd_link_info *, bfd *, asection *, bfd_byte *,
149
-          Elf_Internal_Rela *, Elf_Internal_Sym *, asection **));
150
-static bfd_reloc_status_type openrisc_final_link_relocate
151
-  PARAMS ((reloc_howto_type *, bfd *, asection *, bfd_byte *,
152
-           Elf_Internal_Rela *, bfd_vma));
153
-static bfd_boolean openrisc_elf_gc_sweep_hook
154
-  PARAMS ((bfd *, struct bfd_link_info *, asection *,
155
-           const Elf_Internal_Rela *));
156
-static asection * openrisc_elf_gc_mark_hook
157
-  PARAMS ((asection *, struct bfd_link_info *, Elf_Internal_Rela *,
158
-          struct elf_link_hash_entry *, Elf_Internal_Sym *));
159
-static bfd_boolean openrisc_elf_check_relocs
160
-  PARAMS ((bfd *, struct bfd_link_info *, asection *,
161
-          const Elf_Internal_Rela *));
162
-static bfd_boolean openrisc_elf_object_p
163
-  PARAMS ((bfd *));
164
-static void openrisc_elf_final_write_processing
165
-  PARAMS ((bfd *, bfd_boolean));
166
-
167
-
168
-static reloc_howto_type openrisc_elf_howto_table[] =
169
-  {
170
-  /* This reloc does nothing.  */
171
-  HOWTO (R_OPENRISC_NONE,      /* type */
172
-        0,                     /* rightshift */
173
-        2,                     /* size (0 = byte, 1 = short, 2 = long) */
174
-        32,                    /* bitsize */
175
-        FALSE,                 /* pc_relative */
176
-        0,                     /* bitpos */
177
-        complain_overflow_bitfield, /* complain_on_overflow */
178
-        bfd_elf_generic_reloc, /* special_function */
179
-        "R_OPENRISC_NONE",     /* name */
180
-        FALSE,                 /* partial_inplace */
181
-        0,                     /* src_mask */
182
-        0,                     /* dst_mask */
183
-        FALSE),                /* pcrel_offset */
184
-
185
-  /* A PC relative 26 bit relocation, right shifted by 2.  */
186
-  HOWTO (R_OPENRISC_INSN_REL_26, /* type */
187
-        2,                     /* rightshift */
188
-        2,                     /* size (0 = byte, 1 = short, 2 = long) */
189
-        26,                    /* bitsize */
190
-        TRUE,                  /* pc_relative */
191
-        0,                     /* bitpos */
192
-        complain_overflow_signed, /* complain_on_overflow */
193
-        bfd_elf_generic_reloc, /* special_function */
194
-        "R_OPENRISC_INSN_REL_26", /* name */
195
-        FALSE,                 /* partial_inplace */
196
-        0x00000000,            /* src_mask */
197
-        0x03ffffff,            /* dst_mask */
198
-        FALSE),                /* pcrel_offset */
199
-
200
-  /* A absolute 26 bit relocation, right shifted by 2.  */
201
-  HOWTO (R_OPENRISC_INSN_ABS_26, /* type */
202
-        2,                     /* rightshift */
203
-        2,                     /* size (0 = byte, 1 = short, 2 = long) */
204
-        26,                    /* bitsize */
205
-        FALSE,                 /* pc_relative */
206
-        0,                     /* bitpos */
207
-        complain_overflow_signed, /* complain_on_overflow */
208
-        bfd_elf_generic_reloc, /* special_function */
209
-        "R_OPENRISC_INSN_ABS_26", /* name */
210
-        FALSE,                 /* partial_inplace */
211
-        0x00000000,            /* src_mask */
212
-        0x03ffffff,            /* dst_mask */
213
-        FALSE),                /* pcrel_offset */
214
-
215
-  HOWTO (R_OPENRISC_LO_16_IN_INSN, /* type */
216
-        0,                     /* rightshift */
217
-        1,                     /* size (0 = byte, 1 = short, 2 = long) */
218
-        16,                    /* bitsize */
219
-        FALSE,                 /* pc_relative */
220
-        0,                     /* bitpos */
221
-        complain_overflow_dont, /* complain_on_overflow */
222
-        bfd_elf_generic_reloc, /* special_function */
223
-        "R_OPENRISC_LO_16_IN_INSN", /* name */
224
-        FALSE,                 /* partial_inplace */
225
-        0,                     /* src_mask */
226
-        0x0000ffff,            /* dst_mask */
227
-        FALSE),                /* pcrel_offset */
228
-
229
-  HOWTO (R_OPENRISC_HI_16_IN_INSN, /* type */
230
-        16,                    /* rightshift */
231
-        1,                     /* size (0 = byte, 1 = short, 2 = long) */
232
-        16,                    /* bitsize */
233
-        FALSE,                 /* pc_relative */
234
-        0,                     /* bitpos */
235
-        complain_overflow_dont,        /* complain_on_overflow */
236
-        bfd_elf_generic_reloc, /* special_function */
237
-        "R_OPENRISC_HI_16_IN_INSN",    /* name */
238
-        FALSE,                 /* partial_inplace */
239
-        0,                     /* src_mask */
240
-        0x0000ffff,            /* dst_mask */
241
-        FALSE),                /* pcrel_offset */
242
-
243
-  /* An 8 bit absolute relocation.  */
244
-  HOWTO (R_OPENRISC_8,         /* type */
245
-        0,                     /* rightshift */
246
-        0,                     /* size (0 = byte, 1 = short, 2 = long) */
247
-        8,                     /* bitsize */
248
-        FALSE,                 /* pc_relative */
249
-        0,                     /* bitpos */
250
-        complain_overflow_bitfield, /* complain_on_overflow */
251
-        bfd_elf_generic_reloc, /* special_function */
252
-        "R_OPENRISC_8",        /* name */
253
-        TRUE,                  /* partial_inplace */
254
-        0x0000,                /* src_mask */
255
-        0x00ff,                /* dst_mask */
256
-        FALSE),                /* pcrel_offset */
257
-
258
-  /* A 16 bit absolute relocation.  */
259
-  HOWTO (R_OPENRISC_16,                /* type */
260
-        0,                     /* rightshift */
261
-        1,                     /* size (0 = byte, 1 = short, 2 = long) */
262
-        16,                    /* bitsize */
263
-        FALSE,                 /* pc_relative */
264
-        0,                     /* bitpos */
265
-        complain_overflow_bitfield, /* complain_on_overflow */
266
-        bfd_elf_generic_reloc, /* special_function */
267
-        "R_OPENRISC_16",       /* name */
268
-        TRUE,                  /* partial_inplace */
269
-        0x00000000,            /* src_mask */
270
-        0x0000ffff,            /* dst_mask */
271
-        FALSE),                /* pcrel_offset */
272
-
273
-  /* A 32 bit absolute relocation.  */
274
-  HOWTO (R_OPENRISC_32,                /* type */
275
-        0,                     /* rightshift */
276
-        2,                     /* size (0 = byte, 1 = short, 2 = long) */
277
-        32,                    /* bitsize */
278
-        FALSE,                 /* pc_relative */
279
-        0,                     /* bitpos */
280
-        complain_overflow_bitfield, /* complain_on_overflow */
281
-        bfd_elf_generic_reloc, /* special_function */
282
-        "R_OPENRISC_32",       /* name */
283
-        TRUE,                  /* partial_inplace */
284
-        0x00000000,            /* src_mask */
285
-        0xffffffff,            /* dst_mask */
286
-        FALSE),                /* pcrel_offset */
287
-
288
-  /* GNU extension to record C++ vtable hierarchy */
289
-  HOWTO (R_OPENRISC_GNU_VTINHERIT, /* type */
290
-        0,                     /* rightshift */
291
-        2,                     /* size (0 = byte, 1 = short, 2 = long) */
292
-        0,                     /* bitsize */
293
-        FALSE,                 /* pc_relative */
294
-        0,                     /* bitpos */
295
-        complain_overflow_dont, /* complain_on_overflow */
296
-        NULL,                  /* special_function */
297
-        "R_OPENRISC_GNU_VTINHERIT", /* name */
298
-        FALSE,                 /* partial_inplace */
299
-        0,                     /* src_mask */
300
-        0,                     /* dst_mask */
301
-        FALSE),                /* pcrel_offset */
302
-
303
-  /* GNU extension to record C++ vtable member usage */
304
-  HOWTO (R_OPENRISC_GNU_VTENTRY, /* type */
305
-        0,                     /* rightshift */
306
-        2,                     /* size (0 = byte, 1 = short, 2 = long) */
307
-        0,                     /* bitsize */
308
-        FALSE,                 /* pc_relative */
309
-        0,                     /* bitpos */
310
-        complain_overflow_dont, /* complain_on_overflow */
311
-        _bfd_elf_rel_vtable_reloc_fn, /* special_function */
312
-        "R_OPENRISC_GNU_VTENTRY", /* name */
313
-        FALSE,                 /* partial_inplace */
314
-        0,                     /* src_mask */
315
-        0,                     /* dst_mask */
316
-        FALSE),                /* pcrel_offset */
317
-};
318
-
319
-/* Map BFD reloc types to OpenRISC ELF reloc types.  */
320
-
321
-struct openrisc_reloc_map
322
-  {
323
-    bfd_reloc_code_real_type bfd_reloc_val;
324
-    unsigned int openrisc_reloc_val;
325
-  };
326
-
327
-static const struct openrisc_reloc_map openrisc_reloc_map[] =
328
-  {
329
-    { BFD_RELOC_NONE,          R_OPENRISC_NONE },
330
-    { BFD_RELOC_32,            R_OPENRISC_32 },
331
-    { BFD_RELOC_16,            R_OPENRISC_16 },
332
-    { BFD_RELOC_8,             R_OPENRISC_8 },
333
-    { BFD_RELOC_OPENRISC_REL_26,R_OPENRISC_INSN_REL_26 },
334
-    { BFD_RELOC_OPENRISC_ABS_26,R_OPENRISC_INSN_ABS_26 },
335
-    { BFD_RELOC_HI16,          R_OPENRISC_HI_16_IN_INSN },
336
-    { BFD_RELOC_LO16,          R_OPENRISC_LO_16_IN_INSN },
337
-    { BFD_RELOC_VTABLE_INHERIT,        R_OPENRISC_GNU_VTINHERIT },
338
-    { BFD_RELOC_VTABLE_ENTRY,  R_OPENRISC_GNU_VTENTRY }
339
-  };
340
-
341
-static reloc_howto_type *
342
-openrisc_reloc_type_lookup (abfd, code)
343
-     bfd * abfd ATTRIBUTE_UNUSED;
344
-     bfd_reloc_code_real_type code;
345
-{
346
-  unsigned int i;
347
-
348
-  for (i = ARRAY_SIZE (openrisc_reloc_map); --i;)
349
-    if (openrisc_reloc_map[i].bfd_reloc_val == code)
350
-      return & openrisc_elf_howto_table[openrisc_reloc_map[i].
351
-                                      openrisc_reloc_val];
352
-
353
-  return NULL;
354
-}
355
-
356
-/* Set the howto pointer for an OpenRISC ELF reloc.  */
357
-
358
-static void
359
-openrisc_info_to_howto_rela (abfd, cache_ptr, dst)
360
-     bfd * abfd ATTRIBUTE_UNUSED;
361
-     arelent * cache_ptr;
362
-     Elf_Internal_Rela * dst;
363
-{
364
-  unsigned int r_type;
365
-
366
-  r_type = ELF32_R_TYPE (dst->r_info);
367
-  BFD_ASSERT (r_type < (unsigned int) R_OPENRISC_max);
368
-  cache_ptr->howto = & openrisc_elf_howto_table[r_type];
369
-}
370
-
371
-/* Perform a single relocation.  By default we use the standard BFD
372
-   routines, but a few relocs, we have to do them ourselves.  */
373
-
374
-static bfd_reloc_status_type
375
-openrisc_final_link_relocate (howto, input_bfd, input_section, contents, rel,
376
-                             relocation)
377
-     reloc_howto_type *howto;
378
-     bfd *input_bfd;
379
-     asection *input_section;
380
-     bfd_byte *contents;
381
-     Elf_Internal_Rela *rel;
382
-     bfd_vma relocation;
383
-{
384
-  bfd_reloc_status_type r = bfd_reloc_ok;
385
-
386
-  switch (howto->type)
387
-    {
388
-    case R_OPENRISC_LO_16_IN_INSN:
389
-      relocation &= 0xffff;
390
-      r = _bfd_final_link_relocate (howto, input_bfd, input_section,
391
-                                   contents, rel->r_offset,
392
-                                   relocation, rel->r_addend);
393
-      break;
394
-
395
-    default:
396
-      r = _bfd_final_link_relocate (howto, input_bfd, input_section,
397
-                                   contents, rel->r_offset,
398
-                                   relocation, rel->r_addend);
399
-    }
400
-
401
-  return r;
402
-}
403
-
404
-/* Relocate an OpenRISC ELF section.
405
-
406
-   The RELOCATE_SECTION function is called by the new ELF backend linker
407
-   to handle the relocations for a section.
408
-
409
-   The relocs are always passed as Rela structures; if the section
410
-   actually uses Rel structures, the r_addend field will always be
411
-   zero.
412
-
413
-   This function is responsible for adjusting the section contents as
414
-   necessary, and (if using Rela relocs and generating a relocatable
415
-   output file) adjusting the reloc addend as necessary.
416
-
417
-   This function does not have to worry about setting the reloc
418
-   address or the reloc symbol index.
419
-
420
-   LOCAL_SYMS is a pointer to the swapped in local symbols.
421
-
422
-   LOCAL_SECTIONS is an array giving the section in the input file
423
-   corresponding to the st_shndx field of each local symbol.
424
-
425
-   The global hash table entry for the global symbols can be found
426
-   via elf_sym_hashes (input_bfd).
427
-
428
-   When generating relocatable output, this function must handle
429
-   STB_LOCAL/STT_SECTION symbols specially.  The output symbol is
430
-   going to be the section symbol corresponding to the output
431
-   section, which means that the addend must be adjusted
432
-   accordingly.  */
433
-
434
-static bfd_boolean
435
-openrisc_elf_relocate_section (output_bfd, info, input_bfd, input_section,
436
-                              contents, relocs, local_syms, local_sections)
437
-     bfd *output_bfd;
438
-     struct bfd_link_info *info;
439
-     bfd *input_bfd;
440
-     asection *input_section;
441
-     bfd_byte *contents;
442
-     Elf_Internal_Rela *relocs;
443
-     Elf_Internal_Sym *local_syms;
444
-     asection **local_sections;
445
-{
446
-  Elf_Internal_Shdr *symtab_hdr;
447
-  struct elf_link_hash_entry **sym_hashes;
448
-  Elf_Internal_Rela *rel;
449
-  Elf_Internal_Rela *relend;
450
-
451
-  if (info->relocatable)
452
-    return TRUE;
453
-
454
-  symtab_hdr = &elf_tdata (input_bfd)->symtab_hdr;
455
-  sym_hashes = elf_sym_hashes (input_bfd);
456
-  relend = relocs + input_section->reloc_count;
457
-
458
-  for (rel = relocs; rel < relend; rel++)
459
-    {
460
-      reloc_howto_type *howto;
461
-      unsigned long r_symndx;
462
-      Elf_Internal_Sym *sym;
463
-      asection *sec;
464
-      struct elf_link_hash_entry *h;
465
-      bfd_vma relocation;
466
-      bfd_reloc_status_type r;
467
-      const char *name = NULL;
468
-      int r_type;
469
-
470
-      r_type = ELF32_R_TYPE (rel->r_info);
471
-      r_symndx = ELF32_R_SYM (rel->r_info);
472
-
473
-      if (r_type == R_OPENRISC_GNU_VTINHERIT
474
-         || r_type == R_OPENRISC_GNU_VTENTRY)
475
-       continue;
476
-
477
-      if ((unsigned int) r_type >
478
-         (sizeof openrisc_elf_howto_table / sizeof (reloc_howto_type)))
479
-       abort ();
480
-
481
-      /* This is a final link.  */
482
-      howto = openrisc_elf_howto_table + ELF32_R_TYPE (rel->r_info);
483
-      h = NULL;
484
-      sym = NULL;
485
-      sec = NULL;
486
-
487
-      if (r_symndx < symtab_hdr->sh_info)
488
-       {
489
-         sym = local_syms + r_symndx;
490
-         sec = local_sections[r_symndx];
491
-         relocation = _bfd_elf_rela_local_sym (output_bfd, sym, &sec, rel);
492
-
493
-         name = bfd_elf_string_from_elf_section
494
-           (input_bfd, symtab_hdr->sh_link, sym->st_name);
495
-         name = (name == NULL) ? bfd_section_name (input_bfd, sec) : name;
496
-       }
497
-      else
498
-       {
499
-         bfd_boolean unresolved_reloc, warned;
500
-
501
-         RELOC_FOR_GLOBAL_SYMBOL (info, input_bfd, input_section, rel,
502
-                                  r_symndx, symtab_hdr, sym_hashes,
503
-                                  h, sec, relocation,
504
-                                  unresolved_reloc, warned);
505
-       }
506
-
507
-      r = openrisc_final_link_relocate (howto, input_bfd, input_section,
508
-                                       contents, rel, relocation);
509
-
510
-      if (r != bfd_reloc_ok)
511
-       {
512
-         const char *msg = (const char *) NULL;
513
-
514
-         switch (r)
515
-           {
516
-           case bfd_reloc_overflow:
517
-             r = info->callbacks->reloc_overflow
518
-               (info, (h ? &h->root : NULL), name, howto->name,
519
-                (bfd_vma) 0, input_bfd, input_section, rel->r_offset);
520
-             break;
521
-
522
-           case bfd_reloc_undefined:
523
-             r = info->callbacks->undefined_symbol
524
-               (info, name, input_bfd, input_section, rel->r_offset, TRUE);
525
-             break;
526
-
527
-           case bfd_reloc_outofrange:
528
-             msg = _("internal error: out of range error");
529
-             break;
530
-
531
-           case bfd_reloc_notsupported:
532
-             msg = _("internal error: unsupported relocation error");
533
-             break;
534
-
535
-           case bfd_reloc_dangerous:
536
-             msg = _("internal error: dangerous relocation");
537
-             break;
538
-
539
-           default:
540
-             msg = _("internal error: unknown error");
541
-             break;
542
-           }
543
-
544
-         if (msg)
545
-           r = info->callbacks->warning
546
-             (info, msg, name, input_bfd, input_section, rel->r_offset);
547
-
548
-         if (!r)
549
-           return FALSE;
550
-       }
551
-    }
552
-
553
-  return TRUE;
554
-}
555
-
556
-/* Return the section that should be marked against GC for a given
557
-   relocation.  */
558
-
559
-static asection *
560
-openrisc_elf_gc_mark_hook (sec, info, rel, h, sym)
561
-     asection *sec;
562
-     struct bfd_link_info *info ATTRIBUTE_UNUSED;
563
-     Elf_Internal_Rela *rel;
564
-     struct elf_link_hash_entry *h;
565
-     Elf_Internal_Sym *sym;
566
-{
567
-  if (h != NULL)
568
-    {
569
-      switch (ELF32_R_TYPE (rel->r_info))
570
-       {
571
-       case R_OPENRISC_GNU_VTINHERIT:
572
-       case R_OPENRISC_GNU_VTENTRY:
573
-         break;
574
-
575
-       default:
576
-         switch (h->root.type)
577
-           {
578
-           case bfd_link_hash_defined:
579
-           case bfd_link_hash_defweak:
580
-             return h->root.u.def.section;
581
-
582
-           case bfd_link_hash_common:
583
-             return h->root.u.c.p->section;
584
-
585
-           default:
586
-             break;
587
-           }
588
-       }
589
-    }
590
-  else
591
-    return bfd_section_from_elf_index (sec->owner, sym->st_shndx);
592
-
593
-  return NULL;
594
-}
595
-
596
-/* Update the got entry reference counts for the section being removed.  */
597
-
598
-static bfd_boolean
599
-openrisc_elf_gc_sweep_hook (abfd, info, sec, relocs)
600
-     bfd *abfd ATTRIBUTE_UNUSED;
601
-     struct bfd_link_info *info ATTRIBUTE_UNUSED;
602
-     asection *sec ATTRIBUTE_UNUSED;
603
-     const Elf_Internal_Rela *relocs ATTRIBUTE_UNUSED;
604
-{
605
-  return TRUE;
606
-}
607
-
608
-/* Look through the relocs for a section during the first phase.
609
-   Since we don't do .gots or .plts, we just need to consider the
610
-   virtual table relocs for gc.  */
611
-
612
-static bfd_boolean
613
-openrisc_elf_check_relocs (abfd, info, sec, relocs)
614
-     bfd *abfd;
615
-     struct bfd_link_info *info;
616
-     asection *sec;
617
-     const Elf_Internal_Rela *relocs;
618
-{
619
-  Elf_Internal_Shdr *symtab_hdr;
620
-  struct elf_link_hash_entry **sym_hashes, **sym_hashes_end;
621
-  const Elf_Internal_Rela *rel;
622
-  const Elf_Internal_Rela *rel_end;
623
-
624
-  if (info->relocatable)
625
-    return TRUE;
626
-
627
-  symtab_hdr = &elf_tdata (abfd)->symtab_hdr;
628
-  sym_hashes = elf_sym_hashes (abfd);
629
-  sym_hashes_end =
630
-    sym_hashes + symtab_hdr->sh_size / sizeof (Elf32_External_Sym);
631
-  if (!elf_bad_symtab (abfd))
632
-    sym_hashes_end -= symtab_hdr->sh_info;
633
-
634
-  rel_end = relocs + sec->reloc_count;
635
-  for (rel = relocs; rel < rel_end; rel++)
636
-    {
637
-      struct elf_link_hash_entry *h;
638
-      unsigned long r_symndx;
639
-
640
-      r_symndx = ELF32_R_SYM (rel->r_info);
641
-      if (r_symndx < symtab_hdr->sh_info)
642
-       h = NULL;
643
-      else
644
-       h = sym_hashes[r_symndx - symtab_hdr->sh_info];
645
-
646
-      switch (ELF32_R_TYPE (rel->r_info))
647
-       {
648
-         /* This relocation describes the C++ object vtable hierarchy.
649
-            Reconstruct it for later use during GC.  */
650
-       case R_OPENRISC_GNU_VTINHERIT:
651
-         if (!bfd_elf_gc_record_vtinherit (abfd, sec, h, rel->r_offset))
652
-           return FALSE;
653
-         break;
654
-
655
-         /* This relocation describes which C++ vtable entries are actually
656
-            used.  Record for later use during GC.  */
657
-       case R_OPENRISC_GNU_VTENTRY:
658
-         if (!bfd_elf_gc_record_vtentry (abfd, sec, h, rel->r_addend))
659
-           return FALSE;
660
-         break;
661
-       }
662
-    }
663
-
664
-  return TRUE;
665
-}
666
-
667
-/* Set the right machine number.  */
668
-
669
-static bfd_boolean
670
-openrisc_elf_object_p (abfd)
671
-     bfd *abfd;
672
-{
673
-  switch (elf_elfheader (abfd)->e_flags & 0xf)
674
-    {
675
-    default:
676
-      (void) bfd_default_set_arch_mach (abfd, bfd_arch_openrisc, 0);
677
-      break;
678
-    }
679
-  return TRUE;
680
-}
681
-
682
-/* Store the machine number in the flags field.  */
683
-
684
-static void
685
-openrisc_elf_final_write_processing (abfd, linker)
686
-     bfd *abfd;
687
-     bfd_boolean linker ATTRIBUTE_UNUSED;
688
-{
689
-  unsigned long val;
690
-
691
-  switch (bfd_get_mach (abfd))
692
-    {
693
-    default:
694
-      val = 0;
695
-      break;
696
-    }
697
-
698
-  elf_elfheader (abfd)->e_flags &= ~0xf;
699
-  elf_elfheader (abfd)->e_flags |= val;
700
-}
701
-
702
-
703
-#define ELF_ARCH                       bfd_arch_openrisc
704
-#define ELF_MACHINE_CODE               EM_OPENRISC
705
-#define ELF_MACHINE_ALT1               EM_OPENRISC_OLD
706
-#define ELF_MAXPAGESIZE                        0x1000
707
-
708
-#define TARGET_BIG_SYM                 bfd_elf32_openrisc_vec
709
-#define TARGET_BIG_NAME                        "elf32-openrisc"
710
-
711
-#define elf_info_to_howto_rel          NULL
712
-#define elf_info_to_howto              openrisc_info_to_howto_rela
713
-#define elf_backend_relocate_section   openrisc_elf_relocate_section
714
-#define elf_backend_gc_mark_hook       openrisc_elf_gc_mark_hook
715
-#define elf_backend_gc_sweep_hook      openrisc_elf_gc_sweep_hook
716
-#define elf_backend_check_relocs       openrisc_elf_check_relocs
717
-
718
-#define elf_backend_can_gc_sections    1
719
-#define elf_backend_rela_normal                1
720
-
721
-#define bfd_elf32_bfd_reloc_type_lookup openrisc_reloc_type_lookup
722
-
723
-#define elf_backend_object_p                openrisc_elf_object_p
724
-#define elf_backend_final_write_processing  openrisc_elf_final_write_processing
725
-
726
-#include "elf32-target.h"
727
diff --unified -N -r ../binutils-2.16.1/bfd/libbfd.h binutils-2.16.1/bfd/libbfd.h
728
--- ../binutils-2.16.1/bfd/libbfd.h     2005-03-02 22:23:21.000000000 +0100
729
+++ binutils-2.16.1/bfd/libbfd.h        2005-12-13 15:51:29.000000000 +0100
730
@@ -801,6 +801,7 @@
731
   "BFD_RELOC_32_PCREL_S2",
732
   "BFD_RELOC_16_PCREL_S2",
733
   "BFD_RELOC_23_PCREL_S2",
734
+  "BFD_RELOC_28_PCREL_S2",
735
   "BFD_RELOC_HI22",
736
   "BFD_RELOC_LO10",
737
   "BFD_RELOC_GPREL16",
738
diff --unified -N -r ../binutils-2.16.1/bfd/reloc.c binutils-2.16.1/bfd/reloc.c
739
--- ../binutils-2.16.1/bfd/reloc.c      2005-03-02 22:23:21.000000000 +0100
740
+++ binutils-2.16.1/bfd/reloc.c 2005-12-13 15:51:29.000000000 +0100
741
@@ -1728,13 +1728,17 @@
742
   BFD_RELOC_16_PCREL_S2
743
 ENUMX
744
   BFD_RELOC_23_PCREL_S2
745
+ENUMX
746
+  BFD_RELOC_28_PCREL_S2
747
 ENUMDOC
748
   These PC-relative relocations are stored as word displacements --
749
 i.e., byte displacements shifted right two bits.  The 30-bit word
750
 displacement (<<32_PCREL_S2>> -- 32 bits, shifted 2) is used on the
751
 SPARC.  (SPARC tools generally refer to this as <<WDISP30>>.)  The
752
-signed 16-bit displacement is used on the MIPS, and the 23-bit
753
-displacement is used on the Alpha.
754
+signed 16-bit displacement is used on the MIPS, the 23-bit
755
+displacement is used on the Alpha and the 26-bit displacement is used
756
+on openrisc.
757
+
758
 
759
 ENUM
760
   BFD_RELOC_HI22
761
diff --unified -N -r ../binutils-2.16.1/gas/configure.tgt binutils-2.16.1/gas/configure.tgt
762
--- ../binutils-2.16.1/gas/configure.tgt        2005-01-31 18:18:51.000000000 +0100
763
+++ binutils-2.16.1/gas/configure.tgt   2005-12-13 15:51:29.000000000 +0100
764
@@ -316,7 +316,7 @@
765
   ns32k-pc532-lites*)                  fmt=aout em=nbsd532 ;;
766
   ns32k-*-*n*bsd*)                     fmt=aout em=nbsd532 ;;
767
 
768
-  openrisc-*-*)                                fmt=elf ;;
769
+  or32-*-*linux*)                              fmt=elf ;;
770
 
771
   or32-*-rtems*)                       fmt=elf ;;
772
   or32-*-coff)                         fmt=coff ;;
773
Binary files ../binutils-2.16.1/gas/doc/as.info-3 and binutils-2.16.1/gas/doc/as.info-3 differ
774
diff --unified -N -r ../binutils-2.16.1/gas/testsuite/gas/openrisc/addi.d binutils-2.16.1/gas/testsuite/gas/openrisc/addi.d
775
--- ../binutils-2.16.1/gas/testsuite/gas/openrisc/addi.d        2001-05-02 20:14:30.000000000 +0200
776
+++ binutils-2.16.1/gas/testsuite/gas/openrisc/addi.d   1970-01-01 01:00:00.000000000 +0100
777
@@ -1,10 +0,0 @@
778
-#as:
779
-#objdump: -dr
780
-#name: addi
781
-
782
-.*: +file format .*
783
-
784
-Disassembly of section .text:
785
-
786
-00000000 <l_addi>:
787
-   0:  94 22 ff ff     l.addi r1,r2,-1
788
diff --unified -N -r ../binutils-2.16.1/gas/testsuite/gas/openrisc/addi.s binutils-2.16.1/gas/testsuite/gas/openrisc/addi.s
789
--- ../binutils-2.16.1/gas/testsuite/gas/openrisc/addi.s        2001-05-02 20:14:30.000000000 +0200
790
+++ binutils-2.16.1/gas/testsuite/gas/openrisc/addi.s   1970-01-01 01:00:00.000000000 +0100
791
@@ -1,4 +0,0 @@
792
-       .text
793
-       .global l_addi
794
-l_addi:
795
-       l.addi r1, r2, -1
796
diff --unified -N -r ../binutils-2.16.1/gas/testsuite/gas/openrisc/allinsn.d binutils-2.16.1/gas/testsuite/gas/openrisc/allinsn.d
797
--- ../binutils-2.16.1/gas/testsuite/gas/openrisc/allinsn.d     2001-05-02 20:14:30.000000000 +0200
798
+++ binutils-2.16.1/gas/testsuite/gas/openrisc/allinsn.d        1970-01-01 01:00:00.000000000 +0100
799
@@ -1,201 +0,0 @@
800
-#as:
801
-#objdump: -dr
802
-#name: allinsn
803
-
804
-.*: +file format .*
805
-
806
-Disassembly of section .text:
807
-
808
-00000000 <l_j>:
809
-   0:  00 00 00 00     l.j 0 <l_j>
810
-                       0: R_OPENRISC_INSN_ABS_26       .text
811
-
812
-00000004 <l_jal>:
813
-   4:  04 00 00 00     l.jal 0 <l_j>
814
-                       4: R_OPENRISC_INSN_ABS_26       .text
815
-
816
-00000008 <l_jr>:
817
-   8:  14 00 00 00     l.jr r0
818
-
819
-0000000c <l_jalr>:
820
-   c:  14 20 00 00     l.jalr r0
821
-
822
-00000010 <l_bal>:
823
-  10:  0b ff ff fc     l.bal 0 <l_j>
824
-
825
-00000014 <l_bnf>:
826
-  14:  0f ff ff fb     l.bnf 0 <l_j>
827
-
828
-00000018 <l_bf>:
829
-  18:  13 ff ff fa     l.bf 0 <l_j>
830
-
831
-0000001c <l_brk>:
832
-  1c:  17 00 00 00     l.brk 0x0
833
-
834
-00000020 <l_rfe>:
835
-  20:  14 40 00 00     l.rfe r0
836
-
837
-00000024 <l_sys>:
838
-  24:  16 00 00 00     l.sys 0x0
839
-
840
-00000028 <l_nop>:
841
-  28:  15 00 00 00     l.nop
842
-
843
-0000002c <l_movhi>:
844
-  2c:  18 00 00 00     l.movhi r0,0
845
-
846
-00000030 <l_mfsr>:
847
-  30:  1c 00 00 00     l.mfsr r0,r0
848
-
849
-00000034 <l_mtsr>:
850
-  34:  40 00 00 00     l.mtsr r0,r0
851
-
852
-00000038 <l_lw>:
853
-  38:  80 00 00 00     l.lw r0,0\(r0\)
854
-
855
-0000003c <l_lbz>:
856
-  3c:  84 00 00 00     l.lbz r0,0\(r0\)
857
-
858
-00000040 <l_lbs>:
859
-  40:  88 00 00 00     l.lbs r0,0\(r0\)
860
-
861
-00000044 <l_lhz>:
862
-  44:  8c 00 00 00     l.lhz r0,0\(r0\)
863
-
864
-00000048 <l_lhs>:
865
-  48:  90 00 00 00     l.lhs r0,0\(r0\)
866
-
867
-0000004c <l_sw>:
868
-  4c:  d4 00 00 00     l.sw 0\(r0\),r0
869
-
870
-00000050 <l_sb>:
871
-  50:  d8 00 00 00     l.sb 0\(r0\),r0
872
-
873
-00000054 <l_sh>:
874
-  54:  dc 00 00 00     l.sh 0\(r0\),r0
875
-
876
-00000058 <l_sll>:
877
-  58:  e0 00 00 08     l.sll r0,r0,r0
878
-
879
-0000005c <l_slli>:
880
-  5c:  b4 00 00 00     l.slli r0,r0,0x0
881
-
882
-00000060 <l_srl>:
883
-  60:  e0 00 00 28     l.srl r0,r0,r0
884
-
885
-00000064 <l_srli>:
886
-  64:  b4 00 00 20     l.srli r0,r0,0x0
887
-
888
-00000068 <l_sra>:
889
-  68:  e0 00 00 48     l.sra r0,r0,r0
890
-
891
-0000006c <l_srai>:
892
-  6c:  b4 00 00 40     l.srai r0,r0,0x0
893
-
894
-00000070 <l_ror>:
895
-  70:  e0 00 00 88     l.ror r0,r0,r0
896
-
897
-00000074 <l_rori>:
898
-  74:  b4 00 00 80     l.rori r0,r0,0x0
899
-
900
-00000078 <l_add>:
901
-  78:  e0 00 00 00     l.add r0,r0,r0
902
-
903
-0000007c <l_addi>:
904
-  7c:  94 00 00 00     l.addi r0,r0,0
905
-
906
-00000080 <l_sub>:
907
-  80:  e0 00 00 02     l.sub r0,r0,r0
908
-
909
-00000084 <l_subi>:
910
-  84:  9c 00 00 00     l.subi r0,r0,0
911
-
912
-00000088 <l_and>:
913
-  88:  e0 00 00 03     l.and r0,r0,r0
914
-
915
-0000008c <l_andi>:
916
-  8c:  a0 00 00 00     l.andi r0,r0,0
917
-
918
-00000090 <l_or>:
919
-  90:  e0 00 00 04     l.or r0,r0,r0
920
-
921
-00000094 <l_ori>:
922
-  94:  a4 00 00 00     l.ori r0,r0,0
923
-
924
-00000098 <l_xor>:
925
-  98:  e0 00 00 05     l.xor r0,r0,r0
926
-
927
-0000009c <l_xori>:
928
-  9c:  a8 00 00 00     l.xori r0,r0,0
929
-
930
-000000a0 <l_mul>:
931
-  a0:  e0 00 00 06     l.mul r0,r0,r0
932
-
933
-000000a4 <l_muli>:
934
-  a4:  ac 00 00 00     l.muli r0,r0,0
935
-
936
-000000a8 <l_div>:
937
-  a8:  e0 00 00 09     l.div r0,r0,r0
938
-
939
-000000ac <l_divu>:
940
-  ac:  e0 00 00 0a     l.divu r0,r0,r0
941
-
942
-000000b0 <l_sfgts>:
943
-  b0:  e4 c0 00 00     l.sfgts r0,r0
944
-
945
-000000b4 <l_sfgtu>:
946
-  b4:  e4 40 00 00     l.sfgtu r0,r0
947
-
948
-000000b8 <l_sfges>:
949
-  b8:  e4 e0 00 00     l.sfges r0,r0
950
-
951
-000000bc <l_sfgeu>:
952
-  bc:  e4 60 00 00     l.sfgeu r0,r0
953
-
954
-000000c0 <l_sflts>:
955
-  c0:  e5 00 00 00     l.sflts r0,r0
956
-
957
-000000c4 <l_sfltu>:
958
-  c4:  e4 80 00 00     l.sfltu r0,r0
959
-
960
-000000c8 <l_sfles>:
961
-  c8:  e5 20 00 00     l.sfles r0,r0
962
-
963
-000000cc <l_sfleu>:
964
-  cc:  e4 a0 00 00     l.sfleu r0,r0
965
-
966
-000000d0 <l_sfgtsi>:
967
-  d0:  b8 c0 00 00     l.sfgtsi r0,0
968
-
969
-000000d4 <l_sfgtui>:
970
-  d4:  b8 40 00 00     l.sfgtui r0,0x0
971
-
972
-000000d8 <l_sfgesi>:
973
-  d8:  b8 e0 00 00     l.sfgesi r0,0
974
-
975
-000000dc <l_sfgeui>:
976
-  dc:  b8 60 00 00     l.sfgeui r0,0x0
977
-
978
-000000e0 <l_sfltsi>:
979
-  e0:  b9 00 00 00     l.sfltsi r0,0
980
-
981
-000000e4 <l_sfltui>:
982
-  e4:  b8 80 00 00     l.sfltui r0,0x0
983
-
984
-000000e8 <l_sflesi>:
985
-  e8:  b9 20 00 00     l.sflesi r0,0
986
-
987
-000000ec <l_sfleui>:
988
-  ec:  b8 a0 00 00     l.sfleui r0,0x0
989
-
990
-000000f0 <l_sfeq>:
991
-  f0:  e4 00 00 00     l.sfeq r0,r0
992
-
993
-000000f4 <l_sfeqi>:
994
-  f4:  b8 00 00 00     l.sfeqi r0,0
995
-
996
-000000f8 <l_sfne>:
997
-  f8:  e4 20 00 00     l.sfne r0,r0
998
-
999
-000000fc <l_sfnei>:
1000
-  fc:  b8 20 00 00     l.sfnei r0,0
1001
diff --unified -N -r ../binutils-2.16.1/gas/testsuite/gas/openrisc/allinsn.exp binutils-2.16.1/gas/testsuite/gas/openrisc/allinsn.exp
1002
--- ../binutils-2.16.1/gas/testsuite/gas/openrisc/allinsn.exp   2001-05-02 20:14:30.000000000 +0200
1003
+++ binutils-2.16.1/gas/testsuite/gas/openrisc/allinsn.exp      1970-01-01 01:00:00.000000000 +0100
1004
@@ -1,8 +0,0 @@
1005
-# OpenRISC assembler testsuite.
1006
-
1007
-if [istarget openrisc*-*-*] {
1008
-    run_dump_test "allinsn"
1009
-    run_dump_test "addi"
1010
-    run_dump_test "lohi"
1011
-    run_dump_test "store"
1012
-}
1013
diff --unified -N -r ../binutils-2.16.1/gas/testsuite/gas/openrisc/allinsn.s binutils-2.16.1/gas/testsuite/gas/openrisc/allinsn.s
1014
--- ../binutils-2.16.1/gas/testsuite/gas/openrisc/allinsn.s     2001-05-02 20:14:30.000000000 +0200
1015
+++ binutils-2.16.1/gas/testsuite/gas/openrisc/allinsn.s        1970-01-01 01:00:00.000000000 +0100
1016
@@ -1,260 +0,0 @@
1017
- .data
1018
-foodata: .word 42
1019
- .text
1020
-footext:
1021
-       .text
1022
-       .global l_j
1023
-l_j:
1024
-       l.j footext
1025
-       .text
1026
-       .global l_jal
1027
-l_jal:
1028
-       l.jal footext
1029
-       .text
1030
-       .global l_jr
1031
-l_jr:
1032
-       l.jr r0
1033
-       .text
1034
-       .global l_jalr
1035
-l_jalr:
1036
-       l.jalr r0
1037
-       .text
1038
-       .global l_bal
1039
-l_bal:
1040
-       l.bal footext
1041
-       .text
1042
-       .global l_bnf
1043
-l_bnf:
1044
-       l.bnf footext
1045
-       .text
1046
-       .global l_bf
1047
-l_bf:
1048
-       l.bf footext
1049
-       .text
1050
-       .global l_brk
1051
-l_brk:
1052
-       l.brk 0
1053
-       .text
1054
-       .global l_rfe
1055
-l_rfe:
1056
-       l.rfe r0
1057
-       .text
1058
-       .global l_sys
1059
-l_sys:
1060
-       l.sys 0
1061
-       .text
1062
-       .global l_nop
1063
-l_nop:
1064
-       l.nop
1065
-       .text
1066
-       .global l_movhi
1067
-l_movhi:
1068
-       l.movhi r0,0
1069
-       .text
1070
-       .global l_mfsr
1071
-l_mfsr:
1072
-       l.mfsr r0,r0
1073
-       .text
1074
-       .global l_mtsr
1075
-l_mtsr:
1076
-       l.mtsr r0,r0
1077
-       .text
1078
-       .global l_lw
1079
-l_lw:
1080
-       l.lw r0,0(r0)
1081
-       .text
1082
-       .global l_lbz
1083
-l_lbz:
1084
-       l.lbz r0,0(r0)
1085
-       .text
1086
-       .global l_lbs
1087
-l_lbs:
1088
-       l.lbs r0,0(r0)
1089
-       .text
1090
-       .global l_lhz
1091
-l_lhz:
1092
-       l.lhz r0,0(r0)
1093
-       .text
1094
-       .global l_lhs
1095
-l_lhs:
1096
-       l.lhs r0,0(r0)
1097
-       .text
1098
-       .global l_sw
1099
-l_sw:
1100
-       l.sw 0(r0),r0
1101
-       .text
1102
-       .global l_sb
1103
-l_sb:
1104
-       l.sb 0(r0),r0
1105
-       .text
1106
-       .global l_sh
1107
-l_sh:
1108
-       l.sh 0(r0),r0
1109
-       .text
1110
-       .global l_sll
1111
-l_sll:
1112
-       l.sll r0,r0,r0
1113
-       .text
1114
-       .global l_slli
1115
-l_slli:
1116
-       l.slli r0,r0,0
1117
-       .text
1118
-       .global l_srl
1119
-l_srl:
1120
-       l.srl r0,r0,r0
1121
-       .text
1122
-       .global l_srli
1123
-l_srli:
1124
-       l.srli r0,r0,0
1125
-       .text
1126
-       .global l_sra
1127
-l_sra:
1128
-       l.sra r0,r0,r0
1129
-       .text
1130
-       .global l_srai
1131
-l_srai:
1132
-       l.srai r0,r0,0
1133
-       .text
1134
-       .global l_ror
1135
-l_ror:
1136
-       l.ror r0,r0,r0
1137
-       .text
1138
-       .global l_rori
1139
-l_rori:
1140
-       l.rori r0,r0,0
1141
-       .text
1142
-       .global l_add
1143
-l_add:
1144
-       l.add r0,r0,r0
1145
-       .text
1146
-       .global l_addi
1147
-l_addi:
1148
-       l.addi r0,r0,0
1149
-       .text
1150
-       .global l_sub
1151
-l_sub:
1152
-       l.sub r0,r0,r0
1153
-       .text
1154
-       .global l_subi
1155
-l_subi:
1156
-       l.subi r0,r0,0
1157
-       .text
1158
-       .global l_and
1159
-l_and:
1160
-       l.and r0,r0,r0
1161
-       .text
1162
-       .global l_andi
1163
-l_andi:
1164
-       l.andi r0,r0,0
1165
-       .text
1166
-       .global l_or
1167
-l_or:
1168
-       l.or r0,r0,r0
1169
-       .text
1170
-       .global l_ori
1171
-l_ori:
1172
-       l.ori r0,r0,0
1173
-       .text
1174
-       .global l_xor
1175
-l_xor:
1176
-       l.xor r0,r0,r0
1177
-       .text
1178
-       .global l_xori
1179
-l_xori:
1180
-       l.xori r0,r0,0
1181
-       .text
1182
-       .global l_mul
1183
-l_mul:
1184
-       l.mul r0,r0,r0
1185
-       .text
1186
-       .global l_muli
1187
-l_muli:
1188
-       l.muli r0,r0,0
1189
-       .text
1190
-       .global l_div
1191
-l_div:
1192
-       l.div r0,r0,r0
1193
-       .text
1194
-       .global l_divu
1195
-l_divu:
1196
-       l.divu r0,r0,r0
1197
-       .text
1198
-       .global l_sfgts
1199
-l_sfgts:
1200
-       l.sfgts r0,r0
1201
-       .text
1202
-       .global l_sfgtu
1203
-l_sfgtu:
1204
-       l.sfgtu r0,r0
1205
-       .text
1206
-       .global l_sfges
1207
-l_sfges:
1208
-       l.sfges r0,r0
1209
-       .text
1210
-       .global l_sfgeu
1211
-l_sfgeu:
1212
-       l.sfgeu r0,r0
1213
-       .text
1214
-       .global l_sflts
1215
-l_sflts:
1216
-       l.sflts r0,r0
1217
-       .text
1218
-       .global l_sfltu
1219
-l_sfltu:
1220
-       l.sfltu r0,r0
1221
-       .text
1222
-       .global l_sfles
1223
-l_sfles:
1224
-       l.sfles r0,r0
1225
-       .text
1226
-       .global l_sfleu
1227
-l_sfleu:
1228
-       l.sfleu r0,r0
1229
-       .text
1230
-       .global l_sfgtsi
1231
-l_sfgtsi:
1232
-       l.sfgtsi r0,0
1233
-       .text
1234
-       .global l_sfgtui
1235
-l_sfgtui:
1236
-       l.sfgtui r0,0
1237
-       .text
1238
-       .global l_sfgesi
1239
-l_sfgesi:
1240
-       l.sfgesi r0,0
1241
-       .text
1242
-       .global l_sfgeui
1243
-l_sfgeui:
1244
-       l.sfgeui r0,0
1245
-       .text
1246
-       .global l_sfltsi
1247
-l_sfltsi:
1248
-       l.sfltsi r0,0
1249
-       .text
1250
-       .global l_sfltui
1251
-l_sfltui:
1252
-       l.sfltui r0,0
1253
-       .text
1254
-       .global l_sflesi
1255
-l_sflesi:
1256
-       l.sflesi r0,0
1257
-       .text
1258
-       .global l_sfleui
1259
-l_sfleui:
1260
-       l.sfleui r0,0
1261
-       .text
1262
-       .global l_sfeq
1263
-l_sfeq:
1264
-       l.sfeq r0,r0
1265
-       .text
1266
-       .global l_sfeqi
1267
-l_sfeqi:
1268
-       l.sfeqi r0,0
1269
-       .text
1270
-       .global l_sfne
1271
-l_sfne:
1272
-       l.sfne r0,r0
1273
-       .text
1274
-       .global l_sfnei
1275
-l_sfnei:
1276
-       l.sfnei r0,0
1277
diff --unified -N -r ../binutils-2.16.1/gas/testsuite/gas/openrisc/lohi.d binutils-2.16.1/gas/testsuite/gas/openrisc/lohi.d
1278
--- ../binutils-2.16.1/gas/testsuite/gas/openrisc/lohi.d        2001-05-02 20:14:30.000000000 +0200
1279
+++ binutils-2.16.1/gas/testsuite/gas/openrisc/lohi.d   1970-01-01 01:00:00.000000000 +0100
1280
@@ -1,13 +0,0 @@
1281
-#as:
1282
-#objdump: -dr
1283
-#name: lohi
1284
-
1285
-.*: +file format .*
1286
-
1287
-Disassembly of section .text:
1288
-
1289
-00000000 <l_lo>:
1290
-   0:  94 21 be ef     l.addi r1,r1,-16657
1291
-
1292
-00000004 <l_hi>:
1293
-   4:  18 20 de ad     l.movhi r1,-8531
1294
diff --unified -N -r ../binutils-2.16.1/gas/testsuite/gas/openrisc/lohi.s binutils-2.16.1/gas/testsuite/gas/openrisc/lohi.s
1295
--- ../binutils-2.16.1/gas/testsuite/gas/openrisc/lohi.s        2001-05-02 20:14:30.000000000 +0200
1296
+++ binutils-2.16.1/gas/testsuite/gas/openrisc/lohi.s   1970-01-01 01:00:00.000000000 +0100
1297
@@ -1,7 +0,0 @@
1298
-       .text
1299
-       .global l_lo
1300
-l_lo:
1301
-       l.addi  r1, r1, lo(0xdeadbeef)
1302
-       .global l_hi
1303
-l_hi:
1304
-       l.movhi r1, hi(0xdeadbeef)
1305
diff --unified -N -r ../binutils-2.16.1/gas/testsuite/gas/openrisc/store.d binutils-2.16.1/gas/testsuite/gas/openrisc/store.d
1306
--- ../binutils-2.16.1/gas/testsuite/gas/openrisc/store.d       2001-05-02 20:14:30.000000000 +0200
1307
+++ binutils-2.16.1/gas/testsuite/gas/openrisc/store.d  1970-01-01 01:00:00.000000000 +0100
1308
@@ -1,13 +0,0 @@
1309
-#as:
1310
-#objdump: -dr
1311
-#name: store
1312
-
1313
-.*: +file format .*
1314
-
1315
-Disassembly of section .text:
1316
-
1317
-00000000 <l_sw>:
1318
-   0:  d7 e1 0f fc     l.sw -4\(r1\),r1
1319
-
1320
-00000004 <l_lw>:
1321
-   4:  80 21 ff 9c     l.lw r1,-100\(r1\)
1322
diff --unified -N -r ../binutils-2.16.1/gas/testsuite/gas/openrisc/store.s binutils-2.16.1/gas/testsuite/gas/openrisc/store.s
1323
--- ../binutils-2.16.1/gas/testsuite/gas/openrisc/store.s       2001-05-02 20:14:30.000000000 +0200
1324
+++ binutils-2.16.1/gas/testsuite/gas/openrisc/store.s  1970-01-01 01:00:00.000000000 +0100
1325
@@ -1,7 +0,0 @@
1326
-       .text
1327
-       .global l_sw
1328
-l_sw:
1329
-       l.sw    -4(r1), r1
1330
-       .global l_lw
1331
-l_lw:
1332
-       l.lw    r1, -100(r1)
1333
diff --unified -N -r ../binutils-2.16.1/include/elf/openrisc.h binutils-2.16.1/include/elf/openrisc.h
1334
--- ../binutils-2.16.1/include/elf/openrisc.h   2001-04-24 17:08:16.000000000 +0200
1335
+++ binutils-2.16.1/include/elf/openrisc.h      1970-01-01 01:00:00.000000000 +0100
1336
@@ -1,39 +0,0 @@
1337
-/* OpenRISC ELF support for BFD.
1338
-   Copyright 2001 Free Software Foundation, Inc.
1339
-
1340
-This file is part of BFD, the Binary File Descriptor library.
1341
-
1342
-This program is free software; you can redistribute it and/or modify
1343
-it under the terms of the GNU General Public License as published by
1344
-the Free Software Foundation; either version 2 of the License, or
1345
-(at your option) any later version.
1346
-
1347
-This program is distributed in the hope that it will be useful,
1348
-but WITHOUT ANY WARRANTY; without even the implied warranty of
1349
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1350
-GNU General Public License for more details.
1351
-
1352
-You should have received a copy of the GNU General Public License
1353
-along with this program; if not, write to the Free Software Foundation, Inc.,
1354
-59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
1355
-
1356
-#ifndef _ELF_OPENRISC_H
1357
-#define _ELF_OPENRISC_H
1358
-
1359
-#include "elf/reloc-macros.h"
1360
-
1361
-/* Relocations.  */
1362
-START_RELOC_NUMBERS (elf_openrisc_reloc_type)
1363
-  RELOC_NUMBER (R_OPENRISC_NONE, 0)
1364
-  RELOC_NUMBER (R_OPENRISC_INSN_REL_26, 1)
1365
-  RELOC_NUMBER (R_OPENRISC_INSN_ABS_26, 2)
1366
-  RELOC_NUMBER (R_OPENRISC_LO_16_IN_INSN, 3)
1367
-  RELOC_NUMBER (R_OPENRISC_HI_16_IN_INSN, 4)
1368
-  RELOC_NUMBER (R_OPENRISC_8, 5)
1369
-  RELOC_NUMBER (R_OPENRISC_16, 6)
1370
-  RELOC_NUMBER (R_OPENRISC_32, 7)
1371
-  RELOC_NUMBER (R_OPENRISC_GNU_VTINHERIT, 8)
1372
-  RELOC_NUMBER (R_OPENRISC_GNU_VTENTRY, 9)
1373
-END_RELOC_NUMBERS (R_OPENRISC_max)
1374
-
1375
-#endif /* _ELF_OPENRISC_H */
1376
diff --unified -N -r ../binutils-2.16.1/ld/configure.tgt binutils-2.16.1/ld/configure.tgt
1377
--- ../binutils-2.16.1/ld/configure.tgt 2005-02-08 20:54:27.000000000 +0100
1378
+++ binutils-2.16.1/ld/configure.tgt    2005-12-13 15:51:29.000000000 +0100
1379
@@ -478,7 +478,7 @@
1380
 z8k-*-coff)            targ_emul=z8002; targ_extra_emuls=z8001 ;;
1381
 ns32k-pc532-mach* | ns32k-pc532-ux*)   targ_emul=pc532macha ;;
1382
 ns32k-*-netbsd* | ns32k-pc532-lites*) targ_emul=ns32knbsd ;;
1383
-openrisc-*-*)          targ_emul=elf32openrisc ;;
1384
+or32-*-*linux*)                targ_emul=or32elf ;;
1385
 or32-*-coff)           targ_emul=or32 ;;
1386
 or32-*-elf)            targ_emul=or32elf ;;
1387
 or32-*-rtems*)          targ_emul=or32elf ;;
1388
diff --unified -N -r ../binutils-2.16.1/ld/emulparams/elf32openrisc.sh binutils-2.16.1/ld/emulparams/elf32openrisc.sh
1389
--- ../binutils-2.16.1/ld/emulparams/elf32openrisc.sh   2001-05-02 20:14:30.000000000 +0200
1390
+++ binutils-2.16.1/ld/emulparams/elf32openrisc.sh      1970-01-01 01:00:00.000000000 +0100
1391
@@ -1,10 +0,0 @@
1392
-MACHINE=
1393
-SCRIPT_NAME=elf
1394
-OUTPUT_FORMAT="elf32-openrisc"
1395
-TEXT_START_ADDR=0x10000
1396
-ARCH=openrisc
1397
-MAXPAGESIZE=0x1000
1398
-ENTRY=_start
1399
-EMBEDDED=yes
1400
-NOP=0x15000000
1401
-
1402
diff --unified -N -r ../binutils-2.16.1/opcodes/configure binutils-2.16.1/opcodes/configure
1403
--- ../binutils-2.16.1/opcodes/configure        2005-01-31 21:30:37.000000000 +0100
1404
+++ binutils-2.16.1/opcodes/configure   2005-12-13 15:51:29.000000000 +0100
1405
@@ -8629,7 +8629,6 @@
1406
        bfd_mn10300_arch)       ta="$ta m10300-dis.lo m10300-opc.lo" ;;
1407
        bfd_msp430_arch)        ta="$ta msp430-dis.lo" ;;
1408
        bfd_ns32k_arch)         ta="$ta ns32k-dis.lo" ;;
1409
-       bfd_openrisc_arch)      ta="$ta openrisc-asm.lo openrisc-desc.lo openrisc-dis.lo openrisc-ibld.lo openrisc-opc.lo" using_cgen=yes ;;
1410
        bfd_or32_arch)          ta="$ta or32-dis.lo or32-opc.lo" using_cgen=yes ;;
1411
        bfd_pdp11_arch)         ta="$ta pdp11-dis.lo pdp11-opc.lo" ;;
1412
        bfd_pj_arch)            ta="$ta pj-dis.lo pj-opc.lo" ;;
1413
diff --unified -N -r ../binutils-2.16.1/opcodes/configure.in binutils-2.16.1/opcodes/configure.in
1414
--- ../binutils-2.16.1/opcodes/configure.in     2004-11-08 14:17:37.000000000 +0100
1415
+++ binutils-2.16.1/opcodes/configure.in        2005-12-13 15:51:29.000000000 +0100
1416
@@ -206,7 +206,6 @@
1417
        bfd_mn10300_arch)       ta="$ta m10300-dis.lo m10300-opc.lo" ;;
1418
        bfd_msp430_arch)        ta="$ta msp430-dis.lo" ;;
1419
        bfd_ns32k_arch)         ta="$ta ns32k-dis.lo" ;;
1420
-       bfd_openrisc_arch)      ta="$ta openrisc-asm.lo openrisc-desc.lo openrisc-dis.lo openrisc-ibld.lo openrisc-opc.lo" using_cgen=yes ;;
1421
        bfd_or32_arch)          ta="$ta or32-dis.lo or32-opc.lo" using_cgen=yes ;;
1422
        bfd_pdp11_arch)         ta="$ta pdp11-dis.lo pdp11-opc.lo" ;;
1423
        bfd_pj_arch)            ta="$ta pj-dis.lo pj-opc.lo" ;;
1424
diff --unified -N -r ../binutils-2.16.1/opcodes/openrisc-asm.c binutils-2.16.1/opcodes/openrisc-asm.c
1425
--- ../binutils-2.16.1/opcodes/openrisc-asm.c   2005-02-23 17:04:39.000000000 +0100
1426
+++ binutils-2.16.1/opcodes/openrisc-asm.c      1970-01-01 01:00:00.000000000 +0100
1427
@@ -1,675 +0,0 @@
1428
-/* Assembler interface for targets using CGEN. -*- C -*-
1429
-   CGEN: Cpu tools GENerator
1430
-
1431
-THIS FILE IS MACHINE GENERATED WITH CGEN.
1432
-- the resultant file is machine generated, cgen-asm.in isn't
1433
-
1434
-Copyright 1996, 1997, 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
1435
-
1436
-This file is part of the GNU Binutils and GDB, the GNU debugger.
1437
-
1438
-This program is free software; you can redistribute it and/or modify
1439
-it under the terms of the GNU General Public License as published by
1440
-the Free Software Foundation; either version 2, or (at your option)
1441
-any later version.
1442
-
1443
-This program is distributed in the hope that it will be useful,
1444
-but WITHOUT ANY WARRANTY; without even the implied warranty of
1445
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1446
-GNU General Public License for more details.
1447
-
1448
-You should have received a copy of the GNU General Public License
1449
-along with this program; if not, write to the Free Software Foundation, Inc.,
1450
-59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
1451
-
1452
-/* ??? Eventually more and more of this stuff can go to cpu-independent files.
1453
-   Keep that in mind.  */
1454
-
1455
-#include "sysdep.h"
1456
-#include <stdio.h>
1457
-#include "ansidecl.h"
1458
-#include "bfd.h"
1459
-#include "symcat.h"
1460
-#include "openrisc-desc.h"
1461
-#include "openrisc-opc.h"
1462
-#include "opintl.h"
1463
-#include "xregex.h"
1464
-#include "libiberty.h"
1465
-#include "safe-ctype.h"
1466
-
1467
-#undef  min
1468
-#define min(a,b) ((a) < (b) ? (a) : (b))
1469
-#undef  max
1470
-#define max(a,b) ((a) > (b) ? (a) : (b))
1471
-
1472
-static const char * parse_insn_normal
1473
-  (CGEN_CPU_DESC, const CGEN_INSN *, const char **, CGEN_FIELDS *);
1474
-
1475
-/* -- assembler routines inserted here.  */
1476
-
1477
-/* -- asm.c */
1478
-
1479
-#define CGEN_VERBOSE_ASSEMBLER_ERRORS
1480
-
1481
-static const char * parse_hi16
1482
-  PARAMS ((CGEN_CPU_DESC, const char **, int, long *));
1483
-static const char * parse_lo16
1484
-  PARAMS ((CGEN_CPU_DESC, const char **, int, long *));
1485
-
1486
-long
1487
-openrisc_sign_extend_16bit (value)
1488
-     long value;
1489
-{
1490
-  return ((value & 0xffff) ^ 0x8000) - 0x8000;
1491
-}
1492
-
1493
-/* Handle hi().  */
1494
-
1495
-static const char *
1496
-parse_hi16 (cd, strp, opindex, valuep)
1497
-     CGEN_CPU_DESC cd;
1498
-     const char **strp;
1499
-     int opindex;
1500
-     long *valuep;
1501
-{
1502
-  const char *errmsg;
1503
-  enum cgen_parse_operand_result result_type;
1504
-  unsigned long ret;
1505
-
1506
-  if (**strp == '#')
1507
-    ++*strp;
1508
-
1509
-  if (strncasecmp (*strp, "hi(", 3) == 0)
1510
-    {
1511
-      bfd_vma value;
1512
-
1513
-      *strp += 3;
1514
-      errmsg = cgen_parse_address (cd, strp, opindex, BFD_RELOC_HI16,
1515
-                                     &result_type, &value);
1516
-      if (**strp != ')')
1517
-        return _("missing `)'");
1518
-
1519
-      ++*strp;
1520
-      if (errmsg == NULL
1521
-          && result_type == CGEN_PARSE_OPERAND_RESULT_NUMBER)
1522
-        value >>= 16;
1523
-      ret = value;
1524
-    }
1525
-  else
1526
-    {
1527
-      if (**strp == '-')
1528
-       {
1529
-         long value;
1530
-
1531
-         errmsg = cgen_parse_signed_integer (cd, strp, opindex, &value);
1532
-         ret = value;
1533
-       }
1534
-      else
1535
-       {
1536
-         unsigned long value;
1537
-
1538
-         errmsg = cgen_parse_unsigned_integer (cd, strp, opindex, &value);
1539
-         ret = value;
1540
-       }
1541
-    }
1542
-
1543
-  *valuep = ((ret & 0xffff) ^ 0x8000) - 0x8000;
1544
-  return errmsg;
1545
-}
1546
-
1547
-/* Handle lo().  */
1548
-
1549
-static const char *
1550
-parse_lo16 (cd, strp, opindex, valuep)
1551
-     CGEN_CPU_DESC cd;
1552
-     const char **strp;
1553
-     int opindex;
1554
-     long *valuep;
1555
-{
1556
-  const char *errmsg;
1557
-  enum cgen_parse_operand_result result_type;
1558
-  unsigned long ret;
1559
-
1560
-  if (**strp == '#')
1561
-    ++*strp;
1562
-
1563
-  if (strncasecmp (*strp, "lo(", 3) == 0)
1564
-    {
1565
-      bfd_vma value;
1566
-
1567
-      *strp += 3;
1568
-      errmsg = cgen_parse_address (cd, strp, opindex, BFD_RELOC_LO16,
1569
-                                  &result_type, &value);
1570
-      if (**strp != ')')
1571
-        return _("missing `)'");
1572
-
1573
-      ++*strp;
1574
-      ret = value;
1575
-    }
1576
-  else
1577
-    {
1578
-      if (**strp == '-')
1579
-       {
1580
-         long value;
1581
-
1582
-         errmsg = cgen_parse_signed_integer (cd, strp, opindex, &value);
1583
-         ret = value;
1584
-       }
1585
-      else
1586
-       {
1587
-         unsigned long value;
1588
-
1589
-         errmsg = cgen_parse_unsigned_integer (cd, strp, opindex, &value);
1590
-         ret = value;
1591
-       }
1592
-    }
1593
-
1594
-  *valuep = ((ret & 0xffff) ^ 0x8000) - 0x8000;
1595
-  return errmsg;
1596
-}
1597
-
1598
-/* -- */
1599
-
1600
-const char * openrisc_cgen_parse_operand
1601
-  PARAMS ((CGEN_CPU_DESC, int, const char **, CGEN_FIELDS *));
1602
-
1603
-/* Main entry point for operand parsing.
1604
-
1605
-   This function is basically just a big switch statement.  Earlier versions
1606
-   used tables to look up the function to use, but
1607
-   - if the table contains both assembler and disassembler functions then
1608
-     the disassembler contains much of the assembler and vice-versa,
1609
-   - there's a lot of inlining possibilities as things grow,
1610
-   - using a switch statement avoids the function call overhead.
1611
-
1612
-   This function could be moved into `parse_insn_normal', but keeping it
1613
-   separate makes clear the interface between `parse_insn_normal' and each of
1614
-   the handlers.  */
1615
-
1616
-const char *
1617
-openrisc_cgen_parse_operand (cd, opindex, strp, fields)
1618
-     CGEN_CPU_DESC cd;
1619
-     int opindex;
1620
-     const char ** strp;
1621
-     CGEN_FIELDS * fields;
1622
-{
1623
-  const char * errmsg = NULL;
1624
-  /* Used by scalar operands that still need to be parsed.  */
1625
-  long junk ATTRIBUTE_UNUSED;
1626
-
1627
-  switch (opindex)
1628
-    {
1629
-    case OPENRISC_OPERAND_ABS_26 :
1630
-      {
1631
-        bfd_vma value;
1632
-        errmsg = cgen_parse_address (cd, strp, OPENRISC_OPERAND_ABS_26, 0, NULL,  & value);
1633
-        fields->f_abs26 = value;
1634
-      }
1635
-      break;
1636
-    case OPENRISC_OPERAND_DISP_26 :
1637
-      {
1638
-        bfd_vma value;
1639
-        errmsg = cgen_parse_address (cd, strp, OPENRISC_OPERAND_DISP_26, 0, NULL,  & value);
1640
-        fields->f_disp26 = value;
1641
-      }
1642
-      break;
1643
-    case OPENRISC_OPERAND_HI16 :
1644
-      errmsg = parse_hi16 (cd, strp, OPENRISC_OPERAND_HI16, (long *) (& fields->f_simm16));
1645
-      break;
1646
-    case OPENRISC_OPERAND_LO16 :
1647
-      errmsg = parse_lo16 (cd, strp, OPENRISC_OPERAND_LO16, (long *) (& fields->f_lo16));
1648
-      break;
1649
-    case OPENRISC_OPERAND_OP_F_23 :
1650
-      errmsg = cgen_parse_unsigned_integer (cd, strp, OPENRISC_OPERAND_OP_F_23, (unsigned long *) (& fields->f_op4));
1651
-      break;
1652
-    case OPENRISC_OPERAND_OP_F_3 :
1653
-      errmsg = cgen_parse_unsigned_integer (cd, strp, OPENRISC_OPERAND_OP_F_3, (unsigned long *) (& fields->f_op5));
1654
-      break;
1655
-    case OPENRISC_OPERAND_RA :
1656
-      errmsg = cgen_parse_keyword (cd, strp, & openrisc_cgen_opval_h_gr, & fields->f_r2);
1657
-      break;
1658
-    case OPENRISC_OPERAND_RB :
1659
-      errmsg = cgen_parse_keyword (cd, strp, & openrisc_cgen_opval_h_gr, & fields->f_r3);
1660
-      break;
1661
-    case OPENRISC_OPERAND_RD :
1662
-      errmsg = cgen_parse_keyword (cd, strp, & openrisc_cgen_opval_h_gr, & fields->f_r1);
1663
-      break;
1664
-    case OPENRISC_OPERAND_SIMM_16 :
1665
-      errmsg = cgen_parse_signed_integer (cd, strp, OPENRISC_OPERAND_SIMM_16, (long *) (& fields->f_simm16));
1666
-      break;
1667
-    case OPENRISC_OPERAND_UI16NC :
1668
-      errmsg = parse_lo16 (cd, strp, OPENRISC_OPERAND_UI16NC, (long *) (& fields->f_i16nc));
1669
-      break;
1670
-    case OPENRISC_OPERAND_UIMM_16 :
1671
-      errmsg = cgen_parse_unsigned_integer (cd, strp, OPENRISC_OPERAND_UIMM_16, (unsigned long *) (& fields->f_uimm16));
1672
-      break;
1673
-    case OPENRISC_OPERAND_UIMM_5 :
1674
-      errmsg = cgen_parse_unsigned_integer (cd, strp, OPENRISC_OPERAND_UIMM_5, (unsigned long *) (& fields->f_uimm5));
1675
-      break;
1676
-
1677
-    default :
1678
-      /* xgettext:c-format */
1679
-      fprintf (stderr, _("Unrecognized field %d while parsing.\n"), opindex);
1680
-      abort ();
1681
-  }
1682
-
1683
-  return errmsg;
1684
-}
1685
-
1686
-cgen_parse_fn * const openrisc_cgen_parse_handlers[] =
1687
-{
1688
-  parse_insn_normal,
1689
-};
1690
-
1691
-void
1692
-openrisc_cgen_init_asm (cd)
1693
-     CGEN_CPU_DESC cd;
1694
-{
1695
-  openrisc_cgen_init_opcode_table (cd);
1696
-  openrisc_cgen_init_ibld_table (cd);
1697
-  cd->parse_handlers = & openrisc_cgen_parse_handlers[0];
1698
-  cd->parse_operand = openrisc_cgen_parse_operand;
1699
-}
1700
-
1701
-
1702
-
1703
-/* Regex construction routine.
1704
-
1705
-   This translates an opcode syntax string into a regex string,
1706
-   by replacing any non-character syntax element (such as an
1707
-   opcode) with the pattern '.*'
1708
-
1709
-   It then compiles the regex and stores it in the opcode, for
1710
-   later use by openrisc_cgen_assemble_insn
1711
-
1712
-   Returns NULL for success, an error message for failure.  */
1713
-
1714
-char *
1715
-openrisc_cgen_build_insn_regex (CGEN_INSN *insn)
1716
-{
1717
-  CGEN_OPCODE *opc = (CGEN_OPCODE *) CGEN_INSN_OPCODE (insn);
1718
-  const char *mnem = CGEN_INSN_MNEMONIC (insn);
1719
-  char rxbuf[CGEN_MAX_RX_ELEMENTS];
1720
-  char *rx = rxbuf;
1721
-  const CGEN_SYNTAX_CHAR_TYPE *syn;
1722
-  int reg_err;
1723
-
1724
-  syn = CGEN_SYNTAX_STRING (CGEN_OPCODE_SYNTAX (opc));
1725
-
1726
-  /* Mnemonics come first in the syntax string.  */
1727
-  if (! CGEN_SYNTAX_MNEMONIC_P (* syn))
1728
-    return _("missing mnemonic in syntax string");
1729
-  ++syn;
1730
-
1731
-  /* Generate a case sensitive regular expression that emulates case
1732
-     insensitive matching in the "C" locale.  We cannot generate a case
1733
-     insensitive regular expression because in Turkish locales, 'i' and 'I'
1734
-     are not equal modulo case conversion.  */
1735
-
1736
-  /* Copy the literal mnemonic out of the insn.  */
1737
-  for (; *mnem; mnem++)
1738
-    {
1739
-      char c = *mnem;
1740
-
1741
-      if (ISALPHA (c))
1742
-       {
1743
-         *rx++ = '[';
1744
-         *rx++ = TOLOWER (c);
1745
-         *rx++ = TOUPPER (c);
1746
-         *rx++ = ']';
1747
-       }
1748
-      else
1749
-       *rx++ = c;
1750
-    }
1751
-
1752
-  /* Copy any remaining literals from the syntax string into the rx.  */
1753
-  for(; * syn != 0 && rx <= rxbuf + (CGEN_MAX_RX_ELEMENTS - 7 - 4); ++syn)
1754
-    {
1755
-      if (CGEN_SYNTAX_CHAR_P (* syn))
1756
-       {
1757
-         char c = CGEN_SYNTAX_CHAR (* syn);
1758
-
1759
-         switch (c)
1760
-           {
1761
-             /* Escape any regex metacharacters in the syntax.  */
1762
-           case '.': case '[': case '\\':
1763
-           case '*': case '^': case '$':
1764
-
1765
-#ifdef CGEN_ESCAPE_EXTENDED_REGEX
1766
-           case '?': case '{': case '}':
1767
-           case '(': case ')': case '*':
1768
-           case '|': case '+': case ']':
1769
-#endif
1770
-             *rx++ = '\\';
1771
-             *rx++ = c;
1772
-             break;
1773
-
1774
-           default:
1775
-             if (ISALPHA (c))
1776
-               {
1777
-                 *rx++ = '[';
1778
-                 *rx++ = TOLOWER (c);
1779
-                 *rx++ = TOUPPER (c);
1780
-                 *rx++ = ']';
1781
-               }
1782
-             else
1783
-               *rx++ = c;
1784
-             break;
1785
-           }
1786
-       }
1787
-      else
1788
-       {
1789
-         /* Replace non-syntax fields with globs.  */
1790
-         *rx++ = '.';
1791
-         *rx++ = '*';
1792
-       }
1793
-    }
1794
-
1795
-  /* Trailing whitespace ok.  */
1796
-  * rx++ = '[';
1797
-  * rx++ = ' ';
1798
-  * rx++ = '\t';
1799
-  * rx++ = ']';
1800
-  * rx++ = '*';
1801
-
1802
-  /* But anchor it after that.  */
1803
-  * rx++ = '$';
1804
-  * rx = '\0';
1805
-
1806
-  CGEN_INSN_RX (insn) = xmalloc (sizeof (regex_t));
1807
-  reg_err = regcomp ((regex_t *) CGEN_INSN_RX (insn), rxbuf, REG_NOSUB);
1808
-
1809
-  if (reg_err == 0)
1810
-    return NULL;
1811
-  else
1812
-    {
1813
-      static char msg[80];
1814
-
1815
-      regerror (reg_err, (regex_t *) CGEN_INSN_RX (insn), msg, 80);
1816
-      regfree ((regex_t *) CGEN_INSN_RX (insn));
1817
-      free (CGEN_INSN_RX (insn));
1818
-      (CGEN_INSN_RX (insn)) = NULL;
1819
-      return msg;
1820
-    }
1821
-}
1822
-
1823
-
1824
-/* Default insn parser.
1825
-
1826
-   The syntax string is scanned and operands are parsed and stored in FIELDS.
1827
-   Relocs are queued as we go via other callbacks.
1828
-
1829
-   ??? Note that this is currently an all-or-nothing parser.  If we fail to
1830
-   parse the instruction, we return 0 and the caller will start over from
1831
-   the beginning.  Backtracking will be necessary in parsing subexpressions,
1832
-   but that can be handled there.  Not handling backtracking here may get
1833
-   expensive in the case of the m68k.  Deal with later.
1834
-
1835
-   Returns NULL for success, an error message for failure.  */
1836
-
1837
-static const char *
1838
-parse_insn_normal (CGEN_CPU_DESC cd,
1839
-                  const CGEN_INSN *insn,
1840
-                  const char **strp,
1841
-                  CGEN_FIELDS *fields)
1842
-{
1843
-  /* ??? Runtime added insns not handled yet.  */
1844
-  const CGEN_SYNTAX *syntax = CGEN_INSN_SYNTAX (insn);
1845
-  const char *str = *strp;
1846
-  const char *errmsg;
1847
-  const char *p;
1848
-  const CGEN_SYNTAX_CHAR_TYPE * syn;
1849
-#ifdef CGEN_MNEMONIC_OPERANDS
1850
-  /* FIXME: wip */
1851
-  int past_opcode_p;
1852
-#endif
1853
-
1854
-  /* For now we assume the mnemonic is first (there are no leading operands).
1855
-     We can parse it without needing to set up operand parsing.
1856
-     GAS's input scrubber will ensure mnemonics are lowercase, but we may
1857
-     not be called from GAS.  */
1858
-  p = CGEN_INSN_MNEMONIC (insn);
1859
-  while (*p && TOLOWER (*p) == TOLOWER (*str))
1860
-    ++p, ++str;
1861
-
1862
-  if (* p)
1863
-    return _("unrecognized instruction");
1864
-
1865
-#ifndef CGEN_MNEMONIC_OPERANDS
1866
-  if (* str && ! ISSPACE (* str))
1867
-    return _("unrecognized instruction");
1868
-#endif
1869
-
1870
-  CGEN_INIT_PARSE (cd);
1871
-  cgen_init_parse_operand (cd);
1872
-#ifdef CGEN_MNEMONIC_OPERANDS
1873
-  past_opcode_p = 0;
1874
-#endif
1875
-
1876
-  /* We don't check for (*str != '\0') here because we want to parse
1877
-     any trailing fake arguments in the syntax string.  */
1878
-  syn = CGEN_SYNTAX_STRING (syntax);
1879
-
1880
-  /* Mnemonics come first for now, ensure valid string.  */
1881
-  if (! CGEN_SYNTAX_MNEMONIC_P (* syn))
1882
-    abort ();
1883
-
1884
-  ++syn;
1885
-
1886
-  while (* syn != 0)
1887
-    {
1888
-      /* Non operand chars must match exactly.  */
1889
-      if (CGEN_SYNTAX_CHAR_P (* syn))
1890
-       {
1891
-         /* FIXME: While we allow for non-GAS callers above, we assume the
1892
-            first char after the mnemonic part is a space.  */
1893
-         /* FIXME: We also take inappropriate advantage of the fact that
1894
-            GAS's input scrubber will remove extraneous blanks.  */
1895
-         if (TOLOWER (*str) == TOLOWER (CGEN_SYNTAX_CHAR (* syn)))
1896
-           {
1897
-#ifdef CGEN_MNEMONIC_OPERANDS
1898
-             if (CGEN_SYNTAX_CHAR(* syn) == ' ')
1899
-               past_opcode_p = 1;
1900
-#endif
1901
-             ++ syn;
1902
-             ++ str;
1903
-           }
1904
-         else if (*str)
1905
-           {
1906
-             /* Syntax char didn't match.  Can't be this insn.  */
1907
-             static char msg [80];
1908
-
1909
-             /* xgettext:c-format */
1910
-             sprintf (msg, _("syntax error (expected char `%c', found `%c')"),
1911
-                      CGEN_SYNTAX_CHAR(*syn), *str);
1912
-             return msg;
1913
-           }
1914
-         else
1915
-           {
1916
-             /* Ran out of input.  */
1917
-             static char msg [80];
1918
-
1919
-             /* xgettext:c-format */
1920
-             sprintf (msg, _("syntax error (expected char `%c', found end of instruction)"),
1921
-                      CGEN_SYNTAX_CHAR(*syn));
1922
-             return msg;
1923
-           }
1924
-         continue;
1925
-       }
1926
-
1927
-      /* We have an operand of some sort.  */
1928
-      errmsg = cd->parse_operand (cd, CGEN_SYNTAX_FIELD (*syn),
1929
-                                         &str, fields);
1930
-      if (errmsg)
1931
-       return errmsg;
1932
-
1933
-      /* Done with this operand, continue with next one.  */
1934
-      ++ syn;
1935
-    }
1936
-
1937
-  /* If we're at the end of the syntax string, we're done.  */
1938
-  if (* syn == 0)
1939
-    {
1940
-      /* FIXME: For the moment we assume a valid `str' can only contain
1941
-        blanks now.  IE: We needn't try again with a longer version of
1942
-        the insn and it is assumed that longer versions of insns appear
1943
-        before shorter ones (eg: lsr r2,r3,1 vs lsr r2,r3).  */
1944
-      while (ISSPACE (* str))
1945
-       ++ str;
1946
-
1947
-      if (* str != '\0')
1948
-       return _("junk at end of line"); /* FIXME: would like to include `str' */
1949
-
1950
-      return NULL;
1951
-    }
1952
-
1953
-  /* We couldn't parse it.  */
1954
-  return _("unrecognized instruction");
1955
-}
1956
-
1957
-/* Main entry point.
1958
-   This routine is called for each instruction to be assembled.
1959
-   STR points to the insn to be assembled.
1960
-   We assume all necessary tables have been initialized.
1961
-   The assembled instruction, less any fixups, is stored in BUF.
1962
-   Remember that if CGEN_INT_INSN_P then BUF is an int and thus the value
1963
-   still needs to be converted to target byte order, otherwise BUF is an array
1964
-   of bytes in target byte order.
1965
-   The result is a pointer to the insn's entry in the opcode table,
1966
-   or NULL if an error occured (an error message will have already been
1967
-   printed).
1968
-
1969
-   Note that when processing (non-alias) macro-insns,
1970
-   this function recurses.
1971
-
1972
-   ??? It's possible to make this cpu-independent.
1973
-   One would have to deal with a few minor things.
1974
-   At this point in time doing so would be more of a curiosity than useful
1975
-   [for example this file isn't _that_ big], but keeping the possibility in
1976
-   mind helps keep the design clean.  */
1977
-
1978
-const CGEN_INSN *
1979
-openrisc_cgen_assemble_insn (CGEN_CPU_DESC cd,
1980
-                          const char *str,
1981
-                          CGEN_FIELDS *fields,
1982
-                          CGEN_INSN_BYTES_PTR buf,
1983
-                          char **errmsg)
1984
-{
1985
-  const char *start;
1986
-  CGEN_INSN_LIST *ilist;
1987
-  const char *parse_errmsg = NULL;
1988
-  const char *insert_errmsg = NULL;
1989
-  int recognized_mnemonic = 0;
1990
-
1991
-  /* Skip leading white space.  */
1992
-  while (ISSPACE (* str))
1993
-    ++ str;
1994
-
1995
-  /* The instructions are stored in hashed lists.
1996
-     Get the first in the list.  */
1997
-  ilist = CGEN_ASM_LOOKUP_INSN (cd, str);
1998
-
1999
-  /* Keep looking until we find a match.  */
2000
-  start = str;
2001
-  for ( ; ilist != NULL ; ilist = CGEN_ASM_NEXT_INSN (ilist))
2002
-    {
2003
-      const CGEN_INSN *insn = ilist->insn;
2004
-      recognized_mnemonic = 1;
2005
-
2006
-#ifdef CGEN_VALIDATE_INSN_SUPPORTED
2007
-      /* Not usually needed as unsupported opcodes
2008
-        shouldn't be in the hash lists.  */
2009
-      /* Is this insn supported by the selected cpu?  */
2010
-      if (! openrisc_cgen_insn_supported (cd, insn))
2011
-       continue;
2012
-#endif
2013
-      /* If the RELAXED attribute is set, this is an insn that shouldn't be
2014
-        chosen immediately.  Instead, it is used during assembler/linker
2015
-        relaxation if possible.  */
2016
-      if (CGEN_INSN_ATTR_VALUE (insn, CGEN_INSN_RELAXED) != 0)
2017
-       continue;
2018
-
2019
-      str = start;
2020
-
2021
-      /* Skip this insn if str doesn't look right lexically.  */
2022
-      if (CGEN_INSN_RX (insn) != NULL &&
2023
-         regexec ((regex_t *) CGEN_INSN_RX (insn), str, 0, NULL, 0) == REG_NOMATCH)
2024
-       continue;
2025
-
2026
-      /* Allow parse/insert handlers to obtain length of insn.  */
2027
-      CGEN_FIELDS_BITSIZE (fields) = CGEN_INSN_BITSIZE (insn);
2028
-
2029
-      parse_errmsg = CGEN_PARSE_FN (cd, insn) (cd, insn, & str, fields);
2030
-      if (parse_errmsg != NULL)
2031
-       continue;
2032
-
2033
-      /* ??? 0 is passed for `pc'.  */
2034
-      insert_errmsg = CGEN_INSERT_FN (cd, insn) (cd, insn, fields, buf,
2035
-                                                (bfd_vma) 0);
2036
-      if (insert_errmsg != NULL)
2037
-        continue;
2038
-
2039
-      /* It is up to the caller to actually output the insn and any
2040
-         queued relocs.  */
2041
-      return insn;
2042
-    }
2043
-
2044
-  {
2045
-    static char errbuf[150];
2046
-#ifdef CGEN_VERBOSE_ASSEMBLER_ERRORS
2047
-    const char *tmp_errmsg;
2048
-
2049
-    /* If requesting verbose error messages, use insert_errmsg.
2050
-       Failing that, use parse_errmsg.  */
2051
-    tmp_errmsg = (insert_errmsg ? insert_errmsg :
2052
-                 parse_errmsg ? parse_errmsg :
2053
-                 recognized_mnemonic ?
2054
-                 _("unrecognized form of instruction") :
2055
-                 _("unrecognized instruction"));
2056
-
2057
-    if (strlen (start) > 50)
2058
-      /* xgettext:c-format */
2059
-      sprintf (errbuf, "%s `%.50s...'", tmp_errmsg, start);
2060
-    else
2061
-      /* xgettext:c-format */
2062
-      sprintf (errbuf, "%s `%.50s'", tmp_errmsg, start);
2063
-#else
2064
-    if (strlen (start) > 50)
2065
-      /* xgettext:c-format */
2066
-      sprintf (errbuf, _("bad instruction `%.50s...'"), start);
2067
-    else
2068
-      /* xgettext:c-format */
2069
-      sprintf (errbuf, _("bad instruction `%.50s'"), start);
2070
-#endif
2071
-
2072
-    *errmsg = errbuf;
2073
-    return NULL;
2074
-  }
2075
-}
2076
-
2077
-#if 0 /* This calls back to GAS which we can't do without care.  */
2078
-
2079
-/* Record each member of OPVALS in the assembler's symbol table.
2080
-   This lets GAS parse registers for us.
2081
-   ??? Interesting idea but not currently used.  */
2082
-
2083
-/* Record each member of OPVALS in the assembler's symbol table.
2084
-   FIXME: Not currently used.  */
2085
-
2086
-void
2087
-openrisc_cgen_asm_hash_keywords (CGEN_CPU_DESC cd, CGEN_KEYWORD *opvals)
2088
-{
2089
-  CGEN_KEYWORD_SEARCH search = cgen_keyword_search_init (opvals, NULL);
2090
-  const CGEN_KEYWORD_ENTRY * ke;
2091
-
2092
-  while ((ke = cgen_keyword_search_next (& search)) != NULL)
2093
-    {
2094
-#if 0 /* Unnecessary, should be done in the search routine.  */
2095
-      if (! openrisc_cgen_opval_supported (ke))
2096
-       continue;
2097
-#endif
2098
-      cgen_asm_record_register (cd, ke->name, ke->value);
2099
-    }
2100
-}
2101
-
2102
-#endif /* 0 */
2103
diff --unified -N -r ../binutils-2.16.1/opcodes/openrisc-desc.c binutils-2.16.1/opcodes/openrisc-desc.c
2104
--- ../binutils-2.16.1/opcodes/openrisc-desc.c  2005-02-22 01:33:20.000000000 +0100
2105
+++ binutils-2.16.1/opcodes/openrisc-desc.c     1970-01-01 01:00:00.000000000 +0100
2106
@@ -1,1064 +0,0 @@
2107
-/* CPU data for openrisc.
2108
-
2109
-THIS FILE IS MACHINE GENERATED WITH CGEN.
2110
-
2111
-Copyright 1996-2005 Free Software Foundation, Inc.
2112
-
2113
-This file is part of the GNU Binutils and/or GDB, the GNU debugger.
2114
-
2115
-This program is free software; you can redistribute it and/or modify
2116
-it under the terms of the GNU General Public License as published by
2117
-the Free Software Foundation; either version 2, or (at your option)
2118
-any later version.
2119
-
2120
-This program is distributed in the hope that it will be useful,
2121
-but WITHOUT ANY WARRANTY; without even the implied warranty of
2122
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
2123
-GNU General Public License for more details.
2124
-
2125
-You should have received a copy of the GNU General Public License along
2126
-with this program; if not, write to the Free Software Foundation, Inc.,
2127
-59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
2128
-
2129
-*/
2130
-
2131
-#include "sysdep.h"
2132
-#include <stdio.h>
2133
-#include <stdarg.h>
2134
-#include "ansidecl.h"
2135
-#include "bfd.h"
2136
-#include "symcat.h"
2137
-#include "openrisc-desc.h"
2138
-#include "openrisc-opc.h"
2139
-#include "opintl.h"
2140
-#include "libiberty.h"
2141
-#include "xregex.h"
2142
-
2143
-/* Attributes.  */
2144
-
2145
-static const CGEN_ATTR_ENTRY bool_attr[] =
2146
-{
2147
-  { "#f", 0 },
2148
-  { "#t", 1 },
2149
-  { 0, 0 }
2150
-};
2151
-
2152
-static const CGEN_ATTR_ENTRY MACH_attr[] ATTRIBUTE_UNUSED =
2153
-{
2154
-  { "base", MACH_BASE },
2155
-  { "openrisc", MACH_OPENRISC },
2156
-  { "or1300", MACH_OR1300 },
2157
-  { "max", MACH_MAX },
2158
-  { 0, 0 }
2159
-};
2160
-
2161
-static const CGEN_ATTR_ENTRY ISA_attr[] ATTRIBUTE_UNUSED =
2162
-{
2163
-  { "or32", ISA_OR32 },
2164
-  { "max", ISA_MAX },
2165
-  { 0, 0 }
2166
-};
2167
-
2168
-static const CGEN_ATTR_ENTRY HAS_CACHE_attr[] ATTRIBUTE_UNUSED =
2169
-{
2170
-  { "DATA_CACHE", HAS_CACHE_DATA_CACHE },
2171
-  { "INSN_CACHE", HAS_CACHE_INSN_CACHE },
2172
-  { 0, 0 }
2173
-};
2174
-
2175
-const CGEN_ATTR_TABLE openrisc_cgen_ifield_attr_table[] =
2176
-{
2177
-  { "MACH", & MACH_attr[0], & MACH_attr[0] },
2178
-  { "VIRTUAL", &bool_attr[0], &bool_attr[0] },
2179
-  { "PCREL-ADDR", &bool_attr[0], &bool_attr[0] },
2180
-  { "ABS-ADDR", &bool_attr[0], &bool_attr[0] },
2181
-  { "RESERVED", &bool_attr[0], &bool_attr[0] },
2182
-  { "SIGN-OPT", &bool_attr[0], &bool_attr[0] },
2183
-  { "SIGNED", &bool_attr[0], &bool_attr[0] },
2184
-  { 0, 0, 0 }
2185
-};
2186
-
2187
-const CGEN_ATTR_TABLE openrisc_cgen_hardware_attr_table[] =
2188
-{
2189
-  { "MACH", & MACH_attr[0], & MACH_attr[0] },
2190
-  { "VIRTUAL", &bool_attr[0], &bool_attr[0] },
2191
-  { "CACHE-ADDR", &bool_attr[0], &bool_attr[0] },
2192
-  { "PC", &bool_attr[0], &bool_attr[0] },
2193
-  { "PROFILE", &bool_attr[0], &bool_attr[0] },
2194
-  { 0, 0, 0 }
2195
-};
2196
-
2197
-const CGEN_ATTR_TABLE openrisc_cgen_operand_attr_table[] =
2198
-{
2199
-  { "MACH", & MACH_attr[0], & MACH_attr[0] },
2200
-  { "VIRTUAL", &bool_attr[0], &bool_attr[0] },
2201
-  { "PCREL-ADDR", &bool_attr[0], &bool_attr[0] },
2202
-  { "ABS-ADDR", &bool_attr[0], &bool_attr[0] },
2203
-  { "SIGN-OPT", &bool_attr[0], &bool_attr[0] },
2204
-  { "SIGNED", &bool_attr[0], &bool_attr[0] },
2205
-  { "NEGATIVE", &bool_attr[0], &bool_attr[0] },
2206
-  { "RELAX", &bool_attr[0], &bool_attr[0] },
2207
-  { "SEM-ONLY", &bool_attr[0], &bool_attr[0] },
2208
-  { 0, 0, 0 }
2209
-};
2210
-
2211
-const CGEN_ATTR_TABLE openrisc_cgen_insn_attr_table[] =
2212
-{
2213
-  { "MACH", & MACH_attr[0], & MACH_attr[0] },
2214
-  { "ALIAS", &bool_attr[0], &bool_attr[0] },
2215
-  { "VIRTUAL", &bool_attr[0], &bool_attr[0] },
2216
-  { "UNCOND-CTI", &bool_attr[0], &bool_attr[0] },
2217
-  { "COND-CTI", &bool_attr[0], &bool_attr[0] },
2218
-  { "SKIP-CTI", &bool_attr[0], &bool_attr[0] },
2219
-  { "DELAY-SLOT", &bool_attr[0], &bool_attr[0] },
2220
-  { "RELAXABLE", &bool_attr[0], &bool_attr[0] },
2221
-  { "RELAXED", &bool_attr[0], &bool_attr[0] },
2222
-  { "NO-DIS", &bool_attr[0], &bool_attr[0] },
2223
-  { "PBB", &bool_attr[0], &bool_attr[0] },
2224
-  { "NOT-IN-DELAY-SLOT", &bool_attr[0], &bool_attr[0] },
2225
-  { 0, 0, 0 }
2226
-};
2227
-
2228
-/* Instruction set variants.  */
2229
-
2230
-static const CGEN_ISA openrisc_cgen_isa_table[] = {
2231
-  { "or32", 32, 32, 32, 32 },
2232
-  { 0, 0, 0, 0, 0 }
2233
-};
2234
-
2235
-/* Machine variants.  */
2236
-
2237
-static const CGEN_MACH openrisc_cgen_mach_table[] = {
2238
-  { "openrisc", "openrisc", MACH_OPENRISC, 0 },
2239
-  { "or1300", "openrisc:1300", MACH_OR1300, 0 },
2240
-  { 0, 0, 0, 0 }
2241
-};
2242
-
2243
-static CGEN_KEYWORD_ENTRY openrisc_cgen_opval_h_gr_entries[] =
2244
-{
2245
-  { "r0", 0, {0, {0}}, 0, 0 },
2246
-  { "r1", 1, {0, {0}}, 0, 0 },
2247
-  { "r2", 2, {0, {0}}, 0, 0 },
2248
-  { "r3", 3, {0, {0}}, 0, 0 },
2249
-  { "r4", 4, {0, {0}}, 0, 0 },
2250
-  { "r5", 5, {0, {0}}, 0, 0 },
2251
-  { "r6", 6, {0, {0}}, 0, 0 },
2252
-  { "r7", 7, {0, {0}}, 0, 0 },
2253
-  { "r8", 8, {0, {0}}, 0, 0 },
2254
-  { "r9", 9, {0, {0}}, 0, 0 },
2255
-  { "r10", 10, {0, {0}}, 0, 0 },
2256
-  { "r11", 11, {0, {0}}, 0, 0 },
2257
-  { "r12", 12, {0, {0}}, 0, 0 },
2258
-  { "r13", 13, {0, {0}}, 0, 0 },
2259
-  { "r14", 14, {0, {0}}, 0, 0 },
2260
-  { "r15", 15, {0, {0}}, 0, 0 },
2261
-  { "r16", 16, {0, {0}}, 0, 0 },
2262
-  { "r17", 17, {0, {0}}, 0, 0 },
2263
-  { "r18", 18, {0, {0}}, 0, 0 },
2264
-  { "r19", 19, {0, {0}}, 0, 0 },
2265
-  { "r20", 20, {0, {0}}, 0, 0 },
2266
-  { "r21", 21, {0, {0}}, 0, 0 },
2267
-  { "r22", 22, {0, {0}}, 0, 0 },
2268
-  { "r23", 23, {0, {0}}, 0, 0 },
2269
-  { "r24", 24, {0, {0}}, 0, 0 },
2270
-  { "r25", 25, {0, {0}}, 0, 0 },
2271
-  { "r26", 26, {0, {0}}, 0, 0 },
2272
-  { "r27", 27, {0, {0}}, 0, 0 },
2273
-  { "r28", 28, {0, {0}}, 0, 0 },
2274
-  { "r29", 29, {0, {0}}, 0, 0 },
2275
-  { "r30", 30, {0, {0}}, 0, 0 },
2276
-  { "r31", 31, {0, {0}}, 0, 0 },
2277
-  { "lr", 11, {0, {0}}, 0, 0 },
2278
-  { "sp", 1, {0, {0}}, 0, 0 },
2279
-  { "fp", 2, {0, {0}}, 0, 0 }
2280
-};
2281
-
2282
-CGEN_KEYWORD openrisc_cgen_opval_h_gr =
2283
-{
2284
-  & openrisc_cgen_opval_h_gr_entries[0],
2285
-  35,
2286
-  0, 0, 0, 0, ""
2287
-};
2288
-
2289
-
2290
-/* The hardware table.  */
2291
-
2292
-#if defined (__STDC__) || defined (ALMOST_STDC) || defined (HAVE_STRINGIZE)
2293
-#define A(a) (1 << CGEN_HW_##a)
2294
-#else
2295
-#define A(a) (1 << CGEN_HW_/**/a)
2296
-#endif
2297
-
2298
-const CGEN_HW_ENTRY openrisc_cgen_hw_table[] =
2299
-{
2300
-  { "h-memory", HW_H_MEMORY, CGEN_ASM_NONE, 0, { 0, { (1<<MACH_BASE) } } },
2301
-  { "h-sint", HW_H_SINT, CGEN_ASM_NONE, 0, { 0, { (1<<MACH_BASE) } } },
2302
-  { "h-uint", HW_H_UINT, CGEN_ASM_NONE, 0, { 0, { (1<<MACH_BASE) } } },
2303
-  { "h-addr", HW_H_ADDR, CGEN_ASM_NONE, 0, { 0, { (1<<MACH_BASE) } } },
2304
-  { "h-iaddr", HW_H_IADDR, CGEN_ASM_NONE, 0, { 0, { (1<<MACH_BASE) } } },
2305
-  { "h-pc", HW_H_PC, CGEN_ASM_NONE, 0, { 0|A(PROFILE)|A(PC), { (1<<MACH_BASE) } } },
2306
-  { "h-gr", HW_H_GR, CGEN_ASM_KEYWORD, (PTR) & openrisc_cgen_opval_h_gr, { 0|A(PROFILE), { (1<<MACH_BASE) } } },
2307
-  { "h-sr", HW_H_SR, CGEN_ASM_NONE, 0, { 0, { (1<<MACH_BASE) } } },
2308
-  { "h-hi16", HW_H_HI16, CGEN_ASM_NONE, 0, { 0, { (1<<MACH_BASE) } } },
2309
-  { "h-lo16", HW_H_LO16, CGEN_ASM_NONE, 0, { 0, { (1<<MACH_BASE) } } },
2310
-  { "h-cbit", HW_H_CBIT, CGEN_ASM_NONE, 0, { 0, { (1<<MACH_BASE) } } },
2311
-  { "h-delay-insn", HW_H_DELAY_INSN, CGEN_ASM_NONE, 0, { 0, { (1<<MACH_BASE) } } },
2312
-  { 0, 0, CGEN_ASM_NONE, 0, {0, {0}} }
2313
-};
2314
-
2315
-#undef A
2316
-
2317
-
2318
-/* The instruction field table.  */
2319
-
2320
-#if defined (__STDC__) || defined (ALMOST_STDC) || defined (HAVE_STRINGIZE)
2321
-#define A(a) (1 << CGEN_IFLD_##a)
2322
-#else
2323
-#define A(a) (1 << CGEN_IFLD_/**/a)
2324
-#endif
2325
-
2326
-const CGEN_IFLD openrisc_cgen_ifld_table[] =
2327
-{
2328
-  { OPENRISC_F_NIL, "f-nil", 0, 0, 0, 0, { 0, { (1<<MACH_BASE) } }  },
2329
-  { OPENRISC_F_ANYOF, "f-anyof", 0, 0, 0, 0, { 0, { (1<<MACH_BASE) } }  },
2330
-  { OPENRISC_F_CLASS, "f-class", 0, 32, 31, 2, { 0, { (1<<MACH_BASE) } }  },
2331
-  { OPENRISC_F_SUB, "f-sub", 0, 32, 29, 4, { 0, { (1<<MACH_BASE) } }  },
2332
-  { OPENRISC_F_R1, "f-r1", 0, 32, 25, 5, { 0, { (1<<MACH_BASE) } }  },
2333
-  { OPENRISC_F_R2, "f-r2", 0, 32, 20, 5, { 0, { (1<<MACH_BASE) } }  },
2334
-  { OPENRISC_F_R3, "f-r3", 0, 32, 15, 5, { 0, { (1<<MACH_BASE) } }  },
2335
-  { OPENRISC_F_SIMM16, "f-simm16", 0, 32, 15, 16, { 0, { (1<<MACH_BASE) } }  },
2336
-  { OPENRISC_F_UIMM16, "f-uimm16", 0, 32, 15, 16, { 0, { (1<<MACH_BASE) } }  },
2337
-  { OPENRISC_F_UIMM5, "f-uimm5", 0, 32, 4, 5, { 0, { (1<<MACH_BASE) } }  },
2338
-  { OPENRISC_F_HI16, "f-hi16", 0, 32, 15, 16, { 0, { (1<<MACH_BASE) } }  },
2339
-  { OPENRISC_F_LO16, "f-lo16", 0, 32, 15, 16, { 0, { (1<<MACH_BASE) } }  },
2340
-  { OPENRISC_F_OP1, "f-op1", 0, 32, 31, 2, { 0, { (1<<MACH_BASE) } }  },
2341
-  { OPENRISC_F_OP2, "f-op2", 0, 32, 29, 4, { 0, { (1<<MACH_BASE) } }  },
2342
-  { OPENRISC_F_OP3, "f-op3", 0, 32, 25, 2, { 0, { (1<<MACH_BASE) } }  },
2343
-  { OPENRISC_F_OP4, "f-op4", 0, 32, 23, 3, { 0, { (1<<MACH_BASE) } }  },
2344
-  { OPENRISC_F_OP5, "f-op5", 0, 32, 25, 5, { 0, { (1<<MACH_BASE) } }  },
2345
-  { OPENRISC_F_OP6, "f-op6", 0, 32, 7, 3, { 0, { (1<<MACH_BASE) } }  },
2346
-  { OPENRISC_F_OP7, "f-op7", 0, 32, 3, 4, { 0, { (1<<MACH_BASE) } }  },
2347
-  { OPENRISC_F_I16_1, "f-i16-1", 0, 32, 10, 11, { 0, { (1<<MACH_BASE) } }  },
2348
-  { OPENRISC_F_I16_2, "f-i16-2", 0, 32, 25, 5, { 0, { (1<<MACH_BASE) } }  },
2349
-  { OPENRISC_F_DISP26, "f-disp26", 0, 32, 25, 26, { 0|A(PCREL_ADDR), { (1<<MACH_BASE) } }  },
2350
-  { OPENRISC_F_ABS26, "f-abs26", 0, 32, 25, 26, { 0|A(ABS_ADDR), { (1<<MACH_BASE) } }  },
2351
-  { OPENRISC_F_I16NC, "f-i16nc", 0, 0, 0, 0,{ 0|A(SIGN_OPT)|A(VIRTUAL), { (1<<MACH_BASE) } }  },
2352
-  { OPENRISC_F_F_15_8, "f-f-15-8", 0, 32, 15, 8, { 0|A(RESERVED), { (1<<MACH_BASE) } }  },
2353
-  { OPENRISC_F_F_10_3, "f-f-10-3", 0, 32, 10, 3, { 0|A(RESERVED), { (1<<MACH_BASE) } }  },
2354
-  { OPENRISC_F_F_4_1, "f-f-4-1", 0, 32, 4, 1, { 0|A(RESERVED), { (1<<MACH_BASE) } }  },
2355
-  { OPENRISC_F_F_7_3, "f-f-7-3", 0, 32, 7, 3, { 0|A(RESERVED), { (1<<MACH_BASE) } }  },
2356
-  { OPENRISC_F_F_10_7, "f-f-10-7", 0, 32, 10, 7, { 0|A(RESERVED), { (1<<MACH_BASE) } }  },
2357
-  { OPENRISC_F_F_10_11, "f-f-10-11", 0, 32, 10, 11, { 0|A(RESERVED), { (1<<MACH_BASE) } }  },
2358
-  { 0, 0, 0, 0, 0, 0, {0, {0}} }
2359
-};
2360
-
2361
-#undef A
2362
-
2363
-
2364
-
2365
-/* multi ifield declarations */
2366
-
2367
-const CGEN_MAYBE_MULTI_IFLD OPENRISC_F_I16NC_MULTI_IFIELD [];
2368
-
2369
-
2370
-/* multi ifield definitions */
2371
-
2372
-const CGEN_MAYBE_MULTI_IFLD OPENRISC_F_I16NC_MULTI_IFIELD [] =
2373
-{
2374
-    { 0, { (const PTR) &openrisc_cgen_ifld_table[OPENRISC_F_I16_1] } },
2375
-    { 0, { (const PTR) &openrisc_cgen_ifld_table[OPENRISC_F_I16_2] } },
2376
-    { 0, { (const PTR) 0 } }
2377
-};
2378
-
2379
-/* The operand table.  */
2380
-
2381
-#if defined (__STDC__) || defined (ALMOST_STDC) || defined (HAVE_STRINGIZE)
2382
-#define A(a) (1 << CGEN_OPERAND_##a)
2383
-#else
2384
-#define A(a) (1 << CGEN_OPERAND_/**/a)
2385
-#endif
2386
-#if defined (__STDC__) || defined (ALMOST_STDC) || defined (HAVE_STRINGIZE)
2387
-#define OPERAND(op) OPENRISC_OPERAND_##op
2388
-#else
2389
-#define OPERAND(op) OPENRISC_OPERAND_/**/op
2390
-#endif
2391
-
2392
-const CGEN_OPERAND openrisc_cgen_operand_table[] =
2393
-{
2394
-/* pc: program counter */
2395
-  { "pc", OPENRISC_OPERAND_PC, HW_H_PC, 0, 0,
2396
-    { 0, { (const PTR) &openrisc_cgen_ifld_table[OPENRISC_F_NIL] } },
2397
-    { 0|A(SEM_ONLY), { (1<<MACH_BASE) } }  },
2398
-/* sr: special register */
2399
-  { "sr", OPENRISC_OPERAND_SR, HW_H_SR, 0, 0,
2400
-    { 0, { (const PTR) 0 } },
2401
-    { 0|A(SEM_ONLY), { (1<<MACH_BASE) } }  },
2402
-/* cbit: condition bit */
2403
-  { "cbit", OPENRISC_OPERAND_CBIT, HW_H_CBIT, 0, 0,
2404
-    { 0, { (const PTR) 0 } },
2405
-    { 0|A(SEM_ONLY), { (1<<MACH_BASE) } }  },
2406
-/* simm-16: 16 bit signed immediate */
2407
-  { "simm-16", OPENRISC_OPERAND_SIMM_16, HW_H_SINT, 15, 16,
2408
-    { 0, { (const PTR) &openrisc_cgen_ifld_table[OPENRISC_F_SIMM16] } },
2409
-    { 0, { (1<<MACH_BASE) } }  },
2410
-/* uimm-16: 16 bit unsigned immediate */
2411
-  { "uimm-16", OPENRISC_OPERAND_UIMM_16, HW_H_UINT, 15, 16,
2412
-    { 0, { (const PTR) &openrisc_cgen_ifld_table[OPENRISC_F_UIMM16] } },
2413
-    { 0, { (1<<MACH_BASE) } }  },
2414
-/* disp-26: pc-rel 26 bit */
2415
-  { "disp-26", OPENRISC_OPERAND_DISP_26, HW_H_IADDR, 25, 26,
2416
-    { 0, { (const PTR) &openrisc_cgen_ifld_table[OPENRISC_F_DISP26] } },
2417
-    { 0|A(PCREL_ADDR), { (1<<MACH_BASE) } }  },
2418
-/* abs-26: abs 26 bit */
2419
-  { "abs-26", OPENRISC_OPERAND_ABS_26, HW_H_IADDR, 25, 26,
2420
-    { 0, { (const PTR) &openrisc_cgen_ifld_table[OPENRISC_F_ABS26] } },
2421
-    { 0|A(ABS_ADDR), { (1<<MACH_BASE) } }  },
2422
-/* uimm-5: imm5 */
2423
-  { "uimm-5", OPENRISC_OPERAND_UIMM_5, HW_H_UINT, 4, 5,
2424
-    { 0, { (const PTR) &openrisc_cgen_ifld_table[OPENRISC_F_UIMM5] } },
2425
-    { 0, { (1<<MACH_BASE) } }  },
2426
-/* rD: destination register */
2427
-  { "rD", OPENRISC_OPERAND_RD, HW_H_GR, 25, 5,
2428
-    { 0, { (const PTR) &openrisc_cgen_ifld_table[OPENRISC_F_R1] } },
2429
-    { 0, { (1<<MACH_BASE) } }  },
2430
-/* rA: source register A */
2431
-  { "rA", OPENRISC_OPERAND_RA, HW_H_GR, 20, 5,
2432
-    { 0, { (const PTR) &openrisc_cgen_ifld_table[OPENRISC_F_R2] } },
2433
-    { 0, { (1<<MACH_BASE) } }  },
2434
-/* rB: source register B */
2435
-  { "rB", OPENRISC_OPERAND_RB, HW_H_GR, 15, 5,
2436
-    { 0, { (const PTR) &openrisc_cgen_ifld_table[OPENRISC_F_R3] } },
2437
-    { 0, { (1<<MACH_BASE) } }  },
2438
-/* op-f-23: f-op23 */
2439
-  { "op-f-23", OPENRISC_OPERAND_OP_F_23, HW_H_UINT, 23, 3,
2440
-    { 0, { (const PTR) &openrisc_cgen_ifld_table[OPENRISC_F_OP4] } },
2441
-    { 0, { (1<<MACH_BASE) } }  },
2442
-/* op-f-3: f-op3 */
2443
-  { "op-f-3", OPENRISC_OPERAND_OP_F_3, HW_H_UINT, 25, 5,
2444
-    { 0, { (const PTR) &openrisc_cgen_ifld_table[OPENRISC_F_OP5] } },
2445
-    { 0, { (1<<MACH_BASE) } }  },
2446
-/* hi16: high 16 bit immediate, sign optional */
2447
-  { "hi16", OPENRISC_OPERAND_HI16, HW_H_HI16, 15, 16,
2448
-    { 0, { (const PTR) &openrisc_cgen_ifld_table[OPENRISC_F_SIMM16] } },
2449
-    { 0|A(SIGN_OPT), { (1<<MACH_BASE) } }  },
2450
-/* lo16: low 16 bit immediate, sign optional */
2451
-  { "lo16", OPENRISC_OPERAND_LO16, HW_H_LO16, 15, 16,
2452
-    { 0, { (const PTR) &openrisc_cgen_ifld_table[OPENRISC_F_LO16] } },
2453
-    { 0|A(SIGN_OPT), { (1<<MACH_BASE) } }  },
2454
-/* ui16nc: 16 bit immediate, sign optional */
2455
-  { "ui16nc", OPENRISC_OPERAND_UI16NC, HW_H_LO16, 10, 16,
2456
-    { 2, { (const PTR) &OPENRISC_F_I16NC_MULTI_IFIELD[0] } },
2457
-    { 0|A(SIGN_OPT)|A(VIRTUAL), { (1<<MACH_BASE) } }  },
2458
-/* sentinel */
2459
-  { 0, 0, 0, 0, 0,
2460
-    { 0, { (const PTR) 0 } },
2461
-    { 0, { 0 } } }
2462
-};
2463
-
2464
-#undef A
2465
-
2466
-
2467
-/* The instruction table.  */
2468
-
2469
-#define OP(field) CGEN_SYNTAX_MAKE_FIELD (OPERAND (field))
2470
-#if defined (__STDC__) || defined (ALMOST_STDC) || defined (HAVE_STRINGIZE)
2471
-#define A(a) (1 << CGEN_INSN_##a)
2472
-#else
2473
-#define A(a) (1 << CGEN_INSN_/**/a)
2474
-#endif
2475
-
2476
-static const CGEN_IBASE openrisc_cgen_insn_table[MAX_INSNS] =
2477
-{
2478
-  /* Special null first entry.
2479
-     A `num' value of zero is thus invalid.
2480
-     Also, the special `invalid' insn resides here.  */
2481
-  { 0, 0, 0, 0, {0, {0}} },
2482
-/* l.j ${abs-26} */
2483
-  {
2484
-    OPENRISC_INSN_L_J, "l-j", "l.j", 32,
2485
-    { 0|A(NOT_IN_DELAY_SLOT)|A(UNCOND_CTI)|A(DELAY_SLOT), { (1<<MACH_BASE) } }
2486
-  },
2487
-/* l.jal ${abs-26} */
2488
-  {
2489
-    OPENRISC_INSN_L_JAL, "l-jal", "l.jal", 32,
2490
-    { 0|A(NOT_IN_DELAY_SLOT)|A(UNCOND_CTI)|A(DELAY_SLOT), { (1<<MACH_BASE) } }
2491
-  },
2492
-/* l.jr $rA */
2493
-  {
2494
-    OPENRISC_INSN_L_JR, "l-jr", "l.jr", 32,
2495
-    { 0|A(NOT_IN_DELAY_SLOT)|A(UNCOND_CTI)|A(DELAY_SLOT), { (1<<MACH_BASE) } }
2496
-  },
2497
-/* l.jalr $rA */
2498
-  {
2499
-    OPENRISC_INSN_L_JALR, "l-jalr", "l.jalr", 32,
2500
-    { 0|A(NOT_IN_DELAY_SLOT)|A(UNCOND_CTI)|A(DELAY_SLOT), { (1<<MACH_BASE) } }
2501
-  },
2502
-/* l.bal ${disp-26} */
2503
-  {
2504
-    OPENRISC_INSN_L_BAL, "l-bal", "l.bal", 32,
2505
-    { 0|A(NOT_IN_DELAY_SLOT)|A(UNCOND_CTI)|A(DELAY_SLOT), { (1<<MACH_BASE) } }
2506
-  },
2507
-/* l.bnf ${disp-26} */
2508
-  {
2509
-    OPENRISC_INSN_L_BNF, "l-bnf", "l.bnf", 32,
2510
-    { 0|A(NOT_IN_DELAY_SLOT)|A(COND_CTI)|A(DELAY_SLOT), { (1<<MACH_BASE) } }
2511
-  },
2512
-/* l.bf ${disp-26} */
2513
-  {
2514
-    OPENRISC_INSN_L_BF, "l-bf", "l.bf", 32,
2515
-    { 0|A(NOT_IN_DELAY_SLOT)|A(COND_CTI)|A(DELAY_SLOT), { (1<<MACH_BASE) } }
2516
-  },
2517
-/* l.brk ${uimm-16} */
2518
-  {
2519
-    OPENRISC_INSN_L_BRK, "l-brk", "l.brk", 32,
2520
-    { 0|A(NOT_IN_DELAY_SLOT), { (1<<MACH_BASE) } }
2521
-  },
2522
-/* l.rfe $rA */
2523
-  {
2524
-    OPENRISC_INSN_L_RFE, "l-rfe", "l.rfe", 32,
2525
-    { 0|A(NOT_IN_DELAY_SLOT)|A(UNCOND_CTI)|A(DELAY_SLOT), { (1<<MACH_BASE) } }
2526
-  },
2527
-/* l.sys ${uimm-16} */
2528
-  {
2529
-    OPENRISC_INSN_L_SYS, "l-sys", "l.sys", 32,
2530
-    { 0|A(NOT_IN_DELAY_SLOT)|A(UNCOND_CTI)|A(DELAY_SLOT), { (1<<MACH_BASE) } }
2531
-  },
2532
-/* l.nop */
2533
-  {
2534
-    OPENRISC_INSN_L_NOP, "l-nop", "l.nop", 32,
2535
-    { 0, { (1<<MACH_BASE) } }
2536
-  },
2537
-/* l.movhi $rD,$hi16 */
2538
-  {
2539
-    OPENRISC_INSN_L_MOVHI, "l-movhi", "l.movhi", 32,
2540
-    { 0|A(DELAY_SLOT), { (1<<MACH_BASE) } }
2541
-  },
2542
-/* l.mfsr $rD,$rA */
2543
-  {
2544
-    OPENRISC_INSN_L_MFSR, "l-mfsr", "l.mfsr", 32,
2545
-    { 0|A(DELAY_SLOT), { (1<<MACH_BASE) } }
2546
-  },
2547
-/* l.mtsr $rA,$rB */
2548
-  {
2549
-    OPENRISC_INSN_L_MTSR, "l-mtsr", "l.mtsr", 32,
2550
-    { 0|A(DELAY_SLOT), { (1<<MACH_BASE) } }
2551
-  },
2552
-/* l.lw $rD,${simm-16}($rA) */
2553
-  {
2554
-    OPENRISC_INSN_L_LW, "l-lw", "l.lw", 32,
2555
-    { 0|A(DELAY_SLOT), { (1<<MACH_BASE) } }
2556
-  },
2557
-/* l.lbz $rD,${simm-16}($rA) */
2558
-  {
2559
-    OPENRISC_INSN_L_LBZ, "l-lbz", "l.lbz", 32,
2560
-    { 0|A(DELAY_SLOT), { (1<<MACH_BASE) } }
2561
-  },
2562
-/* l.lbs $rD,${simm-16}($rA) */
2563
-  {
2564
-    OPENRISC_INSN_L_LBS, "l-lbs", "l.lbs", 32,
2565
-    { 0|A(DELAY_SLOT), { (1<<MACH_BASE) } }
2566
-  },
2567
-/* l.lhz $rD,${simm-16}($rA) */
2568
-  {
2569
-    OPENRISC_INSN_L_LHZ, "l-lhz", "l.lhz", 32,
2570
-    { 0|A(DELAY_SLOT), { (1<<MACH_BASE) } }
2571
-  },
2572
-/* l.lhs $rD,${simm-16}($rA) */
2573
-  {
2574
-    OPENRISC_INSN_L_LHS, "l-lhs", "l.lhs", 32,
2575
-    { 0|A(DELAY_SLOT), { (1<<MACH_BASE) } }
2576
-  },
2577
-/* l.sw ${ui16nc}($rA),$rB */
2578
-  {
2579
-    OPENRISC_INSN_L_SW, "l-sw", "l.sw", 32,
2580
-    { 0|A(DELAY_SLOT), { (1<<MACH_BASE) } }
2581
-  },
2582
-/* l.sb ${ui16nc}($rA),$rB */
2583
-  {
2584
-    OPENRISC_INSN_L_SB, "l-sb", "l.sb", 32,
2585
-    { 0|A(DELAY_SLOT), { (1<<MACH_BASE) } }
2586
-  },
2587
-/* l.sh ${ui16nc}($rA),$rB */
2588
-  {
2589
-    OPENRISC_INSN_L_SH, "l-sh", "l.sh", 32,
2590
-    { 0|A(DELAY_SLOT), { (1<<MACH_BASE) } }
2591
-  },
2592
-/* l.sll $rD,$rA,$rB */
2593
-  {
2594
-    OPENRISC_INSN_L_SLL, "l-sll", "l.sll", 32,
2595
-    { 0, { (1<<MACH_BASE) } }
2596
-  },
2597
-/* l.slli $rD,$rA,${uimm-5} */
2598
-  {
2599
-    OPENRISC_INSN_L_SLLI, "l-slli", "l.slli", 32,
2600
-    { 0, { (1<<MACH_BASE) } }
2601
-  },
2602
-/* l.srl $rD,$rA,$rB */
2603
-  {
2604
-    OPENRISC_INSN_L_SRL, "l-srl", "l.srl", 32,
2605
-    { 0, { (1<<MACH_BASE) } }
2606
-  },
2607
-/* l.srli $rD,$rA,${uimm-5} */
2608
-  {
2609
-    OPENRISC_INSN_L_SRLI, "l-srli", "l.srli", 32,
2610
-    { 0, { (1<<MACH_BASE) } }
2611
-  },
2612
-/* l.sra $rD,$rA,$rB */
2613
-  {
2614
-    OPENRISC_INSN_L_SRA, "l-sra", "l.sra", 32,
2615
-    { 0, { (1<<MACH_BASE) } }
2616
-  },
2617
-/* l.srai $rD,$rA,${uimm-5} */
2618
-  {
2619
-    OPENRISC_INSN_L_SRAI, "l-srai", "l.srai", 32,
2620
-    { 0, { (1<<MACH_BASE) } }
2621
-  },
2622
-/* l.ror $rD,$rA,$rB */
2623
-  {
2624
-    OPENRISC_INSN_L_ROR, "l-ror", "l.ror", 32,
2625
-    { 0, { (1<<MACH_BASE) } }
2626
-  },
2627
-/* l.rori $rD,$rA,${uimm-5} */
2628
-  {
2629
-    OPENRISC_INSN_L_RORI, "l-rori", "l.rori", 32,
2630
-    { 0, { (1<<MACH_BASE) } }
2631
-  },
2632
-/* l.add $rD,$rA,$rB */
2633
-  {
2634
-    OPENRISC_INSN_L_ADD, "l-add", "l.add", 32,
2635
-    { 0, { (1<<MACH_BASE) } }
2636
-  },
2637
-/* l.addi $rD,$rA,$lo16 */
2638
-  {
2639
-    OPENRISC_INSN_L_ADDI, "l-addi", "l.addi", 32,
2640
-    { 0, { (1<<MACH_BASE) } }
2641
-  },
2642
-/* l.sub $rD,$rA,$rB */
2643
-  {
2644
-    OPENRISC_INSN_L_SUB, "l-sub", "l.sub", 32,
2645
-    { 0, { (1<<MACH_BASE) } }
2646
-  },
2647
-/* l.subi $rD,$rA,$lo16 */
2648
-  {
2649
-    OPENRISC_INSN_L_SUBI, "l-subi", "l.subi", 32,
2650
-    { 0, { (1<<MACH_BASE) } }
2651
-  },
2652
-/* l.and $rD,$rA,$rB */
2653
-  {
2654
-    OPENRISC_INSN_L_AND, "l-and", "l.and", 32,
2655
-    { 0, { (1<<MACH_BASE) } }
2656
-  },
2657
-/* l.andi $rD,$rA,$lo16 */
2658
-  {
2659
-    OPENRISC_INSN_L_ANDI, "l-andi", "l.andi", 32,
2660
-    { 0, { (1<<MACH_BASE) } }
2661
-  },
2662
-/* l.or $rD,$rA,$rB */
2663
-  {
2664
-    OPENRISC_INSN_L_OR, "l-or", "l.or", 32,
2665
-    { 0, { (1<<MACH_BASE) } }
2666
-  },
2667
-/* l.ori $rD,$rA,$lo16 */
2668
-  {
2669
-    OPENRISC_INSN_L_ORI, "l-ori", "l.ori", 32,
2670
-    { 0, { (1<<MACH_BASE) } }
2671
-  },
2672
-/* l.xor $rD,$rA,$rB */
2673
-  {
2674
-    OPENRISC_INSN_L_XOR, "l-xor", "l.xor", 32,
2675
-    { 0, { (1<<MACH_BASE) } }
2676
-  },
2677
-/* l.xori $rD,$rA,$lo16 */
2678
-  {
2679
-    OPENRISC_INSN_L_XORI, "l-xori", "l.xori", 32,
2680
-    { 0, { (1<<MACH_BASE) } }
2681
-  },
2682
-/* l.mul $rD,$rA,$rB */
2683
-  {
2684
-    OPENRISC_INSN_L_MUL, "l-mul", "l.mul", 32,
2685
-    { 0, { (1<<MACH_BASE) } }
2686
-  },
2687
-/* l.muli $rD,$rA,$lo16 */
2688
-  {
2689
-    OPENRISC_INSN_L_MULI, "l-muli", "l.muli", 32,
2690
-    { 0, { (1<<MACH_BASE) } }
2691
-  },
2692
-/* l.div $rD,$rA,$rB */
2693
-  {
2694
-    OPENRISC_INSN_L_DIV, "l-div", "l.div", 32,
2695
-    { 0|A(DELAY_SLOT), { (1<<MACH_BASE) } }
2696
-  },
2697
-/* l.divu $rD,$rA,$rB */
2698
-  {
2699
-    OPENRISC_INSN_L_DIVU, "l-divu", "l.divu", 32,
2700
-    { 0|A(DELAY_SLOT), { (1<<MACH_BASE) } }
2701
-  },
2702
-/* l.sfgts $rA,$rB */
2703
-  {
2704
-    OPENRISC_INSN_L_SFGTS, "l-sfgts", "l.sfgts", 32,
2705
-    { 0|A(DELAY_SLOT), { (1<<MACH_BASE) } }
2706
-  },
2707
-/* l.sfgtu $rA,$rB */
2708
-  {
2709
-    OPENRISC_INSN_L_SFGTU, "l-sfgtu", "l.sfgtu", 32,
2710
-    { 0|A(DELAY_SLOT), { (1<<MACH_BASE) } }
2711
-  },
2712
-/* l.sfges $rA,$rB */
2713
-  {
2714
-    OPENRISC_INSN_L_SFGES, "l-sfges", "l.sfges", 32,
2715
-    { 0|A(DELAY_SLOT), { (1<<MACH_BASE) } }
2716
-  },
2717
-/* l.sfgeu $rA,$rB */
2718
-  {
2719
-    OPENRISC_INSN_L_SFGEU, "l-sfgeu", "l.sfgeu", 32,
2720
-    { 0|A(DELAY_SLOT), { (1<<MACH_BASE) } }
2721
-  },
2722
-/* l.sflts $rA,$rB */
2723
-  {
2724
-    OPENRISC_INSN_L_SFLTS, "l-sflts", "l.sflts", 32,
2725
-    { 0|A(DELAY_SLOT), { (1<<MACH_BASE) } }
2726
-  },
2727
-/* l.sfltu $rA,$rB */
2728
-  {
2729
-    OPENRISC_INSN_L_SFLTU, "l-sfltu", "l.sfltu", 32,
2730
-    { 0|A(DELAY_SLOT), { (1<<MACH_BASE) } }
2731
-  },
2732
-/* l.sfles $rA,$rB */
2733
-  {
2734
-    OPENRISC_INSN_L_SFLES, "l-sfles", "l.sfles", 32,
2735
-    { 0|A(DELAY_SLOT), { (1<<MACH_BASE) } }
2736
-  },
2737
-/* l.sfleu $rA,$rB */
2738
-  {
2739
-    OPENRISC_INSN_L_SFLEU, "l-sfleu", "l.sfleu", 32,
2740
-    { 0|A(DELAY_SLOT), { (1<<MACH_BASE) } }
2741
-  },
2742
-/* l.sfgtsi $rA,${simm-16} */
2743
-  {
2744
-    OPENRISC_INSN_L_SFGTSI, "l-sfgtsi", "l.sfgtsi", 32,
2745
-    { 0|A(DELAY_SLOT), { (1<<MACH_BASE) } }
2746
-  },
2747
-/* l.sfgtui $rA,${uimm-16} */
2748
-  {
2749
-    OPENRISC_INSN_L_SFGTUI, "l-sfgtui", "l.sfgtui", 32,
2750
-    { 0|A(DELAY_SLOT), { (1<<MACH_BASE) } }
2751
-  },
2752
-/* l.sfgesi $rA,${simm-16} */
2753
-  {
2754
-    OPENRISC_INSN_L_SFGESI, "l-sfgesi", "l.sfgesi", 32,
2755
-    { 0|A(DELAY_SLOT), { (1<<MACH_BASE) } }
2756
-  },
2757
-/* l.sfgeui $rA,${uimm-16} */
2758
-  {
2759
-    OPENRISC_INSN_L_SFGEUI, "l-sfgeui", "l.sfgeui", 32,
2760
-    { 0|A(DELAY_SLOT), { (1<<MACH_BASE) } }
2761
-  },
2762
-/* l.sfltsi $rA,${simm-16} */
2763
-  {
2764
-    OPENRISC_INSN_L_SFLTSI, "l-sfltsi", "l.sfltsi", 32,
2765
-    { 0|A(DELAY_SLOT), { (1<<MACH_BASE) } }
2766
-  },
2767
-/* l.sfltui $rA,${uimm-16} */
2768
-  {
2769
-    OPENRISC_INSN_L_SFLTUI, "l-sfltui", "l.sfltui", 32,
2770
-    { 0|A(DELAY_SLOT), { (1<<MACH_BASE) } }
2771
-  },
2772
-/* l.sflesi $rA,${simm-16} */
2773
-  {
2774
-    OPENRISC_INSN_L_SFLESI, "l-sflesi", "l.sflesi", 32,
2775
-    { 0|A(DELAY_SLOT), { (1<<MACH_BASE) } }
2776
-  },
2777
-/* l.sfleui $rA,${uimm-16} */
2778
-  {
2779
-    OPENRISC_INSN_L_SFLEUI, "l-sfleui", "l.sfleui", 32,
2780
-    { 0|A(DELAY_SLOT), { (1<<MACH_BASE) } }
2781
-  },
2782
-/* l.sfeq $rA,$rB */
2783
-  {
2784
-    OPENRISC_INSN_L_SFEQ, "l-sfeq", "l.sfeq", 32,
2785
-    { 0|A(DELAY_SLOT), { (1<<MACH_BASE) } }
2786
-  },
2787
-/* l.sfeqi $rA,${simm-16} */
2788
-  {
2789
-    OPENRISC_INSN_L_SFEQI, "l-sfeqi", "l.sfeqi", 32,
2790
-    { 0|A(DELAY_SLOT), { (1<<MACH_BASE) } }
2791
-  },
2792
-/* l.sfne $rA,$rB */
2793
-  {
2794
-    OPENRISC_INSN_L_SFNE, "l-sfne", "l.sfne", 32,
2795
-    { 0|A(DELAY_SLOT), { (1<<MACH_BASE) } }
2796
-  },
2797
-/* l.sfnei $rA,${simm-16} */
2798
-  {
2799
-    OPENRISC_INSN_L_SFNEI, "l-sfnei", "l.sfnei", 32,
2800
-    { 0|A(DELAY_SLOT), { (1<<MACH_BASE) } }
2801
-  },
2802
-};
2803
-
2804
-#undef OP
2805
-#undef A
2806
-
2807
-/* Initialize anything needed to be done once, before any cpu_open call.  */
2808
-static void init_tables PARAMS ((void));
2809
-
2810
-static void
2811
-init_tables ()
2812
-{
2813
-}
2814
-
2815
-static const CGEN_MACH * lookup_mach_via_bfd_name
2816
-  PARAMS ((const CGEN_MACH *, const char *));
2817
-static void build_hw_table  PARAMS ((CGEN_CPU_TABLE *));
2818
-static void build_ifield_table  PARAMS ((CGEN_CPU_TABLE *));
2819
-static void build_operand_table PARAMS ((CGEN_CPU_TABLE *));
2820
-static void build_insn_table    PARAMS ((CGEN_CPU_TABLE *));
2821
-static void openrisc_cgen_rebuild_tables PARAMS ((CGEN_CPU_TABLE *));
2822
-
2823
-/* Subroutine of openrisc_cgen_cpu_open to look up a mach via its bfd name.  */
2824
-
2825
-static const CGEN_MACH *
2826
-lookup_mach_via_bfd_name (table, name)
2827
-     const CGEN_MACH *table;
2828
-     const char *name;
2829
-{
2830
-  while (table->name)
2831
-    {
2832
-      if (strcmp (name, table->bfd_name) == 0)
2833
-       return table;
2834
-      ++table;
2835
-    }
2836
-  abort ();
2837
-}
2838
-
2839
-/* Subroutine of openrisc_cgen_cpu_open to build the hardware table.  */
2840
-
2841
-static void
2842
-build_hw_table (cd)
2843
-     CGEN_CPU_TABLE *cd;
2844
-{
2845
-  int i;
2846
-  int machs = cd->machs;
2847
-  const CGEN_HW_ENTRY *init = & openrisc_cgen_hw_table[0];
2848
-  /* MAX_HW is only an upper bound on the number of selected entries.
2849
-     However each entry is indexed by it's enum so there can be holes in
2850
-     the table.  */
2851
-  const CGEN_HW_ENTRY **selected =
2852
-    (const CGEN_HW_ENTRY **) xmalloc (MAX_HW * sizeof (CGEN_HW_ENTRY *));
2853
-
2854
-  cd->hw_table.init_entries = init;
2855
-  cd->hw_table.entry_size = sizeof (CGEN_HW_ENTRY);
2856
-  memset (selected, 0, MAX_HW * sizeof (CGEN_HW_ENTRY *));
2857
-  /* ??? For now we just use machs to determine which ones we want.  */
2858
-  for (i = 0; init[i].name != NULL; ++i)
2859
-    if (CGEN_HW_ATTR_VALUE (&init[i], CGEN_HW_MACH)
2860
-       & machs)
2861
-      selected[init[i].type] = &init[i];
2862
-  cd->hw_table.entries = selected;
2863
-  cd->hw_table.num_entries = MAX_HW;
2864
-}
2865
-
2866
-/* Subroutine of openrisc_cgen_cpu_open to build the hardware table.  */
2867
-
2868
-static void
2869
-build_ifield_table (cd)
2870
-     CGEN_CPU_TABLE *cd;
2871
-{
2872
-  cd->ifld_table = & openrisc_cgen_ifld_table[0];
2873
-}
2874
-
2875
-/* Subroutine of openrisc_cgen_cpu_open to build the hardware table.  */
2876
-
2877
-static void
2878
-build_operand_table (cd)
2879
-     CGEN_CPU_TABLE *cd;
2880
-{
2881
-  int i;
2882
-  int machs = cd->machs;
2883
-  const CGEN_OPERAND *init = & openrisc_cgen_operand_table[0];
2884
-  /* MAX_OPERANDS is only an upper bound on the number of selected entries.
2885
-     However each entry is indexed by it's enum so there can be holes in
2886
-     the table.  */
2887
-  const CGEN_OPERAND **selected =
2888
-    (const CGEN_OPERAND **) xmalloc (MAX_OPERANDS * sizeof (CGEN_OPERAND *));
2889
-
2890
-  cd->operand_table.init_entries = init;
2891
-  cd->operand_table.entry_size = sizeof (CGEN_OPERAND);
2892
-  memset (selected, 0, MAX_OPERANDS * sizeof (CGEN_OPERAND *));
2893
-  /* ??? For now we just use mach to determine which ones we want.  */
2894
-  for (i = 0; init[i].name != NULL; ++i)
2895
-    if (CGEN_OPERAND_ATTR_VALUE (&init[i], CGEN_OPERAND_MACH)
2896
-       & machs)
2897
-      selected[init[i].type] = &init[i];
2898
-  cd->operand_table.entries = selected;
2899
-  cd->operand_table.num_entries = MAX_OPERANDS;
2900
-}
2901
-
2902
-/* Subroutine of openrisc_cgen_cpu_open to build the hardware table.
2903
-   ??? This could leave out insns not supported by the specified mach/isa,
2904
-   but that would cause errors like "foo only supported by bar" to become
2905
-   "unknown insn", so for now we include all insns and require the app to
2906
-   do the checking later.
2907
-   ??? On the other hand, parsing of such insns may require their hardware or
2908
-   operand elements to be in the table [which they mightn't be].  */
2909
-
2910
-static void
2911
-build_insn_table (cd)
2912
-     CGEN_CPU_TABLE *cd;
2913
-{
2914
-  int i;
2915
-  const CGEN_IBASE *ib = & openrisc_cgen_insn_table[0];
2916
-  CGEN_INSN *insns = (CGEN_INSN *) xmalloc (MAX_INSNS * sizeof (CGEN_INSN));
2917
-
2918
-  memset (insns, 0, MAX_INSNS * sizeof (CGEN_INSN));
2919
-  for (i = 0; i < MAX_INSNS; ++i)
2920
-    insns[i].base = &ib[i];
2921
-  cd->insn_table.init_entries = insns;
2922
-  cd->insn_table.entry_size = sizeof (CGEN_IBASE);
2923
-  cd->insn_table.num_init_entries = MAX_INSNS;
2924
-}
2925
-
2926
-/* Subroutine of openrisc_cgen_cpu_open to rebuild the tables.  */
2927
-
2928
-static void
2929
-openrisc_cgen_rebuild_tables (cd)
2930
-     CGEN_CPU_TABLE *cd;
2931
-{
2932
-  int i;
2933
-  unsigned int isas = cd->isas;
2934
-  unsigned int machs = cd->machs;
2935
-
2936
-  cd->int_insn_p = CGEN_INT_INSN_P;
2937
-
2938
-  /* Data derived from the isa spec.  */
2939
-#define UNSET (CGEN_SIZE_UNKNOWN + 1)
2940
-  cd->default_insn_bitsize = UNSET;
2941
-  cd->base_insn_bitsize = UNSET;
2942
-  cd->min_insn_bitsize = 65535; /* some ridiculously big number */
2943
-  cd->max_insn_bitsize = 0;
2944
-  for (i = 0; i < MAX_ISAS; ++i)
2945
-    if (((1 << i) & isas) != 0)
2946
-      {
2947
-       const CGEN_ISA *isa = & openrisc_cgen_isa_table[i];
2948
-
2949
-       /* Default insn sizes of all selected isas must be
2950
-          equal or we set the result to 0, meaning "unknown".  */
2951
-       if (cd->default_insn_bitsize == UNSET)
2952
-         cd->default_insn_bitsize = isa->default_insn_bitsize;
2953
-       else if (isa->default_insn_bitsize == cd->default_insn_bitsize)
2954
-         ; /* this is ok */
2955
-       else
2956
-         cd->default_insn_bitsize = CGEN_SIZE_UNKNOWN;
2957
-
2958
-       /* Base insn sizes of all selected isas must be equal
2959
-          or we set the result to 0, meaning "unknown".  */
2960
-       if (cd->base_insn_bitsize == UNSET)
2961
-         cd->base_insn_bitsize = isa->base_insn_bitsize;
2962
-       else if (isa->base_insn_bitsize == cd->base_insn_bitsize)
2963
-         ; /* this is ok */
2964
-       else
2965
-         cd->base_insn_bitsize = CGEN_SIZE_UNKNOWN;
2966
-
2967
-       /* Set min,max insn sizes.  */
2968
-       if (isa->min_insn_bitsize < cd->min_insn_bitsize)
2969
-         cd->min_insn_bitsize = isa->min_insn_bitsize;
2970
-       if (isa->max_insn_bitsize > cd->max_insn_bitsize)
2971
-         cd->max_insn_bitsize = isa->max_insn_bitsize;
2972
-      }
2973
-
2974
-  /* Data derived from the mach spec.  */
2975
-  for (i = 0; i < MAX_MACHS; ++i)
2976
-    if (((1 << i) & machs) != 0)
2977
-      {
2978
-       const CGEN_MACH *mach = & openrisc_cgen_mach_table[i];
2979
-
2980
-       if (mach->insn_chunk_bitsize != 0)
2981
-       {
2982
-         if (cd->insn_chunk_bitsize != 0 && cd->insn_chunk_bitsize != mach->insn_chunk_bitsize)
2983
-           {
2984
-             fprintf (stderr, "openrisc_cgen_rebuild_tables: conflicting insn-chunk-bitsize values: `%d' vs. `%d'\n",
2985
-                      cd->insn_chunk_bitsize, mach->insn_chunk_bitsize);
2986
-             abort ();
2987
-           }
2988
-
2989
-         cd->insn_chunk_bitsize = mach->insn_chunk_bitsize;
2990
-       }
2991
-      }
2992
-
2993
-  /* Determine which hw elements are used by MACH.  */
2994
-  build_hw_table (cd);
2995
-
2996
-  /* Build the ifield table.  */
2997
-  build_ifield_table (cd);
2998
-
2999
-  /* Determine which operands are used by MACH/ISA.  */
3000
-  build_operand_table (cd);
3001
-
3002
-  /* Build the instruction table.  */
3003
-  build_insn_table (cd);
3004
-}
3005
-
3006
-/* Initialize a cpu table and return a descriptor.
3007
-   It's much like opening a file, and must be the first function called.
3008
-   The arguments are a set of (type/value) pairs, terminated with
3009
-   CGEN_CPU_OPEN_END.
3010
-
3011
-   Currently supported values:
3012
-   CGEN_CPU_OPEN_ISAS:    bitmap of values in enum isa_attr
3013
-   CGEN_CPU_OPEN_MACHS:   bitmap of values in enum mach_attr
3014
-   CGEN_CPU_OPEN_BFDMACH: specify 1 mach using bfd name
3015
-   CGEN_CPU_OPEN_ENDIAN:  specify endian choice
3016
-   CGEN_CPU_OPEN_END:     terminates arguments
3017
-
3018
-   ??? Simultaneous multiple isas might not make sense, but it's not (yet)
3019
-   precluded.
3020
-
3021
-   ??? We only support ISO C stdargs here, not K&R.
3022
-   Laziness, plus experiment to see if anything requires K&R - eventually
3023
-   K&R will no longer be supported - e.g. GDB is currently trying this.  */
3024
-
3025
-CGEN_CPU_DESC
3026
-openrisc_cgen_cpu_open (enum cgen_cpu_open_arg arg_type, ...)
3027
-{
3028
-  CGEN_CPU_TABLE *cd = (CGEN_CPU_TABLE *) xmalloc (sizeof (CGEN_CPU_TABLE));
3029
-  static int init_p;
3030
-  unsigned int isas = 0;  /* 0 = "unspecified" */
3031
-  unsigned int machs = 0; /* 0 = "unspecified" */
3032
-  enum cgen_endian endian = CGEN_ENDIAN_UNKNOWN;
3033
-  va_list ap;
3034
-
3035
-  if (! init_p)
3036
-    {
3037
-      init_tables ();
3038
-      init_p = 1;
3039
-    }
3040
-
3041
-  memset (cd, 0, sizeof (*cd));
3042
-
3043
-  va_start (ap, arg_type);
3044
-  while (arg_type != CGEN_CPU_OPEN_END)
3045
-    {
3046
-      switch (arg_type)
3047
-       {
3048
-       case CGEN_CPU_OPEN_ISAS :
3049
-         isas = va_arg (ap, unsigned int);
3050
-         break;
3051
-       case CGEN_CPU_OPEN_MACHS :
3052
-         machs = va_arg (ap, unsigned int);
3053
-         break;
3054
-       case CGEN_CPU_OPEN_BFDMACH :
3055
-         {
3056
-           const char *name = va_arg (ap, const char *);
3057
-           const CGEN_MACH *mach =
3058
-             lookup_mach_via_bfd_name (openrisc_cgen_mach_table, name);
3059
-
3060
-           machs |= 1 << mach->num;
3061
-           break;
3062
-         }
3063
-       case CGEN_CPU_OPEN_ENDIAN :
3064
-         endian = va_arg (ap, enum cgen_endian);
3065
-         break;
3066
-       default :
3067
-         fprintf (stderr, "openrisc_cgen_cpu_open: unsupported argument `%d'\n",
3068
-                  arg_type);
3069
-         abort (); /* ??? return NULL? */
3070
-       }
3071
-      arg_type = va_arg (ap, enum cgen_cpu_open_arg);
3072
-    }
3073
-  va_end (ap);
3074
-
3075
-  /* mach unspecified means "all" */
3076
-  if (machs == 0)
3077
-    machs = (1 << MAX_MACHS) - 1;
3078
-  /* base mach is always selected */
3079
-  machs |= 1;
3080
-  /* isa unspecified means "all" */
3081
-  if (isas == 0)
3082
-    isas = (1 << MAX_ISAS) - 1;
3083
-  if (endian == CGEN_ENDIAN_UNKNOWN)
3084
-    {
3085
-      /* ??? If target has only one, could have a default.  */
3086
-      fprintf (stderr, "openrisc_cgen_cpu_open: no endianness specified\n");
3087
-      abort ();
3088
-    }
3089
-
3090
-  cd->isas = isas;
3091
-  cd->machs = machs;
3092
-  cd->endian = endian;
3093
-  /* FIXME: for the sparc case we can determine insn-endianness statically.
3094
-     The worry here is where both data and insn endian can be independently
3095
-     chosen, in which case this function will need another argument.
3096
-     Actually, will want to allow for more arguments in the future anyway.  */
3097
-  cd->insn_endian = endian;
3098
-
3099
-  /* Table (re)builder.  */
3100
-  cd->rebuild_tables = openrisc_cgen_rebuild_tables;
3101
-  openrisc_cgen_rebuild_tables (cd);
3102
-
3103
-  /* Default to not allowing signed overflow.  */
3104
-  cd->signed_overflow_ok_p = 0;
3105
-
3106
-  return (CGEN_CPU_DESC) cd;
3107
-}
3108
-
3109
-/* Cover fn to openrisc_cgen_cpu_open to handle the simple case of 1 isa, 1 mach.
3110
-   MACH_NAME is the bfd name of the mach.  */
3111
-
3112
-CGEN_CPU_DESC
3113
-openrisc_cgen_cpu_open_1 (mach_name, endian)
3114
-     const char *mach_name;
3115
-     enum cgen_endian endian;
3116
-{
3117
-  return openrisc_cgen_cpu_open (CGEN_CPU_OPEN_BFDMACH, mach_name,
3118
-                              CGEN_CPU_OPEN_ENDIAN, endian,
3119
-                              CGEN_CPU_OPEN_END);
3120
-}
3121
-
3122
-/* Close a cpu table.
3123
-   ??? This can live in a machine independent file, but there's currently
3124
-   no place to put this file (there's no libcgen).  libopcodes is the wrong
3125
-   place as some simulator ports use this but they don't use libopcodes.  */
3126
-
3127
-void
3128
-openrisc_cgen_cpu_close (cd)
3129
-     CGEN_CPU_DESC cd;
3130
-{
3131
-  unsigned int i;
3132
-  const CGEN_INSN *insns;
3133
-
3134
-  if (cd->macro_insn_table.init_entries)
3135
-    {
3136
-      insns = cd->macro_insn_table.init_entries;
3137
-      for (i = 0; i < cd->macro_insn_table.num_init_entries; ++i, ++insns)
3138
-       {
3139
-         if (CGEN_INSN_RX ((insns)))
3140
-           regfree (CGEN_INSN_RX (insns));
3141
-       }
3142
-    }
3143
-
3144
-  if (cd->insn_table.init_entries)
3145
-    {
3146
-      insns = cd->insn_table.init_entries;
3147
-      for (i = 0; i < cd->insn_table.num_init_entries; ++i, ++insns)
3148
-       {
3149
-         if (CGEN_INSN_RX (insns))
3150
-           regfree (CGEN_INSN_RX (insns));
3151
-       }
3152
-    }
3153
-
3154
-
3155
-
3156
-  if (cd->macro_insn_table.init_entries)
3157
-    free ((CGEN_INSN *) cd->macro_insn_table.init_entries);
3158
-
3159
-  if (cd->insn_table.init_entries)
3160
-    free ((CGEN_INSN *) cd->insn_table.init_entries);
3161
-
3162
-  if (cd->hw_table.entries)
3163
-    free ((CGEN_HW_ENTRY *) cd->hw_table.entries);
3164
-
3165
-  if (cd->operand_table.entries)
3166
-    free ((CGEN_HW_ENTRY *) cd->operand_table.entries);
3167
-
3168
-  free (cd);
3169
-}
3170
-
3171
diff --unified -N -r ../binutils-2.16.1/opcodes/openrisc-desc.h binutils-2.16.1/opcodes/openrisc-desc.h
3172
--- ../binutils-2.16.1/opcodes/openrisc-desc.h  2005-02-22 01:33:20.000000000 +0100
3173
+++ binutils-2.16.1/opcodes/openrisc-desc.h     1970-01-01 01:00:00.000000000 +0100
3174
@@ -1,251 +0,0 @@
3175
-/* CPU data header for openrisc.
3176
-
3177
-THIS FILE IS MACHINE GENERATED WITH CGEN.
3178
-
3179
-Copyright 1996-2005 Free Software Foundation, Inc.
3180
-
3181
-This file is part of the GNU Binutils and/or GDB, the GNU debugger.
3182
-
3183
-This program is free software; you can redistribute it and/or modify
3184
-it under the terms of the GNU General Public License as published by
3185
-the Free Software Foundation; either version 2, or (at your option)
3186
-any later version.
3187
-
3188
-This program is distributed in the hope that it will be useful,
3189
-but WITHOUT ANY WARRANTY; without even the implied warranty of
3190
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
3191
-GNU General Public License for more details.
3192
-
3193
-You should have received a copy of the GNU General Public License along
3194
-with this program; if not, write to the Free Software Foundation, Inc.,
3195
-59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
3196
-
3197
-*/
3198
-
3199
-#ifndef OPENRISC_CPU_H
3200
-#define OPENRISC_CPU_H
3201
-
3202
-#define CGEN_ARCH openrisc
3203
-
3204
-/* Given symbol S, return openrisc_cgen_<S>.  */
3205
-#if defined (__STDC__) || defined (ALMOST_STDC) || defined (HAVE_STRINGIZE)
3206
-#define CGEN_SYM(s) openrisc##_cgen_##s
3207
-#else
3208
-#define CGEN_SYM(s) openrisc/**/_cgen_/**/s
3209
-#endif
3210
-
3211
-
3212
-/* Selected cpu families.  */
3213
-#define HAVE_CPU_OPENRISCBF
3214
-
3215
-#define CGEN_INSN_LSB0_P 1
3216
-
3217
-/* Minimum size of any insn (in bytes).  */
3218
-#define CGEN_MIN_INSN_SIZE 4
3219
-
3220
-/* Maximum size of any insn (in bytes).  */
3221
-#define CGEN_MAX_INSN_SIZE 4
3222
-
3223
-#define CGEN_INT_INSN_P 1
3224
-
3225
-/* Maximum number of syntax elements in an instruction.  */
3226
-#define CGEN_ACTUAL_MAX_SYNTAX_ELEMENTS 14
3227
-
3228
-/* CGEN_MNEMONIC_OPERANDS is defined if mnemonics have operands.
3229
-   e.g. In "b,a foo" the ",a" is an operand.  If mnemonics have operands
3230
-   we can't hash on everything up to the space.  */
3231
-#define CGEN_MNEMONIC_OPERANDS
3232
-
3233
-/* Maximum number of fields in an instruction.  */
3234
-#define CGEN_ACTUAL_MAX_IFMT_OPERANDS 9
3235
-
3236
-/* Enums.  */
3237
-
3238
-/* Enum declaration for exception vectors.  */
3239
-typedef enum e_exception {
3240
-  E_RESET, E_BUSERR, E_DPF, E_IPF
3241
- , E_EXTINT, E_ALIGN, E_ILLEGAL, E_PEINT
3242
- , E_DTLBMISS, E_ITLBMISS, E_RRANGE, E_SYSCALL
3243
- , E_BREAK, E_RESERVED
3244
-} E_EXCEPTION;
3245
-
3246
-/* Enum declaration for FIXME.  */
3247
-typedef enum insn_class {
3248
-  OP1_0, OP1_1, OP1_2, OP1_3
3249
-} INSN_CLASS;
3250
-
3251
-/* Enum declaration for FIXME.  */
3252
-typedef enum insn_sub {
3253
-  OP2_0, OP2_1, OP2_2, OP2_3
3254
- , OP2_4, OP2_5, OP2_6, OP2_7
3255
- , OP2_8, OP2_9, OP2_10, OP2_11
3256
- , OP2_12, OP2_13, OP2_14, OP2_15
3257
-} INSN_SUB;
3258
-
3259
-/* Enum declaration for FIXME.  */
3260
-typedef enum insn_op3 {
3261
-  OP3_0, OP3_1, OP3_2, OP3_3
3262
-} INSN_OP3;
3263
-
3264
-/* Enum declaration for FIXME.  */
3265
-typedef enum insn_op4 {
3266
-  OP4_0, OP4_1, OP4_2, OP4_3
3267
- , OP4_4, OP4_5, OP4_6, OP4_7
3268
-} INSN_OP4;
3269
-
3270
-/* Enum declaration for FIXME.  */
3271
-typedef enum insn_op5 {
3272
-  OP5_0, OP5_1, OP5_2, OP5_3
3273
- , OP5_4, OP5_5, OP5_6, OP5_7
3274
- , OP5_8, OP5_9, OP5_10, OP5_11
3275
- , OP5_12, OP5_13, OP5_14, OP5_15
3276
- , OP5_16, OP5_17, OP5_18, OP5_19
3277
- , OP5_20, OP5_21, OP5_22, OP5_23
3278
- , OP5_24, OP5_25, OP5_26, OP5_27
3279
- , OP5_28, OP5_29, OP5_30, OP5_31
3280
-} INSN_OP5;
3281
-
3282
-/* Enum declaration for FIXME.  */
3283
-typedef enum insn_op6 {
3284
-  OP6_0, OP6_1, OP6_2, OP6_3
3285
- , OP6_4, OP6_5, OP6_6, OP6_7
3286
-} INSN_OP6;
3287
-
3288
-/* Enum declaration for FIXME.  */
3289
-typedef enum insn_op7 {
3290
-  OP7_0, OP7_1, OP7_2, OP7_3
3291
- , OP7_4, OP7_5, OP7_6, OP7_7
3292
- , OP7_8, OP7_9, OP7_10, OP7_11
3293
- , OP7_12, OP7_13, OP7_14, OP7_15
3294
-} INSN_OP7;
3295
-
3296
-/* Attributes.  */
3297
-
3298
-/* Enum declaration for machine type selection.  */
3299
-typedef enum mach_attr {
3300
-  MACH_BASE, MACH_OPENRISC, MACH_OR1300, MACH_MAX
3301
-} MACH_ATTR;
3302
-
3303
-/* Enum declaration for instruction set selection.  */
3304
-typedef enum isa_attr {
3305
-  ISA_OR32, ISA_MAX
3306
-} ISA_ATTR;
3307
-
3308
-/* Enum declaration for if this model has caches.  */
3309
-typedef enum has_cache_attr {
3310
-  HAS_CACHE_DATA_CACHE, HAS_CACHE_INSN_CACHE
3311
-} HAS_CACHE_ATTR;
3312
-
3313
-/* Number of architecture variants.  */
3314
-#define MAX_ISAS  1
3315
-#define MAX_MACHS ((int) MACH_MAX)
3316
-
3317
-/* Ifield support.  */
3318
-
3319
-/* Ifield attribute indices.  */
3320
-
3321
-/* Enum declaration for cgen_ifld attrs.  */
3322
-typedef enum cgen_ifld_attr {
3323
-  CGEN_IFLD_VIRTUAL, CGEN_IFLD_PCREL_ADDR, CGEN_IFLD_ABS_ADDR, CGEN_IFLD_RESERVED
3324
- , CGEN_IFLD_SIGN_OPT, CGEN_IFLD_SIGNED, CGEN_IFLD_END_BOOLS, CGEN_IFLD_START_NBOOLS = 31
3325
- , CGEN_IFLD_MACH, CGEN_IFLD_END_NBOOLS
3326
-} CGEN_IFLD_ATTR;
3327
-
3328
-/* Number of non-boolean elements in cgen_ifld_attr.  */
3329
-#define CGEN_IFLD_NBOOL_ATTRS (CGEN_IFLD_END_NBOOLS - CGEN_IFLD_START_NBOOLS - 1)
3330
-
3331
-/* Enum declaration for openrisc ifield types.  */
3332
-typedef enum ifield_type {
3333
-  OPENRISC_F_NIL, OPENRISC_F_ANYOF, OPENRISC_F_CLASS, OPENRISC_F_SUB
3334
- , OPENRISC_F_R1, OPENRISC_F_R2, OPENRISC_F_R3, OPENRISC_F_SIMM16
3335
- , OPENRISC_F_UIMM16, OPENRISC_F_UIMM5, OPENRISC_F_HI16, OPENRISC_F_LO16
3336
- , OPENRISC_F_OP1, OPENRISC_F_OP2, OPENRISC_F_OP3, OPENRISC_F_OP4
3337
- , OPENRISC_F_OP5, OPENRISC_F_OP6, OPENRISC_F_OP7, OPENRISC_F_I16_1
3338
- , OPENRISC_F_I16_2, OPENRISC_F_DISP26, OPENRISC_F_ABS26, OPENRISC_F_I16NC
3339
- , OPENRISC_F_F_15_8, OPENRISC_F_F_10_3, OPENRISC_F_F_4_1, OPENRISC_F_F_7_3
3340
- , OPENRISC_F_F_10_7, OPENRISC_F_F_10_11, OPENRISC_F_MAX
3341
-} IFIELD_TYPE;
3342
-
3343
-#define MAX_IFLD ((int) OPENRISC_F_MAX)
3344
-
3345
-/* Hardware attribute indices.  */
3346
-
3347
-/* Enum declaration for cgen_hw attrs.  */
3348
-typedef enum cgen_hw_attr {
3349
-  CGEN_HW_VIRTUAL, CGEN_HW_CACHE_ADDR, CGEN_HW_PC, CGEN_HW_PROFILE
3350
- , CGEN_HW_END_BOOLS, CGEN_HW_START_NBOOLS = 31, CGEN_HW_MACH, CGEN_HW_END_NBOOLS
3351
-} CGEN_HW_ATTR;
3352
-
3353
-/* Number of non-boolean elements in cgen_hw_attr.  */
3354
-#define CGEN_HW_NBOOL_ATTRS (CGEN_HW_END_NBOOLS - CGEN_HW_START_NBOOLS - 1)
3355
-
3356
-/* Enum declaration for openrisc hardware types.  */
3357
-typedef enum cgen_hw_type {
3358
-  HW_H_MEMORY, HW_H_SINT, HW_H_UINT, HW_H_ADDR
3359
- , HW_H_IADDR, HW_H_PC, HW_H_GR, HW_H_SR
3360
- , HW_H_HI16, HW_H_LO16, HW_H_CBIT, HW_H_DELAY_INSN
3361
- , HW_MAX
3362
-} CGEN_HW_TYPE;
3363
-
3364
-#define MAX_HW ((int) HW_MAX)
3365
-
3366
-/* Operand attribute indices.  */
3367
-
3368
-/* Enum declaration for cgen_operand attrs.  */
3369
-typedef enum cgen_operand_attr {
3370
-  CGEN_OPERAND_VIRTUAL, CGEN_OPERAND_PCREL_ADDR, CGEN_OPERAND_ABS_ADDR, CGEN_OPERAND_SIGN_OPT
3371
- , CGEN_OPERAND_SIGNED, CGEN_OPERAND_NEGATIVE, CGEN_OPERAND_RELAX, CGEN_OPERAND_SEM_ONLY
3372
- , CGEN_OPERAND_END_BOOLS, CGEN_OPERAND_START_NBOOLS = 31, CGEN_OPERAND_MACH, CGEN_OPERAND_END_NBOOLS
3373
-} CGEN_OPERAND_ATTR;
3374
-
3375
-/* Number of non-boolean elements in cgen_operand_attr.  */
3376
-#define CGEN_OPERAND_NBOOL_ATTRS (CGEN_OPERAND_END_NBOOLS - CGEN_OPERAND_START_NBOOLS - 1)
3377
-
3378
-/* Enum declaration for openrisc operand types.  */
3379
-typedef enum cgen_operand_type {
3380
-  OPENRISC_OPERAND_PC, OPENRISC_OPERAND_SR, OPENRISC_OPERAND_CBIT, OPENRISC_OPERAND_SIMM_16
3381
- , OPENRISC_OPERAND_UIMM_16, OPENRISC_OPERAND_DISP_26, OPENRISC_OPERAND_ABS_26, OPENRISC_OPERAND_UIMM_5
3382
- , OPENRISC_OPERAND_RD, OPENRISC_OPERAND_RA, OPENRISC_OPERAND_RB, OPENRISC_OPERAND_OP_F_23
3383
- , OPENRISC_OPERAND_OP_F_3, OPENRISC_OPERAND_HI16, OPENRISC_OPERAND_LO16, OPENRISC_OPERAND_UI16NC
3384
- , OPENRISC_OPERAND_MAX
3385
-} CGEN_OPERAND_TYPE;
3386
-
3387
-/* Number of operands types.  */
3388
-#define MAX_OPERANDS 16
3389
-
3390
-/* Maximum number of operands referenced by any insn.  */
3391
-#define MAX_OPERAND_INSTANCES 8
3392
-
3393
-/* Insn attribute indices.  */
3394
-
3395
-/* Enum declaration for cgen_insn attrs.  */
3396
-typedef enum cgen_insn_attr {
3397
-  CGEN_INSN_ALIAS, CGEN_INSN_VIRTUAL, CGEN_INSN_UNCOND_CTI, CGEN_INSN_COND_CTI
3398
- , CGEN_INSN_SKIP_CTI, CGEN_INSN_DELAY_SLOT, CGEN_INSN_RELAXABLE, CGEN_INSN_RELAXED
3399
- , CGEN_INSN_NO_DIS, CGEN_INSN_PBB, CGEN_INSN_NOT_IN_DELAY_SLOT, CGEN_INSN_END_BOOLS
3400
- , CGEN_INSN_START_NBOOLS = 31, CGEN_INSN_MACH, CGEN_INSN_END_NBOOLS
3401
-} CGEN_INSN_ATTR;
3402
-
3403
-/* Number of non-boolean elements in cgen_insn_attr.  */
3404
-#define CGEN_INSN_NBOOL_ATTRS (CGEN_INSN_END_NBOOLS - CGEN_INSN_START_NBOOLS - 1)
3405
-
3406
-/* cgen.h uses things we just defined.  */
3407
-#include "opcode/cgen.h"
3408
-
3409
-extern const struct cgen_ifld openrisc_cgen_ifld_table[];
3410
-
3411
-/* Attributes.  */
3412
-extern const CGEN_ATTR_TABLE openrisc_cgen_hardware_attr_table[];
3413
-extern const CGEN_ATTR_TABLE openrisc_cgen_ifield_attr_table[];
3414
-extern const CGEN_ATTR_TABLE openrisc_cgen_operand_attr_table[];
3415
-extern const CGEN_ATTR_TABLE openrisc_cgen_insn_attr_table[];
3416
-
3417
-/* Hardware decls.  */
3418
-
3419
-extern CGEN_KEYWORD openrisc_cgen_opval_h_gr;
3420
-
3421
-extern const CGEN_HW_ENTRY openrisc_cgen_hw_table[];
3422
-
3423
-
3424
-
3425
-#endif /* OPENRISC_CPU_H */
3426
diff --unified -N -r ../binutils-2.16.1/opcodes/openrisc-dis.c binutils-2.16.1/opcodes/openrisc-dis.c
3427
--- ../binutils-2.16.1/opcodes/openrisc-dis.c   2005-02-23 17:04:39.000000000 +0100
3428
+++ binutils-2.16.1/opcodes/openrisc-dis.c      1970-01-01 01:00:00.000000000 +0100
3429
@@ -1,555 +0,0 @@
3430
-/* Disassembler interface for targets using CGEN. -*- C -*-
3431
-   CGEN: Cpu tools GENerator
3432
-
3433
-THIS FILE IS MACHINE GENERATED WITH CGEN.
3434
-- the resultant file is machine generated, cgen-dis.in isn't
3435
-
3436
-Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2005
3437
-Free Software Foundation, Inc.
3438
-
3439
-This file is part of the GNU Binutils and GDB, the GNU debugger.
3440
-
3441
-This program is free software; you can redistribute it and/or modify
3442
-it under the terms of the GNU General Public License as published by
3443
-the Free Software Foundation; either version 2, or (at your option)
3444
-any later version.
3445
-
3446
-This program is distributed in the hope that it will be useful,
3447
-but WITHOUT ANY WARRANTY; without even the implied warranty of
3448
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
3449
-GNU General Public License for more details.
3450
-
3451
-You should have received a copy of the GNU General Public License
3452
-along with this program; if not, write to the Free Software Foundation, Inc.,
3453
-59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
3454
-
3455
-/* ??? Eventually more and more of this stuff can go to cpu-independent files.
3456
-   Keep that in mind.  */
3457
-
3458
-#include "sysdep.h"
3459
-#include <stdio.h>
3460
-#include "ansidecl.h"
3461
-#include "dis-asm.h"
3462
-#include "bfd.h"
3463
-#include "symcat.h"
3464
-#include "libiberty.h"
3465
-#include "openrisc-desc.h"
3466
-#include "openrisc-opc.h"
3467
-#include "opintl.h"
3468
-
3469
-/* Default text to print if an instruction isn't recognized.  */
3470
-#define UNKNOWN_INSN_MSG _("*unknown*")
3471
-
3472
-static void print_normal
3473
-  (CGEN_CPU_DESC, void *, long, unsigned int, bfd_vma, int);
3474
-static void print_address
3475
-  (CGEN_CPU_DESC, void *, bfd_vma, unsigned int, bfd_vma, int) ATTRIBUTE_UNUSED;
3476
-static void print_keyword
3477
-  (CGEN_CPU_DESC, void *, CGEN_KEYWORD *, long, unsigned int) ATTRIBUTE_UNUSED;
3478
-static void print_insn_normal
3479
-  (CGEN_CPU_DESC, void *, const CGEN_INSN *, CGEN_FIELDS *, bfd_vma, int);
3480
-static int print_insn
3481
-  (CGEN_CPU_DESC, bfd_vma,  disassemble_info *, bfd_byte *, unsigned);
3482
-static int default_print_insn
3483
-  (CGEN_CPU_DESC, bfd_vma, disassemble_info *) ATTRIBUTE_UNUSED;
3484
-static int read_insn
3485
-  (CGEN_CPU_DESC, bfd_vma, disassemble_info *, bfd_byte *, int, CGEN_EXTRACT_INFO *,
3486
-   unsigned long *);
3487
-
3488
-/* -- disassembler routines inserted here */
3489
-
3490
-
3491
-void openrisc_cgen_print_operand
3492
-  PARAMS ((CGEN_CPU_DESC, int, PTR, CGEN_FIELDS *,
3493
-           void const *, bfd_vma, int));
3494
-
3495
-/* Main entry point for printing operands.
3496
-   XINFO is a `void *' and not a `disassemble_info *' to not put a requirement
3497
-   of dis-asm.h on cgen.h.
3498
-
3499
-   This function is basically just a big switch statement.  Earlier versions
3500
-   used tables to look up the function to use, but
3501
-   - if the table contains both assembler and disassembler functions then
3502
-     the disassembler contains much of the assembler and vice-versa,
3503
-   - there's a lot of inlining possibilities as things grow,
3504
-   - using a switch statement avoids the function call overhead.
3505
-
3506
-   This function could be moved into `print_insn_normal', but keeping it
3507
-   separate makes clear the interface between `print_insn_normal' and each of
3508
-   the handlers.  */
3509
-
3510
-void
3511
-openrisc_cgen_print_operand (cd, opindex, xinfo, fields, attrs, pc, length)
3512
-     CGEN_CPU_DESC cd;
3513
-     int opindex;
3514
-     PTR xinfo;
3515
-     CGEN_FIELDS *fields;
3516
-     void const *attrs ATTRIBUTE_UNUSED;
3517
-     bfd_vma pc;
3518
-     int length;
3519
-{
3520
- disassemble_info *info = (disassemble_info *) xinfo;
3521
-
3522
-  switch (opindex)
3523
-    {
3524
-    case OPENRISC_OPERAND_ABS_26 :
3525
-      print_address (cd, info, fields->f_abs26, 0|(1<<CGEN_OPERAND_ABS_ADDR), pc, length);
3526
-      break;
3527
-    case OPENRISC_OPERAND_DISP_26 :
3528
-      print_address (cd, info, fields->f_disp26, 0|(1<<CGEN_OPERAND_PCREL_ADDR), pc, length);
3529
-      break;
3530
-    case OPENRISC_OPERAND_HI16 :
3531
-      print_normal (cd, info, fields->f_simm16, 0|(1<<CGEN_OPERAND_SIGNED)|(1<<CGEN_OPERAND_SIGN_OPT), pc, length);
3532
-      break;
3533
-    case OPENRISC_OPERAND_LO16 :
3534
-      print_normal (cd, info, fields->f_lo16, 0|(1<<CGEN_OPERAND_SIGNED)|(1<<CGEN_OPERAND_SIGN_OPT), pc, length);
3535
-      break;
3536
-    case OPENRISC_OPERAND_OP_F_23 :
3537
-      print_normal (cd, info, fields->f_op4, 0, pc, length);
3538
-      break;
3539
-    case OPENRISC_OPERAND_OP_F_3 :
3540
-      print_normal (cd, info, fields->f_op5, 0, pc, length);
3541
-      break;
3542
-    case OPENRISC_OPERAND_RA :
3543
-      print_keyword (cd, info, & openrisc_cgen_opval_h_gr, fields->f_r2, 0);
3544
-      break;
3545
-    case OPENRISC_OPERAND_RB :
3546
-      print_keyword (cd, info, & openrisc_cgen_opval_h_gr, fields->f_r3, 0);
3547
-      break;
3548
-    case OPENRISC_OPERAND_RD :
3549
-      print_keyword (cd, info, & openrisc_cgen_opval_h_gr, fields->f_r1, 0);
3550
-      break;
3551
-    case OPENRISC_OPERAND_SIMM_16 :
3552
-      print_normal (cd, info, fields->f_simm16, 0|(1<<CGEN_OPERAND_SIGNED), pc, length);
3553
-      break;
3554
-    case OPENRISC_OPERAND_UI16NC :
3555
-      print_normal (cd, info, fields->f_i16nc, 0|(1<<CGEN_OPERAND_SIGNED)|(1<<CGEN_OPERAND_SIGN_OPT)|(1<<CGEN_OPERAND_VIRTUAL), pc, length);
3556
-      break;
3557
-    case OPENRISC_OPERAND_UIMM_16 :
3558
-      print_normal (cd, info, fields->f_uimm16, 0, pc, length);
3559
-      break;
3560
-    case OPENRISC_OPERAND_UIMM_5 :
3561
-      print_normal (cd, info, fields->f_uimm5, 0, pc, length);
3562
-      break;
3563
-
3564
-    default :
3565
-      /* xgettext:c-format */
3566
-      fprintf (stderr, _("Unrecognized field %d while printing insn.\n"),
3567
-              opindex);
3568
-    abort ();
3569
-  }
3570
-}
3571
-
3572
-cgen_print_fn * const openrisc_cgen_print_handlers[] =
3573
-{
3574
-  print_insn_normal,
3575
-};
3576
-
3577
-
3578
-void
3579
-openrisc_cgen_init_dis (cd)
3580
-     CGEN_CPU_DESC cd;
3581
-{
3582
-  openrisc_cgen_init_opcode_table (cd);
3583
-  openrisc_cgen_init_ibld_table (cd);
3584
-  cd->print_handlers = & openrisc_cgen_print_handlers[0];
3585
-  cd->print_operand = openrisc_cgen_print_operand;
3586
-}
3587
-
3588
-
3589
-/* Default print handler.  */
3590
-
3591
-static void
3592
-print_normal (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
3593
-             void *dis_info,
3594
-             long value,
3595
-             unsigned int attrs,
3596
-             bfd_vma pc ATTRIBUTE_UNUSED,
3597
-             int length ATTRIBUTE_UNUSED)
3598
-{
3599
-  disassemble_info *info = (disassemble_info *) dis_info;
3600
-
3601
-#ifdef CGEN_PRINT_NORMAL
3602
-  CGEN_PRINT_NORMAL (cd, info, value, attrs, pc, length);
3603
-#endif
3604
-
3605
-  /* Print the operand as directed by the attributes.  */
3606
-  if (CGEN_BOOL_ATTR (attrs, CGEN_OPERAND_SEM_ONLY))
3607
-    ; /* nothing to do */
3608
-  else if (CGEN_BOOL_ATTR (attrs, CGEN_OPERAND_SIGNED))
3609
-    (*info->fprintf_func) (info->stream, "%ld", value);
3610
-  else
3611
-    (*info->fprintf_func) (info->stream, "0x%lx", value);
3612
-}
3613
-
3614
-/* Default address handler.  */
3615
-
3616
-static void
3617
-print_address (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
3618
-              void *dis_info,
3619
-              bfd_vma value,
3620
-              unsigned int attrs,
3621
-              bfd_vma pc ATTRIBUTE_UNUSED,
3622
-              int length ATTRIBUTE_UNUSED)
3623
-{
3624
-  disassemble_info *info = (disassemble_info *) dis_info;
3625
-
3626
-#ifdef CGEN_PRINT_ADDRESS
3627
-  CGEN_PRINT_ADDRESS (cd, info, value, attrs, pc, length);
3628
-#endif
3629
-
3630
-  /* Print the operand as directed by the attributes.  */
3631
-  if (CGEN_BOOL_ATTR (attrs, CGEN_OPERAND_SEM_ONLY))
3632
-    ; /* nothing to do */
3633
-  else if (CGEN_BOOL_ATTR (attrs, CGEN_OPERAND_PCREL_ADDR))
3634
-    (*info->print_address_func) (value, info);
3635
-  else if (CGEN_BOOL_ATTR (attrs, CGEN_OPERAND_ABS_ADDR))
3636
-    (*info->print_address_func) (value, info);
3637
-  else if (CGEN_BOOL_ATTR (attrs, CGEN_OPERAND_SIGNED))
3638
-    (*info->fprintf_func) (info->stream, "%ld", (long) value);
3639
-  else
3640
-    (*info->fprintf_func) (info->stream, "0x%lx", (long) value);
3641
-}
3642
-
3643
-/* Keyword print handler.  */
3644
-
3645
-static void
3646
-print_keyword (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
3647
-              void *dis_info,
3648
-              CGEN_KEYWORD *keyword_table,
3649
-              long value,
3650
-              unsigned int attrs ATTRIBUTE_UNUSED)
3651
-{
3652
-  disassemble_info *info = (disassemble_info *) dis_info;
3653
-  const CGEN_KEYWORD_ENTRY *ke;
3654
-
3655
-  ke = cgen_keyword_lookup_value (keyword_table, value);
3656
-  if (ke != NULL)
3657
-    (*info->fprintf_func) (info->stream, "%s", ke->name);
3658
-  else
3659
-    (*info->fprintf_func) (info->stream, "???");
3660
-}
3661
-
3662
-/* Default insn printer.
3663
-
3664
-   DIS_INFO is defined as `void *' so the disassembler needn't know anything
3665
-   about disassemble_info.  */
3666
-
3667
-static void
3668
-print_insn_normal (CGEN_CPU_DESC cd,
3669
-                  void *dis_info,
3670
-                  const CGEN_INSN *insn,
3671
-                  CGEN_FIELDS *fields,
3672
-                  bfd_vma pc,
3673
-                  int length)
3674
-{
3675
-  const CGEN_SYNTAX *syntax = CGEN_INSN_SYNTAX (insn);
3676
-  disassemble_info *info = (disassemble_info *) dis_info;
3677
-  const CGEN_SYNTAX_CHAR_TYPE *syn;
3678
-
3679
-  CGEN_INIT_PRINT (cd);
3680
-
3681
-  for (syn = CGEN_SYNTAX_STRING (syntax); *syn; ++syn)
3682
-    {
3683
-      if (CGEN_SYNTAX_MNEMONIC_P (*syn))
3684
-       {
3685
-         (*info->fprintf_func) (info->stream, "%s", CGEN_INSN_MNEMONIC (insn));
3686
-         continue;
3687
-       }
3688
-      if (CGEN_SYNTAX_CHAR_P (*syn))
3689
-       {
3690
-         (*info->fprintf_func) (info->stream, "%c", CGEN_SYNTAX_CHAR (*syn));
3691
-         continue;
3692
-       }
3693
-
3694
-      /* We have an operand.  */
3695
-      openrisc_cgen_print_operand (cd, CGEN_SYNTAX_FIELD (*syn), info,
3696
-                                fields, CGEN_INSN_ATTRS (insn), pc, length);
3697
-    }
3698
-}
3699
-
3700
-/* Subroutine of print_insn. Reads an insn into the given buffers and updates
3701
-   the extract info.
3702
-   Returns 0 if all is well, non-zero otherwise.  */
3703
-
3704
-static int
3705
-read_insn (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
3706
-          bfd_vma pc,
3707
-          disassemble_info *info,
3708
-          bfd_byte *buf,
3709
-          int buflen,
3710
-          CGEN_EXTRACT_INFO *ex_info,
3711
-          unsigned long *insn_value)
3712
-{
3713
-  int status = (*info->read_memory_func) (pc, buf, buflen, info);
3714
-  if (status != 0)
3715
-    {
3716
-      (*info->memory_error_func) (status, pc, info);
3717
-      return -1;
3718
-    }
3719
-
3720
-  ex_info->dis_info = info;
3721
-  ex_info->valid = (1 << buflen) - 1;
3722
-  ex_info->insn_bytes = buf;
3723
-
3724
-  *insn_value = bfd_get_bits (buf, buflen * 8, info->endian == BFD_ENDIAN_BIG);
3725
-  return 0;
3726
-}
3727
-
3728
-/* Utility to print an insn.
3729
-   BUF is the base part of the insn, target byte order, BUFLEN bytes long.
3730
-   The result is the size of the insn in bytes or zero for an unknown insn
3731
-   or -1 if an error occurs fetching data (memory_error_func will have
3732
-   been called).  */
3733
-
3734
-static int
3735
-print_insn (CGEN_CPU_DESC cd,
3736
-           bfd_vma pc,
3737
-           disassemble_info *info,
3738
-           bfd_byte *buf,
3739
-           unsigned int buflen)
3740
-{
3741
-  CGEN_INSN_INT insn_value;
3742
-  const CGEN_INSN_LIST *insn_list;
3743
-  CGEN_EXTRACT_INFO ex_info;
3744
-  int basesize;
3745
-
3746
-  /* Extract base part of instruction, just in case CGEN_DIS_* uses it. */
3747
-  basesize = cd->base_insn_bitsize < buflen * 8 ?
3748
-                                     cd->base_insn_bitsize : buflen * 8;
3749
-  insn_value = cgen_get_insn_value (cd, buf, basesize);
3750
-
3751
-
3752
-  /* Fill in ex_info fields like read_insn would.  Don't actually call
3753
-     read_insn, since the incoming buffer is already read (and possibly
3754
-     modified a la m32r).  */
3755
-  ex_info.valid = (1 << buflen) - 1;
3756
-  ex_info.dis_info = info;
3757
-  ex_info.insn_bytes = buf;
3758
-
3759
-  /* The instructions are stored in hash lists.
3760
-     Pick the first one and keep trying until we find the right one.  */
3761
-
3762
-  insn_list = CGEN_DIS_LOOKUP_INSN (cd, (char *) buf, insn_value);
3763
-  while (insn_list != NULL)
3764
-    {
3765
-      const CGEN_INSN *insn = insn_list->insn;
3766
-      CGEN_FIELDS fields;
3767
-      int length;
3768
-      unsigned long insn_value_cropped;
3769
-
3770
-#ifdef CGEN_VALIDATE_INSN_SUPPORTED
3771
-      /* Not needed as insn shouldn't be in hash lists if not supported.  */
3772
-      /* Supported by this cpu?  */
3773
-      if (! openrisc_cgen_insn_supported (cd, insn))
3774
-        {
3775
-          insn_list = CGEN_DIS_NEXT_INSN (insn_list);
3776
-         continue;
3777
-        }
3778
-#endif
3779
-
3780
-      /* Basic bit mask must be correct.  */
3781
-      /* ??? May wish to allow target to defer this check until the extract
3782
-        handler.  */
3783
-
3784
-      /* Base size may exceed this instruction's size.  Extract the
3785
-         relevant part from the buffer. */
3786
-      if ((unsigned) (CGEN_INSN_BITSIZE (insn) / 8) < buflen &&
3787
-         (unsigned) (CGEN_INSN_BITSIZE (insn) / 8) <= sizeof (unsigned long))
3788
-       insn_value_cropped = bfd_get_bits (buf, CGEN_INSN_BITSIZE (insn),
3789
-                                          info->endian == BFD_ENDIAN_BIG);
3790
-      else
3791
-       insn_value_cropped = insn_value;
3792
-
3793
-      if ((insn_value_cropped & CGEN_INSN_BASE_MASK (insn))
3794
-         == CGEN_INSN_BASE_VALUE (insn))
3795
-       {
3796
-         /* Printing is handled in two passes.  The first pass parses the
3797
-            machine insn and extracts the fields.  The second pass prints
3798
-            them.  */
3799
-
3800
-         /* Make sure the entire insn is loaded into insn_value, if it
3801
-            can fit.  */
3802
-         if (((unsigned) CGEN_INSN_BITSIZE (insn) > cd->base_insn_bitsize) &&
3803
-             (unsigned) (CGEN_INSN_BITSIZE (insn) / 8) <= sizeof (unsigned long))
3804
-           {
3805
-             unsigned long full_insn_value;
3806
-             int rc = read_insn (cd, pc, info, buf,
3807
-                                 CGEN_INSN_BITSIZE (insn) / 8,
3808
-                                 & ex_info, & full_insn_value);
3809
-             if (rc != 0)
3810
-               return rc;
3811
-             length = CGEN_EXTRACT_FN (cd, insn)
3812
-               (cd, insn, &ex_info, full_insn_value, &fields, pc);
3813
-           }
3814
-         else
3815
-           length = CGEN_EXTRACT_FN (cd, insn)
3816
-             (cd, insn, &ex_info, insn_value_cropped, &fields, pc);
3817
-
3818
-         /* length < 0 -> error */
3819
-         if (length < 0)
3820
-           return length;
3821
-         if (length > 0)
3822
-           {
3823
-             CGEN_PRINT_FN (cd, insn) (cd, info, insn, &fields, pc, length);
3824
-             /* length is in bits, result is in bytes */
3825
-             return length / 8;
3826
-           }
3827
-       }
3828
-
3829
-      insn_list = CGEN_DIS_NEXT_INSN (insn_list);
3830
-    }
3831
-
3832
-  return 0;
3833
-}
3834
-
3835
-/* Default value for CGEN_PRINT_INSN.
3836
-   The result is the size of the insn in bytes or zero for an unknown insn
3837
-   or -1 if an error occured fetching bytes.  */
3838
-
3839
-#ifndef CGEN_PRINT_INSN
3840
-#define CGEN_PRINT_INSN default_print_insn
3841
-#endif
3842
-
3843
-static int
3844
-default_print_insn (CGEN_CPU_DESC cd, bfd_vma pc, disassemble_info *info)
3845
-{
3846
-  bfd_byte buf[CGEN_MAX_INSN_SIZE];
3847
-  int buflen;
3848
-  int status;
3849
-
3850
-  /* Attempt to read the base part of the insn.  */
3851
-  buflen = cd->base_insn_bitsize / 8;
3852
-  status = (*info->read_memory_func) (pc, buf, buflen, info);
3853
-
3854
-  /* Try again with the minimum part, if min < base.  */
3855
-  if (status != 0 && (cd->min_insn_bitsize < cd->base_insn_bitsize))
3856
-    {
3857
-      buflen = cd->min_insn_bitsize / 8;
3858
-      status = (*info->read_memory_func) (pc, buf, buflen, info);
3859
-    }
3860
-
3861
-  if (status != 0)
3862
-    {
3863
-      (*info->memory_error_func) (status, pc, info);
3864
-      return -1;
3865
-    }
3866
-
3867
-  return print_insn (cd, pc, info, buf, buflen);
3868
-}
3869
-
3870
-/* Main entry point.
3871
-   Print one instruction from PC on INFO->STREAM.
3872
-   Return the size of the instruction (in bytes).  */
3873
-
3874
-typedef struct cpu_desc_list {
3875
-  struct cpu_desc_list *next;
3876
-  int isa;
3877
-  int mach;
3878
-  int endian;
3879
-  CGEN_CPU_DESC cd;
3880
-} cpu_desc_list;
3881
-
3882
-int
3883
-print_insn_openrisc (bfd_vma pc, disassemble_info *info)
3884
-{
3885
-  static cpu_desc_list *cd_list = 0;
3886
-  cpu_desc_list *cl = 0;
3887
-  static CGEN_CPU_DESC cd = 0;
3888
-  static int prev_isa;
3889
-  static int prev_mach;
3890
-  static int prev_endian;
3891
-  int length;
3892
-  int isa,mach;
3893
-  int endian = (info->endian == BFD_ENDIAN_BIG
3894
-               ? CGEN_ENDIAN_BIG
3895
-               : CGEN_ENDIAN_LITTLE);
3896
-  enum bfd_architecture arch;
3897
-
3898
-  /* ??? gdb will set mach but leave the architecture as "unknown" */
3899
-#ifndef CGEN_BFD_ARCH
3900
-#define CGEN_BFD_ARCH bfd_arch_openrisc
3901
-#endif
3902
-  arch = info->arch;
3903
-  if (arch == bfd_arch_unknown)
3904
-    arch = CGEN_BFD_ARCH;
3905
-
3906
-  /* There's no standard way to compute the machine or isa number
3907
-     so we leave it to the target.  */
3908
-#ifdef CGEN_COMPUTE_MACH
3909
-  mach = CGEN_COMPUTE_MACH (info);
3910
-#else
3911
-  mach = info->mach;
3912
-#endif
3913
-
3914
-#ifdef CGEN_COMPUTE_ISA
3915
-  isa = CGEN_COMPUTE_ISA (info);
3916
-#else
3917
-  isa = info->insn_sets;
3918
-#endif
3919
-
3920
-  /* If we've switched cpu's, try to find a handle we've used before */
3921
-  if (cd
3922
-      && (isa != prev_isa
3923
-         || mach != prev_mach
3924
-         || endian != prev_endian))
3925
-    {
3926
-      cd = 0;
3927
-      for (cl = cd_list; cl; cl = cl->next)
3928
-       {
3929
-         if (cl->isa == isa &&
3930
-             cl->mach == mach &&
3931
-             cl->endian == endian)
3932
-           {
3933
-             cd = cl->cd;
3934
-             break;
3935
-           }
3936
-       }
3937
-    }
3938
-
3939
-  /* If we haven't initialized yet, initialize the opcode table.  */
3940
-  if (! cd)
3941
-    {
3942
-      const bfd_arch_info_type *arch_type = bfd_lookup_arch (arch, mach);
3943
-      const char *mach_name;
3944
-
3945
-      if (!arch_type)
3946
-       abort ();
3947
-      mach_name = arch_type->printable_name;
3948
-
3949
-      prev_isa = isa;
3950
-      prev_mach = mach;
3951
-      prev_endian = endian;
3952
-      cd = openrisc_cgen_cpu_open (CGEN_CPU_OPEN_ISAS, prev_isa,
3953
-                                CGEN_CPU_OPEN_BFDMACH, mach_name,
3954
-                                CGEN_CPU_OPEN_ENDIAN, prev_endian,
3955
-                                CGEN_CPU_OPEN_END);
3956
-      if (!cd)
3957
-       abort ();
3958
-
3959
-      /* save this away for future reference */
3960
-      cl = xmalloc (sizeof (struct cpu_desc_list));
3961
-      cl->cd = cd;
3962
-      cl->isa = isa;
3963
-      cl->mach = mach;
3964
-      cl->endian = endian;
3965
-      cl->next = cd_list;
3966
-      cd_list = cl;
3967
-
3968
-      openrisc_cgen_init_dis (cd);
3969
-    }
3970
-
3971
-  /* We try to have as much common code as possible.
3972
-     But at this point some targets need to take over.  */
3973
-  /* ??? Some targets may need a hook elsewhere.  Try to avoid this,
3974
-     but if not possible try to move this hook elsewhere rather than
3975
-     have two hooks.  */
3976
-  length = CGEN_PRINT_INSN (cd, pc, info);
3977
-  if (length > 0)
3978
-    return length;
3979
-  if (length < 0)
3980
-    return -1;
3981
-
3982
-  (*info->fprintf_func) (info->stream, UNKNOWN_INSN_MSG);
3983
-  return cd->default_insn_bitsize / 8;
3984
-}
3985
diff --unified -N -r ../binutils-2.16.1/opcodes/openrisc-ibld.c binutils-2.16.1/opcodes/openrisc-ibld.c
3986
--- ../binutils-2.16.1/opcodes/openrisc-ibld.c  2003-08-09 02:39:21.000000000 +0200
3987
+++ binutils-2.16.1/opcodes/openrisc-ibld.c     1970-01-01 01:00:00.000000000 +0100
3988
@@ -1,1025 +0,0 @@
3989
-/* Instruction building/extraction support for openrisc. -*- C -*-
3990
-
3991
-THIS FILE IS MACHINE GENERATED WITH CGEN: Cpu tools GENerator.
3992
-- the resultant file is machine generated, cgen-ibld.in isn't
3993
-
3994
-Copyright 1996, 1997, 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
3995
-
3996
-This file is part of the GNU Binutils and GDB, the GNU debugger.
3997
-
3998
-This program is free software; you can redistribute it and/or modify
3999
-it under the terms of the GNU General Public License as published by
4000
-the Free Software Foundation; either version 2, or (at your option)
4001
-any later version.
4002
-
4003
-This program is distributed in the hope that it will be useful,
4004
-but WITHOUT ANY WARRANTY; without even the implied warranty of
4005
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
4006
-GNU General Public License for more details.
4007
-
4008
-You should have received a copy of the GNU General Public License
4009
-along with this program; if not, write to the Free Software Foundation, Inc.,
4010
-59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
4011
-
4012
-/* ??? Eventually more and more of this stuff can go to cpu-independent files.
4013
-   Keep that in mind.  */
4014
-
4015
-#include "sysdep.h"
4016
-#include <stdio.h>
4017
-#include "ansidecl.h"
4018
-#include "dis-asm.h"
4019
-#include "bfd.h"
4020
-#include "symcat.h"
4021
-#include "openrisc-desc.h"
4022
-#include "openrisc-opc.h"
4023
-#include "opintl.h"
4024
-#include "safe-ctype.h"
4025
-
4026
-#undef min
4027
-#define min(a,b) ((a) < (b) ? (a) : (b))
4028
-#undef max
4029
-#define max(a,b) ((a) > (b) ? (a) : (b))
4030
-
4031
-/* Used by the ifield rtx function.  */
4032
-#define FLD(f) (fields->f)
4033
-
4034
-static const char * insert_normal
4035
-  (CGEN_CPU_DESC, long, unsigned int, unsigned int, unsigned int,
4036
-   unsigned int, unsigned int, unsigned int, CGEN_INSN_BYTES_PTR);
4037
-static const char * insert_insn_normal
4038
-  (CGEN_CPU_DESC, const CGEN_INSN *,
4039
-   CGEN_FIELDS *, CGEN_INSN_BYTES_PTR, bfd_vma);
4040
-static int extract_normal
4041
-  (CGEN_CPU_DESC, CGEN_EXTRACT_INFO *, CGEN_INSN_INT,
4042
-   unsigned int, unsigned int, unsigned int, unsigned int,
4043
-   unsigned int, unsigned int, bfd_vma, long *);
4044
-static int extract_insn_normal
4045
-  (CGEN_CPU_DESC, const CGEN_INSN *, CGEN_EXTRACT_INFO *,
4046
-   CGEN_INSN_INT, CGEN_FIELDS *, bfd_vma);
4047
-#if CGEN_INT_INSN_P
4048
-static void put_insn_int_value
4049
-  (CGEN_CPU_DESC, CGEN_INSN_BYTES_PTR, int, int, CGEN_INSN_INT);
4050
-#endif
4051
-#if ! CGEN_INT_INSN_P
4052
-static CGEN_INLINE void insert_1
4053
-  (CGEN_CPU_DESC, unsigned long, int, int, int, unsigned char *);
4054
-static CGEN_INLINE int fill_cache
4055
-  (CGEN_CPU_DESC, CGEN_EXTRACT_INFO *,  int, int, bfd_vma);
4056
-static CGEN_INLINE long extract_1
4057
-  (CGEN_CPU_DESC, CGEN_EXTRACT_INFO *, int, int, int, unsigned char *, bfd_vma);
4058
-#endif
4059
-
4060
-/* Operand insertion.  */
4061
-
4062
-#if ! CGEN_INT_INSN_P
4063
-
4064
-/* Subroutine of insert_normal.  */
4065
-
4066
-static CGEN_INLINE void
4067
-insert_1 (CGEN_CPU_DESC cd,
4068
-         unsigned long value,
4069
-         int start,
4070
-         int length,
4071
-         int word_length,
4072
-         unsigned char *bufp)
4073
-{
4074
-  unsigned long x,mask;
4075
-  int shift;
4076
-
4077
-  x = cgen_get_insn_value (cd, bufp, word_length);
4078
-
4079
-  /* Written this way to avoid undefined behaviour.  */
4080
-  mask = (((1L << (length - 1)) - 1) << 1) | 1;
4081
-  if (CGEN_INSN_LSB0_P)
4082
-    shift = (start + 1) - length;
4083
-  else
4084
-    shift = (word_length - (start + length));
4085
-  x = (x & ~(mask << shift)) | ((value & mask) << shift);
4086
-
4087
-  cgen_put_insn_value (cd, bufp, word_length, (bfd_vma) x);
4088
-}
4089
-
4090
-#endif /* ! CGEN_INT_INSN_P */
4091
-
4092
-/* Default insertion routine.
4093
-
4094
-   ATTRS is a mask of the boolean attributes.
4095
-   WORD_OFFSET is the offset in bits from the start of the insn of the value.
4096
-   WORD_LENGTH is the length of the word in bits in which the value resides.
4097
-   START is the starting bit number in the word, architecture origin.
4098
-   LENGTH is the length of VALUE in bits.
4099
-   TOTAL_LENGTH is the total length of the insn in bits.
4100
-
4101
-   The result is an error message or NULL if success.  */
4102
-
4103
-/* ??? This duplicates functionality with bfd's howto table and
4104
-   bfd_install_relocation.  */
4105
-/* ??? This doesn't handle bfd_vma's.  Create another function when
4106
-   necessary.  */
4107
-
4108
-static const char *
4109
-insert_normal (CGEN_CPU_DESC cd,
4110
-              long value,
4111
-              unsigned int attrs,
4112
-              unsigned int word_offset,
4113
-              unsigned int start,
4114
-              unsigned int length,
4115
-              unsigned int word_length,
4116
-              unsigned int total_length,
4117
-              CGEN_INSN_BYTES_PTR buffer)
4118
-{
4119
-  static char errbuf[100];
4120
-  /* Written this way to avoid undefined behaviour.  */
4121
-  unsigned long mask = (((1L << (length - 1)) - 1) << 1) | 1;
4122
-
4123
-  /* If LENGTH is zero, this operand doesn't contribute to the value.  */
4124
-  if (length == 0)
4125
-    return NULL;
4126
-
4127
-#if 0
4128
-  if (CGEN_INT_INSN_P
4129
-      && word_offset != 0)
4130
-    abort ();
4131
-#endif
4132
-
4133
-  if (word_length > 32)
4134
-    abort ();
4135
-
4136
-  /* For architectures with insns smaller than the base-insn-bitsize,
4137
-     word_length may be too big.  */
4138
-  if (cd->min_insn_bitsize < cd->base_insn_bitsize)
4139
-    {
4140
-      if (word_offset == 0
4141
-         && word_length > total_length)
4142
-       word_length = total_length;
4143
-    }
4144
-
4145
-  /* Ensure VALUE will fit.  */
4146
-  if (CGEN_BOOL_ATTR (attrs, CGEN_IFLD_SIGN_OPT))
4147
-    {
4148
-      long minval = - (1L << (length - 1));
4149
-      unsigned long maxval = mask;
4150
-
4151
-      if ((value > 0 && (unsigned long) value > maxval)
4152
-         || value < minval)
4153
-       {
4154
-         /* xgettext:c-format */
4155
-         sprintf (errbuf,
4156
-                  _("operand out of range (%ld not between %ld and %lu)"),
4157
-                  value, minval, maxval);
4158
-         return errbuf;
4159
-       }
4160
-    }
4161
-  else if (! CGEN_BOOL_ATTR (attrs, CGEN_IFLD_SIGNED))
4162
-    {
4163
-      unsigned long maxval = mask;
4164
-
4165
-      if ((unsigned long) value > maxval)
4166
-       {
4167
-         /* xgettext:c-format */
4168
-         sprintf (errbuf,
4169
-                  _("operand out of range (%lu not between 0 and %lu)"),
4170
-                  value, maxval);
4171
-         return errbuf;
4172
-       }
4173
-    }
4174
-  else
4175
-    {
4176
-      if (! cgen_signed_overflow_ok_p (cd))
4177
-       {
4178
-         long minval = - (1L << (length - 1));
4179
-         long maxval =   (1L << (length - 1)) - 1;
4180
-
4181
-         if (value < minval || value > maxval)
4182
-           {
4183
-             sprintf
4184
-               /* xgettext:c-format */
4185
-               (errbuf, _("operand out of range (%ld not between %ld and %ld)"),
4186
-                value, minval, maxval);
4187
-             return errbuf;
4188
-           }
4189
-       }
4190
-    }
4191
-
4192
-#if CGEN_INT_INSN_P
4193
-
4194
-  {
4195
-    int shift;
4196
-
4197
-    if (CGEN_INSN_LSB0_P)
4198
-      shift = (word_offset + start + 1) - length;
4199
-    else
4200
-      shift = total_length - (word_offset + start + length);
4201
-    *buffer = (*buffer & ~(mask << shift)) | ((value & mask) << shift);
4202
-  }
4203
-
4204
-#else /* ! CGEN_INT_INSN_P */
4205
-
4206
-  {
4207
-    unsigned char *bufp = (unsigned char *) buffer + word_offset / 8;
4208
-
4209
-    insert_1 (cd, value, start, length, word_length, bufp);
4210
-  }
4211
-
4212
-#endif /* ! CGEN_INT_INSN_P */
4213
-
4214
-  return NULL;
4215
-}
4216
-
4217
-/* Default insn builder (insert handler).
4218
-   The instruction is recorded in CGEN_INT_INSN_P byte order (meaning
4219
-   that if CGEN_INSN_BYTES_PTR is an int * and thus, the value is
4220
-   recorded in host byte order, otherwise BUFFER is an array of bytes
4221
-   and the value is recorded in target byte order).
4222
-   The result is an error message or NULL if success.  */
4223
-
4224
-static const char *
4225
-insert_insn_normal (CGEN_CPU_DESC cd,
4226
-                   const CGEN_INSN * insn,
4227
-                   CGEN_FIELDS * fields,
4228
-                   CGEN_INSN_BYTES_PTR buffer,
4229
-                   bfd_vma pc)
4230
-{
4231
-  const CGEN_SYNTAX *syntax = CGEN_INSN_SYNTAX (insn);
4232
-  unsigned long value;
4233
-  const CGEN_SYNTAX_CHAR_TYPE * syn;
4234
-
4235
-  CGEN_INIT_INSERT (cd);
4236
-  value = CGEN_INSN_BASE_VALUE (insn);
4237
-
4238
-  /* If we're recording insns as numbers (rather than a string of bytes),
4239
-     target byte order handling is deferred until later.  */
4240
-
4241
-#if CGEN_INT_INSN_P
4242
-
4243
-  put_insn_int_value (cd, buffer, cd->base_insn_bitsize,
4244
-                     CGEN_FIELDS_BITSIZE (fields), value);
4245
-
4246
-#else
4247
-
4248
-  cgen_put_insn_value (cd, buffer, min ((unsigned) cd->base_insn_bitsize,
4249
-                                       (unsigned) CGEN_FIELDS_BITSIZE (fields)),
4250
-                      value);
4251
-
4252
-#endif /* ! CGEN_INT_INSN_P */
4253
-
4254
-  /* ??? It would be better to scan the format's fields.
4255
-     Still need to be able to insert a value based on the operand though;
4256
-     e.g. storing a branch displacement that got resolved later.
4257
-     Needs more thought first.  */
4258
-
4259
-  for (syn = CGEN_SYNTAX_STRING (syntax); * syn; ++ syn)
4260
-    {
4261
-      const char *errmsg;
4262
-
4263
-      if (CGEN_SYNTAX_CHAR_P (* syn))
4264
-       continue;
4265
-
4266
-      errmsg = (* cd->insert_operand) (cd, CGEN_SYNTAX_FIELD (*syn),
4267
-                                      fields, buffer, pc);
4268
-      if (errmsg)
4269
-       return errmsg;
4270
-    }
4271
-
4272
-  return NULL;
4273
-}
4274
-
4275
-#if CGEN_INT_INSN_P
4276
-/* Cover function to store an insn value into an integral insn.  Must go here
4277
- because it needs <prefix>-desc.h for CGEN_INT_INSN_P.  */
4278
-
4279
-static void
4280
-put_insn_int_value (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
4281
-                   CGEN_INSN_BYTES_PTR buf,
4282
-                   int length,
4283
-                   int insn_length,
4284
-                   CGEN_INSN_INT value)
4285
-{
4286
-  /* For architectures with insns smaller than the base-insn-bitsize,
4287
-     length may be too big.  */
4288
-  if (length > insn_length)
4289
-    *buf = value;
4290
-  else
4291
-    {
4292
-      int shift = insn_length - length;
4293
-      /* Written this way to avoid undefined behaviour.  */
4294
-      CGEN_INSN_INT mask = (((1L << (length - 1)) - 1) << 1) | 1;
4295
-      *buf = (*buf & ~(mask << shift)) | ((value & mask) << shift);
4296
-    }
4297
-}
4298
-#endif
4299
-
4300
-/* Operand extraction.  */
4301
-
4302
-#if ! CGEN_INT_INSN_P
4303
-
4304
-/* Subroutine of extract_normal.
4305
-   Ensure sufficient bytes are cached in EX_INFO.
4306
-   OFFSET is the offset in bytes from the start of the insn of the value.
4307
-   BYTES is the length of the needed value.
4308
-   Returns 1 for success, 0 for failure.  */
4309
-
4310
-static CGEN_INLINE int
4311
-fill_cache (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
4312
-           CGEN_EXTRACT_INFO *ex_info,
4313
-           int offset,
4314
-           int bytes,
4315
-           bfd_vma pc)
4316
-{
4317
-  /* It's doubtful that the middle part has already been fetched so
4318
-     we don't optimize that case.  kiss.  */
4319
-  unsigned int mask;
4320
-  disassemble_info *info = (disassemble_info *) ex_info->dis_info;
4321
-
4322
-  /* First do a quick check.  */
4323
-  mask = (1 << bytes) - 1;
4324
-  if (((ex_info->valid >> offset) & mask) == mask)
4325
-    return 1;
4326
-
4327
-  /* Search for the first byte we need to read.  */
4328
-  for (mask = 1 << offset; bytes > 0; --bytes, ++offset, mask <<= 1)
4329
-    if (! (mask & ex_info->valid))
4330
-      break;
4331
-
4332
-  if (bytes)
4333
-    {
4334
-      int status;
4335
-
4336
-      pc += offset;
4337
-      status = (*info->read_memory_func)
4338
-       (pc, ex_info->insn_bytes + offset, bytes, info);
4339
-
4340
-      if (status != 0)
4341
-       {
4342
-         (*info->memory_error_func) (status, pc, info);
4343
-         return 0;
4344
-       }
4345
-
4346
-      ex_info->valid |= ((1 << bytes) - 1) << offset;
4347
-    }
4348
-
4349
-  return 1;
4350
-}
4351
-
4352
-/* Subroutine of extract_normal.  */
4353
-
4354
-static CGEN_INLINE long
4355
-extract_1 (CGEN_CPU_DESC cd,
4356
-          CGEN_EXTRACT_INFO *ex_info ATTRIBUTE_UNUSED,
4357
-          int start,
4358
-          int length,
4359
-          int word_length,
4360
-          unsigned char *bufp,
4361
-          bfd_vma pc ATTRIBUTE_UNUSED)
4362
-{
4363
-  unsigned long x;
4364
-  int shift;
4365
-#if 0
4366
-  int big_p = CGEN_CPU_INSN_ENDIAN (cd) == CGEN_ENDIAN_BIG;
4367
-#endif
4368
-  x = cgen_get_insn_value (cd, bufp, word_length);
4369
-
4370
-  if (CGEN_INSN_LSB0_P)
4371
-    shift = (start + 1) - length;
4372
-  else
4373
-    shift = (word_length - (start + length));
4374
-  return x >> shift;
4375
-}
4376
-
4377
-#endif /* ! CGEN_INT_INSN_P */
4378
-
4379
-/* Default extraction routine.
4380
-
4381
-   INSN_VALUE is the first base_insn_bitsize bits of the insn in host order,
4382
-   or sometimes less for cases like the m32r where the base insn size is 32
4383
-   but some insns are 16 bits.
4384
-   ATTRS is a mask of the boolean attributes.  We only need `SIGNED',
4385
-   but for generality we take a bitmask of all of them.
4386
-   WORD_OFFSET is the offset in bits from the start of the insn of the value.
4387
-   WORD_LENGTH is the length of the word in bits in which the value resides.
4388
-   START is the starting bit number in the word, architecture origin.
4389
-   LENGTH is the length of VALUE in bits.
4390
-   TOTAL_LENGTH is the total length of the insn in bits.
4391
-
4392
-   Returns 1 for success, 0 for failure.  */
4393
-
4394
-/* ??? The return code isn't properly used.  wip.  */
4395
-
4396
-/* ??? This doesn't handle bfd_vma's.  Create another function when
4397
-   necessary.  */
4398
-
4399
-static int
4400
-extract_normal (CGEN_CPU_DESC cd,
4401
-#if ! CGEN_INT_INSN_P
4402
-               CGEN_EXTRACT_INFO *ex_info,
4403
-#else
4404
-               CGEN_EXTRACT_INFO *ex_info ATTRIBUTE_UNUSED,
4405
-#endif
4406
-               CGEN_INSN_INT insn_value,
4407
-               unsigned int attrs,
4408
-               unsigned int word_offset,
4409
-               unsigned int start,
4410
-               unsigned int length,
4411
-               unsigned int word_length,
4412
-               unsigned int total_length,
4413
-#if ! CGEN_INT_INSN_P
4414
-               bfd_vma pc,
4415
-#else
4416
-               bfd_vma pc ATTRIBUTE_UNUSED,
4417
-#endif
4418
-               long *valuep)
4419
-{
4420
-  long value, mask;
4421
-
4422
-  /* If LENGTH is zero, this operand doesn't contribute to the value
4423
-     so give it a standard value of zero.  */
4424
-  if (length == 0)
4425
-    {
4426
-      *valuep = 0;
4427
-      return 1;
4428
-    }
4429
-
4430
-#if 0
4431
-  if (CGEN_INT_INSN_P
4432
-      && word_offset != 0)
4433
-    abort ();
4434
-#endif
4435
-
4436
-  if (word_length > 32)
4437
-    abort ();
4438
-
4439
-  /* For architectures with insns smaller than the insn-base-bitsize,
4440
-     word_length may be too big.  */
4441
-  if (cd->min_insn_bitsize < cd->base_insn_bitsize)
4442
-    {
4443
-      if (word_offset == 0
4444
-         && word_length > total_length)
4445
-       word_length = total_length;
4446
-    }
4447
-
4448
-  /* Does the value reside in INSN_VALUE, and at the right alignment?  */
4449
-
4450
-  if (CGEN_INT_INSN_P || (word_offset == 0 && word_length == total_length))
4451
-    {
4452
-      if (CGEN_INSN_LSB0_P)
4453
-       value = insn_value >> ((word_offset + start + 1) - length);
4454
-      else
4455
-       value = insn_value >> (total_length - ( word_offset + start + length));
4456
-    }
4457
-
4458
-#if ! CGEN_INT_INSN_P
4459
-
4460
-  else
4461
-    {
4462
-      unsigned char *bufp = ex_info->insn_bytes + word_offset / 8;
4463
-
4464
-      if (word_length > 32)
4465
-       abort ();
4466
-
4467
-      if (fill_cache (cd, ex_info, word_offset / 8, word_length / 8, pc) == 0)
4468
-       return 0;
4469
-
4470
-      value = extract_1 (cd, ex_info, start, length, word_length, bufp, pc);
4471
-    }
4472
-
4473
-#endif /* ! CGEN_INT_INSN_P */
4474
-
4475
-  /* Written this way to avoid undefined behaviour.  */
4476
-  mask = (((1L << (length - 1)) - 1) << 1) | 1;
4477
-
4478
-  value &= mask;
4479
-  /* sign extend? */
4480
-  if (CGEN_BOOL_ATTR (attrs, CGEN_IFLD_SIGNED)
4481
-      && (value & (1L << (length - 1))))
4482
-    value |= ~mask;
4483
-
4484
-  *valuep = value;
4485
-
4486
-  return 1;
4487
-}
4488
-
4489
-/* Default insn extractor.
4490
-
4491
-   INSN_VALUE is the first base_insn_bitsize bits, translated to host order.
4492
-   The extracted fields are stored in FIELDS.
4493
-   EX_INFO is used to handle reading variable length insns.
4494
-   Return the length of the insn in bits, or 0 if no match,
4495
-   or -1 if an error occurs fetching data (memory_error_func will have
4496
-   been called).  */
4497
-
4498
-static int
4499
-extract_insn_normal (CGEN_CPU_DESC cd,
4500
-                    const CGEN_INSN *insn,
4501
-                    CGEN_EXTRACT_INFO *ex_info,
4502
-                    CGEN_INSN_INT insn_value,
4503
-                    CGEN_FIELDS *fields,
4504
-                    bfd_vma pc)
4505
-{
4506
-  const CGEN_SYNTAX *syntax = CGEN_INSN_SYNTAX (insn);
4507
-  const CGEN_SYNTAX_CHAR_TYPE *syn;
4508
-
4509
-  CGEN_FIELDS_BITSIZE (fields) = CGEN_INSN_BITSIZE (insn);
4510
-
4511
-  CGEN_INIT_EXTRACT (cd);
4512
-
4513
-  for (syn = CGEN_SYNTAX_STRING (syntax); *syn; ++syn)
4514
-    {
4515
-      int length;
4516
-
4517
-      if (CGEN_SYNTAX_CHAR_P (*syn))
4518
-       continue;
4519
-
4520
-      length = (* cd->extract_operand) (cd, CGEN_SYNTAX_FIELD (*syn),
4521
-                                       ex_info, insn_value, fields, pc);
4522
-      if (length <= 0)
4523
-       return length;
4524
-    }
4525
-
4526
-  /* We recognized and successfully extracted this insn.  */
4527
-  return CGEN_INSN_BITSIZE (insn);
4528
-}
4529
-
4530
-/* machine generated code added here */
4531
-
4532
-const char * openrisc_cgen_insert_operand
4533
-  PARAMS ((CGEN_CPU_DESC, int, CGEN_FIELDS *, CGEN_INSN_BYTES_PTR, bfd_vma));
4534
-
4535
-/* Main entry point for operand insertion.
4536
-
4537
-   This function is basically just a big switch statement.  Earlier versions
4538
-   used tables to look up the function to use, but
4539
-   - if the table contains both assembler and disassembler functions then
4540
-     the disassembler contains much of the assembler and vice-versa,
4541
-   - there's a lot of inlining possibilities as things grow,
4542
-   - using a switch statement avoids the function call overhead.
4543
-
4544
-   This function could be moved into `parse_insn_normal', but keeping it
4545
-   separate makes clear the interface between `parse_insn_normal' and each of
4546
-   the handlers.  It's also needed by GAS to insert operands that couldn't be
4547
-   resolved during parsing.  */
4548
-
4549
-const char *
4550
-openrisc_cgen_insert_operand (cd, opindex, fields, buffer, pc)
4551
-     CGEN_CPU_DESC cd;
4552
-     int opindex;
4553
-     CGEN_FIELDS * fields;
4554
-     CGEN_INSN_BYTES_PTR buffer;
4555
-     bfd_vma pc ATTRIBUTE_UNUSED;
4556
-{
4557
-  const char * errmsg = NULL;
4558
-  unsigned int total_length = CGEN_FIELDS_BITSIZE (fields);
4559
-
4560
-  switch (opindex)
4561
-    {
4562
-    case OPENRISC_OPERAND_ABS_26 :
4563
-      {
4564
-        long value = fields->f_abs26;
4565
-        value = ((unsigned int) (pc) >> (2));
4566
-        errmsg = insert_normal (cd, value, 0|(1<<CGEN_IFLD_SIGNED)|(1<<CGEN_IFLD_ABS_ADDR), 0, 25, 26, 32, total_length, buffer);
4567
-      }
4568
-      break;
4569
-    case OPENRISC_OPERAND_DISP_26 :
4570
-      {
4571
-        long value = fields->f_disp26;
4572
-        value = ((int) (((value) - (pc))) >> (2));
4573
-        errmsg = insert_normal (cd, value, 0|(1<<CGEN_IFLD_SIGNED)|(1<<CGEN_IFLD_PCREL_ADDR), 0, 25, 26, 32, total_length, buffer);
4574
-      }
4575
-      break;
4576
-    case OPENRISC_OPERAND_HI16 :
4577
-      errmsg = insert_normal (cd, fields->f_simm16, 0|(1<<CGEN_IFLD_SIGNED), 0, 15, 16, 32, total_length, buffer);
4578
-      break;
4579
-    case OPENRISC_OPERAND_LO16 :
4580
-      errmsg = insert_normal (cd, fields->f_lo16, 0|(1<<CGEN_IFLD_SIGNED), 0, 15, 16, 32, total_length, buffer);
4581
-      break;
4582
-    case OPENRISC_OPERAND_OP_F_23 :
4583
-      errmsg = insert_normal (cd, fields->f_op4, 0, 0, 23, 3, 32, total_length, buffer);
4584
-      break;
4585
-    case OPENRISC_OPERAND_OP_F_3 :
4586
-      errmsg = insert_normal (cd, fields->f_op5, 0, 0, 25, 5, 32, total_length, buffer);
4587
-      break;
4588
-    case OPENRISC_OPERAND_RA :
4589
-      errmsg = insert_normal (cd, fields->f_r2, 0, 0, 20, 5, 32, total_length, buffer);
4590
-      break;
4591
-    case OPENRISC_OPERAND_RB :
4592
-      errmsg = insert_normal (cd, fields->f_r3, 0, 0, 15, 5, 32, total_length, buffer);
4593
-      break;
4594
-    case OPENRISC_OPERAND_RD :
4595
-      errmsg = insert_normal (cd, fields->f_r1, 0, 0, 25, 5, 32, total_length, buffer);
4596
-      break;
4597
-    case OPENRISC_OPERAND_SIMM_16 :
4598
-      errmsg = insert_normal (cd, fields->f_simm16, 0|(1<<CGEN_IFLD_SIGNED), 0, 15, 16, 32, total_length, buffer);
4599
-      break;
4600
-    case OPENRISC_OPERAND_UI16NC :
4601
-      {
4602
-{
4603
-  FLD (f_i16_2) = ((((unsigned int) (FLD (f_i16nc)) >> (11))) & (31));
4604
-  FLD (f_i16_1) = ((FLD (f_i16nc)) & (2047));
4605
-}
4606
-        errmsg = insert_normal (cd, fields->f_i16_1, 0, 0, 10, 11, 32, total_length, buffer);
4607
-        if (errmsg)
4608
-          break;
4609
-        errmsg = insert_normal (cd, fields->f_i16_2, 0, 0, 25, 5, 32, total_length, buffer);
4610
-        if (errmsg)
4611
-          break;
4612
-      }
4613
-      break;
4614
-    case OPENRISC_OPERAND_UIMM_16 :
4615
-      errmsg = insert_normal (cd, fields->f_uimm16, 0, 0, 15, 16, 32, total_length, buffer);
4616
-      break;
4617
-    case OPENRISC_OPERAND_UIMM_5 :
4618
-      errmsg = insert_normal (cd, fields->f_uimm5, 0, 0, 4, 5, 32, total_length, buffer);
4619
-      break;
4620
-
4621
-    default :
4622
-      /* xgettext:c-format */
4623
-      fprintf (stderr, _("Unrecognized field %d while building insn.\n"),
4624
-              opindex);
4625
-      abort ();
4626
-  }
4627
-
4628
-  return errmsg;
4629
-}
4630
-
4631
-int openrisc_cgen_extract_operand
4632
-  PARAMS ((CGEN_CPU_DESC, int, CGEN_EXTRACT_INFO *, CGEN_INSN_INT,
4633
-           CGEN_FIELDS *, bfd_vma));
4634
-
4635
-/* Main entry point for operand extraction.
4636
-   The result is <= 0 for error, >0 for success.
4637
-   ??? Actual values aren't well defined right now.
4638
-
4639
-   This function is basically just a big switch statement.  Earlier versions
4640
-   used tables to look up the function to use, but
4641
-   - if the table contains both assembler and disassembler functions then
4642
-     the disassembler contains much of the assembler and vice-versa,
4643
-   - there's a lot of inlining possibilities as things grow,
4644
-   - using a switch statement avoids the function call overhead.
4645
-
4646
-   This function could be moved into `print_insn_normal', but keeping it
4647
-   separate makes clear the interface between `print_insn_normal' and each of
4648
-   the handlers.  */
4649
-
4650
-int
4651
-openrisc_cgen_extract_operand (cd, opindex, ex_info, insn_value, fields, pc)
4652
-     CGEN_CPU_DESC cd;
4653
-     int opindex;
4654
-     CGEN_EXTRACT_INFO *ex_info;
4655
-     CGEN_INSN_INT insn_value;
4656
-     CGEN_FIELDS * fields;
4657
-     bfd_vma pc;
4658
-{
4659
-  /* Assume success (for those operands that are nops).  */
4660
-  int length = 1;
4661
-  unsigned int total_length = CGEN_FIELDS_BITSIZE (fields);
4662
-
4663
-  switch (opindex)
4664
-    {
4665
-    case OPENRISC_OPERAND_ABS_26 :
4666
-      {
4667
-        long value;
4668
-        length = extract_normal (cd, ex_info, insn_value, 0|(1<<CGEN_IFLD_SIGNED)|(1<<CGEN_IFLD_ABS_ADDR), 0, 25, 26, 32, total_length, pc, & value);
4669
-        value = ((value) << (2));
4670
-        fields->f_abs26 = value;
4671
-      }
4672
-      break;
4673
-    case OPENRISC_OPERAND_DISP_26 :
4674
-      {
4675
-        long value;
4676
-        length = extract_normal (cd, ex_info, insn_value, 0|(1<<CGEN_IFLD_SIGNED)|(1<<CGEN_IFLD_PCREL_ADDR), 0, 25, 26, 32, total_length, pc, & value);
4677
-        value = ((((value) << (2))) + (pc));
4678
-        fields->f_disp26 = value;
4679
-      }
4680
-      break;
4681
-    case OPENRISC_OPERAND_HI16 :
4682
-      length = extract_normal (cd, ex_info, insn_value, 0|(1<<CGEN_IFLD_SIGNED), 0, 15, 16, 32, total_length, pc, & fields->f_simm16);
4683
-      break;
4684
-    case OPENRISC_OPERAND_LO16 :
4685
-      length = extract_normal (cd, ex_info, insn_value, 0|(1<<CGEN_IFLD_SIGNED), 0, 15, 16, 32, total_length, pc, & fields->f_lo16);
4686
-      break;
4687
-    case OPENRISC_OPERAND_OP_F_23 :
4688
-      length = extract_normal (cd, ex_info, insn_value, 0, 0, 23, 3, 32, total_length, pc, & fields->f_op4);
4689
-      break;
4690
-    case OPENRISC_OPERAND_OP_F_3 :
4691
-      length = extract_normal (cd, ex_info, insn_value, 0, 0, 25, 5, 32, total_length, pc, & fields->f_op5);
4692
-      break;
4693
-    case OPENRISC_OPERAND_RA :
4694
-      length = extract_normal (cd, ex_info, insn_value, 0, 0, 20, 5, 32, total_length, pc, & fields->f_r2);
4695
-      break;
4696
-    case OPENRISC_OPERAND_RB :
4697
-      length = extract_normal (cd, ex_info, insn_value, 0, 0, 15, 5, 32, total_length, pc, & fields->f_r3);
4698
-      break;
4699
-    case OPENRISC_OPERAND_RD :
4700
-      length = extract_normal (cd, ex_info, insn_value, 0, 0, 25, 5, 32, total_length, pc, & fields->f_r1);
4701
-      break;
4702
-    case OPENRISC_OPERAND_SIMM_16 :
4703
-      length = extract_normal (cd, ex_info, insn_value, 0|(1<<CGEN_IFLD_SIGNED), 0, 15, 16, 32, total_length, pc, & fields->f_simm16);
4704
-      break;
4705
-    case OPENRISC_OPERAND_UI16NC :
4706
-      {
4707
-        length = extract_normal (cd, ex_info, insn_value, 0, 0, 10, 11, 32, total_length, pc, & fields->f_i16_1);
4708
-        if (length <= 0) break;
4709
-        length = extract_normal (cd, ex_info, insn_value, 0, 0, 25, 5, 32, total_length, pc, & fields->f_i16_2);
4710
-        if (length <= 0) break;
4711
-{
4712
-  FLD (f_i16nc) = openrisc_sign_extend_16bit (((((FLD (f_i16_2)) << (11))) | (FLD (f_i16_1))));
4713
-}
4714
-      }
4715
-      break;
4716
-    case OPENRISC_OPERAND_UIMM_16 :
4717
-      length = extract_normal (cd, ex_info, insn_value, 0, 0, 15, 16, 32, total_length, pc, & fields->f_uimm16);
4718
-      break;
4719
-    case OPENRISC_OPERAND_UIMM_5 :
4720
-      length = extract_normal (cd, ex_info, insn_value, 0, 0, 4, 5, 32, total_length, pc, & fields->f_uimm5);
4721
-      break;
4722
-
4723
-    default :
4724
-      /* xgettext:c-format */
4725
-      fprintf (stderr, _("Unrecognized field %d while decoding insn.\n"),
4726
-              opindex);
4727
-      abort ();
4728
-    }
4729
-
4730
-  return length;
4731
-}
4732
-
4733
-cgen_insert_fn * const openrisc_cgen_insert_handlers[] =
4734
-{
4735
-  insert_insn_normal,
4736
-};
4737
-
4738
-cgen_extract_fn * const openrisc_cgen_extract_handlers[] =
4739
-{
4740
-  extract_insn_normal,
4741
-};
4742
-
4743
-int openrisc_cgen_get_int_operand
4744
-  PARAMS ((CGEN_CPU_DESC, int, const CGEN_FIELDS *));
4745
-bfd_vma openrisc_cgen_get_vma_operand
4746
-  PARAMS ((CGEN_CPU_DESC, int, const CGEN_FIELDS *));
4747
-
4748
-/* Getting values from cgen_fields is handled by a collection of functions.
4749
-   They are distinguished by the type of the VALUE argument they return.
4750
-   TODO: floating point, inlining support, remove cases where result type
4751
-   not appropriate.  */
4752
-
4753
-int
4754
-openrisc_cgen_get_int_operand (cd, opindex, fields)
4755
-     CGEN_CPU_DESC cd ATTRIBUTE_UNUSED;
4756
-     int opindex;
4757
-     const CGEN_FIELDS * fields;
4758
-{
4759
-  int value;
4760
-
4761
-  switch (opindex)
4762
-    {
4763
-    case OPENRISC_OPERAND_ABS_26 :
4764
-      value = fields->f_abs26;
4765
-      break;
4766
-    case OPENRISC_OPERAND_DISP_26 :
4767
-      value = fields->f_disp26;
4768
-      break;
4769
-    case OPENRISC_OPERAND_HI16 :
4770
-      value = fields->f_simm16;
4771
-      break;
4772
-    case OPENRISC_OPERAND_LO16 :
4773
-      value = fields->f_lo16;
4774
-      break;
4775
-    case OPENRISC_OPERAND_OP_F_23 :
4776
-      value = fields->f_op4;
4777
-      break;
4778
-    case OPENRISC_OPERAND_OP_F_3 :
4779
-      value = fields->f_op5;
4780
-      break;
4781
-    case OPENRISC_OPERAND_RA :
4782
-      value = fields->f_r2;
4783
-      break;
4784
-    case OPENRISC_OPERAND_RB :
4785
-      value = fields->f_r3;
4786
-      break;
4787
-    case OPENRISC_OPERAND_RD :
4788
-      value = fields->f_r1;
4789
-      break;
4790
-    case OPENRISC_OPERAND_SIMM_16 :
4791
-      value = fields->f_simm16;
4792
-      break;
4793
-    case OPENRISC_OPERAND_UI16NC :
4794
-      value = fields->f_i16nc;
4795
-      break;
4796
-    case OPENRISC_OPERAND_UIMM_16 :
4797
-      value = fields->f_uimm16;
4798
-      break;
4799
-    case OPENRISC_OPERAND_UIMM_5 :
4800
-      value = fields->f_uimm5;
4801
-      break;
4802
-
4803
-    default :
4804
-      /* xgettext:c-format */
4805
-      fprintf (stderr, _("Unrecognized field %d while getting int operand.\n"),
4806
-                      opindex);
4807
-      abort ();
4808
-  }
4809
-
4810
-  return value;
4811
-}
4812
-
4813
-bfd_vma
4814
-openrisc_cgen_get_vma_operand (cd, opindex, fields)
4815
-     CGEN_CPU_DESC cd ATTRIBUTE_UNUSED;
4816
-     int opindex;
4817
-     const CGEN_FIELDS * fields;
4818
-{
4819
-  bfd_vma value;
4820
-
4821
-  switch (opindex)
4822
-    {
4823
-    case OPENRISC_OPERAND_ABS_26 :
4824
-      value = fields->f_abs26;
4825
-      break;
4826
-    case OPENRISC_OPERAND_DISP_26 :
4827
-      value = fields->f_disp26;
4828
-      break;
4829
-    case OPENRISC_OPERAND_HI16 :
4830
-      value = fields->f_simm16;
4831
-      break;
4832
-    case OPENRISC_OPERAND_LO16 :
4833
-      value = fields->f_lo16;
4834
-      break;
4835
-    case OPENRISC_OPERAND_OP_F_23 :
4836
-      value = fields->f_op4;
4837
-      break;
4838
-    case OPENRISC_OPERAND_OP_F_3 :
4839
-      value = fields->f_op5;
4840
-      break;
4841
-    case OPENRISC_OPERAND_RA :
4842
-      value = fields->f_r2;
4843
-      break;
4844
-    case OPENRISC_OPERAND_RB :
4845
-      value = fields->f_r3;
4846
-      break;
4847
-    case OPENRISC_OPERAND_RD :
4848
-      value = fields->f_r1;
4849
-      break;
4850
-    case OPENRISC_OPERAND_SIMM_16 :
4851
-      value = fields->f_simm16;
4852
-      break;
4853
-    case OPENRISC_OPERAND_UI16NC :
4854
-      value = fields->f_i16nc;
4855
-      break;
4856
-    case OPENRISC_OPERAND_UIMM_16 :
4857
-      value = fields->f_uimm16;
4858
-      break;
4859
-    case OPENRISC_OPERAND_UIMM_5 :
4860
-      value = fields->f_uimm5;
4861
-      break;
4862
-
4863
-    default :
4864
-      /* xgettext:c-format */
4865
-      fprintf (stderr, _("Unrecognized field %d while getting vma operand.\n"),
4866
-                      opindex);
4867
-      abort ();
4868
-  }
4869
-
4870
-  return value;
4871
-}
4872
-
4873
-void openrisc_cgen_set_int_operand
4874
-  PARAMS ((CGEN_CPU_DESC, int, CGEN_FIELDS *, int));
4875
-void openrisc_cgen_set_vma_operand
4876
-  PARAMS ((CGEN_CPU_DESC, int, CGEN_FIELDS *, bfd_vma));
4877
-
4878
-/* Stuffing values in cgen_fields is handled by a collection of functions.
4879
-   They are distinguished by the type of the VALUE argument they accept.
4880
-   TODO: floating point, inlining support, remove cases where argument type
4881
-   not appropriate.  */
4882
-
4883
-void
4884
-openrisc_cgen_set_int_operand (cd, opindex, fields, value)
4885
-     CGEN_CPU_DESC cd ATTRIBUTE_UNUSED;
4886
-     int opindex;
4887
-     CGEN_FIELDS * fields;
4888
-     int value;
4889
-{
4890
-  switch (opindex)
4891
-    {
4892
-    case OPENRISC_OPERAND_ABS_26 :
4893
-      fields->f_abs26 = value;
4894
-      break;
4895
-    case OPENRISC_OPERAND_DISP_26 :
4896
-      fields->f_disp26 = value;
4897
-      break;
4898
-    case OPENRISC_OPERAND_HI16 :
4899
-      fields->f_simm16 = value;
4900
-      break;
4901
-    case OPENRISC_OPERAND_LO16 :
4902
-      fields->f_lo16 = value;
4903
-      break;
4904
-    case OPENRISC_OPERAND_OP_F_23 :
4905
-      fields->f_op4 = value;
4906
-      break;
4907
-    case OPENRISC_OPERAND_OP_F_3 :
4908
-      fields->f_op5 = value;
4909
-      break;
4910
-    case OPENRISC_OPERAND_RA :
4911
-      fields->f_r2 = value;
4912
-      break;
4913
-    case OPENRISC_OPERAND_RB :
4914
-      fields->f_r3 = value;
4915
-      break;
4916
-    case OPENRISC_OPERAND_RD :
4917
-      fields->f_r1 = value;
4918
-      break;
4919
-    case OPENRISC_OPERAND_SIMM_16 :
4920
-      fields->f_simm16 = value;
4921
-      break;
4922
-    case OPENRISC_OPERAND_UI16NC :
4923
-      fields->f_i16nc = value;
4924
-      break;
4925
-    case OPENRISC_OPERAND_UIMM_16 :
4926
-      fields->f_uimm16 = value;
4927
-      break;
4928
-    case OPENRISC_OPERAND_UIMM_5 :
4929
-      fields->f_uimm5 = value;
4930
-      break;
4931
-
4932
-    default :
4933
-      /* xgettext:c-format */
4934
-      fprintf (stderr, _("Unrecognized field %d while setting int operand.\n"),
4935
-                      opindex);
4936
-      abort ();
4937
-  }
4938
-}
4939
-
4940
-void
4941
-openrisc_cgen_set_vma_operand (cd, opindex, fields, value)
4942
-     CGEN_CPU_DESC cd ATTRIBUTE_UNUSED;
4943
-     int opindex;
4944
-     CGEN_FIELDS * fields;
4945
-     bfd_vma value;
4946
-{
4947
-  switch (opindex)
4948
-    {
4949
-    case OPENRISC_OPERAND_ABS_26 :
4950
-      fields->f_abs26 = value;
4951
-      break;
4952
-    case OPENRISC_OPERAND_DISP_26 :
4953
-      fields->f_disp26 = value;
4954
-      break;
4955
-    case OPENRISC_OPERAND_HI16 :
4956
-      fields->f_simm16 = value;
4957
-      break;
4958
-    case OPENRISC_OPERAND_LO16 :
4959
-      fields->f_lo16 = value;
4960
-      break;
4961
-    case OPENRISC_OPERAND_OP_F_23 :
4962
-      fields->f_op4 = value;
4963
-      break;
4964
-    case OPENRISC_OPERAND_OP_F_3 :
4965
-      fields->f_op5 = value;
4966
-      break;
4967
-    case OPENRISC_OPERAND_RA :
4968
-      fields->f_r2 = value;
4969
-      break;
4970
-    case OPENRISC_OPERAND_RB :
4971
-      fields->f_r3 = value;
4972
-      break;
4973
-    case OPENRISC_OPERAND_RD :
4974
-      fields->f_r1 = value;
4975
-      break;
4976
-    case OPENRISC_OPERAND_SIMM_16 :
4977
-      fields->f_simm16 = value;
4978
-      break;
4979
-    case OPENRISC_OPERAND_UI16NC :
4980
-      fields->f_i16nc = value;
4981
-      break;
4982
-    case OPENRISC_OPERAND_UIMM_16 :
4983
-      fields->f_uimm16 = value;
4984
-      break;
4985
-    case OPENRISC_OPERAND_UIMM_5 :
4986
-      fields->f_uimm5 = value;
4987
-      break;
4988
-
4989
-    default :
4990
-      /* xgettext:c-format */
4991
-      fprintf (stderr, _("Unrecognized field %d while setting vma operand.\n"),
4992
-                      opindex);
4993
-      abort ();
4994
-  }
4995
-}
4996
-
4997
-/* Function to call before using the instruction builder tables.  */
4998
-
4999
-void
5000
-openrisc_cgen_init_ibld_table (cd)
5001
-     CGEN_CPU_DESC cd;
5002
-{
5003
-  cd->insert_handlers = & openrisc_cgen_insert_handlers[0];
5004
-  cd->extract_handlers = & openrisc_cgen_extract_handlers[0];
5005
-
5006
-  cd->insert_operand = openrisc_cgen_insert_operand;
5007
-  cd->extract_operand = openrisc_cgen_extract_operand;
5008
-
5009
-  cd->get_int_operand = openrisc_cgen_get_int_operand;
5010
-  cd->set_int_operand = openrisc_cgen_set_int_operand;
5011
-  cd->get_vma_operand = openrisc_cgen_get_vma_operand;
5012
-  cd->set_vma_operand = openrisc_cgen_set_vma_operand;
5013
-}
5014
diff --unified -N -r ../binutils-2.16.1/opcodes/openrisc-opc.c binutils-2.16.1/opcodes/openrisc-opc.c
5015
--- ../binutils-2.16.1/opcodes/openrisc-opc.c   2005-02-22 01:33:20.000000000 +0100
5016
+++ binutils-2.16.1/opcodes/openrisc-opc.c      1970-01-01 01:00:00.000000000 +0100
5017
@@ -1,707 +0,0 @@
5018
-/* Instruction opcode table for openrisc.
5019
-
5020
-THIS FILE IS MACHINE GENERATED WITH CGEN.
5021
-
5022
-Copyright 1996-2005 Free Software Foundation, Inc.
5023
-
5024
-This file is part of the GNU Binutils and/or GDB, the GNU debugger.
5025
-
5026
-This program is free software; you can redistribute it and/or modify
5027
-it under the terms of the GNU General Public License as published by
5028
-the Free Software Foundation; either version 2, or (at your option)
5029
-any later version.
5030
-
5031
-This program is distributed in the hope that it will be useful,
5032
-but WITHOUT ANY WARRANTY; without even the implied warranty of
5033
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
5034
-GNU General Public License for more details.
5035
-
5036
-You should have received a copy of the GNU General Public License along
5037
-with this program; if not, write to the Free Software Foundation, Inc.,
5038
-59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
5039
-
5040
-*/
5041
-
5042
-#include "sysdep.h"
5043
-#include "ansidecl.h"
5044
-#include "bfd.h"
5045
-#include "symcat.h"
5046
-#include "openrisc-desc.h"
5047
-#include "openrisc-opc.h"
5048
-#include "libiberty.h"
5049
-
5050
-/* -- opc.c */
5051
-/* -- */
5052
-/* The hash functions are recorded here to help keep assembler code out of
5053
-   the disassembler and vice versa.  */
5054
-
5055
-static int asm_hash_insn_p PARAMS ((const CGEN_INSN *));
5056
-static unsigned int asm_hash_insn PARAMS ((const char *));
5057
-static int dis_hash_insn_p PARAMS ((const CGEN_INSN *));
5058
-static unsigned int dis_hash_insn PARAMS ((const char *, CGEN_INSN_INT));
5059
-
5060
-/* Instruction formats.  */
5061
-
5062
-#if defined (__STDC__) || defined (ALMOST_STDC) || defined (HAVE_STRINGIZE)
5063
-#define F(f) & openrisc_cgen_ifld_table[OPENRISC_##f]
5064
-#else
5065
-#define F(f) & openrisc_cgen_ifld_table[OPENRISC_/**/f]
5066
-#endif
5067
-static const CGEN_IFMT ifmt_empty ATTRIBUTE_UNUSED = {
5068
-  0, 0, 0x0, { { 0 } }
5069
-};
5070
-
5071
-static const CGEN_IFMT ifmt_l_j ATTRIBUTE_UNUSED = {
5072
-  32, 32, 0xfc000000, { { F (F_CLASS) }, { F (F_SUB) }, { F (F_ABS26) }, { 0 } }
5073
-};
5074
-
5075
-static const CGEN_IFMT ifmt_l_jr ATTRIBUTE_UNUSED = {
5076
-  32, 32, 0xffe00000, { { F (F_CLASS) }, { F (F_SUB) }, { F (F_OP3) }, { F (F_OP4) }, { F (F_R2) }, { F (F_UIMM16) }, { 0 } }
5077
-};
5078
-
5079
-static const CGEN_IFMT ifmt_l_bal ATTRIBUTE_UNUSED = {
5080
-  32, 32, 0xfc000000, { { F (F_CLASS) }, { F (F_SUB) }, { F (F_DISP26) }, { 0 } }
5081
-};
5082
-
5083
-static const CGEN_IFMT ifmt_l_movhi ATTRIBUTE_UNUSED = {
5084
-  32, 32, 0xfc000000, { { F (F_CLASS) }, { F (F_SUB) }, { F (F_R1) }, { F (F_R2) }, { F (F_SIMM16) }, { 0 } }
5085
-};
5086
-
5087
-static const CGEN_IFMT ifmt_l_mfsr ATTRIBUTE_UNUSED = {
5088
-  32, 32, 0xfc000000, { { F (F_CLASS) }, { F (F_SUB) }, { F (F_R1) }, { F (F_R2) }, { F (F_UIMM16) }, { 0 } }
5089
-};
5090
-
5091
-static const CGEN_IFMT ifmt_l_mtsr ATTRIBUTE_UNUSED = {
5092
-  32, 32, 0xfc0007ff, { { F (F_CLASS) }, { F (F_SUB) }, { F (F_R1) }, { F (F_R2) }, { F (F_R3) }, { F (F_I16_1) }, { 0 } }
5093
-};
5094
-
5095
-static const CGEN_IFMT ifmt_l_lw ATTRIBUTE_UNUSED = {
5096
-  32, 32, 0xfc000000, { { F (F_CLASS) }, { F (F_SUB) }, { F (F_R1) }, { F (F_R2) }, { F (F_SIMM16) }, { 0 } }
5097
-};
5098
-
5099
-static const CGEN_IFMT ifmt_l_sw ATTRIBUTE_UNUSED = {
5100
-  32, 32, 0xfc000000, { { F (F_CLASS) }, { F (F_SUB) }, { F (F_R1) }, { F (F_R3) }, { F (F_I16NC) }, { 0 } }
5101
-};
5102
-
5103
-static const CGEN_IFMT ifmt_l_sll ATTRIBUTE_UNUSED = {
5104
-  32, 32, 0xfc0007ff, { { F (F_CLASS) }, { F (F_SUB) }, { F (F_R1) }, { F (F_R2) }, { F (F_R3) }, { F (F_F_10_3) }, { F (F_OP6) }, { F (F_F_4_1) }, { F (F_OP7) }, { 0 } }
5105
-};
5106
-
5107
-static const CGEN_IFMT ifmt_l_slli ATTRIBUTE_UNUSED = {
5108
-  32, 32, 0xfc00ffe0, { { F (F_CLASS) }, { F (F_SUB) }, { F (F_R1) }, { F (F_R2) }, { F (F_F_15_8) }, { F (F_OP6) }, { F (F_UIMM5) }, { 0 } }
5109
-};
5110
-
5111
-static const CGEN_IFMT ifmt_l_add ATTRIBUTE_UNUSED = {
5112
-  32, 32, 0xfc0007ff, { { F (F_CLASS) }, { F (F_SUB) }, { F (F_R1) }, { F (F_R2) }, { F (F_R3) }, { F (F_F_10_7) }, { F (F_OP7) }, { 0 } }
5113
-};
5114
-
5115
-static const CGEN_IFMT ifmt_l_addi ATTRIBUTE_UNUSED = {
5116
-  32, 32, 0xfc000000, { { F (F_CLASS) }, { F (F_SUB) }, { F (F_R1) }, { F (F_R2) }, { F (F_LO16) }, { 0 } }
5117
-};
5118
-
5119
-static const CGEN_IFMT ifmt_l_sfgts ATTRIBUTE_UNUSED = {
5120
-  32, 32, 0xffe007ff, { { F (F_CLASS) }, { F (F_SUB) }, { F (F_OP5) }, { F (F_R2) }, { F (F_R3) }, { F (F_F_10_11) }, { 0 } }
5121
-};
5122
-
5123
-static const CGEN_IFMT ifmt_l_sfgtsi ATTRIBUTE_UNUSED = {
5124
-  32, 32, 0xffe00000, { { F (F_CLASS) }, { F (F_SUB) }, { F (F_OP5) }, { F (F_R2) }, { F (F_SIMM16) }, { 0 } }
5125
-};
5126
-
5127
-static const CGEN_IFMT ifmt_l_sfgtui ATTRIBUTE_UNUSED = {
5128
-  32, 32, 0xffe00000, { { F (F_CLASS) }, { F (F_SUB) }, { F (F_OP5) }, { F (F_R2) }, { F (F_UIMM16) }, { 0 } }
5129
-};
5130
-
5131
-#undef F
5132
-
5133
-#if defined (__STDC__) || defined (ALMOST_STDC) || defined (HAVE_STRINGIZE)
5134
-#define A(a) (1 << CGEN_INSN_##a)
5135
-#else
5136
-#define A(a) (1 << CGEN_INSN_/**/a)
5137
-#endif
5138
-#if defined (__STDC__) || defined (ALMOST_STDC) || defined (HAVE_STRINGIZE)
5139
-#define OPERAND(op) OPENRISC_OPERAND_##op
5140
-#else
5141
-#define OPERAND(op) OPENRISC_OPERAND_/**/op
5142
-#endif
5143
-#define MNEM CGEN_SYNTAX_MNEMONIC /* syntax value for mnemonic */
5144
-#define OP(field) CGEN_SYNTAX_MAKE_FIELD (OPERAND (field))
5145
-
5146
-/* The instruction table.  */
5147
-
5148
-static const CGEN_OPCODE openrisc_cgen_insn_opcode_table[MAX_INSNS] =
5149
-{
5150
-  /* Special null first entry.
5151
-     A `num' value of zero is thus invalid.
5152
-     Also, the special `invalid' insn resides here.  */
5153
-  { { 0, 0, 0, 0 }, {{0}}, 0, {0}},
5154
-/* l.j ${abs-26} */
5155
-  {
5156
-    { 0, 0, 0, 0 },
5157
-    { { MNEM, ' ', OP (ABS_26), 0 } },
5158
-    & ifmt_l_j, { 0x0 }
5159
-  },
5160
-/* l.jal ${abs-26} */
5161
-  {
5162
-    { 0, 0, 0, 0 },
5163
-    { { MNEM, ' ', OP (ABS_26), 0 } },
5164
-    & ifmt_l_j, { 0x4000000 }
5165
-  },
5166
-/* l.jr $rA */
5167
-  {
5168
-    { 0, 0, 0, 0 },
5169
-    { { MNEM, ' ', OP (RA), 0 } },
5170
-    & ifmt_l_jr, { 0x14000000 }
5171
-  },
5172
-/* l.jalr $rA */
5173
-  {
5174
-    { 0, 0, 0, 0 },
5175
-    { { MNEM, ' ', OP (RA), 0 } },
5176
-    & ifmt_l_jr, { 0x14200000 }
5177
-  },
5178
-/* l.bal ${disp-26} */
5179
-  {
5180
-    { 0, 0, 0, 0 },
5181
-    { { MNEM, ' ', OP (DISP_26), 0 } },
5182
-    & ifmt_l_bal, { 0x8000000 }
5183
-  },
5184
-/* l.bnf ${disp-26} */
5185
-  {
5186
-    { 0, 0, 0, 0 },
5187
-    { { MNEM, ' ', OP (DISP_26), 0 } },
5188
-    & ifmt_l_bal, { 0xc000000 }
5189
-  },
5190
-/* l.bf ${disp-26} */
5191
-  {
5192
-    { 0, 0, 0, 0 },
5193
-    { { MNEM, ' ', OP (DISP_26), 0 } },
5194
-    & ifmt_l_bal, { 0x10000000 }
5195
-  },
5196
-/* l.brk ${uimm-16} */
5197
-  {
5198
-    { 0, 0, 0, 0 },
5199
-    { { MNEM, ' ', OP (UIMM_16), 0 } },
5200
-    & ifmt_l_jr, { 0x17000000 }
5201
-  },
5202
-/* l.rfe $rA */
5203
-  {
5204
-    { 0, 0, 0, 0 },
5205
-    { { MNEM, ' ', OP (RA), 0 } },
5206
-    & ifmt_l_jr, { 0x14400000 }
5207
-  },
5208
-/* l.sys ${uimm-16} */
5209
-  {
5210
-    { 0, 0, 0, 0 },
5211
-    { { MNEM, ' ', OP (UIMM_16), 0 } },
5212
-    & ifmt_l_jr, { 0x16000000 }
5213
-  },
5214
-/* l.nop */
5215
-  {
5216
-    { 0, 0, 0, 0 },
5217
-    { { MNEM, 0 } },
5218
-    & ifmt_l_jr, { 0x15000000 }
5219
-  },
5220
-/* l.movhi $rD,$hi16 */
5221
-  {
5222
-    { 0, 0, 0, 0 },
5223
-    { { MNEM, ' ', OP (RD), ',', OP (HI16), 0 } },
5224
-    & ifmt_l_movhi, { 0x18000000 }
5225
-  },
5226
-/* l.mfsr $rD,$rA */
5227
-  {
5228
-    { 0, 0, 0, 0 },
5229
-    { { MNEM, ' ', OP (RD), ',', OP (RA), 0 } },
5230
-    & ifmt_l_mfsr, { 0x1c000000 }
5231
-  },
5232
-/* l.mtsr $rA,$rB */
5233
-  {
5234
-    { 0, 0, 0, 0 },
5235
-    { { MNEM, ' ', OP (RA), ',', OP (RB), 0 } },
5236
-    & ifmt_l_mtsr, { 0x40000000 }
5237
-  },
5238
-/* l.lw $rD,${simm-16}($rA) */
5239
-  {
5240
-    { 0, 0, 0, 0 },
5241
-    { { MNEM, ' ', OP (RD), ',', OP (SIMM_16), '(', OP (RA), ')', 0 } },
5242
-    & ifmt_l_lw, { 0x80000000 }
5243
-  },
5244
-/* l.lbz $rD,${simm-16}($rA) */
5245
-  {
5246
-    { 0, 0, 0, 0 },
5247
-    { { MNEM, ' ', OP (RD), ',', OP (SIMM_16), '(', OP (RA), ')', 0 } },
5248
-    & ifmt_l_lw, { 0x84000000 }
5249
-  },
5250
-/* l.lbs $rD,${simm-16}($rA) */
5251
-  {
5252
-    { 0, 0, 0, 0 },
5253
-    { { MNEM, ' ', OP (RD), ',', OP (SIMM_16), '(', OP (RA), ')', 0 } },
5254
-    & ifmt_l_lw, { 0x88000000 }
5255
-  },
5256
-/* l.lhz $rD,${simm-16}($rA) */
5257
-  {
5258
-    { 0, 0, 0, 0 },
5259
-    { { MNEM, ' ', OP (RD), ',', OP (SIMM_16), '(', OP (RA), ')', 0 } },
5260
-    & ifmt_l_lw, { 0x8c000000 }
5261
-  },
5262
-/* l.lhs $rD,${simm-16}($rA) */
5263
-  {
5264
-    { 0, 0, 0, 0 },
5265
-    { { MNEM, ' ', OP (RD), ',', OP (SIMM_16), '(', OP (RA), ')', 0 } },
5266
-    & ifmt_l_lw, { 0x90000000 }
5267
-  },
5268
-/* l.sw ${ui16nc}($rA),$rB */
5269
-  {
5270
-    { 0, 0, 0, 0 },
5271
-    { { MNEM, ' ', OP (UI16NC), '(', OP (RA), ')', ',', OP (RB), 0 } },
5272
-    & ifmt_l_sw, { 0xd4000000 }
5273
-  },
5274
-/* l.sb ${ui16nc}($rA),$rB */
5275
-  {
5276
-    { 0, 0, 0, 0 },
5277
-    { { MNEM, ' ', OP (UI16NC), '(', OP (RA), ')', ',', OP (RB), 0 } },
5278
-    & ifmt_l_sw, { 0xd8000000 }
5279
-  },
5280
-/* l.sh ${ui16nc}($rA),$rB */
5281
-  {
5282
-    { 0, 0, 0, 0 },
5283
-    { { MNEM, ' ', OP (UI16NC), '(', OP (RA), ')', ',', OP (RB), 0 } },
5284
-    & ifmt_l_sw, { 0xdc000000 }
5285
-  },
5286
-/* l.sll $rD,$rA,$rB */
5287
-  {
5288
-    { 0, 0, 0, 0 },
5289
-    { { MNEM, ' ', OP (RD), ',', OP (RA), ',', OP (RB), 0 } },
5290
-    & ifmt_l_sll, { 0xe0000008 }
5291
-  },
5292
-/* l.slli $rD,$rA,${uimm-5} */
5293
-  {
5294
-    { 0, 0, 0, 0 },
5295
-    { { MNEM, ' ', OP (RD), ',', OP (RA), ',', OP (UIMM_5), 0 } },
5296
-    & ifmt_l_slli, { 0xb4000000 }
5297
-  },
5298
-/* l.srl $rD,$rA,$rB */
5299
-  {
5300
-    { 0, 0, 0, 0 },
5301
-    { { MNEM, ' ', OP (RD), ',', OP (RA), ',', OP (RB), 0 } },
5302
-    & ifmt_l_sll, { 0xe0000028 }
5303
-  },
5304
-/* l.srli $rD,$rA,${uimm-5} */
5305
-  {
5306
-    { 0, 0, 0, 0 },
5307
-    { { MNEM, ' ', OP (RD), ',', OP (RA), ',', OP (UIMM_5), 0 } },
5308
-    & ifmt_l_slli, { 0xb4000020 }
5309
-  },
5310
-/* l.sra $rD,$rA,$rB */
5311
-  {
5312
-    { 0, 0, 0, 0 },
5313
-    { { MNEM, ' ', OP (RD), ',', OP (RA), ',', OP (RB), 0 } },
5314
-    & ifmt_l_sll, { 0xe0000048 }
5315
-  },
5316
-/* l.srai $rD,$rA,${uimm-5} */
5317
-  {
5318
-    { 0, 0, 0, 0 },
5319
-    { { MNEM, ' ', OP (RD), ',', OP (RA), ',', OP (UIMM_5), 0 } },
5320
-    & ifmt_l_slli, { 0xb4000040 }
5321
-  },
5322
-/* l.ror $rD,$rA,$rB */
5323
-  {
5324
-    { 0, 0, 0, 0 },
5325
-    { { MNEM, ' ', OP (RD), ',', OP (RA), ',', OP (RB), 0 } },
5326
-    & ifmt_l_sll, { 0xe0000088 }
5327
-  },
5328
-/* l.rori $rD,$rA,${uimm-5} */
5329
-  {
5330
-    { 0, 0, 0, 0 },
5331
-    { { MNEM, ' ', OP (RD), ',', OP (RA), ',', OP (UIMM_5), 0 } },
5332
-    & ifmt_l_slli, { 0xb4000080 }
5333
-  },
5334
-/* l.add $rD,$rA,$rB */
5335
-  {
5336
-    { 0, 0, 0, 0 },
5337
-    { { MNEM, ' ', OP (RD), ',', OP (RA), ',', OP (RB), 0 } },
5338
-    & ifmt_l_add, { 0xe0000000 }
5339
-  },
5340
-/* l.addi $rD,$rA,$lo16 */
5341
-  {
5342
-    { 0, 0, 0, 0 },
5343
-    { { MNEM, ' ', OP (RD), ',', OP (RA), ',', OP (LO16), 0 } },
5344
-    & ifmt_l_addi, { 0x94000000 }
5345
-  },
5346
-/* l.sub $rD,$rA,$rB */
5347
-  {
5348
-    { 0, 0, 0, 0 },
5349
-    { { MNEM, ' ', OP (RD), ',', OP (RA), ',', OP (RB), 0 } },
5350
-    & ifmt_l_add, { 0xe0000002 }
5351
-  },
5352
-/* l.subi $rD,$rA,$lo16 */
5353
-  {
5354
-    { 0, 0, 0, 0 },
5355
-    { { MNEM, ' ', OP (RD), ',', OP (RA), ',', OP (LO16), 0 } },
5356
-    & ifmt_l_addi, { 0x9c000000 }
5357
-  },
5358
-/* l.and $rD,$rA,$rB */
5359
-  {
5360
-    { 0, 0, 0, 0 },
5361
-    { { MNEM, ' ', OP (RD), ',', OP (RA), ',', OP (RB), 0 } },
5362
-    & ifmt_l_add, { 0xe0000003 }
5363
-  },
5364
-/* l.andi $rD,$rA,$lo16 */
5365
-  {
5366
-    { 0, 0, 0, 0 },
5367
-    { { MNEM, ' ', OP (RD), ',', OP (RA), ',', OP (LO16), 0 } },
5368
-    & ifmt_l_addi, { 0xa0000000 }
5369
-  },
5370
-/* l.or $rD,$rA,$rB */
5371
-  {
5372
-    { 0, 0, 0, 0 },
5373
-    { { MNEM, ' ', OP (RD), ',', OP (RA), ',', OP (RB), 0 } },
5374
-    & ifmt_l_add, { 0xe0000004 }
5375
-  },
5376
-/* l.ori $rD,$rA,$lo16 */
5377
-  {
5378
-    { 0, 0, 0, 0 },
5379
-    { { MNEM, ' ', OP (RD), ',', OP (RA), ',', OP (LO16), 0 } },
5380
-    & ifmt_l_addi, { 0xa4000000 }
5381
-  },
5382
-/* l.xor $rD,$rA,$rB */
5383
-  {
5384
-    { 0, 0, 0, 0 },
5385
-    { { MNEM, ' ', OP (RD), ',', OP (RA), ',', OP (RB), 0 } },
5386
-    & ifmt_l_add, { 0xe0000005 }
5387
-  },
5388
-/* l.xori $rD,$rA,$lo16 */
5389
-  {
5390
-    { 0, 0, 0, 0 },
5391
-    { { MNEM, ' ', OP (RD), ',', OP (RA), ',', OP (LO16), 0 } },
5392
-    & ifmt_l_addi, { 0xa8000000 }
5393
-  },
5394
-/* l.mul $rD,$rA,$rB */
5395
-  {
5396
-    { 0, 0, 0, 0 },
5397
-    { { MNEM, ' ', OP (RD), ',', OP (RA), ',', OP (RB), 0 } },
5398
-    & ifmt_l_add, { 0xe0000006 }
5399
-  },
5400
-/* l.muli $rD,$rA,$lo16 */
5401
-  {
5402
-    { 0, 0, 0, 0 },
5403
-    { { MNEM, ' ', OP (RD), ',', OP (RA), ',', OP (LO16), 0 } },
5404
-    & ifmt_l_addi, { 0xac000000 }
5405
-  },
5406
-/* l.div $rD,$rA,$rB */
5407
-  {
5408
-    { 0, 0, 0, 0 },
5409
-    { { MNEM, ' ', OP (RD), ',', OP (RA), ',', OP (RB), 0 } },
5410
-    & ifmt_l_add, { 0xe0000009 }
5411
-  },
5412
-/* l.divu $rD,$rA,$rB */
5413
-  {
5414
-    { 0, 0, 0, 0 },
5415
-    { { MNEM, ' ', OP (RD), ',', OP (RA), ',', OP (RB), 0 } },
5416
-    & ifmt_l_add, { 0xe000000a }
5417
-  },
5418
-/* l.sfgts $rA,$rB */
5419
-  {
5420
-    { 0, 0, 0, 0 },
5421
-    { { MNEM, ' ', OP (RA), ',', OP (RB), 0 } },
5422
-    & ifmt_l_sfgts, { 0xe4c00000 }
5423
-  },
5424
-/* l.sfgtu $rA,$rB */
5425
-  {
5426
-    { 0, 0, 0, 0 },
5427
-    { { MNEM, ' ', OP (RA), ',', OP (RB), 0 } },
5428
-    & ifmt_l_sfgts, { 0xe4400000 }
5429
-  },
5430
-/* l.sfges $rA,$rB */
5431
-  {
5432
-    { 0, 0, 0, 0 },
5433
-    { { MNEM, ' ', OP (RA), ',', OP (RB), 0 } },
5434
-    & ifmt_l_sfgts, { 0xe4e00000 }
5435
-  },
5436
-/* l.sfgeu $rA,$rB */
5437
-  {
5438
-    { 0, 0, 0, 0 },
5439
-    { { MNEM, ' ', OP (RA), ',', OP (RB), 0 } },
5440
-    & ifmt_l_sfgts, { 0xe4600000 }
5441
-  },
5442
-/* l.sflts $rA,$rB */
5443
-  {
5444
-    { 0, 0, 0, 0 },
5445
-    { { MNEM, ' ', OP (RA), ',', OP (RB), 0 } },
5446
-    & ifmt_l_sfgts, { 0xe5000000 }
5447
-  },
5448
-/* l.sfltu $rA,$rB */
5449
-  {
5450
-    { 0, 0, 0, 0 },
5451
-    { { MNEM, ' ', OP (RA), ',', OP (RB), 0 } },
5452
-    & ifmt_l_sfgts, { 0xe4800000 }
5453
-  },
5454
-/* l.sfles $rA,$rB */
5455
-  {
5456
-    { 0, 0, 0, 0 },
5457
-    { { MNEM, ' ', OP (RA), ',', OP (RB), 0 } },
5458
-    & ifmt_l_sfgts, { 0xe5200000 }
5459
-  },
5460
-/* l.sfleu $rA,$rB */
5461
-  {
5462
-    { 0, 0, 0, 0 },
5463
-    { { MNEM, ' ', OP (RA), ',', OP (RB), 0 } },
5464
-    & ifmt_l_sfgts, { 0xe4a00000 }
5465
-  },
5466
-/* l.sfgtsi $rA,${simm-16} */
5467
-  {
5468
-    { 0, 0, 0, 0 },
5469
-    { { MNEM, ' ', OP (RA), ',', OP (SIMM_16), 0 } },
5470
-    & ifmt_l_sfgtsi, { 0xb8c00000 }
5471
-  },
5472
-/* l.sfgtui $rA,${uimm-16} */
5473
-  {
5474
-    { 0, 0, 0, 0 },
5475
-    { { MNEM, ' ', OP (RA), ',', OP (UIMM_16), 0 } },
5476
-    & ifmt_l_sfgtui, { 0xb8400000 }
5477
-  },
5478
-/* l.sfgesi $rA,${simm-16} */
5479
-  {
5480
-    { 0, 0, 0, 0 },
5481
-    { { MNEM, ' ', OP (RA), ',', OP (SIMM_16), 0 } },
5482
-    & ifmt_l_sfgtsi, { 0xb8e00000 }
5483
-  },
5484
-/* l.sfgeui $rA,${uimm-16} */
5485
-  {
5486
-    { 0, 0, 0, 0 },
5487
-    { { MNEM, ' ', OP (RA), ',', OP (UIMM_16), 0 } },
5488
-    & ifmt_l_sfgtui, { 0xb8600000 }
5489
-  },
5490
-/* l.sfltsi $rA,${simm-16} */
5491
-  {
5492
-    { 0, 0, 0, 0 },
5493
-    { { MNEM, ' ', OP (RA), ',', OP (SIMM_16), 0 } },
5494
-    & ifmt_l_sfgtsi, { 0xb9000000 }
5495
-  },
5496
-/* l.sfltui $rA,${uimm-16} */
5497
-  {
5498
-    { 0, 0, 0, 0 },
5499
-    { { MNEM, ' ', OP (RA), ',', OP (UIMM_16), 0 } },
5500
-    & ifmt_l_sfgtui, { 0xb8800000 }
5501
-  },
5502
-/* l.sflesi $rA,${simm-16} */
5503
-  {
5504
-    { 0, 0, 0, 0 },
5505
-    { { MNEM, ' ', OP (RA), ',', OP (SIMM_16), 0 } },
5506
-    & ifmt_l_sfgtsi, { 0xb9200000 }
5507
-  },
5508
-/* l.sfleui $rA,${uimm-16} */
5509
-  {
5510
-    { 0, 0, 0, 0 },
5511
-    { { MNEM, ' ', OP (RA), ',', OP (UIMM_16), 0 } },
5512
-    & ifmt_l_sfgtui, { 0xb8a00000 }
5513
-  },
5514
-/* l.sfeq $rA,$rB */
5515
-  {
5516
-    { 0, 0, 0, 0 },
5517
-    { { MNEM, ' ', OP (RA), ',', OP (RB), 0 } },
5518
-    & ifmt_l_sfgts, { 0xe4000000 }
5519
-  },
5520
-/* l.sfeqi $rA,${simm-16} */
5521
-  {
5522
-    { 0, 0, 0, 0 },
5523
-    { { MNEM, ' ', OP (RA), ',', OP (SIMM_16), 0 } },
5524
-    & ifmt_l_sfgtsi, { 0xb8000000 }
5525
-  },
5526
-/* l.sfne $rA,$rB */
5527
-  {
5528
-    { 0, 0, 0, 0 },
5529
-    { { MNEM, ' ', OP (RA), ',', OP (RB), 0 } },
5530
-    & ifmt_l_sfgts, { 0xe4200000 }
5531
-  },
5532
-/* l.sfnei $rA,${simm-16} */
5533
-  {
5534
-    { 0, 0, 0, 0 },
5535
-    { { MNEM, ' ', OP (RA), ',', OP (SIMM_16), 0 } },
5536
-    & ifmt_l_sfgtsi, { 0xb8200000 }
5537
-  },
5538
-};
5539
-
5540
-#undef A
5541
-#undef OPERAND
5542
-#undef MNEM
5543
-#undef OP
5544
-
5545
-/* Formats for ALIAS macro-insns.  */
5546
-
5547
-#if defined (__STDC__) || defined (ALMOST_STDC) || defined (HAVE_STRINGIZE)
5548
-#define F(f) & openrisc_cgen_ifld_table[OPENRISC_##f]
5549
-#else
5550
-#define F(f) & openrisc_cgen_ifld_table[OPENRISC_/**/f]
5551
-#endif
5552
-static const CGEN_IFMT ifmt_l_ret ATTRIBUTE_UNUSED = {
5553
-  32, 32, 0xffffffff, { { F (F_CLASS) }, { F (F_SUB) }, { F (F_OP3) }, { F (F_OP4) }, { F (F_R2) }, { F (F_UIMM16) }, { 0 } }
5554
-};
5555
-
5556
-#undef F
5557
-
5558
-/* Each non-simple macro entry points to an array of expansion possibilities.  */
5559
-
5560
-#if defined (__STDC__) || defined (ALMOST_STDC) || defined (HAVE_STRINGIZE)
5561
-#define A(a) (1 << CGEN_INSN_##a)
5562
-#else
5563
-#define A(a) (1 << CGEN_INSN_/**/a)
5564
-#endif
5565
-#if defined (__STDC__) || defined (ALMOST_STDC) || defined (HAVE_STRINGIZE)
5566
-#define OPERAND(op) OPENRISC_OPERAND_##op
5567
-#else
5568
-#define OPERAND(op) OPENRISC_OPERAND_/**/op
5569
-#endif
5570
-#define MNEM CGEN_SYNTAX_MNEMONIC /* syntax value for mnemonic */
5571
-#define OP(field) CGEN_SYNTAX_MAKE_FIELD (OPERAND (field))
5572
-
5573
-/* The macro instruction table.  */
5574
-
5575
-static const CGEN_IBASE openrisc_cgen_macro_insn_table[] =
5576
-{
5577
-/* l.ret */
5578
-  {
5579
-    -1, "l-ret", "l.ret", 32,
5580
-    { 0|A(ALIAS), { (1<<MACH_BASE) } }
5581
-  },
5582
-};
5583
-
5584
-/* The macro instruction opcode table.  */
5585
-
5586
-static const CGEN_OPCODE openrisc_cgen_macro_insn_opcode_table[] =
5587
-{
5588
-/* l.ret */
5589
-  {
5590
-    { 0, 0, 0, 0 },
5591
-    { { MNEM, 0 } },
5592
-    & ifmt_l_ret, { 0x140b0000 }
5593
-  },
5594
-};
5595
-
5596
-#undef A
5597
-#undef OPERAND
5598
-#undef MNEM
5599
-#undef OP
5600
-
5601
-#ifndef CGEN_ASM_HASH_P
5602
-#define CGEN_ASM_HASH_P(insn) 1
5603
-#endif
5604
-
5605
-#ifndef CGEN_DIS_HASH_P
5606
-#define CGEN_DIS_HASH_P(insn) 1
5607
-#endif
5608
-
5609
-/* Return non-zero if INSN is to be added to the hash table.
5610
-   Targets are free to override CGEN_{ASM,DIS}_HASH_P in the .opc file.  */
5611
-
5612
-static int
5613
-asm_hash_insn_p (insn)
5614
-     const CGEN_INSN *insn ATTRIBUTE_UNUSED;
5615
-{
5616
-  return CGEN_ASM_HASH_P (insn);
5617
-}
5618
-
5619
-static int
5620
-dis_hash_insn_p (insn)
5621
-     const CGEN_INSN *insn;
5622
-{
5623
-  /* If building the hash table and the NO-DIS attribute is present,
5624
-     ignore.  */
5625
-  if (CGEN_INSN_ATTR_VALUE (insn, CGEN_INSN_NO_DIS))
5626
-    return 0;
5627
-  return CGEN_DIS_HASH_P (insn);
5628
-}
5629
-
5630
-#ifndef CGEN_ASM_HASH
5631
-#define CGEN_ASM_HASH_SIZE 127
5632
-#ifdef CGEN_MNEMONIC_OPERANDS
5633
-#define CGEN_ASM_HASH(mnem) (*(unsigned char *) (mnem) % CGEN_ASM_HASH_SIZE)
5634
-#else
5635
-#define CGEN_ASM_HASH(mnem) (*(unsigned char *) (mnem) % CGEN_ASM_HASH_SIZE) /*FIXME*/
5636
-#endif
5637
-#endif
5638
-
5639
-/* It doesn't make much sense to provide a default here,
5640
-   but while this is under development we do.
5641
-   BUFFER is a pointer to the bytes of the insn, target order.
5642
-   VALUE is the first base_insn_bitsize bits as an int in host order.  */
5643
-
5644
-#ifndef CGEN_DIS_HASH
5645
-#define CGEN_DIS_HASH_SIZE 256
5646
-#define CGEN_DIS_HASH(buf, value) (*(unsigned char *) (buf))
5647
-#endif
5648
-
5649
-/* The result is the hash value of the insn.
5650
-   Targets are free to override CGEN_{ASM,DIS}_HASH in the .opc file.  */
5651
-
5652
-static unsigned int
5653
-asm_hash_insn (mnem)
5654
-     const char * mnem;
5655
-{
5656
-  return CGEN_ASM_HASH (mnem);
5657
-}
5658
-
5659
-/* BUF is a pointer to the bytes of the insn, target order.
5660
-   VALUE is the first base_insn_bitsize bits as an int in host order.  */
5661
-
5662
-static unsigned int
5663
-dis_hash_insn (buf, value)
5664
-     const char * buf ATTRIBUTE_UNUSED;
5665
-     CGEN_INSN_INT value ATTRIBUTE_UNUSED;
5666
-{
5667
-  return CGEN_DIS_HASH (buf, value);
5668
-}
5669
-
5670
-static void set_fields_bitsize PARAMS ((CGEN_FIELDS *, int));
5671
-
5672
-/* Set the recorded length of the insn in the CGEN_FIELDS struct.  */
5673
-
5674
-static void
5675
-set_fields_bitsize (fields, size)
5676
-     CGEN_FIELDS *fields;
5677
-     int size;
5678
-{
5679
-  CGEN_FIELDS_BITSIZE (fields) = size;
5680
-}
5681
-
5682
-/* Function to call before using the operand instance table.
5683
-   This plugs the opcode entries and macro instructions into the cpu table.  */
5684
-
5685
-void
5686
-openrisc_cgen_init_opcode_table (cd)
5687
-     CGEN_CPU_DESC cd;
5688
-{
5689
-  int i;
5690
-  int num_macros = (sizeof (openrisc_cgen_macro_insn_table) /
5691
-                   sizeof (openrisc_cgen_macro_insn_table[0]));
5692
-  const CGEN_IBASE *ib = & openrisc_cgen_macro_insn_table[0];
5693
-  const CGEN_OPCODE *oc = & openrisc_cgen_macro_insn_opcode_table[0];
5694
-  CGEN_INSN *insns = (CGEN_INSN *) xmalloc (num_macros * sizeof (CGEN_INSN));
5695
-  memset (insns, 0, num_macros * sizeof (CGEN_INSN));
5696
-  for (i = 0; i < num_macros; ++i)
5697
-    {
5698
-      insns[i].base = &ib[i];
5699
-      insns[i].opcode = &oc[i];
5700
-      openrisc_cgen_build_insn_regex (& insns[i]);
5701
-    }
5702
-  cd->macro_insn_table.init_entries = insns;
5703
-  cd->macro_insn_table.entry_size = sizeof (CGEN_IBASE);
5704
-  cd->macro_insn_table.num_init_entries = num_macros;
5705
-
5706
-  oc = & openrisc_cgen_insn_opcode_table[0];
5707
-  insns = (CGEN_INSN *) cd->insn_table.init_entries;
5708
-  for (i = 0; i < MAX_INSNS; ++i)
5709
-    {
5710
-      insns[i].opcode = &oc[i];
5711
-      openrisc_cgen_build_insn_regex (& insns[i]);
5712
-    }
5713
-
5714
-  cd->sizeof_fields = sizeof (CGEN_FIELDS);
5715
-  cd->set_fields_bitsize = set_fields_bitsize;
5716
-
5717
-  cd->asm_hash_p = asm_hash_insn_p;
5718
-  cd->asm_hash = asm_hash_insn;
5719
-  cd->asm_hash_size = CGEN_ASM_HASH_SIZE;
5720
-
5721
-  cd->dis_hash_p = dis_hash_insn_p;
5722
-  cd->dis_hash = dis_hash_insn;
5723
-  cd->dis_hash_size = CGEN_DIS_HASH_SIZE;
5724
-}
5725
diff --unified -N -r ../binutils-2.16.1/opcodes/openrisc-opc.h binutils-2.16.1/opcodes/openrisc-opc.h
5726
--- ../binutils-2.16.1/opcodes/openrisc-opc.h   2005-02-22 01:33:20.000000000 +0100
5727
+++ binutils-2.16.1/opcodes/openrisc-opc.h      1970-01-01 01:00:00.000000000 +0100
5728
@@ -1,113 +0,0 @@
5729
-/* Instruction opcode header for openrisc.
5730
-
5731
-THIS FILE IS MACHINE GENERATED WITH CGEN.
5732
-
5733
-Copyright 1996-2005 Free Software Foundation, Inc.
5734
-
5735
-This file is part of the GNU Binutils and/or GDB, the GNU debugger.
5736
-
5737
-This program is free software; you can redistribute it and/or modify
5738
-it under the terms of the GNU General Public License as published by
5739
-the Free Software Foundation; either version 2, or (at your option)
5740
-any later version.
5741
-
5742
-This program is distributed in the hope that it will be useful,
5743
-but WITHOUT ANY WARRANTY; without even the implied warranty of
5744
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
5745
-GNU General Public License for more details.
5746
-
5747
-You should have received a copy of the GNU General Public License along
5748
-with this program; if not, write to the Free Software Foundation, Inc.,
5749
-59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
5750
-
5751
-*/
5752
-
5753
-#ifndef OPENRISC_OPC_H
5754
-#define OPENRISC_OPC_H
5755
-
5756
-/* -- opc.h */
5757
-#undef  CGEN_DIS_HASH_SIZE
5758
-#define CGEN_DIS_HASH_SIZE 64
5759
-#undef  CGEN_DIS_HASH
5760
-#define CGEN_DIS_HASH(buffer, value) (((unsigned char *) (buffer))[0] >> 2)
5761
-
5762
-extern long openrisc_sign_extend_16bit PARAMS ((long));
5763
-/* -- */
5764
-/* Enum declaration for openrisc instruction types.  */
5765
-typedef enum cgen_insn_type {
5766
-  OPENRISC_INSN_INVALID, OPENRISC_INSN_L_J, OPENRISC_INSN_L_JAL, OPENRISC_INSN_L_JR
5767
- , OPENRISC_INSN_L_JALR, OPENRISC_INSN_L_BAL, OPENRISC_INSN_L_BNF, OPENRISC_INSN_L_BF
5768
- , OPENRISC_INSN_L_BRK, OPENRISC_INSN_L_RFE, OPENRISC_INSN_L_SYS, OPENRISC_INSN_L_NOP
5769
- , OPENRISC_INSN_L_MOVHI, OPENRISC_INSN_L_MFSR, OPENRISC_INSN_L_MTSR, OPENRISC_INSN_L_LW
5770
- , OPENRISC_INSN_L_LBZ, OPENRISC_INSN_L_LBS, OPENRISC_INSN_L_LHZ, OPENRISC_INSN_L_LHS
5771
- , OPENRISC_INSN_L_SW, OPENRISC_INSN_L_SB, OPENRISC_INSN_L_SH, OPENRISC_INSN_L_SLL
5772
- , OPENRISC_INSN_L_SLLI, OPENRISC_INSN_L_SRL, OPENRISC_INSN_L_SRLI, OPENRISC_INSN_L_SRA
5773
- , OPENRISC_INSN_L_SRAI, OPENRISC_INSN_L_ROR, OPENRISC_INSN_L_RORI, OPENRISC_INSN_L_ADD
5774
- , OPENRISC_INSN_L_ADDI, OPENRISC_INSN_L_SUB, OPENRISC_INSN_L_SUBI, OPENRISC_INSN_L_AND
5775
- , OPENRISC_INSN_L_ANDI, OPENRISC_INSN_L_OR, OPENRISC_INSN_L_ORI, OPENRISC_INSN_L_XOR
5776
- , OPENRISC_INSN_L_XORI, OPENRISC_INSN_L_MUL, OPENRISC_INSN_L_MULI, OPENRISC_INSN_L_DIV
5777
- , OPENRISC_INSN_L_DIVU, OPENRISC_INSN_L_SFGTS, OPENRISC_INSN_L_SFGTU, OPENRISC_INSN_L_SFGES
5778
- , OPENRISC_INSN_L_SFGEU, OPENRISC_INSN_L_SFLTS, OPENRISC_INSN_L_SFLTU, OPENRISC_INSN_L_SFLES
5779
- , OPENRISC_INSN_L_SFLEU, OPENRISC_INSN_L_SFGTSI, OPENRISC_INSN_L_SFGTUI, OPENRISC_INSN_L_SFGESI
5780
- , OPENRISC_INSN_L_SFGEUI, OPENRISC_INSN_L_SFLTSI, OPENRISC_INSN_L_SFLTUI, OPENRISC_INSN_L_SFLESI
5781
- , OPENRISC_INSN_L_SFLEUI, OPENRISC_INSN_L_SFEQ, OPENRISC_INSN_L_SFEQI, OPENRISC_INSN_L_SFNE
5782
- , OPENRISC_INSN_L_SFNEI
5783
-} CGEN_INSN_TYPE;
5784
-
5785
-/* Index of `invalid' insn place holder.  */
5786
-#define CGEN_INSN_INVALID OPENRISC_INSN_INVALID
5787
-
5788
-/* Total number of insns in table.  */
5789
-#define MAX_INSNS ((int) OPENRISC_INSN_L_SFNEI + 1)
5790
-
5791
-/* This struct records data prior to insertion or after extraction.  */
5792
-struct cgen_fields
5793
-{
5794
-  int length;
5795
-  long f_nil;
5796
-  long f_anyof;
5797
-  long f_class;
5798
-  long f_sub;
5799
-  long f_r1;
5800
-  long f_r2;
5801
-  long f_r3;
5802
-  long f_simm16;
5803
-  long f_uimm16;
5804
-  long f_uimm5;
5805
-  long f_hi16;
5806
-  long f_lo16;
5807
-  long f_op1;
5808
-  long f_op2;
5809
-  long f_op3;
5810
-  long f_op4;
5811
-  long f_op5;
5812
-  long f_op6;
5813
-  long f_op7;
5814
-  long f_i16_1;
5815
-  long f_i16_2;
5816
-  long f_disp26;
5817
-  long f_abs26;
5818
-  long f_i16nc;
5819
-  long f_f_15_8;
5820
-  long f_f_10_3;
5821
-  long f_f_4_1;
5822
-  long f_f_7_3;
5823
-  long f_f_10_7;
5824
-  long f_f_10_11;
5825
-};
5826
-
5827
-#define CGEN_INIT_PARSE(od) \
5828
-{\
5829
-}
5830
-#define CGEN_INIT_INSERT(od) \
5831
-{\
5832
-}
5833
-#define CGEN_INIT_EXTRACT(od) \
5834
-{\
5835
-}
5836
-#define CGEN_INIT_PRINT(od) \
5837
-{\
5838
-}
5839
-
5840
-
5841
-#endif /* OPENRISC_OPC_H */

powered by: WebSVN 2.1.0

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