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 /* pragma structure */
55 int (*func)(int id, const char *name, const char *cp);
58 /* defined in SDCClex.lex */
59 int process_pragma_tbl(const struct pragma_s *pragma_tbl, const char *s);
61 /* Processor specific names */
64 /** Unique id for this target */
66 /** Target name used for -m */
69 /** Target name string, used for --help */
70 const char *target_name;
72 /** Specific processor for the given target family. specified by -p */
77 /** Pointer to glue function */
78 void (*do_glue)(void);
79 /** TRUE if all types of glue functions should be inserted into
80 the file that also defines main.
81 We dont want this in cases like the z80 where the startup
82 code is provided by a seperate module.
91 /* assembler related information */
94 /** Command to run and arguments (eg as-z80) */
96 /** Alternate macro based form. */
98 /** Arguments for debug mode. */
99 const char *debug_opts;
100 /** Arguments for normal assembly mode. */
101 const char *plain_opts;
102 /* print externs as global */
104 /* assembler file extension */
105 const char *file_ext;
106 /** If non-null will be used to execute the assembler. */
107 void (*do_assemble) (set *);
111 /* linker related info */
114 /** Command to run (eg link-z80) */
116 /** Alternate macro based form. */
118 /** If non-null will be used to execute the link. */
119 void (*do_link) (void);
120 /** Extension for object files (.rel, .obj, ...) */
122 /** 1 if port needs the .lnk file, 0 otherwise */
123 const int needLinkerScript;
129 /** Default peephole rules */
131 int (*getSize)(lineNode *line);
132 bitVect * (*getRegsRead)(lineNode *line);
133 bitVect * (*getRegsWritten)(lineNode *line);
137 /** Basic type sizes */
142 unsigned int int_size;
146 int gptr_size; //generic
153 /** tags for far, near, xstack, code generic pointers */
163 /** memory regions related stuff */
166 const char *xstack_name;
167 const char *istack_name;
168 const char *code_name;
169 const char *data_name;
170 const char *idata_name;
171 const char *pdata_name;
172 const char *xdata_name;
173 const char *bit_name;
174 const char *reg_name;
175 const char *static_name;
176 const char *overlay_name;
177 const char *post_static_name;
178 const char *home_name;
179 const char *xidata_name; // initialized xdata
180 const char *xinit_name; // a code copy of xidata
181 const char *const_name; // const data (code or not)
182 const char *cabs_name; // const absolute data (code or not)
183 struct memmap *default_local_map; // default location for auto vars
184 struct memmap *default_globl_map; // default location for globl vars
185 int code_ro; /* code space read-only 1=yes */
191 void (*genExtraAreaDeclaration)(FILE *, bool);
192 void (*genExtraAreaLinkOptions)(FILE *);
196 /* stack related information */
199 /** -1 for grows down (z80), +1 for grows up (mcs51) */
201 /** Extra overhead when calling between banks */
203 /** Extra overhead when the function is an ISR */
205 /** Standard overhead for a function call */
207 /** Re-enterant space */
209 /** 'banked' call overhead.
210 Mild overlap with bank_overhead */
217 /** One more than the smallest
218 mul/div operation the processor can do natively
219 Eg if the processor has an 8 bit mul, native below is 2 */
227 void (*emitDebuggerSymbol) (char *);
230 int (*regNum) (struct regs *);
247 int sizeofMatchJump[3];
248 int sizeofRangeCompare[3];
254 /** Prefix to add to a C function (eg "_") */
255 const char *fun_prefix;
257 /** Called once the processor target has been selected.
258 First chance to initalise and set any port specific variables.
259 'port' is set before calling this. May be NULL.
262 /** Parses one option + its arguments */
263 bool (*parseOption) (int *pargc, char **argv, int *i);
264 /** Optional list of automatically parsed options. Should be
265 implemented to at least show the help text correctly. */
267 /** Initialise port spectific paths */
268 void (*initPaths)(void);
269 /** Called after all the options have been parsed. */
270 void (*finaliseOptions) (void);
271 /** Called after the port has been selected but before any
272 options are parsed. */
273 void (*setDefaultOptions) (void);
274 /** Does the dirty work. */
275 void (*assignRegisters) (struct ebbIndex *);
277 /** Returns the register name of a symbol.
278 Used so that 'regs' can be an incomplete type. */
279 const char *(*getRegName) (struct regs * reg);
281 /* list of keywords that are used by this
282 target (used by lexer) */
285 /* Write any port specific assembler output. */
286 void (*genAssemblerPreamble) (FILE * of);
287 /* invoked at end assembler file */
288 void (*genAssemblerEnd) (FILE * of);
290 /* Write the port specific IVT. If genIVT is NULL or if
291 * it returns zero, default (8051) IVT generation code
294 int (*genIVT) (FILE * of, symbol ** intTable, int intCount);
296 void (*genXINIT) (FILE * of);
298 /* Write port specific startup code */
299 void (*genInitStartup) (FILE * of);
301 /* parameter passing in register related functions */
302 void (*reset_regparms) (void); /* reset the register count */
303 int (*reg_parm) (struct sym_link *, bool reentrant); /* will return 1 if can be passed in register */
305 /** Process the pragma string 'sz'. Returns 0 if recognised and
306 processed, 1 otherwise. May be NULL.
308 int (*process_pragma) (const char *sz);
310 /** Mangles a support function name to reflect the calling model.
312 char *(*getMangledFunctionName) (char *szOrginial);
314 /** Returns true if the port can multiply the two types nativly
315 without using support functions.
317 bool (*hasNativeMulFor) (iCode *ic, sym_link *left, sym_link *right);
319 /** Returns true if the port has implemented certain bit
320 manipulation iCodes (RRC, RLC, SWAP, GETHBIT, GETABIT, GETBYTE, GETWORD)
322 bool (*hasExtBitOp) (int op, int size);
324 /** Returns the relative expense of accessing a particular output
325 storage class. Larger values indicate higher expense.
327 int (*oclsExpense) (struct memmap *oclass);
329 /** If TRUE, then tprintf and !dw will be used for some initalisers
331 bool use_dw_for_init;
333 /** TRUE for targets with little endian byte ordering, FALSE for
334 targets with big endian byte ordering.
338 /* condition transformations */
339 bool lt_nge; /* transform (a < b) to !(a >= b) */
340 bool gt_nle; /* transform (a > b) to !(a <= b) */
341 bool le_ngt; /* transform (a <= b) to !(a > b) */
342 bool ge_nlt; /* transform (a >= b) to !(a < b) */
343 bool ne_neq; /* transform a != b --> ! (a == b) */
344 bool eq_nne; /* transform a == b --> ! (a != b) */
346 bool arrayInitializerSuppported;
347 bool (*cseOk) (iCode *ic, iCode *pdic);
348 builtins *builtintable; /* table of builtin functions */
349 int unqualified_pointer; /* unqualified pointers type is */
350 int reset_labelKey ; /* reset Label no 1 at the start of a function */
351 int globals_allowed ; /* global & static locals not allowed ? 0 ONLY TININative*/
352 #define PORT_MAGIC 0xAC32
353 /** Used at runtime to detect if this structure has been completly filled in. */
360 #if !OPT_DISABLE_MCS51
361 extern PORT mcs51_port;
363 #if !OPT_DISABLE_GBZ80
364 extern PORT gbz80_port;
367 extern PORT z80_port;
370 extern PORT avr_port;
372 #if !OPT_DISABLE_DS390
373 extern PORT ds390_port;
376 extern PORT pic_port;
378 #if !OPT_DISABLE_PIC16
379 extern PORT pic16_port;
381 #if !OPT_DISABLE_TININative
382 extern PORT tininative_port;
384 #if !OPT_DISABLE_XA51
385 extern PORT xa51_port;
387 #if !OPT_DISABLE_DS400
388 extern PORT ds400_port;
390 #if !OPT_DISABLE_HC08
391 extern PORT hc08_port;
394 #endif /* PORT_INCLUDE*/