XED
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
xed-encode.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 #ifndef _XED_ENCODE_H_
35 # define _XED_ENCODE_H_
36 #include "xed-common-hdrs.h"
37 #include "xed-types.h"
38 #include "xed-error-enum.h"
40 #include "xed-operand-width-enum.h"
41 #include "xed-encoder-iforms.h" //generated
42 #include "xed-encoder-gen-defs.h" //generated
43 
44 // we now (mostly) share the decode data structure
45 #include "xed-decoded-inst.h"
46 
47 
48 // establish a type equivalence for the xed_encoder_request_t and the corresponding xed_decoded_inst_t.
49 
54 
55 
56 
60 
62 // set functions
63 
65 XED_DLL_EXPORT void
67  xed_iclass_enum_t iclass);
68 
70 
84 
86 
89  xed_uint_t width_bits);
92  xed_uint_t width_bits);
101  xed_operand_enum_t operand,
102  xed_reg_enum_t reg);
104 
106 
107 
121  xed_uint_t operand_index,
122  xed_operand_enum_t name);
123 
132  xed_uint_t operand_index);
133 
134 
138 static XED_INLINE
140  return p->_n_operand_order;
141 }
142 
144 
145 
147 
152  xed_int32_t brdisp,
153  xed_uint_t nbytes);
157 
158 
160 
164  xed_uint64_t uimm,
165  xed_uint_t nbytes);
169  xed_uint64_t uimm,
170  xed_uint_t nbits);
173  xed_uint8_t uimm);
177  xed_int32_t simm,
178  xed_uint_t nbytes);
179 
181 
184  xed_int64_t memdisp,
185  xed_uint_t nbytes);
186 
195  xed_uint_t nbytes);
198  xed_reg_enum_t seg_reg);
201  xed_reg_enum_t seg_reg);
204  xed_reg_enum_t base_reg);
207  xed_reg_enum_t base_reg) ;
210  xed_reg_enum_t index_reg);
213  xed_uint_t scale);
215 
221 
223 
224 
229 
232  const xed_state_t* dstate);
236 
237 struct xed_decoded_inst_s; //fwd decl
241 
243 
246  char* buf, xed_uint_t buflen);
248 
249 
250 
251 
253 
270  xed_uint8_t* array,
271  const unsigned int ilen,
272  unsigned int* olen);
273 
282 xed_encode_nop(xed_uint8_t* array,
283  const unsigned int ilen);
285 
286 #endif
xed_error_enum_t
The main container for instructions.
XED_DLL_EXPORT void xed_encoder_request_set_repne(xed_encoder_request_t *p)
for REPNE(F2) prefix on string ops
XED_DLL_EXPORT void xed_encoder_request_set_relbr(xed_encoder_request_t *p)
XED_DLL_EXPORT void xed_encoder_request_set_effective_address_size(xed_encoder_request_t *p, xed_uint_t width_bits)
XED_DLL_EXPORT xed_error_enum_t xed_encode_nop(xed_uint8_t *array, const unsigned int ilen)
This function will attempt to encode a NOP of exactly ilen bytes.
XED_DLL_EXPORT void xed_encoder_request_clear_rep(xed_encoder_request_t *p)
clear the REP prefix indicator
xed_iclass_enum_t
XED_DLL_EXPORT void xed_encoder_request_set_scale(xed_encoder_request_t *p, xed_uint_t scale)
XED_DLL_EXPORT void xed_encoder_request_set_effective_operand_width(xed_encoder_request_t *p, xed_uint_t width_bits)
XED_DLL_EXPORT void xed_encoder_request_zero_operand_order(xed_encoder_request_t *p)
static XED_INLINE xed_uint_t xed_encoder_request_operand_order_entries(xed_encoder_request_t *p)
Retreive the number of entries in the encoder operand order array.
Definition: xed-encode.h:139
XED_DLL_EXPORT void xed_encoder_request_set_index(xed_encoder_request_t *p, xed_reg_enum_t index_reg)
XED_DLL_EXPORT xed_operand_values_t * xed_encoder_request_operands(xed_encoder_request_t *p)
XED_DLL_EXPORT void xed_encoder_request_set_branch_displacement(xed_encoder_request_t *p, xed_int32_t brdisp, xed_uint_t nbytes)
XED_DLL_EXPORT void xed_encoder_request_set_operand_order(xed_encoder_request_t *p, xed_uint_t operand_index, xed_operand_enum_t name)
XED_DLL_EXPORT void xed_encoder_request_init_from_decode(struct xed_decoded_inst_s *d)
Converts an decoder request to a valid encoder request.
XED_DLL_EXPORT void xed_encoder_request_set_uimm0(xed_encoder_request_t *p, xed_uint64_t uimm, xed_uint_t nbytes)
Set the uimm0 using a BYTE width.
xed_operand_enum_t
#define XED_INLINE
XED_DLL_EXPORT void xed_encoder_request_set_simm(xed_encoder_request_t *p, xed_int32_t simm, xed_uint_t nbytes)
same storage as uimm0
XED_DLL_EXPORT void xed_encoder_request_set_base1(xed_encoder_request_t *p, xed_reg_enum_t base_reg)
xed_reg_enum_t
Definition: xed-reg-enum.h:39
xed_decoded_inst_t xed_encoder_request_t
Definition: xed-encode.h:53
XED_DLL_EXPORT void xed_encoder_request_set_base0(xed_encoder_request_t *p, xed_reg_enum_t base_reg)
XED_DLL_EXPORT void xed_encoder_request_set_lock(xed_encoder_request_t *p)
For locked (atomic read-modify-write) memops requests.
XED_DLL_EXPORT void xed_encoder_request_zero_set_mode(xed_encoder_request_t *p, const xed_state_t *dstate)
XED_DLL_EXPORT void xed_encoder_request_set_ptr(xed_encoder_request_t *p)
XED_DLL_EXPORT const xed_operand_values_t * xed_encoder_request_operands_const(const xed_encoder_request_t *p)
Encapsulates machine modes for decoder/encoder requests.
Definition: xed-state.h:52
XED_DLL_EXPORT void xed_encoder_request_set_memory_operand_length(xed_encoder_request_t *p, xed_uint_t nbytes)
XED_DLL_EXPORT void xed_encoder_request_set_iclass(xed_encoder_request_t *p, xed_iclass_enum_t iclass)
XED_DLL_EXPORT void xed_encode_request_print(const xed_encoder_request_t *p, char *buf, xed_uint_t buflen)
XED_DLL_EXPORT xed_operand_enum_t xed_encoder_request_get_operand_order(xed_encoder_request_t *p, xed_uint_t operand_index)
unsigned int xed_uint_t
Definition: xed-types.h:65
XED_DLL_EXPORT void xed_encoder_request_set_mem0(xed_encoder_request_t *p)
XED_DLL_EXPORT xed_iclass_enum_t xed_encoder_request_get_iclass(const xed_encoder_request_t *p)
XED_DLL_EXPORT xed_error_enum_t xed_encode(xed_encoder_request_t *r, xed_uint8_t *array, const unsigned int ilen, unsigned int *olen)
This is the main interface to the encoder.
XED_DLL_EXPORT void xed_encoder_request_set_agen(xed_encoder_request_t *p)
XED_DLL_EXPORT void xed_encoder_request_set_memory_displacement(xed_encoder_request_t *p, xed_int64_t memdisp, xed_uint_t nbytes)
XED_DLL_EXPORT void xed_encoder_request_set_uimm0_bits(xed_encoder_request_t *p, xed_uint64_t uimm, xed_uint_t nbits)
Set the uimm0 using a BIT width.
xed_uint8_t _n_operand_order
Length of the _operand_order[] array.
XED_DLL_EXPORT void xed_encoder_request_set_seg1(xed_encoder_request_t *p, xed_reg_enum_t seg_reg)
XED_DLL_EXPORT void xed_encoder_request_set_mem1(xed_encoder_request_t *p)
XED_DLL_EXPORT void xed_encoder_request_set_reg(xed_encoder_request_t *p, xed_operand_enum_t operand, xed_reg_enum_t reg)
XED_DLL_EXPORT void xed_encoder_request_set_seg0(xed_encoder_request_t *p, xed_reg_enum_t seg_reg)
XED_DLL_EXPORT void xed_encoder_request_set_uimm1(xed_encoder_request_t *p, xed_uint8_t uimm)
#define XED_DLL_EXPORT
XED_DLL_EXPORT void xed_encoder_request_set_rep(xed_encoder_request_t *p)
for REP(F3) prefix on string ops
XED_DLL_EXPORT void xed_encoder_request_zero(xed_encoder_request_t *p)