/* 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"
/*****************************************************************************/
-/* 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 */
{
- return GetCodeSegEntries (CS);
+ 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);
}
-static void PrintFunctionHeader (FILE* F, SymEntry* Entry)
+void MoveCode (CodeMark Start, CodeMark End, CodeMark Target)
+/* Move the code between Start (inclusive) and End (exclusive) to
+ * (before) Target.
+ */
{
- /* Print a comment with the function signature */
- fprintf (F,
- "; ---------------------------------------------------------------\n"
- "; ");
- PrintFuncSig (F, Entry->Name, Entry->Type);
- fprintf (F,
- "\n"
- "; ---------------------------------------------------------------\n"
- "\n");
+ CS_MoveEntries (CS->Code, Start, End - Start, Target);
}
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 (!HaveGlobalCode ());
+ 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 */
- 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);
- }
- Entry = Entry->NextSym;
+ SymIsDef (Entry) &&
+ (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;
}
}