- Main Page
- Modules
- Data Structures
- Files

- Search for |

- File List
- Globals

# xed-decoded-inst-api.h

Go to the documentation of this file.

    00001 /*BEGIN_LEGAL
    00002 Intel Open Source License
    00003
    00004 Copyright (c) 2002-2014 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_DECODED_INST_API_H_)
    00035 # define _XED_DECODED_INST_API_H_
    00036
    00037 #include "xed-decoded-inst.h"
    00038 #include "xed-operand-accessors.h"
    00039 #include "xed-state.h"
    00040 #include "xed-operand-values-interface.h"
    00041
    00045
    00047
    00048
    00049
    00050 static XED_INLINE xed_bool_t xed_decoded_inst_valid(const xed_decoded_inst_t* p ) {
    00051     return XED_STATIC_CAST(xed_bool_t,(p->_inst != 0));
    00052 }
    00055 static XED_INLINE const xed_inst_t* xed_decoded_inst_inst( const xed_decoded_inst_t* p) {
    00056     return p->_inst;
    00057 }
    00058
    00059
    00062 static XED_INLINE xed_category_enum_t xed_decoded_inst_get_category(const xed_decoded_inst_t* p) {
    00063     xed_assert(p->_inst != 0);
    00064     return xed_inst_category(p->_inst);
    00065 }
    00068 static XED_INLINE xed_extension_enum_t xed_decoded_inst_get_extension( const xed_decoded_inst_t* p) {
    00069     xed_assert(p->_inst != 0);
    00070     return xed_inst_extension(p->_inst);
    00071 }
    00074 static XED_INLINE xed_isa_set_enum_t xed_decoded_inst_get_isa_set(xed_decoded_inst_t const* const p) {
    00075     xed_assert(p->_inst != 0);
    00076     return xed_inst_isa_set(p->_inst);
    00077 }
    00080 static XED_INLINE xed_iclass_enum_t xed_decoded_inst_get_iclass( const xed_decoded_inst_t* p){
    00081     xed_assert(p->_inst != 0);
    00082     return xed_inst_iclass(p->_inst);
    00083 }
    00084
    00086
    00087
    00088
    00089 XED_DLL_EXPORT xed_uint32_t
    00090 xed_decoded_inst_get_attribute(const xed_decoded_inst_t* p,
    00091                                xed_attribute_enum_t attr);
    00092
    00095 XED_DLL_EXPORT xed_attributes_t
    00096 xed_decoded_inst_get_attributes(const xed_decoded_inst_t* p);
    00098
    00101 XED_DLL_EXPORT xed_uint32_t
    00102 xed_decoded_inst_is_xacquire(const xed_decoded_inst_t* p);
    00103
    00106 XED_DLL_EXPORT xed_uint32_t
    00107 xed_decoded_inst_is_xrelease(const xed_decoded_inst_t* p);
    00108
    00111 XED_DLL_EXPORT xed_uint32_t
    00112 xed_decoded_inst_has_mpx_prefix(const xed_decoded_inst_t* p);
    00113
    00116 XED_DLL_EXPORT xed_uint8_t
    00117 xed_decoded_inst_get_modrm(const xed_decoded_inst_t* p);
    00118
    00122 XED_DLL_EXPORT xed_bool_t
    00123 xed_decoded_inst_masked_vector_operation(xed_decoded_inst_t* p);
    00124
    00131 XED_DLL_EXPORT xed_uint_t
    00132 xed_decoded_inst_vector_length_bits(xed_decoded_inst_t const* const p);
    00133
    00136 XED_DLL_EXPORT xed_uint_t
    00137 xed_decoded_inst_get_nprefixes(xed_decoded_inst_t* p);
    00138
    00140
    00141
    00143
    00144
    00145
    00146 static XED_INLINE const xed_operand_values_t*
    00147 xed_decoded_inst_operands_const(const xed_decoded_inst_t* p) {
    00148     return p;
    00149 }
    00152 static XED_INLINE xed_operand_values_t*
    00153 xed_decoded_inst_operands(xed_decoded_inst_t* p) {
    00154     return p;
    00155 }
    00156
    00159 XED_DLL_EXPORT unsigned int  xed_decoded_inst_operand_length_bits(const xed_decoded_inst_t* p,
    00160                                                                   unsigned int operand_index);
    00161
    00162
    00166 XED_DLL_EXPORT unsigned int  xed_decoded_inst_operand_length(const xed_decoded_inst_t* p,
    00167                                                              unsigned int operand_index);
    00168
    00169
    00172 static XED_INLINE unsigned int  xed_decoded_inst_noperands(const xed_decoded_inst_t* p) {
    00173     unsigned int noperands = xed_inst_noperands(xed_decoded_inst_inst(p));
    00174     return noperands;
    00175 }
    00176
    00177
    00180 XED_DLL_EXPORT unsigned int  xed_decoded_inst_operand_elements(const xed_decoded_inst_t* p,
    00181                                                                unsigned int operand_index);
    00182
    00185 XED_DLL_EXPORT unsigned int  xed_decoded_inst_operand_element_size_bits(const xed_decoded_inst_t* p,
    00186                                                                         unsigned int operand_index);
    00187
    00190 XED_DLL_EXPORT xed_operand_element_type_enum_t  xed_decoded_inst_operand_element_type(const xed_decoded_inst_t* p,
    00191                                                                                       unsigned int operand_index);
    00192
    00193
    00195
    00197
    00198
    00199
    00200 XED_DLL_EXPORT void  xed_decoded_inst_zero_set_mode(xed_decoded_inst_t* p, const xed_state_t* dstate);
    00203 XED_DLL_EXPORT void  xed_decoded_inst_zero_keep_mode(xed_decoded_inst_t* p);
    00206 XED_DLL_EXPORT void  xed_decoded_inst_zero(xed_decoded_inst_t* p);
    00207
    00212 static XED_INLINE void  xed_decoded_inst_set_mode(xed_decoded_inst_t* p,
    00213                                                   xed_machine_mode_enum_t mmode,
    00214                                                   xed_address_width_enum_t stack_addr_width) {
    00215     xed_state_t dstate;
    00216     dstate.mmode = mmode;
    00217     dstate.stack_addr_width = stack_addr_width;
    00218     xed_operand_values_set_mode(p, &dstate);
    00219 }
    00220
    00221
    00222
    00225 XED_DLL_EXPORT void  xed_decoded_inst_zero_keep_mode_from_operands(xed_decoded_inst_t* p,
    00226                                                                    const xed_operand_values_t* operands);
    00227
    00229
    00230
    00231
    00232 static XED_INLINE xed_uint_t
    00233 xed_decoded_inst_get_length(const xed_decoded_inst_t* p) {
    00234     return p->_decoded_length;
    00235 }
    00236
    00237
    00239
    00241
    00242
    00243
    00244 static XED_INLINE xed_uint_t
    00245 xed_decoded_inst_set_length(xed_decoded_inst_t* p, unsigned char length) {
    00246     return p->_decoded_length = length;
    00247 }
    00248
    00249
    00251
    00252
    00254
    00255
    00256
    00257 static XED_INLINE xed_uint_t
    00258 xed_decoded_inst_inc_length(xed_decoded_inst_t* p) {
    00259     return p->_decoded_length++;
    00260 }
    00261
    00262
    00264
    00265
    00266
    00268
    00269
    00270
    00271 static XED_INLINE xed_uint8_t
    00272 xed_decoded_inst_get_byte(const xed_decoded_inst_t* p, xed_uint_t byte_index)
    00273 {
    00275     xed_uint8_t out = p->_byte_array._dec[byte_index];
    00276     return out;
    00277 }
    00278
    00280
    00282
    00283
    00284
    00285
    00286 static XED_INLINE xed_uint_t xed_decoded_inst_get_machine_mode_bits(const xed_decoded_inst_t* p) {
    00287     xed_uint8_t mode = xed3_operand_get_mode(p);
    00288     if (mode == 2) return 64;
    00289     if (mode == 1) return 32;
    00290     return 16;
    00291 }
    00295 static XED_INLINE xed_uint_t xed_decoded_inst_get_stack_address_mode_bits(const xed_decoded_inst_t* p) {
    00296     xed_uint8_t smode = xed3_operand_get_smode(p);
    00297     if (smode == 2) return 64;
    00298     if (smode == 1) return 32;
    00299     return 16;
    00300 }
    00301
    00307 XED_DLL_EXPORT xed_uint32_t xed_decoded_inst_get_operand_width(const xed_decoded_inst_t* p);
    00308
    00311 static XED_INLINE xed_chip_enum_t xed_decoded_inst_get_input_chip(const xed_decoded_inst_t* p) {
    00312     return xed3_operand_get_chip(p);
    00313 }
    00314
    00317 static XED_INLINE void xed_decoded_inst_set_input_chip(xed_decoded_inst_t* p,  xed_chip_enum_t chip) {
    00318     xed3_operand_set_chip(p,chip);
    00319 }
    00320
    00321
    00324 XED_DLL_EXPORT xed_bool_t xed_decoded_inst_valid_for_chip(xed_decoded_inst_t const* const p,
    00325                                                           xed_chip_enum_t chip);
    00326
    00328
    00329
    00330
    00331
    00333
    00334
    00337 static XED_INLINE xed_iform_enum_t xed_decoded_inst_get_iform_enum(const xed_decoded_inst_t* p) {
    00338     xed_assert(p->_inst != 0);
    00339     return xed_inst_iform_enum(p->_inst);
    00340 }
    00341
    00347 static XED_INLINE unsigned int xed_decoded_inst_get_iform_enum_dispatch(const xed_decoded_inst_t* p) {
    00348     xed_assert(p->_inst != 0);
    00349     return xed_inst_iform_enum(p->_inst) - xed_iform_first_per_iclass(xed_inst_iclass(p->_inst));
    00350 }
    00352
    00353
    00354
    00355
    00357
    00358
    00359
    00360 XED_DLL_EXPORT void xed_decoded_inst_dump(const xed_decoded_inst_t* p, char* buf,  int buflen);
    00361
    00362
    00371 XED_DLL_EXPORT xed_bool_t xed_decoded_inst_dump_intel_format(const xed_decoded_inst_t* p,
    00372                                                              char* buf,
    00373                                                              int buflen,
    00374                                                              xed_uint64_t runtime_address);
    00384 XED_DLL_EXPORT xed_bool_t xed_decoded_inst_dump_intel_format_context(const xed_decoded_inst_t* p,
    00385                                                                      char* buf,
    00386                                                                      int buflen,
    00387                                                                      xed_uint64_t runtime_address,
    00388                                                                      void* context);
    00389
    00402 XED_DLL_EXPORT xed_bool_t xed_decoded_inst_dump_att_format(const xed_decoded_inst_t* p,
    00403                                                            char* buf,
    00404                                                            int buflen,
    00405                                                            xed_uint64_t runtime_address);
    00406
    00419 XED_DLL_EXPORT xed_bool_t xed_decoded_inst_dump_att_format_context(const xed_decoded_inst_t* p,
    00420                                                                    char* buf,
    00421                                                                    int buflen,
    00422                                                                    xed_uint64_t runtime_address,
    00423                                                                    void* context);
    00424
    00432 XED_DLL_EXPORT xed_bool_t xed_decoded_inst_dump_xed_format(const xed_decoded_inst_t* p,
    00433                                                            char* buf,
    00434                                                            int buflen,
    00435                                                            xed_uint64_t runtime_address) ;
    00437
    00439
    00440
    00441 XED_DLL_EXPORT xed_reg_enum_t xed_decoded_inst_get_seg_reg(const xed_decoded_inst_t* p, unsigned int mem_idx);
    00443 XED_DLL_EXPORT xed_reg_enum_t xed_decoded_inst_get_base_reg(const xed_decoded_inst_t* p, unsigned int mem_idx);
    00444 XED_DLL_EXPORT xed_reg_enum_t xed_decoded_inst_get_index_reg(const xed_decoded_inst_t* p, unsigned int mem_idx);
    00446 XED_DLL_EXPORT xed_uint_t xed_decoded_inst_get_scale(const xed_decoded_inst_t* p, unsigned int mem_idx);
    00448 XED_DLL_EXPORT xed_int64_t xed_decoded_inst_get_memory_displacement(const xed_decoded_inst_t* p, unsigned int mem_idx);
    00451 XED_DLL_EXPORT xed_uint_t  xed_decoded_inst_get_memory_displacement_width(const xed_decoded_inst_t* p, unsigned int mem_idx);
    00454 XED_DLL_EXPORT xed_uint_t  xed_decoded_inst_get_memory_displacement_width_bits(const xed_decoded_inst_t* p, unsigned int mem_idx);
    00456 XED_DLL_EXPORT xed_int32_t xed_decoded_inst_get_branch_displacement(const xed_decoded_inst_t* p);
    00459 XED_DLL_EXPORT xed_uint_t  xed_decoded_inst_get_branch_displacement_width(const xed_decoded_inst_t* p);
    00462 XED_DLL_EXPORT xed_uint_t  xed_decoded_inst_get_branch_displacement_width_bits(const xed_decoded_inst_t* p);
    00464 XED_DLL_EXPORT xed_uint64_t xed_decoded_inst_get_unsigned_immediate(const xed_decoded_inst_t* p);
    00467 XED_DLL_EXPORT xed_uint_t xed_decoded_inst_get_immediate_is_signed(const xed_decoded_inst_t* p);
    00470 XED_DLL_EXPORT xed_uint_t xed_decoded_inst_get_immediate_width(const xed_decoded_inst_t* p);
    00473 XED_DLL_EXPORT xed_uint_t xed_decoded_inst_get_immediate_width_bits(const xed_decoded_inst_t* p);
    00475 XED_DLL_EXPORT xed_int32_t xed_decoded_inst_get_signed_immediate(const xed_decoded_inst_t* p);
    00478 static XED_INLINE xed_uint8_t xed_decoded_inst_get_second_immediate(const xed_decoded_inst_t* p) {
    00479     return xed3_operand_get_uimm1(p);
    00480 }
    00481
    00484 XED_DLL_EXPORT xed_reg_enum_t xed_decoded_inst_get_reg(const xed_decoded_inst_t* p,
    00485                                                        xed_operand_enum_t reg_operand);
    00486
    00487
    00491 XED_DLL_EXPORT const xed_simple_flag_t* xed_decoded_inst_get_rflags_info( const xed_decoded_inst_t* p );
    00492
    00499 XED_DLL_EXPORT xed_bool_t xed_decoded_inst_uses_rflags(const xed_decoded_inst_t* p);
    00501 XED_DLL_EXPORT xed_uint_t xed_decoded_inst_number_of_memory_operands(const xed_decoded_inst_t* p);
    00503 XED_DLL_EXPORT xed_bool_t xed_decoded_inst_mem_read(const xed_decoded_inst_t* p, unsigned int mem_idx);
    00505 XED_DLL_EXPORT xed_bool_t xed_decoded_inst_mem_written(const xed_decoded_inst_t* p, unsigned int mem_idx);
    00507 XED_DLL_EXPORT xed_bool_t xed_decoded_inst_mem_written_only(const xed_decoded_inst_t* p, unsigned int mem_idx);
    00509 XED_DLL_EXPORT xed_bool_t xed_decoded_inst_conditionally_writes_registers(const xed_decoded_inst_t* p);
    00511 XED_DLL_EXPORT unsigned int  xed_decoded_inst_get_memory_operand_length(const xed_decoded_inst_t* p,
    00512                                                                         unsigned int memop_idx);
    00513
    00517 // 67 prefixes if present.
    00518
    00520 XED_DLL_EXPORT unsigned int
    00521 xed_decoded_inst_get_memop_address_width(const xed_decoded_inst_t* p,
    00522                                          xed_uint_t memop_idx);
    00523
    00524
    00525
    00528 XED_DLL_EXPORT xed_bool_t xed_decoded_inst_is_prefetch(const xed_decoded_inst_t* p);
    00530
    00531
    00533
    00534 // Modifying decoded instructions before re-encoding
    00536 XED_DLL_EXPORT void xed_decoded_inst_set_scale(xed_decoded_inst_t* p, xed_uint_t scale);
    00539 XED_DLL_EXPORT void xed_decoded_inst_set_memory_displacement(xed_decoded_inst_t* p, xed_int64_t disp, xed_uint_t length_bytes);
    00542 XED_DLL_EXPORT void xed_decoded_inst_set_branch_displacement(xed_decoded_inst_t* p, xed_int32_t disp, xed_uint_t length_bytes);
    00545 XED_DLL_EXPORT void xed_decoded_inst_set_immediate_signed(xed_decoded_inst_t* p, xed_int32_t x, xed_uint_t length_bytes);
    00548 XED_DLL_EXPORT void xed_decoded_inst_set_immediate_unsigned(xed_decoded_inst_t* p, xed_uint64_t x, xed_uint_t length_bytes);
    00549
    00550
    00553 XED_DLL_EXPORT void xed_decoded_inst_set_memory_displacement_bits(xed_decoded_inst_t* p, xed_int64_t disp, xed_uint_t length_bits);
    00556 XED_DLL_EXPORT void xed_decoded_inst_set_branch_displacement_bits(xed_decoded_inst_t* p, xed_int32_t disp, xed_uint_t length_bits);
    00559 XED_DLL_EXPORT void xed_decoded_inst_set_immediate_signed_bits(xed_decoded_inst_t* p, xed_int32_t x, xed_uint_t length_bits);
    00562 XED_DLL_EXPORT void xed_decoded_inst_set_immediate_unsigned_bits(xed_decoded_inst_t* p, xed_uint64_t x, xed_uint_t length_bits);
    00563
    00565
    00567
    00568
    00569
    00570 static XED_INLINE  xed_uint64_t xed_decoded_inst_get_user_data(xed_decoded_inst_t* p) {
    00571     return p->u.user_data;
    00572 }
    00575 static XED_INLINE  void xed_decoded_inst_set_user_data(xed_decoded_inst_t* p, xed_uint64_t new_value) {
    00576     p->u.user_data = new_value;
    00577 }
    00578
    00579
    00580
    00581
    00583 #endif
    00584