xed-inst.h

Go to the documentation of this file.
00001 /*BEGIN_LEGAL 
00002 Copyright (c) 2007, Intel Corp.
00003 All rights reserved.
00004 
00005 Redistribution and use in source and binary forms, with or without
00006 modification, are permitted provided that the following conditions are
00007 met:
00008 
00009     * Redistributions of source code must retain the above copyright
00010       notice, this list of conditions and the following disclaimer.
00011 
00012     * Redistributions in binary form must reproduce the above
00013       copyright notice, this list of conditions and the following
00014       disclaimer in the documentation and/or other materials provided
00015       with the distribution.
00016 
00017     * Neither the name of Intel Corporation nor the names of its
00018       contributors may be used to endorse or promote products derived
00019       from this software without specific prior written permission.
00020 
00021 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00022 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00023 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
00024 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
00025 OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
00026 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
00027 LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
00028 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
00029 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00030 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
00031 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00032 END_LEGAL */
00035 
00036 #if !defined(_XED_INST_H_)
00037 # define _XED_INST_H_
00038 
00039 #include "xed-util.h"
00040 #include "xed-portability.h"
00041 #include "xed-category-enum.h"
00042 #include "xed-extension-enum.h"
00043 #include "xed-iclass-enum.h"
00044 #include "xed-operand-enum.h"
00045 #include "xed-operand-visibility-enum.h"
00046 #include "xed-operand-action-enum.h"
00047 #include "xed-operand-type-enum.h"
00048 #include "xed-nonterminal-enum.h" // a generated file
00049 #include "xed-operand-width-enum.h" // a generated file
00050 #include "xed-reg-enum.h" // a generated file
00051 #include "xed-attribute-enum.h" // a generated file
00052 #include "xed-iform-enum.h" // a generated file
00053 #include "xed-operand-bitvec.h" // a generated file
00054 
00055 
00056 struct xed_decoded_inst_s; //fwd-decl
00057 
00058 typedef void (*xed_operand_extractor_fn_t)(struct xed_decoded_inst_s* xds);
00059 //typedef xed_bool_t (*xed_instruction_fixed_bit_confirmer_fn_t)(struct xed_decoded_inst_s* xds);
00060 
00061 
00064 typedef struct XED_DLL_EXPORT xed_operand_s
00065 {
00066     xed_operand_enum_t _name;
00067     
00068     xed_operand_visibility_enum_t _operand_visibility;
00069 
00070     xed_operand_action_enum_t _rw;
00071     xed_operand_width_enum_t _oc2;
00072 
00073     xed_operand_type_enum_t _type;
00074     union {
00075         xed_uint32_t               _imm; 
00076         xed_nonterminal_enum_t _nt; // for nt_lookup_fn's
00077         xed_reg_enum_t         _reg;
00078     } _u;
00079 }  xed_operand_t;    
00080 
00082 
00083 
00084 static XED_INLINE xed_operand_enum_t xed_operand_name(const xed_operand_t* p)  { 
00085     return p->_name; 
00086 }
00087 
00088 
00090 static XED_INLINE xed_operand_visibility_enum_t  xed_operand_operand_visibility( const xed_operand_t* p) { 
00091     return p->_operand_visibility; 
00092 }
00093 
00094 
00098 static XED_INLINE xed_operand_type_enum_t xed_operand_type(const xed_operand_t* p)  {
00099     return p->_type; 
00100 }
00101 
00102 
00104 static XED_INLINE xed_operand_width_enum_t xed_operand_width(const xed_operand_t* p)  { 
00105     return p->_oc2; 
00106 }
00107 
00109 static XED_INLINE 
00110 xed_nonterminal_enum_t xed_operand_nonterminal_name(const xed_operand_t* p)  { 
00111     return p->_u._nt; 
00112 }
00113 
00123 static XED_INLINE xed_reg_enum_t xed_operand_reg(const xed_operand_t* p) {
00124     return p->_u._reg;
00125 }
00126 
00127 
00128 
00139 static XED_INLINE xed_uint_t xed_operand_template_is_register(const xed_operand_t* p) {
00140     return p->_type == XED_OPERAND_TYPE_NT_LOOKUP_FN || p->_type == XED_OPERAND_TYPE_REG;
00141 }
00142 
00146 static XED_INLINE xed_uint32_t xed_operand_imm(const xed_operand_t* p) {
00147     return p->_u._imm;
00148 }
00149 
00155 XED_DLL_EXPORT void    xed_operand_print(const xed_operand_t* p, char* buf, int buflen);
00157 
00158 
00159 
00160 
00161 
00162 
00163 
00164 
00165 
00166 static XED_INLINE xed_uint_t xed_operand_is_register(xed_operand_enum_t name) {
00167     return name >= XED_OPERAND_REG0 && name <= XED_OPERAND_REG15;
00168 }
00174 static XED_INLINE xed_uint_t xed_operand_is_memory_addressing_register(xed_operand_enum_t name) {
00175     return  ( name == XED_OPERAND_BASE0 || 
00176               name == XED_OPERAND_INDEX ||
00177               name == XED_OPERAND_SEG0  ||
00178               name == XED_OPERAND_BASE1 || 
00179               name == XED_OPERAND_SEG1 );
00180 }
00181 
00183 
00185 
00186 
00187 
00188 
00189 static XED_INLINE xed_operand_action_enum_t xed_operand_rw(const xed_operand_t* p)  { 
00190     return p->_rw; 
00191 }
00192 
00195 XED_DLL_EXPORT xed_uint_t xed_operand_read(const xed_operand_t* p);
00198 XED_DLL_EXPORT xed_uint_t xed_operand_read_only(const xed_operand_t* p);
00201 XED_DLL_EXPORT xed_uint_t xed_operand_written(const xed_operand_t* p);
00204 XED_DLL_EXPORT xed_uint_t xed_operand_written_only(const xed_operand_t* p);
00207 XED_DLL_EXPORT xed_uint_t xed_operand_read_and_written(const xed_operand_t* p);
00210 XED_DLL_EXPORT xed_uint_t xed_operand_conditional_read(const xed_operand_t* p);
00213 XED_DLL_EXPORT xed_uint_t xed_operand_conditional_write(const xed_operand_t* p);
00215 
00216 
00217 #include "xed-gen-table-defs.h"
00218 XED_DLL_GLOBAL extern const  xed_operand_t xed_operand[XED_MAX_OPERAND_TABLE_NODES];
00219 
00222 typedef struct XED_DLL_EXPORT xed_inst_s {
00223     xed_iclass_enum_t _iclass;
00224     xed_category_enum_t _category;
00225     xed_extension_enum_t _extension;
00226     xed_operand_bitvec_t _operand_bitvec;
00227     // The instruction form for this iclass.  The iform is a zero-based dense sequence for each iclass.
00228     xed_uint8_t _iform;
00229     xed_iform_enum_t _iform_enum;
00230 
00231     //xed_instruction_fixed_bit_confirmer_fn_t _confirmer;
00232     
00233     // number of operands in the operands array
00234     xed_uint8_t _noperands; 
00235 
00236     // index into the xed_operand[] array of xed_operand_t structures
00237     xed_uint32_t _operand_base; 
00238     // bit vector of values from the xed_attribute_enum_t
00239     xed_uint32_t _attributes;
00240 
00241     // rflags info -- index in to the 2 tables of flags information. 
00242     // If _flag_complex is true, then the data are in the
00243     // xed_flags_complex_table[]. Otherwise, the data are in the
00244     // xed_flags_simple_table[].
00245     xed_uint16_t _flag_info_index; 
00246     xed_bool_t  _flag_complex;
00247 
00248     xed_uint8_t _cpl;  // the nominal CPL for the instruction.
00249 }  xed_inst_t;
00250 
00252 
00253 
00254 
00255 XED_DLL_EXPORT unsigned int xed_inst_cpl(const xed_inst_t* p) ;
00256 
00257 
00258 //These next few are not doxygen commented because I want people to use the higher
00259 //level interface in xed-decoded-inst.h.
00260 static XED_INLINE xed_iclass_enum_t xed_inst_iclass(const xed_inst_t* p) {
00261     return p->_iclass;
00262 }
00263 
00264 static XED_INLINE xed_category_enum_t xed_inst_category(const xed_inst_t* p) {
00265     return p->_category;
00266 }
00267 
00268 static XED_INLINE xed_extension_enum_t xed_inst_extension(const xed_inst_t* p) {
00269     return p->_extension;
00270 }
00271 
00272 static XED_INLINE xed_uint_t xed_inst_iform(const xed_inst_t* p) {
00273     return p->_iform;
00274 }
00275 static XED_INLINE xed_iform_enum_t xed_inst_iform_enum(const xed_inst_t* p) {
00276     return p->_iform_enum;
00277 }
00278 
00279 
00282 static XED_INLINE unsigned int xed_inst_noperands(const xed_inst_t* p) {
00283     return p->_noperands;
00284 }
00285 
00288 static XED_INLINE const xed_operand_t* xed_inst_operand(const xed_inst_t* p, unsigned int i)    {
00289     xed_assert(i <  p->_noperands);
00290     return &(xed_operand[p->_operand_base + i]);
00291 }
00292 
00293 
00294 
00295 XED_DLL_EXPORT xed_uint32_t xed_inst_flag_info_index(const xed_inst_t* p);
00296 
00298 
00300 
00301 
00302 
00303 static XED_INLINE xed_uint32_t xed_inst_get_attribute(const xed_inst_t* p, xed_attribute_enum_t attr) {
00304     if (p->_attributes & attr) 
00305         return 1;
00306     return 0;
00307 }
00308 
00311 static XED_INLINE xed_uint32_t xed_inst_get_attributes(const xed_inst_t* p) {
00312     return p->_attributes;
00313 }
00316 XED_DLL_EXPORT unsigned int xed_attribute_max();
00317 
00321 XED_DLL_EXPORT xed_attribute_enum_t xed_attribute(unsigned int i);
00322 
00324 
00325 #endif

Generated on Thu May 15 03:15:09 2008 for XED2 by  doxygen 1.4.6