/* */
/* */
/* */
-/* (C) 2000 Ullrich von Bassewitz */
-/* Wacholderweg 14 */
-/* D-70597 Stuttgart */
-/* EMail: uz@musoftware.de */
+/* (C) 2000-2001 Ullrich von Bassewitz */
+/* Wacholderweg 14 */
+/* D-70597 Stuttgart */
+/* EMail: uz@cc65.org */
/* */
/* */
/* This software is provided 'as-is', without any expressed or implied */
/* common */
#include "check.h"
-/* b6502 */
+/* cc65 */
+#include "codeopt.h"
#include "codeseg.h"
#include "dataseg.h"
-
-/* cc65 */
-#include "codegen.h"
-#include "global.h"
+#include "segments.h"
+#include "symtab.h"
#include "asmcode.h"
/*****************************************************************************/
-/* Code */
+/* Code */
/*****************************************************************************/
-void AddCodeHint (const char* Hint)
-/* Add an optimizer hint */
-{
- /* ### AddCodeLine ("+%s", Hint); */
-}
-
-
-
CodeMark GetCodePos (void)
/* Get a marker pointing to the current output position */
{
- unsigned EntryCount = GetCodeSegEntries (CS);
-
- /* This function should never be called without any code output */
- CHECK (EntryCount > 0);
-
- return EntryCount;
+ return CS_GetEntryCount (CS->Code);
}
void RemoveCode (CodeMark M)
/* Remove all code after the given code marker */
{
- DelCodeSegAfter (CS, M);
+ CS_DelCodeAfter (CS->Code, M);
+}
+
+
+
+void MoveCode (CodeMark Start, CodeMark End, CodeMark Target)
+/* Move the code between Start (inclusive) and End (exclusive) to
+ * (before) Target.
+ */
+{
+ CS_MoveEntries (CS->Code, Start, End - Start, Target);
}
void WriteOutput (FILE* F)
/* Write the final output to a file */
{
- OutputDataSeg (F, DS);
- MergeCodeLabels (CS);
- OutputCodeSeg (F, CS);
+ SymTable* SymTab;
+ SymEntry* Entry;
+
+ /* Output the global data segment */
+ CHECK (CS_GetEntryCount (CS->Code) == 0);
+ OutputSegments (CS, F);
+
+ /* Output all global or referenced functions */
+ SymTab = GetGlobalSymTab ();
+ Entry = SymTab->SymHead;
+ while (Entry) {
+ if (IsTypeFunc (Entry->Type) &&
+ (Entry->Flags & SC_DEF) != 0 &&
+ (Entry->Flags & (SC_REF | SC_EXTERN)) != 0) {
+ /* Function which is defined and referenced or extern */
+ CS_MergeLabels (Entry->V.F.Seg->Code);
+ RunOpt (Entry->V.F.Seg->Code);
+ OutputSegments (Entry->V.F.Seg, F);
+ }
+ Entry = Entry->NextSym;
+ }
}