Back to index

cell-binutils  2.17cvs20070401
openrisc-opc.c
Go to the documentation of this file.
00001 /* Instruction opcode table for openrisc.
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 "openrisc-desc.h"
00030 #include "openrisc-opc.h"
00031 #include "libiberty.h"
00032 
00033 /* -- opc.c */
00034 /* -- */
00035 /* The hash functions are recorded here to help keep assembler code out of
00036    the disassembler and vice versa.  */
00037 
00038 static int asm_hash_insn_p        (const CGEN_INSN *);
00039 static unsigned int asm_hash_insn (const char *);
00040 static int dis_hash_insn_p        (const CGEN_INSN *);
00041 static unsigned int dis_hash_insn (const char *, CGEN_INSN_INT);
00042 
00043 /* Instruction formats.  */
00044 
00045 #if defined (__STDC__) || defined (ALMOST_STDC) || defined (HAVE_STRINGIZE)
00046 #define F(f) & openrisc_cgen_ifld_table[OPENRISC_##f]
00047 #else
00048 #define F(f) & openrisc_cgen_ifld_table[OPENRISC_f]
00049 #endif
00050 static const CGEN_IFMT ifmt_empty ATTRIBUTE_UNUSED = {
00051   0, 0, 0x0, { { 0 } }
00052 };
00053 
00054 static const CGEN_IFMT ifmt_l_j ATTRIBUTE_UNUSED = {
00055   32, 32, 0xfc000000, { { F (F_CLASS) }, { F (F_SUB) }, { F (F_ABS26) }, { 0 } }
00056 };
00057 
00058 static const CGEN_IFMT ifmt_l_jr ATTRIBUTE_UNUSED = {
00059   32, 32, 0xffe00000, { { F (F_CLASS) }, { F (F_SUB) }, { F (F_OP3) }, { F (F_OP4) }, { F (F_R2) }, { F (F_UIMM16) }, { 0 } }
00060 };
00061 
00062 static const CGEN_IFMT ifmt_l_bal ATTRIBUTE_UNUSED = {
00063   32, 32, 0xfc000000, { { F (F_CLASS) }, { F (F_SUB) }, { F (F_DISP26) }, { 0 } }
00064 };
00065 
00066 static const CGEN_IFMT ifmt_l_movhi ATTRIBUTE_UNUSED = {
00067   32, 32, 0xfc000000, { { F (F_CLASS) }, { F (F_SUB) }, { F (F_R1) }, { F (F_R2) }, { F (F_SIMM16) }, { 0 } }
00068 };
00069 
00070 static const CGEN_IFMT ifmt_l_mfsr ATTRIBUTE_UNUSED = {
00071   32, 32, 0xfc000000, { { F (F_CLASS) }, { F (F_SUB) }, { F (F_R1) }, { F (F_R2) }, { F (F_UIMM16) }, { 0 } }
00072 };
00073 
00074 static const CGEN_IFMT ifmt_l_mtsr ATTRIBUTE_UNUSED = {
00075   32, 32, 0xfc0007ff, { { F (F_CLASS) }, { F (F_SUB) }, { F (F_R1) }, { F (F_R2) }, { F (F_R3) }, { F (F_I16_1) }, { 0 } }
00076 };
00077 
00078 static const CGEN_IFMT ifmt_l_lw ATTRIBUTE_UNUSED = {
00079   32, 32, 0xfc000000, { { F (F_CLASS) }, { F (F_SUB) }, { F (F_R1) }, { F (F_R2) }, { F (F_SIMM16) }, { 0 } }
00080 };
00081 
00082 static const CGEN_IFMT ifmt_l_sw ATTRIBUTE_UNUSED = {
00083   32, 32, 0xfc000000, { { F (F_CLASS) }, { F (F_SUB) }, { F (F_R1) }, { F (F_R3) }, { F (F_I16NC) }, { 0 } }
00084 };
00085 
00086 static const CGEN_IFMT ifmt_l_sll ATTRIBUTE_UNUSED = {
00087   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 } }
00088 };
00089 
00090 static const CGEN_IFMT ifmt_l_slli ATTRIBUTE_UNUSED = {
00091   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 } }
00092 };
00093 
00094 static const CGEN_IFMT ifmt_l_add ATTRIBUTE_UNUSED = {
00095   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 } }
00096 };
00097 
00098 static const CGEN_IFMT ifmt_l_addi ATTRIBUTE_UNUSED = {
00099   32, 32, 0xfc000000, { { F (F_CLASS) }, { F (F_SUB) }, { F (F_R1) }, { F (F_R2) }, { F (F_LO16) }, { 0 } }
00100 };
00101 
00102 static const CGEN_IFMT ifmt_l_sfgts ATTRIBUTE_UNUSED = {
00103   32, 32, 0xffe007ff, { { F (F_CLASS) }, { F (F_SUB) }, { F (F_OP5) }, { F (F_R2) }, { F (F_R3) }, { F (F_F_10_11) }, { 0 } }
00104 };
00105 
00106 static const CGEN_IFMT ifmt_l_sfgtsi ATTRIBUTE_UNUSED = {
00107   32, 32, 0xffe00000, { { F (F_CLASS) }, { F (F_SUB) }, { F (F_OP5) }, { F (F_R2) }, { F (F_SIMM16) }, { 0 } }
00108 };
00109 
00110 static const CGEN_IFMT ifmt_l_sfgtui ATTRIBUTE_UNUSED = {
00111   32, 32, 0xffe00000, { { F (F_CLASS) }, { F (F_SUB) }, { F (F_OP5) }, { F (F_R2) }, { F (F_UIMM16) }, { 0 } }
00112 };
00113 
00114 #undef F
00115 
00116 #if defined (__STDC__) || defined (ALMOST_STDC) || defined (HAVE_STRINGIZE)
00117 #define A(a) (1 << CGEN_INSN_##a)
00118 #else
00119 #define A(a) (1 << CGEN_INSN_a)
00120 #endif
00121 #if defined (__STDC__) || defined (ALMOST_STDC) || defined (HAVE_STRINGIZE)
00122 #define OPERAND(op) OPENRISC_OPERAND_##op
00123 #else
00124 #define OPERAND(op) OPENRISC_OPERAND_op
00125 #endif
00126 #define MNEM CGEN_SYNTAX_MNEMONIC /* syntax value for mnemonic */
00127 #define OP(field) CGEN_SYNTAX_MAKE_FIELD (OPERAND (field))
00128 
00129 /* The instruction table.  */
00130 
00131 static const CGEN_OPCODE openrisc_cgen_insn_opcode_table[MAX_INSNS] =
00132 {
00133   /* Special null first entry.
00134      A `num' value of zero is thus invalid.
00135      Also, the special `invalid' insn resides here.  */
00136   { { 0, 0, 0, 0 }, {{0}}, 0, {0}},
00137 /* l.j ${abs-26} */
00138   {
00139     { 0, 0, 0, 0 },
00140     { { MNEM, ' ', OP (ABS_26), 0 } },
00141     & ifmt_l_j, { 0x0 }
00142   },
00143 /* l.jal ${abs-26} */
00144   {
00145     { 0, 0, 0, 0 },
00146     { { MNEM, ' ', OP (ABS_26), 0 } },
00147     & ifmt_l_j, { 0x4000000 }
00148   },
00149 /* l.jr $rA */
00150   {
00151     { 0, 0, 0, 0 },
00152     { { MNEM, ' ', OP (RA), 0 } },
00153     & ifmt_l_jr, { 0x14000000 }
00154   },
00155 /* l.jalr $rA */
00156   {
00157     { 0, 0, 0, 0 },
00158     { { MNEM, ' ', OP (RA), 0 } },
00159     & ifmt_l_jr, { 0x14200000 }
00160   },
00161 /* l.bal ${disp-26} */
00162   {
00163     { 0, 0, 0, 0 },
00164     { { MNEM, ' ', OP (DISP_26), 0 } },
00165     & ifmt_l_bal, { 0x8000000 }
00166   },
00167 /* l.bnf ${disp-26} */
00168   {
00169     { 0, 0, 0, 0 },
00170     { { MNEM, ' ', OP (DISP_26), 0 } },
00171     & ifmt_l_bal, { 0xc000000 }
00172   },
00173 /* l.bf ${disp-26} */
00174   {
00175     { 0, 0, 0, 0 },
00176     { { MNEM, ' ', OP (DISP_26), 0 } },
00177     & ifmt_l_bal, { 0x10000000 }
00178   },
00179 /* l.brk ${uimm-16} */
00180   {
00181     { 0, 0, 0, 0 },
00182     { { MNEM, ' ', OP (UIMM_16), 0 } },
00183     & ifmt_l_jr, { 0x17000000 }
00184   },
00185 /* l.rfe $rA */
00186   {
00187     { 0, 0, 0, 0 },
00188     { { MNEM, ' ', OP (RA), 0 } },
00189     & ifmt_l_jr, { 0x14400000 }
00190   },
00191 /* l.sys ${uimm-16} */
00192   {
00193     { 0, 0, 0, 0 },
00194     { { MNEM, ' ', OP (UIMM_16), 0 } },
00195     & ifmt_l_jr, { 0x16000000 }
00196   },
00197 /* l.nop */
00198   {
00199     { 0, 0, 0, 0 },
00200     { { MNEM, 0 } },
00201     & ifmt_l_jr, { 0x15000000 }
00202   },
00203 /* l.movhi $rD,$hi16 */
00204   {
00205     { 0, 0, 0, 0 },
00206     { { MNEM, ' ', OP (RD), ',', OP (HI16), 0 } },
00207     & ifmt_l_movhi, { 0x18000000 }
00208   },
00209 /* l.mfsr $rD,$rA */
00210   {
00211     { 0, 0, 0, 0 },
00212     { { MNEM, ' ', OP (RD), ',', OP (RA), 0 } },
00213     & ifmt_l_mfsr, { 0x1c000000 }
00214   },
00215 /* l.mtsr $rA,$rB */
00216   {
00217     { 0, 0, 0, 0 },
00218     { { MNEM, ' ', OP (RA), ',', OP (RB), 0 } },
00219     & ifmt_l_mtsr, { 0x40000000 }
00220   },
00221 /* l.lw $rD,${simm-16}($rA) */
00222   {
00223     { 0, 0, 0, 0 },
00224     { { MNEM, ' ', OP (RD), ',', OP (SIMM_16), '(', OP (RA), ')', 0 } },
00225     & ifmt_l_lw, { 0x80000000 }
00226   },
00227 /* l.lbz $rD,${simm-16}($rA) */
00228   {
00229     { 0, 0, 0, 0 },
00230     { { MNEM, ' ', OP (RD), ',', OP (SIMM_16), '(', OP (RA), ')', 0 } },
00231     & ifmt_l_lw, { 0x84000000 }
00232   },
00233 /* l.lbs $rD,${simm-16}($rA) */
00234   {
00235     { 0, 0, 0, 0 },
00236     { { MNEM, ' ', OP (RD), ',', OP (SIMM_16), '(', OP (RA), ')', 0 } },
00237     & ifmt_l_lw, { 0x88000000 }
00238   },
00239 /* l.lhz $rD,${simm-16}($rA) */
00240   {
00241     { 0, 0, 0, 0 },
00242     { { MNEM, ' ', OP (RD), ',', OP (SIMM_16), '(', OP (RA), ')', 0 } },
00243     & ifmt_l_lw, { 0x8c000000 }
00244   },
00245 /* l.lhs $rD,${simm-16}($rA) */
00246   {
00247     { 0, 0, 0, 0 },
00248     { { MNEM, ' ', OP (RD), ',', OP (SIMM_16), '(', OP (RA), ')', 0 } },
00249     & ifmt_l_lw, { 0x90000000 }
00250   },
00251 /* l.sw ${ui16nc}($rA),$rB */
00252   {
00253     { 0, 0, 0, 0 },
00254     { { MNEM, ' ', OP (UI16NC), '(', OP (RA), ')', ',', OP (RB), 0 } },
00255     & ifmt_l_sw, { 0xd4000000 }
00256   },
00257 /* l.sb ${ui16nc}($rA),$rB */
00258   {
00259     { 0, 0, 0, 0 },
00260     { { MNEM, ' ', OP (UI16NC), '(', OP (RA), ')', ',', OP (RB), 0 } },
00261     & ifmt_l_sw, { 0xd8000000 }
00262   },
00263 /* l.sh ${ui16nc}($rA),$rB */
00264   {
00265     { 0, 0, 0, 0 },
00266     { { MNEM, ' ', OP (UI16NC), '(', OP (RA), ')', ',', OP (RB), 0 } },
00267     & ifmt_l_sw, { 0xdc000000 }
00268   },
00269 /* l.sll $rD,$rA,$rB */
00270   {
00271     { 0, 0, 0, 0 },
00272     { { MNEM, ' ', OP (RD), ',', OP (RA), ',', OP (RB), 0 } },
00273     & ifmt_l_sll, { 0xe0000008 }
00274   },
00275 /* l.slli $rD,$rA,${uimm-5} */
00276   {
00277     { 0, 0, 0, 0 },
00278     { { MNEM, ' ', OP (RD), ',', OP (RA), ',', OP (UIMM_5), 0 } },
00279     & ifmt_l_slli, { 0xb4000000 }
00280   },
00281 /* l.srl $rD,$rA,$rB */
00282   {
00283     { 0, 0, 0, 0 },
00284     { { MNEM, ' ', OP (RD), ',', OP (RA), ',', OP (RB), 0 } },
00285     & ifmt_l_sll, { 0xe0000028 }
00286   },
00287 /* l.srli $rD,$rA,${uimm-5} */
00288   {
00289     { 0, 0, 0, 0 },
00290     { { MNEM, ' ', OP (RD), ',', OP (RA), ',', OP (UIMM_5), 0 } },
00291     & ifmt_l_slli, { 0xb4000020 }
00292   },
00293 /* l.sra $rD,$rA,$rB */
00294   {
00295     { 0, 0, 0, 0 },
00296     { { MNEM, ' ', OP (RD), ',', OP (RA), ',', OP (RB), 0 } },
00297     & ifmt_l_sll, { 0xe0000048 }
00298   },
00299 /* l.srai $rD,$rA,${uimm-5} */
00300   {
00301     { 0, 0, 0, 0 },
00302     { { MNEM, ' ', OP (RD), ',', OP (RA), ',', OP (UIMM_5), 0 } },
00303     & ifmt_l_slli, { 0xb4000040 }
00304   },
00305 /* l.ror $rD,$rA,$rB */
00306   {
00307     { 0, 0, 0, 0 },
00308     { { MNEM, ' ', OP (RD), ',', OP (RA), ',', OP (RB), 0 } },
00309     & ifmt_l_sll, { 0xe0000088 }
00310   },
00311 /* l.rori $rD,$rA,${uimm-5} */
00312   {
00313     { 0, 0, 0, 0 },
00314     { { MNEM, ' ', OP (RD), ',', OP (RA), ',', OP (UIMM_5), 0 } },
00315     & ifmt_l_slli, { 0xb4000080 }
00316   },
00317 /* l.add $rD,$rA,$rB */
00318   {
00319     { 0, 0, 0, 0 },
00320     { { MNEM, ' ', OP (RD), ',', OP (RA), ',', OP (RB), 0 } },
00321     & ifmt_l_add, { 0xe0000000 }
00322   },
00323 /* l.addi $rD,$rA,$lo16 */
00324   {
00325     { 0, 0, 0, 0 },
00326     { { MNEM, ' ', OP (RD), ',', OP (RA), ',', OP (LO16), 0 } },
00327     & ifmt_l_addi, { 0x94000000 }
00328   },
00329 /* l.sub $rD,$rA,$rB */
00330   {
00331     { 0, 0, 0, 0 },
00332     { { MNEM, ' ', OP (RD), ',', OP (RA), ',', OP (RB), 0 } },
00333     & ifmt_l_add, { 0xe0000002 }
00334   },
00335 /* l.subi $rD,$rA,$lo16 */
00336   {
00337     { 0, 0, 0, 0 },
00338     { { MNEM, ' ', OP (RD), ',', OP (RA), ',', OP (LO16), 0 } },
00339     & ifmt_l_addi, { 0x9c000000 }
00340   },
00341 /* l.and $rD,$rA,$rB */
00342   {
00343     { 0, 0, 0, 0 },
00344     { { MNEM, ' ', OP (RD), ',', OP (RA), ',', OP (RB), 0 } },
00345     & ifmt_l_add, { 0xe0000003 }
00346   },
00347 /* l.andi $rD,$rA,$lo16 */
00348   {
00349     { 0, 0, 0, 0 },
00350     { { MNEM, ' ', OP (RD), ',', OP (RA), ',', OP (LO16), 0 } },
00351     & ifmt_l_addi, { 0xa0000000 }
00352   },
00353 /* l.or $rD,$rA,$rB */
00354   {
00355     { 0, 0, 0, 0 },
00356     { { MNEM, ' ', OP (RD), ',', OP (RA), ',', OP (RB), 0 } },
00357     & ifmt_l_add, { 0xe0000004 }
00358   },
00359 /* l.ori $rD,$rA,$lo16 */
00360   {
00361     { 0, 0, 0, 0 },
00362     { { MNEM, ' ', OP (RD), ',', OP (RA), ',', OP (LO16), 0 } },
00363     & ifmt_l_addi, { 0xa4000000 }
00364   },
00365 /* l.xor $rD,$rA,$rB */
00366   {
00367     { 0, 0, 0, 0 },
00368     { { MNEM, ' ', OP (RD), ',', OP (RA), ',', OP (RB), 0 } },
00369     & ifmt_l_add, { 0xe0000005 }
00370   },
00371 /* l.xori $rD,$rA,$lo16 */
00372   {
00373     { 0, 0, 0, 0 },
00374     { { MNEM, ' ', OP (RD), ',', OP (RA), ',', OP (LO16), 0 } },
00375     & ifmt_l_addi, { 0xa8000000 }
00376   },
00377 /* l.mul $rD,$rA,$rB */
00378   {
00379     { 0, 0, 0, 0 },
00380     { { MNEM, ' ', OP (RD), ',', OP (RA), ',', OP (RB), 0 } },
00381     & ifmt_l_add, { 0xe0000006 }
00382   },
00383 /* l.muli $rD,$rA,$lo16 */
00384   {
00385     { 0, 0, 0, 0 },
00386     { { MNEM, ' ', OP (RD), ',', OP (RA), ',', OP (LO16), 0 } },
00387     & ifmt_l_addi, { 0xac000000 }
00388   },
00389 /* l.div $rD,$rA,$rB */
00390   {
00391     { 0, 0, 0, 0 },
00392     { { MNEM, ' ', OP (RD), ',', OP (RA), ',', OP (RB), 0 } },
00393     & ifmt_l_add, { 0xe0000009 }
00394   },
00395 /* l.divu $rD,$rA,$rB */
00396   {
00397     { 0, 0, 0, 0 },
00398     { { MNEM, ' ', OP (RD), ',', OP (RA), ',', OP (RB), 0 } },
00399     & ifmt_l_add, { 0xe000000a }
00400   },
00401 /* l.sfgts $rA,$rB */
00402   {
00403     { 0, 0, 0, 0 },
00404     { { MNEM, ' ', OP (RA), ',', OP (RB), 0 } },
00405     & ifmt_l_sfgts, { 0xe4c00000 }
00406   },
00407 /* l.sfgtu $rA,$rB */
00408   {
00409     { 0, 0, 0, 0 },
00410     { { MNEM, ' ', OP (RA), ',', OP (RB), 0 } },
00411     & ifmt_l_sfgts, { 0xe4400000 }
00412   },
00413 /* l.sfges $rA,$rB */
00414   {
00415     { 0, 0, 0, 0 },
00416     { { MNEM, ' ', OP (RA), ',', OP (RB), 0 } },
00417     & ifmt_l_sfgts, { 0xe4e00000 }
00418   },
00419 /* l.sfgeu $rA,$rB */
00420   {
00421     { 0, 0, 0, 0 },
00422     { { MNEM, ' ', OP (RA), ',', OP (RB), 0 } },
00423     & ifmt_l_sfgts, { 0xe4600000 }
00424   },
00425 /* l.sflts $rA,$rB */
00426   {
00427     { 0, 0, 0, 0 },
00428     { { MNEM, ' ', OP (RA), ',', OP (RB), 0 } },
00429     & ifmt_l_sfgts, { 0xe5000000 }
00430   },
00431 /* l.sfltu $rA,$rB */
00432   {
00433     { 0, 0, 0, 0 },
00434     { { MNEM, ' ', OP (RA), ',', OP (RB), 0 } },
00435     & ifmt_l_sfgts, { 0xe4800000 }
00436   },
00437 /* l.sfles $rA,$rB */
00438   {
00439     { 0, 0, 0, 0 },
00440     { { MNEM, ' ', OP (RA), ',', OP (RB), 0 } },
00441     & ifmt_l_sfgts, { 0xe5200000 }
00442   },
00443 /* l.sfleu $rA,$rB */
00444   {
00445     { 0, 0, 0, 0 },
00446     { { MNEM, ' ', OP (RA), ',', OP (RB), 0 } },
00447     & ifmt_l_sfgts, { 0xe4a00000 }
00448   },
00449 /* l.sfgtsi $rA,${simm-16} */
00450   {
00451     { 0, 0, 0, 0 },
00452     { { MNEM, ' ', OP (RA), ',', OP (SIMM_16), 0 } },
00453     & ifmt_l_sfgtsi, { 0xb8c00000 }
00454   },
00455 /* l.sfgtui $rA,${uimm-16} */
00456   {
00457     { 0, 0, 0, 0 },
00458     { { MNEM, ' ', OP (RA), ',', OP (UIMM_16), 0 } },
00459     & ifmt_l_sfgtui, { 0xb8400000 }
00460   },
00461 /* l.sfgesi $rA,${simm-16} */
00462   {
00463     { 0, 0, 0, 0 },
00464     { { MNEM, ' ', OP (RA), ',', OP (SIMM_16), 0 } },
00465     & ifmt_l_sfgtsi, { 0xb8e00000 }
00466   },
00467 /* l.sfgeui $rA,${uimm-16} */
00468   {
00469     { 0, 0, 0, 0 },
00470     { { MNEM, ' ', OP (RA), ',', OP (UIMM_16), 0 } },
00471     & ifmt_l_sfgtui, { 0xb8600000 }
00472   },
00473 /* l.sfltsi $rA,${simm-16} */
00474   {
00475     { 0, 0, 0, 0 },
00476     { { MNEM, ' ', OP (RA), ',', OP (SIMM_16), 0 } },
00477     & ifmt_l_sfgtsi, { 0xb9000000 }
00478   },
00479 /* l.sfltui $rA,${uimm-16} */
00480   {
00481     { 0, 0, 0, 0 },
00482     { { MNEM, ' ', OP (RA), ',', OP (UIMM_16), 0 } },
00483     & ifmt_l_sfgtui, { 0xb8800000 }
00484   },
00485 /* l.sflesi $rA,${simm-16} */
00486   {
00487     { 0, 0, 0, 0 },
00488     { { MNEM, ' ', OP (RA), ',', OP (SIMM_16), 0 } },
00489     & ifmt_l_sfgtsi, { 0xb9200000 }
00490   },
00491 /* l.sfleui $rA,${uimm-16} */
00492   {
00493     { 0, 0, 0, 0 },
00494     { { MNEM, ' ', OP (RA), ',', OP (UIMM_16), 0 } },
00495     & ifmt_l_sfgtui, { 0xb8a00000 }
00496   },
00497 /* l.sfeq $rA,$rB */
00498   {
00499     { 0, 0, 0, 0 },
00500     { { MNEM, ' ', OP (RA), ',', OP (RB), 0 } },
00501     & ifmt_l_sfgts, { 0xe4000000 }
00502   },
00503 /* l.sfeqi $rA,${simm-16} */
00504   {
00505     { 0, 0, 0, 0 },
00506     { { MNEM, ' ', OP (RA), ',', OP (SIMM_16), 0 } },
00507     & ifmt_l_sfgtsi, { 0xb8000000 }
00508   },
00509 /* l.sfne $rA,$rB */
00510   {
00511     { 0, 0, 0, 0 },
00512     { { MNEM, ' ', OP (RA), ',', OP (RB), 0 } },
00513     & ifmt_l_sfgts, { 0xe4200000 }
00514   },
00515 /* l.sfnei $rA,${simm-16} */
00516   {
00517     { 0, 0, 0, 0 },
00518     { { MNEM, ' ', OP (RA), ',', OP (SIMM_16), 0 } },
00519     & ifmt_l_sfgtsi, { 0xb8200000 }
00520   },
00521 };
00522 
00523 #undef A
00524 #undef OPERAND
00525 #undef MNEM
00526 #undef OP
00527 
00528 /* Formats for ALIAS macro-insns.  */
00529 
00530 #if defined (__STDC__) || defined (ALMOST_STDC) || defined (HAVE_STRINGIZE)
00531 #define F(f) & openrisc_cgen_ifld_table[OPENRISC_##f]
00532 #else
00533 #define F(f) & openrisc_cgen_ifld_table[OPENRISC_f]
00534 #endif
00535 static const CGEN_IFMT ifmt_l_ret ATTRIBUTE_UNUSED = {
00536   32, 32, 0xffffffff, { { F (F_CLASS) }, { F (F_SUB) }, { F (F_OP3) }, { F (F_OP4) }, { F (F_R2) }, { F (F_UIMM16) }, { 0 } }
00537 };
00538 
00539 #undef F
00540 
00541 /* Each non-simple macro entry points to an array of expansion possibilities.  */
00542 
00543 #if defined (__STDC__) || defined (ALMOST_STDC) || defined (HAVE_STRINGIZE)
00544 #define A(a) (1 << CGEN_INSN_##a)
00545 #else
00546 #define A(a) (1 << CGEN_INSN_a)
00547 #endif
00548 #if defined (__STDC__) || defined (ALMOST_STDC) || defined (HAVE_STRINGIZE)
00549 #define OPERAND(op) OPENRISC_OPERAND_##op
00550 #else
00551 #define OPERAND(op) OPENRISC_OPERAND_op
00552 #endif
00553 #define MNEM CGEN_SYNTAX_MNEMONIC /* syntax value for mnemonic */
00554 #define OP(field) CGEN_SYNTAX_MAKE_FIELD (OPERAND (field))
00555 
00556 /* The macro instruction table.  */
00557 
00558 static const CGEN_IBASE openrisc_cgen_macro_insn_table[] =
00559 {
00560 /* l.ret */
00561   {
00562     -1, "l-ret", "l.ret", 32,
00563     { 0|A(ALIAS), { { { (1<<MACH_BASE), 0 } } } }
00564   },
00565 };
00566 
00567 /* The macro instruction opcode table.  */
00568 
00569 static const CGEN_OPCODE openrisc_cgen_macro_insn_opcode_table[] =
00570 {
00571 /* l.ret */
00572   {
00573     { 0, 0, 0, 0 },
00574     { { MNEM, 0 } },
00575     & ifmt_l_ret, { 0x140b0000 }
00576   },
00577 };
00578 
00579 #undef A
00580 #undef OPERAND
00581 #undef MNEM
00582 #undef OP
00583 
00584 #ifndef CGEN_ASM_HASH_P
00585 #define CGEN_ASM_HASH_P(insn) 1
00586 #endif
00587 
00588 #ifndef CGEN_DIS_HASH_P
00589 #define CGEN_DIS_HASH_P(insn) 1
00590 #endif
00591 
00592 /* Return non-zero if INSN is to be added to the hash table.
00593    Targets are free to override CGEN_{ASM,DIS}_HASH_P in the .opc file.  */
00594 
00595 static int
00596 asm_hash_insn_p (insn)
00597      const CGEN_INSN *insn ATTRIBUTE_UNUSED;
00598 {
00599   return CGEN_ASM_HASH_P (insn);
00600 }
00601 
00602 static int
00603 dis_hash_insn_p (insn)
00604      const CGEN_INSN *insn;
00605 {
00606   /* If building the hash table and the NO-DIS attribute is present,
00607      ignore.  */
00608   if (CGEN_INSN_ATTR_VALUE (insn, CGEN_INSN_NO_DIS))
00609     return 0;
00610   return CGEN_DIS_HASH_P (insn);
00611 }
00612 
00613 #ifndef CGEN_ASM_HASH
00614 #define CGEN_ASM_HASH_SIZE 127
00615 #ifdef CGEN_MNEMONIC_OPERANDS
00616 #define CGEN_ASM_HASH(mnem) (*(unsigned char *) (mnem) % CGEN_ASM_HASH_SIZE)
00617 #else
00618 #define CGEN_ASM_HASH(mnem) (*(unsigned char *) (mnem) % CGEN_ASM_HASH_SIZE) /*FIXME*/
00619 #endif
00620 #endif
00621 
00622 /* It doesn't make much sense to provide a default here,
00623    but while this is under development we do.
00624    BUFFER is a pointer to the bytes of the insn, target order.
00625    VALUE is the first base_insn_bitsize bits as an int in host order.  */
00626 
00627 #ifndef CGEN_DIS_HASH
00628 #define CGEN_DIS_HASH_SIZE 256
00629 #define CGEN_DIS_HASH(buf, value) (*(unsigned char *) (buf))
00630 #endif
00631 
00632 /* The result is the hash value of the insn.
00633    Targets are free to override CGEN_{ASM,DIS}_HASH in the .opc file.  */
00634 
00635 static unsigned int
00636 asm_hash_insn (mnem)
00637      const char * mnem;
00638 {
00639   return CGEN_ASM_HASH (mnem);
00640 }
00641 
00642 /* BUF is a pointer to the bytes of the insn, target order.
00643    VALUE is the first base_insn_bitsize bits as an int in host order.  */
00644 
00645 static unsigned int
00646 dis_hash_insn (buf, value)
00647      const char * buf ATTRIBUTE_UNUSED;
00648      CGEN_INSN_INT value ATTRIBUTE_UNUSED;
00649 {
00650   return CGEN_DIS_HASH (buf, value);
00651 }
00652 
00653 /* Set the recorded length of the insn in the CGEN_FIELDS struct.  */
00654 
00655 static void
00656 set_fields_bitsize (CGEN_FIELDS *fields, int size)
00657 {
00658   CGEN_FIELDS_BITSIZE (fields) = size;
00659 }
00660 
00661 /* Function to call before using the operand instance table.
00662    This plugs the opcode entries and macro instructions into the cpu table.  */
00663 
00664 void
00665 openrisc_cgen_init_opcode_table (CGEN_CPU_DESC cd)
00666 {
00667   int i;
00668   int num_macros = (sizeof (openrisc_cgen_macro_insn_table) /
00669                   sizeof (openrisc_cgen_macro_insn_table[0]));
00670   const CGEN_IBASE *ib = & openrisc_cgen_macro_insn_table[0];
00671   const CGEN_OPCODE *oc = & openrisc_cgen_macro_insn_opcode_table[0];
00672   CGEN_INSN *insns = xmalloc (num_macros * sizeof (CGEN_INSN));
00673 
00674   memset (insns, 0, num_macros * sizeof (CGEN_INSN));
00675   for (i = 0; i < num_macros; ++i)
00676     {
00677       insns[i].base = &ib[i];
00678       insns[i].opcode = &oc[i];
00679       openrisc_cgen_build_insn_regex (& insns[i]);
00680     }
00681   cd->macro_insn_table.init_entries = insns;
00682   cd->macro_insn_table.entry_size = sizeof (CGEN_IBASE);
00683   cd->macro_insn_table.num_init_entries = num_macros;
00684 
00685   oc = & openrisc_cgen_insn_opcode_table[0];
00686   insns = (CGEN_INSN *) cd->insn_table.init_entries;
00687   for (i = 0; i < MAX_INSNS; ++i)
00688     {
00689       insns[i].opcode = &oc[i];
00690       openrisc_cgen_build_insn_regex (& insns[i]);
00691     }
00692 
00693   cd->sizeof_fields = sizeof (CGEN_FIELDS);
00694   cd->set_fields_bitsize = set_fields_bitsize;
00695 
00696   cd->asm_hash_p = asm_hash_insn_p;
00697   cd->asm_hash = asm_hash_insn;
00698   cd->asm_hash_size = CGEN_ASM_HASH_SIZE;
00699 
00700   cd->dis_hash_p = dis_hash_insn_p;
00701   cd->dis_hash = dis_hash_insn;
00702   cd->dis_hash_size = CGEN_DIS_HASH_SIZE;
00703 }