Extended switch -s to also warn about automatically applied 68000 optimisations....
authorggn <ggn.dbug@gmail.com>
Mon, 16 Nov 2015 11:53:02 +0000 (13:53 +0200)
committerShamus Hammons <jlhamm@acm.org>
Tue, 17 Nov 2015 13:40:58 +0000 (07:40 -0600)
mach.c
parmode.h
rmac.c
rmac.h

diff --git a/mach.c b/mach.c
index 46193d7a8953b958757d1ab35db4f07b3524b015..b3e36c7dc382c93b84599a1979f8da85920c7280 100644 (file)
--- a/mach.c
+++ b/mach.c
@@ -13,6 +13,7 @@
 #include "token.h"
 #include "procln.h"
 #include "riscasm.h"
+#include "rmac.h"
 
 #define DEF_KW
 #include "kwtab.h"
@@ -439,10 +440,12 @@ int m_move(WORD inst, WORD size)
        int siz = (int)size;
 
        // Try to optimize to MOVEQ
-       if (siz == SIZL && am0 == IMMED && am1 == DREG
+       if (optim_flag && siz == SIZL && am0 == IMMED && am1 == DREG
                && (a0exattr & (TDB|DEFINED)) == DEFINED && a0exval + 0x80 < 0x100)
        {
                m_moveq((WORD)0x7000, (WORD)0);
+               if (sbra_flag)
+                       warn("move.l #size,dx converted to moveq");
        }
        else
        {
@@ -555,11 +558,13 @@ int m_br(WORD inst, WORD siz)
                // Optimize branch instr. size
                if (siz == SIZN)
                {
-                       if (v != 0 && v + 0x80 < 0x100)
+                       if (optim_flag && v != 0 && v + 0x80 < 0x100)
                        {
                                // Fits in .B 
                                inst |= v & 0xFF;
                                D_word(inst);
+                               if (sbra_flag)
+                                       warn("Bcc.w/BSR.w converted to .s");
                                return 0;
                        }
                        else
index 38f6f94b6c787f5143c40bb98cdc0e7f806c8a0f..c72b47012613e6ffd4d3b15bbdcf75e221157601 100644 (file)
--- a/parmode.h
+++ b/parmode.h
@@ -252,8 +252,12 @@ CHK_FOR_DISPn:
 
                        // Defined, absolute values from $FFFF8000..$00007FFF get optimized
                        // to absolute short
-                       if ((AnEXATTR & (TDB|DEFINED)) == DEFINED && (AnEXVAL + 0x8000) < 0x10000)
+                       if (optim_flag && (AnEXATTR & (TDB|DEFINED)) == DEFINED && (AnEXVAL + 0x8000) < 0x10000)
+                       {
                                AMn = ABSW;
+                               if (sbra_flag)
+                                       warn("absolute value from $FFFF8000..$00007FFF optimised to absolute short");
+                       }
 
                        // Is .L forced here?
                        if (*tok == DOTL)
diff --git a/rmac.c b/rmac.c
index 0683739847ce7172b1562068545f393a5b969266..910cb88d5260535406cef0dd397282630b58d372 100644 (file)
--- a/rmac.c
+++ b/rmac.c
@@ -45,7 +45,7 @@ char * firstfname;                            // First source filename
 char * cmdlnexec;                              // Executable name, pointer to ARGV[0]
 char * searchpath;                             // Search path for include files 
 char defname[] = "noname.o";   // Default output filename
-
+int optim_flag;                                        // Optimise all the things!
 
 //
 // Manipulate file extension.
@@ -142,7 +142,9 @@ void DisplayHelp(void)
                "                    d: double phrase (16 bytes)\n"
                "                    q: quad phrase (32 bytes)\n"
                "  -s                Warn about possible short branches\n"
+               "                    and applied optimisations\n"
                "  -u                Force referenced and undefined symbols global\n"
+               "  -w                Turn off optimisations done automatically\n"
                "  -v                Set verbose mode\n"
                "  -y[pagelen]       Set page line length (default: 61)\n"
                "\n", cmdlnexec);
@@ -200,6 +202,7 @@ int Process(int argc, char ** argv)
        orgactive = 0;                                  // Not in RISC org section
        orgwarning = 0;                                 // No ORG warning issued
        segpadsize = 2;                                 // Initialise segment padding size
+       optim_flag = 1;                                 // Automatically optimise
 
        // Initialise modules
        InitSymbolTable();                              // Symbol table
@@ -357,6 +360,10 @@ int Process(int argc, char ** argv)
                                        DisplayVersion();
 
                                break;
+                       case 'w':
+                       case 'W':
+                               optim_flag=0;
+                               break;
                        case 'x':                               // Turn on debugging
                        case 'X':
                                debug = 1;
diff --git a/rmac.h b/rmac.h
index 25d2afda3a334baaf6a15daab6ff612839bd4cab..f7b39e39b8d027ded9bf9b68da12dcd408fd7aa4 100644 (file)
--- a/rmac.h
+++ b/rmac.h
@@ -211,6 +211,7 @@ extern int sbra_flag;
 extern int obj_format;
 extern int legacy_flag;
 extern LONG PRGFLAGS;
+extern int optim_flag;
 
 // Exported functions
 char * fext(char *, char *, int);