annotate gcc/config/msp430/msp430.h @ 145:1830386684a0

gcc-9.2.0
author anatofuz
date Thu, 13 Feb 2020 11:34:05 +0900
parents 84e7813d76e9
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
111
kono
parents:
diff changeset
1 /* GCC backend definitions for the TI MSP430 Processor
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
2 Copyright (C) 2012-2020 Free Software Foundation, Inc.
111
kono
parents:
diff changeset
3 Contributed by Red Hat.
kono
parents:
diff changeset
4
kono
parents:
diff changeset
5 This file is part of GCC.
kono
parents:
diff changeset
6
kono
parents:
diff changeset
7 GCC is free software; you can redistribute it and/or modify it
kono
parents:
diff changeset
8 under the terms of the GNU General Public License as published
kono
parents:
diff changeset
9 by the Free Software Foundation; either version 3, or (at your
kono
parents:
diff changeset
10 option) any later version.
kono
parents:
diff changeset
11
kono
parents:
diff changeset
12 GCC is distributed in the hope that it will be useful, but WITHOUT
kono
parents:
diff changeset
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
kono
parents:
diff changeset
14 or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
kono
parents:
diff changeset
15 License for more details.
kono
parents:
diff changeset
16
kono
parents:
diff changeset
17 You should have received a copy of the GNU General Public License
kono
parents:
diff changeset
18 along with GCC; see the file COPYING3. If not see
kono
parents:
diff changeset
19 <http://www.gnu.org/licenses/>. */
kono
parents:
diff changeset
20
kono
parents:
diff changeset
21
kono
parents:
diff changeset
22 /* Run-time Target Specification */
kono
parents:
diff changeset
23
kono
parents:
diff changeset
24 /* True if the MSP430x extensions are enabled. */
kono
parents:
diff changeset
25 #ifndef IN_LIBGCC2
kono
parents:
diff changeset
26 extern bool msp430x;
kono
parents:
diff changeset
27 #endif
kono
parents:
diff changeset
28
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
29 #define TARGET_CPU_CPP_BUILTINS() \
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
30 do \
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
31 { \
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
32 builtin_define ("NO_TRAMPOLINES"); \
111
kono
parents:
diff changeset
33 builtin_define ("__MSP430__"); \
kono
parents:
diff changeset
34 builtin_define (msp430_mcu_name ()); \
kono
parents:
diff changeset
35 if (msp430x) \
kono
parents:
diff changeset
36 { \
kono
parents:
diff changeset
37 builtin_define ("__MSP430X__"); \
kono
parents:
diff changeset
38 builtin_assert ("cpu=MSP430X"); \
kono
parents:
diff changeset
39 if (TARGET_LARGE) \
kono
parents:
diff changeset
40 builtin_define ("__MSP430X_LARGE__"); \
kono
parents:
diff changeset
41 } \
kono
parents:
diff changeset
42 else \
kono
parents:
diff changeset
43 builtin_assert ("cpu=MSP430"); \
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
44 } \
111
kono
parents:
diff changeset
45 while (0)
kono
parents:
diff changeset
46
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
47 /* For the "c" language where exceptions are implicitly disabled, use
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
48 crt*_no_eh.o unless -fexceptions is passed. For other languages, only use
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
49 crt*_no_eh.o if -fno-exceptions is explicitly passed. */
111
kono
parents:
diff changeset
50 #undef STARTFILE_SPEC
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
51 #define STARTFILE_SPEC "%{pg:gcrt0.o%s}" \
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
52 "%{!pg:%{minrt:crt0-minrt.o%s}%{!minrt:crt0.o%s}} " \
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
53 "%{!minrt:%{,c:%{!fexceptions:crtbegin_no_eh.o%s; :crtbegin.o%s}; " \
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
54 ":%{fno-exceptions:crtbegin_no_eh.o%s; :crtbegin.o%s}}}"
111
kono
parents:
diff changeset
55
kono
parents:
diff changeset
56 /* -lgcc is included because crtend.o needs __mspabi_func_epilog_1. */
kono
parents:
diff changeset
57 #undef ENDFILE_SPEC
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
58 #define ENDFILE_SPEC \
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
59 "%{!minrt:%{,c:%{!fexceptions:crtend_no_eh.o%s; :crtend.o%s}; " \
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
60 ":%{fno-exceptions:crtend_no_eh.o%s; :crtend.o%s}}} " \
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
61 "%{minrt:%:if-exists(crtn-minrt.o%s)}%{!minrt:%:if-exists(crtn.o%s)} -lgcc"
111
kono
parents:
diff changeset
62
kono
parents:
diff changeset
63 #define ASM_SPEC "-mP " /* Enable polymorphic instructions. */ \
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
64 "%{mcpu=*:-mcpu=%*} " /* Pass the CPU type on to the assembler. */ \
111
kono
parents:
diff changeset
65 "%{mrelax=-mQ} " /* Pass the relax option on to the assembler. */ \
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
66 /* Tell the assembler if we are building for the LARGE pointer model. */ \
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
67 "%{mlarge:-ml} " \
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
68 /* Copy data from ROM to RAM if necessary. */ \
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
69 "%{!msim:-md} %{msim:%{mlarge:-md}} " \
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
70 "%{msilicon-errata=*:-msilicon-errata=%*} " \
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
71 "%{msilicon-errata-warn=*:-msilicon-errata-warn=%*} " \
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
72 /* Create DWARF line number sections for -ffunction-sections. */ \
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
73 "%{ffunction-sections:-gdwarf-sections} " \
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
74 "%{mdata-region=*:-mdata-region=%*} "
111
kono
parents:
diff changeset
75
kono
parents:
diff changeset
76 /* Enable linker section garbage collection by default, unless we
kono
parents:
diff changeset
77 are creating a relocatable binary (gc does not work) or debugging
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
78 is enabled (the GDB testsuite relies upon unused entities not being
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
79 deleted). */
111
kono
parents:
diff changeset
80 #define LINK_SPEC "%{mrelax:--relax} %{mlarge:%{!r:%{!g:--gc-sections}}} " \
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
81 "%{mcode-region=*:--code-region=%:" \
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
82 "msp430_propagate_region_opt(%* %{muse-lower-region-prefix})} " \
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
83 "%{mdata-region=*:--data-region=%:" \
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
84 "msp430_propagate_region_opt(%* %{muse-lower-region-prefix})} " \
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
85 "%:msp430_get_linker_devices_include_path() " \
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
86 "%{mtiny-printf:--wrap puts --wrap printf} "
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
87
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
88 #define DRIVER_SELF_SPECS \
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
89 " %{!mlarge:%{mcode-region=*:%{mdata-region=*:%e-mcode-region and " \
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
90 "-mdata-region require the large memory model (-mlarge)}}}" \
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
91 " %{!mlarge:%{mcode-region=*:" \
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
92 "%e-mcode-region requires the large memory model (-mlarge)}}" \
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
93 " %{!mlarge:%{mdata-region=*:" \
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
94 "%e-mdata-region requires the large memory model (-mlarge)}}" \
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
95 " %{mno-warn-devices-csv:%:msp430_set_driver_var(msp430_warn_devices_csv 0)}"\
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
96 " %{mdevices-csv-loc=*:%:msp430_set_driver_var(msp430_devices_csv_loc %*)}"\
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
97 " %{I*:%:msp430_check_path_for_devices(%{I*:%*})}" \
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
98 " %{L*:%:msp430_check_path_for_devices(%{L*:%*})}" \
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
99 " %{!mcpu=*:%{mmcu=*:%:msp430_select_cpu(%{mmcu=*:%*})}}"
111
kono
parents:
diff changeset
100
kono
parents:
diff changeset
101 extern const char * msp430_select_hwmult_lib (int, const char **);
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
102 extern const char * msp430_select_cpu (int, const char **);
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
103 extern const char * msp430_set_driver_var (int, const char **);
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
104 extern const char * msp430_check_path_for_devices (int, const char **);
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
105 extern const char *msp430_propagate_region_opt (int, const char **);
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
106 extern const char *msp430_get_linker_devices_include_path (int, const char **);
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
107
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
108 /* There must be a trailing comma after the last item, see gcc.c
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
109 "static_spec_functions". */
111
kono
parents:
diff changeset
110 # define EXTRA_SPEC_FUNCTIONS \
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
111 { "msp430_hwmult_lib", msp430_select_hwmult_lib }, \
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
112 { "msp430_select_cpu", msp430_select_cpu }, \
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
113 { "msp430_set_driver_var", msp430_set_driver_var }, \
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
114 { "msp430_check_path_for_devices", msp430_check_path_for_devices }, \
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
115 { "msp430_propagate_region_opt", msp430_propagate_region_opt }, \
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
116 { "msp430_get_linker_devices_include_path", \
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
117 msp430_get_linker_devices_include_path },
111
kono
parents:
diff changeset
118
kono
parents:
diff changeset
119 /* Specify the libraries to include on the linker command line.
kono
parents:
diff changeset
120
kono
parents:
diff changeset
121 Selecting the hardware multiply library to use is quite complex.
kono
parents:
diff changeset
122 If the user has specified -mhwmult=FOO then the mapping is quite
kono
parents:
diff changeset
123 easy (and could be handled here in the SPEC string), unless FOO
kono
parents:
diff changeset
124 is set to AUTO. In this case the -mmcu= option must be consulted
kono
parents:
diff changeset
125 instead. If the -mhwmult= option is not specified then the -mmcu=
kono
parents:
diff changeset
126 option must then be examined. If neither -mhwmult= nor -mmcu= are
kono
parents:
diff changeset
127 specified then a default hardware multiply library is used.
kono
parents:
diff changeset
128
kono
parents:
diff changeset
129 Examining the -mmcu=FOO option is difficult, and it is so this
kono
parents:
diff changeset
130 reason that a spec function is used. There are so many possible
kono
parents:
diff changeset
131 values of FOO that a table is used to look up the name and map
kono
parents:
diff changeset
132 it to a hardware multiply library. This table (in device-msp430.c)
kono
parents:
diff changeset
133 must be kept in sync with the same table in msp430.c. */
kono
parents:
diff changeset
134 #undef LIB_SPEC
kono
parents:
diff changeset
135 #define LIB_SPEC " \
kono
parents:
diff changeset
136 --start-group \
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
137 %{mhwmult=auto:%{mmcu=*:%:msp430_hwmult_lib(mcu %{mmcu=*:%*});\
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
138 :%:msp430_hwmult_lib(default)}; \
111
kono
parents:
diff changeset
139 mhwmult=*:%:msp430_hwmult_lib(hwmult %{mhwmult=*:%*}); \
kono
parents:
diff changeset
140 mmcu=*:%:msp430_hwmult_lib(mcu %{mmcu=*:%*}); \
kono
parents:
diff changeset
141 :%:msp430_hwmult_lib(default)} \
kono
parents:
diff changeset
142 -lc \
kono
parents:
diff changeset
143 -lgcc \
kono
parents:
diff changeset
144 -lcrt \
kono
parents:
diff changeset
145 %{msim:-lsim} \
kono
parents:
diff changeset
146 %{!msim:-lnosys} \
kono
parents:
diff changeset
147 --end-group \
kono
parents:
diff changeset
148 %{!T*:%{!msim:%{mmcu=*:--script=%*.ld}}} \
kono
parents:
diff changeset
149 %{!T*:%{msim:%{mlarge:%Tmsp430xl-sim.ld}%{!mlarge:%Tmsp430-sim.ld}}} \
kono
parents:
diff changeset
150 "
kono
parents:
diff changeset
151
kono
parents:
diff changeset
152 /* Storage Layout */
kono
parents:
diff changeset
153
kono
parents:
diff changeset
154 #define BITS_BIG_ENDIAN 0
kono
parents:
diff changeset
155 #define BYTES_BIG_ENDIAN 0
kono
parents:
diff changeset
156 #define WORDS_BIG_ENDIAN 0
kono
parents:
diff changeset
157
kono
parents:
diff changeset
158
kono
parents:
diff changeset
159 #ifdef IN_LIBGCC2
kono
parents:
diff changeset
160 /* This is to get correct SI and DI modes in libgcc2.c (32 and 64 bits). */
kono
parents:
diff changeset
161 #define UNITS_PER_WORD 4
kono
parents:
diff changeset
162 /* We have a problem with libgcc2. It only defines two versions of
kono
parents:
diff changeset
163 each function, one for "int" and one for "long long". Ie it assumes
kono
parents:
diff changeset
164 that "sizeof (int) == sizeof (long)". For the MSP430 this is not true
kono
parents:
diff changeset
165 and we need a third set of functions. We explicitly define
kono
parents:
diff changeset
166 LIBGCC2_UNITS_PER_WORD here so that it is clear that we are expecting
kono
parents:
diff changeset
167 to get the SI and DI versions from the libgcc2.c sources, and we
kono
parents:
diff changeset
168 provide our own set of HI functions, which is why this
kono
parents:
diff changeset
169 definition is surrounded by #ifndef..#endif. */
kono
parents:
diff changeset
170 #ifndef LIBGCC2_UNITS_PER_WORD
kono
parents:
diff changeset
171 #define LIBGCC2_UNITS_PER_WORD 4
kono
parents:
diff changeset
172 #endif
kono
parents:
diff changeset
173 #else
kono
parents:
diff changeset
174 /* Actual width of a word, in units (bytes). */
kono
parents:
diff changeset
175 #define UNITS_PER_WORD 2
kono
parents:
diff changeset
176 #endif
kono
parents:
diff changeset
177
kono
parents:
diff changeset
178 #define SHORT_TYPE_SIZE 16
kono
parents:
diff changeset
179 #define INT_TYPE_SIZE 16
kono
parents:
diff changeset
180 #define LONG_TYPE_SIZE 32
kono
parents:
diff changeset
181 #define LONG_LONG_TYPE_SIZE 64
kono
parents:
diff changeset
182
kono
parents:
diff changeset
183 #define FLOAT_TYPE_SIZE 32
kono
parents:
diff changeset
184 #define DOUBLE_TYPE_SIZE 64
kono
parents:
diff changeset
185 #define LONG_DOUBLE_TYPE_SIZE 64 /*DOUBLE_TYPE_SIZE*/
kono
parents:
diff changeset
186
kono
parents:
diff changeset
187 #define DEFAULT_SIGNED_CHAR 0
kono
parents:
diff changeset
188
kono
parents:
diff changeset
189 #define STRICT_ALIGNMENT 1
kono
parents:
diff changeset
190 #define FUNCTION_BOUNDARY 16
kono
parents:
diff changeset
191 #define BIGGEST_ALIGNMENT 16
kono
parents:
diff changeset
192 #define STACK_BOUNDARY 16
kono
parents:
diff changeset
193 #define PARM_BOUNDARY 8
kono
parents:
diff changeset
194 #define PCC_BITFIELD_TYPE_MATTERS 1
kono
parents:
diff changeset
195
kono
parents:
diff changeset
196 #define STACK_GROWS_DOWNWARD 1
kono
parents:
diff changeset
197 #define FRAME_GROWS_DOWNWARD 1
kono
parents:
diff changeset
198 #define FIRST_PARM_OFFSET(FNDECL) 0
kono
parents:
diff changeset
199
kono
parents:
diff changeset
200 #define MAX_REGS_PER_ADDRESS 1
kono
parents:
diff changeset
201
kono
parents:
diff changeset
202 #define Pmode (TARGET_LARGE ? PSImode : HImode)
kono
parents:
diff changeset
203 #define POINTER_SIZE (TARGET_LARGE ? 20 : 16)
kono
parents:
diff changeset
204 /* This is just for .eh_frame, to match bfd. */
kono
parents:
diff changeset
205 #define PTR_SIZE (TARGET_LARGE ? 4 : 2)
kono
parents:
diff changeset
206 #define POINTERS_EXTEND_UNSIGNED 1
kono
parents:
diff changeset
207
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
208 /* TARGET_VTABLE_ENTRY_ALIGN defaults to POINTER_SIZE, which is 20 for
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
209 TARGET_LARGE. Pointer alignment is always 16 for MSP430, so set explicitly
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
210 here. */
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
211 #define TARGET_VTABLE_ENTRY_ALIGN 16
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
212
111
kono
parents:
diff changeset
213 #define ADDR_SPACE_NEAR 1
kono
parents:
diff changeset
214 #define ADDR_SPACE_FAR 2
kono
parents:
diff changeset
215
kono
parents:
diff changeset
216 #define REGISTER_TARGET_PRAGMAS() msp430_register_pragmas()
kono
parents:
diff changeset
217
kono
parents:
diff changeset
218 #if 1 /* XXX */
kono
parents:
diff changeset
219 /* Define this macro if it is advisable to hold scalars in registers
kono
parents:
diff changeset
220 in a wider mode than that declared by the program. In such cases,
kono
parents:
diff changeset
221 the value is constrained to be within the bounds of the declared
kono
parents:
diff changeset
222 type, but kept valid in the wider mode. The signedness of the
kono
parents:
diff changeset
223 extension may differ from that of the type. */
kono
parents:
diff changeset
224
kono
parents:
diff changeset
225 #define PROMOTE_MODE(MODE, UNSIGNEDP, TYPE) \
kono
parents:
diff changeset
226 if (GET_MODE_CLASS (MODE) == MODE_INT \
kono
parents:
diff changeset
227 && GET_MODE_SIZE (MODE) < 2) \
kono
parents:
diff changeset
228 (MODE) = HImode;
kono
parents:
diff changeset
229 #endif
kono
parents:
diff changeset
230
kono
parents:
diff changeset
231 /* Layout of Source Language Data Types */
kono
parents:
diff changeset
232
kono
parents:
diff changeset
233 #undef SIZE_TYPE
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
234 #define SIZE_TYPE (TARGET_LARGE \
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
235 ? "__int20__ unsigned" \
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
236 : "unsigned int")
111
kono
parents:
diff changeset
237 #undef PTRDIFF_TYPE
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
238 #define PTRDIFF_TYPE (TARGET_LARGE ? "__int20__" : "int")
111
kono
parents:
diff changeset
239 #undef WCHAR_TYPE
kono
parents:
diff changeset
240 #define WCHAR_TYPE "long int"
kono
parents:
diff changeset
241 #undef WCHAR_TYPE_SIZE
kono
parents:
diff changeset
242 #define WCHAR_TYPE_SIZE BITS_PER_WORD
kono
parents:
diff changeset
243 #define FUNCTION_MODE HImode
kono
parents:
diff changeset
244 #define CASE_VECTOR_MODE Pmode
kono
parents:
diff changeset
245 #define HAS_LONG_COND_BRANCH 0
kono
parents:
diff changeset
246 #define HAS_LONG_UNCOND_BRANCH 0
kono
parents:
diff changeset
247
kono
parents:
diff changeset
248 #define LOAD_EXTEND_OP(M) ZERO_EXTEND
kono
parents:
diff changeset
249 #define WORD_REGISTER_OPERATIONS 1
kono
parents:
diff changeset
250
kono
parents:
diff changeset
251 #define MOVE_MAX 8
kono
parents:
diff changeset
252
kono
parents:
diff changeset
253 #define INCOMING_RETURN_ADDR_RTX \
kono
parents:
diff changeset
254 msp430_incoming_return_addr_rtx ()
kono
parents:
diff changeset
255
kono
parents:
diff changeset
256 #define RETURN_ADDR_RTX(COUNT, FA) \
kono
parents:
diff changeset
257 msp430_return_addr_rtx (COUNT)
kono
parents:
diff changeset
258
kono
parents:
diff changeset
259 #define SLOW_BYTE_ACCESS 0
kono
parents:
diff changeset
260
kono
parents:
diff changeset
261
kono
parents:
diff changeset
262 /* Register Usage */
kono
parents:
diff changeset
263
kono
parents:
diff changeset
264 /* gas doesn't recognize PC (R0), SP (R1), and SR (R2) as register
kono
parents:
diff changeset
265 names. */
kono
parents:
diff changeset
266 #define REGISTER_NAMES \
kono
parents:
diff changeset
267 { \
kono
parents:
diff changeset
268 "R0", "R1", "R2", "R3", "R4", "R5", "R6", "R7", \
kono
parents:
diff changeset
269 "R8", "R9", "R10", "R11", "R12", "R13", "R14", "R15", \
kono
parents:
diff changeset
270 "argptr" \
kono
parents:
diff changeset
271 }
kono
parents:
diff changeset
272
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
273 /* Allow lowercase "r" to be used in register names instead of upper
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
274 case "R". */
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
275 #define ADDITIONAL_REGISTER_NAMES \
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
276 { \
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
277 { "r0", 0 }, \
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
278 { "r1", 1 }, \
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
279 { "r2", 2 }, \
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
280 { "r3", 3 }, \
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
281 { "r4", 4 }, \
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
282 { "r5", 5 }, \
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
283 { "r6", 6 }, \
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
284 { "r7", 7 }, \
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
285 { "r8", 8 }, \
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
286 { "r9", 9 }, \
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
287 { "r10", 10 }, \
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
288 { "r11", 11 }, \
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
289 { "r12", 12 }, \
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
290 { "r13", 13 }, \
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
291 { "r14", 14 }, \
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
292 { "r15", 15 } \
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
293 }
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
294
111
kono
parents:
diff changeset
295 enum reg_class
kono
parents:
diff changeset
296 {
kono
parents:
diff changeset
297 NO_REGS,
kono
parents:
diff changeset
298 R12_REGS,
kono
parents:
diff changeset
299 R13_REGS,
kono
parents:
diff changeset
300 GEN_REGS,
kono
parents:
diff changeset
301 ALL_REGS,
kono
parents:
diff changeset
302 LIM_REG_CLASSES
kono
parents:
diff changeset
303 };
kono
parents:
diff changeset
304
kono
parents:
diff changeset
305 #define REG_CLASS_NAMES \
kono
parents:
diff changeset
306 { \
kono
parents:
diff changeset
307 "NO_REGS", \
kono
parents:
diff changeset
308 "R12_REGS", \
kono
parents:
diff changeset
309 "R13_REGS", \
kono
parents:
diff changeset
310 "GEN_REGS", \
kono
parents:
diff changeset
311 "ALL_REGS" \
kono
parents:
diff changeset
312 }
kono
parents:
diff changeset
313
kono
parents:
diff changeset
314 #define REG_CLASS_CONTENTS \
kono
parents:
diff changeset
315 { \
kono
parents:
diff changeset
316 0x00000000, \
kono
parents:
diff changeset
317 0x00001000, \
kono
parents:
diff changeset
318 0x00002000, \
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
319 0x0000fff3, \
111
kono
parents:
diff changeset
320 0x0001ffff \
kono
parents:
diff changeset
321 }
kono
parents:
diff changeset
322
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
323 /* GENERAL_REGS just means that the "g" and "r" constraints can use these
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
324 registers.
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
325 Even though R0 (PC) and R1 (SP) are not "general" in that they can be used
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
326 for any purpose by the register allocator, they are general in that they can
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
327 be used by any instruction in any addressing mode. */
111
kono
parents:
diff changeset
328 #define GENERAL_REGS GEN_REGS
kono
parents:
diff changeset
329 #define BASE_REG_CLASS GEN_REGS
kono
parents:
diff changeset
330 #define INDEX_REG_CLASS GEN_REGS
kono
parents:
diff changeset
331 #define N_REG_CLASSES (int) LIM_REG_CLASSES
kono
parents:
diff changeset
332
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
333 #define PC_REGNUM 0
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
334 #define STACK_POINTER_REGNUM 1
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
335 #define CC_REGNUM 2
111
kono
parents:
diff changeset
336 #define FRAME_POINTER_REGNUM 4 /* not usually used, call preserved */
kono
parents:
diff changeset
337 #define ARG_POINTER_REGNUM 16
kono
parents:
diff changeset
338 #define STATIC_CHAIN_REGNUM 5 /* FIXME */
kono
parents:
diff changeset
339
kono
parents:
diff changeset
340 #define FIRST_PSEUDO_REGISTER 17
kono
parents:
diff changeset
341
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
342 #define REGNO_REG_CLASS(REGNO) (REGNO != 2 \
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
343 && REGNO != 3 \
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
344 && REGNO < 17 \
111
kono
parents:
diff changeset
345 ? GEN_REGS : NO_REGS)
kono
parents:
diff changeset
346
kono
parents:
diff changeset
347 #define TRAMPOLINE_SIZE 4 /* FIXME */
kono
parents:
diff changeset
348 #define TRAMPOLINE_ALIGNMENT 16 /* FIXME */
kono
parents:
diff changeset
349
kono
parents:
diff changeset
350 #define ELIMINABLE_REGS \
kono
parents:
diff changeset
351 {{ ARG_POINTER_REGNUM, STACK_POINTER_REGNUM }, \
kono
parents:
diff changeset
352 { ARG_POINTER_REGNUM, FRAME_POINTER_REGNUM }, \
kono
parents:
diff changeset
353 { FRAME_POINTER_REGNUM, STACK_POINTER_REGNUM }}
kono
parents:
diff changeset
354
kono
parents:
diff changeset
355 #define INITIAL_ELIMINATION_OFFSET(FROM, TO, OFFSET) \
kono
parents:
diff changeset
356 (OFFSET) = msp430_initial_elimination_offset ((FROM), (TO))
kono
parents:
diff changeset
357
kono
parents:
diff changeset
358
kono
parents:
diff changeset
359 #define FUNCTION_ARG_REGNO_P(N) ((N) >= 8 && (N) < ARG_POINTER_REGNUM)
kono
parents:
diff changeset
360 #define DEFAULT_PCC_STRUCT_RETURN 0
kono
parents:
diff changeset
361
kono
parents:
diff changeset
362 /* 1 == register can't be used by gcc, in general
kono
parents:
diff changeset
363 0 == register can be used by gcc, in general */
kono
parents:
diff changeset
364 #define FIXED_REGISTERS \
kono
parents:
diff changeset
365 { \
kono
parents:
diff changeset
366 1,0,1,1, 0,0,0,0, \
kono
parents:
diff changeset
367 0,0,0,0, 0,0,0,0, \
kono
parents:
diff changeset
368 1, \
kono
parents:
diff changeset
369 }
kono
parents:
diff changeset
370
kono
parents:
diff changeset
371 /* 1 == value changes across function calls
kono
parents:
diff changeset
372 0 == value is the same after a call */
kono
parents:
diff changeset
373 /* R4 through R10 are callee-saved */
kono
parents:
diff changeset
374 #define CALL_USED_REGISTERS \
kono
parents:
diff changeset
375 { \
kono
parents:
diff changeset
376 1,0,1,1, 0,0,0,0, \
kono
parents:
diff changeset
377 0,0,0,1, 1,1,1,1, \
kono
parents:
diff changeset
378 1, \
kono
parents:
diff changeset
379 }
kono
parents:
diff changeset
380
kono
parents:
diff changeset
381 #define REG_ALLOC_ORDER \
kono
parents:
diff changeset
382 { 12, 13, 14, 15, 10, 9, 8, 7, 6, 5, 4, 11, 0, 1, 2, 3, 16 }
kono
parents:
diff changeset
383 /* { 11, 15, 14, 13, 12, 10, 9, 8, 7, 6, 5, 4, 0, 1, 2, 3, 16 }*/
kono
parents:
diff changeset
384
kono
parents:
diff changeset
385 #define REGNO_OK_FOR_BASE_P(regno) 1
kono
parents:
diff changeset
386 #define REGNO_OK_FOR_INDEX_P(regno) 1
kono
parents:
diff changeset
387
kono
parents:
diff changeset
388
kono
parents:
diff changeset
389
kono
parents:
diff changeset
390 typedef struct
kono
parents:
diff changeset
391 {
kono
parents:
diff changeset
392 /* These two are the current argument status. */
kono
parents:
diff changeset
393 char reg_used[4];
kono
parents:
diff changeset
394 #define CA_FIRST_REG 12
kono
parents:
diff changeset
395 char can_split;
kono
parents:
diff changeset
396 /* These two are temporaries used internally. */
kono
parents:
diff changeset
397 char start_reg;
kono
parents:
diff changeset
398 char reg_count;
kono
parents:
diff changeset
399 char mem_count;
kono
parents:
diff changeset
400 char special_p;
kono
parents:
diff changeset
401 } CUMULATIVE_ARGS;
kono
parents:
diff changeset
402
kono
parents:
diff changeset
403 #define INIT_CUMULATIVE_ARGS(CA, FNTYPE, LIBNAME, INDIRECT, N_NAMED_ARGS) \
kono
parents:
diff changeset
404 msp430_init_cumulative_args (&CA, FNTYPE, LIBNAME, INDIRECT, N_NAMED_ARGS)
kono
parents:
diff changeset
405
kono
parents:
diff changeset
406
kono
parents:
diff changeset
407 /* FIXME */
kono
parents:
diff changeset
408 #define NO_PROFILE_COUNTERS 1
kono
parents:
diff changeset
409 #define PROFILE_BEFORE_PROLOGUE 1
kono
parents:
diff changeset
410
kono
parents:
diff changeset
411 #define FUNCTION_PROFILER(FILE, LABELNO) \
kono
parents:
diff changeset
412 fprintf (FILE, "\tcall\t__mcount\n");
kono
parents:
diff changeset
413
kono
parents:
diff changeset
414 /* Exception Handling */
kono
parents:
diff changeset
415
kono
parents:
diff changeset
416 /* R12,R13,R14 - EH data
kono
parents:
diff changeset
417 R15 - stack adjustment */
kono
parents:
diff changeset
418
kono
parents:
diff changeset
419 #define EH_RETURN_DATA_REGNO(N) \
kono
parents:
diff changeset
420 (((N) < 3) ? ((N) + 12) : INVALID_REGNUM)
kono
parents:
diff changeset
421
kono
parents:
diff changeset
422 #define EH_RETURN_HANDLER_RTX \
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
423 gen_rtx_MEM (Pmode, gen_rtx_PLUS (Pmode, gen_rtx_REG (Pmode, SP_REGNO), \
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
424 gen_rtx_REG (Pmode, 15)))
111
kono
parents:
diff changeset
425
kono
parents:
diff changeset
426 #define EH_RETURN_STACKADJ_RTX gen_rtx_REG (Pmode, 15)
kono
parents:
diff changeset
427
kono
parents:
diff changeset
428 #define ASM_PREFERRED_EH_DATA_FORMAT(CODE,GLOBAL) DW_EH_PE_udata4
kono
parents:
diff changeset
429
kono
parents:
diff changeset
430
kono
parents:
diff changeset
431 /* Stack Layout and Calling Conventions */
kono
parents:
diff changeset
432
kono
parents:
diff changeset
433
kono
parents:
diff changeset
434 /* Addressing Modes */
kono
parents:
diff changeset
435
kono
parents:
diff changeset
436
kono
parents:
diff changeset
437
kono
parents:
diff changeset
438 #define TEXT_SECTION_ASM_OP ".text"
kono
parents:
diff changeset
439 #define DATA_SECTION_ASM_OP ".data"
kono
parents:
diff changeset
440 #define BSS_SECTION_ASM_OP "\t.section .bss"
kono
parents:
diff changeset
441
kono
parents:
diff changeset
442 #define ASM_COMMENT_START " ;"
kono
parents:
diff changeset
443 #define ASM_APP_ON ""
kono
parents:
diff changeset
444 #define ASM_APP_OFF ""
kono
parents:
diff changeset
445 #define LOCAL_LABEL_PREFIX ".L"
kono
parents:
diff changeset
446 #undef USER_LABEL_PREFIX
kono
parents:
diff changeset
447 #define USER_LABEL_PREFIX ""
kono
parents:
diff changeset
448
kono
parents:
diff changeset
449 #define GLOBAL_ASM_OP "\t.global\t"
kono
parents:
diff changeset
450
kono
parents:
diff changeset
451 #define ASM_OUTPUT_LABELREF(FILE, SYM) msp430_output_labelref ((FILE), (SYM))
kono
parents:
diff changeset
452
kono
parents:
diff changeset
453 #define ASM_OUTPUT_ADDR_VEC_ELT(FILE, VALUE) \
kono
parents:
diff changeset
454 fprintf (FILE, "\t.long .L%d\n", VALUE)
kono
parents:
diff changeset
455
kono
parents:
diff changeset
456 /* This is how to output an element of a case-vector that is relative.
kono
parents:
diff changeset
457 Note: The local label referenced by the "3b" below is emitted by
kono
parents:
diff changeset
458 the tablejump insn. */
kono
parents:
diff changeset
459
kono
parents:
diff changeset
460 #define ASM_OUTPUT_ADDR_DIFF_ELT(FILE, BODY, VALUE, REL) \
kono
parents:
diff changeset
461 fprintf (FILE, "\t.long .L%d - 1b\n", VALUE)
kono
parents:
diff changeset
462
kono
parents:
diff changeset
463
kono
parents:
diff changeset
464 #define ASM_OUTPUT_ALIGN(STREAM, LOG) \
kono
parents:
diff changeset
465 do \
kono
parents:
diff changeset
466 { \
kono
parents:
diff changeset
467 if ((LOG) == 0) \
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
468 break; \
111
kono
parents:
diff changeset
469 fprintf (STREAM, "\t.balign %d\n", 1 << (LOG)); \
kono
parents:
diff changeset
470 } \
kono
parents:
diff changeset
471 while (0)
kono
parents:
diff changeset
472
kono
parents:
diff changeset
473 #define JUMP_TABLES_IN_TEXT_SECTION 1
kono
parents:
diff changeset
474
kono
parents:
diff changeset
475 #undef DWARF2_ADDR_SIZE
kono
parents:
diff changeset
476 #define DWARF2_ADDR_SIZE 4
kono
parents:
diff changeset
477
kono
parents:
diff changeset
478 #define INCOMING_FRAME_SP_OFFSET (TARGET_LARGE ? 4 : 2)
kono
parents:
diff changeset
479
kono
parents:
diff changeset
480 #undef PREFERRED_DEBUGGING_TYPE
kono
parents:
diff changeset
481 #define PREFERRED_DEBUGGING_TYPE DWARF2_DEBUG
kono
parents:
diff changeset
482
kono
parents:
diff changeset
483 #define DWARF2_ASM_LINE_DEBUG_INFO 1
kono
parents:
diff changeset
484
kono
parents:
diff changeset
485 /* Prevent reload (and others) from choosing HImode stack slots
kono
parents:
diff changeset
486 when spilling hard registers when they may contain PSImode values. */
kono
parents:
diff changeset
487 #define HARD_REGNO_CALLER_SAVE_MODE(REGNO,NREGS,MODE) \
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
488 ((TARGET_LARGE && ((NREGS) <= 2)) ? PSImode \
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
489 : choose_hard_reg_mode ((REGNO), (NREGS), NULL))
111
kono
parents:
diff changeset
490
kono
parents:
diff changeset
491 #define ACCUMULATE_OUTGOING_ARGS 1
kono
parents:
diff changeset
492
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
493 #define HAVE_POST_INCREMENT 1
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
494
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
495 /* This (unsurprisingly) improves code size in the vast majority of cases, we
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
496 want to prevent any instructions using a "store post increment" from being
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
497 generated. These will have to later be reloaded since msp430 does not
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
498 support post inc for the destination operand. */
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
499 #define USE_STORE_POST_INCREMENT(MODE) 0
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
500
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
501 /* Many other targets set USE_LOAD_POST_INCREMENT to 0. For msp430-elf
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
502 the benefit of disabling it is not clear. When looking at code size, on
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
503 average, there is a slight advantage to leaving it enabled. */
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
504
111
kono
parents:
diff changeset
505 #undef ASM_DECLARE_FUNCTION_NAME
kono
parents:
diff changeset
506 #define ASM_DECLARE_FUNCTION_NAME(FILE, NAME, DECL) \
kono
parents:
diff changeset
507 msp430_start_function ((FILE), (NAME), (DECL))
kono
parents:
diff changeset
508
kono
parents:
diff changeset
509 #define TARGET_HAS_NO_HW_DIVIDE (! TARGET_HWMULT)
kono
parents:
diff changeset
510
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
511 void msp430_register_pre_includes (const char *sysroot ATTRIBUTE_UNUSED,
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
512 const char *iprefix ATTRIBUTE_UNUSED,
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
513 int stdinc ATTRIBUTE_UNUSED);
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
514 #undef TARGET_EXTRA_PRE_INCLUDES
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
515 #define TARGET_EXTRA_PRE_INCLUDES msp430_register_pre_includes
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
516
111
kono
parents:
diff changeset
517 #undef USE_SELECT_SECTION_FOR_FUNCTIONS
kono
parents:
diff changeset
518 #define USE_SELECT_SECTION_FOR_FUNCTIONS 1
kono
parents:
diff changeset
519
kono
parents:
diff changeset
520 #define ASM_OUTPUT_ALIGNED_DECL_COMMON(FILE, DECL, NAME, SIZE, ALIGN) \
kono
parents:
diff changeset
521 msp430_output_aligned_decl_common ((FILE), (DECL), (NAME), (SIZE), (ALIGN))
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
522
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
523 #define SYMBOL_FLAG_LOW_MEM (SYMBOL_FLAG_MACH_DEP << 0)