]> git.sur5r.net Git - cc65/blobdiff - src/cc65/codeseg.h
Renamed ExprDesc.Val to ExprDesc.IVal. Added an FVal field for a floating
[cc65] / src / cc65 / codeseg.h
index fc61ab25eb476790ef4d25cad27cf587c9b4e004..cde8c4ff1c4fc53550dfd003805c7ea94e3e7903 100644 (file)
@@ -6,9 +6,9 @@
 /*                                                                           */
 /*                                                                           */
 /*                                                                           */
-/* (C) 2001      Ullrich von Bassewitz                                       */
-/*               Wacholderweg 14                                             */
-/*               D-70597 Stuttgart                                           */
+/* (C) 2001-2004 Ullrich von Bassewitz                                       */
+/*               Römerstrasse 52                                             */
+/*               D-70794 Filderstadt                                         */
 /* EMail:        uz@cc65.org                                                 */
 /*                                                                           */
 /*                                                                           */
@@ -103,6 +103,16 @@ void CS_AddVLine (CodeSeg* S, LineInfo* LI, const char* Format, va_list ap) attr
 void CS_AddLine (CodeSeg* S, LineInfo* LI, const char* Format, ...) attribute ((format(printf,3,4)));
 /* Add a line to the given code segment */
 
+#if defined(HAVE_INLINE)
+INLINE unsigned CS_GetEntryCount (const CodeSeg* S)
+/* Return the number of entries for the given code segment */
+{
+    return CollCount (&S->Entries);
+}
+#else
+#  define CS_GetEntryCount(S)  CollCount (&(S)->Entries)
+#endif
+
 void CS_InsertEntry (CodeSeg* S, struct CodeEntry* E, unsigned Index);
 /* Insert the code entry at the index given. Following code entries will be
  * moved to slots with higher indices.
@@ -112,6 +122,8 @@ void CS_DelEntry (CodeSeg* S, unsigned Index);
 /* Delete an entry from the code segment. This includes moving any associated
  * labels, removing references to labels and even removing the referenced labels
  * if the reference count drops to zero.
+ * Note: Labels are moved forward if possible, that is, they are moved to the
+ * next insn (not the preceeding one).
  */
 
 void CS_DelEntries (CodeSeg* S, unsigned Start, unsigned Count);
@@ -149,7 +161,7 @@ INLINE struct CodeEntry* CS_GetEntry (CodeSeg* S, unsigned Index)
     return CollAt (&S->Entries, Index);
 }
 #else
-#  define CS_GetEntry(S, Index)        CollAt(&(S)->Entries, (Index))
+#  define CS_GetEntry(S, Index)        ((struct CodeEntry*) CollAt(&(S)->Entries, (Index)))
 #endif
 
 struct CodeEntry* CS_GetPrevEntry (CodeSeg* S, unsigned Index);
@@ -177,6 +189,18 @@ int CS_RangeHasLabel (CodeSeg* S, unsigned Start, unsigned Count);
  * possible span instead.
  */
 
+#if defined(HAVE_INLINE)
+INLINE int CS_HavePendingLabel (const CodeSeg* S)
+/* Return true if there are open labels that will get attached to the next
+ * instruction that is added.
+ */
+{
+    return (CollCount (&S->Labels) > 0);
+}
+#else
+#  define CS_HavePendingLabel(S)        (CollCount (&(S)->Labels) > 0)
+#endif
+
 CodeLabel* CS_AddLabel (CodeSeg* S, const char* Name);
 /* Add a code label for the next instruction to follow */
 
@@ -216,19 +240,44 @@ void CS_MoveLabelRef (CodeSeg* S, struct CodeEntry* E, CodeLabel* L);
 void CS_DelCodeAfter (CodeSeg* S, unsigned Last);
 /* Delete all entries including the given one */
 
-void CS_Output (const CodeSeg* S, FILE* F);
-/* Output the code segment data to a file */
+void CS_ResetMarks (CodeSeg* S, unsigned First, unsigned Last);
+/* Remove all user marks from the entries in the given range */
 
 #if defined(HAVE_INLINE)
-INLINE unsigned CS_GetEntryCount (const CodeSeg* S)
-/* Return the number of entries for the given code segment */
+INLINE void CS_ResetAllMarks (CodeSeg* S)
+/* Remove all user marks from the code segment */
 {
-    return CollCount (&S->Entries);
+    if (CS_GetEntryCount (S) > 0) {
+        CS_ResetMarks (S, 0, CS_GetEntryCount (S));
+    }
 }
 #else
-#  define CS_GetEntryCount(S)  CollCount (&(S)->Entries)
+#  define CS_ResetAllMarks(S) \
+        ((CS_GetEntryCount (S) > 0)? CS_ResetMarks (S, 0, CS_GetEntryCount (S)) : (void) 0)
 #endif
 
+int CS_IsBasicBlock (CodeSeg* S, unsigned First, unsigned Last);
+/* Check if the given code segment range is a basic block. That is, check if
+ * First is the only entrance and Last is the only exit. This means that no
+ * jump/branch inside the block may jump to an insn below First or after(!)
+ * Last, and that no insn may jump into this block from the outside.
+ */
+
+void CS_OutputPrologue (const CodeSeg* S, FILE* F);
+/* If the given code segment is a code segment for a function, output the
+ * assembler prologue into the file. That is: Output a comment header, switch
+ * to the correct segment and enter the local function scope. If the code
+ * segment is global, do nothing.
+ */
+
+void CS_OutputEpilogue (const CodeSeg* S, FILE* F);
+/* If the given code segment is a code segment for a function, output the
+ * assembler epilogue into the file. That is: Close the local function scope.
+ */
+
+void CS_Output (CodeSeg* S, FILE* F);
+/* Output the code segment data to a file */
+
 void CS_FreeRegInfo (CodeSeg* S);
 /* Free register infos for all instructions */