2 Definitions for what a port must provide.
3 All ports are referenced in SDCCmain.c.
10 #include "SDCCpeeph.h"
12 #define TARGET_ID_MCS51 1
13 #define TARGET_ID_GBZ80 2
14 #define TARGET_ID_Z80 3
15 #define TARGET_ID_AVR 4
16 #define TARGET_ID_DS390 5
17 #define TARGET_ID_PIC 6
18 #define TARGET_ID_PIC16 7
19 #define TARGET_ID_XA51 9
20 #define TARGET_ID_DS400 10
21 #define TARGET_ID_HC08 11
23 /* Macro to test the target we are compiling for.
24 Can only be used after SDCCmain has defined the port
26 #define TARGET_IS_MCS51 (port->id==TARGET_ID_MCS51)
27 #define TARGET_IS_GBZ80 (port->id==TARGET_ID_GBZ80)
28 #define TARGET_IS_Z80 (port->id==TARGET_ID_Z80)
29 #define TARGET_IS_AVR (port->id==TARGET_ID_AVR)
30 #define TARGET_IS_DS390 (port->id==TARGET_ID_DS390)
31 #define TARGET_IS_DS400 (port->id==TARGET_ID_DS400)
32 #define TARGET_IS_PIC (port->id==TARGET_ID_PIC)
33 #define TARGET_IS_PIC16 (port->id==TARGET_ID_PIC16)
34 #define TARGET_IS_XA51 (port->id==TARGET_ID_XA51)
35 #define TARGET_IS_HC08 (port->id==TARGET_ID_HC08)
37 #define MAX_BUILTIN_ARGS 16
38 /* definition of builtin functions */
39 typedef struct builtins
41 char *name ; /* name of builtin function */
42 char *rtype; /* return type as string : see typefromStr */
43 int nParms; /* number of parms : max 8 */
44 char *parm_types[MAX_BUILTIN_ARGS]; /* each parm type as string : see typeFromStr */
49 /* Processor specific names */
52 /** Unique id for this target */
54 /** Target name used for -m */
57 /** Target name string, used for --help */
58 const char *target_name;
60 /** Specific processor for the given target family. specified by -p */
65 /** Pointer to glue function */
66 void (*do_glue)(void);
67 /** TRUE if all types of glue functions should be inserted into
68 the file that also defines main.
69 We dont want this in cases like the z80 where the startup
70 code is provided by a seperate module.
79 /* assembler related information */
82 /** Command to run and arguments (eg as-z80) */
84 /** Alternate macro based form. */
86 /** Arguments for debug mode. */
87 const char *debug_opts;
88 /** Arguments for normal assembly mode. */
89 const char *plain_opts;
90 /* print externs as global */
92 /* assembler file extension */
94 /** If non-null will be used to execute the assembler. */
95 void (*do_assemble) (set *);
99 /* linker related info */
102 /** Command to run (eg link-z80) */
104 /** Alternate macro based form. */
106 /** If non-null will be used to execute the link. */
107 void (*do_link) (void);
108 /** Extension for object files (.rel, .obj, ...) */
110 /** 1 if port needs the .lnk file, 0 otherwise */
111 const int needLinkerScript;
117 /** Default peephole rules */
119 int (*getSize)(lineNode *line);
120 bitVect * (*getRegsRead)(lineNode *line);
121 bitVect * (*getRegsWritten)(lineNode *line);
125 /** Basic type sizes */
130 unsigned int int_size;
134 int gptr_size; //generic
141 /** tags for far, near, xstack, code generic pointers */
151 /** memory regions related stuff */
154 const char *xstack_name;
155 const char *istack_name;
156 const char *code_name;
157 const char *data_name;
158 const char *idata_name;
159 const char *pdata_name;
160 const char *xdata_name;
161 const char *bit_name;
162 const char *reg_name;
163 const char *static_name;
164 const char *overlay_name;
165 const char *post_static_name;
166 const char *home_name;
167 const char *xidata_name; // initialized xdata
168 const char *xinit_name; // a code copy of xidata
169 const char *const_name; // const data (code or not)
170 struct memmap *default_local_map; // default location for auto vars
171 struct memmap *default_globl_map; // default location for globl vars
172 int code_ro; /* code space read-only 1=yes */
178 void (*genExtraAreaDeclaration)(FILE *, bool);
179 void (*genExtraAreaLinkOptions)(FILE *);
183 /* stack related information */
186 /** -1 for grows down (z80), +1 for grows up (mcs51) */
188 /** Extra overhead when calling between banks */
190 /** Extra overhead when the function is an ISR */
192 /** Standard overhead for a function call */
194 /** Re-enterant space */
196 /** 'banked' call overhead.
197 Mild overlap with bank_overhead */
204 /** One more than the smallest
205 mul/div operation the processor can do nativley
206 Eg if the processor has an 8 bit mul, nativebelow is 2 */
214 void (*emitDebuggerSymbol) (char *);
217 int (*regNum) (struct regs *);
234 int sizeofMatchJump[3];
235 int sizeofRangeCompare[3];
241 /** Prefix to add to a C function (eg "_") */
242 const char *fun_prefix;
244 /** Called once the processor target has been selected.
245 First chance to initalise and set any port specific variables.
246 'port' is set before calling this. May be NULL.
249 /** Parses one option + its arguments */
250 bool (*parseOption) (int *pargc, char **argv, int *i);
251 /** Optional list of automatically parsed options. Should be
252 implemented to at least show the help text correctly. */
254 /** Initialise port spectific paths */
255 void (*initPaths)(void);
256 /** Called after all the options have been parsed. */
257 void (*finaliseOptions) (void);
258 /** Called after the port has been selected but before any
259 options are parsed. */
260 void (*setDefaultOptions) (void);
261 /** Does the dirty work. */
262 void (*assignRegisters) (struct ebbIndex *);
264 /** Returns the register name of a symbol.
265 Used so that 'regs' can be an incomplete type. */
266 const char *(*getRegName) (struct regs * reg);
268 /* list of keywords that are used by this
269 target (used by lexer) */
272 /* Write any port specific assembler output. */
273 void (*genAssemblerPreamble) (FILE * of);
274 /* invoked at end assembler file */
275 void (*genAssemblerEnd) (FILE * of);
277 /* Write the port specific IVT. If genIVT is NULL or if
278 * it returns zero, default (8051) IVT generation code
281 int (*genIVT) (FILE * of, symbol ** intTable, int intCount);
283 void (*genXINIT) (FILE * of);
285 /* Write port specific startup code */
286 void (*genInitStartup) (FILE * of);
288 /* parameter passing in register related functions */
289 void (*reset_regparms) (void); /* reset the register count */
290 int (*reg_parm) (struct sym_link *, bool reentrant); /* will return 1 if can be passed in register */
292 /** Process the pragma string 'sz'. Returns 0 if recognised and
293 processed, 1 otherwise. May be NULL.
295 int (*process_pragma) (const char *sz);
297 /** Mangles a support function name to reflect the calling model.
299 char *(*getMangledFunctionName) (char *szOrginial);
301 /** Returns true if the port can multiply the two types nativly
302 without using support functions.
304 bool (*hasNativeMulFor) (iCode *ic, sym_link *left, sym_link *right);
306 /** Returns true if the port has implemented certain bit
307 manipulation iCodes (RRC, RLC, SWAP, GETHBIT, GETABIT, GETBYTE, GETWORD)
309 bool (*hasExtBitOp) (int op, int size);
311 /** Returns the relative expense of accessing a particular output
312 storage class. Larger values indicate higher expense.
314 int (*oclsExpense) (struct memmap *oclass);
316 /** If TRUE, then tprintf and !dw will be used for some initalisers
318 bool use_dw_for_init;
320 /** TRUE for targets with little endian byte ordering, FALSE for
321 targets with big endian byte ordering.
325 /* condition transformations */
326 bool lt_nge; /* transform (a < b) to !(a >= b) */
327 bool gt_nle; /* transform (a > b) to !(a <= b) */
328 bool le_ngt; /* transform (a <= b) to !(a > b) */
329 bool ge_nlt; /* transform (a >= b) to !(a < b) */
330 bool ne_neq; /* transform a != b --> ! (a == b) */
331 bool eq_nne; /* transform a == b --> ! (a != b) */
333 bool arrayInitializerSuppported;
334 bool (*cseOk) (iCode *ic, iCode *pdic);
335 builtins *builtintable; /* table of builtin functions */
336 int unqualified_pointer; /* unqualified pointers type is */
337 int reset_labelKey ; /* reset Label no 1 at the start of a function */
338 int globals_allowed ; /* global & static locals not allowed ? 0 ONLY TININative*/
339 #define PORT_MAGIC 0xAC32
340 /** Used at runtime to detect if this structure has been completly filled in. */
347 #if !OPT_DISABLE_MCS51
348 extern PORT mcs51_port;
350 #if !OPT_DISABLE_GBZ80
351 extern PORT gbz80_port;
354 extern PORT z80_port;
357 extern PORT avr_port;
359 #if !OPT_DISABLE_DS390
360 extern PORT ds390_port;
363 extern PORT pic_port;
365 #if !OPT_DISABLE_PIC16
366 extern PORT pic16_port;
368 #if !OPT_DISABLE_TININative
369 extern PORT tininative_port;
371 #if !OPT_DISABLE_XA51
372 extern PORT xa51_port;
374 #if !OPT_DISABLE_DS400
375 extern PORT ds400_port;
377 #if !OPT_DISABLE_HC08
378 extern PORT hc08_port;
381 #endif /* PORT_INCLUDE*/