XED
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
xed-inst.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 */
32 
33 
34 #if !defined(_XED_INST_H_)
35 # define _XED_INST_H_
36 
37 #include "xed-util.h"
38 #include "xed-portability.h"
39 #include "xed-category-enum.h" // generated
40 #include "xed-extension-enum.h" //generated
41 #include "xed-iclass-enum.h" //generated
42 #include "xed-operand-enum.h" // generated
43 #include "xed-operand-visibility-enum.h" //generated
44 #include "xed-operand-action-enum.h" // generated
45 #include "xed-operand-convert-enum.h" // generated
46 #include "xed-operand-type-enum.h" // generated
47 #include "xed-nonterminal-enum.h" // a generated file
48 #include "xed-operand-width-enum.h" // a generated file
49 #include "xed-operand-element-xtype-enum.h" // a generated file
50 #include "xed-reg-enum.h" // a generated file
51 #include "xed-attribute-enum.h" // a generated file
52 #include "xed-exception-enum.h" // a generated file
53 #include "xed-iform-enum.h" // a generated file
54 #include "xed-iform-map.h"
55 #include "xed-attributes.h"
56 
57 struct xed_decoded_inst_s; //fwd-decl
58 
59 typedef void (*xed_operand_extractor_fn_t)(struct xed_decoded_inst_s* xds);
60 
61 
66 typedef struct xed_operand_s
67 {
69 
70  // implicit, explicit, suppressed
72  xed_operand_action_enum_t _rw; // read or written
73 
74  // width code, could be invalid (then use register name)
76 
77  // IMM, IMM_CONST, NT_LOOKUP_FN, REG, ERROR
79  xed_operand_element_xtype_enum_t _xtype; // xed data type: u32, f32, etc.
80  xed_uint8_t _cvt_idx; // decoration index
81  union {
82  xed_uint32_t _imm; // value for some constant immmed
83  xed_nonterminal_enum_t _nt; // for nt_lookup_fn's
84  xed_reg_enum_t _reg; // register name
85  } _u;
86 } xed_operand_t;
87 
89 
93  return p->_name;
94 }
95 
96 
100  return p->_operand_visibility;
101 }
102 
103 
109  return p->_type;
110 }
111 
117  return p->_xtype;
118 }
119 
120 
124  return p->_oc2;
125 }
126 
133 XED_DLL_EXPORT xed_uint32_t
135  const xed_uint32_t eosz);
136 
140  return p->_u._nt;
141 }
142 
153  return p->_u._reg;
154 }
155 
156 
157 
168 static XED_INLINE xed_uint_t
170  return p->_type == XED_OPERAND_TYPE_NT_LOOKUP_FN ||
172 }
173 
178 static XED_INLINE xed_uint32_t xed_operand_imm(const xed_operand_t* p) {
179  return p->_u._imm;
180 }
181 
187 XED_DLL_EXPORT void
188 xed_operand_print(const xed_operand_t* p, char* buf, int buflen);
190 
192 
201  return name >= XED_OPERAND_REG0 && name <= XED_OPERAND_REG8;
202 }
208 static XED_INLINE xed_uint_t
210  return ( name == XED_OPERAND_BASE0 ||
211  name == XED_OPERAND_INDEX ||
212  name == XED_OPERAND_SEG0 ||
213  name == XED_OPERAND_BASE1 ||
214  name == XED_OPERAND_SEG1 );
215 }
216 
218 
220 
226  return p->_rw;
227 }
228 
251 
252 
257 typedef struct xed_inst_s {
258 
259 
260  // rflags info -- index in to the 2 tables of flags information.
261  // If _flag_complex is true, then the data are in the
262  // xed_flags_complex_table[]. Otherwise, the data are in the
263  // xed_flags_simple_table[].
264 
265  //xed_instruction_fixed_bit_confirmer_fn_t _confirmer;
266 
267  // number of operands in the operands array
268  xed_uint8_t _noperands;
269  xed_uint8_t _cpl; // the nominal CPL for the instruction.
270  xed_uint16_t _flag_info_index;
271 
273  // index into the xed_operand[] array of xed_operand_t structures
274  xed_uint16_t _operand_base;
275  xed_uint16_t _flag_complex; /* 1/0 valued, bool type */
276 
277  // index to table of xed_attributes_t structures
278  xed_uint16_t _attributes;
280 } xed_inst_t;
281 
283 
284 XED_DLL_EXPORT unsigned int xed_inst_cpl(const xed_inst_t* p) ;
291 
292 
293 //These next few are not doxygen commented because I want people to use the
294 //higher level interface in xed-decoded-inst.h.
296  return xed_iform_to_iclass(p->_iform_enum);
297 }
298 
301 }
302 
305 }
308 }
309 
311  return p->_iform_enum;
312 }
313 
314 
317 static XED_INLINE unsigned int xed_inst_noperands(const xed_inst_t* p) {
318  return p->_noperands;
319 }
320 
324 xed_inst_operand(const xed_inst_t* p, unsigned int i);
325 
326 
327 
328 XED_DLL_EXPORT xed_uint32_t xed_inst_flag_info_index(const xed_inst_t* p);
329 
331 
333 
334 XED_DLL_EXPORT xed_uint32_t
338  xed_attribute_enum_t attr);
339 
344 
345 
349 XED_DLL_EXPORT unsigned int xed_attribute_max(void);
350 
355 
357 
359 
360 static XED_INLINE
365  return p->_exceptions;
366 }
367 
372 
373 #endif
xed_iform_enum_t
xed_uint8_t _cpl
Definition: xed-inst.h:269
The main container for instructions.
static XED_INLINE xed_uint_t xed_operand_is_memory_addressing_register(xed_operand_enum_t name)
Tests the enum for inclusion in XED_OPERAND_{BASE0,BASE1,INDEX,SEG0,SEG1}.
Definition: xed-inst.h:209
xed_uint8_t _cvt_idx
Definition: xed-inst.h:80
XED_DLL_EXPORT const xed_inst_t * xed_inst_table_base(void)
Return the base of instruction table.
XED_DLL_EXPORT xed_attribute_enum_t xed_attribute(unsigned int i)
Return the i'th global attribute in a linear sequence, independent of any instruction.
struct xed_operand_s xed_operand_t
Constant information about an individual generic operand, like an operand template, describing the operand properties.
XED_DLL_EXPORT xed_extension_enum_t xed_iform_to_extension(xed_iform_enum_t iform)
Return the extension for a given iform.
xed_iclass_enum_t
static XED_INLINE xed_operand_enum_t xed_operand_name(const xed_operand_t *p)
Definition: xed-inst.h:92
struct xed_inst_s xed_inst_t
constant information about a decoded instruction form, including the pointer to the constant operand ...
static XED_INLINE xed_isa_set_enum_t xed_inst_isa_set(const xed_inst_t *p)
Definition: xed-inst.h:306
xed_uint32_t _imm
Definition: xed-inst.h:82
static XED_INLINE xed_nonterminal_enum_t xed_operand_nonterminal_name(const xed_operand_t *p)
Definition: xed-inst.h:139
XED_DLL_EXPORT xed_uint_t xed_operand_written_only(const xed_operand_t *p)
If the operand is written-only, including conditional writes.
XED_DLL_EXPORT xed_uint_t xed_operand_read_and_written(const xed_operand_t *p)
If the operand is read-and-written, conditional reads and conditional writes.
XED_DLL_EXPORT xed_category_enum_t xed_iform_to_category(xed_iform_enum_t iform)
Return the category for a given iform.
static XED_INLINE xed_operand_type_enum_t xed_operand_type(const xed_operand_t *p)
Definition: xed-inst.h:108
static XED_INLINE xed_extension_enum_t xed_inst_extension(const xed_inst_t *p)
Definition: xed-inst.h:303
xed_uint16_t _attributes
Definition: xed-inst.h:278
xed_uint16_t _flag_info_index
Definition: xed-inst.h:270
xed_operand_width_enum_t _oc2
Definition: xed-inst.h:75
XED_DLL_EXPORT xed_uint_t xed_operand_conditional_write(const xed_operand_t *p)
If the operand has a conditional write (may also read)
xed_exception_enum_t
static XED_INLINE xed_iclass_enum_t xed_inst_iclass(const xed_inst_t *p)
Definition: xed-inst.h:295
XED_DLL_EXPORT xed_uint_t xed_operand_read_only(const xed_operand_t *p)
If the operand is read-only, including conditional reads.
static XED_INLINE xed_iform_enum_t xed_inst_iform_enum(const xed_inst_t *p)
Definition: xed-inst.h:310
XED_DLL_EXPORT const xed_operand_t * xed_inst_operand(const xed_inst_t *p, unsigned int i)
Obtain a pointer to an individual operand.
xed_operand_enum_t
#define XED_INLINE
static XED_INLINE xed_operand_action_enum_t xed_operand_rw(const xed_operand_t *p)
Returns the raw R/W action.
Definition: xed-inst.h:225
static XED_INLINE unsigned int xed_inst_noperands(const xed_inst_t *p)
Number of instruction operands.
Definition: xed-inst.h:317
xed_reg_enum_t
Definition: xed-reg-enum.h:39
xed_isa_set_enum_t
xed_operand_element_xtype_enum_t _xtype
Definition: xed-inst.h:79
xed_operand_enum_t _name
Definition: xed-inst.h:68
xed_uint16_t _flag_complex
Definition: xed-inst.h:275
xed_operand_type_enum_t _type
Definition: xed-inst.h:78
XED_DLL_EXPORT xed_uint32_t xed_inst_flag_info_index(const xed_inst_t *p)
static XED_INLINE xed_uint_t xed_operand_is_register(xed_operand_enum_t name)
Tests the enum for inclusion in XED_OPERAND_REG0 through XED_OPERAND_REG15.
Definition: xed-inst.h:200
constant information about a decoded instruction form, including the pointer to the constant operand ...
Definition: xed-inst.h:257
static XED_INLINE xed_operand_width_enum_t xed_operand_width(const xed_operand_t *p)
Definition: xed-inst.h:123
static XED_INLINE xed_reg_enum_t xed_operand_reg(const xed_operand_t *p)
Careful with this one – use xed_decoded_inst_get_reg()! This one is probably not what you think it i...
Definition: xed-inst.h:152
static XED_INLINE xed_uint_t xed_operand_template_is_register(const xed_operand_t *p)
Careful with this one; See xed_operand_is_register().
Definition: xed-inst.h:169
xed_operand_action_enum_t
xed_exception_enum_t _exceptions
Definition: xed-inst.h:279
static xed_iclass_enum_t XED_INLINE xed_iform_to_iclass(xed_iform_enum_t iform)
Return the iclass for a given iform.
Definition: xed-iform-map.h:87
xed_operand_visibility_enum_t
xed_operand_visibility_enum_t _operand_visibility
Definition: xed-inst.h:71
xed_attribute_enum_t
static XED_INLINE xed_uint32_t xed_operand_imm(const xed_operand_t *p)
Definition: xed-inst.h:178
XED_DLL_EXPORT unsigned int xed_inst_cpl(const xed_inst_t *p)
xed_inst_cpl() is DEPRECATED.
union xed_operand_s::@6 _u
XED_DLL_EXPORT void xed_operand_print(const xed_operand_t *p, char *buf, int buflen)
Print the operand p into the buffer buf, of length buflen.
xed_nonterminal_enum_t
xed_category_enum_t
unsigned int xed_uint_t
Definition: xed-types.h:65
xed_uint8_t _noperands
Definition: xed-inst.h:268
xed_reg_enum_t _reg
Definition: xed-inst.h:84
XED_DLL_EXPORT xed_attributes_t xed_inst_get_attributes(const xed_inst_t *p)
Return the attributes bit vector.
static XED_INLINE xed_exception_enum_t xed_inst_exception(const xed_inst_t *p)
Return xed_exception_enum_t if present for the specified instruction.
Definition: xed-inst.h:364
static XED_INLINE xed_operand_visibility_enum_t xed_operand_operand_visibility(const xed_operand_t *p)
Definition: xed-inst.h:99
Constant information about an individual generic operand, like an operand template, describing the operand properties.
Definition: xed-inst.h:66
xed_iform_enum_t _iform_enum
Definition: xed-inst.h:272
xed_uint16_t _operand_base
Definition: xed-inst.h:274
xed_operand_action_enum_t _rw
Definition: xed-inst.h:72
XED_DLL_EXPORT xed_uint32_t xed_operand_width_bits(const xed_operand_t *p, const xed_uint32_t eosz)
void(* xed_operand_extractor_fn_t)(struct xed_decoded_inst_s *xds)
Definition: xed-inst.h:59
xed_extension_enum_t
xed_nonterminal_enum_t _nt
Definition: xed-inst.h:83
XED_DLL_EXPORT unsigned int xed_attribute_max(void)
Return the maximum number of defined attributes, independent of any instruction.
XED_DLL_EXPORT xed_uint_t xed_operand_conditional_read(const xed_operand_t *p)
If the operand has a conditional read (may also write)
xed_operand_width_enum_t
XED_DLL_EXPORT xed_isa_set_enum_t xed_iform_to_isa_set(xed_iform_enum_t iform)
Return the isa_set for a given iform.
XED_DLL_EXPORT xed_uint_t xed_operand_written(const xed_operand_t *p)
If the operand is written, including conditional writes.
static XED_INLINE xed_category_enum_t xed_inst_category(const xed_inst_t *p)
Definition: xed-inst.h:299
#define XED_DLL_EXPORT
xed_operand_type_enum_t
static XED_INLINE xed_operand_element_xtype_enum_t xed_operand_xtype(const xed_operand_t *p)
Definition: xed-inst.h:116
XED_DLL_EXPORT xed_uint32_t xed_inst_get_attribute(const xed_inst_t *p, xed_attribute_enum_t attr)
Scan for the attribute attr and return 1 if it is found, 0 otherwise.
XED_DLL_EXPORT xed_uint_t xed_operand_read(const xed_operand_t *p)
If the operand is read, including conditional reads.