00001 /*BEGIN_LEGAL 00002 Intel Open Source License 00003 00004 Copyright (c) 2002-2009 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 */ 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-iform-enum.h" // a generated file 00053 #include "xed-iform-map.h" 00054 00055 struct xed_decoded_inst_s; //fwd-decl 00056 00057 typedef void (*xed_operand_extractor_fn_t)(struct xed_decoded_inst_s* xds); 00058 //typedef xed_bool_t (*xed_instruction_fixed_bit_confirmer_fn_t)(struct xed_decoded_inst_s* xds); 00059 00060 00063 typedef struct XED_DLL_EXPORT xed_operand_s 00064 { 00065 xed_operand_enum_t _name; 00066 xed_operand_visibility_enum_t _operand_visibility; // implicit, explicit, suppressed 00067 xed_operand_action_enum_t _rw; // read or written 00068 xed_operand_width_enum_t _oc2; // width code, could be invalid (then use register name) 00069 xed_operand_type_enum_t _type; // IMM, IMM_CONST, NT_LOOKU_FN, REG, ERROR 00070 xed_operand_element_xtype_enum_t _xtype; // xed data type: u32, f32, etc. 00071 xed_operand_convert_enum_t _cvt1; // decoration string 00072 xed_operand_convert_enum_t _cvt2; // decoration string 00073 xed_operand_convert_enum_t _cvt3; // decoration string 00074 union { 00075 xed_uint32_t _imm; // value for some constant immediates 00076 xed_nonterminal_enum_t _nt; // for nt_lookup_fn's 00077 xed_reg_enum_t _reg; // register name 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 00105 static XED_INLINE xed_operand_element_xtype_enum_t xed_operand_xtype(const xed_operand_t* p) { 00106 return p->_xtype; 00107 } 00108 00109 00111 static XED_INLINE xed_operand_width_enum_t xed_operand_width(const xed_operand_t* p) { 00112 return p->_oc2; 00113 } 00114 00116 static XED_INLINE 00117 xed_nonterminal_enum_t xed_operand_nonterminal_name(const xed_operand_t* p) { 00118 return p->_u._nt; 00119 } 00120 00130 static XED_INLINE xed_reg_enum_t xed_operand_reg(const xed_operand_t* p) { 00131 return p->_u._reg; 00132 } 00133 00134 00135 00146 static XED_INLINE xed_uint_t xed_operand_template_is_register(const xed_operand_t* p) { 00147 return p->_type == XED_OPERAND_TYPE_NT_LOOKUP_FN || p->_type == XED_OPERAND_TYPE_REG; 00148 } 00149 00153 static XED_INLINE xed_uint32_t xed_operand_imm(const xed_operand_t* p) { 00154 return p->_u._imm; 00155 } 00156 00162 XED_DLL_EXPORT void xed_operand_print(const xed_operand_t* p, char* buf, int buflen); 00164 00165 00166 00167 00168 00169 00170 00171 00172 00173 static XED_INLINE xed_uint_t xed_operand_is_register(xed_operand_enum_t name) { 00174 return name >= XED_OPERAND_REG0 && name <= XED_OPERAND_REG15; 00175 } 00181 static XED_INLINE xed_uint_t xed_operand_is_memory_addressing_register(xed_operand_enum_t name) { 00182 return ( name == XED_OPERAND_BASE0 || 00183 name == XED_OPERAND_INDEX || 00184 name == XED_OPERAND_SEG0 || 00185 name == XED_OPERAND_BASE1 || 00186 name == XED_OPERAND_SEG1 ); 00187 } 00188 00190 00192 00193 00194 00195 00196 static XED_INLINE xed_operand_action_enum_t xed_operand_rw(const xed_operand_t* p) { 00197 return p->_rw; 00198 } 00199 00202 XED_DLL_EXPORT xed_uint_t xed_operand_read(const xed_operand_t* p); 00205 XED_DLL_EXPORT xed_uint_t xed_operand_read_only(const xed_operand_t* p); 00208 XED_DLL_EXPORT xed_uint_t xed_operand_written(const xed_operand_t* p); 00211 XED_DLL_EXPORT xed_uint_t xed_operand_written_only(const xed_operand_t* p); 00214 XED_DLL_EXPORT xed_uint_t xed_operand_read_and_written(const xed_operand_t* p); 00217 XED_DLL_EXPORT xed_uint_t xed_operand_conditional_read(const xed_operand_t* p); 00220 XED_DLL_EXPORT xed_uint_t xed_operand_conditional_write(const xed_operand_t* p); 00222 00223 00224 #include "xed-gen-table-defs.h" 00225 XED_DLL_GLOBAL extern const xed_operand_t xed_operand[XED_MAX_OPERAND_TABLE_NODES]; 00226 00229 typedef struct XED_DLL_EXPORT xed_inst_s { 00230 00231 00232 // rflags info -- index in to the 2 tables of flags information. 00233 // If _flag_complex is true, then the data are in the 00234 // xed_flags_complex_table[]. Otherwise, the data are in the 00235 // xed_flags_simple_table[]. 00236 00237 //xed_instruction_fixed_bit_confirmer_fn_t _confirmer; 00238 00239 // number of operands in the operands array 00240 xed_uint8_t _noperands; 00241 xed_uint8_t _cpl; // the nominal CPL for the instruction. 00242 xed_uint16_t _flag_info_index; 00243 00244 xed_iform_enum_t _iform_enum; 00245 // index into the xed_operand[] array of xed_operand_t structures 00246 xed_uint32_t _operand_base; 00247 xed_bool_t _flag_complex; 00248 00249 // bit vector of values from the xed_attribute_enum_t 00250 xed_uint64_t _attributes; 00251 } xed_inst_t; 00252 00254 00255 00256 00257 00258 00259 00260 00261 XED_DLL_EXPORT unsigned int xed_inst_cpl(const xed_inst_t* p) ; 00262 00263 00264 //These next few are not doxygen commented because I want people to use the higher 00265 //level interface in xed-decoded-inst.h. 00266 static XED_INLINE xed_iclass_enum_t xed_inst_iclass(const xed_inst_t* p) { 00267 return xed_iform_to_iclass(p->_iform_enum); 00268 } 00269 00270 static XED_INLINE xed_category_enum_t xed_inst_category(const xed_inst_t* p) { 00271 return xed_iform_to_category(p->_iform_enum); 00272 } 00273 00274 static XED_INLINE xed_extension_enum_t xed_inst_extension(const xed_inst_t* p) { 00275 return xed_iform_to_extension(p->_iform_enum); 00276 } 00277 static XED_INLINE xed_isa_set_enum_t xed_inst_isa_set(const xed_inst_t* p) { 00278 return xed_iform_to_isa_set(p->_iform_enum); 00279 } 00280 00281 static XED_INLINE xed_iform_enum_t xed_inst_iform_enum(const xed_inst_t* p) { 00282 return p->_iform_enum; 00283 } 00284 00285 00288 static XED_INLINE unsigned int xed_inst_noperands(const xed_inst_t* p) { 00289 return p->_noperands; 00290 } 00291 00294 static XED_INLINE const xed_operand_t* xed_inst_operand(const xed_inst_t* p, unsigned int i) { 00295 xed_assert(i < p->_noperands); 00296 return &(xed_operand[p->_operand_base + i]); 00297 } 00298 00299 00300 00301 XED_DLL_EXPORT xed_uint32_t xed_inst_flag_info_index(const xed_inst_t* p); 00302 00304 00306 00307 00308 00309 static XED_INLINE xed_uint32_t xed_inst_get_attribute(const xed_inst_t* p, xed_attribute_enum_t attr) { 00310 const xed_uint64_t one = 1; 00311 if (p->_attributes & (one<<attr)) 00312 return 1; 00313 return 0; 00314 } 00315 00318 static XED_INLINE xed_uint64_t xed_inst_get_attributes(const xed_inst_t* p) { 00319 return p->_attributes; 00320 } 00323 XED_DLL_EXPORT unsigned int xed_attribute_max(void); 00324 00328 XED_DLL_EXPORT xed_attribute_enum_t xed_attribute(unsigned int i); 00329 00331 00332 00335 XED_DLL_EXPORT const xed_inst_t* xed_inst_table_base(void); 00336 00337 #endif
1.4.6