2 Definitions for what a port must provide.
3 All ports are referenced in SDCCmain.c.
10 #define TARGET_ID_MCS51 1
11 #define TARGET_ID_GBZ80 2
12 #define TARGET_ID_Z80 3
13 #define TARGET_ID_AVR 4
14 #define TARGET_ID_DS390 5
15 #define TARGET_ID_PIC 6
16 #define TARGET_ID_I186 7
17 #define TARGET_ID_TLCS900H 8
18 #define TARGET_ID_XA51 9
20 /* Macro to test the target we are compiling for.
21 Can only be used after SDCCmain has defined the port
23 #define TARGET_IS_MCS51 (port->id==TARGET_ID_MCS51)
24 #define TARGET_IS_GBZ80 (port->id==TARGET_ID_GBZ80)
25 #define TARGET_IS_Z80 (port->id==TARGET_ID_Z80)
26 #define TARGET_IS_AVR (port->id==TARGET_ID_AVR)
27 #define TARGET_IS_DS390 (port->id==TARGET_ID_DS390)
28 #define TARGET_IS_PIC (port->id==TARGET_ID_PIC)
29 #define TARGET_IS_I186 (port->id==TARGET_ID_I186)
30 #define TARGET_IS_TCLS900H (port->id==TARGET_ID_TCLS900H)
32 #define MAX_BUILTIN_ARGS 16
33 /* definition of builtin functions */
34 typedef struct builtins
36 char *name ; /* name of builtin function */
37 char *rtype; /* return type as string : see typefromStr */
38 int nParms; /* number of parms : max 8 */
39 char *parm_types[MAX_BUILTIN_ARGS]; /* each parm type as string : see typeFromStr */
42 /* Processor specific names */
45 /** Unique id for this target */
47 /** Target name used for -m */
50 /** Target name string, used for --help */
51 const char *target_name;
55 /** TRUE if all types of glue functions should be inserted into
56 the file that also defines main.
57 We dont want this in cases like the z80 where the startup
58 code is provided by a seperate module.
67 /* assembler related information */
70 /** Command to run and arguments (eg as-z80) */
72 /** Alternate macro based form. */
74 /** Arguments for debug mode. */
75 const char *debug_opts;
76 /** Arguments for normal assembly mode. */
77 const char *plain_opts;
78 /* print externs as global */
80 /* assembler file extension */
85 /* linker related info */
88 /** Command to run (eg link-z80) */
90 /** Alternate macro based form. */
92 /** If non-null will be used to execute the link. */
93 void (*do_link) (void);
94 /** Extention for object files (.rel, .obj, ...) */
101 /** Default peephole rules */
106 /** Basic type sizes */
122 /** memory regions related stuff */
125 const char *xstack_name;
126 const char *istack_name;
127 const char *code_name;
128 const char *data_name;
129 const char *idata_name;
130 const char *xdata_name;
131 const char *bit_name;
132 const char *reg_name;
133 const char *static_name;
134 const char *overlay_name;
135 const char *post_static_name;
136 const char *home_name;
137 const char *xidata_name; // initialized xdata
138 const char *xinit_name; // a code copy of xidata
139 struct memmap *default_local_map; // default location for auto vars
140 struct memmap *default_globl_map; // default location for globl vars
141 int code_ro; /* code space read-only 1=yes */
145 /* stack related information */
148 /** -1 for grows down (z80), +1 for grows up (mcs51) */
150 /** Extra overhead when calling between banks */
152 /** Extra overhead when the function is an ISR */
154 /** Standard overhead for a function call */
156 /** Re-enterant space */
158 /** 'banked' call overhead.
159 Mild overlap with bank_overhead */
166 /** One more than the smallest
167 mul/div operation the processor can do nativley
168 Eg if the processor has an 8 bit mul, nativebelow is 2 */
174 /** Prefix to add to a C function (eg "_") */
175 const char *fun_prefix;
177 /** Called once the processor target has been selected.
178 First chance to initalise and set any port specific variables.
179 'port' is set before calling this. May be NULL.
182 /** Parses one option + its arguments */
183 bool (*parseOption) (int *pargc, char **argv, int *i);
184 /** Called after all the options have been parsed. */
185 void (*finaliseOptions) (void);
186 /** Called after the port has been selected but before any
187 options are parsed. */
188 void (*setDefaultOptions) (void);
189 /** Does the dirty work. */
190 void (*assignRegisters) (struct eBBlock **, int);
192 /** Returns the register name of a symbol.
193 Used so that 'regs' can be an incomplete type. */
194 const char *(*getRegName) (struct regs * reg);
196 /* list of keywords that are used by this
197 target (used by lexer) */
200 /* Write any port specific assembler output. */
201 void (*genAssemblerPreamble) (FILE * of);
203 /* Write the port specific IVT. If genIVT is NULL or if
204 * it returns zero, default (8051) IVT generation code
207 int (*genIVT) (FILE * of, symbol ** intTable, int intCount);
209 void (*genXINIT) (FILE * of);
211 /* parameter passing in register related functions */
212 void (*reset_regparms) (); /* reset the register count */
213 int (*reg_parm) (struct sym_link *); /* will return 1 if can be passed in register */
215 /** Process the pragma string 'sz'. Returns 0 if recognised and
216 processed, 1 otherwise. May be NULL.
218 int (*process_pragma) (const char *sz);
220 /** Mangles a support function name to reflect the calling model.
222 char *(*getMangledFunctionName) (char *szOrginial);
224 /** Returns true if the port can multiply the two types nativly
225 without using support functions.
227 bool (*hasNativeMulFor) (iCode *ic, sym_link *left, sym_link *right);
229 /** If TRUE, then tprintf and !dw will be used for some initalisers
231 bool use_dw_for_init;
233 /* condition transformations */
234 bool lt_nge; /* transform (a < b) to !(a >= b) */
235 bool gt_nle; /* transform (a > b) to !(a <= b) */
236 bool le_ngt; /* transform (a <= b) to !(a > b) */
237 bool ge_nlt; /* transform (a >= b) to !(a < b) */
238 bool ne_neq; /* transform a != b --> ! (a == b) */
239 bool eq_nne; /* transform a == b --> ! (a != b) */
241 bool arrayInitializerSuppported;
242 bool (*cseOk) (iCode *ic, iCode *pdic);
243 builtins *builtintable; /* table of builtin functions */
244 int unqualified_pointer; /* unqualified pointers type is */
245 int reset_labelKey ; /* reset Label no 1 at the start of a function */
246 int globals_allowed ; /* global & static locals not allowed ? 0 ONLY TININative*/
247 #define PORT_MAGIC 0xAC32
248 /** Used at runtime to detect if this structure has been completly filled in. */
255 #if !OPT_DISABLE_MCS51
256 extern PORT mcs51_port;
258 #if !OPT_DISABLE_GBZ80
259 extern PORT gbz80_port;
262 extern PORT z80_port;
265 extern PORT avr_port;
267 #if !OPT_DISABLE_DS390
268 extern PORT ds390_port;
271 extern PORT pic_port;
273 #if !OPT_DISABLE_I186
274 extern PORT i186_port;
276 #if !OPT_DISABLE_TLCS900H
277 extern PORT tlcs900h_port;
279 #if !OPT_DISABLE_TININative
280 extern PORT tininative_port;
283 #endif /* PORT_INCLUDE*/