diff options
| author | Michael Matz <matz@suse.de> | 2016-05-15 18:38:12 +0200 |
|---|---|---|
| committer | Michael Matz <matz@suse.de> | 2016-12-15 17:47:05 +0100 |
| commit | 4af6e087dde9a2048419219bc4b7e6efff0e17bf (patch) | |
| tree | 2c29140de09930962e6c171f3f200047239c2d86 | |
| parent | ed35ac841b9e9c3c8cec8459ec84833f483af959 (diff) | |
| download | tinycc-4af6e087dde9a2048419219bc4b7e6efff0e17bf.tar.gz tinycc-4af6e087dde9a2048419219bc4b7e6efff0e17bf.tar.bz2 | |
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.
| -rw-r--r-- | i386-asm.c | 40 | ||||
| -rw-r--r-- | tccasm.c | 32 |
2 files changed, 40 insertions, 32 deletions
@@ -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;i<pa->nb_ops;i++) { + for(j=0;j<nb_op_vals;j++) { + //if (pa->op_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<nb_op_vals;i++) { + int v = op_vals[i]; + //if ((v & (v - 1)) != 0) + printf("%3d: %08x\n", i, v); + } + printf("size=%d nb=%d f0=%d f1=%d f2=%d f3=%d\n", + (int)sizeof(asm_instrs), + (int)sizeof(asm_instrs) / (int)sizeof(ASMInstr), + freq[0], freq[1], freq[2], freq[3]); + } +} + ST_FUNC void asm_opcode(TCCState *s1, int opcode) { const ASMInstr *pa; @@ -515,6 +554,7 @@ ST_FUNC void asm_opcode(TCCState *s1, int opcode) int autosize; int p66; + maybe_print_stats(); /* force synthetic ';' after prefix instruction, so we can handle */ /* one-line things like "rep stosb" instead of only "rep\nstosb" */ if (opcode >= TOK_ASM_wait && opcode <= TOK_ASM_repnz) @@ -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;i<pa->nb_ops;i++) { - for(j=0;j<nb_op_vals;j++) { - if (pa->op_type[i] == op_vals[j]) - goto found; - } - op_vals[nb_op_vals++] = pa->op_type[i]; - found: ; - } - } - for(i=0;i<nb_op_vals;i++) { - int v = op_vals[i]; - if ((v & (v - 1)) != 0) - printf("%3d: %08x\n", i, v); - } - printf("size=%d nb=%d f0=%d f1=%d f2=%d f3=%d\n", - sizeof(asm_instrs), sizeof(asm_instrs) / sizeof(ASMInstr), - freq[0], freq[1], freq[2], freq[3]); - } -#endif - /* XXX: undefine C labels */ ch = file->buf_ptr[0]; |
