- Main Page
- Modules
- Data Structures
- Files

- Search for |

- File List
- Globals

# xed-flags.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 #ifndef _XED_FLAGS_H_
    00035 # define  _XED_FLAGS_H_
    00036
    00037 #include "xed-types.h"
    00038 #include "xed-portability.h"
    00039 #include "xed-flag-enum.h"
    00040 #include "xed-flag-action-enum.h"
    00041 #include "xed-gen-table-defs.h"
    00042
    00043
    00047 union  xed_flag_set_s {
    00048     struct {
    00049         xed_uint32_t cf:1;
    00050         xed_uint32_t must_be_1:1;
    00051         xed_uint32_t pf:1;
    00052         xed_uint32_t must_be_0a:1;
    00053
    00054         xed_uint32_t af:1;
    00055         xed_uint32_t must_be_0b:1;
    00056         xed_uint32_t zf:1;
    00057         xed_uint32_t sf:1;
    00058
    00059         xed_uint32_t tf:1;
    00060         xed_uint32_t _if:1;
    00061         xed_uint32_t df:1;
    00062         xed_uint32_t of:1;
    00063
    00064         xed_uint32_t iopl:2;
    00065         xed_uint32_t nt:1;
    00066         xed_uint32_t must_be_0c:1;
    00067
    00068         xed_uint32_t rf:1;
    00069         xed_uint32_t vm:1;
    00070         xed_uint32_t ac:1;
    00071         xed_uint32_t vif:1;
    00072
    00073         xed_uint32_t vip:1;
    00074         xed_uint32_t id:1;
    00075         xed_uint32_t must_be_0d:2;
    00076
    00077         xed_uint32_t must_be_0e:4;
    00078
    00079         // fc0,fc1,fc2,fc3 are not really part of rflags but I put them
    00080         // here to save space. These bits are only used for x87
    00081         // instructions.
    00082         xed_uint32_t fc0:1;
    00083         xed_uint32_t fc1:1;
    00084         xed_uint32_t fc2:1;
    00085         xed_uint32_t fc3:1;
    00086     } s;
    00087     xed_uint32_t flat;
    00088 };
    00089
    00090 typedef union xed_flag_set_s xed_flag_set_t;
    00093
    00094
    00095
    00096 XED_DLL_EXPORT int  xed_flag_set_print(const xed_flag_set_t* p, char* buf, int buflen);
    00100 XED_DLL_EXPORT xed_bool_t xed_flag_set_is_subset_of(const xed_flag_set_t* p,
    00101                                const xed_flag_set_t* other);
    00103
    00104
    00106
    00109 typedef struct xed_flag_enum_s {
    00110     xed_flag_enum_t flag;
    00111     // there are at most two actions per flag. The 2nd may be invalid.
    00112     xed_flag_action_enum_t action;
    00113 }  xed_flag_action_t;
    00114
    00115
    00116
    00117
    00120
    00121
    00122
    00123 XED_DLL_EXPORT xed_flag_enum_t
    00124 xed_flag_action_get_flag_name(const xed_flag_action_t* p);
    00127 XED_DLL_EXPORT xed_flag_action_enum_t
    00128 xed_flag_action_get_action(const xed_flag_action_t* p, unsigned int i);
    00131 XED_DLL_EXPORT xed_bool_t
    00132 xed_flag_action_action_invalid(const xed_flag_action_enum_t a);
    00135 XED_DLL_EXPORT int xed_flag_action_print(const xed_flag_action_t* p, char* buf, int buflen);
    00138 XED_DLL_EXPORT xed_bool_t
    00139 xed_flag_action_read_flag(const xed_flag_action_t* p );
    00142 XED_DLL_EXPORT xed_bool_t
    00143 xed_flag_action_writes_flag(const xed_flag_action_t* p);
    00144
    00147 XED_DLL_EXPORT xed_bool_t
    00148 xed_flag_action_read_action( xed_flag_action_enum_t a);
    00151 XED_DLL_EXPORT xed_bool_t
    00152 xed_flag_action_write_action( xed_flag_action_enum_t a);
    00154
    00156
    00157 #define XED_MAX_FLAG_ACTIONS (XED_MAX_ACTIONS_PER_SIMPLE_FLAG)
    00160 typedef struct  xed_simple_flag_s
    00161 {
    00162     xed_uint8_t nflags;
    00163
    00164     xed_uint8_t may_write; /* 1/0,  only using one bit */
    00165     xed_uint8_t must_write;  /* 1/0,  only using one bit */
    00166
    00168     xed_flag_set_t read;
    00169
    00171     xed_flag_set_t written;
    00172
    00174     xed_flag_set_t undefined;
    00175
    00176     // index in to the xed_flag_action_table. nflags limits the # of entries.
    00177     xed_uint16_t fa_index;
    00178
    00179 } xed_simple_flag_t;
    00180
    00183
    00184
    00185
    00186 XED_DLL_EXPORT unsigned int
    00187 xed_simple_flag_get_nflags(const xed_simple_flag_t* p);
    00188
    00191 XED_DLL_EXPORT const xed_flag_set_t*
    00192 xed_simple_flag_get_read_flag_set(const xed_simple_flag_t* p);
    00193
    00196 XED_DLL_EXPORT const xed_flag_set_t*
    00197 xed_simple_flag_get_written_flag_set(const xed_simple_flag_t* p);
    00198
    00199
    00202 XED_DLL_EXPORT const xed_flag_set_t*
    00203 xed_simple_flag_get_undefined_flag_set(const xed_simple_flag_t* p);
    00204
    00208 XED_DLL_EXPORT xed_bool_t xed_simple_flag_get_may_write(const xed_simple_flag_t* p);
    00209
    00212 XED_DLL_EXPORT xed_bool_t xed_simple_flag_get_must_write(const xed_simple_flag_t* p);
    00213
    00216 XED_DLL_EXPORT const xed_flag_action_t*
    00217 xed_simple_flag_get_flag_action(const xed_simple_flag_t* p, unsigned int i);
    00218
    00221 XED_DLL_EXPORT xed_bool_t
    00222 xed_simple_flag_reads_flags(const xed_simple_flag_t* p);
    00223
    00226 XED_DLL_EXPORT xed_bool_t xed_simple_flag_writes_flags(const xed_simple_flag_t* p);
    00227
    00230 XED_DLL_EXPORT int xed_simple_flag_print(const xed_simple_flag_t* p, char* buf, int buflen);
    00231
    00234 static XED_INLINE int xed_flag_set_mask(const xed_flag_set_t* p) {
    00235     return p->flat; // FIXME: could mask out the X87 flags
    00236 }
    00237
    00239
    00241
    00242
    00244
    00245 #endif