* in genGenPointerSet forgot to use postdec1
[fw/sdcc] / src / pic16 / pcode.h
index 2b57ef5d2f36fd181ee4541a5157847df5961d90..55ae2e9e1eba93eac74aa055dd3fabc784f4ad9a 100644 (file)
@@ -157,6 +157,9 @@ typedef enum
   PO_SFR_REGISTER,   // A special function register (e.g. PORTA)
   PO_PCL,            // Program counter Low register
   PO_PCLATH,         // Program counter Latch high register
+  PO_PCLATU,         // Program counter Latch upper register
+  PO_PRODL,          // Product Register Low
+  PO_PRODH,          // Product Register High
   PO_LITERAL,        // A constant
   PO_REL_ADDR,       // A relative address
   PO_IMMEDIATE,      //  (8051 legacy)
@@ -225,6 +228,7 @@ typedef enum
   POC_INCFSZ,
   POC_INCFSZW,
   POC_INFSNZ,
+  POC_INFSNZW,
   POC_IORWF,
   POC_IORFW,
   POC_IORLW,
@@ -264,11 +268,20 @@ typedef enum
   POC_SUBFWB_D1,
   POC_SWAPF,
   POC_SWAPFW,
-//  POC_TRIS , // To be removed
+  POC_TBLRD,
+  POC_TBLRD_POSTINC,
+  POC_TBLRD_POSTDEC,
+  POC_TBLRD_PREINC,
+  POC_TBLWT,
+  POC_TBLWT_POSTINC,
+  POC_TBLWT_POSTDEC,
+  POC_TBLWT_PREINC,
   POC_TSTFSZ,
   POC_XORLW,
   POC_XORWF,
-  POC_XORFW
+  POC_XORFW,
+
+  POC_BANKSEL
 } PIC_OPCODE;
 
 
@@ -288,9 +301,34 @@ typedef enum
                   * in the pCode peep hole optimizer */
   PC_CSOURCE,     /* C-Source Line  */
   PC_ASMDIR,     /* Assembler directive */
-  PC_BAD          /* Mark the pCode object as being bad */
+  PC_BAD,         /* Mark the pCode object as being bad */
+  PC_INFO         /* pCode informatio node, used primarily in optimizing */
 } PC_TYPE;
 
+
+/***********************************************************************
+ *  INFO_TYPE  - information node types
+ ***********************************************************************/
+
+typedef enum
+{
+  INF_OPTIMIZATION,      /* structure contains optimization information */
+} INFO_TYPE;
+
+
+
+/***********************************************************************
+ *  OPT_TYPE  - optimization node types
+ ***********************************************************************/
+
+typedef enum
+{
+  OPT_BEGIN,             /* mark beginning of optimization block */
+  OPT_END,               /* mark ending of optimization block */
+} OPT_TYPE;
+
+
+
 /************************************************/
 /***************  Structures ********************/
 /************************************************/
@@ -364,14 +402,14 @@ typedef struct pCodeOpLit2
 {
   pCodeOp pcop;
   int lit;
-  int lit2;
+  pCodeOp *arg2;
 } pCodeOpLit2;
 
 
 typedef struct pCodeOpImmd
 {
   pCodeOp pcop;
-  int offset;           /* low,med, or high byte of immediat value */
+  int offset;           /* low,high or upper byte of immediate value */
   int index;            /* add this to the immediate value */
   unsigned _const:1;    /* is in code space    */
 
@@ -429,9 +467,22 @@ typedef struct pCodeOpWild
   pCodeOp *matched;       /* When a wild matches, we'll store a pointer to the
                           * opcode we matched */
 
+  pCodeOp *pcop2;        /* second operand if exists */
+
 } pCodeOpWild;
 
 
+typedef struct pCodeOpOpt
+{
+  pCodeOp pcop;
+  
+  OPT_TYPE type;          /* optimization node type */
+  
+  char *key;              /* key by which a block is identified */
+} pCodeOpOpt;
+
+  
+
 /*************************************************
     pCode
 
@@ -498,17 +549,6 @@ typedef struct pCodeCSource
     pCodeAsmDir
 **************************************************/
 
-typedef struct pCodeAsmDir
-{
-  pCode pc;
-  
-  char *directive;
-  char *arg;
-
-  pBranch *label;
-} pCodeAsmDir;
-
-
 /*************************************************
     pCodeFlow
 
@@ -620,6 +660,20 @@ typedef struct pCodeInstruction
 } pCodeInstruction;
 
 
+
+/*************************************************
+    pCodeAsmDir
+**************************************************/
+
+typedef struct pCodeAsmDir
+{
+  pCodeInstruction pci;
+  
+  char *directive;
+  char *arg;
+} pCodeAsmDir;
+
+
 /*************************************************
     pCodeLabel
 **************************************************/
