Palacios Public Git Repository

To checkout Palacios execute

  git clone http://v3vee.org/palacios/palacios.web/palacios.git
This will give you the master branch. You probably want the devel branch or one of the release branches. To switch to the devel branch, simply execute
  cd palacios
  git checkout --track -b devel origin/devel
The other branches are similar.


Release 1.0
[palacios.git] / misc / decoder_test / XED2 / include / xed-flags.h
1 /*BEGIN_LEGAL 
2 Intel Open Source License 
3
4 Copyright (c) 2002-2007 Intel Corporation 
5 All rights reserved. 
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 */
31 /// @file xed-flags.h
32 /// @author Mark Charney <mark.charney@intel.com>
33
34 #ifndef _XED_FLAGS_H_
35 # define  _XED_FLAGS_H_
36
37 #include "xed-types.h"
38 #include "xed-flag-enum.h"
39 #include "xed-flag-action-enum.h"
40
41
42 ////////////////////////////////////////////////////////////////////////////
43 /// @ingroup FLAGS
44 /// a union of flags bits
45 union  XED_DLL_EXPORT xed_flag_set_s {
46     struct {
47         xed_uint32_t of:1;
48         xed_uint32_t sf:1;
49         xed_uint32_t zf:1;
50         xed_uint32_t af:1;
51         xed_uint32_t pf:1;
52         xed_uint32_t cf:1;
53         xed_uint32_t df:1;
54         xed_uint32_t vif:1;
55         xed_uint32_t iopl:1;
56         xed_uint32_t _if:1;  ///< underscore to avoid token clash
57         xed_uint32_t ac:1;
58         xed_uint32_t vm:1;
59         xed_uint32_t rf:1;
60         xed_uint32_t nt:1;
61         xed_uint32_t tf:1;
62         xed_uint32_t id:1;
63         xed_uint32_t vip:1; 
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
68     } s;
69     xed_uint32_t flat;
70 };
71
72 typedef union xed_flag_set_s xed_flag_set_t;
73 /// @ingroup FLAGS
74 /// @name Flag-set accessors
75 //@{
76 /// @ingroup FLAGS
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);
79 /// @ingroup FLAGS
80 /// returns true if this object has a subset of the flags of the
81 /// "other" object.
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);
84 //@}
85
86
87 ////////////////////////////////////////////////////////////////////////////
88
89 /// @ingroup FLAGS
90 /// Associated with each flag field there can be one action.
91 typedef struct XED_DLL_EXPORT xed_flag_enum_s {
92     xed_flag_enum_t flag;
93     // there are at most two actions per flag. The 2nd may be invalid.
94     xed_flag_action_enum_t action;
95 }  xed_flag_action_t;
96
97
98
99
100 /// @ingroup FLAGS
101 /// @name Lowest-level flag-action accessors
102 //@{
103 /// @ingroup FLAGS    
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);
107 /// @ingroup FLAGS        
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);
111 /// @ingroup FLAGS    
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);
115 /// @ingroup FLAGS    
116 /// print the flag & actions
117 XED_DLL_EXPORT int xed_flag_action_print(const xed_flag_action_t* p, char* buf, int buflen);
118 /// @ingroup FLAGS    
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 );
122 /// @ingroup FLAGS    
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);
126   
127 /// @ingroup FLAGS    
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);
131 /// @ingroup FLAGS    
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);
135 //@}
136
137 ////////////////////////////////////////////////////////////////////////////
138
139 #define XED_MAX_FLAG_ACTIONS (XED_FLAG_LAST + 3)
140 /// @ingroup FLAGS
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 
143 {
144     xed_uint8_t nflags;
145
146     xed_bool_t may_write :1;
147     xed_bool_t must_write :1;
148
149     /// indexed from 0, not by position in archtectural flags array.
150     xed_flag_action_t fa[XED_MAX_FLAG_ACTIONS];
151
152     ///union of read flags
153     xed_flag_set_t read;
154
155     /// union of written flags;
156     xed_flag_set_t written;
157 } xed_simple_flag_t;
158
159 /// @ingroup FLAGS
160 /// @name Accessing the simple flags (Mid-level access)
161 //@{
162 /// @ingroup FLAGS
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);
166
167 /// @ingroup FLAGS
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);
171
172 /// @ingroup FLAGS  
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);
176
177 /// @ingroup FLAGS
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);
181
182 /// @ingroup FLAGS
183 /// the flags always written
184 XED_DLL_EXPORT xed_bool_t xed_simple_flag_get_must_write(const xed_simple_flag_t* p);
185
186 /// @ingroup FLAGS
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);
190
191 /// @ingroup FLAGS    
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);
195
196 /// @ingroup FLAGS    
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);
199
200 /// @ingroup FLAGS    
201 /// print the flags
202 XED_DLL_EXPORT int xed_simple_flag_print(const xed_simple_flag_t* p, char* buf, int buflen);
203 //@}
204
205 ////////////////////////////////////////////////////////////////////////////
206
207
208 ////////////////////////////////////////////////////////////////////////////
209
210 #endif