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