@@ -631,6 +685,7 @@ typedef struct pCodeLabel
 
   char *label;
   int key;
+  int force;           /* label cannot be optimized out */
 
 } pCodeLabel;
 
@@ -655,6 +710,10 @@ typedef struct pCodeFunction
 
   int  ncalled;    /* Number of times function is called */
 
+  int absblock;    /* hack to emulate a block pCodes in absolute position
+                      but not inside a function */
+  int stackusage;  /* stack positions used in function */
+  
 } pCodeFunction;
 
 
@@ -681,6 +740,22 @@ typedef struct pCodeWild
 
 } pCodeWild;
 
+
+/*************************************************
+    pInfo
+    
+    Here are stored generic informaton
+*************************************************/
+typedef struct pInfo
+{
+  pCode pc;
+  
+  INFO_TYPE type;      /* info node type */
+  
+  pCodeOp *oper1;      /* info node arguments */
+} pInfo;
+  
+
 /*************************************************
     pBlock
 
@@ -841,8 +916,9 @@ typedef struct peepCommand {
 #define PCOR(x)   ((pCodeOpReg *)(x))
 #define PCOR2(x)  ((pCodeOpReg2 *)(x))
 #define PCORB(x)  ((pCodeOpRegBit *)(x))
+#define PCOO(x)   ((pCodeOpOpt *)(x))
 #define PCOW(x)   ((pCodeOpWild *)(x))
-
+#define PCOW2(x)  (PCOW(PCOW(x)->pcop2))
 #define PBR(x)    ((pBranch *)(x))
 
 #define PCWB(x)   ((pCodeWildBlock *)(x))
@@ -866,24 +942,7 @@ typedef struct peepCommand {
 #define isCALL(x)       ((isPCI(x)) && (PCI(x)->op == POC_CALL))
 #define isSTATUS_REG(r) ((r)->pc_type == PO_STATUS)
 #define isBSR_REG(r)    ((r)->pc_type == PO_BSR)
-
-#if 0
-/* these are deprecated since when creating relocatable code, the register
-   address is not known (except of course of the SFRs and the Fixed registers)
-*/
-
-
-#define isACCESS_LOW(r) ((pic16_finalMapping[REG_ADDR(r)].bank == \
-                          PIC_BANK_FIRST) && (REG_ADDR(r) < 0x80))
-#define isACCESS_HI(r)  (pic16_finalMapping[REG_ADDR(r)].bank == PIC_BANK_LAST)
-#define isACCESS_BANK(r)       (isACCESS_LOW(r) || isACCESS_HI(r))
-
-#endif
-
-//#define isACCESS_BANK(r)     (REG_ADDR(r)!= 0)
 #define isACCESS_BANK(r)       (r->accessBank)
-// && pic16_finalMapping[REG_ADDR(r)].isSFR)
-//                             || (pic16_finalMapping[(r)->rIdx].reg && pic16_finalMapping[(r)->rIdx].reg->isFixed))
 
 
 
@@ -898,6 +957,7 @@ pCode *pic16_newpCodeCharP(char *cP);              // Create a new pCode given a
 pCode *pic16_newpCodeInlineP(char *cP);            // Create a new pCode given a char *
 pCode *pic16_newpCodeFunction(char *g, char *f);   // Create a new function
 pCode *pic16_newpCodeLabel(char *name,int key);    // Create a new label given a key
+pCode *pic16_newpCodeLabelFORCE(char *name, int key); // Same as newpCodeLabel but label cannot be optimized out
 pCode *pic16_newpCodeCSource(int ln, char *f, char *l); // Create a new symbol line 
 pBlock *pic16_newpCodeChain(memmap *cm,char c, pCode *pc); // Create a new pBlock
 void pic16_printpBlock(FILE *of, pBlock *pb);      // Write a pBlock to a file
@@ -910,12 +970,19 @@ void pic16_AssignRegBanks(void);
 void pic16_printCallTree(FILE *of);
 void pCodePeepInit(void);
 void pic16_pBlockConvert2ISR(pBlock *pb);
+void pic16_pBlockConvert2Absolute(pBlock *pb);
+void pic16_initDB(void);
+void pic16_emitDB(char c, char ptype, void *p);                  // Add DB directives to a pBlock
+void pic16_emitDS(char *s, char ptype, void *p);
+void pic16_flushDB(char ptype, void *p);                         // Add pending DB data to a pBlock
+
+pCode *pic16_newpCodeAsmDir(char *asdir, char *argfmt, ...); 
 
 pCodeOp *pic16_newpCodeOpLabel(char *name, int key);
 pCodeOp *pic16_newpCodeOpImmd(char *name, int offset, int index, int code_space);
 pCodeOp *pic16_newpCodeOpLit(int lit);
