Added -p command line option to allow selection of port dependent processor.
[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
39 static char *_tlcs900h_keywords[] =
40 {
41   NULL
42 };
43
44 void tlcs900h_assignRegisters (eBBlock ** ebbs, int count);
45
46 static void
47 _tlcs900h_init (void)
48 {
49   asm_addTree (&asm_asxxxx_mapping);
50   izt_init (&_tlcs900h_port);
51 }
52
53 static void
54 _tlcs900h_reset_regparm ()
55 {
56 }
57
58 static int
59 _tlcs900h_regparm (sym_link * l)
60 {
61   // PENDING: No register parameters.
62   return 0;
63 }
64
65 static bool
66 _tlcs900h_parseOptions (int *pargc, char **argv, int *i)
67 {
68   /* TODO: allow port-specific command line options to specify
69    * segment names here.
70    */
71   return FALSE;
72 }
73
74 static void
75 _tlcs900h_finaliseOptions (void)
76 {
77   // No options
78 }
79
80 static void
81 _tlcs900h_setDefaultOptions (void)
82 {
83   // No options
84 }
85
86 static const char *
87 _tlcs900h_getRegName (struct regs *reg)
88 {
89   if (reg)
90     return reg->name;
91   wassert (0);
92   return "err";
93 }
94
95 static void
96 _tlcs900h_genAssemblerPreamble (FILE * of)
97 {
98   // PENDING
99 }
100
101 /* Generate interrupt vector table. */
102 static int
103 _tlcs900h_genIVT (FILE * of, symbol ** interrupts, int maxInterrupts)
104 {
105   // PENDING
106   return 0;
107 }
108
109 /** $1 is always the basename.
110     $2 is always the output file.
111     $3 varies
112     $l is the list of extra options that should be there somewhere...
113     MUST be terminated with a NULL.
114 */
115 // PENDING
116 static const char *_linkCmd[] =
117 {
118   "aslink", "-nf", "$1", NULL
119 };
120
121 // PENDING
122 static const char *_asmCmd[] =
123 {
124   "gpasm", NULL, NULL, NULL
125 };
126
127 void
128 tlcs900h_assignRegisters (eBBlock ** ebbs, int count)
129 {
130 }
131
132 /* Globals */
133 PORT tlcs900h_port =
134 {
135   TARGET_ID_TLCS900H,
136   "tlcs900h",
137   "Toshiba TLCS-900H",          /* Target name */
138   NULL,
139   {
140     TRUE,                       /* Emit glue around main */
141     MODEL_SMALL,
142     MODEL_SMALL
143   },
144   {
145     _asmCmd,
146     NULL,
147     NULL,
148     NULL,
149     0,
150     NULL,
151     NULL                        /* no do_assemble function */
152   },
153   {
154     _linkCmd,
155     NULL,
156     NULL,
157     ".o"
158   },
159   {
160     _defaultRules
161   },
162   {
163         /* Sizes: char, short, int, long, ptr, fptr, gptr, bit, float, max */
164     1, 2, 2, 4, 2, 2, 2, 1, 4, 4
165   },
166   {
167     "XSEG    (XDATA)",
168     "STACK   (DATA)",
169     "CSEG    (CODE)",
170     "DSEG    (DATA)",
171     "ISEG    (DATA)",
172     "XSEG    (XDATA)",
173     "BSEG    (BIT)",
174     "RSEG    (DATA)",
175     "GSINIT  (CODE)",
176     "OSEG    (OVR,DATA)",
177     "GSFINAL (CODE)",
178     "HOME        (CODE)",
179     NULL, // xidata
180     NULL, // xinit
181     NULL,
182     NULL,
183     1
184   },
185   {
186     +1, 1, 4, 1, 1, 0
187   },
188     /* tlcs900h has an 16 bit mul */
189   {
190     2, -1
191   },
192   "_",
193   _tlcs900h_init,
194   _tlcs900h_parseOptions,
195   _tlcs900h_finaliseOptions,
196   _tlcs900h_setDefaultOptions,
197   tlcs900h_assignRegisters,
198   _tlcs900h_getRegName,
199   _tlcs900h_keywords,
200   _tlcs900h_genAssemblerPreamble,
201   NULL,                         /* no genAssemblerEnd */
202   _tlcs900h_genIVT,
203   0, // _tlcs900h_genXINIT
204   _tlcs900h_reset_regparm,
205   _tlcs900h_regparm,
206   NULL,
207   NULL,
208   NULL,
209   FALSE,
210   0,                            /* leave lt */
211   0,                            /* leave gt */
212   1,                            /* transform <= to ! > */
213   1,                            /* transform >= to ! < */
214   1,                            /* transform != to !(a == b) */
215   0,                            /* leave == */
216   FALSE,                        /* No array initializer support. */     
217   0,                            /* no CSE cost estimation yet */
218   NULL,                         /* no builtin functions */
219   GPOINTER,                     /* treat unqualified pointers as "generic" pointers */
220   1,                            /* reset labelKey to 1 */
221   1,                            /* globals & local static allowed */
222   PORT_MAGIC
223 };