1 /* Definitions of target machine for GNU compiler, 2 for m68k (including m68010) NetBSD platforms using the 3 ELF object format. 4 Copyright (C) 2002, 2003, 2004, 2006, 2007 Free Software Foundation, Inc. 5 Contributed by Wasabi Systems. Inc. 6 7 This file is derived from <m68k/m68kv4.h>, <m68k/m68kelf.h>, 8 and <m68k/linux.h>. 9 10 This file is part of GCC. 11 12 GCC is free software; you can redistribute it and/or modify 13 it under the terms of the GNU General Public License as published by 14 the Free Software Foundation; either version 3, or (at your option) 15 any later version. 16 17 GCC is distributed in the hope that it will be useful, 18 but WITHOUT ANY WARRANTY; without even the implied warranty of 19 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 GNU General Public License for more details. 21 22 You should have received a copy of the GNU General Public License 23 along with GCC; see the file COPYING3. If not see 24 <http://www.gnu.org/licenses/>. */ 25 26 #define TARGET_OS_CPP_BUILTINS() \ 27 do \ 28 { \ 29 NETBSD_OS_CPP_BUILTINS_ELF(); \ 30 builtin_define ("__m68k__"); \ 31 builtin_define ("__SVR4_ABI__"); \ 32 builtin_define ("__motorola__"); \ 33 if (TARGET_HARD_FLOAT) \ 34 builtin_define ("__HAVE_FPU__"); \ 35 } \ 36 while (0) 37 38 /* Don't try using XFmode on the 68010 or coldfire. */ 39 #undef LONG_DOUBLE_TYPE_SIZE 40 #define LONG_DOUBLE_TYPE_SIZE (TARGET_68020 ? 80 : 64) 41 42 #undef LIBGCC2_LONG_DOUBLE_TYPE_SIZE 43 #if defined(__mc68010__) || defined(__mcoldfire__) 44 #define LIBGCC2_LONG_DOUBLE_TYPE_SIZE 64 45 #else 46 #define LIBGCC2_LONG_DOUBLE_TYPE_SIZE 80 47 #endif 48 49 #undef SUBTARGET_OVERRIDE_OPTIONS 50 #define SUBTARGET_OVERRIDE_OPTIONS \ 51 { \ 52 if (TARGET_COLDFIRE) \ 53 { \ 54 target_flags |= MASK_STRICT_ALIGNMENT | MASK_CF_HWDIV; \ 55 if ((target_flags_explicit & MASK_HARD_FLOAT) == 0) \ 56 { \ 57 target_flags &= ~MASK_HARD_FLOAT; \ 58 m68k_fpu = FPUTYPE_NONE; \ 59 } \ 60 } \ 61 } 62 63 #undef SUBTARGET_EXTRA_SPECS 64 #define SUBTARGET_EXTRA_SPECS \ 65 { "netbsd_cpp_spec", NETBSD_CPP_SPEC }, \ 66 { "netbsd_entry_point", NETBSD_ENTRY_POINT }, 67 68 69 #undef TARGET_VERSION 70 #define TARGET_VERSION fprintf (stderr, " (NetBSD/m68k ELF)"); 71 72 73 /* Provide a CPP_SPEC appropriate for NetBSD m68k targets. Currently we 74 deal with the GCC option '-posix', as well as an indication as to 75 whether or not use of the FPU is allowed. */ 76 77 #undef CPP_SPEC 78 #define CPP_SPEC \ 79 "%(netbsd_cpp_spec)" 80 81 82 /* Provide an ASM_SPEC appropriate for NetBSD m68k ELF targets. We need 83 to pass PIC code generation options. */ 84 85 #undef ASM_SPEC 86 #define ASM_SPEC \ 87 "%(asm_default_spec) \ 88 %{m68010} %{m68020} %{m68030} %{m68040} %{m68060} \ 89 %{m5200} %{m5206e} %{m528x} %{m5307} %{m5407} %{mcfv4e}\ 90 %{mcpu=*:-mcpu=%*} %{march=*:-march=%*}\ 91 %{fpic|fpie:-k} %{fPIC|fPIE:-k -K}" 92 93 #define AS_NEEDS_DASH_FOR_PIPED_INPUT 94 95 /* Provide a LINK_SPEC appropriate for a NetBSD/m68k ELF target. */ 96 97 #undef LINK_SPEC 98 #define LINK_SPEC NETBSD_LINK_SPEC_ELF 99 100 /* NetBSD/sun2 does not support shlibs, avoid using libgcc_pic. */ 101 #if TARGET_DEFAULT_CPU == 0 102 #undef REAL_LIBGCC_SPEC 103 #endif 104 105 #define NETBSD_ENTRY_POINT "_start" 106 107 /* Output assembler code to FILE to increment profiler label # LABELNO 108 for profiling a function only. */ 109 110 #undef FUNCTION_PROFILER 111 #define FUNCTION_PROFILER(FILE, LABELNO) \ 112 do \ 113 { \ 114 if (TARGET_COLDFIRE) \ 115 { \ 116 asm_fprintf (FILE, "\tmovea.l #%LLP%d-.,%Ra1\n", (LABELNO)); \ 117 asm_fprintf (FILE, "\tlea (-6,%Rpc,%Ra1),%Ra1\n", (LABELNO)); \ 118 } \ 119 else \ 120 asm_fprintf (FILE, "\tlea (%LLP%d,%Rpc),%Ra1\n", (LABELNO)); \ 121 if (flag_pic) \ 122 fprintf (FILE, "\tbsr.l __mcount@PLTPC\n"); \ 123 else \ 124 fprintf (FILE, "\tjbsr __mcount\n"); \ 125 } \ 126 while (0) 127 128 129 /* Make gcc agree with <machine/ansi.h> */ 130 131 #undef SIZE_TYPE 132 #define SIZE_TYPE "unsigned int" 133 134 #undef PTRDIFF_TYPE 135 #define PTRDIFF_TYPE "int" 136 137 138 /* XXX 139 Here is a bunch of stuff lifted from m68kelf.h. We don't use that 140 file directly, because it has a lot of baggage we don't want. */ 141 142 143 /* The prefix for register names. Note that REGISTER_NAMES 144 is supposed to include this prefix. Also note that this is NOT an 145 fprintf format string, it is a literal string. */ 146 147 #undef REGISTER_PREFIX 148 #define REGISTER_PREFIX "%" 149 150 151 /* The prefix for local (compiler generated) lables. 152 These labels will not appear in the symbol table. */ 153 154 #undef LOCAL_LABEL_PREFIX 155 #define LOCAL_LABEL_PREFIX "." 156 157 158 /* The prefix to add to user-visible assembler symbols. */ 159 160 #undef USER_LABEL_PREFIX 161 #define USER_LABEL_PREFIX "" 162 163 164 #undef ASM_COMMENT_START 165 #define ASM_COMMENT_START "|" 166 167 168 /* Currently, JUMP_TABLES_IN_TEXT_SECTION must be defined in order to 169 keep switch tables in the text section. */ 170 171 #undef JUMP_TABLES_IN_TEXT_SECTION 172 #define JUMP_TABLES_IN_TEXT_SECTION 1 173 174 175 /* Use the default action for outputting the case label. */ 176 #undef ASM_OUTPUT_CASE_LABEL 177 #define ASM_RETURN_CASE_JUMP \ 178 do { \ 179 if (TARGET_COLDFIRE) \ 180 { \ 181 if (ADDRESS_REG_P (operands[0])) \ 182 return "jmp %%pc@(2,%0:l)"; \ 183 else \ 184 return "ext%.l %0\n\tjmp %%pc@(2,%0:l)"; \ 185 } \ 186 else \ 187 return "jmp %%pc@(2,%0:w)"; \ 188 } while (0) 189 190 191 /* This is how to output an assembler line that says to advance the 192 location counter to a multiple of 2**LOG bytes. */ 193 194 #undef ASM_OUTPUT_ALIGN 195 #define ASM_OUTPUT_ALIGN(FILE,LOG) \ 196 do \ 197 { \ 198 if ((LOG) > 0) \ 199 fprintf ((FILE), "%s%u\n", ALIGN_ASM_OP, 1 << (LOG)); \ 200 } \ 201 while (0) 202 203 204 /* If defined, a C expression whose value is a string containing the 205 assembler operation to identify the following data as uninitialized global 206 data. */ 207 208 #define BSS_SECTION_ASM_OP ".section\t.bss" 209 210 211 /* Like `ASM_OUTPUT_BSS' except takes the required alignment as a 212 separate, explicit argument. If you define this macro, it is used 213 in place of `ASM_OUTPUT_BSS', and gives you more flexibility in 214 handling the required alignment of the variable. The alignment is 215 specified as the number of bits. 216 217 Try to use function `asm_output_aligned_bss' defined in file 218 `varasm.c' when defining this macro. */ 219 220 #undef ASM_OUTPUT_ALIGNED_BSS 221 #define ASM_OUTPUT_ALIGNED_BSS(FILE, DECL, NAME, SIZE, ALIGN) \ 222 asm_output_aligned_bss (FILE, DECL, NAME, SIZE, ALIGN) 223 224 225 #undef ASM_OUTPUT_COMMON 226 #define ASM_OUTPUT_COMMON(FILE, NAME, SIZE, ROUNDED) \ 227 ( fputs (".comm ", (FILE)), \ 228 assemble_name ((FILE), (NAME)), \ 229 fprintf ((FILE), ",%u\n", (int)(SIZE))) 230 231 #undef ASM_OUTPUT_LOCAL 232 #define ASM_OUTPUT_LOCAL(FILE, NAME, SIZE, ROUNDED) \ 233 ( fputs (".lcomm ", (FILE)), \ 234 assemble_name ((FILE), (NAME)), \ 235 fprintf ((FILE), ",%u\n", (int)(SIZE))) 236 237 238 /* XXX 239 This is the end of the chunk lifted from m68kelf.h */ 240 241 242 /* XXX 243 The following chunk is more or less lifted from m68kv4.h. 244 We'd like to just #include that file, but it has not yet 245 been converted to the new include style. 246 247 Should there be a m68kv4-abi.h ?? */ 248 249 250 /* Register in which address to store a structure value is passed to a 251 function. The default in m68k.h is a1. For m68k/SVR4 it is a0. */ 252 253 #undef M68K_STRUCT_VALUE_REGNUM 254 #define M68K_STRUCT_VALUE_REGNUM A0_REG 255 256 257 /* Register in which static-chain is passed to a function. The 258 default isn m68k.h is a0, but that is already the struct value 259 regnum. Make it a1 instead. */ 260 261 #undef STATIC_CHAIN_REGNUM 262 #define STATIC_CHAIN_REGNUM A1_REG 263 #undef M68K_STATIC_CHAIN_REG_NAME 264 #define M68K_STATIC_CHAIN_REG_NAME REGISTER_PREFIX "a1" 265 266 267 /* Now to renumber registers for dbx and gdb. 268 We use the Sun-3 convention, which is: 269 floating point registers have numbers 18 to 25, not 270 16 to 23 as they do in the compiler. */ 271 272 #undef DBX_REGISTER_NUMBER 273 #define DBX_REGISTER_NUMBER(REGNO) ((REGNO) < 16 ? (REGNO) : (REGNO) + 2) 274 275 276 /* 1 if N is a possible register number for a function value. For 277 m68k/SVR4 allow d0, a0, or fp0 as return registers, for integral, 278 pointer, or floating types, respectively. Reject fp0 if not using 279 a 68881 coprocessor. */ 280 281 #undef FUNCTION_VALUE_REGNO_P 282 #define FUNCTION_VALUE_REGNO_P(N) \ 283 ((N) == D0_REG || (N) == A0_REG || (TARGET_68881 && (N) == FP0_REG)) 284 285 286 /* Define this to be true when FUNCTION_VALUE_REGNO_P is true for 287 more than one register. */ 288 289 #undef NEEDS_UNTYPED_CALL 290 #define NEEDS_UNTYPED_CALL 1 291 292 293 /* Define how to generate (in the callee) the output value of a 294 function and how to find (in the caller) the value returned by a 295 function. VALTYPE is the data type of the value (as a tree). If 296 the precise function being called is known, FUNC is its 297 FUNCTION_DECL; otherwise, FUNC is 0. For m68k/SVR4 generate the 298 result in d0, a0, or fp0 as appropriate. */ 299 300 #undef FUNCTION_VALUE 301 #define FUNCTION_VALUE(VALTYPE, FUNC) \ 302 m68k_function_value (VALTYPE, FUNC) 303 304 305 /* Define how to find the value returned by a library function 306 assuming the value has mode MODE. 307 For m68k/SVR4 look for integer values in d0, pointer values in d0 308 (returned in both d0 and a0), and floating values in fp0. */ 309 310 #undef LIBCALL_VALUE 311 #define LIBCALL_VALUE(MODE) \ 312 m68k_libcall_value (MODE) 313 314 315 /* Boundary (in *bits*) on which stack pointer should be aligned. 316 The m68k/SVR4 convention is to keep the stack pointer longword aligned. */ 317 318 #undef STACK_BOUNDARY 319 #define STACK_BOUNDARY 32 320 #undef PREFERRED_STACK_BOUNDARY 321 #define PREFERRED_STACK_BOUNDARY 32 322 323 324 /* Alignment of field after `int : 0' in a structure. 325 For m68k/SVR4, this is the next longword boundary. */ 326 327 #undef EMPTY_FIELD_BOUNDARY 328 #define EMPTY_FIELD_BOUNDARY 32 329 330 331 /* No data type wants to be aligned rounder than this. 332 For m68k/SVR4, some types (doubles for example) are aligned on 8 byte 333 boundaries */ 334 335 #undef BIGGEST_ALIGNMENT 336 #define BIGGEST_ALIGNMENT 64 337 338 339 /* The svr4 ABI for the m68k says that records and unions are returned 340 in memory. */ 341 342 #undef DEFAULT_PCC_STRUCT_RETURN 343 #define DEFAULT_PCC_STRUCT_RETURN 1 344 345 /* XXX 346 This is the end of the chunk lifted from m68kv4.h */ 347