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-2020 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 SUBTARGET_OVERRIDE_OPTIONS 43 #define SUBTARGET_OVERRIDE_OPTIONS \ 44 { \ 45 if (TARGET_COLDFIRE) \ 46 { \ 47 target_flags |= MASK_STRICT_ALIGNMENT | MASK_CF_HWDIV; \ 48 if ((target_flags_explicit & MASK_HARD_FLOAT) == 0) \ 49 { \ 50 target_flags &= ~MASK_HARD_FLOAT; \ 51 m68k_fpu = FPUTYPE_NONE; \ 52 } \ 53 } \ 54 } 55 56 57 /* Provide a CPP_SPEC appropriate for NetBSD m68k targets. Currently we 58 deal with the GCC option '-posix', as well as an indication as to 59 whether or not use of the FPU is allowed. */ 60 61 #undef CPP_SPEC 62 #define CPP_SPEC \ 63 "%(netbsd_cpp_spec)" 64 65 66 /* Provide an ASM_SPEC appropriate for NetBSD m68k ELF targets. We need 67 to pass PIC code generation options. */ 68 69 #undef ASM_SPEC 70 #define ASM_SPEC \ 71 "%(asm_cpu_spec) \ 72 %{m68010} %{m68020} %{m68030} %{m68040} %{m68060} \ 73 %{m5200} %{m5206e} %{m528x} %{m5307} %{m5407} %{mcfv4e} \ 74 %{" FPIE1_OR_FPIC1_SPEC ":-k} %{" FPIE2_OR_FPIC2_SPEC ":-k -K}" 75 76 /* Provide a LINK_SPEC appropriate for a NetBSD/m68k ELF target. */ 77 78 #undef LINK_SPEC 79 #define LINK_SPEC NETBSD_LINK_SPEC_ELF 80 81 /* NetBSD/sun2 does not support shlibs, avoid using libgcc_pic. */ 82 #ifndef ENABLE_SHARED_LIBGCC 83 #undef REAL_LIBGCC_SPEC 84 #define REAL_LIBGCC_SPEC "-lgcc" 85 #endif 86 87 #define NETBSD_ENTRY_POINT "_start" 88 89 /* Output assembler code to FILE to increment profiler label # LABELNO 90 for profiling a function only. */ 91 92 #undef FUNCTION_PROFILER 93 #define FUNCTION_PROFILER(FILE, LABELNO) \ 94 do \ 95 { \ 96 if (TARGET_COLDFIRE) \ 97 { \ 98 asm_fprintf (FILE, "\tmovea.l #%LLP%d-.,%Ra1\n", (LABELNO)); \ 99 asm_fprintf (FILE, "\tlea (-6,%Rpc,%Ra1),%Ra1\n"); \ 100 } \ 101 else \ 102 asm_fprintf (FILE, "\tlea (%LLP%d,%Rpc),%Ra1\n", (LABELNO)); \ 103 if (flag_pic) \ 104 fprintf (FILE, "\tbsr.l __mcount@PLTPC\n"); \ 105 else \ 106 fprintf (FILE, "\tjbsr __mcount\n"); \ 107 } \ 108 while (0) 109 110 111 /* Make gcc agree with <machine/ansi.h> */ 112 113 #undef SIZE_TYPE 114 #define SIZE_TYPE "unsigned int" 115 116 #undef PTRDIFF_TYPE 117 #define PTRDIFF_TYPE "int" 118 119 120 /* XXX 121 Here is a bunch of stuff lifted from m68kelf.h. We don't use that 122 file directly, because it has a lot of baggage we don't want. */ 123 124 125 /* The prefix for register names. Note that REGISTER_NAMES 126 is supposed to include this prefix. Also note that this is NOT an 127 fprintf format string, it is a literal string. */ 128 129 #undef REGISTER_PREFIX 130 #define REGISTER_PREFIX "%" 131 132 133 /* The prefix for local (compiler generated) lables. 134 These labels will not appear in the symbol table. */ 135 136 #undef LOCAL_LABEL_PREFIX 137 #define LOCAL_LABEL_PREFIX "." 138 139 140 /* The prefix to add to user-visible assembler symbols. */ 141 142 #undef USER_LABEL_PREFIX 143 #define USER_LABEL_PREFIX "" 144 145 146 #undef ASM_COMMENT_START 147 #define ASM_COMMENT_START "|" 148 149 150 /* Currently, JUMP_TABLES_IN_TEXT_SECTION must be defined in order to 151 keep switch tables in the text section. */ 152 153 #undef JUMP_TABLES_IN_TEXT_SECTION 154 #define JUMP_TABLES_IN_TEXT_SECTION 1 155 156 157 /* Use the default action for outputting the case label. */ 158 #undef ASM_OUTPUT_CASE_LABEL 159 #define ASM_RETURN_CASE_JUMP \ 160 do { \ 161 if (TARGET_COLDFIRE) \ 162 { \ 163 if (ADDRESS_REG_P (operands[0])) \ 164 return "jmp %%pc@(2,%0:l)"; \ 165 else if (TARGET_LONG_JUMP_TABLE_OFFSETS) \ 166 return "jmp %%pc@(2,%0:l)"; \ 167 else \ 168 return "ext%.l %0\n\tjmp %%pc@(2,%0:l)"; \ 169 } \ 170 else if (TARGET_LONG_JUMP_TABLE_OFFSETS) \ 171 return "jmp %%pc@(2,%0:l)"; \ 172 else \ 173 return "jmp %%pc@(2,%0:w)"; \ 174 } while (0) 175 176 177 /* This is how to output an assembler line that says to advance the 178 location counter to a multiple of 2**LOG bytes. */ 179 180 #undef ASM_OUTPUT_ALIGN 181 #define ASM_OUTPUT_ALIGN(FILE,LOG) \ 182 do \ 183 { \ 184 if ((LOG) > 0) \ 185 fprintf ((FILE), "%s%u\n", ALIGN_ASM_OP, 1 << (LOG)); \ 186 } \ 187 while (0) 188 189 190 /* If defined, a C expression whose value is a string containing the 191 assembler operation to identify the following data as uninitialized global 192 data. */ 193 194 #define BSS_SECTION_ASM_OP ".section\t.bss" 195 196 197 #undef ASM_OUTPUT_ALIGNED_BSS 198 #define ASM_OUTPUT_ALIGNED_BSS(FILE, DECL, NAME, SIZE, ALIGN) \ 199 asm_output_aligned_bss (FILE, DECL, NAME, SIZE, ALIGN) 200 201 202 #undef ASM_OUTPUT_COMMON 203 #define ASM_OUTPUT_COMMON(FILE, NAME, SIZE, ROUNDED) \ 204 ( fputs (".comm ", (FILE)), \ 205 assemble_name ((FILE), (NAME)), \ 206 fprintf ((FILE), ",%u\n", (int)(SIZE))) 207 208 #undef ASM_OUTPUT_LOCAL 209 #define ASM_OUTPUT_LOCAL(FILE, NAME, SIZE, ROUNDED) \ 210 ( fputs (".lcomm ", (FILE)), \ 211 assemble_name ((FILE), (NAME)), \ 212 fprintf ((FILE), ",%u\n", (int)(SIZE))) 213 214 215 /* XXX 216 This is the end of the chunk lifted from m68kelf.h */ 217 218 219 /* XXX 220 The following chunk is more or less lifted from m68kv4.h. 221 We'd like to just #include that file, but it has not yet 222 been converted to the new include style. 223 224 Should there be a m68kv4-abi.h ?? */ 225 226 227 /* Register in which address to store a structure value is passed to a 228 function. The default in m68k.h is a1. For m68k/SVR4 it is a0. */ 229 230 #undef M68K_STRUCT_VALUE_REGNUM 231 #define M68K_STRUCT_VALUE_REGNUM A0_REG 232 233 234 /* Register in which static-chain is passed to a function. The 235 default isn m68k.h is a0, but that is already the struct value 236 regnum. Make it a1 instead. */ 237 238 #undef STATIC_CHAIN_REGNUM 239 #define STATIC_CHAIN_REGNUM A1_REG 240 #undef M68K_STATIC_CHAIN_REG_NAME 241 #define M68K_STATIC_CHAIN_REG_NAME REGISTER_PREFIX "a1" 242 243 244 /* Now to renumber registers for dbx and gdb. 245 We use the Sun-3 convention, which is: 246 floating point registers have numbers 18 to 25, not 247 16 to 23 as they do in the compiler. */ 248 249 #undef DBX_REGISTER_NUMBER 250 #define DBX_REGISTER_NUMBER(REGNO) ((REGNO) < 16 ? (REGNO) : (REGNO) + 2) 251 252 253 /* 1 if N is a possible register number for a function value. For 254 m68k/SVR4 allow d0, a0, or fp0 as return registers, for integral, 255 pointer, or floating types, respectively. Reject fp0 if not using 256 a 68881 coprocessor. */ 257 258 #undef FUNCTION_VALUE_REGNO_P 259 #define FUNCTION_VALUE_REGNO_P(N) \ 260 ((N) == D0_REG || (N) == A0_REG || (TARGET_68881 && (N) == FP0_REG)) 261 262 263 /* Define this to be true when FUNCTION_VALUE_REGNO_P is true for 264 more than one register. */ 265 266 #undef NEEDS_UNTYPED_CALL 267 #define NEEDS_UNTYPED_CALL 1 268 269 270 /* Define how to generate (in the callee) the output value of a 271 function and how to find (in the caller) the value returned by a 272 function. VALTYPE is the data type of the value (as a tree). If 273 the precise function being called is known, FUNC is its 274 FUNCTION_DECL; otherwise, FUNC is 0. For m68k/SVR4 generate the 275 result in d0, a0, or fp0 as appropriate. */ 276 277 #undef FUNCTION_VALUE 278 #define FUNCTION_VALUE(VALTYPE, FUNC) \ 279 m68k_function_value (VALTYPE, FUNC) 280 281 282 /* Define how to find the value returned by a library function 283 assuming the value has mode MODE. 284 For m68k/SVR4 look for integer values in d0, pointer values in d0 285 (returned in both d0 and a0), and floating values in fp0. */ 286 287 #undef LIBCALL_VALUE 288 #define LIBCALL_VALUE(MODE) \ 289 m68k_libcall_value (MODE) 290 291 292 /* Boundary (in *bits*) on which stack pointer should be aligned. 293 The m68k/SVR4 convention is to keep the stack pointer longword aligned. */ 294 295 #undef PREFERRED_STACK_BOUNDARY 296 #define PREFERRED_STACK_BOUNDARY 32 297 298 299 /* Alignment of field after `int : 0' in a structure. 300 For m68k/SVR4, this is the next longword boundary. */ 301 302 #undef EMPTY_FIELD_BOUNDARY 303 #define EMPTY_FIELD_BOUNDARY 32 304 305 306 /* No data type wants to be aligned rounder than this. 307 For m68k/SVR4, some types (doubles for example) are aligned on 8 byte 308 boundaries */ 309 310 #undef BIGGEST_ALIGNMENT 311 #define BIGGEST_ALIGNMENT 64 312 313 314 /* The svr4 ABI for the m68k says that records and unions are returned 315 in memory. */ 316 317 #undef DEFAULT_PCC_STRUCT_RETURN 318 #define DEFAULT_PCC_STRUCT_RETURN 1 319 320 /* XXX 321 This is the end of the chunk lifted from m68kv4.h */ 322