2 Intel Open Source License
4 Copyright (c) 2002-2007 Intel Corporation
6 Redistribution and use in source and binary forms, with or without
7 modification, are permitted provided that the following conditions are
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.
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.
32 /// @author Mark Charney <mark.charney@intel.com>
35 # define _XED_FLAGS_H_
37 #include <xed/xed-types.h>
38 #include <xed/xed-flag-enum.h>
39 #include <xed/xed-flag-action-enum.h>
42 ////////////////////////////////////////////////////////////////////////////
44 /// a union of flags bits
45 union XED_DLL_EXPORT xed_flag_set_s {
56 xed_uint32_t _if:1; ///< underscore to avoid token clash
64 xed_uint32_t fc0:1; ///< x87 flag FC0
65 xed_uint32_t fc1:1; ///< x87 flag FC1
66 xed_uint32_t fc2:1; ///< x87 flag FC2
67 xed_uint32_t fc3:1; ///< x87 flag FC3
72 typedef union xed_flag_set_s xed_flag_set_t;
74 /// @name Flag-set accessors
77 /// print the flag set in the supplied buffer
78 XED_DLL_EXPORT int xed_flag_set_print(const xed_flag_set_t* p, char* buf, int buflen);
80 /// returns true if this object has a subset of the flags of the
82 XED_DLL_EXPORT xed_bool_t xed_flag_set_is_subset_of(const xed_flag_set_t* p,
83 const xed_flag_set_t* other);
87 ////////////////////////////////////////////////////////////////////////////
90 /// Associated with each flag field there can be one action.
91 typedef struct XED_DLL_EXPORT xed_flag_enum_s {
93 // there are at most two actions per flag. The 2nd may be invalid.
94 xed_flag_action_enum_t action;
101 /// @name Lowest-level flag-action accessors
104 /// get the name of the flag
105 XED_DLL_EXPORT xed_flag_enum_t
106 xed_flag_action_get_flag_name(const xed_flag_action_t* p);
108 /// return the action
109 XED_DLL_EXPORT xed_flag_action_enum_t
110 xed_flag_action_get_action(const xed_flag_action_t* p, unsigned int i);
112 /// returns true if the specified action is invalid. Only the 2nd flag might be invalid.
113 XED_DLL_EXPORT xed_bool_t
114 xed_flag_action_action_invalid(const xed_flag_action_enum_t a);
116 /// print the flag & actions
117 XED_DLL_EXPORT int xed_flag_action_print(const xed_flag_action_t* p, char* buf, int buflen);
119 /// returns true if either action is a read
120 XED_DLL_EXPORT xed_bool_t
121 xed_flag_action_read_flag(const xed_flag_action_t* p );
123 /// returns true if either action is a write
124 XED_DLL_EXPORT xed_bool_t
125 xed_flag_action_writes_flag(const xed_flag_action_t* p);
128 /// test to see if the specific action is a read
129 XED_DLL_EXPORT xed_bool_t
130 xed_flag_action_read_action( xed_flag_action_enum_t a);
132 /// test to see if a specific action is a write
133 XED_DLL_EXPORT xed_bool_t
134 xed_flag_action_write_action( xed_flag_action_enum_t a);
137 ////////////////////////////////////////////////////////////////////////////
139 #define XED_MAX_FLAG_ACTIONS (XED_FLAG_LAST + 3)
141 /// A collection of #xed_flag_action_t's and unions of read and written flags
142 typedef struct XED_DLL_EXPORT xed_simple_flag_s
146 xed_bool_t may_write :1;
147 xed_bool_t must_write :1;
149 /// indexed from 0, not by position in archtectural flags array.
150 xed_flag_action_t fa[XED_MAX_FLAG_ACTIONS];
152 ///union of read flags
155 /// union of written flags;
156 xed_flag_set_t written;
160 /// @name Accessing the simple flags (Mid-level access)
163 /// returns the number of flag-actions
164 XED_DLL_EXPORT unsigned int
165 xed_simple_flag_get_nflags(const xed_simple_flag_t* p);
168 /// return union of bits for read flags
169 XED_DLL_EXPORT const xed_flag_set_t*
170 xed_simple_flag_get_read_flag_set(const xed_simple_flag_t* p);
173 /// return union of bits for written flags
174 XED_DLL_EXPORT const xed_flag_set_t*
175 xed_simple_flag_get_written_flag_set(const xed_simple_flag_t* p);
178 /// Indicates the flags are only conditionally written. Usally MAY-writes
179 /// of the flags instructions that are dependent on a REP count.
180 XED_DLL_EXPORT xed_bool_t xed_simple_flag_get_may_write(const xed_simple_flag_t* p);
183 /// the flags always written
184 XED_DLL_EXPORT xed_bool_t xed_simple_flag_get_must_write(const xed_simple_flag_t* p);
187 /// return the specific flag-action. Very detailed low level information
188 XED_DLL_EXPORT const xed_flag_action_t*
189 xed_simple_flag_get_flag_action(const xed_simple_flag_t* p, unsigned int i);
192 /// boolean test to see if flags are read, scans the flags
193 XED_DLL_EXPORT xed_bool_t
194 xed_simple_flag_reads_flags(const xed_simple_flag_t* p);
197 /// boolean test to see if flags are written, scans the flags
198 XED_DLL_EXPORT xed_bool_t xed_simple_flag_writes_flags(const xed_simple_flag_t* p);
202 XED_DLL_EXPORT int xed_simple_flag_print(const xed_simple_flag_t* p, char* buf, int buflen);
205 ////////////////////////////////////////////////////////////////////////////
208 ////////////////////////////////////////////////////////////////////////////