diff options
author | Cyrille Bagard <nocbos@gmail.com> | 2017-04-20 18:52:01 (GMT) |
---|---|---|
committer | Cyrille Bagard <nocbos@gmail.com> | 2017-04-20 18:52:01 (GMT) |
commit | 8e5c8417e8ef79c1b475cb1b86a1754b24f9af78 (patch) | |
tree | 650a39bde7a5367995b471a562aa766febd505bc /tools/d2c | |
parent | c177597d6da5dedb32aa176e8370db8ffb7f87aa (diff) |
Shared immediate operands in order to avoid useless allocations.
Diffstat (limited to 'tools/d2c')
-rw-r--r-- | tools/d2c/syntax/manager.c | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/tools/d2c/syntax/manager.c b/tools/d2c/syntax/manager.c index cfbf826..6857e9a 100644 --- a/tools/d2c/syntax/manager.c +++ b/tools/d2c/syntax/manager.c @@ -230,12 +230,14 @@ bool declare_syntax_items(const asm_syntax *syntax, int fd, const coding_bits *b { bool result; /* Bilan à retourner */ bool has_operand; /* Présence d'un opérande */ + bool has_immediate; /* Présence d'une conversion */ size_t i; /* Boucle de parcours */ syntax_item *item; /* Lien vers un opérande */ result = true; has_operand = false; + has_immediate = false; for (i = 0; i < syntax->items_count && result; i++) { @@ -244,11 +246,17 @@ bool declare_syntax_items(const asm_syntax *syntax, int fd, const coding_bits *b has_operand |= (item->impact == SIT_EXT_OPERAND); + if (has_operand) + has_immediate = (item->flags & SIF_DECIMAL); + } if (has_operand) dprintf(fd, "\t\tGArchOperand *op;\n"); + if (has_immediate) + dprintf(fd, "\t\tGImmOperand *imm;\n"); + return result; } @@ -355,7 +363,11 @@ bool define_syntax_items(const asm_syntax *syntax, int fd, const char *arch, con dprintf(fd, "\n"); if (item->flags & SIF_DECIMAL) - dprintf(fd, "\t\tg_imm_operand_set_default_display(G_IMM_OPERAND(op), IOD_DEC);\n"); + { + dprintf(fd, "\t\timm = G_IMM_OPERAND(op)\n"); + dprintf(fd, "\t\tg_imm_operand_set_default_display(&imm, IOD_DEC, NULL);\n"); + dprintf(fd, "\t\timm = G_IMM_OPERAND(op)\n"); + } dprintf(fd, "\t\tg_arch_instruction_attach_extra_operand(instr, op);\n"); @@ -382,7 +394,11 @@ bool define_syntax_items(const asm_syntax *syntax, int fd, const char *arch, con dprintf(fd, "\n"); if (item->flags & SIF_DECIMAL) - dprintf(fd, "\t\tg_imm_operand_set_default_display(G_IMM_OPERAND(op), IOD_DEC);\n"); + { + dprintf(fd, "\t\timm = G_IMM_OPERAND(op)\n"); + dprintf(fd, "\t\tg_imm_operand_set_default_display(&imm, IOD_DEC, NULL);\n"); + dprintf(fd, "\t\timm = G_IMM_OPERAND(op)\n"); + } dprintf(fd, "\t\tg_arch_instruction_attach_extra_operand(instr, op);\n"); |