i386-interix.h revision 52284
152284Sobrien/* Target definitions for GNU compiler for Intel 80386 running Interix
252284Sobrien   Parts Copyright (C) 1991, 1999 Free Software Foundation, Inc.
352284Sobrien
452284Sobrien   Parts:
552284Sobrien     by Douglas B. Rupp (drupp@cs.washington.edu).
652284Sobrien     by Ron Guilmette (rfg@netcom.com).
752284Sobrien     by Donn Terry (donn@softway.com).
852284Sobrien     by Mumit Khan (khan@xraylith.wisc.edu).
952284Sobrien
1052284SobrienThis file is part of GNU CC.
1152284Sobrien
1252284SobrienGNU CC is free software; you can redistribute it and/or modify
1352284Sobrienit under the terms of the GNU General Public License as published by
1452284Sobrienthe Free Software Foundation; either version 2, or (at your option)
1552284Sobrienany later version.
1652284Sobrien
1752284SobrienGNU CC is distributed in the hope that it will be useful,
1852284Sobrienbut WITHOUT ANY WARRANTY; without even the implied warranty of
1952284SobrienMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
2052284SobrienGNU General Public License for more details.
2152284Sobrien
2252284SobrienYou should have received a copy of the GNU General Public License
2352284Sobrienalong with GNU CC; see the file COPYING.  If not, write to
2452284Sobrienthe Free Software Foundation, 59 Temple Place - Suite 330,
2552284SobrienBoston, MA 02111-1307, USA.  */
2652284Sobrien
2752284Sobrien#define YES_UNDERSCORES
2852284Sobrien
2952284Sobrien/* YES_UNDERSCORES must preceed gas.h */
3052284Sobrien#include <i386/gas.h>
3152284Sobrien/* The rest must follow. */
3252284Sobrien
3352284Sobrien#define DBX_DEBUGGING_INFO
3452284Sobrien#define SDB_DEBUGGING_INFO
3552284Sobrien#define PREFERRED_DEBUGGING_TYPE DBX_DEBUG
3652284Sobrien
3752284Sobrien#define HANDLE_SYSV_PRAGMA
3852284Sobrien#undef HANDLE_PRAGMA_WEAK  /* until the link format can handle it */
3952284Sobrien
4052284Sobrien/* By default, target has a 80387, uses IEEE compatible arithmetic,
4152284Sobrien   and returns float values in the 387 and needs stack probes
4252284Sobrien   We also align doubles to 64-bits for MSVC default compatability */
4352284Sobrien#undef TARGET_DEFAULT
4452284Sobrien#define TARGET_DEFAULT \
4552284Sobrien   (MASK_80387 | MASK_IEEE_FP | MASK_FLOAT_RETURNS | MASK_STACK_PROBE | \
4652284Sobrien    MASK_ALIGN_DOUBLE)
4752284Sobrien
4852284Sobrien#undef TARGET_CPU_DEFAULT
4952284Sobrien#define TARGET_CPU_DEFAULT 2 /* 486 */
5052284Sobrien
5152284Sobrien#define WCHAR_UNSIGNED 1
5252284Sobrien#define WCHAR_TYPE_SIZE 16
5352284Sobrien#define WCHAR_TYPE "short unsigned int"
5452284Sobrien
5552284Sobrien/* WinNT (and thus Interix) use unsigned int */
5652284Sobrien#define SIZE_TYPE "unsigned int"
5752284Sobrien
5852284Sobrien#define ASM_LOAD_ADDR(loc, reg)   "     leal " #loc "," #reg "\n"
5952284Sobrien
6052284Sobrien/* For the sake of libgcc2.c, indicate target supports atexit.  */
6152284Sobrien#define HAVE_ATEXIT
6252284Sobrien
6352284Sobrien/* cpp handles __STDC__ */
6452284Sobrien#undef CPP_PREDEFINES
6552284Sobrien#define CPP_PREDEFINES " \
6652284Sobrien  -D__INTERIX \
6752284Sobrien  -D__OPENNT \
6852284Sobrien  -D_M_IX86=300 -D_X86_=1 \
6952284Sobrien  -D__stdcall=__attribute__((__stdcall__)) \
7052284Sobrien  -D__cdecl=__attribute__((__cdecl__)) \
7152284Sobrien  -Asystem(unix) -Asystem(interix) -Asystem(interix) -Acpu(i386) -Amachine(i386)"
7252284Sobrien
7352284Sobrien#undef CPP_SPEC
7452284Sobrien/* Write out the correct language type definition for the header files.
7552284Sobrien   Unless we have assembler language, write out the symbols for C.
7652284Sobrien   cpp_cpu is an Intel specific variant. See i386.h
7752284Sobrien   mieee is an Alpha specific variant.  Cross polination a bad idea.
7852284Sobrien   */
7952284Sobrien#define CPP_SPEC "\
8052284Sobrien%{!.S:	-D__LANGUAGE_C__ -D__LANGUAGE_C %{!ansi:-DLANGUAGE_C}}  \
8152284Sobrien%{.S:	-D__LANGUAGE_ASSEMBLY__ -D__LANGUAGE_ASSEMBLY %{!ansi:-DLANGUAGE_ASSEMBLY}} \
8252284Sobrien%{.cc:	-D__LANGUAGE_C_PLUS_PLUS__ -D__LANGUAGE_C_PLUS_PLUS -D__cplusplus} \
8352284Sobrien%{.cxx:	-D__LANGUAGE_C_PLUS_PLUS__ -D__LANGUAGE_C_PLUS_PLUS -D__cplusplus} \
8452284Sobrien%{.C:	-D__LANGUAGE_C_PLUS_PLUS__ -D__LANGUAGE_C_PLUS_PLUS -D__cplusplus} \
8552284Sobrien%{.m:	-D__LANGUAGE_OBJECTIVE_C__ -D__LANGUAGE_OBJECTIVE_C} \
8652284Sobrien-remap \
8752284Sobrien%(cpp_cpu) \
8852284Sobrien%{posix:-D_POSIX_SOURCE} \
8952284Sobrien-idirafter %$INTERIX_ROOT/usr/include"
9052284Sobrien
9152284Sobrien#undef TARGET_VERSION
9252284Sobrien#define TARGET_VERSION fprintf (stderr, " (i386 Interix)");
9352284Sobrien
9452284Sobrien/* The global __fltused is necessary to cause the printf/scanf routines
9552284Sobrien   for outputting/inputting floating point numbers to be loaded.  Since this
9652284Sobrien   is kind of hard to detect, we just do it all the time. */
9752284Sobrien
9852284Sobrien#ifdef ASM_FILE_START
9952284Sobrien#undef ASM_FILE_START
10052284Sobrien#endif
10152284Sobrien#define ASM_FILE_START(FILE) \
10252284Sobrien  do {  fprintf (FILE, "\t.file\t");                            \
10352284Sobrien        output_quoted_string (FILE, dump_base_name);            \
10452284Sobrien        fprintf (FILE, "\n");                                   \
10552284Sobrien        fprintf (FILE, ".global\t__fltused\n");                 \
10652284Sobrien  } while (0)
10752284Sobrien
10852284Sobrien/* A table of bytes codes used by the ASM_OUTPUT_ASCII and
10952284Sobrien   ASM_OUTPUT_LIMITED_STRING macros.  Each byte in the table
11052284Sobrien   corresponds to a particular byte value [0..255].  For any
11152284Sobrien   given byte value, if the value in the corresponding table
11252284Sobrien   position is zero, the given character can be output directly.
11352284Sobrien   If the table value is 1, the byte must be output as a \ooo
11452284Sobrien   octal escape.  If the tables value is anything else, then the
11552284Sobrien   byte value should be output as a \ followed by the value
11652284Sobrien   in the table.  Note that we can use standard UN*X escape
11752284Sobrien   sequences for many control characters, but we don't use
11852284Sobrien   \a to represent BEL because some svr4 assemblers (e.g. on
11952284Sobrien   the i386) don't know about that.  Also, we don't use \v
12052284Sobrien   since some versions of gas, such as 2.2 did not accept it.  */
12152284Sobrien
12252284Sobrien#define ESCAPES \
12352284Sobrien"\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\
12452284Sobrien\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\
12552284Sobrien\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\
12652284Sobrien\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\
12752284Sobrien\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\
12852284Sobrien\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\
12952284Sobrien\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\
13052284Sobrien\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"
13152284Sobrien
13252284Sobrien/* Some svr4 assemblers have a limit on the number of characters which
13352284Sobrien   can appear in the operand of a .string directive.  If your assembler
13452284Sobrien   has such a limitation, you should define STRING_LIMIT to reflect that
13552284Sobrien   limit.  Note that at least some svr4 assemblers have a limit on the
13652284Sobrien   actual number of bytes in the double-quoted string, and that they
13752284Sobrien   count each character in an escape sequence as one byte.  Thus, an
13852284Sobrien   escape sequence like \377 would count as four bytes.
13952284Sobrien
14052284Sobrien   If your target assembler doesn't support the .string directive, you
14152284Sobrien   should define this to zero.
14252284Sobrien*/
14352284Sobrien
14452284Sobrien#define STRING_LIMIT	((unsigned) 256)
14552284Sobrien
14652284Sobrien#define STRING_ASM_OP	".string"
14752284Sobrien
14852284Sobrien/* The routine used to output NUL terminated strings.  We use a special
14952284Sobrien   version of this for most svr4 targets because doing so makes the
15052284Sobrien   generated assembly code more compact (and thus faster to assemble)
15152284Sobrien   as well as more readable, especially for targets like the i386
15252284Sobrien   (where the only alternative is to output character sequences as
15352284Sobrien   comma separated lists of numbers).   */
15452284Sobrien
15552284Sobrien#define ASM_OUTPUT_LIMITED_STRING(FILE, STR)				\
15652284Sobrien  do									\
15752284Sobrien    {									\
15852284Sobrien      register unsigned char *_limited_str = (unsigned char *) (STR);	\
15952284Sobrien      register unsigned ch;						\
16052284Sobrien      fprintf ((FILE), "\t%s\t\"", STRING_ASM_OP);			\
16152284Sobrien      for (; (ch = *_limited_str); _limited_str++)			\
16252284Sobrien        {								\
16352284Sobrien	  register int escape = ESCAPES[ch];				\
16452284Sobrien	  switch (escape)						\
16552284Sobrien	    {								\
16652284Sobrien	    case 0:							\
16752284Sobrien	      putc (ch, (FILE));					\
16852284Sobrien	      break;							\
16952284Sobrien	    case 1:							\
17052284Sobrien	      fprintf ((FILE), "\\%03o", ch);				\
17152284Sobrien	      break;							\
17252284Sobrien	    default:							\
17352284Sobrien	      putc ('\\', (FILE));					\
17452284Sobrien	      putc (escape, (FILE));					\
17552284Sobrien	      break;							\
17652284Sobrien	    }								\
17752284Sobrien        }								\
17852284Sobrien      fprintf ((FILE), "\"\n");						\
17952284Sobrien    }									\
18052284Sobrien  while (0)
18152284Sobrien
18252284Sobrien/* The routine used to output sequences of byte values.  We use a special
18352284Sobrien   version of this for most svr4 targets because doing so makes the
18452284Sobrien   generated assembly code more compact (and thus faster to assemble)
18552284Sobrien   as well as more readable.  Note that if we find subparts of the
18652284Sobrien   character sequence which end with NUL (and which are shorter than
18752284Sobrien   STRING_LIMIT) we output those using ASM_OUTPUT_LIMITED_STRING.  */
18852284Sobrien
18952284Sobrien#undef ASM_OUTPUT_ASCII
19052284Sobrien#define ASM_OUTPUT_ASCII(FILE, STR, LENGTH)				\
19152284Sobrien  do									\
19252284Sobrien    {									\
19352284Sobrien      register unsigned char *_ascii_bytes = (unsigned char *) (STR);	\
19452284Sobrien      register unsigned char *limit = _ascii_bytes + (LENGTH);		\
19552284Sobrien      register unsigned bytes_in_chunk = 0;				\
19652284Sobrien      for (; _ascii_bytes < limit; _ascii_bytes++)			\
19752284Sobrien        {								\
19852284Sobrien	  register unsigned char *p;					\
19952284Sobrien	  if (bytes_in_chunk >= 64)					\
20052284Sobrien	    {								\
20152284Sobrien	      fputc ('\n', (FILE));					\
20252284Sobrien	      bytes_in_chunk = 0;					\
20352284Sobrien	    }								\
20452284Sobrien	  for (p = _ascii_bytes; p < limit && *p != '\0'; p++)		\
20552284Sobrien	    continue;							\
20652284Sobrien	  if (p < limit && (p - _ascii_bytes) <= STRING_LIMIT)		\
20752284Sobrien	    {								\
20852284Sobrien	      if (bytes_in_chunk > 0)					\
20952284Sobrien		{							\
21052284Sobrien		  fputc ('\n', (FILE));					\
21152284Sobrien		  bytes_in_chunk = 0;					\
21252284Sobrien		}							\
21352284Sobrien	      ASM_OUTPUT_LIMITED_STRING ((FILE), _ascii_bytes);		\
21452284Sobrien	      _ascii_bytes = p;						\
21552284Sobrien	    }								\
21652284Sobrien	  else								\
21752284Sobrien	    {								\
21852284Sobrien	      if (bytes_in_chunk == 0)					\
21952284Sobrien		fprintf ((FILE), "\t.byte\t");				\
22052284Sobrien	      else							\
22152284Sobrien		fputc (',', (FILE));					\
22252284Sobrien	      fprintf ((FILE), "0x%02x", *_ascii_bytes);		\
22352284Sobrien	      bytes_in_chunk += 5;					\
22452284Sobrien	    }								\
22552284Sobrien	}								\
22652284Sobrien      if (bytes_in_chunk > 0)						\
22752284Sobrien        fprintf ((FILE), "\n");						\
22852284Sobrien    }									\
22952284Sobrien  while (0)
23052284Sobrien
23152284Sobrien/* This is how to output an element of a case-vector that is relative.
23252284Sobrien   This is only used for PIC code.  See comments by the `casesi' insn in
23352284Sobrien   i386.md for an explanation of the expression this outputs.
23452284Sobrien   PE format differs on what PC-relative offsets look like (see
23552284Sobrien   coff_i386_rtype_to_howto), and we need to compensate (by one word) here. */
23652284Sobrien
23752284Sobrien#undef ASM_OUTPUT_ADDR_DIFF_ELT
23852284Sobrien#define ASM_OUTPUT_ADDR_DIFF_ELT(FILE, BODY, VALUE, REL) \
23952284Sobrien  fprintf (FILE, "\t.long __GLOBAL_OFFSET_TABLE_+[.-%s%d+4]\n", LPREFIX, VALUE)
24052284Sobrien
24152284Sobrien/* Indicate that jump tables go in the text section.  This is
24252284Sobrien   necessary when compiling PIC code.  */
24352284Sobrien
24452284Sobrien#define JUMP_TABLES_IN_TEXT_SECTION 1
24552284Sobrien
24652284Sobrien/* Emit code to check the stack when allocating more that 4000
24752284Sobrien   bytes in one go. */
24852284Sobrien
24952284Sobrien#define CHECK_STACK_LIMIT 0x1000
25052284Sobrien
25152284Sobrien/* the following are OSF linker (not gld) specific... we don't want them */
25252284Sobrien#undef HAS_INIT_SECTION
25352284Sobrien#undef LD_INIT_SWITCH
25452284Sobrien#undef LD_FINI_SWITCH
25552284Sobrien
25652284Sobrien
25752284Sobrien/* The following are needed for C++, but also needed for profiling */
25852284Sobrien
25952284Sobrien/* Support const sections and the ctors and dtors sections for g++.
26052284Sobrien   Note that there appears to be two different ways to support const
26152284Sobrien   sections at the moment.  You can either #define the symbol
26252284Sobrien   READONLY_DATA_SECTION (giving it some code which switches to the
26352284Sobrien   readonly data section) or else you can #define the symbols
26452284Sobrien   EXTRA_SECTIONS, EXTRA_SECTION_FUNCTIONS, SELECT_SECTION, and
26552284Sobrien   SELECT_RTX_SECTION.  We do both here just to be on the safe side.  */
26652284Sobrien
26752284Sobrien#define USE_CONST_SECTION	1
26852284Sobrien
26952284Sobrien#define CONST_SECTION_ASM_OP	".section\t.rdata,\"r\""
27052284Sobrien
27152284Sobrien/* Define the pseudo-ops used to switch to the .ctors and .dtors sections.
27252284Sobrien
27352284Sobrien   Note that we want to give these sections the SHF_WRITE attribute
27452284Sobrien   because these sections will actually contain data (i.e. tables of
27552284Sobrien   addresses of functions in the current root executable or shared library
27652284Sobrien   file) and, in the case of a shared library, the relocatable addresses
27752284Sobrien   will have to be properly resolved/relocated (and then written into) by
27852284Sobrien   the dynamic linker when it actually attaches the given shared library
27952284Sobrien   to the executing process.  (Note that on SVR4, you may wish to use the
28052284Sobrien   `-z text' option to the ELF linker, when building a shared library, as
28152284Sobrien   an additional check that you are doing everything right.  But if you do
28252284Sobrien   use the `-z text' option when building a shared library, you will get
28352284Sobrien   errors unless the .ctors and .dtors sections are marked as writable
28452284Sobrien   via the SHF_WRITE attribute.)  */
28552284Sobrien
28652284Sobrien#define CTORS_SECTION_ASM_OP	".section\t.ctors,\"x\""
28752284Sobrien#define DTORS_SECTION_ASM_OP	".section\t.dtors,\"x\""
28852284Sobrien
28952284Sobrien/* A default list of other sections which we might be "in" at any given
29052284Sobrien   time.  For targets that use additional sections (e.g. .tdesc) you
29152284Sobrien   should override this definition in the target-specific file which
29252284Sobrien   includes this file.  */
29352284Sobrien
29452284Sobrien#undef EXTRA_SECTIONS
29552284Sobrien#define EXTRA_SECTIONS in_const, in_ctors, in_dtors
29652284Sobrien
29752284Sobrien/* A default list of extra section function definitions.  For targets
29852284Sobrien   that use additional sections (e.g. .tdesc) you should override this
29952284Sobrien   definition in the target-specific file which includes this file.  */
30052284Sobrien
30152284Sobrien#undef EXTRA_SECTION_FUNCTIONS
30252284Sobrien#define EXTRA_SECTION_FUNCTIONS						\
30352284Sobrien  CONST_SECTION_FUNCTION						\
30452284Sobrien  CTORS_SECTION_FUNCTION						\
30552284Sobrien  DTORS_SECTION_FUNCTION
30652284Sobrien
30752284Sobrien#undef READONLY_DATA_SECTION
30852284Sobrien#define READONLY_DATA_SECTION() const_section ()
30952284Sobrien
31052284Sobrienextern void text_section ();
31152284Sobrien
31252284Sobrien#define CONST_SECTION_FUNCTION						\
31352284Sobrienvoid									\
31452284Sobrienconst_section ()							\
31552284Sobrien{									\
31652284Sobrien  if (!USE_CONST_SECTION)						\
31752284Sobrien    text_section();							\
31852284Sobrien  else if (in_section != in_const)					\
31952284Sobrien    {									\
32052284Sobrien      fprintf (asm_out_file, "%s\n", CONST_SECTION_ASM_OP);		\
32152284Sobrien      in_section = in_const;						\
32252284Sobrien    }									\
32352284Sobrien}
32452284Sobrien
32552284Sobrien#define CTORS_SECTION_FUNCTION						\
32652284Sobrienvoid									\
32752284Sobrienctors_section ()							\
32852284Sobrien{									\
32952284Sobrien  if (in_section != in_ctors)						\
33052284Sobrien    {									\
33152284Sobrien      fprintf (asm_out_file, "%s\n", CTORS_SECTION_ASM_OP);		\
33252284Sobrien      in_section = in_ctors;						\
33352284Sobrien    }									\
33452284Sobrien}
33552284Sobrien
33652284Sobrien#define DTORS_SECTION_FUNCTION						\
33752284Sobrienvoid									\
33852284Sobriendtors_section ()							\
33952284Sobrien{									\
34052284Sobrien  if (in_section != in_dtors)						\
34152284Sobrien    {									\
34252284Sobrien      fprintf (asm_out_file, "%s\n", DTORS_SECTION_ASM_OP);		\
34352284Sobrien      in_section = in_dtors;						\
34452284Sobrien    }									\
34552284Sobrien}
34652284Sobrien
34752284Sobrien#if 0
34852284Sobrien/* Currently gas chokes on this; that's not too hard to fix, but there's
34952284Sobrien   not a lot of impeteus to do it, either.  If it is done, gas will have
35052284Sobrien   to handle long section name escapes (which are defined in the COFF/PE
35152284Sobrien   document as /nnn where nnn is a string table index).  The benefit:
35252284Sobrien   section attributes and -ffunction-sections, neither of which seem to
35352284Sobrien   be critical. */
35452284Sobrien/* gas may have been fixed? bfd was. */
35552284Sobrien
35652284Sobrien/* Switch into a generic section.
35752284Sobrien   This is currently only used to support section attributes.
35852284Sobrien
35952284Sobrien   We make the section read-only and executable for a function decl,
36052284Sobrien   read-only for a const data decl, and writable for a non-const data decl.  */
36152284Sobrien#define ASM_OUTPUT_SECTION_NAME(FILE, DECL, NAME) \
36252284Sobrien  fprintf (FILE, ".section\t%s,\"%s\",@progbits\n", NAME, \
36352284Sobrien	   (DECL) && TREE_CODE (DECL) == FUNCTION_DECL ? "ax" : \
36452284Sobrien	   (DECL) && TREE_READONLY (DECL) ? "a" : "aw")
36552284Sobrien#endif
36652284Sobrien
36752284Sobrien#define INT_ASM_OP		".long"
36852284Sobrien
36952284Sobrien/* The MS compilers take alignment as a number of bytes, so we do as well */
37052284Sobrien#undef ASM_OUTPUT_ALIGN
37152284Sobrien#define ASM_OUTPUT_ALIGN(FILE,LOG) \
37252284Sobrien  if ((LOG)!=0) fprintf ((FILE), "\t.balign %d\n", 1<<(LOG))
37352284Sobrien
37452284Sobrien/* A C statement (sans semicolon) to output an element in the table of
37552284Sobrien   global constructors.  */
37652284Sobrien#define ASM_OUTPUT_CONSTRUCTOR(FILE,NAME)				\
37752284Sobrien  do {									\
37852284Sobrien    ctors_section ();							\
37952284Sobrien    fprintf (FILE, "\t%s\t ", INT_ASM_OP);				\
38052284Sobrien    assemble_name (FILE, NAME);						\
38152284Sobrien    fprintf (FILE, "\n");						\
38252284Sobrien  } while (0)
38352284Sobrien
38452284Sobrien/* A C statement (sans semicolon) to output an element in the table of
38552284Sobrien   global destructors.  */
38652284Sobrien#define ASM_OUTPUT_DESTRUCTOR(FILE,NAME)       				\
38752284Sobrien  do {									\
38852284Sobrien    dtors_section ();                   				\
38952284Sobrien    fprintf (FILE, "\t%s\t ", INT_ASM_OP);				\
39052284Sobrien    assemble_name (FILE, NAME);              				\
39152284Sobrien    fprintf (FILE, "\n");						\
39252284Sobrien  } while (0)
39352284Sobrien
39452284Sobrien/* The linker will take care of this, and having them causes problems with
39552284Sobrien   ld -r (specifically -rU). */
39652284Sobrien#define CTOR_LISTS_DEFINED_EXTERNALLY 1
39752284Sobrien
39852284Sobrien#define SET_ASM_OP	".set"
39952284Sobrien/* Output a definition (implements alias) */
40052284Sobrien#define ASM_OUTPUT_DEF(FILE,LABEL1,LABEL2)				\
40152284Sobriendo									\
40252284Sobrien{									\
40352284Sobrien    fprintf ((FILE), "\t%s\t", SET_ASM_OP);				\
40452284Sobrien    assemble_name (FILE, LABEL1);					\
40552284Sobrien    fprintf (FILE, ",");						\
40652284Sobrien    assemble_name (FILE, LABEL2);					\
40752284Sobrien    fprintf (FILE, "\n");						\
40852284Sobrien    }									\
40952284Sobrienwhile (0)
41052284Sobrien
41152284Sobrien#define HOST_PTR_PRINTF "%p"
41252284Sobrien#define HOST_PTR_AS_INT unsigned long
41352284Sobrien
41452284Sobrien#define PCC_BITFIELD_TYPE_MATTERS 1
41552284Sobrien#define PCC_BITFIELD_TYPE_TEST TYPE_NATIVE(rec)
41652284Sobrien#define GROUP_BITFIELDS_BY_ALIGN TYPE_NATIVE(rec)
41752284Sobrien
41852284Sobrien/* The following two flags are usually "off" for i386, because some non-gnu
41952284Sobrien   tools (for the i386) don't handle them.  However, we don't have that
42052284Sobrien   problem, so.... */
42152284Sobrien
42252284Sobrien/* Forward references to tags are allowed.  */
42352284Sobrien#define SDB_ALLOW_FORWARD_REFERENCES
42452284Sobrien
42552284Sobrien/* Unknown tags are also allowed.  */
42652284Sobrien#define SDB_ALLOW_UNKNOWN_REFERENCES
42752284Sobrien
42852284Sobrien/* The integer half of this list needs to be constant.  However, there's
42952284Sobrien   a lot of disagreement about what the floating point adjustments should
43052284Sobrien   be.  We pick one that works with gdb.  (The underlying problem is
43152284Sobrien   what to do about the segment registers.  Since we have access to them
43252284Sobrien   from /proc, we'll allow them to be accessed in gdb, even tho the
43352284Sobrien   gcc compiler can't generate them.  (There's some evidence that
43452284Sobrien   MSVC does, but possibly only for certain special "canned" sequences.) */
43552284Sobrien
43652284Sobrien#undef DBX_REGISTER_NUMBER
43752284Sobrien#define DBX_REGISTER_NUMBER(n) \
43852284Sobrien((n) == 0 ? 0 \
43952284Sobrien : (n) == 1 ? 2 \
44052284Sobrien : (n) == 2 ? 1 \
44152284Sobrien : (n) == 3 ? 3 \
44252284Sobrien : (n) == 4 ? 6 \
44352284Sobrien : (n) == 5 ? 7 \
44452284Sobrien : (n) == 6 ? 5 \
44552284Sobrien : (n) == 7 ? 4 \
44652284Sobrien : ((n) >= FIRST_STACK_REG && (n) <= LAST_STACK_REG) ? (n)+8 \
44752284Sobrien : (-1))
44852284Sobrien
44952284Sobrien/* Define this macro if references to a symbol must be treated
45052284Sobrien   differently depending on something about the variable or
45152284Sobrien   function named by the symbol (such as what section it is in).
45252284Sobrien
45352284Sobrien   Apply stddef, handle (as yet unimplemented) pic.
45452284Sobrien
45552284Sobrien   stddef renaming does NOT apply to Alpha. */
45652284Sobrien
45752284Sobrienchar *gen_stdcall_suffix ();
45852284Sobrien
45952284Sobrien#undef ENCODE_SECTION_INFO
46052284Sobrien#define ENCODE_SECTION_INFO(DECL) 					\
46152284Sobriendo 									\
46252284Sobrien  {									\
46352284Sobrien    if (flag_pic)							\
46452284Sobrien      {									\
46552284Sobrien	rtx rtl = (TREE_CODE_CLASS (TREE_CODE (DECL)) != 'd'		\
46652284Sobrien		   ? TREE_CST_RTL (DECL) : DECL_RTL (DECL));		\
46752284Sobrien	SYMBOL_REF_FLAG (XEXP (rtl, 0))					\
46852284Sobrien	  = (TREE_CODE_CLASS (TREE_CODE (DECL)) != 'd'			\
46952284Sobrien	     || ! TREE_PUBLIC (DECL));					\
47052284Sobrien      }									\
47152284Sobrien    if (TREE_CODE (DECL) == FUNCTION_DECL) 				\
47252284Sobrien      if (lookup_attribute ("stdcall",					\
47352284Sobrien			    TYPE_ATTRIBUTES (TREE_TYPE (DECL))))	\
47452284Sobrien        XEXP (DECL_RTL (DECL), 0) = 					\
47552284Sobrien          gen_rtx (SYMBOL_REF, Pmode, gen_stdcall_suffix (DECL)); 	\
47652284Sobrien  }									\
47752284Sobrienwhile (0)
47852284Sobrien
47952284Sobrien/* This macro gets just the user-specified name
48052284Sobrien   out of the string in a SYMBOL_REF.  Discard
48152284Sobrien   trailing @[NUM] encoded by ENCODE_SECTION_INFO.  */
48252284Sobrien#undef  STRIP_NAME_ENCODING
48352284Sobrien#define STRIP_NAME_ENCODING(VAR,SYMBOL_NAME)				\
48452284Sobriendo {									\
48552284Sobrien  char *_p;								\
48652284Sobrien  char *_name = SYMBOL_NAME;						\
48752284Sobrien  for (_p = _name; *_p && *_p != '@'; ++_p)				\
48852284Sobrien    ;									\
48952284Sobrien  if (*_p == '@')							\
49052284Sobrien    {									\
49152284Sobrien      int _len = _p - _name;						\
49252284Sobrien      (VAR) = (char *) alloca (_len + 1);				\
49352284Sobrien      strncpy ((VAR), _name, _len);					\
49452284Sobrien      (VAR)[_len] = '\0';						\
49552284Sobrien    }									\
49652284Sobrien  else									\
49752284Sobrien    (VAR) = _name;							\
49852284Sobrien} while (0)
49952284Sobrien
50052284Sobrien#if 0
50152284Sobrien/* Turn this back on when the linker is updated to handle grouped
50252284Sobrien   .data$ sections correctly. See corresponding note in i386/interix.c.
50352284Sobrien   MK. */
50452284Sobrien
50552284Sobrien/* Define this macro if in some cases global symbols from one translation
50652284Sobrien   unit may not be bound to undefined symbols in another translation unit
50752284Sobrien   without user intervention.  For instance, under Microsoft Windows
50852284Sobrien   symbols must be explicitly imported from shared libraries (DLLs).  */
50952284Sobrien#define MULTIPLE_SYMBOL_SPACES
51052284Sobrien
51152284Sobrien#define UNIQUE_SECTION_P(DECL) DECL_ONE_ONLY (DECL)
51252284Sobrienextern void i386_pe_unique_section ();
51352284Sobrien#define UNIQUE_SECTION(DECL,RELOC) i386_pe_unique_section (DECL, RELOC)
51452284Sobrien
51552284Sobrien#define SUPPORTS_ONE_ONLY 1
51652284Sobrien
51752284Sobrien/* A C statement to output something to the assembler file to switch to section
51852284Sobrien   NAME for object DECL which is either a FUNCTION_DECL, a VAR_DECL or
51952284Sobrien   NULL_TREE.  Some target formats do not support arbitrary sections.  Do not
52052284Sobrien   define this macro in such cases.  */
52152284Sobrien#undef ASM_OUTPUT_SECTION_NAME
52252284Sobrien#define ASM_OUTPUT_SECTION_NAME(STREAM, DECL, NAME, RELOC)		\
52352284Sobriendo {									\
52452284Sobrien  static struct section_info						\
52552284Sobrien    {									\
52652284Sobrien      struct section_info *next;					\
52752284Sobrien      char *name;							\
52852284Sobrien      enum sect_enum {SECT_RW, SECT_RO, SECT_EXEC} type;		\
52952284Sobrien    } *sections;							\
53052284Sobrien  struct section_info *s;						\
53152284Sobrien  char *mode;								\
53252284Sobrien  enum sect_enum type;							\
53352284Sobrien									\
53452284Sobrien  for (s = sections; s; s = s->next)					\
53552284Sobrien    if (!strcmp (NAME, s->name))					\
53652284Sobrien      break;								\
53752284Sobrien									\
53852284Sobrien  if (DECL && TREE_CODE (DECL) == FUNCTION_DECL)			\
53952284Sobrien    type = SECT_EXEC, mode = "x";					\
54052284Sobrien  else if (DECL && DECL_READONLY_SECTION (DECL, RELOC))			\
54152284Sobrien    type = SECT_RO, mode = "r";						\
54252284Sobrien  else									\
54352284Sobrien    type = SECT_RW, mode = "w";						\
54452284Sobrien									\
54552284Sobrien  if (s == 0)								\
54652284Sobrien    {									\
54752284Sobrien      s = (struct section_info *) xmalloc (sizeof (struct section_info)); \
54852284Sobrien      s->name = xmalloc ((strlen (NAME) + 1) * sizeof (*NAME));		\
54952284Sobrien      strcpy (s->name, NAME);						\
55052284Sobrien      s->type = type;							\
55152284Sobrien      s->next = sections;						\
55252284Sobrien      sections = s;							\
55352284Sobrien      fprintf (STREAM, ".section\t%s,\"%s\"\n", NAME, mode);		\
55452284Sobrien      /* Functions may have been compiled at various levels of		\
55552284Sobrien         optimization so we can't use `same_size' here.  Instead,	\
55652284Sobrien         have the linker pick one.  */					\
55752284Sobrien      if ((DECL) && DECL_ONE_ONLY (DECL))				\
55852284Sobrien        fprintf (STREAM, "\t.linkonce %s\n",				\
55952284Sobrien	         TREE_CODE (DECL) == FUNCTION_DECL			\
56052284Sobrien	         ? "discard" : "same_size");				\
56152284Sobrien    }									\
56252284Sobrien  else									\
56352284Sobrien    {									\
56452284Sobrien      fprintf (STREAM, ".section\t%s,\"%s\"\n", NAME, mode);		\
56552284Sobrien    }									\
56652284Sobrien} while (0)
56752284Sobrien
56852284Sobrien#endif /* 0 */
56952284Sobrien
57052284Sobrien/* DWARF2 Unwinding doesn't work with exception handling yet. */
57152284Sobrien#define DWARF2_UNWIND_INFO 0
57252284Sobrien
57352284Sobrien/* Don't assume anything about the header files. */
57452284Sobrien#define NO_IMPLICIT_EXTERN_C
57552284Sobrien
576