X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=src%2Fpic16%2Fgen.h;h=437fa83b72cf5e5beb99a6e4eb082f58d43b7324;hb=80972b2e54c9b88f11c27b878874fd2a6a681391;hp=84af5945cfec479c45eaafd117b94c130f7f0678;hpb=35dd84251b9d153bb48ad98be9c5eae77799cb42;p=fw%2Fsdcc diff --git a/src/pic16/gen.h b/src/pic16/gen.h index 84af5945..437fa83b 100644 --- a/src/pic16/gen.h +++ b/src/pic16/gen.h @@ -27,6 +27,12 @@ #ifndef SDCCGENPIC16_H #define SDCCGENPIC16_H +/* If you change these, you also have to update the library files + * device/lib/pic16/libsdcc/gptr{get,put}{1,2,3,4}.c */ +#define GPTR_TAG_DATA 0x80 +#define GPTR_TAG_EEPROM 0x40 +#define GPTR_TAG_CODE 0x00 /* must be 0 becaue of UPPER(sym)==0 */ + struct pCodeOp; enum @@ -34,18 +40,10 @@ enum AOP_LIT = 1, AOP_REG, AOP_DIR, - AOP_DPTR, - AOP_DPTR2, - AOP_R0, - AOP_R1, AOP_STK, - AOP_IMMD, AOP_STR, AOP_CRY, AOP_ACC, - AOP_FSR0, - AOP_FSR1, - AOP_FSR2, AOP_PCODE, AOP_STA // asmop on stack }; @@ -60,12 +58,8 @@ typedef struct asmop AOP_LIT - operand is a literal value AOP_REG - is in registers AOP_DIR - direct just a name - AOP_DPTR - dptr contains address of operand - AOP_DPTR2 - dptr2 contains address of operand (DS80C390 only). - AOP_R0/R1 - r0/r1 contains address of operand AOP_STK - should be pushed on stack this can happen only for the result - AOP_IMMD - immediate value for eg. remateriazable AOP_CRY - carry contains the value of this AOP_STR - array of strings AOP_ACC - result is in the acc:b pair @@ -81,7 +75,6 @@ typedef struct asmop regs *aop_reg[4]; /* array of registers */ char *aop_dir; /* if direct */ regs *aop_ptr; /* either -> to r0 or r1 */ - char *aop_immd; /* if immediate others are implied */ int aop_stk; /* stack offset when AOP_STK */ char *aop_str[4]; /* just a string array containing the location */ /* regs *aop_alloc_reg; * points to a dynamically allocated register */ @@ -103,17 +96,10 @@ extern unsigned pic16_fReturnSizePic; #define AOP(op) op->aop #define AOP_TYPE(op) AOP(op)->type #define AOP_SIZE(op) AOP(op)->size -#define IS_AOP_PREG(x) (AOP(x) && (AOP_TYPE(x) == AOP_R1 || \ - AOP_TYPE(x) == AOP_R0)) #define AOP_NEEDSACC(x) (AOP(x) && (AOP_TYPE(x) == AOP_CRY || \ - AOP_TYPE(x) == AOP_DPTR || AOP_TYPE(x) == AOP_DPTR2 || \ AOP(x)->paged)) -#define AOP_INPREG(x) (x && (x->type == AOP_REG && \ - (x->aopu.aop_reg[0] == pic16_regWithIdx(R0_IDX) || \ - x->aopu.aop_reg[0] == pic16_regWithIdx(R1_IDX) ))) - #define RESULTONSTACK(x) \ (IC_RESULT(x) && IC_RESULT(x)->aop && \ IC_RESULT(x)->aop->type == AOP_STK ) @@ -156,7 +142,8 @@ extern unsigned pic16_fReturnSizePic; #define emitTOGC pic16_emitpcode(POC_BTG, pic16_popCopyGPR2Bit(PCOP(&pic16_pc_status),PIC_C_BIT)) int pic16_getDataSize(operand *op); -void pic16_emitpcode(PIC_OPCODE poc, pCodeOp *pcop); +void pic16_emitpcode_real(PIC_OPCODE poc, pCodeOp *pcop); +#define pic16_emitpcode(poc,pcop) do { if (pic16_pcode_verbose) pic16_emitpcomment ("%s:%u(%s):", __FILE__, __LINE__, __FUNCTION__); pic16_emitpcode_real(poc,pcop); } while(0) void pic16_emitpLabel(int key); void pic16_emitcode (char *inst,char *fmt, ...); void DEBUGpic16_emitcode (char *inst,char *fmt, ...); @@ -180,7 +167,7 @@ void pic16_genLeftShiftLiteral (operand *left, operand *right, operand *result, pCodeOp *pic16_popGet2p(pCodeOp *src, pCodeOp *dst); void pic16_emitpcomment (char *fmt, ...); -pCodeOp *pic16_popGetLabel(unsigned int key); +pCodeOp *pic16_popGetLabel(int key); pCodeOp *pic16_popCopyReg(pCodeOpReg *pc); pCodeOp *pic16_popCopyGPR2Bit(pCodeOp *pc, int bitval); pCodeOp *pic16_popGetLit(int lit); @@ -188,7 +175,7 @@ pCodeOp *pic16_popGetLit2(int lit, pCodeOp *arg2); pCodeOp *popGetWithString(char *str); pCodeOp *pic16_popGet (asmop *aop, int offset);//, bool bit16, bool dname); pCodeOp *pic16_popGetTempReg(int lock); -pCodeOp *pic16_popGetTempRegCond(bitVect *, int lock); +pCodeOp *pic16_popGetTempRegCond(bitVect *, bitVect *, int lock); void pic16_popReleaseTempReg(pCodeOp *pcop, int lock); pCodeOp *pic16_popCombine2(pCodeOpReg *src, pCodeOpReg *dst, int noalloc); @@ -202,23 +189,35 @@ void pic16_freeAsmop (operand *op, asmop *aaop, iCode *ic, bool pop); const char *pic16_pCodeOpType( pCodeOp *pcop); int pic16_my_powof2 (unsigned long num); -void mov2w (asmop *aop, int offset); +void pic16_mov2w (asmop *aop, int offset); +void pic16_mov2f(asmop *dst, asmop *src, int offset); + +bool pic16_isLitOp(operand *op); +bool pic16_isLitAop(asmop *aop); void dumpiCode(iCode *lic); int inWparamList(char *s); +#include "device.h" + #define DUMP_FUNCTION_ENTRY 1 #define DUMP_FUNCTION_EXIT 0 #if DUMP_FUNCTION_ENTRY -#define FENTRY pic16_emitpcomment("**{\t%d %s", __LINE__, __FUNCTION__) +#define FENTRY if(pic16_options.debgen&2)pic16_emitpcomment("**{\t%d %s", __LINE__, __FUNCTION__) #define FENTRY2 if(pic16_options.debgen&2)pic16_emitpcomment("**{\t%d %s", __LINE__, __FUNCTION__) +#else +#define FENTRY +#define FENTRY2 #endif #if DUMP_FUNCTION_EXIT -#define FEXIT pic16_emitpcomment("; **}", "%d %s", __LINE__, __FUNCTION__) +#define FEXIT if(pic16_options.debgen&2)pic16_emitpcomment("; **}", "%d %s", __LINE__, __FUNCTION__) #define FEXIT2 if(pic16_options.debgen&2)pic16_emitpcomment("**{\t%d %s", __LINE__, __FUNCTION__) +#else +#define FEXIT +#define FEXIT2 #endif #define ERROR werror(W_POSSBUG2, __FILE__, __LINE__)