2 Definitions for what a port must provide.
3 All ports are referenced in SDCCmain.c.
10 #include "SDCCpeeph.h"
11 #include "mcs51/peep.h"
13 #define TARGET_ID_MCS51 1
14 #define TARGET_ID_GBZ80 2
15 #define TARGET_ID_Z80 3
16 #define TARGET_ID_AVR 4
17 #define TARGET_ID_DS390 5
18 #define TARGET_ID_PIC 6
19 #define TARGET_ID_PIC16 7
20 #define TARGET_ID_XA51 9
21 #define TARGET_ID_DS400 10
22 #define TARGET_ID_HC08 11
24 /* Macro to test the target we are compiling for.
25 Can only be used after SDCCmain has defined the port
27 #define TARGET_IS_MCS51 (port->id==TARGET_ID_MCS51)
28 #define TARGET_IS_GBZ80 (port->id==TARGET_ID_GBZ80)
29 #define TARGET_IS_Z80 (port->id==TARGET_ID_Z80)
30 #define TARGET_IS_AVR (port->id==TARGET_ID_AVR)
31 #define TARGET_IS_DS390 (port->id==TARGET_ID_DS390)
32 #define TARGET_IS_DS400 (port->id==TARGET_ID_DS400)
33 #define TARGET_IS_PIC (port->id==TARGET_ID_PIC)
34 #define TARGET_IS_PIC16 (port->id==TARGET_ID_PIC16)
35 #define TARGET_IS_XA51 (port->id==TARGET_ID_XA51)
36 #define TARGET_IS_HC08 (port->id==TARGET_ID_HC08)
38 #define MAX_BUILTIN_ARGS 16
39 /* definition of builtin functions */
40 typedef struct builtins
42 char *name; /* name of builtin function */
43 char *rtype; /* return type as string : see typefromStr */
44 int nParms; /* number of parms : max 8 */
45 char *parm_types[MAX_BUILTIN_ARGS]; /* each parm type as string : see typeFromStr */
50 /* pragma structure */
56 int (*func)(int id, const char *name, const char *cp);
59 /* defined in SDCClex.lex */
60 int process_pragma_tbl(const struct pragma_s *pragma_tbl, const char *s);
62 /* Processor specific names */
65 /** Unique id for this target */
67 /** Target name used for -m */
70 /** Target name string, used for --help */
71 const char *target_name;
73 /** Specific processor for the given target family. specified by -p */
78 /** Pointer to glue function */
79 void (*do_glue)(void);
80 /** TRUE if all types of glue functions should be inserted into
81 the file that also defines main.
82 We dont want this in cases like the z80 where the startup
83 code is provided by a seperate module.
92 /* assembler related information */
95 /** Command to run and arguments (eg as-z80) */
97 /** Alternate macro based form. */
99 /** Arguments for debug mode. */
100 const char *debug_opts;
101 /** Arguments for normal assembly mode. */
102 const char *plain_opts;
103 /* print externs as global */
105 /* assembler file extension */
106 const char *file_ext;
107 /** If non-null will be used to execute the assembler. */
108 void (*do_assemble) (set *);
112 /* linker related info */
115 /** Command to run (eg link-z80) */
117 /** Alternate macro based form. */
119 /** If non-null will be used to execute the link. */
120 void (*do_link) (void);
121 /** Extension for object files (.rel, .obj, ...) */
123 /** 1 if port needs the .lnk file, 0 otherwise */
124 const int needLinkerScript;
130 /** Default peephole rules */
132 int (*getSize)(lineNode *line);
133 bitVect * (*getRegsRead)(lineNode *line);
134 bitVect * (*getRegsWritten)(lineNode *line);
135 bool (*deadMove) (const char *op, lineNode *currPl, lineNode *head);
139 /** Basic type sizes */
144 unsigned int int_size;
148 int gptr_size; //generic
155 /** tags for far, near, xstack, code generic pointers */
165 /** memory regions related stuff */
168 const char *xstack_name;
169 const char *istack_name;
170 const char *code_name;
171 const char *data_name;
172 const char *idata_name;
173 const char *pdata_name;
174 const char *xdata_name;
175 const char *bit_name;
176 const char *reg_name;
177 const char *static_name;
178 const char *overlay_name;
179 const char *post_static_name;
180 const char *home_name;
181 const char *xidata_name; // initialized xdata
182 const char *xinit_name; // a code copy of xidata
183 const char *const_name; // const data (code or not)
184 const char *cabs_name; // const absolute data (code or not)
185 const char *xabs_name; // absolute xdata/pdata
186 const char *iabs_name; // absolute idata/data
187 struct memmap *default_local_map; // default location for auto vars
188 struct memmap *default_globl_map; // default location for globl vars
189 int code_ro; /* code space read-only 1=yes */
195 void (*genExtraAreaDeclaration)(FILE *, bool);
196 void (*genExtraAreaLinkOptions)(FILE *);
200 /* stack related information */
203 /** -1 for grows down (z80), +1 for grows up (mcs51) */
205 /** Extra overhead when calling between banks */
207 /** Extra overhead when the function is an ISR */
209 /** Standard overhead for a function call */
211 /** Re-enterant space */
213 /** 'banked' call overhead.
214 Mild overlap with bank_overhead */
221 /** One more than the smallest
222 mul/div operation the processor can do natively
223 Eg if the processor has an 8 bit mul, native below is 2 */
231 void (*emitDebuggerSymbol) (char *);
234 int (*regNum) (struct regs *);
251 int sizeofMatchJump[3];
252 int sizeofRangeCompare[3];
258 /** Prefix to add to a C function (eg "_") */
259 const char *fun_prefix;
261 /** Called once the processor target has been selected.
262 First chance to initalise and set any port specific variables.
263 'port' is set before calling this. May be NULL.
266 /** Parses one option + its arguments */
267 bool (*parseOption) (int *pargc, char **argv, int *i);
268 /** Optional list of automatically parsed options. Should be
269 implemented to at least show the help text correctly. */
271 /** Initialise port spectific paths */
272 void (*initPaths)(void);
273 /** Called after all the options have been parsed. */
274 void (*finaliseOptions) (void);
275 /** Called after the port has been selected but before any
276 options are parsed. */
277 void (*setDefaultOptions) (void);
278 /** Does the dirty work. */
279 void (*assignRegisters) (struct ebbIndex *);
281 /** Returns the register name of a symbol.
282 Used so that 'regs' can be an incomplete type. */
283 const char *(*getRegName) (struct regs * reg);
285 /* list of keywords that are used by this
286 target (used by lexer) */
289 /* Write any port specific assembler output. */
290 void (*genAssemblerPreamble) (FILE * of);
291 /* invoked at end assembler file */
292 void (*genAssemblerEnd) (FILE * of);
294 /* Write the port specific IVT. If genIVT is NULL or if
295 * it returns zero, default (8051) IVT generation code
298 int (*genIVT) (FILE * of, symbol ** intTable, int intCount);
300 void (*genXINIT) (FILE * of);
302 /* Write port specific startup code */
303 void (*genInitStartup) (FILE * of);
305 /* parameter passing in register related functions */
306 void (*reset_regparms) (void); /* reset the register count */
307 int (*reg_parm) (struct sym_link *, bool reentrant); /* will return 1 if can be passed in register */
309 /** Process the pragma string 'sz'. Returns 0 if recognised and
310 processed, 1 otherwise. May be NULL.
312 int (*process_pragma) (const char *sz);
314 /** Mangles a support function name to reflect the calling model.
316 char *(*getMangledFunctionName) (char *szOrginial);
318 /** Returns true if the port can multiply the two types nativly
319 without using support functions.
321 bool (*hasNativeMulFor) (iCode *ic, sym_link *left, sym_link *right);
323 /** Returns true if the port has implemented certain bit
324 manipulation iCodes (RRC, RLC, SWAP, GETHBIT, GETABIT, GETBYTE, GETWORD)
326 bool (*hasExtBitOp) (int op, int size);
328 /** Returns the relative expense of accessing a particular output
329 storage class. Larger values indicate higher expense.
331 int (*oclsExpense) (struct memmap *oclass);
333 /** If TRUE, then tprintf and !dw will be used for some initalisers
335 bool use_dw_for_init;
337 /** TRUE for targets with little endian byte ordering, FALSE for
338 targets with big endian byte ordering.
342 /* condition transformations */
343 bool lt_nge; /* transform (a < b) to !(a >= b) */
344 bool gt_nle; /* transform (a > b) to !(a <= b) */
345 bool le_ngt; /* transform (a <= b) to !(a > b) */
346 bool ge_nlt; /* transform (a >= b) to !(a < b) */
347 bool ne_neq; /* transform a != b --> ! (a == b) */
348 bool eq_nne; /* transform a == b --> ! (a != b) */
350 bool arrayInitializerSuppported;
351 bool (*cseOk) (iCode *ic, iCode *pdic);
352 builtins *builtintable; /* table of builtin functions */
353 int unqualified_pointer; /* unqualified pointers type is */
354 int reset_labelKey ; /* reset Label no 1 at the start of a function */
355 int globals_allowed ; /* global & static locals not allowed ? 0 ONLY TININative*/
356 #define PORT_MAGIC 0xAC32
357 /** Used at runtime to detect if this structure has been completly filled in. */
364 #if !OPT_DISABLE_MCS51
365 extern PORT mcs51_port;
367 #if !OPT_DISABLE_GBZ80
368 extern PORT gbz80_port;
371 extern PORT z80_port;
374 extern PORT avr_port;
376 #if !OPT_DISABLE_DS390
377 extern PORT ds390_port;
380 extern PORT pic_port;
382 #if !OPT_DISABLE_PIC16
383 extern PORT pic16_port;
385 #if !OPT_DISABLE_TININative
386 extern PORT tininative_port;
388 #if !OPT_DISABLE_XA51
389 extern PORT xa51_port;
391 #if !OPT_DISABLE_DS400
392 extern PORT ds400_port;
394 #if !OPT_DISABLE_HC08
395 extern PORT hc08_port;
398 #endif /* PORT_INCLUDE*/