Open64 (mfef90, whirl2f, and IR tools)  TAG: version-openad; SVN changeset: 916
ti_asm.h
Go to the documentation of this file.
00001 /*
00002 
00003   Copyright (C) 2000, 2001 Silicon Graphics, Inc.  All Rights Reserved.
00004 
00005   This program is free software; you can redistribute it and/or modify it
00006   under the terms of version 2 of the GNU General Public License as
00007   published by the Free Software Foundation.
00008 
00009   This program is distributed in the hope that it would be useful, but
00010   WITHOUT ANY WARRANTY; without even the implied warranty of
00011   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  
00012 
00013   Further, this software is distributed without any warranty that it is
00014   free of the rightful claim of any third person regarding infringement 
00015   or the like.  Any license provided herein, whether implied or 
00016   otherwise, applies only to this software file.  Patent licenses, if 
00017   any, provided herein do not apply to combinations of this program with 
00018   other software, or any other product whatsoever.  
00019 
00020   You should have received a copy of the GNU General Public License along
00021   with this program; if not, write the Free Software Foundation, Inc., 59
00022   Temple Place - Suite 330, Boston MA 02111-1307, USA.
00023 
00024   Contact information:  Silicon Graphics, Inc., 1600 Amphitheatre Pky,
00025   Mountain View, CA 94043, or:
00026 
00027   http://www.sgi.com
00028 
00029   For further information regarding this notice, see:
00030 
00031   http://oss.sgi.com/projects/GenInfo/NoticeExplan
00032 
00033 */
00034 
00035 
00036 /* ====================================================================
00037  * ====================================================================
00038  *
00039  *
00040  *  Synopsis:
00041  *
00042  *      Support for assembling and disassembling instructions.
00043  *
00044  *  Interface Description:
00045  *
00046  *      Constants:
00047  *
00048  *          const INT TI_ASM_DISASM_ABI_REGS
00049  *
00050  *              TI_ASM_DisAsm_Inst flag that indicates the abi register
00051  *              names should be used; otherwise the hardware names are used.
00052  *
00053  *          const INT TI_ASM_DISASM_TRUE_PRED
00054  *
00055  *              TI_ASM_DisAsm_Inst flag that indicates that true predicates
00056  *              should be printed; otherwise true predicates are supporessed.
00057  *
00058  *      Exported functions:
00059  *
00060  *          INT TI_ASM_Pack_Inst(
00061  *              TOP topcode
00062  *              const INT64 *result
00063  *              const INT64 *opnd
00064  *              ISA_PACK_INST *pinst
00065  *          )
00066  *
00067  *              Assemble an instruction into object code. <topcode> is the 
00068  *              opcode of the instruction being assembled. <result> is an
00069  *              array of result values, indexed by result number. <opnd>
00070  *              is an array of operand values, indexed by operand number.
00071  *              A <result> or <opnd> value is whatever bit pattern 
00072  *              represents the operand, e.g. machine register number, 
00073  *              literal, etc.  <pinst> points to a buffer to receive the
00074  *              the instruction word(s).
00075  *
00076  *              On success, the return value indicates the number of
00077  *              instruction words written to the buffer pointed to by
00078  *              <pinst>. On error, the return value will be TI_RC_ERROR,
00079  *              and the error message copied to TI_errmsg.
00080  *
00081  *          INT TI_ASM_Print_Inst(
00082  *              TOP topcode
00083  *              const char **result
00084  *              const char **opnd
00085  *              FILE *f
00086  *          )
00087  *
00088  *              Assemble an instruction into printable assembly code.
00089  *              <topcode> is the opcode of the instruction being assembled. 
00090  *              <result> is an array of result values, indexed by result 
00091  *              number. <opnd> is an array of operand values, indexed by 
00092  *              operand number. A <result> or <opnd> value is the string 
00093  *              representation for the particular instruction operand, 
00094  *              e.g. machine register name, label, etc. The assembled 
00095  *              instruction is written to file <f>. No carriage control 
00096  *              is included in the copied string.
00097  *
00098  *              On success, the return value is the number of characters 
00099  *              that were written to the file (excluding the terminating null
00100  *              character). On error, the return value will be TI_RC_ERROR,
00101  *              and the error message copied to TI_errmsg.
00102  *
00103  *          INT TI_ASM_DisAsm_Inst(
00104  *              TOP topcode
00105  *              INT64 *result
00106  *              INT64 *opnd
00107  *              INT64 pc
00108  *              INT flags
00109  *              char *bufptr
00110  *          )
00111  *
00112  *              Disassemble an instruction into printable assembly code.
00113  *              <topcode> is the opcode of the instruction being disassembled. 
00114  *              <result> is an array of result values, indexed by result 
00115  *              number. <opnd> is an array of operand values, indexed by 
00116  *              operand number. A <result> or <opnd> value is whatever bit 
00117  *              pattern represents the operand, e.g. machine register number, 
00118  *              literal, etc. <pc> is the address of bundle containing
00119  *              the address (used only for formatting of pc-relative labels).
00120  *              <flags> one or more formatting flags (see TI_ASM_DISASM_xxx).
00121  *              <bufptr> is a pointer to a buffer to receive the disassembled 
00122  *              instruction.
00123  *
00124  *              On success, the return value is the number of characters 
00125  *              that were written to the buffer (excluding the terminating null
00126  *              character). On error, the return value will be TI_RC_ERROR,
00127  *              and the error message copied to TI_errmsg.
00128  *
00129  *          void TI_ASM_Set_Bundle_Comp(
00130  *              ISA_BUNDLE           *bundle,
00131  *              ISA_BUNDLE_PACK_COMP  comp,
00132  *              UINT64                val
00133  *          )
00134  *
00135  *              Set the <comp> field of the bundle pointed to by <bundle>
00136  *              to the value <val>. The contents of the field are overwritten,
00137  *              i.e. it is not necessary to zero the field (or bundle) first
00138  *              (quite handy for modifying a bundle field).
00139  *
00140  *          UINT64 TI_ASM_Get_Bundle_Comp(
00141  *              const ISA_BUNDLE     *bundle,
00142  *              ISA_BUNDLE_PACK_COMP  comp
00143  *          )
00144  *
00145  *              Get the value of the <comp> field of the bundle pointed to
00146  *              by <bundle>. If the component is not part of the bundle
00147  *              on the current architecture, 0 is returned.
00148  *
00149  *          void TI_ASM_Set_Bundle_Reloc_Value(
00150  *              ISA_BUNDLE *bundle,
00151  *              INT         slot,
00152  *              UINT64      val
00153  *          )
00154  *
00155  *              Set the relocatable value in the instruction in slot <slot> 
00156  *              of the bundle pointed to by <bundle> to the value <val>. 
00157  *              The contents of the instruction/bundle field are overwritten, 
00158  *              i.e. it is not necessary to zero the field.
00159  *
00160  *          UINT64 TI_ASM_Get_Bundle_Reloc_Value(
00161  *              const ISA_BUNDLE *bundle,
00162  *              INT               slot
00163  *          )
00164  *
00165  *              Get the value of the relocatable value in the instruction
00166  *              in slot <slot> of the bundle pointed to by <bundle>.
00167  *
00168  *          TOP TI_ASM_Unpack_Inst(
00169  *              ISA_PACK_INST *pinst,
00170  *              ISA_EXEC_UNIT  ex_unit,
00171  *              INT64         *result, 
00172  *              INT64         *opnd,
00173  *              BOOL           xlate_pseudo
00174  *          )
00175  *
00176  *              Decode and unpack the instruction pointed to by <pinst>
00177  *              which executes in execution unit <ex_unit>. The decoded 
00178  *              opcode is returned by function value, and the operands 
00179  *              and results are returned in the arrays <opnd> and <result>. 
00180  *              These arrays should be large enough to hold the maximum 
00181  *              number of operands and results (ISA_OPERAND_max_operands 
00182  *              and ISA_OPERAND_max_results respectively). If <xlate_pseudo> 
00183  *              is true and the instruction matches the pattern for a pseudo 
00184  *              instruction, the topcode and results/operands are translated 
00185  *              as appropriate.
00186  *
00187  * ====================================================================
00188  * ====================================================================
00189  */
00190 
00191 #ifndef ti_asm_INCLUDED
00192 #define ti_asm_INCLUDED
00193 
00194 #include <stdio.h>
00195 #include "topcode.h"
00196 #include "targ_isa_pack.h"
00197 #include "targ_isa_bundle.h"
00198 
00199 #ifdef __cplusplus
00200 extern "C" {
00201 #endif
00202 
00203 #ifdef _KEEP_RCS_ID
00204 #endif /* _KEEP_RCS_ID */
00205 
00206 #ifndef defs_INCLUDED
00207 #define defs_INCLUDED
00208 typedef signed int INT;
00209 typedef signed int INT32;
00210 typedef signed long long INT64;
00211 typedef signed char mINT8;
00212 typedef signed short mINT16;
00213 typedef signed int mINT32;
00214 typedef signed long long mINT64;
00215 typedef unsigned int UINT;
00216 typedef unsigned int UINT32;
00217 typedef unsigned long long UINT64;
00218 typedef unsigned char mUINT8;
00219 typedef unsigned short mUINT16;
00220 typedef unsigned int mUINT32;
00221 typedef unsigned long long mUINT64;
00222 typedef int BOOL;
00223 typedef unsigned char mBOOL;
00224 #ifndef TRUE
00225 #define TRUE    ((BOOL) 1)
00226 #endif
00227 #ifndef FALSE
00228 #define FALSE   ((BOOL) 0)
00229 #endif
00230 #if defined(_LANGUAGE_C) && !defined(inline)
00231 #define inline static __inline
00232 #endif
00233 #endif
00234 
00235 #define TI_ASM_DISASM_ABI_REGS  (0x01)
00236 #define TI_ASM_DISASM_TRUE_PRED (0x02)
00237 
00238 extern INT TI_ASM_Pack_Inst(
00239   TOP topcode,
00240   const INT64 *result,
00241   const INT64 *opnd,
00242   ISA_PACK_INST *pinst
00243 );
00244 
00245 extern INT TI_ASM_Print_Inst(
00246   TOP topcode,
00247   const char **result,
00248   const char **opnd,
00249   FILE *f
00250 );
00251 
00252 extern INT TI_ASM_DisAsm_Inst(
00253   TOP topcode,
00254   INT64 *result,
00255   INT64 *opnd,
00256   INT64 pc,
00257   INT flags,
00258   char *bufptr
00259 );
00260 
00261 extern void TI_ASM_Set_Bundle_Comp(
00262   ISA_BUNDLE           *bundle,
00263   ISA_BUNDLE_PACK_COMP  comp,
00264   UINT64                val
00265 );
00266 
00267 extern UINT64 TI_ASM_Get_Bundle_Comp(
00268   const ISA_BUNDLE     *bundle,
00269   ISA_BUNDLE_PACK_COMP  comp
00270 );
00271 
00272 extern void TI_ASM_Set_Bundle_Reloc_Value(
00273   ISA_BUNDLE *bundle,
00274   INT         slot,
00275   UINT64      val
00276 );
00277 
00278 extern UINT64 TI_ASM_Get_Bundle_Reloc_Value(
00279   const ISA_BUNDLE *bundle,
00280   INT               slot
00281 );
00282 
00283 extern TOP TI_ASM_Unpack_Inst(
00284   const ISA_PACK_INST *inst,
00285   ISA_EXEC_UNIT        ex_unit,
00286   INT64               *result, 
00287   INT64               *opnd,
00288   BOOL                 xlate_pseudo
00289 );
00290 
00291 #ifdef __cplusplus
00292 }
00293 #endif
00294 #endif /* ti_asm_INCLUDED */
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines