From bbbe2d0d380334ba0d471c928b2b8a6de4d84ada Mon Sep 17 00:00:00 2001 From: David Schmenk Date: Fri, 16 Mar 2018 09:57:01 -0700 Subject: [PATCH] opcode statistics --- src/opstat | 82 +++++++++++++++++++++++++++++++++++++++++++ src/toolsrc/codegen.c | 16 ++++----- 2 files changed, 90 insertions(+), 8 deletions(-) create mode 100755 src/opstat diff --git a/src/opstat b/src/opstat new file mode 100755 index 0000000..38ae4bf --- /dev/null +++ b/src/opstat @@ -0,0 +1,82 @@ +echo -n "CN "; grep -c '; CN' $1 +echo -n "MINUS1 "; grep -c '; MINUS' $1 +echo -n "BREQ "; grep -c '; BREQ' $1 +echo -n "BRNE "; grep -c '; BRNE' $1 +echo -n "LA "; grep -c '; LA' $1 +echo -n "LLA "; grep -c '; LLA' $1 +echo -n "CB "; grep -c '; CB' $1 +echo -n "CW "; grep -c '; CW' $1 +echo -n "CS "; grep -c '; CS' $1 +echo -n "DROP "; grep -c '; DROP ' $1 +echo -n "DROP2 "; grep -c '; DROP2' $1 +echo -n "DUP "; grep -c '; DUP' $1 +echo -n "DIVMOD "; grep -c '; DIVMOD' $1 +echo -n "ADDI "; grep -c '; ADDI' $1 +echo -n "SUBI "; grep -c '; SUBI' $1 +echo -n "ANDI "; grep -c '; ANDI' $1 +echo -n "ORI "; grep -c '; ORI' $1 +echo -n "ISEQ "; grep -c '; ISEQ' $1 +echo -n "ISNE "; grep -c '; ISNE' $1 +echo -n "ISGT "; grep -c '; ISGT' $1 +echo -n "ISLT "; grep -c '; ISLT' $1 +echo -n "ISGE "; grep -c '; ISGE' $1 +echo -n "ISLE "; grep -c '; ISLE' $1 +echo -n "BRFLS "; grep -c '; BRFLS' $1 +echo -n "BRTRU "; grep -c '; BRTRU' $1 +echo -n "BRNCH "; grep -c '; BRNCH' $1 +echo -n "SEL "; grep -c '; SEL' $1 +echo -n "CALL "; grep -c '; CALL' $1 +echo -n "ICAL "; grep -c '; ICAL' $1 +echo -n "ENTER "; grep -c '; ENTER' $1 +echo -n "LEAVE "; grep -c '; LEAVE' $1 +echo -n "RET "; grep -c '; RET' $1 +echo -n "CFFB "; grep -c '; CFFB' $1 +echo -n "LB "; grep -c '; LB' $1 +echo -n "LW "; grep -c '; LW' $1 +echo -n "LLB "; grep -c '; LLB' $1 +echo -n "LLW "; grep -c '; LLW' $1 +echo -n "LAB "; grep -c '; LAB' $1 +echo -n "LAW "; grep -c '; LAW' $1 +echo -n "DLB "; grep -c '; DLB' $1 +echo -n "DLW "; grep -c '; DLW' $1 +echo -n "SB "; grep -c '; SB' $1 +echo -n "SW "; grep -c '; SW' $1 +echo -n "SLB "; grep -c '; SLB' $1 +echo -n "SLW "; grep -c '; SLW' $1 +echo -n "SAB "; grep -c '; SAB' $1 +echo -n "SAW "; grep -c '; SAW' $1 +echo -n "DAB "; grep -c '; DAB' $1 +echo -n "DAW "; grep -c '; DAW' $1 +echo -n "NOT "; grep -c '; NOT' $1 +echo -n "ADD "; grep -c '; ADD ' $1 +echo -n "SUB "; grep -c '; SUB ' $1 +echo -n "MUL "; grep -c '; MUL' $1 +echo -n "DIV "; grep -c '; DIV' $1 +echo -n "MOD "; grep -c '; MOD' $1 +echo -n "INCR "; grep -c '; INCR' $1 +echo -n "DECR "; grep -c '; DECR' $1 +echo -n "NEG "; grep -c '; NEG' $1 +echo -n "COMP "; grep -c '; COMP' $1 +echo -n "AND "; grep -c '; AND ' $1 +echo -n "OR "; grep -c '; OR' $1 +echo -n "XOR "; grep -c '; XOR' $1 +echo -n "SHL "; grep -c '; SHL' $1 +echo -n "SHR "; grep -c '; SHR' $1 +echo -n "IDXW "; grep -c '; IDXW' $1 +echo -n "BRGT "; grep -c '; BRGT' $1 +echo -n "BRLT "; grep -c '; BRLT' $1 +echo -n "INCBRLE "; grep -c '; INCBRLE' $1 +echo -n "ADDBRLE "; grep -c '; ADDBRLE' $1 +echo -n "DECBRGE "; grep -c '; DECBRGE' $1 +echo -n "SUBBRGE "; grep -c '; SUBBRGE' $1 +echo -n "BRAND "; grep -c '; BRAND' $1 +echo -n "BROR "; grep -c '; BROR' $1 +echo -n "ADDLB "; grep -c '; ADDLB' $1 +echo -n "ADDLW "; grep -c '; ADDLW' $1 +echo -n "ADDAB "; grep -c '; ADDAB' $1 +echo -n "ADDAW "; grep -c '; ADDAW' $1 +echo -n "IDXLB "; grep -c '; IDXLB' $1 +echo -n "IDXLW "; grep -c '; IDXLW' $1 +echo -n "IDXAB "; grep -c '; IDXAB' $1 +echo -n "IDXAW "; grep -c '; IDXAW' $1 + diff --git a/src/toolsrc/codegen.c b/src/toolsrc/codegen.c index 7c24b4e..9e2f6a5 100755 --- a/src/toolsrc/codegen.c +++ b/src/toolsrc/codegen.c @@ -926,7 +926,7 @@ void emit_incbrle(int tag) void emit_addbrle(int tag) { emit_pending_seq(); - printf("\t%s\t$A6\t\t\t; BRLE\t_B%03d\n", DB, tag); + printf("\t%s\t$A6\t\t\t; ADDBRLE\t_B%03d\n", DB, tag); printf("\t%s\t_B%03d-*\n", DW, tag); } void emit_decbrge(int tag) @@ -938,7 +938,7 @@ void emit_decbrge(int tag) void emit_subbrge(int tag) { emit_pending_seq(); - printf("\t%s\t$AA\t\t\t; BRGE\t_B%03d\n", DB, tag); + printf("\t%s\t$AA\t\t\t; SUBBRGE\t_B%03d\n", DB, tag); printf("\t%s\t_B%03d-*\n", DW, tag); } void emit_call(int tag, int type) @@ -987,12 +987,12 @@ void emit_start(void) void emit_drop(void) { emit_pending_seq(); - printf("\t%s\t$30\t\t\t; DROP\n", DB); + printf("\t%s\t$30\t\t\t; DROP \n", DB); } void emit_drop2(void) { emit_pending_seq(); - printf("\t%s\t$32\t\t\t; DUP\n", DB); + printf("\t%s\t$32\t\t\t; DROP2\n", DB); } void emit_dup(void) { @@ -1046,10 +1046,10 @@ int emit_op(t_token op) printf("\t%s\t$8A\t\t\t; MOD\n", DB); break; case ADD_TOKEN: - printf("\t%s\t$82\t\t\t; ADD\n", DB); + printf("\t%s\t$82\t\t\t; ADD \n", DB); break; case SUB_TOKEN: - printf("\t%s\t$84\t\t\t; SUB\n", DB); + printf("\t%s\t$84\t\t\t; SUB \n", DB); break; case SHL_TOKEN: printf("\t%s\t$9A\t\t\t; SHL\n", DB); @@ -1058,10 +1058,10 @@ int emit_op(t_token op) printf("\t%s\t$9C\t\t\t; SHR\n", DB); break; case AND_TOKEN: - printf("\t%s\t$94\t\t\t; AND\n", DB); + printf("\t%s\t$94\t\t\t; AND \n", DB); break; case OR_TOKEN: - printf("\t%s\t$96\t\t\t; IOR\n", DB); + printf("\t%s\t$96\t\t\t; OR \n", DB); break; case EOR_TOKEN: printf("\t%s\t$98\t\t\t; XOR\n", DB);