From 4af6e087dde9a2048419219bc4b7e6efff0e17bf Mon Sep 17 00:00:00 2001 From: Michael Matz Date: Sun, 15 May 2016 18:38:12 +0200 Subject: [PATCH] x86-asm: move stats code The old place (tccasm.c) didn't have access to the variables anymore and was ifdefed out. Move it to i386-asm.c. --- i386-asm.c | 40 ++++++++++++++++++++++++++++++++++++++++ tccasm.c | 32 -------------------------------- 2 files changed, 40 insertions(+), 32 deletions(-) diff --git a/i386-asm.c b/i386-asm.c index 16916f9..ad510d3 100644 --- a/i386-asm.c +++ b/i386-asm.c @@ -504,6 +504,45 @@ static inline int asm_modrm(int reg, Operand *op) return 0; } +static void maybe_print_stats (void) +{ + static int already = 1; + if (!already) + /* print stats about opcodes */ + { + const struct ASMInstr *pa; + int freq[4]; + int op_vals[500]; + int nb_op_vals, i, j; + + already = 1; + nb_op_vals = 0; + memset(freq, 0, sizeof(freq)); + for(pa = asm_instrs; pa->sym != 0; pa++) { + freq[pa->nb_ops]++; + //for(i=0;inb_ops;i++) { + for(j=0;jop_type[i] == op_vals[j]) + if (pa->instr_type == op_vals[j]) + goto found; + } + //op_vals[nb_op_vals++] = pa->op_type[i]; + op_vals[nb_op_vals++] = pa->instr_type; + found: ; + //} + } + for(i=0;i= TOK_ASM_wait && opcode <= TOK_ASM_repnz) diff --git a/tccasm.c b/tccasm.c index cff4b98..e8bc357 100644 --- a/tccasm.c +++ b/tccasm.c @@ -757,38 +757,6 @@ static int tcc_assemble_internal(TCCState *s1, int do_preprocess) { int opcode; -#if 0 - /* print stats about opcodes */ - { - const ASMInstr *pa; - int freq[4]; - int op_vals[500]; - int nb_op_vals, i, j; - - nb_op_vals = 0; - memset(freq, 0, sizeof(freq)); - for(pa = asm_instrs; pa->sym != 0; pa++) { - freq[pa->nb_ops]++; - for(i=0;inb_ops;i++) { - for(j=0;jop_type[i] == op_vals[j]) - goto found; - } - op_vals[nb_op_vals++] = pa->op_type[i]; - found: ; - } - } - for(i=0;ibuf_ptr[0];