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