xed-inst.h

Go to the documentation of this file.
00001 /*BEGIN_LEGAL 
00002 Intel Open Source License 
00003 
00004 Copyright (c) 2002-2015 Intel Corporation. All rights reserved.
00005  
00006 Redistribution and use in source and binary forms, with or without
00007 modification, are permitted provided that the following conditions are
00008 met:
00009 
00010 Redistributions of source code must retain the above copyright notice,
00011 this list of conditions and the following disclaimer.  Redistributions
00012 in binary form must reproduce the above copyright notice, this list of
00013 conditions and the following disclaimer in the documentation and/or
00014 other materials provided with the distribution.  Neither the name of
00015 the Intel Corporation nor the names of its contributors may be used to
00016 endorse or promote products derived from this software without
00017 specific prior written permission.
00018  
00019 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00020 ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00021 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
00022 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE INTEL OR
00023 ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
00024 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
00025 LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
00026 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
00027 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00028 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
00029 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00030 END_LEGAL */
00032 
00033 
00034 #if !defined(_XED_INST_H_)
00035 # define _XED_INST_H_
00036 
00037 #include "xed-util.h"
00038 #include "xed-portability.h"
00039 #include "xed-category-enum.h" // generated
00040 #include "xed-extension-enum.h" //generated
00041 #include "xed-iclass-enum.h" //generated
00042 #include "xed-operand-enum.h" // generated
00043 #include "xed-operand-visibility-enum.h" //generated
00044 #include "xed-operand-action-enum.h" // generated
00045 #include "xed-operand-convert-enum.h" // generated
00046 #include "xed-operand-type-enum.h" // generated
00047 #include "xed-nonterminal-enum.h" // a generated file
00048 #include "xed-operand-width-enum.h" // a generated file
00049 #include "xed-operand-element-xtype-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-exception-enum.h" // a generated file
00053 #include "xed-iform-enum.h" // a generated file
00054 #include "xed-iform-map.h" 
00055 #include "xed-attributes.h"
00056 
00057 struct xed_decoded_inst_s; //fwd-decl
00058 
00059 typedef void (*xed_operand_extractor_fn_t)(struct xed_decoded_inst_s* xds);
00060 
00061 
00066 typedef struct xed_operand_s
00067 {
00068     xed_operand_enum_t               _name;
00069     
00070      // implicit, explicit, suppressed
00071     xed_operand_visibility_enum_t    _operand_visibility; 
00072     xed_operand_action_enum_t        _rw;   // read or written
00073     
00074      // width code, could be invalid (then use register name)
00075     xed_operand_width_enum_t         _oc2;
00076     
00077      // IMM, IMM_CONST, NT_LOOKUP_FN, REG, ERROR
00078     xed_operand_type_enum_t          _type;
00079     xed_operand_element_xtype_enum_t _xtype; // xed data type: u32, f32, etc.
00080     xed_uint8_t                      _cvt_idx; //  decoration index
00081     union {
00082         xed_uint32_t                 _imm;  // value for some constant immmed
00083         xed_nonterminal_enum_t       _nt;   // for nt_lookup_fn's
00084         xed_reg_enum_t               _reg;  // register name
00085     } _u;
00086 }  xed_operand_t;    
00087 
00089 
00090 
00091 static XED_INLINE xed_operand_enum_t
00092 xed_operand_name(const xed_operand_t* p)  { 
00093     return p->_name; 
00094 }
00095 
00096 
00098 static XED_INLINE xed_operand_visibility_enum_t 
00099 xed_operand_operand_visibility( const xed_operand_t* p) { 
00100     return p->_operand_visibility; 
00101 }
00102 
00103 
00107 static XED_INLINE xed_operand_type_enum_t
00108 xed_operand_type(const xed_operand_t* p)  {
00109     return p->_type; 
00110 }
00111 
00115 static XED_INLINE xed_operand_element_xtype_enum_t
00116 xed_operand_xtype(const xed_operand_t* p)  {
00117     return p->_xtype; 
00118 }
00119 
00120 
00122 static XED_INLINE xed_operand_width_enum_t
00123 xed_operand_width(const xed_operand_t* p)  { 
00124     return p->_oc2; 
00125 }
00126 
00133 XED_DLL_EXPORT xed_uint32_t
00134 xed_operand_width_bits(const xed_operand_t* p,
00135                        const xed_uint32_t eosz);
00136 
00138 static XED_INLINE xed_nonterminal_enum_t
00139 xed_operand_nonterminal_name(const xed_operand_t* p)  {
00140     if (xed_operand_type(p) == XED_OPERAND_TYPE_NT_LOOKUP_FN)
00141         return p->_u._nt;
00142     return XED_NONTERMINAL_INVALID;
00143 }
00144 
00154 static XED_INLINE xed_reg_enum_t xed_operand_reg(const xed_operand_t* p) {
00155     if (xed_operand_type(p) == XED_OPERAND_TYPE_REG)
00156         return p->_u._reg;
00157     return XED_REG_INVALID;
00158 }
00159 
00160 
00161 
00172 static XED_INLINE xed_uint_t
00173 xed_operand_template_is_register(const xed_operand_t* p) {
00174     return p->_type == XED_OPERAND_TYPE_NT_LOOKUP_FN ||
00175            p->_type == XED_OPERAND_TYPE_REG;
00176 }
00177 
00182 static XED_INLINE xed_uint32_t xed_operand_imm(const xed_operand_t* p) {
00183     if (xed_operand_type(p) == XED_OPERAND_TYPE_IMM_CONST)
00184         return p->_u._imm;
00185     return 0; 
00186 }
00187 
00193 XED_DLL_EXPORT void
00194 xed_operand_print(const xed_operand_t* p, char* buf, int buflen);
00196 
00198 
00199 
00200 
00201 
00202 
00203 
00204 
00205 
00206 static XED_INLINE xed_uint_t xed_operand_is_register(xed_operand_enum_t name) {
00207     return name >= XED_OPERAND_REG0 && name <= XED_OPERAND_REG8;
00208 }
00214 static XED_INLINE xed_uint_t
00215 xed_operand_is_memory_addressing_register(xed_operand_enum_t name) {
00216     return  ( name == XED_OPERAND_BASE0 || 
00217               name == XED_OPERAND_INDEX ||
00218               name == XED_OPERAND_SEG0  ||
00219               name == XED_OPERAND_BASE1 || 
00220               name == XED_OPERAND_SEG1 );
00221 }
00222 
00224 
00226 
00227 
00228 
00229 
00230 static XED_INLINE xed_operand_action_enum_t
00231 xed_operand_rw(const xed_operand_t* p)  { 
00232     return p->_rw; 
00233 }
00234 
00237 XED_DLL_EXPORT xed_uint_t xed_operand_read(const xed_operand_t* p);
00240 XED_DLL_EXPORT xed_uint_t xed_operand_read_only(const xed_operand_t* p);
00243 XED_DLL_EXPORT xed_uint_t xed_operand_written(const xed_operand_t* p);
00246 XED_DLL_EXPORT xed_uint_t xed_operand_written_only(const xed_operand_t* p);
00249 XED_DLL_EXPORT xed_uint_t xed_operand_read_and_written(const xed_operand_t* p);
00252 XED_DLL_EXPORT xed_uint_t xed_operand_conditional_read(const xed_operand_t* p);
00255 XED_DLL_EXPORT xed_uint_t xed_operand_conditional_write(const xed_operand_t* p);
00257 
00258 
00263 typedef struct xed_inst_s {
00264 
00265 
00266     // rflags info -- index in to the 2 tables of flags information. 
00267     // If _flag_complex is true, then the data are in the
00268     // xed_flags_complex_table[]. Otherwise, the data are in the
00269     // xed_flags_simple_table[].
00270 
00271     //xed_instruction_fixed_bit_confirmer_fn_t _confirmer;
00272     
00273     // number of operands in the operands array
00274     xed_uint8_t _noperands; 
00275     xed_uint8_t _cpl;  // the nominal CPL for the instruction.
00276     xed_uint16_t _flag_info_index; 
00277 
00278     xed_iform_enum_t _iform_enum;
00279     // index into the xed_operand[] array of xed_operand_t structures
00280     xed_uint16_t _operand_base; 
00281     xed_uint16_t _flag_complex; /* 1/0 valued, bool type */
00282 
00283     // index to table of xed_attributes_t structures
00284     xed_uint16_t _attributes;
00285     xed_exception_enum_t _exceptions;
00286 }  xed_inst_t;
00287 
00289 
00290 
00291 
00292 
00293 
00294 
00295 
00296 XED_DLL_EXPORT unsigned int xed_inst_cpl(const xed_inst_t* p) ;
00297 
00298 
00299 //These next few are not doxygen commented because I want people to use the
00300 //higher level interface in xed-decoded-inst.h.
00301 static XED_INLINE xed_iclass_enum_t xed_inst_iclass(const xed_inst_t* p) {
00302     return xed_iform_to_iclass(p->_iform_enum);
00303 }
00304 
00305 static XED_INLINE xed_category_enum_t xed_inst_category(const xed_inst_t* p) {
00306     return xed_iform_to_category(p->_iform_enum);
00307 }
00308 
00309 static XED_INLINE xed_extension_enum_t xed_inst_extension(const xed_inst_t* p) {
00310     return xed_iform_to_extension(p->_iform_enum);
00311 }
00312 static XED_INLINE xed_isa_set_enum_t xed_inst_isa_set(const xed_inst_t* p) {
00313     return xed_iform_to_isa_set(p->_iform_enum);
00314 }
00315 
00316 static XED_INLINE xed_iform_enum_t xed_inst_iform_enum(const xed_inst_t* p) {
00317     return p->_iform_enum;
00318 }
00319 
00320 
00323 static XED_INLINE unsigned int xed_inst_noperands(const xed_inst_t* p) {
00324     return p->_noperands;
00325 }
00326 
00329 XED_DLL_EXPORT const xed_operand_t*
00330 xed_inst_operand(const xed_inst_t* p, unsigned int i);
00331 
00332 
00333 
00334 XED_DLL_EXPORT xed_uint32_t xed_inst_flag_info_index(const xed_inst_t* p);
00335 
00337 
00339 
00340 
00341 
00342 XED_DLL_EXPORT xed_uint32_t
00343 xed_inst_get_attribute(const xed_inst_t* p, 
00344                        xed_attribute_enum_t attr);
00345 
00348 XED_DLL_EXPORT xed_attributes_t
00349 xed_inst_get_attributes(const xed_inst_t* p);
00350 
00351 
00355 XED_DLL_EXPORT unsigned int xed_attribute_max(void);
00356 
00360 XED_DLL_EXPORT xed_attribute_enum_t xed_attribute(unsigned int i);
00361 
00363 
00365 
00366 
00367 
00368 
00369 static XED_INLINE
00370 xed_exception_enum_t xed_inst_exception(const xed_inst_t* p) {
00371     return p->_exceptions;
00372 }
00373 
00375 
00376 
00377 XED_DLL_EXPORT const xed_inst_t* xed_inst_table_base(void);
00378 
00379 #endif

Generated on Wed Jan 21 02:14:35 2015 for XED by  doxygen 1.4.6