History

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.

Michael Matz committed 10 years ago

Commit 4af6e081 parent ed35ac82 files · +40 −32Browse files

Unified · Split

2 files
  1. i386-asm.c +40 −0
  2. tccasm.c +0 −32
i386-asm.c+40−0
@@ -504,6 +504,45 @@ static inline int asm_modrm(int reg, Operand *op) · 503 unmodified lines
504504 return 0;
505505 }
506506
507+static void maybe_print_stats (void)
508+{
509+ static int already = 1;
510+ if (!already)
511+ /* print stats about opcodes */
512+ {
513+ const struct ASMInstr *pa;
514+ int freq[4];
515+ int op_vals[500];
516+ int nb_op_vals, i, j;
517+
518+ already = 1;
519+ nb_op_vals = 0;
520+ memset(freq, 0, sizeof(freq));
521+ for(pa = asm_instrs; pa->sym != 0; pa++) {
522+ freq[pa->nb_ops]++;
523+ //for(i=0;i<pa->nb_ops;i++) {
524+ for(j=0;j<nb_op_vals;j++) {
525+ //if (pa->op_type[i] == op_vals[j])
526+ if (pa->instr_type == op_vals[j])
527+ goto found;
528+ }
529+ //op_vals[nb_op_vals++] = pa->op_type[i];
530+ op_vals[nb_op_vals++] = pa->instr_type;
531+ found: ;
532+ //}
533+ }
534+ for(i=0;i<nb_op_vals;i++) {
535+ int v = op_vals[i];
536+ //if ((v & (v - 1)) != 0)
537+ printf("%3d: %08x\n", i, v);
538+ }
539+ printf("size=%d nb=%d f0=%d f1=%d f2=%d f3=%d\n",
540+ (int)sizeof(asm_instrs),
541+ (int)sizeof(asm_instrs) / (int)sizeof(ASMInstr),
542+ freq[0], freq[1], freq[2], freq[3]);
543+ }
544+}
545+
507546 ST_FUNC void asm_opcode(TCCState *s1, int opcode)
508547 {
509548 const ASMInstr *pa;
@@ -515,6 +554,7 @@ ST_FUNC void asm_opcode(TCCState *s1, int opcode) · 5 unmodified lines
515554 int autosize;
516555 int p66;
517556
557+ maybe_print_stats();
518558 /* force synthetic ';' after prefix instruction, so we can handle */
519559 /* one-line things like "rep stosb" instead of only "rep\nstosb" */
520560 if (opcode >= TOK_ASM_wait && opcode <= TOK_ASM_repnz)
tccasm.c+0−32
@@ -757,38 +757,6 @@ static int tcc_assemble_internal(TCCState *s1, int do_preprocess) · 756 unmodified lines
757757 {
758758 int opcode;
759759
760−#if 0
761− /* print stats about opcodes */
762− {
763− const ASMInstr *pa;
764− int freq[4];
765− int op_vals[500];
766− int nb_op_vals, i, j;
767−
768− nb_op_vals = 0;
769− memset(freq, 0, sizeof(freq));
770− for(pa = asm_instrs; pa->sym != 0; pa++) {
771− freq[pa->nb_ops]++;
772− for(i=0;i<pa->nb_ops;i++) {
773− for(j=0;j<nb_op_vals;j++) {
774− if (pa->op_type[i] == op_vals[j])
775− goto found;
776− }
777− op_vals[nb_op_vals++] = pa->op_type[i];
778− found: ;
779− }
780− }
781− for(i=0;i<nb_op_vals;i++) {
782− int v = op_vals[i];
783− if ((v & (v - 1)) != 0)
784− printf("%3d: %08x\n", i, v);
785− }
786− printf("size=%d nb=%d f0=%d f1=%d f2=%d f3=%d\n",
787− sizeof(asm_instrs), sizeof(asm_instrs) / sizeof(ASMInstr),
788− freq[0], freq[1], freq[2], freq[3]);
789− }
790−#endif
791−
792760 /* XXX: undefine C labels */
793761
794762 ch = file->buf_ptr[0];

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t