From: ggn Date: Mon, 16 Nov 2015 11:53:02 +0000 (+0200) Subject: Extended switch -s to also warn about automatically applied 68000 optimisations.... X-Git-Tag: v2.1.0~173 X-Git-Url: http://shamusworld.gotdns.org/cgi-bin/gitweb.cgi?p=rmac;a=commitdiff_plain;h=917bfc1503181b7e762b73b9560bb834c12c64fa Extended switch -s to also warn about automatically applied 68000 optimisations. Added switch -w to turn off all automatic optimisations. --- diff --git a/mach.c b/mach.c index 46193d7..b3e36c7 100644 --- 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 diff --git a/parmode.h b/parmode.h index 38f6f94..c72b470 100644 --- 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 0683739..910cb88 100644 --- 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 25d2afd..f7b39e3 100644 --- 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);