Verified Commit 421da3d2 authored by Camil Staps's avatar Camil Staps 🚀

Add specialized instructions eq{Cc,Ii}, jmp_{eq,ne}{Cc,Ii}, put_{a,b}_jmp, and push_b_decI

These are frequent pairs of instructions in the Ligretto and Trax
examples in iTasks.
parent ae74f5d3
Pipeline #22561 passed with stages
in 14 minutes and 8 seconds
...@@ -62,23 +62,29 @@ from StdFile import class <<< ...@@ -62,23 +62,29 @@ from StdFile import class <<<
| Idup2_a !Int | Idup2_a !Int
| Idup3_a !Int | Idup3_a !Int
| Idup_a !Int | Idup_a !Int
| IeqCc !Char
| IeqIi !Int
| Iexchange_a !Int !Int | Iexchange_a !Int !Int
| Ifill_a01_pop_rtn | Ifill_a01_pop_rtn
| Ijmp_b_false !Int !String | Ijmp_b_false !Int !String
| Ijmp_eqACio !StringLiteral !Int !String | Ijmp_eqACio !StringLiteral !Int !String
| Ijmp_eqC_b !Char !Int !String | Ijmp_eqC_b !Char !Int !String
| Ijmp_eqC_b2 !Char !Char !Int !String !String | Ijmp_eqC_b2 !Char !Char !Int !String !String
| Ijmp_eqCc !Char !String
| Ijmp_eqD_b !String !Int !String | Ijmp_eqD_b !String !Int !String
| Ijmp_eqD_b2 !String !Int !String !String !Int !String | Ijmp_eqD_b2 !String !Int !String !String !Int !String
| Ijmp_eqI !String | Ijmp_eqI !String
| Ijmp_eqI_b !Int !Int !String | Ijmp_eqI_b !Int !Int !String
| Ijmp_eqI_b2 !Int !Int !Int !String !String | Ijmp_eqI_b2 !Int !Int !Int !String !String
| Ijmp_eqIi !Int !String
| Ijmp_eq_desc !String !Int !Int !String | Ijmp_eq_desc !String !Int !Int !String
| Ijmp_geI !String | Ijmp_geI !String
| Ijmp_ltI !String | Ijmp_ltI !String
| Ijmp_neC_b !Char !Int !String | Ijmp_neC_b !Char !Int !String
| Ijmp_neCc !Char !String
| Ijmp_neI !String | Ijmp_neI !String
| Ijmp_neI_b !Int !Int !String | Ijmp_neI_b !Int !Int !String
| Ijmp_neIi !Int !String
| Ijmp_ne_desc !String !Int !Int !String | Ijmp_ne_desc !String !Int !Int !String
| Ijmp_o_geI !Int !String | Ijmp_o_geI !Int !String
| Ijmp_o_geI_arraysize_a !String !Int !Int !String | Ijmp_o_geI_arraysize_a !String !Int !Int !String
...@@ -103,12 +109,15 @@ from StdFile import class <<< ...@@ -103,12 +109,15 @@ from StdFile import class <<<
| Ipush_ab !Int !Int | Ipush_ab !Int !Int
| Ipush_arraysize_a !String !Int !Int !Int | Ipush_arraysize_a !String !Int !Int !Int
| Ipush_b2 !Int !Int | Ipush_b2 !Int !Int
| Ipush_b_decI !Int
| Ipush_b_incI !Int | Ipush_b_incI !Int
| Ipush_b_jsr !Int !String | Ipush_b_jsr !Int !String
| Ipush_jsr_eval !Int | Ipush_jsr_eval !Int
| Ipush_update_a !Int !Int | Ipush_update_a !Int !Int
| Iput_a !Int | Iput_a !Int
| Iput_a_jmp !Int !String
| Iput_b !Int | Iput_b !Int
| Iput_b_jmp !Int !String
| Irepl_arg !Int !Int | Irepl_arg !Int !Int
| Iselectoo !String !Int !Int !Int !Int | Iselectoo !String !Int !Int !Int !Int
| Iswap_a !Int | Iswap_a !Int
......
...@@ -115,10 +115,12 @@ opt_abc1 [IIns "notB",Ijmp_true id:is] = opt_abc1 [Ijmp_false id:is] ...@@ -115,10 +115,12 @@ opt_abc1 [IIns "notB",Ijmp_true id:is] = opt_abc1 [Ijmp_false id:is]
opt_abc1 [IpushC c,Ipush_b 0,IIns "eqC":is] = opt_abc1 [IpushB True:is] opt_abc1 [IpushC c,Ipush_b 0,IIns "eqC":is] = opt_abc1 [IpushB True:is]
opt_abc1 [IpushC c,Ipush_b n,IIns "eqC":is] = [IeqC_b c (n-1):opt_abc1 is] opt_abc1 [IpushC c,Ipush_b n,IIns "eqC":is] = [IeqC_b c (n-1):opt_abc1 is]
opt_abc1 [Ipush_b n,IpushC c,IIns "eqC":is] = [IeqC_b c n :opt_abc1 is] opt_abc1 [Ipush_b n,IpushC c,IIns "eqC":is] = [IeqC_b c n :opt_abc1 is]
opt_abc1 [IpushC c, IIns "eqC":is] = [IeqCc c :opt_abc1 is]
opt_abc1 [IpushI c,Ipush_b 0,IIns "eqI":is] = opt_abc1 [IpushB True:is] opt_abc1 [IpushI c,Ipush_b 0,IIns "eqI":is] = opt_abc1 [IpushB True:is]
opt_abc1 [IpushI c,Ipush_b n,IIns "eqI":is] = [IeqI_b c (n-1):opt_abc1 is] opt_abc1 [IpushI c,Ipush_b n,IIns "eqI":is] = [IeqI_b c (n-1):opt_abc1 is]
opt_abc1 [Ipush_b n,IpushI c,IIns "eqI":is] = [IeqI_b c n :opt_abc1 is] opt_abc1 [Ipush_b n,IpushI c,IIns "eqI":is] = [IeqI_b c n :opt_abc1 is]
opt_abc1 [IpushI c, IIns "eqI":is] = [IeqIi c :opt_abc1 is]
opt_abc1 [Ipush_b 1,Iupdate_b 1 2,Iupdatepop_b 0 1,i:is] opt_abc1 [Ipush_b 1,Iupdate_b 1 2,Iupdatepop_b 0 1,i:is]
| isCommutativeBStackInstruction i = opt_abc1 [i:is] | isCommutativeBStackInstruction i = opt_abc1 [i:is]
...@@ -227,6 +229,11 @@ opt_abc_new [IeqC_b c n,Ijmp_false l:is] = [Ijmp_neC_b c n l:opt_abc_new is] ...@@ -227,6 +229,11 @@ opt_abc_new [IeqC_b c n,Ijmp_false l:is] = [Ijmp_neC_b c n l:opt_abc_new is]
opt_abc_new [IeqI_b i n,Ijmp_true l:is] = [Ijmp_eqI_b i n l:opt_abc_new is] opt_abc_new [IeqI_b i n,Ijmp_true l:is] = [Ijmp_eqI_b i n l:opt_abc_new is]
opt_abc_new [IeqI_b i n,Ijmp_false l:is] = [Ijmp_neI_b i n l:opt_abc_new is] opt_abc_new [IeqI_b i n,Ijmp_false l:is] = [Ijmp_neI_b i n l:opt_abc_new is]
opt_abc_new [IeqIi c,Ijmp_true l:is] = [Ijmp_eqIi c l:opt_abc_new is]
opt_abc_new [IeqIi c,Ijmp_false l:is] = [Ijmp_neIi c l:opt_abc_new is]
opt_abc_new [IeqCc c,Ijmp_true l:is] = [Ijmp_eqCc c l:opt_abc_new is]
opt_abc_new [IeqCc c,Ijmp_false l:is] = [Ijmp_neCc c l:opt_abc_new is]
opt_abc_new [Ipush_b n,IpushI i,IIns "and%":is] = [IandIio i n:opt_abc_new is] opt_abc_new [Ipush_b n,IpushI i,IIns "and%":is] = [IandIio i n:opt_abc_new is]
opt_abc_new [IpushI i,IIns "and%":is] = [IandIi i:opt_abc_new is] opt_abc_new [IpushI i,IIns "and%":is] = [IandIi i:opt_abc_new is]
opt_abc_new [IpushI i,Ipush_b n,IIns "and%":is] | n > 0 = [IandIio i (n-1):opt_abc_new is] opt_abc_new [IpushI i,Ipush_b n,IIns "and%":is] | n > 0 = [IandIio i (n-1):opt_abc_new is]
...@@ -263,11 +270,20 @@ opt_abc_new2 [Iupdate_a 0 d0,Iupdate_a 0 d1,Iupdate_a 0 d2:is] ...@@ -263,11 +270,20 @@ opt_abc_new2 [Iupdate_a 0 d0,Iupdate_a 0 d1,Iupdate_a 0 d2:is]
opt_abc_new2 [Iupdate_a 0 d0,Iupdate_a 0 d1:is] opt_abc_new2 [Iupdate_a 0 d0,Iupdate_a 0 d1:is]
| d0==d1+1 = [Idup2_a d1:opt_abc_new2 is] | d0==d1+1 = [Idup2_a d1:opt_abc_new2 is]
opt_abc_new2 [Iupdate_a 0 d0,Ipop_a 1:is] = [Iput_a d0:opt_abc_new2 is] opt_abc_new2 [Iupdate_a 0 d0,Ipop_a 1:is] = case is of
opt_abc_new2 [Iupdate_a 0 d0:is] = [Idup_a d0:opt_abc_new2 is] [a=:(Annotation _),Ijmp l:is] -> [a,Iput_a_jmp d0 l:opt_abc_new2 is]
opt_abc_new2 [Iupdate_b 0 d0,Ipop_b 1:is] = [Iput_b d0:opt_abc_new2 is] _ -> [ Iput_a d0 :opt_abc_new2 is]
opt_abc_new2 [Iupdatepop_a 0 1:is] = [Iput_a 1:opt_abc_new2 is] opt_abc_new2 [Iupdate_b 0 d0,Ipop_b 1:is] = case is of
opt_abc_new2 [Iupdatepop_b 0 1:is] = [Iput_b 1:opt_abc_new2 is] [a=:(Annotation _),Ijmp l:is] -> [a,Iput_b_jmp d0 l:opt_abc_new2 is]
_ -> [ Iput_b d0 :opt_abc_new2 is]
opt_abc_new2 [Iupdatepop_a 0 1:is] = case is of
[a=:(Annotation _),Ijmp l:is] -> [a,Iput_a_jmp 1 l:opt_abc_new2 is]
_ -> [ Iput_a 1 :opt_abc_new2 is]
opt_abc_new2 [Iupdatepop_b 0 1:is] = case is of
[a=:(Annotation _),Ijmp l:is] -> [a,Iput_b_jmp 1 l:opt_abc_new2 is]
_ -> [ Iput_b 1 :opt_abc_new2 is]
opt_abc_new2 [Iupdate_a 0 d0:is] = [Idup_a d0:opt_abc_new2 is]
opt_abc_new2 [Ipush_a d0,Ijsr_eval 0:is] = [Ipush_jsr_eval d0:opt_abc_new2 is] opt_abc_new2 [Ipush_a d0,Ijsr_eval 0:is] = [Ipush_jsr_eval d0:opt_abc_new2 is]
opt_abc_new2 [Ipush_a s0,Ipush_a s1:is] opt_abc_new2 [Ipush_a s0,Ipush_a s1:is]
| s0==s1 && s0>0 = [Ipush2_a s0:opt_abc_new2 is] | s0==s1 && s0>0 = [Ipush2_a s0:opt_abc_new2 is]
...@@ -325,6 +341,7 @@ opt_abc_new2 [Ipush_b s0,Ipush_b s1:is] ...@@ -325,6 +341,7 @@ opt_abc_new2 [Ipush_b s0,Ipush_b s1:is]
opt_abc_new2 [Ipush_b sb,Ipush_a sa,Iselect d i0 i1:is] = [Iselectoo d i0 i1 sa sb:opt_abc_new2 is] opt_abc_new2 [Ipush_b sb,Ipush_a sa,Iselect d i0 i1:is] = [Iselectoo d i0 i1 sa sb:opt_abc_new2 is]
opt_abc_new2 [Ipush_b sb,Ipush_a sa:is] = [Ipush_ab sa sb:opt_abc_new2 is] opt_abc_new2 [Ipush_b sb,Ipush_a sa:is] = [Ipush_ab sa sb:opt_abc_new2 is]
opt_abc_new2 [Ipush_b n,Ijmp_false l:is] = [Ijmp_b_false n l:opt_abc_new2 is] opt_abc_new2 [Ipush_b n,Ijmp_false l:is] = [Ijmp_b_false n l:opt_abc_new2 is]
opt_abc_new2 [Ipush_b n,IIns "decI":is] = [Ipush_b_decI n:opt_abc_new2 is]
opt_abc_new2 [Ipush_b n,IIns "incI":is] = [Ipush_b_incI n:opt_abc_new2 is] opt_abc_new2 [Ipush_b n,IIns "incI":is] = [Ipush_b_incI n:opt_abc_new2 is]
opt_abc_new2 [Ipush_b n,IIns "ltI",Ijmp_false l:is] = [Ijmp_o_geI n l:opt_abc_new2 is] opt_abc_new2 [Ipush_b n,IIns "ltI",Ijmp_false l:is] = [Ijmp_o_geI n l:opt_abc_new2 is]
opt_abc_new2 [Ipush_b n,annot=:Annotation (Ad _ _ _),Ijsr l:is] = [annot,Ipush_b_jsr n l:opt_abc_new2 is] opt_abc_new2 [Ipush_b n,annot=:Annotation (Ad _ _ _),Ijsr l:is] = [annot,Ipush_b_jsr n l:opt_abc_new2 is]
......
...@@ -174,10 +174,12 @@ const char *instruction_type (BC_WORD i) { ...@@ -174,10 +174,12 @@ const char *instruction_type (BC_WORD i) {
case CeqC: return ""; case CeqC: return "";
case CeqC_a: return "nc"; case CeqC_a: return "nc";
case CeqC_b: return "nc"; case CeqC_b: return "nc";
case CeqCc: return "c";
case CeqD_b: return "l"; case CeqD_b: return "l";
case CeqI: return ""; case CeqI: return "";
case CeqI_a: return "ni"; case CeqI_a: return "ni";
case CeqI_b: return "ni"; case CeqI_b: return "ni";
case CeqIi: return "i";
case CeqR: return ""; case CeqR: return "";
case CeqR_b: return "nr"; case CeqR_b: return "nr";
case Ceq_desc: return "nl"; case Ceq_desc: return "nl";
...@@ -695,17 +697,21 @@ const char *instruction_type (BC_WORD i) { ...@@ -695,17 +697,21 @@ const char *instruction_type (BC_WORD i) {
case Cjmp_eqACio: return "nsl"; case Cjmp_eqACio: return "nsl";
case Cjmp_eqC_b: return "ncl"; case Cjmp_eqC_b: return "ncl";
case Cjmp_eqC_b2: return "nclcl"; case Cjmp_eqC_b2: return "nclcl";
case Cjmp_eqCc: return "cl";
case Cjmp_eqD_b: return "ll"; case Cjmp_eqD_b: return "ll";
case Cjmp_eqD_b2: return "llll"; case Cjmp_eqD_b2: return "llll";
case Cjmp_eqI: return "l"; case Cjmp_eqI: return "l";
case Cjmp_eqI_b: return "nil"; case Cjmp_eqI_b: return "nil";
case Cjmp_eqI_b2: return "nilil"; case Cjmp_eqI_b2: return "nilil";
case Cjmp_eqIi: return "il";
case Cjmp_eq_desc: return "nll"; case Cjmp_eq_desc: return "nll";
case Cjmp_geI: return "l"; case Cjmp_geI: return "l";
case Cjmp_ltI: return "l"; case Cjmp_ltI: return "l";
case Cjmp_neC_b: return "ncl"; case Cjmp_neC_b: return "ncl";
case Cjmp_neCc: return "cl";
case Cjmp_neI: return "l"; case Cjmp_neI: return "l";
case Cjmp_neI_b: return "nil"; case Cjmp_neI_b: return "nil";
case Cjmp_neIi: return "il";
case Cjmp_ne_desc: return "nll"; case Cjmp_ne_desc: return "nll";
case Cjmp_o_geI: return "nl"; case Cjmp_o_geI: return "nl";
case Cjmp_o_geI_arraysize_a: return "nnl"; case Cjmp_o_geI_arraysize_a: return "nnl";
...@@ -722,6 +728,7 @@ const char *instruction_type (BC_WORD i) { ...@@ -722,6 +728,7 @@ const char *instruction_type (BC_WORD i) {
case Cpop_b_rtn: return "N"; case Cpop_b_rtn: return "N";
case CpushD_a_jmp_eqD_b2: return "nllll"; case CpushD_a_jmp_eqD_b2: return "nllll";
case Cpush_a_jsr: return "nl"; case Cpush_a_jsr: return "nl";
case Cpush_b_decI: return "n";
case Cpush_b_incI: return "n"; case Cpush_b_incI: return "n";
case Cpush_b_jsr: return "nl"; case Cpush_b_jsr: return "nl";
case Cpush_arraysize_a: return "n"; case Cpush_arraysize_a: return "n";
...@@ -735,7 +742,9 @@ const char *instruction_type (BC_WORD i) { ...@@ -735,7 +742,9 @@ const char *instruction_type (BC_WORD i) {
case Cpush3_b: return "n"; case Cpush3_b: return "n";
case Cpush_update_a: return "nn"; case Cpush_update_a: return "nn";
case Cput_a: return "n"; case Cput_a: return "n";
case Cput_a_jmp: return "nl";
case Cput_b: return "n"; case Cput_b: return "n";
case Cput_b_jmp: return "nl";
case CselectBOOLoo: return "nn"; case CselectBOOLoo: return "nn";
case CselectCHARoo: return "nn"; case CselectCHARoo: return "nn";
case CselectINToo: return "nn"; case CselectINToo: return "nn";
......
...@@ -160,6 +160,7 @@ enum { ...@@ -160,6 +160,7 @@ enum {
INSTRUCTION(eqC) INSTRUCTION(eqC)
INSTRUCTION(eqC_a) INSTRUCTION(eqC_a)
INSTRUCTION(eqC_b) INSTRUCTION(eqC_b)
INSTRUCTION(eqCc)
INSTRUCTION(eqD_b) INSTRUCTION(eqD_b)
INSTRUCTION(eq_desc) INSTRUCTION(eq_desc)
INSTRUCTION(eq_desc_b) INSTRUCTION(eq_desc_b)
...@@ -167,6 +168,7 @@ enum { ...@@ -167,6 +168,7 @@ enum {
INSTRUCTION(eqI) INSTRUCTION(eqI)
INSTRUCTION(eqI_a) INSTRUCTION(eqI_a)
INSTRUCTION(eqI_b) INSTRUCTION(eqI_b)
INSTRUCTION(eqIi)
INSTRUCTION(eqR) INSTRUCTION(eqR)
INSTRUCTION(eqR_b) INSTRUCTION(eqR_b)
INSTRUCTION(expR) INSTRUCTION(expR)
...@@ -682,17 +684,21 @@ enum { ...@@ -682,17 +684,21 @@ enum {
INSTRUCTION(jmp_eqACio) INSTRUCTION(jmp_eqACio)
INSTRUCTION(jmp_eqC_b) INSTRUCTION(jmp_eqC_b)
INSTRUCTION(jmp_eqC_b2) INSTRUCTION(jmp_eqC_b2)
INSTRUCTION(jmp_eqCc)
INSTRUCTION(jmp_eqD_b) INSTRUCTION(jmp_eqD_b)
INSTRUCTION(jmp_eqD_b2) INSTRUCTION(jmp_eqD_b2)
INSTRUCTION(jmp_eqI) INSTRUCTION(jmp_eqI)
INSTRUCTION(jmp_eqI_b) INSTRUCTION(jmp_eqI_b)
INSTRUCTION(jmp_eqI_b2) INSTRUCTION(jmp_eqI_b2)
INSTRUCTION(jmp_eqIi)
INSTRUCTION(jmp_eq_desc) INSTRUCTION(jmp_eq_desc)
INSTRUCTION(jmp_geI) INSTRUCTION(jmp_geI)
INSTRUCTION(jmp_ltI) INSTRUCTION(jmp_ltI)
INSTRUCTION(jmp_neC_b) INSTRUCTION(jmp_neC_b)
INSTRUCTION(jmp_neCc)
INSTRUCTION(jmp_neI) INSTRUCTION(jmp_neI)
INSTRUCTION(jmp_neI_b) INSTRUCTION(jmp_neI_b)
INSTRUCTION(jmp_neIi)
INSTRUCTION(jmp_ne_desc) INSTRUCTION(jmp_ne_desc)
INSTRUCTION(jmp_o_geI) INSTRUCTION(jmp_o_geI)
INSTRUCTION(jmp_o_geI_arraysize_a) INSTRUCTION(jmp_o_geI_arraysize_a)
...@@ -710,6 +716,7 @@ enum { ...@@ -710,6 +716,7 @@ enum {
INSTRUCTION(pop_b_rtn) INSTRUCTION(pop_b_rtn)
INSTRUCTION(pushD_a_jmp_eqD_b2) INSTRUCTION(pushD_a_jmp_eqD_b2)
INSTRUCTION(push_a_jsr) INSTRUCTION(push_a_jsr)
INSTRUCTION(push_b_decI)
INSTRUCTION(push_b_incI) INSTRUCTION(push_b_incI)
INSTRUCTION(push_b_jsr) INSTRUCTION(push_b_jsr)
INSTRUCTION(push_arraysize_a) INSTRUCTION(push_arraysize_a)
...@@ -723,7 +730,9 @@ enum { ...@@ -723,7 +730,9 @@ enum {
INSTRUCTION(push3_b) INSTRUCTION(push3_b)
INSTRUCTION(push_update_a) INSTRUCTION(push_update_a)
INSTRUCTION(put_a) INSTRUCTION(put_a)
INSTRUCTION(put_a_jmp)
INSTRUCTION(put_b) INSTRUCTION(put_b)
INSTRUCTION(put_b_jmp)
INSTRUCTION(selectBOOLoo) INSTRUCTION(selectBOOLoo)
INSTRUCTION(selectCHARoo) INSTRUCTION(selectCHARoo)
INSTRUCTION(selectINToo) INSTRUCTION(selectINToo)
......
...@@ -104,9 +104,11 @@ void load_instruction_table(void) { ...@@ -104,9 +104,11 @@ void load_instruction_table(void) {
put_instruction_name("eqC", parse_instruction, code_eqC ); put_instruction_name("eqC", parse_instruction, code_eqC );
put_instruction_name("eqC_a", parse_instruction_c_n, code_eqC_a ); put_instruction_name("eqC_a", parse_instruction_c_n, code_eqC_a );
put_instruction_name("eqC_b", parse_instruction_c_n, code_eqC_b ); put_instruction_name("eqC_b", parse_instruction_c_n, code_eqC_b );
put_instruction_name("eqCc", parse_instruction_c, code_eqCc );
put_instruction_name("eqI", parse_instruction, code_eqI ); put_instruction_name("eqI", parse_instruction, code_eqI );
put_instruction_name("eqI_a", parse_instruction_i_n, code_eqI_a ); put_instruction_name("eqI_a", parse_instruction_i_n, code_eqI_a );
put_instruction_name("eqI_b", parse_instruction_i_n, code_eqI_b ); put_instruction_name("eqI_b", parse_instruction_i_n, code_eqI_b );
put_instruction_name("eqIi", parse_instruction_i, code_eqIi );
put_instruction_name("eqR", parse_instruction, code_eqR ); put_instruction_name("eqR", parse_instruction, code_eqR );
put_instruction_name("eqR_b", parse_instruction_r_n, code_eqR_b ); put_instruction_name("eqR_b", parse_instruction_r_n, code_eqR_b );
put_instruction_name("eq_desc", parse_instruction_a_n_n, code_eq_desc ); put_instruction_name("eq_desc", parse_instruction_a_n_n, code_eq_desc );
...@@ -276,17 +278,21 @@ void load_instruction_table(void) { ...@@ -276,17 +278,21 @@ void load_instruction_table(void) {
put_instruction_name("jmp_eqACio", parse_instruction_s2_n_a, code_jmp_eqACio ); put_instruction_name("jmp_eqACio", parse_instruction_s2_n_a, code_jmp_eqACio );
put_instruction_name("jmp_eqC_b", parse_instruction_c_n_a, code_jmp_eqC_b ); put_instruction_name("jmp_eqC_b", parse_instruction_c_n_a, code_jmp_eqC_b );
put_instruction_name("jmp_eqC_b2", parse_instruction_c_c_n_a_a, code_jmp_eqC_b2 ); put_instruction_name("jmp_eqC_b2", parse_instruction_c_c_n_a_a, code_jmp_eqC_b2 );
put_instruction_name("jmp_eqCc", parse_instruction_c_a, code_jmp_eqCc );
put_instruction_name("jmp_eqD_b", parse_instruction_a_n_a, code_jmp_eqD_b ); put_instruction_name("jmp_eqD_b", parse_instruction_a_n_a, code_jmp_eqD_b );
put_instruction_name("jmp_eqD_b2", parse_instruction_a_n_a_a_n_a, code_jmp_eqD_b2 ); put_instruction_name("jmp_eqD_b2", parse_instruction_a_n_a_a_n_a, code_jmp_eqD_b2 );
put_instruction_name("jmp_eqI", parse_instruction_a, code_jmp_eqI ); put_instruction_name("jmp_eqI", parse_instruction_a, code_jmp_eqI );
put_instruction_name("jmp_eqI_b", parse_instruction_i_n_a, code_jmp_eqI_b ); put_instruction_name("jmp_eqI_b", parse_instruction_i_n_a, code_jmp_eqI_b );
put_instruction_name("jmp_eqI_b2", parse_instruction_i_i_n_a_a, code_jmp_eqI_b2 ); put_instruction_name("jmp_eqI_b2", parse_instruction_i_i_n_a_a, code_jmp_eqI_b2 );
put_instruction_name("jmp_eqIi", parse_instruction_i_a, code_jmp_eqIi );
put_instruction_name("jmp_eq_desc", parse_instruction_a_n_n_a, code_jmp_eq_desc ); put_instruction_name("jmp_eq_desc", parse_instruction_a_n_n_a, code_jmp_eq_desc );
put_instruction_name("jmp_geI", parse_instruction_a, code_jmp_geI ); put_instruction_name("jmp_geI", parse_instruction_a, code_jmp_geI );
put_instruction_name("jmp_ltI", parse_instruction_a, code_jmp_ltI ); put_instruction_name("jmp_ltI", parse_instruction_a, code_jmp_ltI );
put_instruction_name("jmp_neC_b", parse_instruction_c_n_a, code_jmp_neC_b ); put_instruction_name("jmp_neC_b", parse_instruction_c_n_a, code_jmp_neC_b );
put_instruction_name("jmp_neCc", parse_instruction_c_a, code_jmp_neCc );
put_instruction_name("jmp_neI", parse_instruction_a, code_jmp_neI ); put_instruction_name("jmp_neI", parse_instruction_a, code_jmp_neI );
put_instruction_name("jmp_neI_b", parse_instruction_i_n_a, code_jmp_neI_b ); put_instruction_name("jmp_neI_b", parse_instruction_i_n_a, code_jmp_neI_b );
put_instruction_name("jmp_neIi", parse_instruction_i_a, code_jmp_neIi );
put_instruction_name("jmp_ne_desc", parse_instruction_a_n_n_a, code_jmp_ne_desc ); put_instruction_name("jmp_ne_desc", parse_instruction_a_n_n_a, code_jmp_ne_desc );
put_instruction_name("jmp_o_geI", parse_instruction_n_a, code_jmp_o_geI ); put_instruction_name("jmp_o_geI", parse_instruction_n_a, code_jmp_o_geI );
put_instruction_name("jmp_o_geI_arraysize_a", parse_instruction_a_n_n_a, code_jmp_o_geI_arraysize_a ); put_instruction_name("jmp_o_geI_arraysize_a", parse_instruction_a_n_n_a, code_jmp_o_geI_arraysize_a );
...@@ -306,6 +312,7 @@ void load_instruction_table(void) { ...@@ -306,6 +312,7 @@ void load_instruction_table(void) {
put_instruction_name("pushD_a_jmp_eqD_b2", parse_instruction_n_a_n_a_a_n_a, code_pushD_a_jmp_eqD_b2 ); put_instruction_name("pushD_a_jmp_eqD_b2", parse_instruction_n_a_n_a_a_n_a, code_pushD_a_jmp_eqD_b2 );
put_instruction_name("push_a_jsr", parse_instruction_n_a, code_push_a_jsr ); put_instruction_name("push_a_jsr", parse_instruction_n_a, code_push_a_jsr );
put_instruction_name("push_arraysize_a", parse_instruction_a_n_n_n, code_push_arraysize_a ); put_instruction_name("push_arraysize_a", parse_instruction_a_n_n_n, code_push_arraysize_a );
put_instruction_name("push_b_decI", parse_instruction_n, code_push_b_decI );
put_instruction_name("push_b_incI", parse_instruction_n, code_push_b_incI ); put_instruction_name("push_b_incI", parse_instruction_n, code_push_b_incI );
put_instruction_name("push_b_jsr", parse_instruction_n_a, code_push_b_jsr ); put_instruction_name("push_b_jsr", parse_instruction_n_a, code_push_b_jsr );
put_instruction_name("push_jsr_eval", parse_instruction_n, code_push_jsr_eval ); put_instruction_name("push_jsr_eval", parse_instruction_n, code_push_jsr_eval );
...@@ -318,7 +325,9 @@ void load_instruction_table(void) { ...@@ -318,7 +325,9 @@ void load_instruction_table(void) {
put_instruction_name("push3_b", parse_instruction_n, code_push3_b ); put_instruction_name("push3_b", parse_instruction_n, code_push3_b );
put_instruction_name("push_update_a", parse_instruction_n_n, code_push_update_a ); put_instruction_name("push_update_a", parse_instruction_n_n, code_push_update_a );
put_instruction_name("put_a", parse_instruction_n, code_put_a ); put_instruction_name("put_a", parse_instruction_n, code_put_a );
put_instruction_name("put_a_jmp", parse_instruction_n_a, code_put_a_jmp );
put_instruction_name("put_b", parse_instruction_n, code_put_b ); put_instruction_name("put_b", parse_instruction_n, code_put_b );
put_instruction_name("put_b_jmp", parse_instruction_n_a, code_put_b_jmp );
put_instruction_name("selectoo", parse_instruction_a_n_n_n_n, code_selectoo ); put_instruction_name("selectoo", parse_instruction_a_n_n_n_n, code_selectoo );
put_instruction_name("update2_a", parse_instruction_n_n, code_update2_a ); put_instruction_name("update2_a", parse_instruction_n_n, code_update2_a );
put_instruction_name("update2_b", parse_instruction_n_n, code_update2_b ); put_instruction_name("update2_b", parse_instruction_n_n, code_update2_b );
......
...@@ -421,6 +421,15 @@ void add_instruction_c(int16_t i,char n) { ...@@ -421,6 +421,15 @@ void add_instruction_c(int16_t i,char n) {
store_code_elem(1, n); store_code_elem(1, n);
} }
void add_instruction_c_label(int16_t i,char n,char *label_name) {
if (list_code || i>max_implemented_instruction_n)
printf("%d\t%s %d %s\n",pgrm.code_size,instruction_name (i),(int)n,label_name);
store_code_elem(BYTEWIDTH_INSTRUCTION, i);
store_code_elem(1, n);
store_code_label_value(label_name,0);
}
void add_instruction_w(int16_t i,int32_t n) { void add_instruction_w(int16_t i,int32_t n) {
if (list_code || i>max_implemented_instruction_n) if (list_code || i>max_implemented_instruction_n)
printf("%d\t%s %d\n",pgrm.code_size,instruction_name (i),(int)n); printf("%d\t%s %d\n",pgrm.code_size,instruction_name (i),(int)n);
...@@ -550,6 +559,15 @@ void add_instruction_i_w(int16_t i,int64_t n1,int32_t n2) { ...@@ -550,6 +559,15 @@ void add_instruction_i_w(int16_t i,int64_t n1,int32_t n2) {
store_code_elem(2, n2); store_code_elem(2, n2);
} }
void add_instruction_i_label(int16_t i,int64_t n,char *label_name) {
if (list_code || i>max_implemented_instruction_n)
printf("%d\t%s %d %s\n",pgrm.code_size,instruction_name (i),(int)n,label_name);
store_code_elem(BYTEWIDTH_INSTRUCTION, i);
store_code_elem(8, n);
store_code_label_value(label_name,0);
}
void add_instruction_w_c_label(int16_t i,int32_t n1,char n2,char *label_name) { void add_instruction_w_c_label(int16_t i,int32_t n1,char n2,char *label_name) {
if (list_code || i>max_implemented_instruction_n) if (list_code || i>max_implemented_instruction_n)
printf("%d\t%s %d %d %s\n",pgrm.code_size,instruction_name (i),(int)n1,(int)n2,label_name); printf("%d\t%s %d %d %s\n",pgrm.code_size,instruction_name (i),(int)n1,(int)n2,label_name);
...@@ -1500,6 +1518,10 @@ void code_eqC_b(int value,int b_offset) { ...@@ -1500,6 +1518,10 @@ void code_eqC_b(int value,int b_offset) {
add_instruction_w_c(CeqC_b,b_offset,value); add_instruction_w_c(CeqC_b,b_offset,value);
} }
void code_eqCc(int value) {
add_instruction_c(CeqCc,value);
}
void code_eqD_b(char descriptor_name[],int arity) { void code_eqD_b(char descriptor_name[],int arity) {
add_instruction_label_offset(CeqD_b,descriptor_name,(arity<<3)+2); add_instruction_label_offset(CeqD_b,descriptor_name,(arity<<3)+2);
} }
...@@ -1516,6 +1538,10 @@ void code_eqI_a(CleanInt value,int a_offset) { ...@@ -1516,6 +1538,10 @@ void code_eqI_a(CleanInt value,int a_offset) {
add_instruction_w_i(CeqI_a,-a_offset,value); add_instruction_w_i(CeqI_a,-a_offset,value);
} }
void code_eqIi(CleanInt value) {
add_instruction_i(CeqIi,value);
}
void code_eqR(void) { void code_eqR(void) {
add_instruction(CeqR); add_instruction(CeqR);
} }
...@@ -3575,6 +3601,10 @@ void code_jmp_eqC_b2(int value1,int value2,int b_offset,char label_name1[],char ...@@ -3575,6 +3601,10 @@ void code_jmp_eqC_b2(int value1,int value2,int b_offset,char label_name1[],char
add_instruction_w_c_label_c_label(Cjmp_eqC_b2,b_offset,value1,label_name1,value2,label_name2); add_instruction_w_c_label_c_label(Cjmp_eqC_b2,b_offset,value1,label_name1,value2,label_name2);
} }
void code_jmp_eqCc(int value,char label_name[]) {
add_instruction_c_label(Cjmp_eqCc,value,label_name);
}
void code_jmp_eqD_b(char descriptor_name[],int arity,char label_name[]) { void code_jmp_eqD_b(char descriptor_name[],int arity,char label_name[]) {
add_instruction_label_offset_label(Cjmp_eqD_b,descriptor_name,(arity<<3)+2,label_name); add_instruction_label_offset_label(Cjmp_eqD_b,descriptor_name,(arity<<3)+2,label_name);
} }
...@@ -3596,6 +3626,10 @@ void code_jmp_eqI_b2(CleanInt value1,CleanInt value2,int b_offset,char label_nam ...@@ -3596,6 +3626,10 @@ void code_jmp_eqI_b2(CleanInt value1,CleanInt value2,int b_offset,char label_nam
add_instruction_w_i_label_i_label(Cjmp_eqI_b2,b_offset,value1,label_name1,value2,label_name2); add_instruction_w_i_label_i_label(Cjmp_eqI_b2,b_offset,value1,label_name1,value2,label_name2);
} }
void code_jmp_eqIi(CleanInt value,char label_name[]) {
add_instruction_i_label(Cjmp_eqIi,value,label_name);
}
void code_jmp_eq_desc(char descriptor_name[],int arity,int a_offset,char label_name[]) { void code_jmp_eq_desc(char descriptor_name[],int arity,int a_offset,char label_name[]) {
add_instruction_w_label_offset_label(Cjmp_eq_desc,-a_offset,descriptor_name,(arity<<3)+2,label_name); add_instruction_w_label_offset_label(Cjmp_eq_desc,-a_offset,descriptor_name,(arity<<3)+2,label_name);
} }
...@@ -3612,6 +3646,10 @@ void code_jmp_neC_b(int value,int b_offset,char label_name[]) { ...@@ -3612,6 +3646,10 @@ void code_jmp_neC_b(int value,int b_offset,char label_name[]) {
add_instruction_w_c_label(Cjmp_neC_b,b_offset,value,label_name); add_instruction_w_c_label(Cjmp_neC_b,b_offset,value,label_name);
} }
void code_jmp_neCc(int value,char label_name[]) {
add_instruction_c_label(Cjmp_neCc,value,label_name);
}
void code_jmp_neI(char label_name[]) { void code_jmp_neI(char label_name[]) {
add_instruction_label(Cjmp_neI,label_name); add_instruction_label(Cjmp_neI,label_name);
} }
...@@ -3620,6 +3658,10 @@ void code_jmp_neI_b(CleanInt value,int b_offset,char label_name[]) { ...@@ -3620,6 +3658,10 @@ void code_jmp_neI_b(CleanInt value,int b_offset,char label_name[]) {
add_instruction_w_i_label(Cjmp_neI_b,b_offset,value,label_name); add_instruction_w_i_label(Cjmp_neI_b,b_offset,value,label_name);
} }
void code_jmp_neIi(CleanInt value,char label_name[]) {
add_instruction_i_label(Cjmp_neIi,value,label_name);
}
void code_jmp_ne_desc(char descriptor_name[],int arity,int a_offset,char label_name[]) { void code_jmp_ne_desc(char descriptor_name[],int arity,int a_offset,char label_name[]) {
add_instruction_w_label_offset_label(Cjmp_ne_desc,-a_offset,descriptor_name,(arity<<3)+2,label_name); add_instruction_w_label_offset_label(Cjmp_ne_desc,-a_offset,descriptor_name,(arity<<3)+2,label_name);
} }
...@@ -3789,6 +3831,10 @@ void code_push_ab(int a_offset,int b_offset) { ...@@ -3789,6 +3831,10 @@ void code_push_ab(int a_offset,int b_offset) {
add_instruction_w_w(Cpush_ab,-a_offset,b_offset); add_instruction_w_w(Cpush_ab,-a_offset,b_offset);
} }
void code_push_b_decI(int b_offset) {
add_instruction_w(Cpush_b_decI,b_offset);
}
void code_push_b_incI(int b_offset) { void code_push_b_incI(int b_offset) {
add_instruction_w(Cpush_b_incI,b_offset); add_instruction_w(Cpush_b_incI,b_offset);
} }
...@@ -3856,10 +3902,22 @@ void code_put_a(int a_offset) { ...@@ -3856,10 +3902,22 @@ void code_put_a(int a_offset) {
add_instruction_w(Cput_a,-a_offset); add_instruction_w(Cput_a,-a_offset);
} }
void code_put_a_jmp(int a_offset, char label_name[]) {
last_d=0;
add_instruction_w_label(Cput_a_jmp,-a_offset,label_name);
}
void code_put_b(int b_offset) { void code_put_b(int b_offset) {
add_instruction_w(Cput_b,b_offset); add_instruction_w(Cput_b,b_offset);
} }
void code_put_b_jmp(int b_offset, char label_name[]) {
last_d=0;
add_instruction_w_label(Cput_b_jmp,b_offset,label_name);
}
void code_selectoo(char element_descriptor[],int a_size,int b_size,int a_offset,int b_offset) { void code_selectoo(char element_descriptor[],int a_size,int b_size,int a_offset,int b_offset) {
switch(element_descriptor[0]) { switch(element_descriptor[0]) {
case 'B': case 'B':
......