* src/SDCCpeeph.c (buildLabelRefCountHash): assume function entry point
labels are referenced at least once (even if a reference is not found)
* src/hc08/gen.c (emitcode): set isComment flag for comments
* src/hc08/peeph.def: added rules 5a..5f (optimize redundant immediate
loads), rules 6a..6b (optimize jumps to return)
git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@3466
4a8a32a2-be11-0410-ad9d-
d568d2c75423
+2004-08-30 Erik Petrich <epetrich AT ivorytower.norman.ok.us>
+
+ * src/SDCCpeeph.c (labelIsReturnOnly): support hc08 rts opcode also
+ * src/SDCCpeeph.c (buildLabelRefCountHash): assume function entry point
+ labels are referenced at least once (even if a reference is not found)
+ * src/hc08/gen.c (emitcode): set isComment flag for comments
+ * src/hc08/peeph.def: added rules 5a..5f (optimize redundant immediate
+ loads), rules 6a..6b (optimize jumps to return)
+
2004-08-30 Erik Petrich <epetrich AT ivorytower.norman.ok.us>
* device/lib/acosf.c (acosf),
const char *label, *p;
const lineNode *pl;
int len;
+ char * retInst;
label = hTabItemWithKey (vars, 5);
if (!label) return FALSE;
p = pl->line;
for (p = pl->line; *p && isspace(*p); p++)
;
- if (strcmp(p, "ret") == 0) return TRUE;
+
+ retInst = "ret";
+ if (TARGET_IS_HC08)
+ retInst = "rts";
+ if (strcmp(p, retInst) == 0) return TRUE;
return FALSE;
}
memcpy (entry->name, label, labelLen);
entry->name[labelLen] = 0;
entry->refCount = -1;
+
+ /* Assume function entry points are referenced somewhere, */
+ /* even if we can't find a reference (might be from outside */
+ /* the function) */
+ if (line->ic && (line->ic->op == FUNCTION))
+ entry->refCount++;
hTabAddItem (&labelHash, hashSymbolName (entry->name), entry);
}
lineCurr->isInline = _G.inLine;
lineCurr->isDebug = _G.debugLine;
lineCurr->ic = _G.current_iCode;
+ lineCurr->isComment = (*lbp==';');
//printf("%s\n", lb);
va_end (ap);
; Peephole 4d - eliminated redundant tstx
ldx %1,s
}
+
+replace {
+ clra
+ sta %1
+ clra
+ sta %2
+ clra
+ sta %3
+ clra
+ sta %4
+} by {
+ ; Peephole 5a - eliminated redundant clra
+ clra
+ sta %1
+ sta %2
+ sta %3
+ sta %4
+}
+
+replace {
+ clra
+ sta %1
+ clra
+ sta %2
+ clra
+ sta %3
+} by {
+ ; Peephole 5b - eliminated redundant clra
+ clra
+ sta %1
+ sta %2
+ sta %3
+}
+
+replace {
+ clra
+ sta %1
+ clra
+ sta %2
+} by {
+ ; Peephole 5c - eliminated redundant clra
+ clra
+ sta %1
+ sta %2
+}
+
+replace {
+ lda #%9
+ sta %1
+ lda #%9
+ sta %2
+ lda #%9
+ sta %3
+ lda #%9
+ sta %4
+} by {
+ ; Peephole 5d - eliminated redundant lda
+ lda #%9
+ sta %1
+ sta %2
+ sta %3
+ sta %4
+}
+
+replace {
+ lda #%9
+ sta %1
+ lda #%9
+ sta %2
+ lda #%9
+ sta %3
+} by {
+ ; Peephole 5e - eliminated redundant lda
+ lda #%9
+ sta %1
+ sta %2
+ sta %3
+}
+
+replace {
+ lda #%9
+ sta %1
+ lda #%9
+ sta %2
+} by {
+ ; Peephole 5f - eliminated redundant lda
+ lda #%9
+ sta %1
+ sta %2
+}
+
+replace {
+ jmp %5
+} by {
+ ; Peephole 6a - replaced jmp to rts with rts
+ rts
+} if labelIsReturnOnly
+
+replace {
+ bra %5
+} by {
+ ; Peephole 6b - replaced jmp to rts with rts
+ rts
+} if labelIsReturnOnly