2 Definitions for what a port must provide.
3 All ports are referenced in SDCCmain.c.
8 #define TARGET_ID_MCS51 1
9 #define TARGET_ID_GBZ80 2
10 #define TARGET_ID_Z80 3
11 #define TARGET_ID_AVR 4
12 #define TARGET_ID_DS390 5
13 #define TARGET_ID_PIC 6
14 #define TARGET_ID_I186 7
15 #define TARGET_ID_TLCS900H 8
16 #define TARGET_ID_XA51 9
18 /* Macro to test the target we are compiling for.
19 Can only be used after SDCCmain has defined the port
21 #define TARGET_IS_MCS51 (port->id==TARGET_ID_MCS51)
22 #define TARGET_IS_GBZ80 (port->id==TARGET_ID_GBZ80)
23 #define TARGET_IS_Z80 (port->id==TARGET_ID_Z80)
24 #define TARGET_IS_AVR (port->id==TARGET_ID_AVR)
25 #define TARGET_IS_DS390 (port->id==TARGET_ID_DS390)
26 #define TARGET_IS_PIC (port->id==TARGET_ID_PIC)
27 #define TARGET_IS_I186 (port->id==TARGET_ID_I186)
28 #define TARGET_IS_TCLS900H (port->id==TARGET_ID_TCLS900H)
30 /* Processor specific names */
33 /** Unique id for this target */
35 /** Target name used for -m */
38 /** Target name string, used for --help */
39 const char *target_name;
43 /** TRUE if all types of glue functions should be inserted into
44 the file that also defines main.
45 We dont want this in cases like the z80 where the startup
46 code is provided by a seperate module.
55 /* assembler related information */
58 /** Command to run and arguments (eg as-z80) */
60 /** Arguments for debug mode. PENDING: ignored */
61 const char *debug_opts;
62 /** Arguments for normal assembly mode. PENDING: ignored */
63 const char *plain_opts;
64 /* print externs as global */
69 /* linker related info */
72 /** Command to run (eg link-z80) */
74 /** If non-null will be used to execute the link. */
75 void (*do_link) (void);
76 /** Extention for object files (.rel, .obj, ...) */
83 /** Default peephole rules */
88 /** Basic type sizes */
104 /** memory regions related stuff */
107 const char *xstack_name;
108 const char *istack_name;
109 const char *code_name;
110 const char *data_name;
111 const char *idata_name;
112 const char *xdata_name;
113 const char *bit_name;
114 const char *reg_name;
115 const char *static_name;
116 const char *overlay_name;
117 const char *post_static_name;
118 const char *home_name;
119 struct memmap *default_local_map; /* default location for auto vars */
120 struct memmap *default_globl_map; /* default location for globl vars */
121 int code_ro; /* code space read-only 1=yes */
125 /* stack related information */
128 /** -1 for grows down (z80), +1 for grows up (mcs51) */
130 /** Extra overhead when calling between banks */
132 /** Extra overhead when the function is an ISR */
134 /** Standard overhead for a function call */
136 /** Re-enterant space */
138 /** 'banked' call overhead.
139 Mild overlap with bank_overhead */
146 /** One more than the smallest
147 mul/div operation the processor can do nativley
148 Eg if the processor has an 8 bit mul, nativebelow is 2 */
150 /** The mul/div/mod functions will be made to use regparams
151 for sizeof(param) < log2(force_reg)
152 i.e. Use 2 for WORD and BYTE, 0 for none. */
153 int force_reg_param_below;
157 /** Prefix to add to a C function (eg "_") */
158 const char *fun_prefix;
160 /** Called once the processor target has been selected.
161 First chance to initalise and set any port specific variables.
162 'port' is set before calling this. May be NULL.
165 /** Parses one option + its arguments */
166 bool (*parseOption) (int *pargc, char **argv, int *i);
167 /** Called after all the options have been parsed. */
168 void (*finaliseOptions) (void);
169 /** Called after the port has been selected but before any
170 options are parsed. */
171 void (*setDefaultOptions) (void);
172 /** Does the dirty work. */
173 void (*assignRegisters) (struct eBBlock **, int);
175 /** Returns the register name of a symbol.
176 Used so that 'regs' can be an incomplete type. */
177 const char *(*getRegName) (struct regs * reg);
179 /* list of keywords that are used by this
180 target (used by lexer) */
183 /* Write any port specific assembler output. */
184 void (*genAssemblerPreamble) (FILE * of);
186 /* Write the port specific IVT. If genIVT is NULL or if
187 * it returns zero, default (8051) IVT generation code
190 int (*genIVT) (FILE * of, symbol ** intTable, int intCount);
193 /* parameter passing in register related functions */
194 void (*reset_regparms) (); /* reset the register count */
195 int (*reg_parm) (struct sym_link *); /* will return 1 if can be passed in register */
197 /** Process the pragma string 'sz'. Returns 0 if recognised and
198 processed, 1 otherwise. May be NULL.
200 int (*process_pragma) (const char *sz);
202 /** If TRUE, then tprintf and !dw will be used for some initalisers
204 bool use_dw_for_init;
206 /* condition transformations */
207 bool lt_nge; /* transform (a < b) to !(a >= b) */
208 bool gt_nle; /* transform (a > b) to !(a <= b) */
209 bool le_ngt; /* transform (a <= b) to !(a > b) */
210 bool ge_nlt; /* transform (a >= b) to !(a < b) */
211 bool ne_neq; /* transform a != b --> ! (a == b) */
212 bool eq_nne; /* transform a == b --> ! (a != b) */
214 #define PORT_MAGIC 0xAC32
215 /** Used at runtime to detect if this structure has been completly filled in. */
222 #if !OPT_DISABLE_MCS51
223 extern PORT mcs51_port;
225 #if !OPT_DISABLE_GBZ80
226 extern PORT gbz80_port;
229 extern PORT z80_port;
232 extern PORT avr_port;
234 #if !OPT_DISABLE_DS390
235 extern PORT ds390_port;
238 extern PORT pic_port;
240 #if !OPT_DISABLE_I186
241 extern PORT i186_port;
243 #if !OPT_DISABLE_TLCS900H
244 extern PORT tlcs900h_port;