Most of the way to far fun support
[fw/sdcc] / src / port.h
1 /** @file port.h
2     Definitions for what a port must provide.
3     All ports are referenced in SDCCmain.c.
4 */
5 #ifndef PORT_INCLUDE
6 #define PORT_INCLUDE
7
8 /* Processor specific names */
9 typedef struct {
10     /** Target name used for -m */
11     const char *target;
12
13     /** Target name string, used for --help */
14     const char *target_name;
15
16     struct {
17         /** TRUE if all types of glue functions should be inseted into
18             the file that also defines main.
19             We dont want this in cases like the z80 where the startup
20             code is provided by a seperate module.
21         */
22         bool glue_up_main;
23     } general;
24
25     /* assembler related information */
26     struct {
27         /** Command to run and arguments (eg as-z80) */
28         const char **cmd;
29         /** Arguments for debug mode.  PENDING: ignored */
30         const char *debug_opts;
31         /** Arguments for normal assembly mode.  PENDING: ignored */
32         const char *plain_opts;
33         /* print externs as global */
34         int externGlobal;
35     } assembler;
36
37     /* linker related info */
38     struct {
39         /** Command to run (eg link-z80) */
40         const char **cmd;
41         /** If non-null will be used to execute the link. */
42         void (*do_link)(void);
43         /** Extention for object files (.rel, .obj, ...) */
44         const char *rel_ext;
45     } linker;
46
47     struct {
48         /** Default peephole rules */
49         char *default_rules;
50     } peep;
51
52     /** Basic type sizes */
53     struct {
54         int char_size;
55         int short_size;
56         int int_size;
57         int long_size;
58         int ptr_size;
59         int fptr_size;
60         int gptr_size;
61         int bit_size;
62         int float_size;
63         int max_base_size;
64     } s;
65
66     /** memory regions related stuff */
67     struct {
68         const char *xstack_name;
69         const char *istack_name;
70         const char *code_name;
71         const char *data_name;
72         const char *idata_name;
73         const char *xdata_name;
74         const char *bit_name;
75         const char *reg_name;
76         const char *static_name;
77         const char *overlay_name;
78         const char *post_static_name;
79         const char *home_name;
80         struct memmap *default_local_map ; /* default location for auto vars */
81         struct memmap *default_globl_map ; /* default location for globl vars*/
82         int         code_ro;               /* code space read-only 1=yes */
83     } mem;
84     
85     /* stack related information */
86     struct {
87         /** -1 for grows down (z80), +1 for grows up (mcs51) */
88         int direction;
89         /** Extra overhead when calling between banks */
90         int bank_overhead;
91         /** Extra overhead when the function is an ISR */
92         int isr_overhead;
93         /** Standard overhead for a function call */
94         int call_overhead;
95         /** Re-enterant space */
96         int reent_overhead;
97         /** 'banked' call overhead.
98             Mild overlap with bank_overhead */
99         int banked_overhead;
100     } stack;
101
102     struct {
103         /** One more than the smallest 
104             mul/div operation the processor can do nativley 
105             Eg if the processor has an 8 bit mul, nativebelow is 2 */
106         int native_below;
107     } muldiv;
108
109     /** Prefix to add to a C function (eg "_") */
110     const char *fun_prefix;
111
112     /** Called once the processor target has been selected.
113         First chance to initalise and set any port specific varibles.
114         'port' is set before calling this.  May be NULL.
115     */
116     void (*init)(void);
117     /** Parses one option + its arguments */
118     bool (*parseOption)(int *pargc, char **argv, int *i);
119     /** Called after all the options have been parsed. */
120     void (*finaliseOptions)(void);
121     /** Called after the port has been selected but before any
122         options are parsed. */
123     void (*setDefaultOptions)(void);
124     /** Does the dirty work. */
125     void (*assignRegisters)(eBBlock **, int);
126     
127     /** Returns the register name of a symbol.
128         Used so that 'regs' can be an incomplete type. */
129     const char *(*getRegName)(struct regs *reg);
130
131     /* list of keywords that are used by this
132        target (used by lexer) */
133     char **keywords; 
134     
135     /* Write any port specific assembler output. */
136     void (*genAssemblerPreamble)(FILE *of);
137     
138     /* Write the port specific IVT. If genIVT is NULL or if
139      * it returns zero, default (8051) IVT generation code
140      * will be used. 
141      */
142     int (*genIVT)(FILE *of, symbol **intTable, int intCount); 
143
144
145     /* parameter passing in register related functions */
146     void (*reset_regparms)();          /* reset the register count */
147     int  (*reg_parm)(struct link *);   /* will return 1 if can be passed in register */
148
149     /** Process the pragma string 'sz'.  Returns 0 if recognised and
150         processed, 1 otherwise.  May be NULL.
151     */
152     int (*process_pragma)(const char *sz);
153
154     /** If TRUE, then tprintf and !dw will be used for some initalisers
155      */
156     bool use_dw_for_init;
157 } PORT;
158
159 extern PORT *port;
160
161 #endif