Back to index

cell-binutils  2.17cvs20070401
or32.h
Go to the documentation of this file.
00001 /* Table of opcodes for the OpenRISC 1000 ISA.
00002    Copyright 2002, 2003 Free Software Foundation, Inc.
00003    Contributed by Damjan Lampret (lampret@opencores.org).
00004    
00005    This file is part of or1k_gen_isa, or1ksim, GDB and GAS.
00006 
00007    This program is free software; you can redistribute it and/or modify
00008    it under the terms of the GNU General Public License as published by
00009    the Free Software Foundation; either version 2 of the License, or
00010    (at your option) any later version.
00011 
00012    This program is distributed in the hope that it will be useful,
00013    but WITHOUT ANY WARRANTY; without even the implied warranty of
00014    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015    GNU General Public License for more details.
00016 
00017    You should have received a copy of the GNU General Public License
00018    along with this program; if not, write to the Free Software
00019    Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.  */
00020 
00021 /* We treat all letters the same in encode/decode routines so
00022    we need to assign some characteristics to them like signess etc.  */
00023 
00024 #ifndef OR32_H_ISA
00025 #define OR32_H_ISA
00026 
00027 #define NUM_UNSIGNED (0)
00028 #define NUM_SIGNED (1)
00029 
00030 #define MAX_GPRS 32
00031 #define PAGE_SIZE 4096
00032 #undef __HALF_WORD_INSN__
00033 
00034 #define OPERAND_DELIM (',')
00035 
00036 #define OR32_IF_DELAY (1)
00037 #define OR32_W_FLAG   (2)
00038 #define OR32_R_FLAG   (4)
00039 
00040 struct or32_letter
00041 {
00042   char letter;
00043   int  sign;
00044   /* int  reloc; relocation per letter ??  */
00045 };
00046 
00047 /* Main instruction specification array.  */
00048 struct or32_opcode
00049 {
00050   /* Name of the instruction.  */
00051   char *name;
00052 
00053   /* A string of characters which describe the operands.
00054      Valid characters are:
00055      ,() Itself.  Characters appears in the assembly code.
00056      rA        Register operand.
00057      rB  Register operand.
00058      rD  Register operand.
00059      I  An immediate operand, range -32768 to 32767.
00060      J  An immediate operand, range . (unused)
00061      K  An immediate operand, range 0 to 65535.
00062      L  An immediate operand, range 0 to 63.
00063      M  An immediate operand, range . (unused)
00064      N  An immediate operand, range -33554432 to 33554431.
00065      O  An immediate operand, range . (unused).  */
00066   char *args;
00067   
00068   /* Opcode and operand encoding.  */
00069   char *encoding;
00070   void (*exec) (void);
00071   unsigned int flags;
00072 };
00073 
00074 #define OPTYPE_LAST (0x80000000)
00075 #define OPTYPE_OP   (0x40000000)
00076 #define OPTYPE_REG  (0x20000000)
00077 #define OPTYPE_SIG  (0x10000000)
00078 #define OPTYPE_DIS  (0x08000000)
00079 #define OPTYPE_DST  (0x04000000)
00080 #define OPTYPE_SBIT (0x00001F00)
00081 #define OPTYPE_SHR  (0x0000001F)
00082 #define OPTYPE_SBIT_SHR (8)
00083 
00084 /* MM: Data how to decode operands.  */
00085 extern struct insn_op_struct
00086 {
00087   unsigned long type;
00088   unsigned long data;
00089 } **op_start;
00090 
00091 #ifdef HAS_EXECUTION
00092 extern void l_invalid (void);
00093 extern void l_sfne    (void);
00094 extern void l_bf      (void);
00095 extern void l_add     (void);
00096 extern void l_sw      (void);
00097 extern void l_sb      (void);
00098 extern void l_sh      (void);
00099 extern void l_lwz     (void);
00100 extern void l_lbs     (void);
00101 extern void l_lbz     (void);
00102 extern void l_lhs     (void);
00103 extern void l_lhz     (void);
00104 extern void l_movhi   (void);
00105 extern void l_and     (void);
00106 extern void l_or      (void);
00107 extern void l_xor     (void);
00108 extern void l_sub     (void);
00109 extern void l_mul     (void);
00110 extern void l_div     (void);
00111 extern void l_divu    (void);
00112 extern void l_sll     (void);
00113 extern void l_sra     (void);
00114 extern void l_srl     (void);
00115 extern void l_j       (void);
00116 extern void l_jal     (void);
00117 extern void l_jalr    (void);
00118 extern void l_jr      (void);
00119 extern void l_rfe     (void);
00120 extern void l_nop     (void);
00121 extern void l_bnf     (void);
00122 extern void l_sfeq    (void);
00123 extern void l_sfgts   (void);
00124 extern void l_sfges   (void);
00125 extern void l_sflts   (void);
00126 extern void l_sfles   (void);
00127 extern void l_sfgtu   (void);
00128 extern void l_sfgeu   (void);
00129 extern void l_sfltu   (void);
00130 extern void l_sfleu   (void);
00131 extern void l_mtspr   (void);
00132 extern void l_mfspr   (void);
00133 extern void l_sys     (void);
00134 extern void l_trap    (void); /* CZ 21/06/01.  */
00135 extern void l_macrc   (void);
00136 extern void l_mac     (void);
00137 extern void l_msb     (void);
00138 extern void l_invalid (void);
00139 extern void l_cust1   (void);
00140 extern void l_cust2   (void);
00141 extern void l_cust3   (void);
00142 extern void l_cust4   (void);
00143 #endif
00144 extern void l_none    (void);
00145 
00146 extern const struct or32_letter or32_letters[];
00147 
00148 extern const struct  or32_opcode or32_opcodes[];
00149 
00150 extern const unsigned int or32_num_opcodes;
00151 
00152 /* Calculates instruction length in bytes.  Always 4 for OR32.  */
00153 extern int insn_len (int);
00154 
00155 /* Is individual insn's operand signed or unsigned?  */
00156 extern int letter_signed (char);
00157 
00158 /* Number of letters in the individual lettered operand.  */
00159 extern int letter_range (char);
00160 
00161 /* MM: Returns index of given instruction name.  */
00162 extern int insn_index (char *);
00163 
00164 /* MM: Returns instruction name from index.  */
00165 extern const char *insn_name (int);
00166 
00167 /* MM: Constructs new FSM, based on or32_opcodes.  */ 
00168 extern void build_automata (void);
00169 
00170 /* MM: Destructs FSM.  */ 
00171 extern void destruct_automata (void);
00172 
00173 /* MM: Decodes instruction using FSM.  Call build_automata first.  */
00174 extern int insn_decode (unsigned int);
00175 
00176 /* Disassemble one instruction from insn to disassemble.
00177    Return the size of the instruction.  */
00178 int disassemble_insn (unsigned long);
00179 
00180 #endif