XED
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
xed-flags.h
Go to the documentation of this file.
1 /*BEGIN_LEGAL
2 Intel Open Source License
3 
4 Copyright (c) 2002-2014 Intel Corporation. All rights reserved.
5 
6 Redistribution and use in source and binary forms, with or without
7 modification, are permitted provided that the following conditions are
8 met:
9 
10 Redistributions of source code must retain the above copyright notice,
11 this list of conditions and the following disclaimer. Redistributions
12 in binary form must reproduce the above copyright notice, this list of
13 conditions and the following disclaimer in the documentation and/or
14 other materials provided with the distribution. Neither the name of
15 the Intel Corporation nor the names of its contributors may be used to
16 endorse or promote products derived from this software without
17 specific prior written permission.
18 
19 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE INTEL OR
23 ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25 LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 END_LEGAL */
33 
34 #ifndef _XED_FLAGS_H_
35 # define _XED_FLAGS_H_
36 
37 #include "xed-types.h"
38 #include "xed-portability.h"
39 #include "xed-flag-enum.h"
40 #include "xed-flag-action-enum.h"
41 #include "xed-gen-table-defs.h"
42 
43 
48  struct {
49  xed_uint32_t cf:1;
50  xed_uint32_t must_be_1:1;
51  xed_uint32_t pf:1;
52  xed_uint32_t must_be_0a:1;
53 
54  xed_uint32_t af:1;
55  xed_uint32_t must_be_0b:1;
56  xed_uint32_t zf:1;
57  xed_uint32_t sf:1;
58 
59  xed_uint32_t tf:1;
60  xed_uint32_t _if:1;
61  xed_uint32_t df:1;
62  xed_uint32_t of:1;
63 
64  xed_uint32_t iopl:2;
65  xed_uint32_t nt:1;
66  xed_uint32_t must_be_0c:1;
67 
68  xed_uint32_t rf:1;
69  xed_uint32_t vm:1;
70  xed_uint32_t ac:1;
71  xed_uint32_t vif:1;
72 
73  xed_uint32_t vip:1;
74  xed_uint32_t id:1;
75  xed_uint32_t must_be_0d:2;
76 
77  xed_uint32_t must_be_0e:4;
78 
79  // fc0,fc1,fc2,fc3 are not really part of rflags but I put them
80  // here to save space. These bits are only used for x87
81  // instructions.
82  xed_uint32_t fc0:1;
83  xed_uint32_t fc1:1;
84  xed_uint32_t fc2:1;
85  xed_uint32_t fc3:1;
86  } s;
87  xed_uint32_t flat;
88 };
89 
93 
94 XED_DLL_EXPORT int xed_flag_set_print(const xed_flag_set_t* p, char* buf, int buflen);
101  const xed_flag_set_t* other);
103 
104 
106 
109 typedef struct xed_flag_enum_s {
111  // there are at most two actions per flag. The 2nd may be invalid.
114 
115 
116 
117 
120 
128 xed_flag_action_get_action(const xed_flag_action_t* p, unsigned int i);
135 XED_DLL_EXPORT int xed_flag_action_print(const xed_flag_action_t* p, char* buf, int buflen);
144 
154 
156 
157 #define XED_MAX_FLAG_ACTIONS (XED_MAX_ACTIONS_PER_SIMPLE_FLAG)
158 typedef struct xed_simple_flag_s
161 {
162  xed_uint8_t nflags;
163 
164  xed_uint8_t may_write; /* 1/0, only using one bit */
165  xed_uint8_t must_write; /* 1/0, only using one bit */
166 
169 
172 
175 
176  // index in to the xed_flag_action_table. nflags limits the # of entries.
177  xed_uint16_t fa_index;
178 
180 
183 
184 XED_DLL_EXPORT unsigned int
188 
193 
198 
199 
204 
209 
213 
217 xed_simple_flag_get_flag_action(const xed_simple_flag_t* p, unsigned int i);
218 
223 
227 
230 XED_DLL_EXPORT int xed_simple_flag_print(const xed_simple_flag_t* p, char* buf, int buflen);
231 
235  return p->flat; // FIXME: could mask out the X87 flags
236 }
237 
239 
241 
242 
244 
245 #endif
xed_uint32_t df
Definition: xed-flags.h:61
xed_uint32_t iopl
A 2-bit field, bits 12-13.
Definition: xed-flags.h:64
xed_uint32_t fc2
x87 flag FC2 (not really part of rflags)
Definition: xed-flags.h:84
xed_flag_enum_t flag
Definition: xed-flags.h:110
xed_uint32_t must_be_0a
Definition: xed-flags.h:52
XED_DLL_EXPORT xed_bool_t xed_flag_action_write_action(xed_flag_action_enum_t a)
test to see if a specific action is a write
xed_uint32_t af
bit 4
Definition: xed-flags.h:54
xed_uint32_t must_be_0c
Definition: xed-flags.h:66
xed_uint32_t must_be_0d
bits 22-23
Definition: xed-flags.h:75
A collection of xed_flag_action_t's and unions of read and written flags.
Definition: xed-flags.h:160
XED_DLL_EXPORT xed_flag_action_enum_t xed_flag_action_get_action(const xed_flag_action_t *p, unsigned int i)
return the action
XED_DLL_EXPORT int xed_flag_set_print(const xed_flag_set_t *p, char *buf, int buflen)
print the flag set in the supplied buffer
xed_uint32_t fc1
x87 flag FC1 (not really part of rflags)
Definition: xed-flags.h:83
XED_DLL_EXPORT xed_bool_t xed_flag_action_writes_flag(const xed_flag_action_t *p)
returns true if either action is a write
XED_DLL_EXPORT xed_bool_t xed_simple_flag_get_may_write(const xed_simple_flag_t *p)
Indicates the flags are only conditionally written.
xed_flag_set_t undefined
union of undefined flags;
Definition: xed-flags.h:174
XED_DLL_EXPORT xed_bool_t xed_simple_flag_reads_flags(const xed_simple_flag_t *p)
boolean test to see if flags are read, scans the flags
XED_DLL_EXPORT int xed_simple_flag_print(const xed_simple_flag_t *p, char *buf, int buflen)
print the flags
XED_DLL_EXPORT const xed_flag_set_t * xed_simple_flag_get_written_flag_set(const xed_simple_flag_t *p)
return union of bits for written flags
xed_uint32_t vip
bit 20
Definition: xed-flags.h:73
xed_uint8_t must_write
Definition: xed-flags.h:165
xed_uint32_t rf
bit 16
Definition: xed-flags.h:68
unsigned int xed_bool_t
Definition: xed-types.h:68
xed_uint32_t must_be_1
Definition: xed-flags.h:50
XED_DLL_EXPORT xed_bool_t xed_simple_flag_get_must_write(const xed_simple_flag_t *p)
the flags always written
xed_uint32_t vif
Definition: xed-flags.h:71
XED_DLL_EXPORT xed_bool_t xed_flag_set_is_subset_of(const xed_flag_set_t *p, const xed_flag_set_t *other)
returns true if this object has a subset of the flags of the "other" object.
xed_uint32_t must_be_0e
bits 24-27
Definition: xed-flags.h:77
xed_flag_action_enum_t action
Definition: xed-flags.h:112
xed_flag_action_enum_t
XED_DLL_EXPORT int xed_flag_action_print(const xed_flag_action_t *p, char *buf, int buflen)
print the flag & actions
xed_flag_set_t written
union of written flags (includes undefined flags);
Definition: xed-flags.h:171
#define XED_INLINE
xed_uint16_t fa_index
Definition: xed-flags.h:177
xed_uint32_t flat
Definition: xed-flags.h:87
xed_uint32_t of
Definition: xed-flags.h:62
struct xed_flag_set_s::@5 s
xed_uint32_t cf
bit 0
Definition: xed-flags.h:49
xed_uint32_t zf
Definition: xed-flags.h:56
XED_DLL_EXPORT const xed_flag_action_t * xed_simple_flag_get_flag_action(const xed_simple_flag_t *p, unsigned int i)
return the specific flag-action.
xed_uint32_t nt
Definition: xed-flags.h:65
xed_uint32_t _if
underscore to avoid token clash
Definition: xed-flags.h:60
xed_uint32_t vm
Definition: xed-flags.h:69
xed_uint32_t fc0
x87 flag FC0 (not really part of rflags)
Definition: xed-flags.h:82
struct xed_flag_enum_s xed_flag_action_t
Associated with each flag field there can be one action.
xed_flag_enum_t
Definition: xed-flag-enum.h:39
xed_uint8_t nflags
Definition: xed-flags.h:162
XED_DLL_EXPORT xed_bool_t xed_flag_action_read_action(xed_flag_action_enum_t a)
test to see if the specific action is a read
XED_DLL_EXPORT const xed_flag_set_t * xed_simple_flag_get_read_flag_set(const xed_simple_flag_t *p)
return union of bits for read flags
xed_uint32_t fc3
x87 flag FC3 (not really part of rflags)
Definition: xed-flags.h:85
xed_uint32_t must_be_0b
Definition: xed-flags.h:55
XED_DLL_EXPORT unsigned int xed_simple_flag_get_nflags(const xed_simple_flag_t *p)
returns the number of flag-actions
a union of flags bits
Definition: xed-flags.h:47
XED_DLL_EXPORT xed_flag_enum_t xed_flag_action_get_flag_name(const xed_flag_action_t *p)
get the name of the flag
xed_uint8_t may_write
Definition: xed-flags.h:164
XED_DLL_EXPORT xed_bool_t xed_flag_action_action_invalid(const xed_flag_action_enum_t a)
returns true if the specified action is invalid.
xed_uint32_t pf
Definition: xed-flags.h:51
struct xed_simple_flag_s xed_simple_flag_t
A collection of xed_flag_action_t's and unions of read and written flags.
XED_DLL_EXPORT const xed_flag_set_t * xed_simple_flag_get_undefined_flag_set(const xed_simple_flag_t *p)
return union of bits for undefined flags
static XED_INLINE int xed_flag_set_mask(const xed_flag_set_t *p)
Return the flags as a mask.
Definition: xed-flags.h:234
xed_flag_set_t read
union of read flags
Definition: xed-flags.h:168
XED_DLL_EXPORT xed_bool_t xed_flag_action_read_flag(const xed_flag_action_t *p)
returns true if either action is a read
Associated with each flag field there can be one action.
Definition: xed-flags.h:109
xed_uint32_t sf
Definition: xed-flags.h:57
#define XED_DLL_EXPORT
XED_DLL_EXPORT xed_bool_t xed_simple_flag_writes_flags(const xed_simple_flag_t *p)
boolean test to see if flags are written, scans the flags
xed_uint32_t ac
Definition: xed-flags.h:70
xed_uint32_t tf
bit 8
Definition: xed-flags.h:59