Debian Codegraph @

src/fcml_hints.c

raw
1 /*
2 * FCML - Free Code Manipulation Library.
3 * Copyright (C) 2010-2020 Slawomir Wojtasiak
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 */
19
20 #include "fcml_hints.h"
21
22 fcml_st_hts_calculated_hints fcml_fn_hts_ihc_far_pointer(
23 const fcml_st_def_addr_mode_desc *addr_mode,
24 fcml_st_def_decoded_addr_mode *decoded_addr_mode) {
25 fcml_st_hts_calculated_hints hints;
26 hints.instruction_hints = FCML_HINT_FAR_POINTER;
27 hints.operand_hints = 0;
28 return hints;
29 }
30
31 fcml_st_hts_calculated_hints fcml_fn_hts_ihc_modrm_hints(
32 const fcml_st_def_addr_mode_desc *addr_mode,
33 fcml_st_def_decoded_addr_mode *decoded_addr_mode) {
34 fcml_st_hts_calculated_hints hints = { 0 };
35 fcml_st_def_tma_rm *rm_args =
36 (fcml_st_def_tma_rm*) decoded_addr_mode->addr_mode_args;
37 if (rm_args->flags & FCML_RMF_M) {
38 hints.operand_hints = 0;
39 /* VSIB addressing mode is available for multimedia instructions only. */
40 if (rm_args->reg_type == FCML_REG_SIMD || rm_args->is_vsib) {
41 /* SIMD media instruction. */
42 hints.operand_hints |= FCML_OP_HINT_MULTIMEDIA_INSTRUCTION;
43 }
44 if ( FCML_GET_OS( rm_args->encoded_memory_operand_size ) == FCML_EOS_FP) {
45 /* Far pointer. */
46 hints.instruction_hints |= FCML_HINT_FAR_POINTER;
47 } else if ( FCML_GET_OS(
48 rm_args->encoded_memory_operand_size) != FCML_EOS_FPI) {
49 /* If not far, then near :) */
50 hints.instruction_hints |= FCML_HINT_NEAR_POINTER;
51 }
52 if (rm_args->flags & FCML_RMF_I) {
53 hints.instruction_hints |= FCML_HINT_INDIRECT_POINTER;
54 }
55 /* Every ModR/M encoded operand supports SIB hint. */
56 hints.operand_hints |= FCML_OP_HINT_SIB_ENCODING;
57 } else {
58 hints.operand_hints = 0;
59 }
60 return hints;
61 }
62
63 fcml_st_hts_calculated_hints fcml_fn_hts_ihc_immediate_dis_relative(
64 const fcml_st_def_addr_mode_desc *addr_mode,
65 fcml_st_def_decoded_addr_mode *decoded_addr_mode) {
66 fcml_st_hts_calculated_hints hints;
67 hints.instruction_hints = 0;
68 hints.operand_hints = FCML_OP_HINT_DISPLACEMENT_RELATIVE_ADDRESS;
69 return hints;
70 }
71
72 fcml_st_hts_calculated_hints fcml_fn_hts_ihc_pseudo_opcode(
73 const fcml_st_def_addr_mode_desc *addr_mode,
74 fcml_st_def_decoded_addr_mode *decoded_addr_mode) {
75 fcml_st_hts_calculated_hints hints;
76 hints.instruction_hints = 0;
77 hints.operand_hints = FCML_OP_HINT_PSEUDO_OPCODE;
78 return hints;
79 }