Added post increment optimization for msc51 &
[fw/sdcc] / src / izt / tlcs900h.c
1 /** @file izt/tlcs900h.c
2     tlcs900h specific general functions.
3 */
4 #include "izt.h"
5
6 static REG _tlcs900h_regs[] =
7 {
8   {1, REG_ID_C, "c", 0,
9    {REG_ID_BC, REG_ID_NONE, REG_ID_NONE}},
10   {1, REG_ID_B, "b", 0,
11    {REG_ID_BC, REG_ID_NONE, REG_ID_NONE}},
12   {1, REG_ID_E, "e", 0,
13    {REG_ID_DE, REG_ID_NONE, REG_ID_NONE}},
14   {1, REG_ID_D, "d", 0,
15    {REG_ID_DE, REG_ID_NONE, REG_ID_NONE}},
16   {2, REG_ID_BC, "bc", 0,
17    {REG_ID_C, REG_ID_B, REG_ID_NONE}},
18   {2, REG_ID_DE, "de", 0,
19    {REG_ID_E, REG_ID_D, REG_ID_NONE}},
20   {4, REG_ID_XBC, "xbc", 0,
21    {REG_ID_C, REG_ID_B, REG_ID_BC}},
22   {4, REG_ID_XDE, "xde", 0,
23    {REG_ID_E, REG_ID_D, REG_ID_DE}},
24   {0, REG_ID_NONE, "??", 0,
25    {REG_ID_NONE, REG_ID_NONE, REG_ID_NONE}}
26 };
27
28 static IZT_PORT _tlcs900h_port =
29 {
30   _tlcs900h_regs
31 };
32
33 static char _defaultRules[] =
34 {
35     //#include "peeph.rul"
36 };
37
38 static char *_tlcs900h_keywords[] =
39 {
40   NULL
41 };
42
43 void tlcs900h_assignRegisters (eBBlock ** ebbs, int count);
44
45 static void
46 _tlcs900h_init (void)
47 {
48   asm_addTree (&asm_asxxxx_mapping);
49   izt_init (&_tlcs900h_port);
50 }
51
52 static void
53 _tlcs900h_reset_regparm ()
54 {
55 }
56
57 static int
58 _tlcs900h_regparm (sym_link * l)
59 {
60   // PENDING: No register parameters.
61   return 0;
62 }
63
64 static bool
65 _tlcs900h_parseOptions (int *pargc, char **argv, int *i)
66 {
67   /* TODO: allow port-specific command line options to specify
68    * segment names here.
69    */
70   return FALSE;
71 }
72
73 static void
74 _tlcs900h_finaliseOptions (void)
75 {
76   // No options
77 }
78
79 static void
80 _tlcs900h_setDefaultOptions (void)
81 {
82   // No options
83 }
84
85 static const char *
86 _tlcs900h_getRegName (struct regs *reg)
87 {
88   if (reg)
89     return reg->name;
90   wassert (0);
91   return "err";
92 }
93
94 static void
95 _tlcs900h_genAssemblerPreamble (FILE * of)
96 {
97   // PENDING
98 }
99
100 /* Generate interrupt vector table. */
101 static int
102 _tlcs900h_genIVT (FILE * of, symbol ** interrupts, int maxInterrupts)
103 {
104   // PENDING
105   return 0;
106 }
107
108 /** $1 is always the basename.
109     $2 is always the output file.
110     $3 varies
111     $l is the list of extra options that should be there somewhere...
112     MUST be terminated with a NULL.
113 */
114 // PENDING
115 static const char *_linkCmd[] =
116 {
117   "aslink", "-nf", "$1", NULL
118 };
119
120 // PENDING
121 static const char *_asmCmd[] =
122 {
123   "gpasm", NULL, NULL, NULL
124 };
125
126 void
127 tlcs900h_assignRegisters (eBBlock ** ebbs, int count)
128 {
129 }
130
131 /* Globals */
132 PORT tlcs900h_port =
133 {
134   TARGET_ID_TLCS900H,
135   "tlcs900h",
136   "Toshiba TLCS-900H",          /* Target name */
137   {
138     TRUE,                       /* Emit glue around main */
139     MODEL_SMALL,
140     MODEL_SMALL
141   },
142   {
143     _asmCmd,
144     NULL,
145     NULL,
146     0,
147     NULL
148   },
149   {
150     _linkCmd,
151     NULL,
152     ".o"
153   },
154   {
155     _defaultRules
156   },
157   {
158         /* Sizes: char, short, int, long, ptr, fptr, gptr, bit, float, max */
159     1, 2, 2, 4, 2, 2, 2, 1, 4, 4
160   },
161   {
162     "XSEG    (XDATA)",
163     "STACK   (DATA)",
164     "CSEG    (CODE)",
165     "DSEG    (DATA)",
166     "ISEG    (DATA)",
167     "XSEG    (XDATA)",
168     "BSEG    (BIT)",
169     "RSEG    (DATA)",
170     "GSINIT  (CODE)",
171     "OSEG    (OVR,DATA)",
172     "GSFINAL (CODE)",
173     "HOME        (CODE)",
174     NULL,
175     NULL,
176     1
177   },
178   {
179     +1, 1, 4, 1, 1, 0
180   },
181     /* tlcs900h has an 16 bit mul */
182   {
183     2, 0
184   },
185   "_",
186   _tlcs900h_init,
187   _tlcs900h_parseOptions,
188   _tlcs900h_finaliseOptions,
189   _tlcs900h_setDefaultOptions,
190   tlcs900h_assignRegisters,
191   _tlcs900h_getRegName,
192   _tlcs900h_keywords,
193   _tlcs900h_genAssemblerPreamble,
194   _tlcs900h_genIVT,
195   _tlcs900h_reset_regparm,
196   _tlcs900h_regparm,
197   NULL,
198   FALSE,
199   0,                            /* leave lt */
200   0,                            /* leave gt */
201   1,                            /* transform <= to ! > */
202   1,                            /* transform >= to ! < */
203   1,                            /* transform != to !(a == b) */
204   0,                            /* leave == */
205   PORT_MAGIC
206 };