2 Definitions for what a port must provide.
3 All ports are referenced in SDCCmain.c.
11 #define TARGET_ID_MCS51 1
12 #define TARGET_ID_GBZ80 2
13 #define TARGET_ID_Z80 3
14 #define TARGET_ID_AVR 4
15 #define TARGET_ID_DS390 5
16 #define TARGET_ID_PIC 6
17 #define TARGET_ID_PIC16 7
18 #define TARGET_ID_XA51 9
19 #define TARGET_ID_DS400 10
20 #define TARGET_ID_HC08 11
22 /* Macro to test the target we are compiling for.
23 Can only be used after SDCCmain has defined the port
25 #define TARGET_IS_MCS51 (port->id==TARGET_ID_MCS51)
26 #define TARGET_IS_GBZ80 (port->id==TARGET_ID_GBZ80)
27 #define TARGET_IS_Z80 (port->id==TARGET_ID_Z80)
28 #define TARGET_IS_AVR (port->id==TARGET_ID_AVR)
29 #define TARGET_IS_DS390 (port->id==TARGET_ID_DS390)
30 #define TARGET_IS_DS400 (port->id==TARGET_ID_DS400)
31 #define TARGET_IS_PIC (port->id==TARGET_ID_PIC)
32 #define TARGET_IS_PIC16 (port->id==TARGET_ID_PIC16)
33 #define TARGET_IS_XA51 (port->id==TARGET_ID_XA51)
34 #define TARGET_IS_HC08 (port->id==TARGET_ID_HC08)
36 #define MAX_BUILTIN_ARGS 16
37 /* definition of builtin functions */
38 typedef struct builtins
40 char *name ; /* name of builtin function */
41 char *rtype; /* return type as string : see typefromStr */
42 int nParms; /* number of parms : max 8 */
43 char *parm_types[MAX_BUILTIN_ARGS]; /* each parm type as string : see typeFromStr */
46 /* Processor specific names */
49 /** Unique id for this target */
51 /** Target name used for -m */
54 /** Target name string, used for --help */
55 const char *target_name;
57 /** Specific processor for the given target family. specified by -p */
62 /** Pointer to glue function */
63 void (*do_glue)(void);
64 /** TRUE if all types of glue functions should be inserted into
65 the file that also defines main.
66 We dont want this in cases like the z80 where the startup
67 code is provided by a seperate module.
76 /* assembler related information */
79 /** Command to run and arguments (eg as-z80) */
81 /** Alternate macro based form. */
83 /** Arguments for debug mode. */
84 const char *debug_opts;
85 /** Arguments for normal assembly mode. */
86 const char *plain_opts;
87 /* print externs as global */
89 /* assembler file extension */
91 /** If non-null will be used to execute the assembler. */
92 void (*do_assemble) (set *);
96 /* linker related info */
99 /** Command to run (eg link-z80) */
101 /** Alternate macro based form. */
103 /** If non-null will be used to execute the link. */
104 void (*do_link) (void);
105 /** Extension for object files (.rel, .obj, ...) */
107 /** 1 if port needs the .lnk file, 0 otherwise */
108 const int needLinkerScript;
114 /** Default peephole rules */
119 /** Basic type sizes */
135 /** memory regions related stuff */
138 const char *xstack_name;
139 const char *istack_name;
140 const char *code_name;
141 const char *data_name;
142 const char *idata_name;
143 const char *xdata_name;
144 const char *bit_name;
145 const char *reg_name;
146 const char *static_name;
147 const char *overlay_name;
148 const char *post_static_name;
149 const char *home_name;
150 const char *xidata_name; // initialized xdata
151 const char *xinit_name; // a code copy of xidata
152 struct memmap *default_local_map; // default location for auto vars
153 struct memmap *default_globl_map; // default location for globl vars
154 int code_ro; /* code space read-only 1=yes */
160 void (*genExtraAreaDeclaration)(FILE *, bool);
161 void (*genExtraAreaLinkOptions)(FILE *);
165 /* stack related information */
168 /** -1 for grows down (z80), +1 for grows up (mcs51) */
170 /** Extra overhead when calling between banks */
172 /** Extra overhead when the function is an ISR */
174 /** Standard overhead for a function call */
176 /** Re-enterant space */
178 /** 'banked' call overhead.
179 Mild overlap with bank_overhead */
186 /** One more than the smallest
187 mul/div operation the processor can do nativley
188 Eg if the processor has an 8 bit mul, nativebelow is 2 */
194 /** Prefix to add to a C function (eg "_") */
195 const char *fun_prefix;
197 /** Called once the processor target has been selected.
198 First chance to initalise and set any port specific variables.
199 'port' is set before calling this. May be NULL.
202 /** Parses one option + its arguments */
203 bool (*parseOption) (int *pargc, char **argv, int *i);
204 /** Optional list of automatically parsed options. Should be
205 implemented to at least show the help text correctly. */
207 /** Called after all the options have been parsed. */
208 void (*finaliseOptions) (void);
209 /** Called after the port has been selected but before any
210 options are parsed. */
211 void (*setDefaultOptions) (void);
212 /** Does the dirty work. */
213 void (*assignRegisters) (struct eBBlock **, int);
215 /** Returns the register name of a symbol.
216 Used so that 'regs' can be an incomplete type. */
217 const char *(*getRegName) (struct regs * reg);
219 /* list of keywords that are used by this
220 target (used by lexer) */
223 /* Write any port specific assembler output. */
224 void (*genAssemblerPreamble) (FILE * of);
225 /* invoked at end assembler file */
226 void (*genAssemblerEnd) (FILE * of);
228 /* Write the port specific IVT. If genIVT is NULL or if
229 * it returns zero, default (8051) IVT generation code
232 int (*genIVT) (FILE * of, symbol ** intTable, int intCount);
234 void (*genXINIT) (FILE * of);
236 /* parameter passing in register related functions */
237 void (*reset_regparms) (); /* reset the register count */
238 int (*reg_parm) (struct sym_link *); /* will return 1 if can be passed in register */
240 /** Process the pragma string 'sz'. Returns 0 if recognised and
241 processed, 1 otherwise. May be NULL.
243 int (*process_pragma) (const char *sz);
245 /** Mangles a support function name to reflect the calling model.
247 char *(*getMangledFunctionName) (char *szOrginial);
249 /** Returns true if the port can multiply the two types nativly
250 without using support functions.
252 bool (*hasNativeMulFor) (iCode *ic, sym_link *left, sym_link *right);
254 /** Returns true if the port has implemented certain bit
255 manipulation iCodes (RRC, RLC, SWAP, GETHBIT)
257 bool (*hasExtBitOp) (int op, int size);
259 /** Returns the relative expense of accessing a particular output
260 storage class. Larger values indicate higher expense.
262 int (*oclsExpense) (struct memmap *oclass);
264 /** If TRUE, then tprintf and !dw will be used for some initalisers
266 bool use_dw_for_init;
268 /** TRUE for targets with little endian byte ordering, FALSE for
269 targets with big endian byte ordering.
273 /* condition transformations */
274 bool lt_nge; /* transform (a < b) to !(a >= b) */
275 bool gt_nle; /* transform (a > b) to !(a <= b) */
276 bool le_ngt; /* transform (a <= b) to !(a > b) */
277 bool ge_nlt; /* transform (a >= b) to !(a < b) */
278 bool ne_neq; /* transform a != b --> ! (a == b) */
279 bool eq_nne; /* transform a == b --> ! (a != b) */
281 bool arrayInitializerSuppported;
282 bool (*cseOk) (iCode *ic, iCode *pdic);
283 builtins *builtintable; /* table of builtin functions */
284 int unqualified_pointer; /* unqualified pointers type is */
285 int reset_labelKey ; /* reset Label no 1 at the start of a function */
286 int globals_allowed ; /* global & static locals not allowed ? 0 ONLY TININative*/
287 #define PORT_MAGIC 0xAC32
288 /** Used at runtime to detect if this structure has been completly filled in. */
295 #if !OPT_DISABLE_MCS51
296 extern PORT mcs51_port;
298 #if !OPT_DISABLE_GBZ80
299 extern PORT gbz80_port;
302 extern PORT z80_port;
305 extern PORT avr_port;
307 #if !OPT_DISABLE_DS390
308 extern PORT ds390_port;
311 extern PORT pic_port;
313 #if !OPT_DISABLE_PIC16
314 extern PORT pic16_port;
316 #if !OPT_DISABLE_TININative
317 extern PORT tininative_port;
319 #if !OPT_DISABLE_XA51
320 extern PORT xa51_port;
322 #if !OPT_DISABLE_DS400
323 extern PORT ds400_port;
325 #if !OPT_DISABLE_HC08
326 extern PORT hc08_port;
329 #endif /* PORT_INCLUDE*/