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 */
47 /* Processor specific names */
50 /** Unique id for this target */
52 /** Target name used for -m */
55 /** Target name string, used for --help */
56 const char *target_name;
58 /** Specific processor for the given target family. specified by -p */
63 /** Pointer to glue function */
64 void (*do_glue)(void);
65 /** TRUE if all types of glue functions should be inserted into
66 the file that also defines main.
67 We dont want this in cases like the z80 where the startup
68 code is provided by a seperate module.
77 /* assembler related information */
80 /** Command to run and arguments (eg as-z80) */
82 /** Alternate macro based form. */
84 /** Arguments for debug mode. */
85 const char *debug_opts;
86 /** Arguments for normal assembly mode. */
87 const char *plain_opts;
88 /* print externs as global */
90 /* assembler file extension */
92 /** If non-null will be used to execute the assembler. */
93 void (*do_assemble) (set *);
97 /* linker related info */
100 /** Command to run (eg link-z80) */
102 /** Alternate macro based form. */
104 /** If non-null will be used to execute the link. */
105 void (*do_link) (void);
106 /** Extension for object files (.rel, .obj, ...) */
108 /** 1 if port needs the .lnk file, 0 otherwise */
109 const int needLinkerScript;
115 /** Default peephole rules */
117 int (*getSize)(lineNode *line);
118 bitVect * (*getRegsRead)(lineNode *line);
119 bitVect * (*getRegsWritten)(lineNode *line);
123 /** Basic type sizes */
139 /** memory regions related stuff */
142 const char *xstack_name;
143 const char *istack_name;
144 const char *code_name;
145 const char *data_name;
146 const char *idata_name;
147 const char *xdata_name;
148 const char *bit_name;
149 const char *reg_name;
150 const char *static_name;
151 const char *overlay_name;
152 const char *post_static_name;
153 const char *home_name;
154 const char *xidata_name; // initialized xdata
155 const char *xinit_name; // a code copy of xidata
156 struct memmap *default_local_map; // default location for auto vars
157 struct memmap *default_globl_map; // default location for globl vars
158 int code_ro; /* code space read-only 1=yes */
164 void (*genExtraAreaDeclaration)(FILE *, bool);
165 void (*genExtraAreaLinkOptions)(FILE *);
169 /* stack related information */
172 /** -1 for grows down (z80), +1 for grows up (mcs51) */
174 /** Extra overhead when calling between banks */
176 /** Extra overhead when the function is an ISR */
178 /** Standard overhead for a function call */
180 /** Re-enterant space */
182 /** 'banked' call overhead.
183 Mild overlap with bank_overhead */
190 /** One more than the smallest
191 mul/div operation the processor can do nativley
192 Eg if the processor has an 8 bit mul, nativebelow is 2 */
198 /** Prefix to add to a C function (eg "_") */
199 const char *fun_prefix;
201 /** Called once the processor target has been selected.
202 First chance to initalise and set any port specific variables.
203 'port' is set before calling this. May be NULL.
206 /** Parses one option + its arguments */
207 bool (*parseOption) (int *pargc, char **argv, int *i);
208 /** Optional list of automatically parsed options. Should be
209 implemented to at least show the help text correctly. */
211 /** Called after all the options have been parsed. */
212 void (*finaliseOptions) (void);
213 /** Called after the port has been selected but before any
214 options are parsed. */
215 void (*setDefaultOptions) (void);
216 /** Does the dirty work. */
217 void (*assignRegisters) (struct eBBlock **, int);
219 /** Returns the register name of a symbol.
220 Used so that 'regs' can be an incomplete type. */
221 const char *(*getRegName) (struct regs * reg);
223 /* list of keywords that are used by this
224 target (used by lexer) */
227 /* Write any port specific assembler output. */
228 void (*genAssemblerPreamble) (FILE * of);
229 /* invoked at end assembler file */
230 void (*genAssemblerEnd) (FILE * of);
232 /* Write the port specific IVT. If genIVT is NULL or if
233 * it returns zero, default (8051) IVT generation code
236 int (*genIVT) (FILE * of, symbol ** intTable, int intCount);
238 void (*genXINIT) (FILE * of);
240 /* Write port specific startup code */
241 void (*genInitStartup) (FILE * of);
243 /* parameter passing in register related functions */
244 void (*reset_regparms) (); /* reset the register count */
245 int (*reg_parm) (struct sym_link *); /* will return 1 if can be passed in register */
247 /** Process the pragma string 'sz'. Returns 0 if recognised and
248 processed, 1 otherwise. May be NULL.
250 int (*process_pragma) (const char *sz);
252 /** Mangles a support function name to reflect the calling model.
254 char *(*getMangledFunctionName) (char *szOrginial);
256 /** Returns true if the port can multiply the two types nativly
257 without using support functions.
259 bool (*hasNativeMulFor) (iCode *ic, sym_link *left, sym_link *right);
261 /** Returns true if the port has implemented certain bit
262 manipulation iCodes (RRC, RLC, SWAP, GETHBIT)
264 bool (*hasExtBitOp) (int op, int size);
266 /** Returns the relative expense of accessing a particular output
267 storage class. Larger values indicate higher expense.
269 int (*oclsExpense) (struct memmap *oclass);
271 /** If TRUE, then tprintf and !dw will be used for some initalisers
273 bool use_dw_for_init;
275 /** TRUE for targets with little endian byte ordering, FALSE for
276 targets with big endian byte ordering.
280 /* condition transformations */
281 bool lt_nge; /* transform (a < b) to !(a >= b) */
282 bool gt_nle; /* transform (a > b) to !(a <= b) */
283 bool le_ngt; /* transform (a <= b) to !(a > b) */
284 bool ge_nlt; /* transform (a >= b) to !(a < b) */
285 bool ne_neq; /* transform a != b --> ! (a == b) */
286 bool eq_nne; /* transform a == b --> ! (a != b) */
288 bool arrayInitializerSuppported;
289 bool (*cseOk) (iCode *ic, iCode *pdic);
290 builtins *builtintable; /* table of builtin functions */
291 int unqualified_pointer; /* unqualified pointers type is */
292 int reset_labelKey ; /* reset Label no 1 at the start of a function */
293 int globals_allowed ; /* global & static locals not allowed ? 0 ONLY TININative*/
294 #define PORT_MAGIC 0xAC32
295 /** Used at runtime to detect if this structure has been completly filled in. */
302 #if !OPT_DISABLE_MCS51
303 extern PORT mcs51_port;
305 #if !OPT_DISABLE_GBZ80
306 extern PORT gbz80_port;
309 extern PORT z80_port;
312 extern PORT avr_port;
314 #if !OPT_DISABLE_DS390
315 extern PORT ds390_port;
318 extern PORT pic_port;
320 #if !OPT_DISABLE_PIC16
321 extern PORT pic16_port;
323 #if !OPT_DISABLE_TININative
324 extern PORT tininative_port;
326 #if !OPT_DISABLE_XA51
327 extern PORT xa51_port;
329 #if !OPT_DISABLE_DS400
330 extern PORT ds400_port;
332 #if !OPT_DISABLE_HC08
333 extern PORT hc08_port;
336 #endif /* PORT_INCLUDE*/