pe.h revision 132718
190075Sobrien/* Definitions of target machine for GNU compiler, for ARM with PE obj format.
2132718Skan   Copyright (C) 1995, 1996, 1999, 2000, 2002, 2003 Free Software Foundation, Inc.
390075Sobrien   Contributed by Doug Evans (dje@cygnus.com).
490075Sobrien
5132718Skan   This file is part of GCC.
690075Sobrien
7132718Skan   GCC is free software; you can redistribute it and/or modify it
8132718Skan   under the terms of the GNU General Public License as published
9132718Skan   by the Free Software Foundation; either version 2, or (at your
10132718Skan   option) any later version.
1190075Sobrien
12132718Skan   GCC is distributed in the hope that it will be useful, but WITHOUT
13132718Skan   ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
14132718Skan   or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public
15132718Skan   License for more details.
1690075Sobrien
17132718Skan   You should have received a copy of the GNU General Public License
18132718Skan   along with GCC; see the file COPYING.  If not, write to
19132718Skan   the Free Software Foundation, 59 Temple Place - Suite 330,
20132718Skan   Boston, MA 02111-1307, USA.  */
2190075Sobrien
2290075Sobrien/* Enable PE specific code.  */
2390075Sobrien#define ARM_PE		1
2490075Sobrien
2590075Sobrien#define ARM_PE_FLAG_CHAR '@'
2690075Sobrien
2790075Sobrien/* Ensure that @x. will be stripped from the function name.  */
2890075Sobrien#undef SUBTARGET_NAME_ENCODING_LENGTHS
2990075Sobrien#define SUBTARGET_NAME_ENCODING_LENGTHS  \
3090075Sobrien  case ARM_PE_FLAG_CHAR: return 3;
3190075Sobrien
3290075Sobrien#undef  USER_LABEL_PREFIX
3390075Sobrien#define USER_LABEL_PREFIX "_"
3490075Sobrien
3590075Sobrien
3690075Sobrien/* Run-time Target Specification.  */
3790075Sobrien#undef  TARGET_VERSION
3890075Sobrien#define TARGET_VERSION fputs (" (ARM/pe)", stderr)
3990075Sobrien
4090075Sobrien/* Get tree.c to declare a target-specific specialization of
4190075Sobrien   merge_decl_attributes.  */
4290075Sobrien#define TARGET_DLLIMPORT_DECL_ATTRIBUTES
4390075Sobrien
4490075Sobrien/* Support the __declspec keyword by turning them into attributes.
4590075Sobrien   We currently only support: naked, dllimport, and dllexport.
4690075Sobrien   Note that the current way we do this may result in a collision with
4790075Sobrien   predefined attributes later on.  This can be solved by using one attribute,
4890075Sobrien   say __declspec__, and passing args to it.  The problem with that approach
4990075Sobrien   is that args are not accumulated: each new appearance would clobber any
5090075Sobrien   existing args.  */
5190075Sobrien#undef  SUBTARGET_CPP_SPEC
5290075Sobrien#define SUBTARGET_CPP_SPEC "-D__pe__ -D__declspec(x)=__attribute__((x))"
5390075Sobrien
5490075Sobrien
5590075Sobrien/* Experimental addition for pr 7885.
5690075Sobrien   Ignore dllimport for functions.  */
5790075Sobrien#define TARGET_FLAG_NOP_FUN	(1 << 24)
5890075Sobrien
5990075Sobrien#undef  TARGET_NOP_FUN_DLLIMPORT
6090075Sobrien#define TARGET_NOP_FUN_DLLIMPORT (target_flags & TARGET_FLAG_NOP_FUN)
6190075Sobrien
6290075Sobrien#undef  SUBTARGET_SWITCHES
6390075Sobrien#define SUBTARGET_SWITCHES					\
6490075Sobrien{ "nop-fun-dllimport",		  TARGET_FLAG_NOP_FUN,		\
6590075Sobrien  N_("Ignore dllimport attribute for functions") },		\
6690075Sobrien{ "no-nop-fun-dllimport",	- TARGET_FLAG_NOP_FUN, "" },
6790075Sobrien
68132718Skan/* Defaulting to APCS-26 support is a legacy issue.   It has been done
69132718Skan   that way for a long time, so changing it will probably break some
70132718Skan   people's worlds.  Support for APCS-32 is now enabled as a multilib,
71132718Skan   and at some point in the future APCS-32 may become the default.
72132718Skan   Possibly when chips that support APCS-26 are no longer made.  */
73132718Skan
7490075Sobrien#undef  TARGET_DEFAULT
75132718Skan#define TARGET_DEFAULT	(ARM_FLAG_SOFT_FLOAT | TARGET_FLAG_NOP_FUN | ARM_FLAG_MMU_TRAPS)
7690075Sobrien
77132718Skan#undef  MULTILIB_DEFAULTS
78132718Skan#define MULTILIB_DEFAULTS \
79132718Skan  { "marm", "mlittle-endian", "msoft-float", "mapcs-26", "mno-thumb-interwork" }
8090075Sobrien
8190075Sobrien#undef  WCHAR_TYPE
8290075Sobrien#define WCHAR_TYPE 	"short unsigned int"
8390075Sobrien#undef  WCHAR_TYPE_SIZE
8490075Sobrien#define WCHAR_TYPE_SIZE 16
8590075Sobrien
86132718Skan/* r11 is fixed.  */
87132718Skan#undef  SUBTARGET_CONDITIONAL_REGISTER_USAGE
88132718Skan#define SUBTARGET_CONDITIONAL_REGISTER_USAGE \
89132718Skan  fixed_regs [11] = 1; \
90132718Skan  call_used_regs [11] = 1;
9190075Sobrien
9290075Sobrien
9390075Sobrien/* Define this macro if in some cases global symbols from one translation
9490075Sobrien   unit may not be bound to undefined symbols in another translation unit
9590075Sobrien   without user intervention.  For instance, under Microsoft Windows
9690075Sobrien   symbols must be explicitly imported from shared libraries (DLLs).  */
9790075Sobrien#define MULTIPLE_SYMBOL_SPACES
9890075Sobrien
99117395Skan#define TARGET_ASM_UNIQUE_SECTION arm_pe_unique_section
10090075Sobrien
10190075Sobrien#define SUPPORTS_ONE_ONLY 1
10290075Sobrien
10390075Sobrien/* Switch into a generic section.  */
104132718Skan#undef  TARGET_ASM_NAMED_SECTION
10590075Sobrien#define TARGET_ASM_NAMED_SECTION  default_pe_asm_named_section
10690075Sobrien
107132718Skan#define TARGET_ASM_FILE_START_FILE_DIRECTIVE true
10890075Sobrien
10990075Sobrien/* Output a reference to a label.  */
11090075Sobrien#undef  ASM_OUTPUT_LABELREF
11190075Sobrien#define ASM_OUTPUT_LABELREF(STREAM, NAME)  \
11290075Sobrien  asm_fprintf (STREAM, "%U%s", arm_strip_name_encoding (NAME))
11390075Sobrien
11490075Sobrien/* Output a function definition label.  */
11590075Sobrien#undef  ASM_DECLARE_FUNCTION_NAME
11690075Sobrien#define ASM_DECLARE_FUNCTION_NAME(STREAM, NAME, DECL)   	\
11790075Sobrien  do								\
11890075Sobrien    {								\
11990075Sobrien      if (arm_dllexport_name_p (NAME))				\
12090075Sobrien	{							\
12190075Sobrien	  drectve_section ();					\
12290075Sobrien	  fprintf (STREAM, "\t.ascii \" -export:%s\"\n",	\
12390075Sobrien		   arm_strip_name_encoding (NAME));		\
12490075Sobrien	  function_section (DECL);				\
12590075Sobrien	}							\
12690075Sobrien      ARM_DECLARE_FUNCTION_NAME (STREAM, NAME, DECL);		\
12790075Sobrien      if (TARGET_THUMB)						\
12890075Sobrien	fprintf (STREAM, "\t.code 16\n");			\
12990075Sobrien      ASM_OUTPUT_LABEL (STREAM, NAME);				\
13090075Sobrien    }								\
13190075Sobrien  while (0)
13290075Sobrien
13390075Sobrien/* Output a common block.  */
13490075Sobrien#undef  ASM_OUTPUT_COMMON
13590075Sobrien#define ASM_OUTPUT_COMMON(STREAM, NAME, SIZE, ROUNDED)	\
13690075Sobrien  do							\
13790075Sobrien    {							\
13890075Sobrien      if (arm_dllexport_name_p (NAME))			\
13990075Sobrien	{						\
14090075Sobrien	  drectve_section ();				\
14190075Sobrien	  fprintf ((STREAM), "\t.ascii \" -export:%s\"\n",\
14290075Sobrien		   arm_strip_name_encoding (NAME));	\
14390075Sobrien	}						\
14490075Sobrien      if (! arm_dllimport_name_p (NAME))		\
14590075Sobrien	{						\
14690075Sobrien	  fprintf ((STREAM), "\t.comm\t"); 		\
14790075Sobrien	  assemble_name ((STREAM), (NAME));		\
14890075Sobrien	  asm_fprintf ((STREAM), ", %d\t%@ %d\n",	\
149132718Skan 		   (int)(ROUNDED), (int)(SIZE));	\
15090075Sobrien	}						\
15190075Sobrien    }							\
15290075Sobrien  while (0)
15390075Sobrien
15490075Sobrien/* Output the label for an initialized variable.  */
15590075Sobrien#undef  ASM_DECLARE_OBJECT_NAME
15690075Sobrien#define ASM_DECLARE_OBJECT_NAME(STREAM, NAME, DECL) 	\
15790075Sobrien  do							\
15890075Sobrien    {							\
15990075Sobrien      if (arm_dllexport_name_p (NAME))			\
16090075Sobrien	{						\
16190075Sobrien	  enum in_section save_section = in_section;	\
16290075Sobrien	  drectve_section ();				\
16390075Sobrien	  fprintf (STREAM, "\t.ascii \" -export:%s\"\n",\
16490075Sobrien		   arm_strip_name_encoding (NAME));	\
16590075Sobrien	  switch_to_section (save_section, (DECL));	\
16690075Sobrien	}						\
16790075Sobrien      ASM_OUTPUT_LABEL ((STREAM), (NAME));		\
16890075Sobrien    }							\
16990075Sobrien  while (0)
17090075Sobrien
17190075Sobrien/* Support the ctors/dtors and other sections.  */
17290075Sobrien
17390075Sobrien#define DRECTVE_SECTION_ASM_OP	"\t.section .drectve"
17490075Sobrien
17590075Sobrien/* A list of other sections which the compiler might be "in" at any
17690075Sobrien   given time.  */
17790075Sobrien
178117395Skan#undef  EXTRA_SECTIONS
179117395Skan#define EXTRA_SECTIONS in_drectve
18090075Sobrien
18190075Sobrien/* A list of extra section function definitions.  */
18290075Sobrien
183117395Skan#undef  EXTRA_SECTION_FUNCTIONS
184117395Skan#define EXTRA_SECTION_FUNCTIONS \
18590075Sobrien  DRECTVE_SECTION_FUNCTION	\
18690075Sobrien  SWITCH_TO_SECTION_FUNCTION
18790075Sobrien
18890075Sobrien#define DRECTVE_SECTION_FUNCTION \
18990075Sobrienvoid									\
190132718Skandrectve_section (void)							\
19190075Sobrien{									\
19290075Sobrien  if (in_section != in_drectve)						\
19390075Sobrien    {									\
19490075Sobrien      fprintf (asm_out_file, "%s\n", DRECTVE_SECTION_ASM_OP);		\
19590075Sobrien      in_section = in_drectve;						\
19690075Sobrien    }									\
19790075Sobrien}
19890075Sobrien
19990075Sobrien/* Switch to SECTION (an `enum in_section').
20090075Sobrien
20190075Sobrien   ??? This facility should be provided by GCC proper.
20290075Sobrien   The problem is that we want to temporarily switch sections in
20390075Sobrien   ASM_DECLARE_OBJECT_NAME and then switch back to the original section
20490075Sobrien   afterwards.  */
20590075Sobrien#define SWITCH_TO_SECTION_FUNCTION				\
20690075Sobrienstatic void							\
207132718Skanswitch_to_section (enum in_section section, tree decl)		\
20890075Sobrien{								\
20990075Sobrien  switch (section)						\
21090075Sobrien    {								\
21190075Sobrien      case in_text: text_section (); break;			\
21290075Sobrien      case in_data: data_section (); break;			\
21390075Sobrien      case in_named: named_section (decl, NULL, 0); break;	\
214117395Skan      case in_readonly_data: readonly_data_section (); break;	\
21590075Sobrien      case in_ctors: ctors_section (); break;			\
21690075Sobrien      case in_dtors: dtors_section (); break;			\
21790075Sobrien      case in_drectve: drectve_section (); break;		\
21890075Sobrien      default: abort (); break;					\
21990075Sobrien    }								\
22090075Sobrien}
221132718Skan
222