b1503ae4ea73b86009c9fb8529662b2df8d91588
[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     /** Target name string, used for --help */
13     const char *target_name;
14     struct {
15         /** Command to run (eg as-z80) */
16         const char *exec_name;
17         /** Arguments for debug mode */
18         const char *debug_opts;
19         /** Arguments for normal assembly mode */
20         const char *plain_opts;
21         /** TRUE if the output file name should be pre-pended to the args */
22         bool requires_output_name;
23     } assembler;
24     struct {
25         /** Command to run (eg link-z80) */
26         const char *exec_name;
27     } linker;
28     /** Basic type sizes */
29     struct {
30         int char_size;
31         int short_size;
32         int int_size;
33         int long_size;
34         int ptr_size;
35         int fptr_size;
36         int gptr_size;
37         int bit_size;
38         int float_size;
39         int max_base_size;
40     } s;
41     /** Names for all the memory regions */
42     struct {
43         const char *xstack_name;
44         const char *istack_name;
45         const char *code_name;
46         const char *data_name;
47         const char *idata_name;
48         const char *xdata_name;
49         const char *bit_name;
50         const char *reg_name;
51         const char *static_name;
52         const char *overlay_name;
53     } mem;
54     struct {
55         /** -1 for grows down (z80), +1 for grows up (mcs51) */
56         int direction;
57         /** Extra overhead when calling between banks */
58         int bank_overhead;
59         /** Extra overhead when the function is an ISR */
60         int isr_overhead;
61         /** Standard overhead for a function call */
62         int call_overhead;
63         /** Initial SP offset */
64         int start_sp;
65     } stack;
66     struct {
67         /** One more than the smallest mul/div operation the processor can do nativley 
68             Eg if the processor has an 8 bit mul, nativebelow is 2 */
69         int nativebelow;
70     } muldiv;
71     /** Parses one option + its arguments */
72     bool (*parseOption)(int *pargc, char **argv);
73     /** Called after all the options have been parsed. */
74     void (*finaliseOptions)(void);
75     /** Called after the port has been selected but before any
76         options are parsed. */
77     void (*setDefaultOptions)(void);
78     /** Does the dirty work. */
79     void (*assignRegisters)(eBBlock **, int);
80     /** Returns the register name of a symbol.
81         Used so that 'regs' can be an incomplete type. */
82     const char *(*getRegName)(struct regs *reg);
83 } PORT;
84
85 extern PORT *port;
86
87 #endif
88