-pCodeOp *pic16_newpCodeOpLit2(int lit, int lit2);
-pCodeOp *pic16_newpCodeOpBit(char *name, int bit,int inBitSpace);
+pCodeOp *pic16_newpCodeOpLit2(int lit, pCodeOp *arg2);
+pCodeOp *pic16_newpCodeOpBit(char *name, int bit,int inBitSpace, PIC_OPTYPE subt);
 pCodeOp *pic16_newpCodeOpRegFromStr(char *name);
 pCodeOp *pic16_newpCodeOp(char *name, PIC_OPTYPE p);
 pCodeOp *pic16_pCodeOpCopy(pCodeOp *pcop);
@@ -927,6 +994,8 @@ struct regs * pic16_getRegFromInstruction(pCode *pc);
 struct regs * pic16_getRegFromInstruction2(pCode *pc);
 
 extern void pic16_pcode_test(void);
+extern int pic16_debug_verbose;
+extern int pic16_pcode_verbose;
 
 /*-----------------------------------------------------------------*
  * pCode objects.
@@ -934,23 +1003,53 @@ extern void pic16_pcode_test(void);
 
 extern pCodeOpReg pic16_pc_status;
 extern pCodeOpReg pic16_pc_intcon;
-extern pCodeOpReg pic16_pc_indf0;
-extern pCodeOpReg pic16_pc_fsr0;
 extern pCodeOpReg pic16_pc_pcl;
 extern pCodeOpReg pic16_pc_pclath;
+extern pCodeOpReg pic16_pc_pclatu; // patch 14
 extern pCodeOpReg pic16_pc_wreg;
+extern pCodeOpReg pic16_pc_tosl; // patch 14
+extern pCodeOpReg pic16_pc_tosh; // patch 14
+extern pCodeOpReg pic16_pc_tosu; // patch 14
+extern pCodeOpReg pic16_pc_tblptrl; // patch 15
+extern pCodeOpReg pic16_pc_tblptrh; //
+extern pCodeOpReg pic16_pc_tblptru; //
+extern pCodeOpReg pic16_pc_tablat;  // patch 15
+extern pCodeOpReg pic16_pc_bsr;
+extern pCodeOpReg pic16_pc_fsr0;
+extern pCodeOpReg pic16_pc_fsr0l;
+extern pCodeOpReg pic16_pc_fsr0h;
 extern pCodeOpReg pic16_pc_fsr1l;
 extern pCodeOpReg pic16_pc_fsr1h;
 extern pCodeOpReg pic16_pc_fsr2l;
 extern pCodeOpReg pic16_pc_fsr2h;
+extern pCodeOpReg pic16_pc_indf0;
+extern pCodeOpReg pic16_pc_postinc0;
+extern pCodeOpReg pic16_pc_postdec0;
+extern pCodeOpReg pic16_pc_preinc0;
+extern pCodeOpReg pic16_pc_plusw0;
+extern pCodeOpReg pic16_pc_indf1;
 extern pCodeOpReg pic16_pc_postinc1;
 extern pCodeOpReg pic16_pc_postdec1;
+extern pCodeOpReg pic16_pc_preinc1;
+extern pCodeOpReg pic16_pc_plusw1;
+extern pCodeOpReg pic16_pc_indf2;
+extern pCodeOpReg pic16_pc_postinc2;
+extern pCodeOpReg pic16_pc_postdec2;
 extern pCodeOpReg pic16_pc_preinc2;
 extern pCodeOpReg pic16_pc_plusw2;
+extern pCodeOpReg pic16_pc_prodl;
+extern pCodeOpReg pic16_pc_prodh;
+
+extern pCodeOpReg pic16_pc_eecon1;
+extern pCodeOpReg pic16_pc_eecon2;
+extern pCodeOpReg pic16_pc_eedata;
+extern pCodeOpReg pic16_pc_eeadr;
 
 extern pCodeOpReg pic16_pc_kzero;
 extern pCodeOpReg pic16_pc_wsave;     /* wsave and ssave are used to save W and the Status */
 extern pCodeOpReg pic16_pc_ssave;     /* registers during an interrupt */
 
+extern pCodeOpReg pic16_pc_gpsimio;
+extern pCodeOpReg pic16_pc_gpsimio2;
 
 #endif // __PCODE_H__