Debian Codegraph @

src/fcml_operand_decorators.c

raw
1 /*
2 * FCML - Free Code Manipulation Library.
3 * Copyright (C) 2017 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_operand_decorators.h"
21 #include "fcml_def.h"
22
23 void fcml_fn_prepare_decorators_existence(fcml_operand_desc *operands,
24 fcml_st_decorators_existence *dec_existence) {
25 int i;
26 for(i = 0; i < FCML_OPERANDS_COUNT; i++) {
27 fcml_operand_decorators decorators = FCML_DECORATORS(operands[i]);
28 if (FCML_IS_DECOR_BCAST(decorators)) {
29 dec_existence->bcast = FCML_TRUE;
30 }
31 if (FCML_IS_DECOR_OPMASK_REG(decorators)) {
32 dec_existence->opmask_reg = FCML_TRUE;
33 }
34 if (FCML_IS_DECOR_Z(decorators)) {
35 dec_existence->z = FCML_TRUE;
36 }
37 if (FCML_IS_DECOR_ER(decorators)) {
38 dec_existence->er = FCML_TRUE;
39 }
40 if (FCML_IS_DECOR_SAE(decorators)) {
41 dec_existence->sae = FCML_TRUE;
42 }
43 }
44 }
45
46 fcml_ceh_error fcml_fn_op_decor_decode(
47 fcml_st_decorators_prefix_flags *prefix_flags,
48 fcml_operand_decorators decorators_def, fcml_st_operand *operand) {
49
50 fcml_ceh_error error = FCML_CEH_GEC_NO_ERROR;
51
52 fcml_st_operand_decorators *decorators = &(operand->decorators);
53
54 /* Operand mask register. */
55 if (FCML_IS_DECOR_OPMASK_REG(decorators_def) && prefix_flags->aaa > 0) {
56 decorators->operand_mask_reg.type = FCML_REG_OPMASK;
57 decorators->operand_mask_reg.size = FCML_DS_64;
58 decorators->operand_mask_reg.x64_exp = FCML_FALSE;
59 decorators->operand_mask_reg.reg = prefix_flags->aaa;
60 }
61
62 /* Zeroying. */
63 if (FCML_IS_DECOR_Z(decorators_def) && prefix_flags->z) {
64 decorators->z = FCML_TRUE;
65 }
66
67 return error;
68 }