xref: /netbsd-src/external/gpl3/gcc.old/dist/gcc/config/rx/linux.h (revision 4c3eb207d36f67d31994830c0a694161fc1ca39b)
1 /* GCC backend definitions for the rx-linux
2    Copyright (C) 2019 Yoshinori Sato
3    Based on rx.h
4 
5    This file is part of GCC.
6 
7    GCC is free software; you can redistribute it and/or modify it
8    under the terms of the GNU General Public License as published
9    by the Free Software Foundation; either version 3, or (at your
10    option) any later version.
11 
12    GCC is distributed in the hope that it will be useful, but WITHOUT
13    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
14    or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public
15    License for more details.
16 
17    You should have received a copy of the GNU General Public License
18    along with GCC; see the file COPYING3.  If not see
19    <http://www.gnu.org/licenses/>.  */
20 
21 
22 #include "config/rx/rx.h"
23 
24 #undef TARGET_CPU_CPP_BUILTINS
25 #define TARGET_CPU_CPP_BUILTINS()               \
26   do                                            \
27     {                                           \
28       builtin_define ("__RX__"); 		\
29       builtin_assert ("cpu=RX"); 		\
30       if (rx_cpu_type == RX610)			\
31         builtin_assert ("machine=RX610");	\
32      else					\
33         builtin_assert ("machine=RX600");	\
34       						\
35       if (TARGET_BIG_ENDIAN_DATA)		\
36 	builtin_define ("__RX_BIG_ENDIAN__");	\
37       else					\
38 	builtin_define ("__RX_LITTLE_ENDIAN__");\
39 						\
40       if (TARGET_64BIT_DOUBLES)			\
41 	builtin_define ("__RX_64BIT_DOUBLES__");\
42       else					\
43 	builtin_define ("__RX_32BIT_DOUBLES__");\
44       						\
45       if (ALLOW_RX_FPU_INSNS)			\
46 	builtin_define ("__RX_FPU_INSNS__");	\
47 						\
48     }                                           \
49   while (0)
50 
51 #undef  CC1_SPEC
52 #define CC1_SPEC "\
53   %{mcpu=rx200:%{fpu:%erx200 cpu does not have FPU hardware}}"
54 
55 #undef  ASM_SPEC
56 #define ASM_SPEC "\
57 %{mbig-endian-data:-mbig-endian-data} \
58 %{m64bit-doubles:-m64bit-doubles} \
59 %{!m64bit-doubles:-m32bit-doubles} \
60 %{msmall-data-limit*:-msmall-data-limit} \
61 %{mrelax:-relax} \
62 "
63 
64 #undef DATA_SECTION_ASM_OP
65 #define DATA_SECTION_ASM_OP	      			\
66    "\t.section .data,\"aw\",@progbits\n\t.p2align 2"
67 
68 #undef SDATA_SECTION_ASM_OP
69 #define SDATA_SECTION_ASM_OP	      			\
70    "\t.section .data2,\"aw\",@progbits\n\t.p2align 1"
71 
72 #undef  READONLY_DATA_SECTION_ASM_OP
73 #define READONLY_DATA_SECTION_ASM_OP  			\
74    "\t.section .rodata,\"a\",@progbits\n\t.p2align 2"
75 
76 #undef BSS_SECTION_ASM_OP
77 #define BSS_SECTION_ASM_OP	      			\
78    "\t.section .bss\n\t.p2align 2"
79 
80 #undef SBSS_SECTION_ASM_OP
81 #define SBSS_SECTION_ASM_OP	      			\
82    "\t.section .bss2\n\t.p2align 1"
83 
84 /* The following definitions are conditional depending upon whether the
85    compiler is being built or crtstuff.c is being compiled by the built
86    compiler.  */
87 #undef TEXT_SECTION_ASM_OP
88 #define TEXT_SECTION_ASM_OP	      \
89   "\t.section .text,\"ax\""
90 #undef CTORS_SECTION_ASM_OP
91 #define CTORS_SECTION_ASM_OP	      \
92   "\t.section\t.init_array,\"aw\",@init_array"
93 #undef DTORS_SECTION_ASM_OP
94 #define DTORS_SECTION_ASM_OP	      \
95   "\t.section\t.fini_array,\"aw\",@fini_array"
96 #undef INIT_ARRAY_SECTION_ASM_OP
97 #define INIT_ARRAY_SECTION_ASM_OP   \
98   "\t.section\t.init_array,\"aw\",@init_array"
99 #undef FINI_ARRAY_SECTION_ASM_OP
100 #define FINI_ARRAY_SECTION_ASM_OP   \
101   "\t.section\t.fini_array,\"aw\",@fini_array"
102 
103 #undef GLOBAL_ASM_OP
104 #define GLOBAL_ASM_OP		"\t.global\t"
105 #undef  USER_LABEL_PREFIX
106 
107 #undef ASM_OUTPUT_ALIGN
108 #define ASM_OUTPUT_ALIGN(STREAM, LOG)		\
109   do						\
110     {						\
111       if ((LOG) == 0)				\
112         break;					\
113       fprintf (STREAM, "\t.balign %d\n", 1 << (LOG));	\
114     }						\
115   while (0)
116 
117 #undef ASM_OUTPUT_ADDR_VEC_ELT
118 #define ASM_OUTPUT_ADDR_VEC_ELT(FILE, VALUE) \
119   fprintf (FILE, "\t.long .L%d\n", VALUE)
120 
121 /* This is how to output an element of a case-vector that is relative.
122    Note: The local label referenced by the "1b" below is emitted by
123    the tablejump insn.  */
124 
125 #undef ASM_OUTPUT_ADDR_DIFF_ELT
126 #define ASM_OUTPUT_ADDR_DIFF_ELT(FILE, BODY, VALUE, REL) \
127   fprintf (FILE, "\t.long .L%d - 1b\n", VALUE)
128 
129 #undef ASM_OUTPUT_SIZE_DIRECTIVE
130 #define ASM_OUTPUT_SIZE_DIRECTIVE(STREAM, NAME, SIZE)			\
131   do									\
132     {									\
133       HOST_WIDE_INT size_ = (SIZE);					\
134 									\
135       fputs (SIZE_ASM_OP, STREAM);					\
136       assemble_name (STREAM, NAME);					\
137       fprintf (STREAM, ", " HOST_WIDE_INT_PRINT_DEC "\n", size_);	\
138     }									\
139   while (0)
140 
141 #undef ASM_OUTPUT_MEASURED_SIZE
142 #define ASM_OUTPUT_MEASURED_SIZE(STREAM, NAME)				\
143   do									\
144     {									\
145       fputs (SIZE_ASM_OP, STREAM);					\
146       assemble_name (STREAM, NAME);					\
147       fputs (", .-", STREAM);						\
148       assemble_name (STREAM, NAME);					\
149       putc ('\n', STREAM);						\
150     }									\
151   while (0)
152 
153 #undef ASM_OUTPUT_TYPE_DIRECTIVE
154 #define ASM_OUTPUT_TYPE_DIRECTIVE(STREAM, NAME, TYPE)			\
155   do									\
156     {									\
157       fputs (TYPE_ASM_OP, STREAM);					\
158       assemble_name (STREAM, NAME);					\
159       fputs (", ", STREAM);						\
160       fprintf (STREAM, TYPE_OPERAND_FMT, TYPE);				\
161       putc ('\n', STREAM);						\
162     }									\
163   while (0)
164 
165 #undef  ASM_GENERATE_INTERNAL_LABEL
166 #define ASM_GENERATE_INTERNAL_LABEL(LABEL, PREFIX, NUM)		\
167   do								\
168     {								\
169       sprintf (LABEL, "*.%s%u", PREFIX, (unsigned) (NUM));			\
170     }								\
171   while (0)
172 
173 #undef  ASM_OUTPUT_EXTERNAL
174 #define ASM_OUTPUT_EXTERNAL(FILE, DECL, NAME)			\
175   do								\
176     {								\
177       default_elf_asm_output_external (FILE, DECL, NAME);	\
178     }								\
179   while (0)
180 
181 #undef  ASM_OUTPUT_ALIGNED_COMMON
182 #define ASM_OUTPUT_ALIGNED_COMMON(FILE, NAME, SIZE, ALIGN)		\
183   do									\
184     {									\
185       fprintf ((FILE), "%s", COMMON_ASM_OP);				\
186       assemble_name ((FILE), (NAME));					\
187       fprintf ((FILE), "," HOST_WIDE_INT_PRINT_UNSIGNED ",%u\n",	\
188 	       (SIZE), (ALIGN) / BITS_PER_UNIT);			\
189     }									\
190   while (0)
191 
192 #undef  SKIP_ASM_OP
193 #define SKIP_ASM_OP   "\t.zero\t"
194 
195 #undef  ASM_OUTPUT_LIMITED_STRING
196 #define ASM_OUTPUT_LIMITED_STRING(FILE, STR)		\
197   do							\
198     {							\
199       const unsigned char *_limited_str =		\
200 	(const unsigned char *) (STR);			\
201       unsigned ch;					\
202 							\
203       fprintf ((FILE), "\t.string\t\"");		\
204 							\
205       for (; (ch = *_limited_str); _limited_str++)	\
206         {						\
207 	  int escape;					\
208 							\
209 	  switch (escape = ESCAPES[ch])			\
210 	    {						\
211 	    case 0:					\
212 	      putc (ch, (FILE));			\
213 	      break;					\
214 	    case 1:					\
215 	      fprintf ((FILE), "\\%03o", ch);		\
216 	      break;					\
217 	    default:					\
218 	      putc ('\\', (FILE));			\
219 	      putc (escape, (FILE));			\
220 	      break;					\
221 	    }						\
222         }						\
223 							\
224       fprintf ((FILE), "\"\n");				\
225     }							\
226   while (0)
227 
228 #undef  PREFERRED_DEBUGGING_TYPE
229 
230 #undef TARGET_AS100_SYNTAX
231 #define TARGET_AS100_SYNTAX 0
232