Open64 (mfef90, whirl2f, and IR tools)  TAG: version-openad; SVN changeset: 916
isa_pack_gen.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 // isa_pack_gen.h
00038 //
00039 //  Interface for packing instructions into an instruction word for all
00040 //  instructions in the ISA.
00041 //
00042 //  void ISA_Pack_Begin( const char* archname, int inst_bit_size )
00043 //      Initialize to generate instruction packing information for the 
00044 //      architecture with the given <archname>.  The information will be 
00045 //      written to the files targ_isa_pack.[ch].  <inst_bit_size>
00046 //      indicates how many bits in an instruction (operation) word.
00047 //
00048 //  TYPE ISA_PACK_TYPE
00049 //      An abstract type that describes different types of packing formats.
00050 //
00051 //  ISA_PACK_TYPE ISA_Pack_Type_Create( const char* name )
00052 //      Used to create a new ISA_PACK_TYPE.  <name> is the pack_type name.
00053 //      The rules to pack individual operands/results are added using the
00054 //      following two routines.
00055 //
00056 //  TYPE OPND_ADJ_TYPE
00057 //      An abstract type that describes different types of operand adjustments.
00058 //
00059 //  OPND_ADJ_TYPE Create_Operand_Adjustment(const char *name,
00060 //                                          const char *adj)
00061 //      Used to create a new operand adjustment. <name> is a descriptive
00062 //      name to be used in comments. <adj> is a string whose contents
00063 //      is a C expression that applies an adjustment to the value
00064 //      of an operand. The macro O_VAL is used to refer to the operand
00065 //      value. The expression should produce a value that is to
00066 //      replace the original value.
00067 //
00068 //  void Instruction_Pack_Group(ISA_PACK_TYPE pack_type, ...)
00069 //      Group instructions which have the same packing format but initialize
00070 //      <opcode_mask> separately for each TOP in this group. The variable
00071 //      part of the parameter list is the pair:
00072 //
00073 //              TOP top, <unsigned-type> opcode_mask
00074 //
00075 //      <unsigned-type> is an unsigned type large enough to hold the
00076 //      instruction word (must correspond with the inst_size parameter
00077 //      of ISA_Pack_Begin). The parameter list is ended by specifing 
00078 //      TOP_UNDEFINED for <top> (<opcode_mask> may be omitted on the 
00079 //      end of list marker).
00080 //
00081 //  void Operand (int operand_index,
00082 //                int opnd_position, 
00083 //                int inst_position,
00084 //                int width)
00085 //      The <operand_index>'th operand of the current packing type is 
00086 //      <width> bits wide. The bits are extracted from the operand at
00087 //      bit <opnd_position> and deposited into the instruction word
00088 //      at bit <inst_position>.
00089 //
00090 //      <opnd_position> will only be non-zero in cases where an operand
00091 //      is split amoung multiple bit fields of an instruction word.
00092 //      In such cases you would include multiple Operand specifications with
00093 //      the same <operand_index>, one for each field.
00094 //
00095 //  void Adjust_Operand(int operand_index, 
00096 //                      OPND_ADJ_TYPE pack_adj,
00097 //                      OPND_ADJ_TYPE unpack_adj)
00098 //      The <operand_index>'th operand of the current packing type
00099 //      requires an adjustment when going between assembler and binary
00100 //      forms. <pack_adj> specifies the adjustment when packing a binary
00101 //      instruction, and <unpack_adj> specifies the adjustment when
00102 //      unpacking a binary instruction.
00103 //
00104 //  void Result (int result_index, int bit_position, int width)
00105 //      The <result_index>'th result of the current packing type is
00106 //      at <bit_position> in the instruction word and is <width> bits long.
00107 //
00108 //  void Next_Word (void)
00109 //      In multiple word instructions, advance to the next word. Subsequent
00110 //      Operand and Result calls operate on this word.
00111 //
00112 //  void ISA_Pack_End(void)
00113 //      Complete processing of operands/results.
00114 //
00115 //
00117 
00118 
00119 
00120 #ifndef isa_pack_gen_INCLUDED
00121 #define isa_pack_gen_INCLUDED
00122 
00123 #ifdef _KEEP_RCS_ID
00124 #endif /* _KEEP_RCS_ID */
00125 
00126 #ifdef __cplusplus
00127 extern "C" {
00128 #endif
00129 
00130 typedef struct isa_pack_type *ISA_PACK_TYPE;
00131 
00132 typedef struct opnd_adj_type *OPND_ADJ_TYPE;
00133 
00134 extern void ISA_Pack_Begin ( const char* archname, int inst_bit_size );
00135 extern ISA_PACK_TYPE ISA_Pack_Type_Create ( const char* name );
00136 extern OPND_ADJ_TYPE Create_Operand_Adjustment(const char *name,
00137                                                const char *adj);
00138 extern void Instruction_Pack_Group (ISA_PACK_TYPE pack_type, ...);
00139 extern void Operand (int operand_index,
00140                      int opnd_position, 
00141                      int inst_position, 
00142                      int width);
00143 extern void Adjust_Operand(int operand_index, 
00144                            OPND_ADJ_TYPE pack_adj,
00145                            OPND_ADJ_TYPE unpack_adj);
00146 extern void Result (int result_index, int bit_position, int width);
00147 extern void Next_Word (void);
00148 extern void ISA_Pack_End(void);
00149 
00150 #ifdef __cplusplus
00151 }
00152 #endif
00153 #endif /* isa_pack_gen_INCLUDED */
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines