]> Shamusworld >> Repos - rmac/commitdiff
Added optimisation switches -o8 and -o9
authorggn <ggn.dbug@gmail.com>
Tue, 23 Jan 2018 08:57:01 +0000 (10:57 +0200)
committerShamus Hammons <jlhamm@acm.org>
Wed, 24 Jan 2018 00:34:43 +0000 (18:34 -0600)
Added optimisation switches -o8 (adda.w/l #x,Dy to addq.w/l #x,Dy) and
-o9 (adda.w/l #x,Dy to lea x(Dy),Dy), both off by default.

mach.c
rmac.c
rmac.h

diff --git a/mach.c b/mach.c
index 2673aa9f5fb5063a44fb3831bf33cf033e13084d..ef4c8c6837c88cbf3c43675a96eebf4c6655ff64 100644 (file)
--- a/mach.c
+++ b/mach.c
@@ -452,6 +452,22 @@ int m_abcd(WORD inst, WORD siz)
 //
 int m_adda(WORD inst, WORD siz)
 {
 //
 int m_adda(WORD inst, WORD siz)
 {
+       if (a0exattr & DEFINED)
+       {
+               if (CHECK_OPTS(OPT_ADDA_ADDQ))
+                       if (a0exval > 1 && a0exval <= 8)
+                               // Immediate is between 1 and 8 so let's convert to addq
+                               return m_addq(B16(01010000, 00000000), siz);
+       if (CHECK_OPTS(OPT_ADDA_LEA))
+               if (a0exval > 8)
+               {
+                       // Immediate is larger than 8 so let's convert to lea
+                       am0 = ADISP;    // Change addressing mode
+                       a0reg = a1reg;  // In ADISP a0reg is used instead of a1reg!
+                       return m_lea(B16(01000001, 11011000), SIZW);
+               }
+       }
+
        inst |= am0 | a0reg | lwsiz_8[siz] | reg_9[a1reg];
        D_word(inst);
        ea0gen(siz);    // Generate EA
        inst |= am0 | a0reg | lwsiz_8[siz] | reg_9[a1reg];
        D_word(inst);
        ea0gen(siz);    // Generate EA
@@ -1298,7 +1314,7 @@ int m_cas(WORD inst, WORD siz)
        if (*tok != EOL)
                return error("extra (unexpected) text found");
 
        if (*tok != EOL)
                return error("extra (unexpected) text found");
 
-       // Reject invalud ea modes
+       // Reject invalid ea modes
        amsk = amsktab[am0];
 
        if ((amsk & (M_AIND | M_APOSTINC | M_APREDEC | M_ADISP | M_AINDEXED | M_ABSW | M_ABSL | M_ABASE | M_MEMPOST | M_MEMPRE)) == 0)
        amsk = amsktab[am0];
 
        if ((amsk & (M_AIND | M_APOSTINC | M_APREDEC | M_ADISP | M_AINDEXED | M_ABSW | M_ABSL | M_ABASE | M_MEMPOST | M_MEMPRE)) == 0)
diff --git a/rmac.c b/rmac.c
index a4b6b42f74e5c9b37c1117dcd2c48d8902e54cd2..615d84d7cdec1eea5d9c013093e4c85d501ed9b5 100644 (file)
--- a/rmac.c
+++ b/rmac.c
@@ -161,6 +161,8 @@ void DisplayHelp(void)
                "                    o5: Absolute long base displacement to word (off)\n"
                "                    o6: Null branches to NOP                    (off)\n"
                "                    o7: clr.l Dx to moveq #0,Dx                 (off)\n"
                "                    o5: Absolute long base displacement to word (off)\n"
                "                    o6: Null branches to NOP                    (off)\n"
                "                    o7: clr.l Dx to moveq #0,Dx                 (off)\n"
+               "                    o8: adda.w/l #x,Dy to addq.w/l #x,Dy        (off)\n"
+               "                    o9: adda.w/l #x,Dy to lea x(Dy),Dy          (off)\n"
                "  ~o[value]         Turn a specific optimisation off\n"
                "  +oall             Turn all optimisations on\n"
                "  ~oall             Turn all optimisations off\n"
                "  ~o[value]         Turn a specific optimisation off\n"
                "  +oall             Turn all optimisations on\n"
                "  ~oall             Turn all optimisations off\n"
diff --git a/rmac.h b/rmac.h
index 48317499ddf7114a71efdf67555b736a25b20ac6..7b1d97244d843d0b1fd8f71e5d2183f5db2ab93b 100644 (file)
--- a/rmac.h
+++ b/rmac.h
@@ -275,6 +275,8 @@ enum
        OPT_BASE_DISP     = 5,
        OPT_NULL_BRA      = 6,
        OPT_CLR_DX        = 7,
        OPT_BASE_DISP     = 5,
        OPT_NULL_BRA      = 6,
        OPT_CLR_DX        = 7,
+       OPT_ADDA_ADDQ     = 8,
+       OPT_ADDA_LEA      = 9,
        OPT_COUNT   // Dummy, used to count number of optimisation switches
 };
 
        OPT_COUNT   // Dummy, used to count number of optimisation switches
 };