Right.
[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     /* assembler related information */
17     struct {
18         /** Command to run and arguments (eg as-z80) */
19         const char **cmd;
20         /** Arguments for debug mode.  PENDING: ignored */
21         const char *debug_opts;
22         /** Arguments for normal assembly mode.  PENDING: ignored */
23         const char *plain_opts;
24     } assembler;
25
26     /* linker related info */
27     struct {
28         /** Command to run (eg link-z80) */
29         const char **cmd;
30     } linker;
31
32     struct {
33         /** Default peephole rules */
34         char *default_rules;
35     } peep;
36
37     /** Basic type sizes */
38     struct {
39         int char_size;
40         int short_size;
41         int int_size;
42         int long_size;
43         int ptr_size;
44         int fptr_size;
45         int gptr_size;
46         int bit_size;
47         int float_size;
48         int max_base_size;
49     } s;
50
51     /** Names for all the memory regions */
52     struct {
53         const char *xstack_name;
54         const char *istack_name;
55         const char *code_name;
56         const char *data_name;
57         const char *idata_name;
58         const char *xdata_name;
59         const char *bit_name;
60         const char *reg_name;
61         const char *static_name;
62         const char *overlay_name;
63     } mem;
64     
65     /* stack related information */
66     struct {
67         /** -1 for grows down (z80), +1 for grows up (mcs51) */
68         int direction;
69         /** Extra overhead when calling between banks */
70         int bank_overhead;
71         /** Extra overhead when the function is an ISR */
72         int isr_overhead;
73         /** Standard overhead for a function call */
74         int call_overhead;
75         /** Re-enterant space */
76         int reent_overhead;
77         
78     } stack;
79     struct {
80         /** One more than the smallest 
81             mul/div operation the processor can do nativley 
82             Eg if the processor has an 8 bit mul, nativebelow is 2 */
83         int nativebelow;
84     } muldiv;
85
86     /** Parses one option + its arguments */
87     bool (*parseOption)(int *pargc, char **argv, int *i);
88     /** Called after all the options have been parsed. */
89     void (*finaliseOptions)(void);
90     /** Called after the port has been selected but before any
91         options are parsed. */
92     void (*setDefaultOptions)(void);
93     /** Does the dirty work. */
94     void (*assignRegisters)(eBBlock **, int);
95     
96     /** Returns the register name of a symbol.
97         Used so that 'regs' can be an incomplete type. */
98     const char *(*getRegName)(struct regs *reg);
99
100     /* list of keywords that are used by this
101        target (used by lexer) */
102     char **keywords; 
103     
104     /* Write any port specific assembler output. */
105     void (*genAssemblerPreamble)(FILE *of);
106     
107     /* Write the port specific IVT. If genIVT is NULL or if
108      * it returns zero, default (8051) IVT generation code
109      * will be used. 
110      */
111     int (*genIVT)(FILE *of, symbol **intTable, int intCount); 
112 } PORT;
113
114 extern PORT *port;
115
116 #endif
117