/* common */
#include "check.h"
-/* b6502 */
+/* cc65 */
#include "codeopt.h"
#include "codeseg.h"
#include "dataseg.h"
-
-/* cc65 */
+#include "segments.h"
#include "symtab.h"
#include "asmcode.h"
-void AddCodeHint (const char* Hint)
-/* Add an optimizer hint */
-{
- /* ### AddCodeLine ("+%s", Hint); */
-}
-
-
-
CodeMark GetCodePos (void)
/* Get a marker pointing to the current output position */
{
- return GetCodeSegEntries (CS);
+ return GetCodeEntryCount (CS->Code);
}
void RemoveCode (CodeMark M)
/* Remove all code after the given code marker */
{
- DelCodeSegAfter (CS, M);
-}
-
-
-
-static void PrintFunctionHeader (FILE* F, SymEntry* Entry)
-{
- /* Print a comment with the function signature */
- fprintf (F,
- "; ---------------------------------------------------------------\n"
- "; ");
- PrintFuncSig (F, Entry->Name, Entry->Type);
- fprintf (F,
- "\n"
- "; ---------------------------------------------------------------\n"
- "\n");
+ DelCodeSegAfter (CS->Code, M);
}
SymTable* SymTab;
SymEntry* Entry;
- /* Output the data segment (the global code segment should be empty) */
- OutputDataSeg (F, DS);
- CHECK (GetCodeSegEntries (CS) == 0);
+ /* Output the global data segment */
+ CHECK (GetCodeEntryCount (CS->Code) == 0);
+ OutputSegments (CS, F);
/* Output all global or referenced functions */
SymTab = GetGlobalSymTab ();
(Entry->Flags & SC_DEF) != 0 &&
(Entry->Flags & (SC_REF | SC_EXTERN)) != 0) {
/* Function which is defined and referenced or extern */
- PrintFunctionHeader (F, Entry);
- MergeCodeLabels (Entry->V.F.CS);
- RunOpt (Entry->V.F.CS);
- fprintf (F, "; Data segment for function %s:\n", Entry->Name);
- OutputDataSeg (F, Entry->V.F.DS);
- fprintf (F, "; Code segment for function %s:\n", Entry->Name);
- OutputCodeSeg (F, Entry->V.F.CS);
+ MergeCodeLabels (Entry->V.F.Seg->Code);
+ RunOpt (Entry->V.F.Seg->Code);
+ OutputSegments (Entry->V.F.Seg, F);
}
Entry = Entry->NextSym;
}