Back to index

cell-binutils  2.17cvs20070401
ip2k-opc.c
Go to the documentation of this file.
00001 /* Instruction opcode table for ip2k.
00002 
00003 THIS FILE IS MACHINE GENERATED WITH CGEN.
00004 
00005 Copyright 1996-2005 Free Software Foundation, Inc.
00006 
00007 This file is part of the GNU Binutils and/or GDB, the GNU debugger.
00008 
00009 This program is free software; you can redistribute it and/or modify
00010 it under the terms of the GNU General Public License as published by
00011 the Free Software Foundation; either version 2, or (at your option)
00012 any later version.
00013 
00014 This program is distributed in the hope that it will be useful,
00015 but WITHOUT ANY WARRANTY; without even the implied warranty of
00016 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017 GNU General Public License for more details.
00018 
00019 You should have received a copy of the GNU General Public License along
00020 with this program; if not, write to the Free Software Foundation, Inc.,
00021 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
00022 
00023 */
00024 
00025 #include "sysdep.h"
00026 #include "ansidecl.h"
00027 #include "bfd.h"
00028 #include "symcat.h"
00029 #include "ip2k-desc.h"
00030 #include "ip2k-opc.h"
00031 #include "libiberty.h"
00032 
00033 /* -- opc.c */
00034 
00035 #include "safe-ctype.h"
00036 
00037 /* A better hash function for instruction mnemonics.  */
00038 unsigned int
00039 ip2k_asm_hash (const char* insn)
00040 {
00041   unsigned int hash;
00042   const char* m = insn;
00043 
00044   for (hash = 0; *m && ! ISSPACE (*m); m++)
00045     hash = (hash * 23) ^ (0x1F & TOLOWER (*m));
00046 
00047   /* printf ("%s %d\n", insn, (hash % CGEN_ASM_HASH_SIZE)); */
00048 
00049   return hash % CGEN_ASM_HASH_SIZE;
00050 }
00051 
00052 
00053 /* Special check to ensure that instruction exists for given machine.  */
00054 
00055 int
00056 ip2k_cgen_insn_supported (CGEN_CPU_DESC cd, const CGEN_INSN *insn)
00057 {
00058   int machs = CGEN_INSN_ATTR_VALUE (insn, CGEN_INSN_MACH);
00059 
00060   /* No mach attribute?  Assume it's supported for all machs.  */
00061   if (machs == 0)
00062     return 1;
00063   
00064   return (machs & cd->machs) != 0;
00065 }
00066 
00067 
00068 /* -- asm.c */
00069 /* The hash functions are recorded here to help keep assembler code out of
00070    the disassembler and vice versa.  */
00071 
00072 static int asm_hash_insn_p        (const CGEN_INSN *);
00073 static unsigned int asm_hash_insn (const char *);
00074 static int dis_hash_insn_p        (const CGEN_INSN *);
00075 static unsigned int dis_hash_insn (const char *, CGEN_INSN_INT);
00076 
00077 /* Instruction formats.  */
00078 
00079 #if defined (__STDC__) || defined (ALMOST_STDC) || defined (HAVE_STRINGIZE)
00080 #define F(f) & ip2k_cgen_ifld_table[IP2K_##f]
00081 #else
00082 #define F(f) & ip2k_cgen_ifld_table[IP2K_f]
00083 #endif
00084 static const CGEN_IFMT ifmt_empty ATTRIBUTE_UNUSED = {
00085   0, 0, 0x0, { { 0 } }
00086 };
00087 
00088 static const CGEN_IFMT ifmt_jmp ATTRIBUTE_UNUSED = {
00089   16, 16, 0xe000, { { F (F_OP3) }, { F (F_ADDR16CJP) }, { 0 } }
00090 };
00091 
00092 static const CGEN_IFMT ifmt_sb ATTRIBUTE_UNUSED = {
00093   16, 16, 0xf000, { { F (F_OP4) }, { F (F_BITNO) }, { F (F_REG) }, { 0 } }
00094 };
00095 
00096 static const CGEN_IFMT ifmt_xorw_l ATTRIBUTE_UNUSED = {
00097   16, 16, 0xff00, { { F (F_OP4) }, { F (F_OP4MID) }, { F (F_IMM8) }, { 0 } }
00098 };
00099 
00100 static const CGEN_IFMT ifmt_loadl_a ATTRIBUTE_UNUSED = {
00101   16, 16, 0xff00, { { F (F_OP4) }, { F (F_OP4MID) }, { F (F_IMM8) }, { 0 } }
00102 };
00103 
00104 static const CGEN_IFMT ifmt_loadh_a ATTRIBUTE_UNUSED = {
00105   16, 16, 0xff00, { { F (F_OP4) }, { F (F_OP4MID) }, { F (F_IMM8) }, { 0 } }
00106 };
00107 
00108 static const CGEN_IFMT ifmt_addcfr_w ATTRIBUTE_UNUSED = {
00109   16, 16, 0xfe00, { { F (F_OP6) }, { F (F_DIR) }, { F (F_REG) }, { 0 } }
00110 };
00111 
00112 static const CGEN_IFMT ifmt_speed ATTRIBUTE_UNUSED = {
00113   16, 16, 0xff00, { { F (F_OP8) }, { F (F_IMM8) }, { 0 } }
00114 };
00115 
00116 static const CGEN_IFMT ifmt_ireadi ATTRIBUTE_UNUSED = {
00117   16, 16, 0xffff, { { F (F_OP6) }, { F (F_OP6_10LOW) }, { 0 } }
00118 };
00119 
00120 static const CGEN_IFMT ifmt_page ATTRIBUTE_UNUSED = {
00121   16, 16, 0xfff8, { { F (F_OP6) }, { F (F_OP6_7LOW) }, { F (F_PAGE3) }, { 0 } }
00122 };
00123 
00124 static const CGEN_IFMT ifmt_reti ATTRIBUTE_UNUSED = {
00125   16, 16, 0xfff8, { { F (F_OP6) }, { F (F_OP6_7LOW) }, { F (F_RETI3) }, { 0 } }
00126 };
00127 
00128 #undef F
00129 
00130 #if defined (__STDC__) || defined (ALMOST_STDC) || defined (HAVE_STRINGIZE)
00131 #define A(a) (1 << CGEN_INSN_##a)
00132 #else
00133 #define A(a) (1 << CGEN_INSN_a)
00134 #endif
00135 #if defined (__STDC__) || defined (ALMOST_STDC) || defined (HAVE_STRINGIZE)
00136 #define OPERAND(op) IP2K_OPERAND_##op
00137 #else
00138 #define OPERAND(op) IP2K_OPERAND_op
00139 #endif
00140 #define MNEM CGEN_SYNTAX_MNEMONIC /* syntax value for mnemonic */
00141 #define OP(field) CGEN_SYNTAX_MAKE_FIELD (OPERAND (field))
00142 
00143 /* The instruction table.  */
00144 
00145 static const CGEN_OPCODE ip2k_cgen_insn_opcode_table[MAX_INSNS] =
00146 {
00147   /* Special null first entry.
00148      A `num' value of zero is thus invalid.
00149      Also, the special `invalid' insn resides here.  */
00150   { { 0, 0, 0, 0 }, {{0}}, 0, {0}},
00151 /* jmp $addr16cjp */
00152   {
00153     { 0, 0, 0, 0 },
00154     { { MNEM, ' ', OP (ADDR16CJP), 0 } },
00155     & ifmt_jmp, { 0xe000 }
00156   },
00157 /* call $addr16cjp */
00158   {
00159     { 0, 0, 0, 0 },
00160     { { MNEM, ' ', OP (ADDR16CJP), 0 } },
00161     & ifmt_jmp, { 0xc000 }
00162   },
00163 /* sb $fr,$bitno */
00164   {
00165     { 0, 0, 0, 0 },
00166     { { MNEM, ' ', OP (FR), ',', OP (BITNO), 0 } },
00167     & ifmt_sb, { 0xb000 }
00168   },
00169 /* snb $fr,$bitno */
00170   {
00171     { 0, 0, 0, 0 },
00172     { { MNEM, ' ', OP (FR), ',', OP (BITNO), 0 } },
00173     & ifmt_sb, { 0xa000 }
00174   },
00175 /* setb $fr,$bitno */
00176   {
00177     { 0, 0, 0, 0 },
00178     { { MNEM, ' ', OP (FR), ',', OP (BITNO), 0 } },
00179     & ifmt_sb, { 0x9000 }
00180   },
00181 /* clrb $fr,$bitno */
00182   {
00183     { 0, 0, 0, 0 },
00184     { { MNEM, ' ', OP (FR), ',', OP (BITNO), 0 } },
00185     & ifmt_sb, { 0x8000 }
00186   },
00187 /* xor W,#$lit8 */
00188   {
00189     { 0, 0, 0, 0 },
00190     { { MNEM, ' ', 'W', ',', '#', OP (LIT8), 0 } },
00191     & ifmt_xorw_l, { 0x7f00 }
00192   },
00193 /* and W,#$lit8 */
00194   {
00195     { 0, 0, 0, 0 },
00196     { { MNEM, ' ', 'W', ',', '#', OP (LIT8), 0 } },
00197     & ifmt_xorw_l, { 0x7e00 }
00198   },
00199 /* or W,#$lit8 */
00200   {
00201     { 0, 0, 0, 0 },
00202     { { MNEM, ' ', 'W', ',', '#', OP (LIT8), 0 } },
00203     & ifmt_xorw_l, { 0x7d00 }
00204   },
00205 /* add W,#$lit8 */
00206   {
00207     { 0, 0, 0, 0 },
00208     { { MNEM, ' ', 'W', ',', '#', OP (LIT8), 0 } },
00209     & ifmt_xorw_l, { 0x7b00 }
00210   },
00211 /* sub W,#$lit8 */
00212   {
00213     { 0, 0, 0, 0 },
00214     { { MNEM, ' ', 'W', ',', '#', OP (LIT8), 0 } },
00215     & ifmt_xorw_l, { 0x7a00 }
00216   },
00217 /* cmp W,#$lit8 */
00218   {
00219     { 0, 0, 0, 0 },
00220     { { MNEM, ' ', 'W', ',', '#', OP (LIT8), 0 } },
00221     & ifmt_xorw_l, { 0x7900 }
00222   },
00223 /* retw #$lit8 */
00224   {
00225     { 0, 0, 0, 0 },
00226     { { MNEM, ' ', '#', OP (LIT8), 0 } },
00227     & ifmt_xorw_l, { 0x7800 }
00228   },
00229 /* cse W,#$lit8 */
00230   {
00231     { 0, 0, 0, 0 },
00232     { { MNEM, ' ', 'W', ',', '#', OP (LIT8), 0 } },
00233     & ifmt_xorw_l, { 0x7700 }
00234   },
00235 /* csne W,#$lit8 */
00236   {
00237     { 0, 0, 0, 0 },
00238     { { MNEM, ' ', 'W', ',', '#', OP (LIT8), 0 } },
00239     & ifmt_xorw_l, { 0x7600 }
00240   },
00241 /* push #$lit8 */
00242   {
00243     { 0, 0, 0, 0 },
00244     { { MNEM, ' ', '#', OP (LIT8), 0 } },
00245     & ifmt_xorw_l, { 0x7400 }
00246   },
00247 /* muls W,#$lit8 */
00248   {
00249     { 0, 0, 0, 0 },
00250     { { MNEM, ' ', 'W', ',', '#', OP (LIT8), 0 } },
00251     & ifmt_xorw_l, { 0x7300 }
00252   },
00253 /* mulu W,#$lit8 */
00254   {
00255     { 0, 0, 0, 0 },
00256     { { MNEM, ' ', 'W', ',', '#', OP (LIT8), 0 } },
00257     & ifmt_xorw_l, { 0x7200 }
00258   },
00259 /* loadl #$lit8 */
00260   {
00261     { 0, 0, 0, 0 },
00262     { { MNEM, ' ', '#', OP (LIT8), 0 } },
00263     & ifmt_xorw_l, { 0x7100 }
00264   },
00265 /* loadh #$lit8 */
00266   {
00267     { 0, 0, 0, 0 },
00268     { { MNEM, ' ', '#', OP (LIT8), 0 } },
00269     & ifmt_xorw_l, { 0x7000 }
00270   },
00271 /* loadl $addr16l */
00272   {
00273     { 0, 0, 0, 0 },
00274     { { MNEM, ' ', OP (ADDR16L), 0 } },
00275     & ifmt_loadl_a, { 0x7100 }
00276   },
00277 /* loadh $addr16h */
00278   {
00279     { 0, 0, 0, 0 },
00280     { { MNEM, ' ', OP (ADDR16H), 0 } },
00281     & ifmt_loadh_a, { 0x7000 }
00282   },
00283 /* addc $fr,W */
00284   {
00285     { 0, 0, 0, 0 },
00286     { { MNEM, ' ', OP (FR), ',', 'W', 0 } },
00287     & ifmt_addcfr_w, { 0x5e00 }
00288   },
00289 /* addc W,$fr */
00290   {
00291     { 0, 0, 0, 0 },
00292     { { MNEM, ' ', 'W', ',', OP (FR), 0 } },
00293     & ifmt_addcfr_w, { 0x5c00 }
00294   },
00295 /* incsnz $fr */
00296   {
00297     { 0, 0, 0, 0 },
00298     { { MNEM, ' ', OP (FR), 0 } },
00299     & ifmt_addcfr_w, { 0x5a00 }
00300   },
00301 /* incsnz W,$fr */
00302   {
00303     { 0, 0, 0, 0 },
00304     { { MNEM, ' ', 'W', ',', OP (FR), 0 } },
00305     & ifmt_addcfr_w, { 0x5800 }
00306   },
00307 /* muls W,$fr */
00308   {
00309     { 0, 0, 0, 0 },
00310     { { MNEM, ' ', 'W', ',', OP (FR), 0 } },
00311     & ifmt_addcfr_w, { 0x5400 }
00312   },
00313 /* mulu W,$fr */
00314   {
00315     { 0, 0, 0, 0 },
00316     { { MNEM, ' ', 'W', ',', OP (FR), 0 } },
00317     & ifmt_addcfr_w, { 0x5000 }
00318   },
00319 /* decsnz $fr */
00320   {
00321     { 0, 0, 0, 0 },
00322     { { MNEM, ' ', OP (FR), 0 } },
00323     & ifmt_addcfr_w, { 0x4e00 }
00324   },
00325 /* decsnz W,$fr */
00326   {
00327     { 0, 0, 0, 0 },
00328     { { MNEM, ' ', 'W', ',', OP (FR), 0 } },
00329     & ifmt_addcfr_w, { 0x4c00 }
00330   },
00331 /* subc W,$fr */
00332   {
00333     { 0, 0, 0, 0 },
00334     { { MNEM, ' ', 'W', ',', OP (FR), 0 } },
00335     & ifmt_addcfr_w, { 0x4800 }
00336   },
00337 /* subc $fr,W */
00338   {
00339     { 0, 0, 0, 0 },
00340     { { MNEM, ' ', OP (FR), ',', 'W', 0 } },
00341     & ifmt_addcfr_w, { 0x4a00 }
00342   },
00343 /* pop $fr */
00344   {
00345     { 0, 0, 0, 0 },
00346     { { MNEM, ' ', OP (FR), 0 } },
00347     & ifmt_addcfr_w, { 0x4600 }
00348   },
00349 /* push $fr */
00350   {
00351     { 0, 0, 0, 0 },
00352     { { MNEM, ' ', OP (FR), 0 } },
00353     & ifmt_addcfr_w, { 0x4400 }
00354   },
00355 /* cse W,$fr */
00356   {
00357     { 0, 0, 0, 0 },
00358     { { MNEM, ' ', 'W', ',', OP (FR), 0 } },
00359     & ifmt_addcfr_w, { 0x4200 }
00360   },
00361 /* csne W,$fr */
00362   {
00363     { 0, 0, 0, 0 },
00364     { { MNEM, ' ', 'W', ',', OP (FR), 0 } },
00365     & ifmt_addcfr_w, { 0x4000 }
00366   },
00367 /* incsz $fr */
00368   {
00369     { 0, 0, 0, 0 },
00370     { { MNEM, ' ', OP (FR), 0 } },
00371     & ifmt_addcfr_w, { 0x3e00 }
00372   },
00373 /* incsz W,$fr */
00374   {
00375     { 0, 0, 0, 0 },
00376     { { MNEM, ' ', 'W', ',', OP (FR), 0 } },
00377     & ifmt_addcfr_w, { 0x3c00 }
00378   },
00379 /* swap $fr */
00380   {
00381     { 0, 0, 0, 0 },
00382     { { MNEM, ' ', OP (FR), 0 } },
00383     & ifmt_addcfr_w, { 0x3a00 }
00384   },
00385 /* swap W,$fr */
00386   {
00387     { 0, 0, 0, 0 },
00388     { { MNEM, ' ', 'W', ',', OP (FR), 0 } },
00389     & ifmt_addcfr_w, { 0x3800 }
00390   },
00391 /* rl $fr */
00392   {
00393     { 0, 0, 0, 0 },
00394     { { MNEM, ' ', OP (FR), 0 } },
00395     & ifmt_addcfr_w, { 0x3600 }
00396   },
00397 /* rl W,$fr */
00398   {
00399     { 0, 0, 0, 0 },
00400     { { MNEM, ' ', 'W', ',', OP (FR), 0 } },
00401     & ifmt_addcfr_w, { 0x3400 }
00402   },
00403 /* rr $fr */
00404   {
00405     { 0, 0, 0, 0 },
00406     { { MNEM, ' ', OP (FR), 0 } },
00407     & ifmt_addcfr_w, { 0x3200 }
00408   },
00409 /* rr W,$fr */
00410   {
00411     { 0, 0, 0, 0 },
00412     { { MNEM, ' ', 'W', ',', OP (FR), 0 } },
00413     & ifmt_addcfr_w, { 0x3000 }
00414   },
00415 /* decsz $fr */
00416   {
00417     { 0, 0, 0, 0 },
00418     { { MNEM, ' ', OP (FR), 0 } },
00419     & ifmt_addcfr_w, { 0x2e00 }
00420   },
00421 /* decsz W,$fr */
00422   {
00423     { 0, 0, 0, 0 },
00424     { { MNEM, ' ', 'W', ',', OP (FR), 0 } },
00425     & ifmt_addcfr_w, { 0x2c00 }
00426   },
00427 /* inc $fr */
00428   {
00429     { 0, 0, 0, 0 },
00430     { { MNEM, ' ', OP (FR), 0 } },
00431     & ifmt_addcfr_w, { 0x2a00 }
00432   },
00433 /* inc W,$fr */
00434   {
00435     { 0, 0, 0, 0 },
00436     { { MNEM, ' ', 'W', ',', OP (FR), 0 } },
00437     & ifmt_addcfr_w, { 0x2800 }
00438   },
00439 /* not $fr */
00440   {
00441     { 0, 0, 0, 0 },
00442     { { MNEM, ' ', OP (FR), 0 } },
00443     & ifmt_addcfr_w, { 0x2600 }
00444   },
00445 /* not W,$fr */
00446   {
00447     { 0, 0, 0, 0 },
00448     { { MNEM, ' ', 'W', ',', OP (FR), 0 } },
00449     & ifmt_addcfr_w, { 0x2400 }
00450   },
00451 /* test $fr */
00452   {
00453     { 0, 0, 0, 0 },
00454     { { MNEM, ' ', OP (FR), 0 } },
00455     & ifmt_addcfr_w, { 0x2200 }
00456   },
00457 /* mov W,#$lit8 */
00458   {
00459     { 0, 0, 0, 0 },
00460     { { MNEM, ' ', 'W', ',', '#', OP (LIT8), 0 } },
00461     & ifmt_xorw_l, { 0x7c00 }
00462   },
00463 /* mov $fr,W */
00464   {
00465     { 0, 0, 0, 0 },
00466     { { MNEM, ' ', OP (FR), ',', 'W', 0 } },
00467     & ifmt_addcfr_w, { 0x200 }
00468   },
00469 /* mov W,$fr */
00470   {
00471     { 0, 0, 0, 0 },
00472     { { MNEM, ' ', 'W', ',', OP (FR), 0 } },
00473     & ifmt_addcfr_w, { 0x2000 }
00474   },
00475 /* add $fr,W */
00476   {
00477     { 0, 0, 0, 0 },
00478     { { MNEM, ' ', OP (FR), ',', 'W', 0 } },
00479     & ifmt_addcfr_w, { 0x1e00 }
00480   },
00481 /* add W,$fr */
00482   {
00483     { 0, 0, 0, 0 },
00484     { { MNEM, ' ', 'W', ',', OP (FR), 0 } },
00485     & ifmt_addcfr_w, { 0x1c00 }
00486   },
00487 /* xor $fr,W */
00488   {
00489     { 0, 0, 0, 0 },
00490     { { MNEM, ' ', OP (FR), ',', 'W', 0 } },
00491     & ifmt_addcfr_w, { 0x1a00 }
00492   },
00493 /* xor W,$fr */
00494   {
00495     { 0, 0, 0, 0 },
00496     { { MNEM, ' ', 'W', ',', OP (FR), 0 } },
00497     & ifmt_addcfr_w, { 0x1800 }
00498   },
00499 /* and $fr,W */
00500   {
00501     { 0, 0, 0, 0 },
00502     { { MNEM, ' ', OP (FR), ',', 'W', 0 } },
00503     & ifmt_addcfr_w, { 0x1600 }
00504   },
00505 /* and W,$fr */
00506   {
00507     { 0, 0, 0, 0 },
00508     { { MNEM, ' ', 'W', ',', OP (FR), 0 } },
00509     & ifmt_addcfr_w, { 0x1400 }
00510   },
00511 /* or $fr,W */
00512   {
00513     { 0, 0, 0, 0 },
00514     { { MNEM, ' ', OP (FR), ',', 'W', 0 } },
00515     & ifmt_addcfr_w, { 0x1200 }
00516   },
00517 /* or W,$fr */
00518   {
00519     { 0, 0, 0, 0 },
00520     { { MNEM, ' ', 'W', ',', OP (FR), 0 } },
00521     & ifmt_addcfr_w, { 0x1000 }
00522   },
00523 /* dec $fr */
00524   {
00525     { 0, 0, 0, 0 },
00526     { { MNEM, ' ', OP (FR), 0 } },
00527     & ifmt_addcfr_w, { 0xe00 }
00528   },
00529 /* dec W,$fr */
00530   {
00531     { 0, 0, 0, 0 },
00532     { { MNEM, ' ', 'W', ',', OP (FR), 0 } },
00533     & ifmt_addcfr_w, { 0xc00 }
00534   },
00535 /* sub $fr,W */
00536   {
00537     { 0, 0, 0, 0 },
00538     { { MNEM, ' ', OP (FR), ',', 'W', 0 } },
00539     & ifmt_addcfr_w, { 0xa00 }
00540   },
00541 /* sub W,$fr */
00542   {
00543     { 0, 0, 0, 0 },
00544     { { MNEM, ' ', 'W', ',', OP (FR), 0 } },
00545     & ifmt_addcfr_w, { 0x800 }
00546   },
00547 /* clr $fr */
00548   {
00549     { 0, 0, 0, 0 },
00550     { { MNEM, ' ', OP (FR), 0 } },
00551     & ifmt_addcfr_w, { 0x600 }
00552   },
00553 /* cmp W,$fr */
00554   {
00555     { 0, 0, 0, 0 },
00556     { { MNEM, ' ', 'W', ',', OP (FR), 0 } },
00557     & ifmt_addcfr_w, { 0x400 }
00558   },
00559 /* speed #$lit8 */
00560   {
00561     { 0, 0, 0, 0 },
00562     { { MNEM, ' ', '#', OP (LIT8), 0 } },
00563     & ifmt_speed, { 0x100 }
00564   },
00565 /* ireadi */
00566   {
00567     { 0, 0, 0, 0 },
00568     { { MNEM, 0 } },
00569     & ifmt_ireadi, { 0x1d }
00570   },
00571 /* iwritei */
00572   {
00573     { 0, 0, 0, 0 },
00574     { { MNEM, 0 } },
00575     & ifmt_ireadi, { 0x1c }
00576   },
00577 /* fread */
00578   {
00579     { 0, 0, 0, 0 },
00580     { { MNEM, 0 } },
00581     & ifmt_ireadi, { 0x1b }
00582   },
00583 /* fwrite */
00584   {
00585     { 0, 0, 0, 0 },
00586     { { MNEM, 0 } },
00587     & ifmt_ireadi, { 0x1a }
00588   },
00589 /* iread */
00590   {
00591     { 0, 0, 0, 0 },
00592     { { MNEM, 0 } },
00593     & ifmt_ireadi, { 0x19 }
00594   },
00595 /* iwrite */
00596   {
00597     { 0, 0, 0, 0 },
00598     { { MNEM, 0 } },
00599     & ifmt_ireadi, { 0x18 }
00600   },
00601 /* page $addr16p */
00602   {
00603     { 0, 0, 0, 0 },
00604     { { MNEM, ' ', OP (ADDR16P), 0 } },
00605     & ifmt_page, { 0x10 }
00606   },
00607 /* system */
00608   {
00609     { 0, 0, 0, 0 },
00610     { { MNEM, 0 } },
00611     & ifmt_ireadi, { 0xff }
00612   },
00613 /* reti #$reti3 */
00614   {
00615     { 0, 0, 0, 0 },
00616     { { MNEM, ' ', '#', OP (RETI3), 0 } },
00617     & ifmt_reti, { 0x8 }
00618   },
00619 /* ret */
00620   {
00621     { 0, 0, 0, 0 },
00622     { { MNEM, 0 } },
00623     & ifmt_ireadi, { 0x7 }
00624   },
00625 /* int */
00626   {
00627     { 0, 0, 0, 0 },
00628     { { MNEM, 0 } },
00629     & ifmt_ireadi, { 0x6 }
00630   },
00631 /* breakx */
00632   {
00633     { 0, 0, 0, 0 },
00634     { { MNEM, 0 } },
00635     & ifmt_ireadi, { 0x5 }
00636   },
00637 /* cwdt */
00638   {
00639     { 0, 0, 0, 0 },
00640     { { MNEM, 0 } },
00641     & ifmt_ireadi, { 0x4 }
00642   },
00643 /* ferase */
00644   {
00645     { 0, 0, 0, 0 },
00646     { { MNEM, 0 } },
00647     & ifmt_ireadi, { 0x3 }
00648   },
00649 /* retnp */
00650   {
00651     { 0, 0, 0, 0 },
00652     { { MNEM, 0 } },
00653     & ifmt_ireadi, { 0x2 }
00654   },
00655 /* break */
00656   {
00657     { 0, 0, 0, 0 },
00658     { { MNEM, 0 } },
00659     & ifmt_ireadi, { 0x1 }
00660   },
00661 /* nop */
00662   {
00663     { 0, 0, 0, 0 },
00664     { { MNEM, 0 } },
00665     & ifmt_ireadi, { 0x0 }
00666   },
00667 };
00668 
00669 #undef A
00670 #undef OPERAND
00671 #undef MNEM
00672 #undef OP
00673 
00674 /* Formats for ALIAS macro-insns.  */
00675 
00676 #if defined (__STDC__) || defined (ALMOST_STDC) || defined (HAVE_STRINGIZE)
00677 #define F(f) & ip2k_cgen_ifld_table[IP2K_##f]
00678 #else
00679 #define F(f) & ip2k_cgen_ifld_table[IP2K_f]
00680 #endif
00681 static const CGEN_IFMT ifmt_sc ATTRIBUTE_UNUSED = {
00682   16, 16, 0xffff, { { F (F_OP4) }, { F (F_BITNO) }, { F (F_REG) }, { 0 } }
00683 };
00684 
00685 static const CGEN_IFMT ifmt_snc ATTRIBUTE_UNUSED = {
00686   16, 16, 0xffff, { { F (F_OP4) }, { F (F_BITNO) }, { F (F_REG) }, { 0 } }
00687 };
00688 
00689 static const CGEN_IFMT ifmt_sz ATTRIBUTE_UNUSED = {
00690   16, 16, 0xffff, { { F (F_OP4) }, { F (F_BITNO) }, { F (F_REG) }, { 0 } }
00691 };
00692 
00693 static const CGEN_IFMT ifmt_snz ATTRIBUTE_UNUSED = {
00694   16, 16, 0xffff, { { F (F_OP4) }, { F (F_BITNO) }, { F (F_REG) }, { 0 } }
00695 };
00696 
00697 static const CGEN_IFMT ifmt_skip ATTRIBUTE_UNUSED = {
00698   16, 16, 0xffff, { { F (F_OP4) }, { F (F_BITNO) }, { F (F_REG) }, { 0 } }
00699 };
00700 
00701 static const CGEN_IFMT ifmt_skipb ATTRIBUTE_UNUSED = {
00702   16, 16, 0xffff, { { F (F_OP4) }, { F (F_BITNO) }, { F (F_REG) }, { 0 } }
00703 };
00704 
00705 #undef F
00706 
00707 /* Each non-simple macro entry points to an array of expansion possibilities.  */
00708 
00709 #if defined (__STDC__) || defined (ALMOST_STDC) || defined (HAVE_STRINGIZE)
00710 #define A(a) (1 << CGEN_INSN_##a)
00711 #else
00712 #define A(a) (1 << CGEN_INSN_a)
00713 #endif
00714 #if defined (__STDC__) || defined (ALMOST_STDC) || defined (HAVE_STRINGIZE)
00715 #define OPERAND(op) IP2K_OPERAND_##op
00716 #else
00717 #define OPERAND(op) IP2K_OPERAND_op
00718 #endif
00719 #define MNEM CGEN_SYNTAX_MNEMONIC /* syntax value for mnemonic */
00720 #define OP(field) CGEN_SYNTAX_MAKE_FIELD (OPERAND (field))
00721 
00722 /* The macro instruction table.  */
00723 
00724 static const CGEN_IBASE ip2k_cgen_macro_insn_table[] =
00725 {
00726 /* sc */
00727   {
00728     -1, "sc", "sc", 16,
00729     { 0|A(ALIAS), { { { (1<<MACH_BASE), 0 } } } }
00730   },
00731 /* snc */
00732   {
00733     -1, "snc", "snc", 16,
00734     { 0|A(ALIAS), { { { (1<<MACH_BASE), 0 } } } }
00735   },
00736 /* sz */
00737   {
00738     -1, "sz", "sz", 16,
00739     { 0|A(ALIAS), { { { (1<<MACH_BASE), 0 } } } }
00740   },
00741 /* snz */
00742   {
00743     -1, "snz", "snz", 16,
00744     { 0|A(ALIAS), { { { (1<<MACH_BASE), 0 } } } }
00745   },
00746 /* skip */
00747   {
00748     -1, "skip", "skip", 16,
00749     { 0|A(SKIPA)|A(ALIAS), { { { (1<<MACH_BASE), 0 } } } }
00750   },
00751 /* skip */
00752   {
00753     -1, "skipb", "skip", 16,
00754     { 0|A(SKIPA)|A(ALIAS), { { { (1<<MACH_BASE), 0 } } } }
00755   },
00756 };
00757 
00758 /* The macro instruction opcode table.  */
00759 
00760 static const CGEN_OPCODE ip2k_cgen_macro_insn_opcode_table[] =
00761 {
00762 /* sc */
00763   {
00764     { 0, 0, 0, 0 },
00765     { { MNEM, 0 } },
00766     & ifmt_sc, { 0xb00b }
00767   },
00768 /* snc */
00769   {
00770     { 0, 0, 0, 0 },
00771     { { MNEM, 0 } },
00772     & ifmt_snc, { 0xa00b }
00773   },
00774 /* sz */
00775   {
00776     { 0, 0, 0, 0 },
00777     { { MNEM, 0 } },
00778     & ifmt_sz, { 0xb40b }
00779   },
00780 /* snz */
00781   {
00782     { 0, 0, 0, 0 },
00783     { { MNEM, 0 } },
00784     & ifmt_snz, { 0xa40b }
00785   },
00786 /* skip */
00787   {
00788     { 0, 0, 0, 0 },
00789     { { MNEM, 0 } },
00790     & ifmt_skip, { 0xa009 }
00791   },
00792 /* skip */
00793   {
00794     { 0, 0, 0, 0 },
00795     { { MNEM, 0 } },
00796     & ifmt_skipb, { 0xb009 }
00797   },
00798 };
00799 
00800 #undef A
00801 #undef OPERAND
00802 #undef MNEM
00803 #undef OP
00804 
00805 #ifndef CGEN_ASM_HASH_P
00806 #define CGEN_ASM_HASH_P(insn) 1
00807 #endif
00808 
00809 #ifndef CGEN_DIS_HASH_P
00810 #define CGEN_DIS_HASH_P(insn) 1
00811 #endif
00812 
00813 /* Return non-zero if INSN is to be added to the hash table.
00814    Targets are free to override CGEN_{ASM,DIS}_HASH_P in the .opc file.  */
00815 
00816 static int
00817 asm_hash_insn_p (insn)
00818      const CGEN_INSN *insn ATTRIBUTE_UNUSED;
00819 {
00820   return CGEN_ASM_HASH_P (insn);
00821 }
00822 
00823 static int
00824 dis_hash_insn_p (insn)
00825      const CGEN_INSN *insn;
00826 {
00827   /* If building the hash table and the NO-DIS attribute is present,
00828      ignore.  */
00829   if (CGEN_INSN_ATTR_VALUE (insn, CGEN_INSN_NO_DIS))
00830     return 0;
00831   return CGEN_DIS_HASH_P (insn);
00832 }
00833 
00834 #ifndef CGEN_ASM_HASH
00835 #define CGEN_ASM_HASH_SIZE 127
00836 #ifdef CGEN_MNEMONIC_OPERANDS
00837 #define CGEN_ASM_HASH(mnem) (*(unsigned char *) (mnem) % CGEN_ASM_HASH_SIZE)
00838 #else
00839 #define CGEN_ASM_HASH(mnem) (*(unsigned char *) (mnem) % CGEN_ASM_HASH_SIZE) /*FIXME*/
00840 #endif
00841 #endif
00842 
00843 /* It doesn't make much sense to provide a default here,
00844    but while this is under development we do.
00845    BUFFER is a pointer to the bytes of the insn, target order.
00846    VALUE is the first base_insn_bitsize bits as an int in host order.  */
00847 
00848 #ifndef CGEN_DIS_HASH
00849 #define CGEN_DIS_HASH_SIZE 256
00850 #define CGEN_DIS_HASH(buf, value) (*(unsigned char *) (buf))
00851 #endif
00852 
00853 /* The result is the hash value of the insn.
00854    Targets are free to override CGEN_{ASM,DIS}_HASH in the .opc file.  */
00855 
00856 static unsigned int
00857 asm_hash_insn (mnem)
00858      const char * mnem;
00859 {
00860   return CGEN_ASM_HASH (mnem);
00861 }
00862 
00863 /* BUF is a pointer to the bytes of the insn, target order.
00864    VALUE is the first base_insn_bitsize bits as an int in host order.  */
00865 
00866 static unsigned int
00867 dis_hash_insn (buf, value)
00868      const char * buf ATTRIBUTE_UNUSED;
00869      CGEN_INSN_INT value ATTRIBUTE_UNUSED;
00870 {
00871   return CGEN_DIS_HASH (buf, value);
00872 }
00873 
00874 /* Set the recorded length of the insn in the CGEN_FIELDS struct.  */
00875 
00876 static void
00877 set_fields_bitsize (CGEN_FIELDS *fields, int size)
00878 {
00879   CGEN_FIELDS_BITSIZE (fields) = size;
00880 }
00881 
00882 /* Function to call before using the operand instance table.
00883    This plugs the opcode entries and macro instructions into the cpu table.  */
00884 
00885 void
00886 ip2k_cgen_init_opcode_table (CGEN_CPU_DESC cd)
00887 {
00888   int i;
00889   int num_macros = (sizeof (ip2k_cgen_macro_insn_table) /
00890                   sizeof (ip2k_cgen_macro_insn_table[0]));
00891   const CGEN_IBASE *ib = & ip2k_cgen_macro_insn_table[0];
00892   const CGEN_OPCODE *oc = & ip2k_cgen_macro_insn_opcode_table[0];
00893   CGEN_INSN *insns = xmalloc (num_macros * sizeof (CGEN_INSN));
00894 
00895   memset (insns, 0, num_macros * sizeof (CGEN_INSN));
00896   for (i = 0; i < num_macros; ++i)
00897     {
00898       insns[i].base = &ib[i];
00899       insns[i].opcode = &oc[i];
00900       ip2k_cgen_build_insn_regex (& insns[i]);
00901     }
00902   cd->macro_insn_table.init_entries = insns;
00903   cd->macro_insn_table.entry_size = sizeof (CGEN_IBASE);
00904   cd->macro_insn_table.num_init_entries = num_macros;
00905 
00906   oc = & ip2k_cgen_insn_opcode_table[0];
00907   insns = (CGEN_INSN *) cd->insn_table.init_entries;
00908   for (i = 0; i < MAX_INSNS; ++i)
00909     {
00910       insns[i].opcode = &oc[i];
00911       ip2k_cgen_build_insn_regex (& insns[i]);
00912     }
00913 
00914   cd->sizeof_fields = sizeof (CGEN_FIELDS);
00915   cd->set_fields_bitsize = set_fields_bitsize;
00916 
00917   cd->asm_hash_p = asm_hash_insn_p;
00918   cd->asm_hash = asm_hash_insn;
00919   cd->asm_hash_size = CGEN_ASM_HASH_SIZE;
00920 
00921   cd->dis_hash_p = dis_hash_insn_p;
00922   cd->dis_hash = dis_hash_insn;
00923   cd->dis_hash_size = CGEN_DIS_HASH_SIZE;
00924 }