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, ...) */
112 /** Default peephole rules */
117 /** Basic type sizes */
133 /** memory regions related stuff */
136 const char *xstack_name;
137 const char *istack_name;
138 const char *code_name;
139 const char *data_name;
140 const char *idata_name;
141 const char *xdata_name;
142 const char *bit_name;
143 const char *reg_name;
144 const char *static_name;
145 const char *overlay_name;
146 const char *post_static_name;
147 const char *home_name;
148 const char *xidata_name; // initialized xdata
149 const char *xinit_name; // a code copy of xidata
150 struct memmap *default_local_map; // default location for auto vars
151 struct memmap *default_globl_map; // default location for globl vars
152 int code_ro; /* code space read-only 1=yes */
158 void (*genExtraAreaDeclaration)(FILE *, bool);
159 void (*genExtraAreaLinkOptions)(FILE *);
163 /* stack related information */
166 /** -1 for grows down (z80), +1 for grows up (mcs51) */
168 /** Extra overhead when calling between banks */
170 /** Extra overhead when the function is an ISR */
172 /** Standard overhead for a function call */
174 /** Re-enterant space */
176 /** 'banked' call overhead.
177 Mild overlap with bank_overhead */
184 /** One more than the smallest
185 mul/div operation the processor can do nativley
186 Eg if the processor has an 8 bit mul, nativebelow is 2 */
192 /** Prefix to add to a C function (eg "_") */
193 const char *fun_prefix;
195 /** Called once the processor target has been selected.
196 First chance to initalise and set any port specific variables.
197 'port' is set before calling this. May be NULL.
200 /** Parses one option + its arguments */
201 bool (*parseOption) (int *pargc, char **argv, int *i);
202 /** Optional list of automatically parsed options. Should be
203 implemented to at least show the help text correctly. */
205 /** Called after all the options have been parsed. */
206 void (*finaliseOptions) (void);
207 /** Called after the port has been selected but before any
208 options are parsed. */
209 void (*setDefaultOptions) (void);
210 /** Does the dirty work. */
211 void (*assignRegisters) (struct eBBlock **, int);
213 /** Returns the register name of a symbol.
214 Used so that 'regs' can be an incomplete type. */
215 const char *(*getRegName) (struct regs * reg);
217 /* list of keywords that are used by this
218 target (used by lexer) */
221 /* Write any port specific assembler output. */
222 void (*genAssemblerPreamble) (FILE * of);
223 /* invoked at end assembler file */
224 void (*genAssemblerEnd) (FILE * of);
226 /* Write the port specific IVT. If genIVT is NULL or if
227 * it returns zero, default (8051) IVT generation code
230 int (*genIVT) (FILE * of, symbol ** intTable, int intCount);
232 void (*genXINIT) (FILE * of);
234 /* parameter passing in register related functions */
235 void (*reset_regparms) (); /* reset the register count */
236 int (*reg_parm) (struct sym_link *); /* will return 1 if can be passed in register */
238 /** Process the pragma string 'sz'. Returns 0 if recognised and
239 processed, 1 otherwise. May be NULL.
241 int (*process_pragma) (const char *sz);
243 /** Mangles a support function name to reflect the calling model.
245 char *(*getMangledFunctionName) (char *szOrginial);
247 /** Returns true if the port can multiply the two types nativly
248 without using support functions.
250 bool (*hasNativeMulFor) (iCode *ic, sym_link *left, sym_link *right);
252 /** Returns true if the port has implemented certain bit
253 manipulation iCodes (RRC, RLC, SWAP, GETHBIT)
255 bool (*hasExtBitOp) (int op, int size);
257 /** Returns the relative expense of accessing a particular output
258 storage class. Larger values indicate higher expense.
260 int (*oclsExpense) (struct memmap *oclass);
262 /** If TRUE, then tprintf and !dw will be used for some initalisers
264 bool use_dw_for_init;
266 /** TRUE for targets with little endian byte ordering, FALSE for
267 targets with big endian byte ordering.
271 /* condition transformations */
272 bool lt_nge; /* transform (a < b) to !(a >= b) */
273 bool gt_nle; /* transform (a > b) to !(a <= b) */
274 bool le_ngt; /* transform (a <= b) to !(a > b) */
275 bool ge_nlt; /* transform (a >= b) to !(a < b) */
276 bool ne_neq; /* transform a != b --> ! (a == b) */
277 bool eq_nne; /* transform a == b --> ! (a != b) */
279 bool arrayInitializerSuppported;
280 bool (*cseOk) (iCode *ic, iCode *pdic);
281 builtins *builtintable; /* table of builtin functions */
282 int unqualified_pointer; /* unqualified pointers type is */
283 int reset_labelKey ; /* reset Label no 1 at the start of a function */
284 int globals_allowed ; /* global & static locals not allowed ? 0 ONLY TININative*/
285 #define PORT_MAGIC 0xAC32
286 /** Used at runtime to detect if this structure has been completly filled in. */
293 #if !OPT_DISABLE_MCS51
294 extern PORT mcs51_port;
296 #if !OPT_DISABLE_GBZ80
297 extern PORT gbz80_port;
300 extern PORT z80_port;
303 extern PORT avr_port;
305 #if !OPT_DISABLE_DS390
306 extern PORT ds390_port;
309 extern PORT pic_port;
311 #if !OPT_DISABLE_PIC16
312 extern PORT pic16_port;
314 #if !OPT_DISABLE_TININative
315 extern PORT tininative_port;
317 #if !OPT_DISABLE_XA51
318 extern PORT xa51_port;
320 #if !OPT_DISABLE_DS400
321 extern PORT ds400_port;
323 #if !OPT_DISABLE_HC08
324 extern PORT hc08_port;
327 #endif /* PORT_INCLUDE*/