1*404b540aSrobert /* Definitions for GCC. Part of the machine description for CRIS. 2*404b540aSrobert Copyright (C) 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc. 3*404b540aSrobert Contributed by Axis Communications. Written by Hans-Peter Nilsson. 4*404b540aSrobert 5*404b540aSrobert This file is part of GCC. 6*404b540aSrobert 7*404b540aSrobert GCC is free software; you can redistribute it and/or modify 8*404b540aSrobert it under the terms of the GNU General Public License as published by 9*404b540aSrobert the Free Software Foundation; either version 2, or (at your option) 10*404b540aSrobert any later version. 11*404b540aSrobert 12*404b540aSrobert GCC is distributed in the hope that it will be useful, 13*404b540aSrobert but WITHOUT ANY WARRANTY; without even the implied warranty of 14*404b540aSrobert MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15*404b540aSrobert GNU General Public License for more details. 16*404b540aSrobert 17*404b540aSrobert You should have received a copy of the GNU General Public License 18*404b540aSrobert along with GCC; see the file COPYING. If not, write to 19*404b540aSrobert the Free Software Foundation, 51 Franklin Street, Fifth Floor, 20*404b540aSrobert Boston, MA 02110-1301, USA. */ 21*404b540aSrobert 22*404b540aSrobert /* After the first "Node:" comment comes all preprocessor directives and 23*404b540aSrobert attached declarations described in the info files, the "Using and 24*404b540aSrobert Porting GCC" manual (uapgcc), in the same order as found in the "Target 25*404b540aSrobert macros" section in the gcc-2.9x CVS edition of 2000-03-17. FIXME: Not 26*404b540aSrobert really, but needs an update anyway. 27*404b540aSrobert 28*404b540aSrobert There is no generic copy-of-uapgcc comment, you'll have to see uapgcc 29*404b540aSrobert for that. If applicable, there is a CRIS-specific comment. The order 30*404b540aSrobert of macro definitions follow the order in the manual. Every section in 31*404b540aSrobert the manual (node in the info pages) has an introductory `Node: 32*404b540aSrobert <subchapter>' comment. If no macros are defined for a section, only 33*404b540aSrobert the section-comment is present. */ 34*404b540aSrobert 35*404b540aSrobert /* This file defines the macros for a.out that are not covered by cris.h. 36*404b540aSrobert Many macros are copied from elfos.h and should be in some generic 37*404b540aSrobert config/gas-aout.h. */ 38*404b540aSrobert 39*404b540aSrobert /* Node: Driver */ 40*404b540aSrobert 41*404b540aSrobert #undef STARTFILE_SPEC 42*404b540aSrobert #define STARTFILE_SPEC \ 43*404b540aSrobert "%{melinux:crt0.o%s}\ 44*404b540aSrobert %{!melinux:%{sim*:crt1.o%s}%{!sim*:crt0.o%s}}" 45*404b540aSrobert 46*404b540aSrobert /* Override cris.h define. */ 47*404b540aSrobert #undef ENDFILE_SPEC 48*404b540aSrobert 49*404b540aSrobert #undef CRIS_CPP_SUBTARGET_SPEC 50*404b540aSrobert #define CRIS_CPP_SUBTARGET_SPEC \ 51*404b540aSrobert "%{melinux:-D__gnu_linux__ -D__linux__ -D__unix__ -D__elinux__ -D__uclinux__\ 52*404b540aSrobert %{!ansi:%{!std=*:%{!undef:-Dlinux -Dunix -Delinux -Duclinux}}}}\ 53*404b540aSrobert %{mbest-lib-options:\ 54*404b540aSrobert %{!moverride-best-lib-options:\ 55*404b540aSrobert %{!march=*:%{!metrax*:%{!mcpu=*:-D__tune_v8 -D__CRIS_arch_tune=8}}}}}" 56*404b540aSrobert 57*404b540aSrobert #undef CRIS_CC1_SUBTARGET_SPEC 58*404b540aSrobert #define CRIS_CC1_SUBTARGET_SPEC \ 59*404b540aSrobert "%{mbest-lib-options:\ 60*404b540aSrobert %{!moverride-best-lib-options:\ 61*404b540aSrobert %{!march=*:%{!mcpu=*:-mtune=v8}}}}" 62*404b540aSrobert 63*404b540aSrobert #undef CRIS_ASM_SUBTARGET_SPEC 64*404b540aSrobert #define CRIS_ASM_SUBTARGET_SPEC "--em=crisaout" 65*404b540aSrobert 66*404b540aSrobert #undef CRIS_LINK_SUBTARGET_SPEC 67*404b540aSrobert #define CRIS_LINK_SUBTARGET_SPEC \ 68*404b540aSrobert "-mcrisaout\ 69*404b540aSrobert %{sim2:%{!T*:-Tdata 0x4000000 -Tbss 0x8000000}}\ 70*404b540aSrobert %{melinux:-Ur -d\ 71*404b540aSrobert %{!shlib:%{!symbolic:-Bstatic}}\ 72*404b540aSrobert %{shlib:-Bdynamic}\ 73*404b540aSrobert %{symbolic:-Bdynamic}\ 74*404b540aSrobert %{static:-Bstatic}}\ 75*404b540aSrobert %{melinux-stacksize=*:-defsym __Stacksize=%*}" 76*404b540aSrobert 77*404b540aSrobert /* Previously controlled by target_flags. */ 78*404b540aSrobert #undef TARGET_ELF 79*404b540aSrobert #define TARGET_ELF 0 80*404b540aSrobert 81*404b540aSrobert #undef CRIS_SUBTARGET_HANDLE_OPTION 82*404b540aSrobert #define CRIS_SUBTARGET_HANDLE_OPTION(CODE, ARG, VALUE) \ 83*404b540aSrobert do \ 84*404b540aSrobert { \ 85*404b540aSrobert switch (CODE) \ 86*404b540aSrobert { \ 87*404b540aSrobert case OPT_melinux: \ 88*404b540aSrobert target_flags \ 89*404b540aSrobert |= (MASK_SVINTO \ 90*404b540aSrobert + MASK_STACK_ALIGN \ 91*404b540aSrobert + MASK_CONST_ALIGN \ 92*404b540aSrobert + MASK_DATA_ALIGN \ 93*404b540aSrobert + MASK_ETRAX4_ADD \ 94*404b540aSrobert + MASK_ALIGN_BY_32); \ 95*404b540aSrobert break; \ 96*404b540aSrobert \ 97*404b540aSrobert default: \ 98*404b540aSrobert break; \ 99*404b540aSrobert } \ 100*404b540aSrobert } \ 101*404b540aSrobert while (0) 102*404b540aSrobert 103*404b540aSrobert #undef CRIS_SUBTARGET_VERSION 104*404b540aSrobert #define CRIS_SUBTARGET_VERSION " - a.out" 105*404b540aSrobert 106*404b540aSrobert #undef CRIS_SUBTARGET_DEFAULT 107*404b540aSrobert #define CRIS_SUBTARGET_DEFAULT 0 108*404b540aSrobert 109*404b540aSrobert 110*404b540aSrobert /* Node: Run-time Target */ 111*404b540aSrobert 112*404b540aSrobert /* For the cris-*-aout subtarget. */ 113*404b540aSrobert #undef TARGET_OS_CPP_BUILTINS 114*404b540aSrobert #define TARGET_OS_CPP_BUILTINS() \ 115*404b540aSrobert do \ 116*404b540aSrobert { \ 117*404b540aSrobert builtin_define ("__AOUT__"); \ 118*404b540aSrobert } \ 119*404b540aSrobert while (0) 120*404b540aSrobert 121*404b540aSrobert 122*404b540aSrobert /* Node: Storage Layout */ 123*404b540aSrobert 124*404b540aSrobert /* All sections but the .bss is rounded up to a 4-byte multiple size. */ 125*404b540aSrobert #define MAX_OFILE_ALIGNMENT 32 126*404b540aSrobert 127*404b540aSrobert 128*404b540aSrobert /* Node: Data Output */ 129*404b540aSrobert 130*404b540aSrobert #define ESCAPES \ 131*404b540aSrobert "\1\1\1\1\1\1\1\1btn\1fr\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\ 132*404b540aSrobert \0\0\"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\ 133*404b540aSrobert \0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\\\0\0\0\ 134*404b540aSrobert \0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\1\ 135*404b540aSrobert \1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\ 136*404b540aSrobert \1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\ 137*404b540aSrobert \1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\ 138*404b540aSrobert \1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1" 139*404b540aSrobert 140*404b540aSrobert /* Some svr4 assemblers have a limit on the number of characters which 141*404b540aSrobert can appear in the operand of a .string directive. If your assembler 142*404b540aSrobert has such a limitation, you should define STRING_LIMIT to reflect that 143*404b540aSrobert limit. Note that at least some svr4 assemblers have a limit on the 144*404b540aSrobert actual number of bytes in the double-quoted string, and that they 145*404b540aSrobert count each character in an escape sequence as one byte. Thus, an 146*404b540aSrobert escape sequence like \377 would count as four bytes. 147*404b540aSrobert 148*404b540aSrobert If your target assembler doesn't support the .string directive, you 149*404b540aSrobert should define this to zero. */ 150*404b540aSrobert 151*404b540aSrobert #define STRING_LIMIT ((unsigned) 256) 152*404b540aSrobert 153*404b540aSrobert #define STRING_ASM_OP "\t.string\t" 154*404b540aSrobert #define ASCII_DATA_ASM_OP "\t.ascii\t" 155*404b540aSrobert #define TYPE_ASM_OP "\t.type\t" 156*404b540aSrobert #define SIZE_ASM_OP "\t.size\t" 157*404b540aSrobert #define TYPE_OPERAND_FMT "@%s" 158*404b540aSrobert 159*404b540aSrobert /* The routine used to output NUL terminated strings. We use a special 160*404b540aSrobert version of this for most svr4 targets because doing so makes the 161*404b540aSrobert generated assembly code more compact (and thus faster to assemble) 162*404b540aSrobert as well as more readable, especially for targets like the i386 163*404b540aSrobert (where the only alternative is to output character sequences as 164*404b540aSrobert comma separated lists of numbers). */ 165*404b540aSrobert 166*404b540aSrobert #define ASM_OUTPUT_LIMITED_STRING(FILE, STR) \ 167*404b540aSrobert do \ 168*404b540aSrobert { \ 169*404b540aSrobert register const unsigned char *_limited_str = \ 170*404b540aSrobert (const unsigned char *) (STR); \ 171*404b540aSrobert register unsigned ch; \ 172*404b540aSrobert \ 173*404b540aSrobert fprintf ((FILE), "%s\"", STRING_ASM_OP); \ 174*404b540aSrobert \ 175*404b540aSrobert for (; (ch = *_limited_str); _limited_str++) \ 176*404b540aSrobert { \ 177*404b540aSrobert register int escape; \ 178*404b540aSrobert \ 179*404b540aSrobert switch (escape = ESCAPES[ch]) \ 180*404b540aSrobert { \ 181*404b540aSrobert case 0: \ 182*404b540aSrobert putc (ch, (FILE)); \ 183*404b540aSrobert break; \ 184*404b540aSrobert case 1: \ 185*404b540aSrobert fprintf ((FILE), "\\%03o", ch); \ 186*404b540aSrobert break; \ 187*404b540aSrobert default: \ 188*404b540aSrobert putc ('\\', (FILE)); \ 189*404b540aSrobert putc (escape, (FILE)); \ 190*404b540aSrobert break; \ 191*404b540aSrobert } \ 192*404b540aSrobert } \ 193*404b540aSrobert \ 194*404b540aSrobert fprintf ((FILE), "\"\n"); \ 195*404b540aSrobert } \ 196*404b540aSrobert while (0) 197*404b540aSrobert 198*404b540aSrobert /* The routine used to output sequences of byte values. We use a special 199*404b540aSrobert version of this for most svr4 targets because doing so makes the 200*404b540aSrobert generated assembly code more compact (and thus faster to assemble) 201*404b540aSrobert as well as more readable. Note that if we find subparts of the 202*404b540aSrobert character sequence which end with NUL (and which are shorter than 203*404b540aSrobert STRING_LIMIT) we output those using ASM_OUTPUT_LIMITED_STRING. */ 204*404b540aSrobert 205*404b540aSrobert #undef ASM_OUTPUT_ASCII 206*404b540aSrobert #define ASM_OUTPUT_ASCII(FILE, STR, LENGTH) \ 207*404b540aSrobert do \ 208*404b540aSrobert { \ 209*404b540aSrobert register const unsigned char *_ascii_bytes = \ 210*404b540aSrobert (const unsigned char *) (STR); \ 211*404b540aSrobert register const unsigned char *limit = _ascii_bytes + (LENGTH); \ 212*404b540aSrobert register unsigned bytes_in_chunk = 0; \ 213*404b540aSrobert \ 214*404b540aSrobert for (; _ascii_bytes < limit; _ascii_bytes++) \ 215*404b540aSrobert { \ 216*404b540aSrobert register const unsigned char *p; \ 217*404b540aSrobert \ 218*404b540aSrobert if (bytes_in_chunk >= 60) \ 219*404b540aSrobert { \ 220*404b540aSrobert fprintf ((FILE), "\"\n"); \ 221*404b540aSrobert bytes_in_chunk = 0; \ 222*404b540aSrobert } \ 223*404b540aSrobert \ 224*404b540aSrobert for (p = _ascii_bytes; p < limit && *p != '\0'; p++) \ 225*404b540aSrobert continue; \ 226*404b540aSrobert \ 227*404b540aSrobert if (p < limit && (p - _ascii_bytes) <= (long)STRING_LIMIT) \ 228*404b540aSrobert { \ 229*404b540aSrobert if (bytes_in_chunk > 0) \ 230*404b540aSrobert { \ 231*404b540aSrobert fprintf ((FILE), "\"\n"); \ 232*404b540aSrobert bytes_in_chunk = 0; \ 233*404b540aSrobert } \ 234*404b540aSrobert \ 235*404b540aSrobert ASM_OUTPUT_LIMITED_STRING ((FILE), _ascii_bytes); \ 236*404b540aSrobert _ascii_bytes = p; \ 237*404b540aSrobert } \ 238*404b540aSrobert else \ 239*404b540aSrobert { \ 240*404b540aSrobert register int escape; \ 241*404b540aSrobert register unsigned ch; \ 242*404b540aSrobert \ 243*404b540aSrobert if (bytes_in_chunk == 0) \ 244*404b540aSrobert fprintf ((FILE), "%s\"", ASCII_DATA_ASM_OP); \ 245*404b540aSrobert \ 246*404b540aSrobert switch (escape = ESCAPES[ch = *_ascii_bytes]) \ 247*404b540aSrobert { \ 248*404b540aSrobert case 0: \ 249*404b540aSrobert putc (ch, (FILE)); \ 250*404b540aSrobert bytes_in_chunk++; \ 251*404b540aSrobert break; \ 252*404b540aSrobert case 1: \ 253*404b540aSrobert fprintf ((FILE), "\\%03o", ch); \ 254*404b540aSrobert bytes_in_chunk += 4; \ 255*404b540aSrobert break; \ 256*404b540aSrobert default: \ 257*404b540aSrobert putc ('\\', (FILE)); \ 258*404b540aSrobert putc (escape, (FILE)); \ 259*404b540aSrobert bytes_in_chunk += 2; \ 260*404b540aSrobert break; \ 261*404b540aSrobert } \ 262*404b540aSrobert } \ 263*404b540aSrobert } \ 264*404b540aSrobert \ 265*404b540aSrobert if (bytes_in_chunk > 0) \ 266*404b540aSrobert fprintf ((FILE), "\"\n"); \ 267*404b540aSrobert } \ 268*404b540aSrobert while (0) 269*404b540aSrobert 270*404b540aSrobert 271*404b540aSrobert /* Node: Label Output */ 272*404b540aSrobert 273*404b540aSrobert #define SET_ASM_OP "\t.set\t" 274*404b540aSrobert 275*404b540aSrobert #define ASM_OUTPUT_EXTERNAL_LIBCALL(FILE, FUN) \ 276*404b540aSrobert (*targetm.asm_out.globalize_label) (FILE, XSTR (FUN, 0)) 277*404b540aSrobert 278*404b540aSrobert #define ASM_WEAKEN_LABEL(FILE, NAME) \ 279*404b540aSrobert do \ 280*404b540aSrobert { \ 281*404b540aSrobert fputs ("\t.weak\t", (FILE)); \ 282*404b540aSrobert assemble_name ((FILE), (NAME)); \ 283*404b540aSrobert fputc ('\n', (FILE)); \ 284*404b540aSrobert } \ 285*404b540aSrobert while (0) 286*404b540aSrobert 287*404b540aSrobert #define ASM_DECLARE_FUNCTION_NAME(FILE, NAME, DECL) \ 288*404b540aSrobert do \ 289*404b540aSrobert { \ 290*404b540aSrobert ASM_OUTPUT_TYPE_DIRECTIVE (FILE, NAME, "function"); \ 291*404b540aSrobert ASM_OUTPUT_LABEL(FILE, NAME); \ 292*404b540aSrobert } \ 293*404b540aSrobert while (0) 294*404b540aSrobert 295*404b540aSrobert #define ASM_DECLARE_OBJECT_NAME(FILE, NAME, DECL) \ 296*404b540aSrobert do \ 297*404b540aSrobert { \ 298*404b540aSrobert HOST_WIDE_INT size; \ 299*404b540aSrobert \ 300*404b540aSrobert ASM_OUTPUT_TYPE_DIRECTIVE (FILE, NAME, "object"); \ 301*404b540aSrobert \ 302*404b540aSrobert size_directive_output = 0; \ 303*404b540aSrobert if (!flag_inhibit_size_directive \ 304*404b540aSrobert && (DECL) && DECL_SIZE (DECL)) \ 305*404b540aSrobert { \ 306*404b540aSrobert size_directive_output = 1; \ 307*404b540aSrobert size = int_size_in_bytes (TREE_TYPE (DECL)); \ 308*404b540aSrobert ASM_OUTPUT_SIZE_DIRECTIVE (FILE, NAME, size); \ 309*404b540aSrobert } \ 310*404b540aSrobert \ 311*404b540aSrobert ASM_OUTPUT_LABEL (FILE, NAME); \ 312*404b540aSrobert } \ 313*404b540aSrobert while (0) 314*404b540aSrobert 315*404b540aSrobert #undef ASM_FINISH_DECLARE_OBJECT 316*404b540aSrobert #define ASM_FINISH_DECLARE_OBJECT(FILE, DECL, TOP_LEVEL, AT_END)\ 317*404b540aSrobert do \ 318*404b540aSrobert { \ 319*404b540aSrobert const char *name = XSTR (XEXP (DECL_RTL (DECL), 0), 0); \ 320*404b540aSrobert HOST_WIDE_INT size; \ 321*404b540aSrobert \ 322*404b540aSrobert if (!flag_inhibit_size_directive \ 323*404b540aSrobert && DECL_SIZE (DECL) \ 324*404b540aSrobert && ! AT_END && TOP_LEVEL \ 325*404b540aSrobert && DECL_INITIAL (DECL) == error_mark_node \ 326*404b540aSrobert && !size_directive_output) \ 327*404b540aSrobert { \ 328*404b540aSrobert size_directive_output = 1; \ 329*404b540aSrobert size = int_size_in_bytes (TREE_TYPE (DECL)); \ 330*404b540aSrobert ASM_OUTPUT_SIZE_DIRECTIVE (FILE, name, size); \ 331*404b540aSrobert } \ 332*404b540aSrobert } \ 333*404b540aSrobert while (0) 334*404b540aSrobert 335*404b540aSrobert #define ASM_DECLARE_FUNCTION_SIZE(FILE, FNAME, DECL) \ 336*404b540aSrobert do \ 337*404b540aSrobert { \ 338*404b540aSrobert if (!flag_inhibit_size_directive) \ 339*404b540aSrobert ASM_OUTPUT_MEASURED_SIZE (FILE, FNAME); \ 340*404b540aSrobert } \ 341*404b540aSrobert while (0) 342*404b540aSrobert 343*404b540aSrobert /* The configure machinery invokes the assembler without options, which is 344*404b540aSrobert not how gcc invokes it. Without options, the multi-target assembler 345*404b540aSrobert will probably be found, which is ELF by default. To counter that, we 346*404b540aSrobert need to override ELF auto-host.h config stuff which we know collides 347*404b540aSrobert with a.out. */ 348*404b540aSrobert #undef HAVE_GAS_HIDDEN 349*404b540aSrobert 350*404b540aSrobert 351*404b540aSrobert /* Node: Alignment Output */ 352*404b540aSrobert 353*404b540aSrobert #define SKIP_ASM_OP "\t.zero\t" 354*404b540aSrobert 355*404b540aSrobert #undef ASM_OUTPUT_SKIP 356*404b540aSrobert #define ASM_OUTPUT_SKIP(FILE, SIZE) \ 357*404b540aSrobert fprintf (FILE, "%s%u\n", SKIP_ASM_OP, (int)(SIZE)) 358*404b540aSrobert 359*404b540aSrobert /* Node: All Debuggers */ 360*404b540aSrobert 361*404b540aSrobert #define PREFERRED_DEBUGGING_TYPE DBX_DEBUG 362*404b540aSrobert 363*404b540aSrobert 364*404b540aSrobert /* Node: Misc */ 365*404b540aSrobert 366*404b540aSrobert #define HANDLE_SYSV_PRAGMA 1 367*404b540aSrobert 368*404b540aSrobert /* In theory, this one isn't necessary, but over time, external tools have 369*404b540aSrobert been primed on names with "." rather than "$". */ 370*404b540aSrobert #define NO_DOLLAR_IN_LABEL 371*404b540aSrobert 372*404b540aSrobert /* These are undocumented, but to keep a single 373*404b540aSrobert CRIS_ASM_OUTPUT_ALIGNED_DECL_COMMON, we set this to an asm that will 374*404b540aSrobert emit an error if ever output. It will not be emitted for a.out modulo 375*404b540aSrobert careless hacking. */ 376*404b540aSrobert #define COMMON_ASM_OP "\t.err\t" 377*404b540aSrobert #define LOCAL_ASM_OP "\t.err\t" 378*404b540aSrobert 379*404b540aSrobert #if defined(__CRIS__) && defined (__AOUT__) && defined (IN_GCC) 380*404b540aSrobert 381*404b540aSrobert #define CRIS_ABI_VERSION_SYMBOL_STRING ".$CRIS_ABI_V2" 382*404b540aSrobert 383*404b540aSrobert /* Make all a.out library functions have undefined references to the 384*404b540aSrobert .$CRIS_ABI_V2 symbol, so it will be picked up. Used by GDB. GDB has 385*404b540aSrobert a bug with reading a.out symbols; it does not see the GNU weak 386*404b540aSrobert extensions, so we can't have .$CRIS_ABI_V2 weak. Weak. */ 387*404b540aSrobert __asm__ (".set .$abi_referer," CRIS_ABI_VERSION_SYMBOL_STRING); 388*404b540aSrobert #endif 389*404b540aSrobert 390*404b540aSrobert /* 391*404b540aSrobert * Local variables: 392*404b540aSrobert * eval: (c-set-style "gnu") 393*404b540aSrobert * indent-tabs-mode: t 394*404b540aSrobert * End: 395*404b540aSrobert */ 396