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_XA51 9
19 /* Macro to test the target we are compiling for.
20 Can only be used after SDCCmain has defined the port
22 #define TARGET_IS_MCS51 (port->id==TARGET_ID_MCS51)
23 #define TARGET_IS_GBZ80 (port->id==TARGET_ID_GBZ80)
24 #define TARGET_IS_Z80 (port->id==TARGET_ID_Z80)
25 #define TARGET_IS_AVR (port->id==TARGET_ID_AVR)
26 #define TARGET_IS_DS390 (port->id==TARGET_ID_DS390)
27 #define TARGET_IS_PIC (port->id==TARGET_ID_PIC)
28 #define TARGET_IS_XA51 (port->id==TARGET_ID_XA51)
30 #define MAX_BUILTIN_ARGS 16
31 /* definition of builtin functions */
32 typedef struct builtins
34 char *name ; /* name of builtin function */
35 char *rtype; /* return type as string : see typefromStr */
36 int nParms; /* number of parms : max 8 */
37 char *parm_types[MAX_BUILTIN_ARGS]; /* each parm type as string : see typeFromStr */
40 /* Processor specific names */
43 /** Unique id for this target */
45 /** Target name used for -m */
48 /** Target name string, used for --help */
49 const char *target_name;
51 /** Specific processor for the given target family. specified by -p */
56 /** TRUE if all types of glue functions should be inserted into
57 the file that also defines main.
58 We dont want this in cases like the z80 where the startup
59 code is provided by a seperate module.
68 /* assembler related information */
71 /** Command to run and arguments (eg as-z80) */
73 /** Alternate macro based form. */
75 /** Arguments for debug mode. */
76 const char *debug_opts;
77 /** Arguments for normal assembly mode. */
78 const char *plain_opts;
79 /* print externs as global */
81 /* assembler file extension */
83 /** If non-null will be used to execute the assembler. */
84 void (*do_assemble) (set *);
88 /* linker related info */
91 /** Command to run (eg link-z80) */
93 /** Alternate macro based form. */
95 /** If non-null will be used to execute the link. */
96 void (*do_link) (void);
97 /** Extension for object files (.rel, .obj, ...) */
104 /** Default peephole rules */
109 /** Basic type sizes */
125 /** memory regions related stuff */
128 const char *xstack_name;
129 const char *istack_name;
130 const char *code_name;
131 const char *data_name;
132 const char *idata_name;
133 const char *xdata_name;
134 const char *bit_name;
135 const char *reg_name;
136 const char *static_name;
137 const char *overlay_name;
138 const char *post_static_name;
139 const char *home_name;
140 const char *xidata_name; // initialized xdata
141 const char *xinit_name; // a code copy of xidata
142 struct memmap *default_local_map; // default location for auto vars
143 struct memmap *default_globl_map; // default location for globl vars
144 int code_ro; /* code space read-only 1=yes */
148 /* stack related information */
151 /** -1 for grows down (z80), +1 for grows up (mcs51) */
153 /** Extra overhead when calling between banks */
155 /** Extra overhead when the function is an ISR */
157 /** Standard overhead for a function call */
159 /** Re-enterant space */
161 /** 'banked' call overhead.
162 Mild overlap with bank_overhead */
169 /** One more than the smallest
170 mul/div operation the processor can do nativley
171 Eg if the processor has an 8 bit mul, nativebelow is 2 */
177 /** Prefix to add to a C function (eg "_") */
178 const char *fun_prefix;
180 /** Called once the processor target has been selected.
181 First chance to initalise and set any port specific variables.
182 'port' is set before calling this. May be NULL.
185 /** Parses one option + its arguments */
186 bool (*parseOption) (int *pargc, char **argv, int *i);
187 /** Optional list of automatically parsed options. Should be
188 implemented to at least show the help text correctly. */
190 /** Called after all the options have been parsed. */
191 void (*finaliseOptions) (void);
192 /** Called after the port has been selected but before any
193 options are parsed. */
194 void (*setDefaultOptions) (void);
195 /** Does the dirty work. */
196 void (*assignRegisters) (struct eBBlock **, int);
198 /** Returns the register name of a symbol.
199 Used so that 'regs' can be an incomplete type. */
200 const char *(*getRegName) (struct regs * reg);
202 /* list of keywords that are used by this
203 target (used by lexer) */
206 /* Write any port specific assembler output. */
207 void (*genAssemblerPreamble) (FILE * of);
208 /* invoked at end assembler file */
209 void (*genAssemblerEnd) (FILE * of);
211 /* Write the port specific IVT. If genIVT is NULL or if
212 * it returns zero, default (8051) IVT generation code
215 int (*genIVT) (FILE * of, symbol ** intTable, int intCount);
217 void (*genXINIT) (FILE * of);
219 /* parameter passing in register related functions */
220 void (*reset_regparms) (); /* reset the register count */
221 int (*reg_parm) (struct sym_link *); /* will return 1 if can be passed in register */
223 /** Process the pragma string 'sz'. Returns 0 if recognised and
224 processed, 1 otherwise. May be NULL.
226 int (*process_pragma) (const char *sz);
228 /** Mangles a support function name to reflect the calling model.
230 char *(*getMangledFunctionName) (char *szOrginial);
232 /** Returns true if the port can multiply the two types nativly
233 without using support functions.
235 bool (*hasNativeMulFor) (iCode *ic, sym_link *left, sym_link *right);
237 /** If TRUE, then tprintf and !dw will be used for some initalisers
239 bool use_dw_for_init;
241 /* condition transformations */
242 bool lt_nge; /* transform (a < b) to !(a >= b) */
243 bool gt_nle; /* transform (a > b) to !(a <= b) */
244 bool le_ngt; /* transform (a <= b) to !(a > b) */
245 bool ge_nlt; /* transform (a >= b) to !(a < b) */
246 bool ne_neq; /* transform a != b --> ! (a == b) */
247 bool eq_nne; /* transform a == b --> ! (a != b) */
249 bool arrayInitializerSuppported;
250 bool (*cseOk) (iCode *ic, iCode *pdic);
251 builtins *builtintable; /* table of builtin functions */
252 int unqualified_pointer; /* unqualified pointers type is */
253 int reset_labelKey ; /* reset Label no 1 at the start of a function */
254 int globals_allowed ; /* global & static locals not allowed ? 0 ONLY TININative*/
255 #define PORT_MAGIC 0xAC32
256 /** Used at runtime to detect if this structure has been completly filled in. */
263 #if !OPT_DISABLE_MCS51
264 extern PORT mcs51_port;
266 #if !OPT_DISABLE_GBZ80
267 extern PORT gbz80_port;
270 extern PORT z80_port;
273 extern PORT avr_port;
275 #if !OPT_DISABLE_DS390
276 extern PORT ds390_port;
279 extern PORT pic_port;
281 #if !OPT_DISABLE_TININative
282 extern PORT tininative_port;
284 #if !OPT_DISABLE_XA51
285 extern PORT xa51_port;
288 #endif /* PORT_INCLUDE*/