Infrastructure stuff for AVR
[fw/sdcc] / src / z80 / main.c
1 #include "z80.h"
2
3 static char _defaultRules[] =
4 {
5 #include "peeph.rul"
6 #include "peeph-z80.rul"
7 };
8
9 Z80_OPTS z80_opts;
10
11 static char *_z80_keywords[] = { NULL };
12
13 static void _z80_init(void)
14 {
15     z80_opts.sub = SUB_Z80;
16 }
17
18 static bool _z80_parseOptions(int *pargc, char **argv, int *i)
19 {
20     return FALSE;
21 }
22
23 static void _z80_finaliseOptions(void)
24 {
25     port->mem.default_local_map = data;
26     port->mem.default_globl_map = data;
27 }
28
29 static void _z80_setDefaultOptions(void)
30 {    
31     options.genericPtr = 1;   /* default on */
32     options.nopeep    = 0;
33     options.stackAuto = 1;
34     options.mainreturn = 1;
35     options.noregparms = 1;
36     /* first the options part */
37     options.intlong_rent = 1;
38
39     optimize.global_cse = 1;    
40     optimize.label1 = 1;
41     optimize.label2 = 1;
42     optimize.label3 = 1;
43     optimize.label4 = 1;    
44     optimize.loopInvariant = 1;
45     optimize.loopInduction = 0;
46 }
47
48 static const char *_z80_getRegName(struct regs *reg)
49 {
50     if (reg)
51         return reg->name;
52     assert(0);
53     return "err";
54 }
55
56 /** $1 is always the basename.
57     $2 is always the output file.
58     $3 varies
59     $l is the list of extra options that should be there somewhere...
60     MUST be terminated with a NULL.
61 */
62 static const char *_linkCmd[] = {
63     "link-z80", "-nf", "$1", NULL
64 };
65
66 static const char *_asmCmd[] = {
67     "as-z80", "-plosgff", "$1.o", "$1.asm", NULL
68 };
69
70 /* Globals */
71 PORT z80_port = {
72     "z80",
73     "Zilog Z80",                /* Target name */
74     {
75         FALSE,
76     },
77     {   
78         _asmCmd,
79         "-plosgff",             /* Options with debug */
80         "-plosgff",             /* Options without debug */
81     },
82     {
83         _linkCmd
84     },
85     {
86         _defaultRules
87     },
88     {
89         /* Sizes: char, short, int, long, ptr, fptr, gptr, bit, float, max */
90         1, 1, 2, 4, 2, 2, 2, 1, 4, 4
91     },
92     {
93         "_XSEG",
94         "_STACK",
95         "_CODE",
96         "_DATA",
97         "_ISEG",
98         "_XSEG",
99         "_BSEG",
100         "_RSEG",
101         "_GSINIT",
102         "_OVERLAY",
103         "_GSFINAL",
104         NULL,
105         NULL
106     },
107     { 
108         -1, 0, 0, 8, 0
109     },
110     /* Z80 has no native mul/div commands */
111     {  
112         0
113     },
114     _z80_init,
115     _z80_parseOptions,
116     _z80_finaliseOptions,
117     _z80_setDefaultOptions,
118     z80_assignRegisters,
119     _z80_getRegName,
120     _z80_keywords,
121     0,  /* no assembler preamble */
122     0,  /* no local IVT generation code */
123 };
124