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