* src/SDCCmain.c (linkEdit): modifications only for pic16 port,
[fw/sdcc] / src / pic16 / main.c
1 /*-------------------------------------------------------------------------
2
3   main.c - pic16 specific general functions.
4
5    Written by - Scott Dattalo scott@dattalo.com
6    Ported to PIC16 by - Martin Dubuc m.debuc@rogers.com
7     
8    Note that mlh prepended _pic16_ on the static functions.  Makes
9    it easier to set a breakpoint using the debugger.
10
11
12    This program is free software; you can redistribute it and/or modify it
13    under the terms of the GNU General Public License as published by the
14    Free Software Foundation; either version 2, or (at your option) any
15    later version.
16    
17    This program is distributed in the hope that it will be useful,
18    but WITHOUT ANY WARRANTY; without even the implied warranty of
19    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20    GNU General Public License for more details.
21    
22    You should have received a copy of the GNU General Public License
23    along with this program; if not, write to the Free Software
24    Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
25 -------------------------------------------------------------------------*/
26
27 #include "common.h"
28 #include "main.h"
29 #include "ralloc.h"
30 #include "device.h"
31 #include "SDCCutil.h"
32 #include "glue.h"
33 #include "pcode.h"
34 //#include "gen.h"
35
36
37 static char _defaultRules[] =
38 {
39 #include "peeph.rul"
40 };
41
42 /* list of key words used by pic16 */
43 static char *_pic16_keywords[] =
44 {
45   "at",
46   "bit",
47   "code",
48   "critical",
49   "data",
50   "far",
51   "idata",
52   "interrupt",
53   "near",
54   "pdata",
55   "reentrant",
56   "sfr",
57   "sbit",
58   "using",
59   "xdata",
60   "_data",
61   "_code",
62   "_generic",
63   "_near",
64   "_xdata",
65   "_pdata",
66   "_idata",
67   "_naked",
68   NULL
69 };
70
71
72 pic16_sectioninfo_t pic16_sectioninfo;
73
74
75 extern char *pic16_processor_base_name(void);
76
77 void  pic16_pCodeInitRegisters(void);
78
79 void pic16_assignRegisters (eBBlock ** ebbs, int count);
80
81 static int regParmFlg = 0;      /* determine if we can register a parameter */
82
83 pic16_options_t pic16_options;
84
85 extern set *includeDirsSet;
86 extern set *dataDirsSet;
87 extern set *libFilesSet;
88
89 /* Also defined in gen.h, but the #include is commented out */
90 /* for an unknowned reason. - EEP */
91 void pic16_emitDebuggerSymbol (char *);
92  
93 extern regs* newReg(short type, short pc_type, int rIdx, char *name, int size, int alias, operand *refop);
94 extern void pic16_emitConfigRegs(FILE *of);
95 extern void pic16_emitIDRegs(FILE *of);
96
97
98
99 static void
100 _pic16_init (void)
101 {
102         asm_addTree (&asm_asxxxx_mapping);
103         pic16_pCodeInitRegisters();
104         maxInterrupts = 2;
105
106         /* set pic16 port options to defaults */
107         pic16_options.no_banksel = 0;
108         pic16_options.opt_banksel = 0;
109         pic16_options.omit_configw = 0;
110         pic16_options.omit_ivt = 0;
111         pic16_options.leave_reset = 0;
112         pic16_options.stack_model = 0;                  /* 0 for 'small', 1 for 'large' */
113         pic16_options.ivt_loc = 0x000000;               /* default location of interrupt vectors */
114         pic16_options.nodefaultlibs = 0;                /* link default libraries */
115         pic16_options.dumpcalltree = 0;
116 }
117
118 static void
119 _pic16_reset_regparm ()
120 {
121   regParmFlg = 0;
122 }
123
124 static int
125 _pic16_regparm (sym_link * l)
126 {
127   /* for this processor it is simple
128      can pass only the first parameter in a register */
129   //if (regParmFlg)
130   //  return 0;
131
132   regParmFlg++;// = 1;
133   return 1;
134 }
135
136
137 int initsfpnt=0;                /* set to 1 if source provides a pragma for stack
138                                  * so glue() later emits code to initialize stack/frame pointers */
139 set *absSymSet;
140
141 set *sectNames=NULL;                    /* list of section listed in pragma directives */
142 set *sectSyms=NULL;                     /* list of symbols set in a specific section */
143
144
145 static int
146 _process_pragma(const char *sz)
147 {
148   static const char *WHITE = " \t\n";
149   
150   char  *ptr = strtok((char *)sz, WHITE);
151
152         /* #pragma maxram [maxram] */
153         if (startsWith (ptr, "maxram")) {
154           char *maxRAM = strtok((char *)NULL, WHITE);
155
156                 if (maxRAM != (char *)NULL) {
157                   int maxRAMaddress;
158                   value *maxRAMVal;
159
160                         maxRAMVal = constVal(maxRAM);
161                         maxRAMaddress = (int)floatFromVal(maxRAMVal);
162                         pic16_setMaxRAM(maxRAMaddress);
163                 }
164         }
165         
166         /* #pragma stack [stack-position] */
167         if(startsWith(ptr, "stack")) {
168           char *stackPosS = strtok((char *)NULL, WHITE);
169           value *stackPosVal;
170           regs *reg;
171           symbol *sym;
172
173 //              fprintf(stderr, "Initializing stack pointer to 0x%x\n", (int)floatFromVal(constVal(stackPos)));
174                 stackPosVal = constVal( stackPosS );
175                 stackPos = (unsigned int)floatFromVal( stackPosVal );
176
177                 reg=newReg(REG_SFR, PO_SFR_REGISTER, stackPos, "_stack", 1, 0, NULL);
178                 addSet(&pic16_fix_udata, reg);
179
180                 sym = newSymbol("stack", 0);
181                 sprintf(sym->rname, "_%s", sym->name);
182                 addSet(&publics, sym);
183                 
184                 initsfpnt = 1;          // force glue() to initialize stack/frame pointers */
185
186           return 0;
187         }
188         
189         /* #pragma code [symbol] [location] */
190         if(startsWith(ptr, "code")) {
191           char *symname = strtok((char *)NULL, WHITE);
192           char *location = strtok((char *)NULL, WHITE);
193           absSym *absS;
194           value *addr;
195
196                 absS = Safe_calloc(1, sizeof(absSym));
197                 absS->name = Safe_strdup( symname );
198                 addr = constVal( location );
199                 absS->address = (unsigned int)floatFromVal( addr );
200
201                 addSet(&absSymSet, absS);
202                 fprintf(stderr, "%s:%d symbol %s will be placed in location 0x%06x in code memory\n",
203                         __FILE__, __LINE__, symname, absS->address);
204
205           return 0;
206         }
207
208         /* #pragma udata [section-name] [symbol] */
209         if(startsWith(ptr, "udata")) {
210           char *sectname = strtok((char *)NULL, WHITE);
211           char *symname = strtok((char *)NULL, WHITE);
212           sectSym *ssym;
213           sectName *snam;
214           int found=0;
215           
216                 while(symname) {
217
218                         ssym = Safe_calloc(1, sizeof(sectSyms));
219                         ssym->name = Safe_calloc(1, strlen(symname)+2);
220                         sprintf(ssym->name, "_%s", symname);
221                         ssym->reg = NULL;
222
223                         addSet(&sectSyms, ssym);
224
225                         found = 0;
226                         for(snam=setFirstItem(sectNames);snam;snam=setNextItem(sectNames)) {
227                                 if(!strcmp(sectname, snam->name)){ found=1; break; }
228                         }
229                         
230                         if(!found) {
231                                 snam = Safe_calloc(1, sizeof(sectNames));
232                                 snam->name = Safe_strdup( sectname );
233                                 snam->regsSet = NULL;
234                                 
235                                 addSet(&sectNames, snam);
236                         }
237                         
238                         ssym->section = snam;
239                                 
240 //                      fprintf(stderr, "%s:%d placing symbol %s at section %s (%p)\n", __FILE__, __LINE__,
241 //                              ssym->name, snam->name, snam);
242
243                         symname = strtok((char *)NULL, WHITE);
244                 }
245
246           return 0;
247         }
248         
249   return 1;
250 }
251
252 #define REP_UDATA       "--preplace-udata-with="
253
254 #define STACK_MODEL     "--pstack-model="
255 #define OPT_BANKSEL     "--obanksel="
256
257 #define ALT_ASM         "--asm="
258 #define ALT_LINK        "--link="
259
260 #define IVT_LOC         "--ivt-loc"
261 #define NO_DEFLIBS      "--nodefaultlibs"
262
263
264 char *alt_asm=NULL;
265 char *alt_link=NULL;
266
267 extern int pic16_debug_verbose;
268 extern int pic16_ralloc_debug;
269 extern int pic16_pcode_verbose;
270
271 int pic16_enable_peeps=0;
272
273 OPTION pic16_optionsTable[]= {
274         { 0,    NO_DEFLIBS,             &pic16_options.nodefaultlibs,   "do not link default libraries when linking"},
275         { 0,    "--pno-banksel",        &pic16_options.no_banksel,      "do not generate BANKSEL assembler directives"},
276         { 0,    OPT_BANKSEL,            NULL,                           "set banksel optimization level (default=0 no)"},
277         { 0,    "--pomit-config-words", &pic16_options.omit_configw,    "omit the generation of configuration words"},
278         { 0,    "--pomit-ivt",          &pic16_options.omit_ivt,        "omit the generation of the Interrupt Vector Table"},
279         { 0,    "--pleave-reset-vector",&pic16_options.leave_reset,     "when omitting IVT leave RESET vector"},
280         { 0,    STACK_MODEL,    NULL,   "use stack model 'small' (default) or 'large'"},
281
282         { 0,    "--debug-xtra",         &pic16_debug_verbose,   "show more debug info in assembly output"},
283         { 0,    "--debug-ralloc",       &pic16_ralloc_debug,    "dump register allocator debug file *.d"},
284         { 0,    "--pcode-verbose",      &pic16_pcode_verbose,   "dump pcode related info"},
285                 
286         { 0,    REP_UDATA,      NULL,   "Place udata variables at another section: udata_acs, udata_ovr, udata_shr"},
287
288         { 0,    ALT_ASM,        NULL,   "Use alternative assembler"},
289         { 0,    ALT_LINK,       NULL,   "Use alternative linker"},
290
291         { 0,    "--denable-peeps",      &pic16_enable_peeps,    "explicit enable of peepholes"},
292         { 0,    IVT_LOC,        NULL,   "<nnnn> interrupt vector table location"},
293         { 0,    "--calltree",           &pic16_options.dumpcalltree,    "dump call tree in .calltree file"},
294         { 0,    NULL,           NULL,   NULL}
295         };
296
297
298 #define ISOPT(str)      !strncmp(argv[ *i ], str, strlen(str) )
299
300 extern char *getStringArg(const char *,  char **, int *, int);
301 extern int getIntArg(const char *, char **, int *, int);
302
303 static bool
304 _pic16_parseOptions (int *pargc, char **argv, int *i)
305 {
306   int j=0;
307   char *stkmodel;
308   
309   /* TODO: allow port-specific command line options to specify
310    * segment names here.
311    */
312         /* check for arguments that have associated an integer variable */
313         while(pic16_optionsTable[j].pparameter) {
314                 if(ISOPT( pic16_optionsTable[j].longOpt )) {
315                         (*pic16_optionsTable[j].pparameter)++;
316                         return TRUE;
317                 }
318                 j++;
319         }
320
321
322         if(ISOPT(STACK_MODEL)) {
323                 stkmodel = getStringArg(STACK_MODEL, argv, i, *pargc);
324                 if(STRCASECMP(stkmodel, "small"))pic16_options.stack_model = 0;
325                 else if(STRCASECMP(stkmodel, "large"))pic16_options.stack_model = 1;
326                 else {
327                         fprintf(stderr, "Unknown stack model: %s", stkmodel);
328                         exit(-1);
329                 }
330                 return TRUE;
331         }
332
333         if(ISOPT(OPT_BANKSEL)) {
334                 pic16_options.opt_banksel = getIntArg(OPT_BANKSEL, argv, i, *pargc);
335                 return TRUE;
336         }
337
338         if(ISOPT(REP_UDATA)) {
339                 pic16_sectioninfo.at_udata = Safe_strdup(getStringArg(REP_UDATA, argv, i, *pargc));
340                 return TRUE;
341         }
342         
343         if(ISOPT(ALT_ASM)) {
344                 alt_asm = Safe_strdup(getStringArg(ALT_ASM, argv, i, *pargc));
345                 return TRUE;
346         }
347         
348         if(ISOPT(ALT_LINK)) {
349                 alt_link = Safe_strdup(getStringArg(ALT_LINK, argv, i, *pargc));
350                 return TRUE;
351         }
352
353         if(ISOPT(IVT_LOC)) {
354                 pic16_options.ivt_loc = getIntArg(IVT_LOC, argv, i, *pargc);
355                 return TRUE;
356         }
357
358   return FALSE;
359 }
360
361 static void _pic16_initPaths(void)
362 {
363   char pic16incDir[512];
364   char pic16libDir[512];
365   set *pic16incDirsSet;
366   set *pic16libDirsSet;
367   char devlib[512];
368
369         setMainValue("mcu", pic16->name[2] );
370         addSet(&preArgvSet, Safe_strdup("-D{mcu}"));
371
372         sprintf(pic16incDir, "%s%cpic16", INCLUDE_DIR_SUFFIX, DIR_SEPARATOR_CHAR);
373         sprintf(pic16libDir, "%s%cpic16", LIB_DIR_SUFFIX, DIR_SEPARATOR_CHAR);
374
375         if(!options.nostdinc) {
376                 /* setup pic16 include directory */
377                 pic16incDirsSet = appendStrSet(dataDirsSet, NULL, pic16incDir);
378                 mergeSets(&includeDirsSet, pic16incDirsSet);
379         }
380         
381         if(!options.nostdlib) {
382                 /* setup pic16 library directory */
383                 pic16libDirsSet = appendStrSet(dataDirsSet, NULL, pic16libDir);
384                 mergeSets(&libDirsSet, pic16libDirsSet);
385
386                 if(!pic16_options.nodefaultlibs) {
387                         /* now add the library for the device */
388                         sprintf(devlib, "%s.lib", pic16->name[2]);
389                         addSet(&libFilesSet, Safe_strdup(devlib));
390                 }
391         }
392 }
393
394
395 /* forward declarations */
396 extern const char *pic16_linkCmd[];
397 extern const char *pic16_asmCmd[];
398
399 static void
400 _pic16_finaliseOptions (void)
401 {
402         port->mem.default_local_map = data;
403         port->mem.default_globl_map = data;
404
405         /* peepholes are disabled for the time being */
406         options.nopeep = 1;
407
408         /* explicit enable peepholes for testing */
409         if(pic16_enable_peeps)
410                 options.nopeep = 0;
411
412         options.all_callee_saves = 1;           // always callee saves
413 //      options.float_rent = 1;
414 //      options.intlong_rent = 1;
415         
416
417         if(alt_asm && strlen(alt_asm))
418                 pic16_asmCmd[0] = alt_asm;
419         
420         if(alt_link && strlen(alt_link))
421                 pic16_linkCmd[0] = alt_link;
422 }
423
424
425 /* all the rest is commented ifdef'd out */
426 #if 0
427   /* Hack-o-matic: if we are using the flat24 model,
428    * adjust pointer sizes.
429    */
430   if (options.model == MODEL_FLAT24)
431     {
432
433       fprintf (stderr, "*** WARNING: you should use the '-mds390' option "
434                "for DS80C390 support. This code generator is "
435                "badly out of date and probably broken.\n");
436
437       port->s.fptr_size = 3;
438       port->s.gptr_size = 4;
439       port->stack.isr_overhead++;       /* Will save dpx on ISR entry. */
440 #if 1
441       port->stack.call_overhead++;      /* This acounts for the extra byte 
442                                          * of return addres on the stack.
443                                          * but is ugly. There must be a 
444                                          * better way.
445                                          */
446 #endif
447       fReturn = fReturn390;
448       fReturnSize = 5;
449     }
450
451   if (options.model == MODEL_LARGE)
452     {
453       port->mem.default_local_map = xdata;
454       port->mem.default_globl_map = xdata;
455     }
456   else
457     {
458       port->mem.default_local_map = data;
459       port->mem.default_globl_map = data;
460     }
461
462   if (options.stack10bit)
463     {
464       if (options.model != MODEL_FLAT24)
465         {
466           fprintf (stderr,
467                    "*** warning: 10 bit stack mode is only supported in flat24 model.\n");
468           fprintf (stderr, "\t10 bit stack mode disabled.\n");
469           options.stack10bit = 0;
470         }
471       else
472         {
473           /* Fixup the memory map for the stack; it is now in
474            * far space and requires a FPOINTER to access it.
475            */
476           istack->fmap = 1;
477           istack->ptrType = FPOINTER;
478         }
479     }
480 #endif
481
482
483 static void
484 _pic16_setDefaultOptions (void)
485 {
486         /* initialize to defaults section locations, names and addresses */
487         pic16_sectioninfo.at_udata      = "udata";
488
489         /* set pic16 port options to defaults */
490         pic16_options.no_banksel = 0;
491         pic16_options.opt_banksel = 0;
492         pic16_options.omit_configw = 0;
493         pic16_options.omit_ivt = 0;
494         pic16_options.leave_reset = 0;
495         pic16_options.stack_model = 0;                  /* 0 for 'small', 1 for 'large' */
496         pic16_options.ivt_loc = 0x000000;
497         pic16_options.nodefaultlibs = 0;
498         pic16_options.dumpcalltree = 0;
499 }
500
501 static const char *
502 _pic16_getRegName (struct regs *reg)
503 {
504   if (reg)
505     return reg->name;
506   return "err";
507 }
508
509
510 #if 1
511 static  char *_pic16_mangleFunctionName(char *sz)
512 {
513 //      fprintf(stderr, "mangled function name: %s\n", sz);
514
515   return sz;
516 }
517 #endif
518
519
520 static void
521 _pic16_genAssemblerPreamble (FILE * of)
522 {
523   char *name = pic16_processor_base_name();
524
525         if(!name) {
526                 name = "p18f452";
527                 fprintf(stderr,"WARNING: No Pic has been selected, defaulting to %s\n",name);
528         }
529
530         fprintf (of, "\tlist\tp=%s\n",&name[1]);
531
532         if(!pic16_options.omit_configw) {
533                 pic16_emitConfigRegs(of);
534                 fprintf(of, "\n");
535                 pic16_emitIDRegs(of);
536         }
537         
538   fprintf (of, "\tradix dec\n");
539 }
540
541 /* Generate interrupt vector table. */
542 static int
543 _pic16_genIVT (FILE * of, symbol ** interrupts, int maxInterrupts)
544 {
545 #if 1
546         /* PIC18F family has only two interrupts, the high and the low
547          * priority interrupts, which reside at 0x0008 and 0x0018 respectively - VR */
548
549         if((!pic16_options.omit_ivt) || (pic16_options.omit_ivt && pic16_options.leave_reset)) {
550                 fprintf(of, "; RESET vector\n");
551                 fprintf(of, "\tgoto\t__sdcc_gsinit_startup\n");
552         }
553         
554         if(!pic16_options.omit_ivt) {
555                 fprintf(of, "\tres 4\n");
556
557
558                 fprintf(of, "; High priority interrupt vector 0x0008\n");
559                 if(interrupts[1]) {
560                         fprintf(of, "\tgoto\t%s\n", interrupts[1]->rname);
561                         fprintf(of, "\tres\t12\n"); 
562                 } else {
563                         fprintf(of, "\tretfie\n");
564                         fprintf(of, "\tres\t14\n");
565                 }
566
567                 fprintf(of, "; Low priority interrupt vector 0x0018\n");
568                 if(interrupts[2]) {
569                         fprintf(of, "\tgoto\t%s\n", interrupts[2]->rname);
570                 } else {
571                         fprintf(of, "\tretfie\n");
572                 }
573         }
574 #endif
575   return TRUE;
576 }
577
578 /* return True if the port can handle the type,
579  * False to convert it to function call */
580 static bool _hasNativeMulFor (iCode *ic, sym_link *left, sym_link *right)
581 {
582 //      fprintf(stderr,"checking for native mult for %c (size: %d)\n", ic->op, getSize(OP_SYMBOL(IC_RESULT(ic))->type));
583
584 #if 1
585         /* multiplication is fixed */
586         /* support mul for char/int/long */
587         if((getSize(OP_SYMBOL(IC_LEFT(ic))->type ) <= 4)
588                 && (ic->op == '*'))return TRUE;
589 #endif
590
591 #if 0
592         /* support div for char/int/long */
593         if((getSize(OP_SYMBOL(IC_LEFT(ic))->type ) <= 0)
594                 && (ic->op == '/'))return TRUE;
595 #endif
596         
597   return FALSE;
598 }
599
600
601 #if 0
602 /* Do CSE estimation */
603 static bool cseCostEstimation (iCode *ic, iCode *pdic)
604 {
605 //    operand *result = IC_RESULT(ic);
606 //    sym_link *result_type = operandType(result);
607
608
609         /* VR -- this is an adhoc. Put here after conversation
610          * with Erik Epetrich */
611
612         if(ic->op == '<'
613                 || ic->op == '>'
614                 || ic->op == EQ_OP) {
615
616                 fprintf(stderr, "%d %s\n", __LINE__, __FUNCTION__);
617           return 0;
618         }
619
620 #if 0
621     /* if it is a pointer then return ok for now */
622     if (IC_RESULT(ic) && IS_PTR(result_type)) return 1;
623
624     /* if bitwise | add & subtract then no since mcs51 is pretty good at it
625        so we will cse only if they are local (i.e. both ic & pdic belong to
626        the same basic block */
627     if (IS_BITWISE_OP(ic) || ic->op == '+' || ic->op == '-') {
628         /* then if they are the same Basic block then ok */
629         if (ic->eBBlockNum == pdic->eBBlockNum) return 1;
630         else return 0;
631     }
632 #endif
633
634     /* for others it is cheaper to do the cse */
635     return 1;
636 }
637 #endif
638
639
640 /* Indicate which extended bit operations this port supports */
641 static bool
642 hasExtBitOp (int op, int size)
643 {
644   if (op == RRC
645       || op == RLC
646       /* || op == GETHBIT */ /* GETHBIT doesn't look complete for PIC */
647      )
648     return TRUE;
649   else
650     return FALSE;
651 }
652
653 /* Indicate the expense of an access to an output storage class */
654 static int
655 oclsExpense (struct memmap *oclass)
656 {
657   /* The IN_FARSPACE test is compatible with historical behaviour, */
658   /* but I don't think it is applicable to PIC. If so, please feel */
659   /* free to remove this test -- EEP */
660   if (IN_FARSPACE(oclass))
661     return 1;
662     
663   return 0;
664 }
665
666 /** $1 is the input object file (PIC16 specific)        // >>always the basename<<.
667     $2 is always the output file.
668     $3 -L path and -l libraries
669     $l is the list of extra options that should be there somewhere...
670     MUST be terminated with a NULL.
671 */
672 const char *pic16_linkCmd[] =
673 {
674   "gplink", "$l", "-o \"$2\"", "\"$1\"","$3", NULL
675 };
676
677
678
679 /** $1 is always the basename.
680     $2 is always the output file.
681     $3 varies (nothing currently)
682     $l is the list of extra options that should be there somewhere...
683     MUST be terminated with a NULL.
684 */
685 const char *pic16_asmCmd[] =
686 {
687   "gpasm", "$l", "$3", "-c", "\"$1.asm\"", "-o \"$2\"", NULL
688
689 };
690
691 /* Globals */
692 PORT pic16_port =
693 {
694   TARGET_ID_PIC16,
695   "pic16",
696   "MCU PIC16",                  /* Target name */
697   "p18f452",                    /* Processor */
698   {
699     pic16glue,
700     TRUE,                       /* Emit glue around main */
701     MODEL_SMALL | MODEL_LARGE | MODEL_FLAT24,
702     MODEL_SMALL
703   },
704   {
705     pic16_asmCmd,               /* assembler command and arguments */
706     NULL,                       /* alternate macro based form */
707     "-g",                       /* arguments for debug mode */
708     NULL,                       /* arguments for normal mode */
709     0,                          /* print externs as global */
710     ".asm",                     /* assembler file extension */
711     NULL                        /* no do_assemble function */
712   },
713   {
714     pic16_linkCmd,              /* linker command and arguments */
715     NULL,                       /* alternate macro based form */
716     NULL,                       /* no do_link function */
717     ".o",                       /* extension for object files */
718     0                           /* no need for linker file */
719   },
720   {
721     _defaultRules
722   },
723   {
724         /* Sizes */
725     1,          /* char */
726     2,          /* short */
727     2,          /* int */
728     4,          /* long */
729     2,          /* ptr */
730     3,          /* fptr, far pointers (see Microchip) */
731     2,          /* gptr */
732     1,          /* bit */
733     4,          /* float */
734     4           /* max */
735   },
736   {
737     "XSEG    (XDATA)",          // xstack
738     "STACK   (DATA)",           // istack
739     "CSEG    (CODE)",           // code
740     "DSEG    (DATA)",           // data
741     "ISEG    (DATA)",           // idata
742     "XSEG    (XDATA)",          // xdata
743     "BSEG    (BIT)",            // bit
744     "RSEG    (DATA)",           // reg
745     "GSINIT  (CODE)",           // static
746     "OSEG    (OVR,DATA)",       // overlay
747     "GSFINAL (CODE)",           // post static
748     "HOME        (CODE)",       // home
749     NULL,                       // xidata
750     NULL,                       // xinit
751     NULL,                       // default location for auto vars
752     NULL,                       // default location for global vars
753     1                           // code is read only 1=yes
754   },
755   {
756     NULL,               /* genExtraAreaDeclaration */
757     NULL                /* genExatrAreaLinkOptions */
758   },
759   {
760         /* stack related information */
761     -1,                 /* -1 stack grows downwards, +1 upwards */
762     1,                  /* extra overhead when calling between banks */
763     4,                  /* extra overhead when the function is an ISR */
764     1,                  /* extra overhead for a function call */
765     1,                  /* re-entrant space */
766     0                   /* 'banked' call overhead, mild overlap with bank_overhead */
767   },
768     /* pic16 has an 8 bit mul */
769   {
770      0, -1
771   },
772   {
773     pic16_emitDebuggerSymbol
774   },
775   "_",
776   _pic16_init,
777   _pic16_parseOptions,
778   pic16_optionsTable,
779   _pic16_initPaths,
780   _pic16_finaliseOptions,
781   _pic16_setDefaultOptions,
782   pic16_assignRegisters,
783   _pic16_getRegName,
784   _pic16_keywords,
785   _pic16_genAssemblerPreamble,
786   NULL,                         /* no genAssemblerEnd */
787   _pic16_genIVT,
788   NULL, // _pic16_genXINIT
789   NULL,                         /* genInitStartup */
790   _pic16_reset_regparm,
791   _pic16_regparm,
792   _process_pragma,                              /* process a pragma */
793   _pic16_mangleFunctionName,                            /* mangles function name */
794   _hasNativeMulFor,
795   hasExtBitOp,                  /* hasExtBitOp */
796   oclsExpense,                  /* oclsExpense */
797   FALSE,                        
798   TRUE,                         /* little endian */
799   0,                            /* leave lt */
800   0,                            /* leave gt */
801   1,                            /* transform <= to ! > */
802   1,                            /* transform >= to ! < */
803   1,                            /* transform != to !(a == b) */
804   0,                            /* leave == */
805   FALSE,                        /* No array initializer support. */
806   0,    //cseCostEstimation,            /* !!!no CSE cost estimation yet */
807   NULL,                         /* no builtin functions */
808   GPOINTER,                     /* treat unqualified pointers as "generic" pointers */
809   1,                            /* reset labelKey to 1 */
810   1,                            /* globals & local static allowed */
811   PORT_MAGIC
812 };