fixed an integral promotion bug
[fw/sdcc] / src / pic / pcode.h
index eaf70478f91ca14921f2f0fc689a65b3055ef6ea..39a637d006885bd0334910d432bf1b2956745873 100644 (file)
@@ -19,7 +19,8 @@
    
 -------------------------------------------------------------------------*/
 
-#include "ralloc.h"
+//#include "ralloc.h"
+struct regs;
 
 /*
    Post code generation
 #ifndef __PCODE_H__
 #define __PCODE_H__
 
+/***********************************************************************
+ * debug stuff
+ * 
+ * The DFPRINTF macro will call fprintf if PCODE_DEBUG is defined.
+ * The macro is used like:
+ *
+ * DPRINTF(("%s #%d\n","test", 1));
+ *
+ * The double parenthesis (()) are necessary
+ * 
+ ***********************************************************************/
+//#define PCODE_DEBUG
+
+#ifdef PCODE_DEBUG
+#define DFPRINTF(args) (fprintf args)
+#else
+#define DFPRINTF(args) ;
+#endif
+
+
 /***********************************************************************
  *  PIC status bits - this will move into device dependent headers
  ***********************************************************************/
@@ -104,8 +125,11 @@ typedef enum
   PO_FSR,            // The "file select register" (in 18c it's one of three)
   PO_INDF,           // The Indirect register
   PO_GPR_REGISTER,   // A general purpose register
+  PO_GPR_BIT,        // A bit of a general purpose register
   PO_GPR_TEMP,       // A general purpose temporary register
   PO_SFR_REGISTER,   // A special function register (e.g. PORTA)
+  PO_PCL,            // Program counter Low register
+  PO_PCLATH,         // Program counter Latch high register
   PO_LITERAL,        // A constant
   PO_IMMEDIATE,      //  (8051 legacy)
   PO_DIR,            // Direct memory (8051 legacy)
@@ -146,6 +170,7 @@ typedef enum
 #define  PCC_Z             (1<<2)
 #define  PCC_DC            (1<<3)
 #define  PCC_W             (1<<4)
+#define  PCC_EXAMINE_PCOP  (1<<5)
 
 /***********************************************************************
  *
@@ -172,6 +197,7 @@ typedef enum
   POC_BTFSS,
   POC_CALL,
   POC_COMF,
+  POC_COMFW,
   POC_CLRF,
   POC_CLRW,
   POC_DECF,
@@ -193,9 +219,15 @@ typedef enum
   POC_NEGF,
   POC_RETLW,
   POC_RETURN,
+  POC_RLF,
+  POC_RLFW,
+  POC_RRF,
+  POC_RRFW,
   POC_SUBLW,
   POC_SUBWF,
   POC_SUBFW,
+  POC_SWAPF,
+  POC_SWAPFW,
   POC_TRIS,
   POC_XORLW,
   POC_XORWF,
@@ -290,10 +322,16 @@ typedef struct pCodeOpReg
 {
   pCodeOp pcop;    // Can be either GPR or SFR
   int rIdx;        // Index into the register table
-  regs *r;
+  struct regs *r;
   struct pBlock *pb;
 } pCodeOpReg;
 
+typedef struct pCodeOpRegBit
+{
+  pCodeOpReg  pcor;       // The Register containing this bit
+  int bit;                // 0-7 bit number.
+  PIC_OPTYPE subtype;     // The type of this register.
+} pCodeOpRegBit;
 
 
 /*************************************************
@@ -360,7 +398,7 @@ typedef struct pCodeInstruction
 
   PIC_OPCODE op;        // The opcode of the instruction.
 
-  char *mnemonic;       // Pointer to mnemonic string
+  char const * const mnemonic;       // Pointer to mnemonic string
 
   pCodeOp *pcop;        // Operand
 
@@ -497,8 +535,11 @@ typedef struct pCodePeep {
 
   int     nvars;       // Number of wildcard registers in target.
   char  **vars;        // array of pointers to them
+  int     nops;             // Number of wildcard operands in target.
+  pCodeOp **wildpCodeOps;   // array of pointers to the pCodeOp's.
+
   int     nwildpCodes; // Number of wildcard pCodes in target/replace
-  pCode **wildpCodes;  // array of pointers to the pCodeOp's.
+  pCode **wildpCodes;  // array of pointers to the pCode's.
 
 
   /* (Note: a wildcard register is a place holder. Any register
@@ -545,6 +586,7 @@ typedef struct pCodeOpWild
 #define PCOL(x)   ((pCodeOpLit *)(x))
 #define PCOLAB(x) ((pCodeOpLabel *)(x))
 #define PCOR(x)   ((pCodeOpReg *)(x))
+#define PCORB(x)  ((pCodeOpRegBit *)(x))
 #define PCOW(x)   ((pCodeOpWild *)(x))
 
 #define PBR(x)    ((pBranch *)(x))
@@ -572,7 +614,7 @@ void pCodePeepInit(void);
 
 pCodeOp *newpCodeOpLabel(int key);
 pCodeOp *newpCodeOpLit(int lit);
-pCodeOp *newpCodeOpBit(char *name, int bit);
+pCodeOp *newpCodeOpBit(char *name, int bit,int inBitSpace);
 pCodeOp *newpCodeOp(char *name, PIC_OPTYPE p);
 extern void pcode_test(void);
 
@@ -580,9 +622,12 @@ extern void pcode_test(void);
  * pCode objects.
  *-----------------------------------------------------------------*/
 
-extern pCodeOp pc_status;
-extern pCodeOp pc_indf;
-extern pCodeOp pc_fsr;
+extern pCodeOpReg pc_status;
+extern pCodeOpReg pc_indf;
+extern pCodeOpReg pc_fsr;
+extern pCodeOpReg pc_pcl;
+extern pCodeOpReg pc_pclath;
+extern pCodeOpReg pc_kzero;
 
 
 ////////////////////   DELETE THIS ///////////////////