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] / palacios / include / xed / xed-operand-values-interface.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-operand-values-interface.h
32 /// @author Mark Charney <mark.charney@intel.com>
33
34 #if !defined(_XED_OPERAND_VALUES_INTERFACE_H_)
35 # define _XED_OPERAND_VALUES_INTERFACE_H_
36
37 #include <xed/xed-common-hdrs.h>
38 #include <xed/xed-common-defs.h>
39 #include <xed/xed-portability.h>
40 #include <xed/xed-util.h>
41 #include <xed/xed-types.h>
42 #include <xed/xed-state.h> // a generated file
43 #include <xed/xed-operand-enum.h> // a generated file
44 #include <xed/xed-operand-storage.h> 
45 #include <xed/xed-reg-enum.h>  // generated
46 #include <xed/xed-iclass-enum.h>  // generated
47 /// @name Initialization
48 //@{
49 /// @ingroup OPERANDS
50 /// Initializes operand structure
51 XED_DLL_EXPORT void xed_operand_values_init(xed_operand_values_t* p);
52
53 /// @ingroup OPERANDS
54 /// Initializes operand structure and sets state values
55 XED_DLL_EXPORT void xed_operand_values_init_set_mode(xed_operand_values_t* p,
56                                                      const xed_state_t* dstate);
57 /// @ingroup OPERANDS
58 /// Initializes dst operand structure but preserves the existing
59 /// MODE/SMODE/AMODE values from the src operand structure.
60 XED_DLL_EXPORT void xed_operand_values_init_keep_mode( xed_operand_values_t* dst,
61                                                        const xed_operand_values_t* src );
62 //@}
63
64 // Returns the raw operand fields. Do not use this. 
65 XED_DLL_EXPORT xed_uint32_t 
66 xed_operand_values_get_operand_decider(const xed_operand_values_t* p,
67                                        xed_operand_enum_t operand_decider_index) ;
68
69     
70 ///////////////////////////////////////////////////////////
71 /// @name String output
72 //@{
73 /// @ingroup OPERANDS
74 /// Dump all the information about the operands to buf.
75 XED_DLL_EXPORT void xed_operand_values_dump(const xed_operand_values_t* ov, char* buf,  int buflen);
76 /// @ingroup OPERANDS
77 /// More tersely dump all the information about the operands to buf.
78 XED_DLL_EXPORT void xed_operand_values_print_short(const xed_operand_values_t* ov, char* buf,  int buflen);
79 //@}
80     
81 /// @name REP/REPNE Prefixes
82 //@{     
83 /// @ingroup OPERANDS    
84 /// True if the instruction has a real REP prefix. This returns false if
85 /// there is no F2/F3 prefix or the F2/F3 prefix is used to refine the
86 /// opcode as in some SSE operations.
87 XED_DLL_EXPORT xed_bool_t
88 xed_operand_values_has_real_rep(const xed_operand_values_t* p);
89 /// @ingroup OPERANDS    
90 /// True if the instruction as a real F3 REP prefix.
91 XED_DLL_EXPORT xed_bool_t
92 xed_operand_values_has_rep_prefix(const xed_operand_values_t* p);
93 /// @ingroup OPERANDS    
94 /// True if the instruction as a real F2 REP prefix.
95 XED_DLL_EXPORT xed_bool_t
96 xed_operand_values_has_repne_prefix(const xed_operand_values_t* p);
97 //@}
98
99 /// @ingroup OPERANDS    
100 /// Returns true if the memory operation has atomic read-modify-write
101 /// semantics. An XCHG accessing memory is atomic with or without a
102 /// LOCK prefix.
103 XED_DLL_EXPORT xed_bool_t
104 xed_operand_values_get_atomic(const xed_operand_values_t* p);
105
106 /// @ingroup OPERANDS    
107 /// Returns true if the memory operatoin has a valid lock prefix.
108 XED_DLL_EXPORT xed_bool_t
109 xed_operand_values_has_lock_prefix(const xed_operand_values_t* p);
110
111 /// @ingroup OPERANDS    
112 /// Indicates if the default segment is being used.
113 /// @param[in] p   the pointer to the #xed_operand_values_t structure.
114 /// @param[in] i   0 or 1, indicating which memory operation.
115 /// @return true if the memory operation is using the default segment for the associated addressing mode base register.
116 XED_DLL_EXPORT xed_bool_t
117 xed_operand_values_using_default_segment(const xed_operand_values_t* p, unsigned int i);
118
119
120
121 /// @ingroup OPERANDS    
122 /// Returns The effective operand width in bits: 16/32/64. Note this is not
123 /// the same as the width of the operand! For 8 bit operations, the
124 /// effective operand width is the machine mode's default width.
125 XED_DLL_EXPORT xed_uint32_t xed_operand_values_get_effective_operand_width(const xed_operand_values_t* p);
126 /// @ingroup OPERANDS    
127 /// Returns The effective address width in bits: 16/32/64. 
128 XED_DLL_EXPORT xed_uint32_t xed_operand_values_get_effective_address_width(const xed_operand_values_t* p);
129
130
131 /// @ingroup OPERANDS    
132 /// True if there is a memory displacement
133 XED_DLL_EXPORT xed_bool_t
134 xed_operand_values_has_memory_displacement(const xed_operand_values_t* p);
135 /// @ingroup OPERANDS    
136 /// True if there is a branch displacement
137 XED_DLL_EXPORT xed_bool_t
138 xed_operand_values_has_branch_displacement(const xed_operand_values_t* p);
139 /// @ingroup OPERANDS    
140 /// True if there is a memory or branch displacement
141 XED_DLL_EXPORT xed_bool_t
142 xed_operand_values_has_displacement(const xed_operand_values_t* p);
143
144
145 /// @ingroup OPERANDS    
146 /// Deprecated. Compatibility function for XED0. See has_memory_displacement().
147 XED_DLL_EXPORT xed_bool_t
148 xed_operand_values_get_displacement_for_memop(const xed_operand_values_t* p);
149
150 /// @ingroup OPERANDS    
151 /// Return true if there is an immediate operand
152 XED_DLL_EXPORT xed_bool_t
153 xed_operand_values_has_immediate(const xed_operand_values_t* p);  
154
155
156 /// @ingroup OPERANDS    
157 /// ALIAS for has_displacement().
158 /// Deprecated. See has_memory_displacement() and
159 /// has_branch_displacement().
160 XED_DLL_EXPORT xed_bool_t
161 xed_operand_values_has_disp(const xed_operand_values_t* p);  
162
163 /// @ingroup OPERANDS    
164 XED_DLL_EXPORT xed_bool_t 
165 xed_operand_values_has_address_size_prefix(const xed_operand_values_t* p);
166 /// @ingroup OPERANDS    
167 XED_DLL_EXPORT xed_bool_t 
168 xed_operand_values_has_operand_size_prefix(const xed_operand_values_t* p);
169
170 #if 0
171 XED_DLL_EXPORT xed_bool_t 
172 xed_operand_values_has_refining_66_prefix(const xed_operand_values_t* p);
173 XED_DLL_EXPORT xed_bool_t 
174 xed_operand_values_has_refining_f2_prefix(const xed_operand_values_t* p);
175 XED_DLL_EXPORT xed_bool_t 
176 xed_operand_values_has_refining_f3_prefix(const xed_operand_values_t* p);
177 #endif
178
179 /// @ingroup OPERANDS    
180 XED_DLL_EXPORT xed_bool_t 
181 xed_operand_values_has_segment_prefix(const xed_operand_values_t* p);
182
183 /// @ingroup OPERANDS    
184 /// Return the segment prefix, if any, as a #xed_reg_enum_t value.
185 XED_DLL_EXPORT xed_reg_enum_t
186 xed_operand_values_segment_prefix(const xed_operand_values_t* p);
187
188 /// @ingroup OPERANDS    
189 XED_DLL_EXPORT xed_bool_t
190 xed_operand_values_is_prefetch(const xed_operand_values_t* p);
191
192 /// @ingroup OPERANDS    
193 XED_DLL_EXPORT xed_bool_t xed_operand_values_get_long_mode(const xed_operand_values_t* p);
194
195 /// @name Memory Addressing
196 //@{
197 /// @ingroup OPERANDS    
198 XED_DLL_EXPORT xed_bool_t
199 xed_operand_values_accesses_memory(const xed_operand_values_t* p);
200
201 /// @ingroup OPERANDS    
202 XED_DLL_EXPORT unsigned int 
203 xed_operand_values_number_of_memory_operands(const xed_operand_values_t* p);
204
205 /// @ingroup OPERANDS    
206 XED_DLL_EXPORT unsigned int
207 xed_operand_values_get_memory_operand_length(const xed_operand_values_t* p,
208                                              unsigned int memop_idx);
209
210 /// @ingroup OPERANDS    
211 XED_DLL_EXPORT xed_reg_enum_t
212 xed_operand_values_get_base_reg(const xed_operand_values_t* p,unsigned int memop_idx);
213
214 /// @ingroup OPERANDS    
215 XED_DLL_EXPORT xed_reg_enum_t
216 xed_operand_values_get_index_reg(const xed_operand_values_t* p,unsigned int memop_idx);
217
218 /// @ingroup OPERANDS    
219 XED_DLL_EXPORT xed_reg_enum_t
220 xed_operand_values_get_seg_reg(const xed_operand_values_t* p,unsigned int memop_idx);
221
222 /// @ingroup OPERANDS    
223 XED_DLL_EXPORT unsigned int
224 xed_operand_values_get_scale(const xed_operand_values_t* p);
225
226 /// @ingroup OPERANDS    
227 /// Returns true if the instruction access memory but without using a MODRM
228 /// byte limiting its addressing modes.
229 XED_DLL_EXPORT xed_bool_t 
230 xed_operand_values_memop_without_modrm(const xed_operand_values_t* p);
231 /// @ingroup OPERANDS
232 /// Returns true if the instruction has a MODRM byte.
233 XED_DLL_EXPORT xed_bool_t
234 xed_operand_values_has_modrm_byte(const xed_operand_values_t* p);
235
236 /// @ingroup OPERANDS
237 /// Returns true if the instruction has a SIB byte.
238 XED_DLL_EXPORT xed_bool_t
239 xed_operand_values_has_sib_byte(const xed_operand_values_t* p);
240 //@}
241
242 /// @ingroup OPERANDS    
243 XED_DLL_EXPORT xed_bool_t
244 xed_operand_values_branch_not_taken_hint(const xed_operand_values_t* p);
245 /// @ingroup OPERANDS    
246 XED_DLL_EXPORT xed_bool_t
247 xed_operand_values_branch_taken_hint(const xed_operand_values_t* p);
248
249 /// @ingroup OPERANDS    
250 XED_DLL_EXPORT xed_bool_t
251 xed_operand_values_is_nop(const xed_operand_values_t* p);
252
253
254 /// @name Immediates
255 //@{
256 /// @ingroup OPERANDS    
257 XED_DLL_EXPORT xed_int64_t
258 xed_operand_values_get_immediate_int64(const xed_operand_values_t* p);
259
260 /// @ingroup OPERANDS    
261 XED_DLL_EXPORT xed_uint64_t
262 xed_operand_values_get_immediate_uint64(const xed_operand_values_t* p);
263
264 /// @ingroup OPERANDS
265 /// Return true if the first immediate (IMM0) is signed
266 XED_DLL_EXPORT xed_uint_t xed_operand_values_get_immediate_is_signed(const xed_operand_values_t* p);
267
268     
269 /// @ingroup OPERANDS    
270 XED_DLL_EXPORT xed_uint8_t 
271 xed_operand_values_get_immediate_byte(const xed_operand_values_t* p,unsigned int i);
272
273 /// @ingroup OPERANDS    
274 XED_DLL_EXPORT xed_uint8_t 
275 xed_operand_values_get_second_immediate(const xed_operand_values_t* p);
276 //@}
277
278 /// @name Memory Displacements
279 //@{
280 /// @ingroup OPERANDS
281 /// Return the memory displacement width in BYTES
282 XED_DLL_EXPORT xed_uint32_t
283 xed_operand_values_get_memory_displacement_length(const xed_operand_values_t* p);
284 /// @ingroup OPERANDS
285 /// Return the memory displacement width in BITS
286 XED_DLL_EXPORT xed_uint32_t
287 xed_operand_values_get_memory_displacement_length_bits(const xed_operand_values_t* p);
288
289 /// @ingroup OPERANDS    
290 XED_DLL_EXPORT xed_int64_t
291 xed_operand_values_get_memory_displacement_int64(const xed_operand_values_t* p);
292
293 /// @ingroup OPERANDS    
294 XED_DLL_EXPORT xed_uint8_t 
295 xed_operand_values_get_memory_displacement_byte(const xed_operand_values_t* p,unsigned int i);
296 //@}
297
298 /// @name Branch Displacements
299 //@{
300 /// @ingroup OPERANDS
301 /// Return the branch displacement width in bytes
302 XED_DLL_EXPORT xed_uint32_t
303 xed_operand_values_get_branch_displacement_length(const xed_operand_values_t* p);
304 /// @ingroup OPERANDS
305 /// Return the branch displacement width in bits
306 XED_DLL_EXPORT xed_uint32_t
307 xed_operand_values_get_branch_displacement_length_bits(const xed_operand_values_t* p);
308
309 /// @ingroup OPERANDS    
310 XED_DLL_EXPORT xed_int32_t
311 xed_operand_values_get_branch_displacement_int32(const xed_operand_values_t* p);
312
313 /// @ingroup OPERANDS    
314 XED_DLL_EXPORT xed_uint8_t 
315 xed_operand_values_get_branch_displacement_byte(const xed_operand_values_t* p,unsigned int i);
316 //@}
317
318
319 /// @ingroup OPERANDS    
320 XED_DLL_EXPORT xed_iclass_enum_t
321 xed_operand_values_get_iclass(const xed_operand_values_t* p);
322     
323 ////////////////////////////////////////////////////
324 // ENCODE API
325 ////////////////////////////////////////////////////
326 /// @name Encoding
327 //@{
328 /// @ingroup OPERANDS    
329 XED_DLL_EXPORT void xed_operand_values_zero_immediate(xed_operand_values_t* p);
330 /// @ingroup OPERANDS    
331 XED_DLL_EXPORT void xed_operand_values_zero_branch_displacement(xed_operand_values_t* p);
332 /// @ingroup OPERANDS    
333 XED_DLL_EXPORT void xed_operand_values_zero_memory_displacement(xed_operand_values_t* p);
334
335 /// @ingroup OPERANDS    
336 XED_DLL_EXPORT void xed_operand_values_set_lock(xed_operand_values_t* p);
337 /// @ingroup OPERANDS    
338 XED_DLL_EXPORT void xed_operand_values_zero_segment_override(xed_operand_values_t* p);
339
340
341 /// @ingroup OPERANDS    
342 XED_DLL_EXPORT void
343 xed_operand_values_set_iclass(xed_operand_values_t* p,xed_iclass_enum_t iclass);
344
345 /// @ingroup OPERANDS    
346 XED_DLL_EXPORT void
347 xed_operand_values_set_effective_operand_width(xed_operand_values_t* p,unsigned int width);
348
349 /// @ingroup OPERANDS    
350 XED_DLL_EXPORT void
351 xed_operand_values_set_memory_operand_length(xed_operand_values_t* p,unsigned int memop_length);
352
353    
354 /// @ingroup OPERANDS    
355 /// Set the memory displacement using a BYTES length
356 XED_DLL_EXPORT void
357 xed_operand_values_set_memory_displacement(xed_operand_values_t* p,xed_int64_t x, unsigned int len);
358 /// @ingroup OPERANDS    
359 /// Set the memory displacement using a BITS length
360 XED_DLL_EXPORT void
361 xed_operand_values_set_memory_displacement_bits(xed_operand_values_t* p,xed_int64_t x, unsigned int len_bits);
362
363 /// @ingroup OPERANDS    
364 /// Indicate that we have a relative branch.
365 XED_DLL_EXPORT void xed_operand_values_set_relbr(xed_operand_values_t* p);
366
367 /// @ingroup OPERANDS    
368 /// Set the branch displacement using a BYTES length
369 XED_DLL_EXPORT void
370 xed_operand_values_set_branch_displacement(xed_operand_values_t* p,xed_int32_t x, unsigned int len);
371 /// @ingroup OPERANDS    
372 /// Set the branch displacement using a BITS length
373 XED_DLL_EXPORT void
374 xed_operand_values_set_branch_displacement_bits(xed_operand_values_t* p,xed_int32_t x, unsigned int len_bits);
375
376 /// @ingroup OPERANDS    
377 /// Set the signed immediate using a BYTES length
378 XED_DLL_EXPORT void
379 xed_operand_values_set_immediate_signed(xed_operand_values_t* p,xed_int32_t x, unsigned int bytes); 
380 /// @ingroup OPERANDS    
381 /// Set the signed immediate using a BITS length
382 XED_DLL_EXPORT void
383 xed_operand_values_set_immediate_signed_bits(xed_operand_values_t* p,xed_int32_t x, unsigned int bits); 
384
385
386 /// @ingroup OPERANDS    
387 /// Set the unsigned immediate using a BYTE length.
388 XED_DLL_EXPORT void
389 xed_operand_values_set_immediate_unsigned(xed_operand_values_t* p,xed_uint64_t x, unsigned int bytes);
390 /// @ingroup OPERANDS    
391 /// Set the unsigned immediate using a BIT length.
392 XED_DLL_EXPORT void
393 xed_operand_values_set_immediate_unsigned_bits(xed_operand_values_t* p,xed_uint64_t x, unsigned int bits);
394
395
396
397 /// @ingroup OPERANDS    
398 XED_DLL_EXPORT void xed_operand_values_set_base_reg(xed_operand_values_t* p,
399                                                     unsigned int memop_idx,
400                                                     xed_reg_enum_t new_base);
401
402 /// @ingroup OPERANDS    
403 XED_DLL_EXPORT void xed_operand_values_set_seg_reg(xed_operand_values_t* p,
404                                                    unsigned int memop_idx,
405                                                    xed_reg_enum_t new_seg);
406
407 /// @ingroup OPERANDS    
408 XED_DLL_EXPORT void xed_operand_values_set_index_reg(xed_operand_values_t* p,
409                                                      unsigned int memop_idx,
410                                                      xed_reg_enum_t new_index);
411
412 /// @ingroup OPERANDS    
413 XED_DLL_EXPORT void xed_operand_values_set_scale(xed_operand_values_t* p, 
414                                                  xed_uint_t memop_idx,
415                                                  xed_uint_t new_scale);
416
417
418 /// @ingroup OPERANDS    
419 /// Set the operand storage field entry named 'operand_name' to the
420 /// register value specified by 'reg_name'.
421 XED_DLL_EXPORT void
422 xed_operand_values_set_operand_reg(xed_operand_values_t* p,
423                                    xed_operand_enum_t operand_name,
424                                    xed_reg_enum_t reg_name);
425
426 //@}
427 #endif
428
429 //Local Variables:
430 //pref: "../../xed-operand-values-interface.c"
431 //End: