2 Definitions for what a port must provide.
3 All ports are referenced in SDCCmain.c.
10 #include "SDCCpeeph.h"
12 #include "mcs51/peep.h"
14 #define TARGET_ID_MCS51 1
15 #define TARGET_ID_GBZ80 2
16 #define TARGET_ID_Z80 3
17 #define TARGET_ID_AVR 4
18 #define TARGET_ID_DS390 5
19 #define TARGET_ID_PIC 6
20 #define TARGET_ID_PIC16 7
21 #define TARGET_ID_XA51 9
22 #define TARGET_ID_DS400 10
23 #define TARGET_ID_HC08 11
25 /* Macro to test the target we are compiling for.
26 Can only be used after SDCCmain has defined the port
28 #define TARGET_IS_MCS51 (port->id==TARGET_ID_MCS51)
29 #define TARGET_IS_GBZ80 (port->id==TARGET_ID_GBZ80)
30 #define TARGET_IS_Z80 (port->id==TARGET_ID_Z80)
31 #define TARGET_Z80_LIKE ((port->id==TARGET_ID_Z80) || (port->id==TARGET_ID_GBZ80))
32 #define TARGET_IS_AVR (port->id==TARGET_ID_AVR)
33 #define TARGET_IS_DS390 (port->id==TARGET_ID_DS390)
34 #define TARGET_IS_DS400 (port->id==TARGET_ID_DS400)
35 #define TARGET_IS_PIC (port->id==TARGET_ID_PIC)
36 #define TARGET_IS_PIC16 (port->id==TARGET_ID_PIC16)
37 #define TARGET_IS_XA51 (port->id==TARGET_ID_XA51)
38 #define TARGET_IS_HC08 (port->id==TARGET_ID_HC08)
40 #define MAX_BUILTIN_ARGS 16
41 /* definition of builtin functions */
42 typedef struct builtins
44 char *name; /* name of builtin function */
45 char *rtype; /* return type as string : see typefromStr */
46 int nParms; /* number of parms : max 8 */
47 char *parm_types[MAX_BUILTIN_ARGS]; /* each parm type as string : see typeFromStr */
52 /* pragma structure */
58 int (*func)(int id, const char *name, const char *cp);
61 /* defined in SDCClex.lex */
62 int process_pragma_tbl(const struct pragma_s *pragma_tbl, const char *s);
64 /* Processor specific names */
67 /** Unique id for this target */
69 /** Target name used for -m */
72 /** Target name string, used for --help */
73 const char *target_name;
75 /** Specific processor for the given target family. specified by -p */
80 /** Pointer to glue function */
81 void (*do_glue)(void);
82 /** TRUE if all types of glue functions should be inserted into
83 the file that also defines main.
84 We dont want this in cases like the z80 where the startup
85 code is provided by a seperate module.
94 /* assembler related information */
97 /** Command to run and arguments (eg as-z80) */
99 /** Alternate macro based form. */
101 /** Arguments for debug mode. */
102 const char *debug_opts;
103 /** Arguments for normal assembly mode. */
104 const char *plain_opts;
105 /* print externs as global */
107 /* assembler file extension */
108 const char *file_ext;
109 /** If non-null will be used to execute the assembler. */
110 void (*do_assemble) (set *);
114 /* linker related info */
117 /** Command to run (eg link-z80) */
119 /** Alternate macro based form. */
121 /** If non-null will be used to execute the link. */
122 void (*do_link) (void);
123 /** Extension for object files (.rel, .obj, ...) */
125 /** 1 if port needs the .lnk file, 0 otherwise */
126 const int needLinkerScript;
132 /** Default peephole rules */
134 int (*getSize)(lineNode *line);
135 bitVect * (*getRegsRead)(lineNode *line);
136 bitVect * (*getRegsWritten)(lineNode *line);
137 bool (*deadMove) (const char *reg, lineNode *currPl, lineNode *head);
141 /** Basic type sizes */
146 unsigned int int_size;
150 int gptr_size; //generic
157 /** tags for far, near, xstack, code generic pointers */
167 /** memory regions related stuff */
170 const char *xstack_name;
171 const char *istack_name;
172 const char *code_name;
173 const char *data_name;
174 const char *idata_name;
175 const char *pdata_name;
176 const char *xdata_name;
177 const char *bit_name;
178 const char *reg_name;
179 const char *static_name;
180 const char *overlay_name;
181 const char *post_static_name;
182 const char *home_name;
183 const char *xidata_name; // initialized xdata
184 const char *xinit_name; // a code copy of xidata
185 const char *const_name; // const data (code or not)
186 const char *cabs_name; // const absolute data (code or not)
187 const char *xabs_name; // absolute xdata/pdata
188 const char *iabs_name; // absolute idata/data
189 struct memmap *default_local_map; // default location for auto vars
190 struct memmap *default_globl_map; // default location for globl vars
191 int code_ro; /* code space read-only 1=yes */
197 void (*genExtraAreaDeclaration)(FILE *, bool);
198 void (*genExtraAreaLinkOptions)(FILE *);
202 /* stack related information */
205 /** -1 for grows down (z80), +1 for grows up (mcs51) */
207 /** Extra overhead when calling between banks */
209 /** Extra overhead when the function is an ISR */
211 /** Standard overhead for a function call */
213 /** Re-enterant space */
215 /** 'banked' call overhead.
216 Mild overlap with bank_overhead */
223 /** One more than the smallest
224 mul/div operation the processor can do natively
225 Eg if the processor has an 8 bit mul, native below is 2 */
233 void (*emitDebuggerSymbol) (char *);
236 int (*regNum) (struct regs *);
253 int sizeofMatchJump[3];
254 int sizeofRangeCompare[3];
260 /** Prefix to add to a C function (eg "_") */
261 const char *fun_prefix;
263 /** Called once the processor target has been selected.
264 First chance to initalise and set any port specific variables.
265 'port' is set before calling this. May be NULL.
268 /** Parses one option + its arguments */
269 bool (*parseOption) (int *pargc, char **argv, int *i);
270 /** Optional list of automatically parsed options. Should be
271 implemented to at least show the help text correctly. */
273 /** Initialise port spectific paths */
274 void (*initPaths)(void);
275 /** Called after all the options have been parsed. */
276 void (*finaliseOptions) (void);
277 /** Called after the port has been selected but before any
278 options are parsed. */
279 void (*setDefaultOptions) (void);
280 /** Does the dirty work. */
281 void (*assignRegisters) (struct ebbIndex *);
283 /** Returns the register name of a symbol.
284 Used so that 'regs' can be an incomplete type. */
285 const char *(*getRegName) (struct regs * reg);
287 /* list of keywords that are used by this
288 target (used by lexer) */
291 /* Write any port specific assembler output. */
292 void (*genAssemblerPreamble) (FILE * of);
293 /* invoked at end assembler file */
294 void (*genAssemblerEnd) (FILE * of);
296 /* Write the port specific IVT. If genIVT is NULL or if
297 * it returns zero, default (8051) IVT generation code
300 int (*genIVT) (struct dbuf_s *oBuf, symbol ** intTable, int intCount);
302 void (*genXINIT) (FILE * of);
304 /* Write port specific startup code */
305 void (*genInitStartup) (FILE * of);
307 /* parameter passing in register related functions */
308 void (*reset_regparms) (void); /* reset the register count */
309 int (*reg_parm) (struct sym_link *, bool reentrant); /* will return 1 if can be passed in register */
311 /** Process the pragma string 'sz'. Returns 0 if recognised and
312 processed, 1 otherwise. May be NULL.
314 int (*process_pragma) (const char *sz);
316 /** Mangles a support function name to reflect the calling model.
318 char *(*getMangledFunctionName) (char *szOrginial);
320 /** Returns true if the port can multiply the two types nativly
321 without using support functions.
323 bool (*hasNativeMulFor) (iCode *ic, sym_link *left, sym_link *right);
325 /** Returns true if the port has implemented certain bit
326 manipulation iCodes (RRC, RLC, SWAP, GETHBIT, GETABIT, GETBYTE, GETWORD)
328 bool (*hasExtBitOp) (int op, int size);
330 /** Returns the relative expense of accessing a particular output
331 storage class. Larger values indicate higher expense.
333 int (*oclsExpense) (struct memmap *oclass);
335 /** If TRUE, then tprintf and !dw will be used for some initalisers
337 bool use_dw_for_init;
339 /** TRUE for targets with little endian byte ordering, FALSE for
340 targets with big endian byte ordering.
344 /* condition transformations */
345 bool lt_nge; /* transform (a < b) to !(a >= b) */
346 bool gt_nle; /* transform (a > b) to !(a <= b) */
347 bool le_ngt; /* transform (a <= b) to !(a > b) */
348 bool ge_nlt; /* transform (a >= b) to !(a < b) */
349 bool ne_neq; /* transform a != b --> ! (a == b) */
350 bool eq_nne; /* transform a == b --> ! (a != b) */
352 bool arrayInitializerSuppported;
353 bool (*cseOk) (iCode *ic, iCode *pdic);
354 builtins *builtintable; /* table of builtin functions */
355 int unqualified_pointer; /* unqualified pointers type is */
356 int reset_labelKey ; /* reset Label no 1 at the start of a function */
357 int globals_allowed ; /* global & static locals not allowed ? 0 ONLY TININative*/
358 #define PORT_MAGIC 0xAC32
359 /** Used at runtime to detect if this structure has been completly filled in. */
366 #if !OPT_DISABLE_MCS51
367 extern PORT mcs51_port;
369 #if !OPT_DISABLE_GBZ80
370 extern PORT gbz80_port;
373 extern PORT z80_port;
376 extern PORT avr_port;
378 #if !OPT_DISABLE_DS390
379 extern PORT ds390_port;
382 extern PORT pic_port;
384 #if !OPT_DISABLE_PIC16
385 extern PORT pic16_port;
387 #if !OPT_DISABLE_TININative
388 extern PORT tininative_port;
390 #if !OPT_DISABLE_XA51
391 extern PORT xa51_port;
393 #if !OPT_DISABLE_DS400
394 extern PORT ds400_port;
396 #if !OPT_DISABLE_HC08
397 extern PORT hc08_port;
400 #endif /* PORT_INCLUDE*/