#include <ctype.h>
#include "common.h"
+#include "main.h"
#include "ralloc.h"
#include "gen.h"
#include "SDCCglobl.h"
va_end (ap);
}
+/*-----------------------------------------------------------------*/
+/* ds390_emitDebuggerSymbol - associate the current code location */
+/* with a debugger symbol */
+/*-----------------------------------------------------------------*/
+void
+ds390_emitDebuggerSymbol (char * debugSym)
+{
+ _G.debugLine = 1;
+ emitcode ("", "%s ==.", debugSym);
+ _G.debugLine = 0;
+}
+
//
// Move the passed value into A unless it is already there.
//
/* save the registers used */
for (i = 0; i < sym->regsUsed->size; i++)
{
- if (bitVectBitValue (sym->regsUsed, i) ||
- (ds390_ptrRegReq && (i == R0_IDX || i == R1_IDX)))
+ if (bitVectBitValue (sym->regsUsed, i))
emitcode ("push", "%s", ds390_regWithIdx (i)->dname);
}
}
- else if (ds390_ptrRegReq)
- {
- emitcode ("push", "%s", ds390_regWithIdx (R0_IDX)->dname);
- emitcode ("push", "%s", ds390_regWithIdx (R1_IDX)->dname);
- }
-
}
else
{
/* save the registers used */
for (i = 0; i < sym->regsUsed->size; i++)
{
- if (bitVectBitValue (sym->regsUsed, i) ||
- (ds390_ptrRegReq && (i == R0_IDX || i == R1_IDX)))
+ if (bitVectBitValue (sym->regsUsed, i))
{
emitcode ("push", "%s", ds390_regWithIdx (i)->dname);
_G.nRegsSaved++;
}
}
}
- else if (ds390_ptrRegReq)
- {
- emitcode ("push", "%s", ds390_regWithIdx (R0_IDX)->dname);
- emitcode ("push", "%s", ds390_regWithIdx (R1_IDX)->dname);
- _G.nRegsSaved += 2;
- }
}
}
if (IFFUNC_ISNAKED(sym->type))
{
emitcode(";", "naked function: no epilogue.");
+ if (options.debug && currFunc)
+ debugFile->writeEndFunction (currFunc, ic, 0);
return;
}
/* save the registers used */
for (i = sym->regsUsed->size; i >= 0; i--)
{
- if (bitVectBitValue (sym->regsUsed, i) ||
- (ds390_ptrRegReq && (i == R0_IDX || i == R1_IDX)))
+ if (bitVectBitValue (sym->regsUsed, i))
emitcode ("pop", "%s", ds390_regWithIdx (i)->dname);
}
}
- else if (ds390_ptrRegReq)
- {
- emitcode ("pop", "%s", ds390_regWithIdx (R1_IDX)->dname);
- emitcode ("pop", "%s", ds390_regWithIdx (R0_IDX)->dname);
- }
-
}
else
{
/* if debug then send end of function */
if (options.debug && currFunc) {
- _G.debugLine = 1;
- emitcode ("", "C$%s$%d$%d$%d ==.",
- FileBaseName (ic->filename), currFunc->lastLine,
- ic->level, ic->block);
- if (IS_STATIC (currFunc->etype))
- emitcode ("", "XF%s$%s$0$0 ==.", moduleName, currFunc->name);
- else
- emitcode ("", "XG$%s$0$0 ==.", currFunc->name);
- _G.debugLine = 0;
+ debugFile->writeEndFunction (currFunc, ic, 1);
}
emitcode ("reti", "");
/* save the registers used */
for (i = sym->regsUsed->size; i >= 0; i--)
{
- if (bitVectBitValue (sym->regsUsed, i) ||
- (ds390_ptrRegReq && (i == R0_IDX || i == R1_IDX)))
+ if (bitVectBitValue (sym->regsUsed, i))
emitcode ("pop", "%s", ds390_regWithIdx (i)->dname);
}
}
- else if (ds390_ptrRegReq)
- {
- emitcode ("pop", "%s", ds390_regWithIdx (R1_IDX)->dname);
- emitcode ("pop", "%s", ds390_regWithIdx (R0_IDX)->dname);
- }
-
}
/* if debug then send end of function */
if (options.debug && currFunc)
{
- _G.debugLine = 1;
- emitcode ("", "C$%s$%d$%d$%d ==.",
- FileBaseName (ic->filename), currFunc->lastLine,
- ic->level, ic->block);
- if (IS_STATIC (currFunc->etype))
- emitcode ("", "XF%s$%s$0$0 ==.", moduleName, currFunc->name);
- else
- emitcode ("", "XG$%s$0$0 ==.", currFunc->name);
- _G.debugLine = 0;
+ debugFile->writeEndFunction (currFunc, ic, 1);
}
emitcode ("ret", "");
&& !FUNC_REGBANK(sym->type))
return;
+ /* There are no push/pops to optimize if not callee-saves or ISR */
+ if (!(FUNC_CALLEESAVES (sym->type) || FUNC_ISISR (sym->type)))
+ return;
+
+ /* If there were stack parameters, we cannot optimize without also */
+ /* fixing all of the stack offsets; this is too dificult to consider. */
+ if (FUNC_HASSTACKPARM(sym->type))
+ return;
+
/* Compute the registers actually used */
regsUsed = newBitVect (ds390_nRegs);
regsUsedPrologue = newBitVect (ds390_nRegs);
regsUsed = bitVectUnion (regsUsed, port->peep.getRegsWritten(lnp));
if (lnp->ic && lnp->ic->op == FUNCTION && lnp->prev
- && lnp->prev->ic && lnp->prev->ic->op != FUNCTION)
+ && lnp->prev->ic && lnp->prev->ic->op == ENDFUNCTION)
break;
if (!lnp->prev)
break;
/* if debug information required */
if (options.debug && currFunc)
{
- debugFile->writeFunction(currFunc);
- _G.debugLine = 1;
- if (IS_STATIC (currFunc->etype))
- emitcode ("", "F%s$%s$0$0 ==.", moduleName, currFunc->name);
- else
- emitcode ("", "G$%s$0$0 ==.", currFunc->name);
- _G.debugLine = 0;
+ debugFile->writeFunction (currFunc, lic);
}
/* stack pointer name */
if (options.useXstack)
{
if (options.debug)
{
- _G.debugLine = 1;
- emitcode ("", "C$%s$%d$%d$%d ==.",
- FileBaseName (ic->filename), ic->lineno,
- ic->level, ic->block);
- _G.debugLine = 0;
+ debugFile->writeCLine (ic);
}
if (!options.noCcodeInAsm) {
emitcode ("", ";\t%s:%d: %s", ic->filename, ic->lineno,