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
21 /* Macro to test the target we are compiling for.
22 Can only be used after SDCCmain has defined the port
24 #define TARGET_IS_MCS51 (port->id==TARGET_ID_MCS51)
25 #define TARGET_IS_GBZ80 (port->id==TARGET_ID_GBZ80)
26 #define TARGET_IS_Z80 (port->id==TARGET_ID_Z80)
27 #define TARGET_IS_AVR (port->id==TARGET_ID_AVR)
28 #define TARGET_IS_DS390 (port->id==TARGET_ID_DS390)
29 #define TARGET_IS_DS400 (port->id==TARGET_ID_DS400)
30 #define TARGET_IS_PIC (port->id==TARGET_ID_PIC)
31 #define TARGET_IS_PIC16 (port->id==TARGET_ID_PIC16)
32 #define TARGET_IS_XA51 (port->id==TARGET_ID_XA51)
34 #define MAX_BUILTIN_ARGS 16
35 /* definition of builtin functions */
36 typedef struct builtins
38 char *name ; /* name of builtin function */
39 char *rtype; /* return type as string : see typefromStr */
40 int nParms; /* number of parms : max 8 */
41 char *parm_types[MAX_BUILTIN_ARGS]; /* each parm type as string : see typeFromStr */
44 /* Processor specific names */
47 /** Unique id for this target */
49 /** Target name used for -m */
52 /** Target name string, used for --help */
53 const char *target_name;
55 /** Specific processor for the given target family. specified by -p */
60 /** TRUE if all types of glue functions should be inserted into
61 the file that also defines main.
62 We dont want this in cases like the z80 where the startup
63 code is provided by a seperate module.
72 /* assembler related information */
75 /** Command to run and arguments (eg as-z80) */
77 /** Alternate macro based form. */
79 /** Arguments for debug mode. */
80 const char *debug_opts;
81 /** Arguments for normal assembly mode. */
82 const char *plain_opts;
83 /* print externs as global */
85 /* assembler file extension */
87 /** If non-null will be used to execute the assembler. */
88 void (*do_assemble) (set *);
92 /* linker related info */
95 /** Command to run (eg link-z80) */
97 /** Alternate macro based form. */
99 /** If non-null will be used to execute the link. */
100 void (*do_link) (void);
101 /** Extension for object files (.rel, .obj, ...) */
108 /** Default peephole rules */
113 /** Basic type sizes */
129 /** memory regions related stuff */
132 const char *xstack_name;
133 const char *istack_name;
134 const char *code_name;
135 const char *data_name;
136 const char *idata_name;
137 const char *xdata_name;
138 const char *bit_name;
139 const char *reg_name;
140 const char *static_name;
141 const char *overlay_name;
142 const char *post_static_name;
143 const char *home_name;
144 const char *xidata_name; // initialized xdata
145 const char *xinit_name; // a code copy of xidata
146 struct memmap *default_local_map; // default location for auto vars
147 struct memmap *default_globl_map; // default location for globl vars
148 int code_ro; /* code space read-only 1=yes */
152 /* stack related information */
155 /** -1 for grows down (z80), +1 for grows up (mcs51) */
157 /** Extra overhead when calling between banks */
159 /** Extra overhead when the function is an ISR */
161 /** Standard overhead for a function call */
163 /** Re-enterant space */
165 /** 'banked' call overhead.
166 Mild overlap with bank_overhead */
173 /** One more than the smallest
174 mul/div operation the processor can do nativley
175 Eg if the processor has an 8 bit mul, nativebelow is 2 */
181 /** Prefix to add to a C function (eg "_") */
182 const char *fun_prefix;
184 /** Called once the processor target has been selected.
185 First chance to initalise and set any port specific variables.
186 'port' is set before calling this. May be NULL.
189 /** Parses one option + its arguments */
190 bool (*parseOption) (int *pargc, char **argv, int *i);
191 /** Optional list of automatically parsed options. Should be
192 implemented to at least show the help text correctly. */
194 /** Called after all the options have been parsed. */
195 void (*finaliseOptions) (void);
196 /** Called after the port has been selected but before any
197 options are parsed. */
198 void (*setDefaultOptions) (void);
199 /** Does the dirty work. */
200 void (*assignRegisters) (struct eBBlock **, int);
202 /** Returns the register name of a symbol.
203 Used so that 'regs' can be an incomplete type. */
204 const char *(*getRegName) (struct regs * reg);
206 /* list of keywords that are used by this
207 target (used by lexer) */
210 /* Write any port specific assembler output. */
211 void (*genAssemblerPreamble) (FILE * of);
212 /* invoked at end assembler file */
213 void (*genAssemblerEnd) (FILE * of);
215 /* Write the port specific IVT. If genIVT is NULL or if
216 * it returns zero, default (8051) IVT generation code
219 int (*genIVT) (FILE * of, symbol ** intTable, int intCount);
221 void (*genXINIT) (FILE * of);
223 /* parameter passing in register related functions */
224 void (*reset_regparms) (); /* reset the register count */
225 int (*reg_parm) (struct sym_link *); /* will return 1 if can be passed in register */
227 /** Process the pragma string 'sz'. Returns 0 if recognised and
228 processed, 1 otherwise. May be NULL.
230 int (*process_pragma) (const char *sz);
232 /** Mangles a support function name to reflect the calling model.
234 char *(*getMangledFunctionName) (char *szOrginial);
236 /** Returns true if the port can multiply the two types nativly
237 without using support functions.
239 bool (*hasNativeMulFor) (iCode *ic, sym_link *left, sym_link *right);
241 /** If TRUE, then tprintf and !dw will be used for some initalisers
243 bool use_dw_for_init;
245 /* condition transformations */
246 bool lt_nge; /* transform (a < b) to !(a >= b) */
247 bool gt_nle; /* transform (a > b) to !(a <= b) */
248 bool le_ngt; /* transform (a <= b) to !(a > b) */
249 bool ge_nlt; /* transform (a >= b) to !(a < b) */
250 bool ne_neq; /* transform a != b --> ! (a == b) */
251 bool eq_nne; /* transform a == b --> ! (a != b) */
253 bool arrayInitializerSuppported;
254 bool (*cseOk) (iCode *ic, iCode *pdic);
255 builtins *builtintable; /* table of builtin functions */
256 int unqualified_pointer; /* unqualified pointers type is */
257 int reset_labelKey ; /* reset Label no 1 at the start of a function */
258 int globals_allowed ; /* global & static locals not allowed ? 0 ONLY TININative*/
259 #define PORT_MAGIC 0xAC32
260 /** Used at runtime to detect if this structure has been completly filled in. */
267 #if !OPT_DISABLE_MCS51
268 extern PORT mcs51_port;
270 #if !OPT_DISABLE_GBZ80
271 extern PORT gbz80_port;
274 extern PORT z80_port;
277 extern PORT avr_port;
279 #if !OPT_DISABLE_DS390
280 extern PORT ds390_port;
283 extern PORT pic_port;
285 #if !OPT_DISABLE_PIC16
286 extern PORT pic16_port;
288 #if !OPT_DISABLE_TININative
289 extern PORT tininative_port;
291 #if !OPT_DISABLE_XA51
292 extern PORT xa51_port;
294 #if !OPT_DISABLE_DS400
295 extern PORT ds400_port;
298 #endif /* PORT_INCLUDE*/