190075Sobrien/* Definitions of target machine for GNU compiler, for ARM with PE obj format.
2169689Skan   Copyright (C) 1995, 1996, 1999, 2000, 2002, 2003, 2004, 2005
3169689Skan   Free Software Foundation, Inc.
490075Sobrien   Contributed by Doug Evans (dje@cygnus.com).
590075Sobrien
6132718Skan   This file is part of GCC.
790075Sobrien
8132718Skan   GCC is free software; you can redistribute it and/or modify it
9132718Skan   under the terms of the GNU General Public License as published
10132718Skan   by the Free Software Foundation; either version 2, or (at your
11132718Skan   option) any later version.
1290075Sobrien
13132718Skan   GCC is distributed in the hope that it will be useful, but WITHOUT
14132718Skan   ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
15132718Skan   or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public
16132718Skan   License for more details.
1790075Sobrien
18132718Skan   You should have received a copy of the GNU General Public License
19132718Skan   along with GCC; see the file COPYING.  If not, write to
20169689Skan   the Free Software Foundation, 51 Franklin Street, Fifth Floor,
21169689Skan   Boston, MA 02110-1301, USA.  */
2290075Sobrien
2390075Sobrien/* Enable PE specific code.  */
2490075Sobrien#define ARM_PE		1
2590075Sobrien
2690075Sobrien#define ARM_PE_FLAG_CHAR '@'
2790075Sobrien
2890075Sobrien/* Ensure that @x. will be stripped from the function name.  */
2990075Sobrien#undef SUBTARGET_NAME_ENCODING_LENGTHS
3090075Sobrien#define SUBTARGET_NAME_ENCODING_LENGTHS  \
3190075Sobrien  case ARM_PE_FLAG_CHAR: return 3;
3290075Sobrien
3390075Sobrien#undef  USER_LABEL_PREFIX
3490075Sobrien#define USER_LABEL_PREFIX "_"
3590075Sobrien
3690075Sobrien
3790075Sobrien/* Run-time Target Specification.  */
3890075Sobrien#undef  TARGET_VERSION
3990075Sobrien#define TARGET_VERSION fputs (" (ARM/pe)", stderr)
4090075Sobrien
4190075Sobrien/* Get tree.c to declare a target-specific specialization of
4290075Sobrien   merge_decl_attributes.  */
43169689Skan#define TARGET_DLLIMPORT_DECL_ATTRIBUTES 1
4490075Sobrien
4590075Sobrien#undef  SUBTARGET_CPP_SPEC
46169689Skan#define SUBTARGET_CPP_SPEC "-D__pe__"
4790075Sobrien
4890075Sobrien#undef  TARGET_DEFAULT
49169689Skan#define TARGET_DEFAULT	(MASK_NOP_FUN_DLLIMPORT)
5090075Sobrien
51132718Skan#undef  MULTILIB_DEFAULTS
52132718Skan#define MULTILIB_DEFAULTS \
53169689Skan  { "marm", "mlittle-endian", "msoft-float", "mno-thumb-interwork" }
5490075Sobrien
5590075Sobrien#undef  WCHAR_TYPE
5690075Sobrien#define WCHAR_TYPE 	"short unsigned int"
5790075Sobrien#undef  WCHAR_TYPE_SIZE
5890075Sobrien#define WCHAR_TYPE_SIZE 16
5990075Sobrien
60132718Skan/* r11 is fixed.  */
61132718Skan#undef  SUBTARGET_CONDITIONAL_REGISTER_USAGE
62132718Skan#define SUBTARGET_CONDITIONAL_REGISTER_USAGE \
63132718Skan  fixed_regs [11] = 1; \
64132718Skan  call_used_regs [11] = 1;
6590075Sobrien
6690075Sobrien
67169689Skan/* PE/COFF uses explicit import from shared libraries.  */
68169689Skan#define MULTIPLE_SYMBOL_SPACES 1
6990075Sobrien
70117395Skan#define TARGET_ASM_UNIQUE_SECTION arm_pe_unique_section
71169689Skan#define TARGET_ASM_FUNCTION_RODATA_SECTION default_no_function_rodata_section
7290075Sobrien
7390075Sobrien#define SUPPORTS_ONE_ONLY 1
7490075Sobrien
7590075Sobrien/* Switch into a generic section.  */
76132718Skan#undef  TARGET_ASM_NAMED_SECTION
7790075Sobrien#define TARGET_ASM_NAMED_SECTION  default_pe_asm_named_section
7890075Sobrien
79132718Skan#define TARGET_ASM_FILE_START_FILE_DIRECTIVE true
8090075Sobrien
8190075Sobrien/* Output a reference to a label.  */
8290075Sobrien#undef  ASM_OUTPUT_LABELREF
8390075Sobrien#define ASM_OUTPUT_LABELREF(STREAM, NAME)  \
8490075Sobrien  asm_fprintf (STREAM, "%U%s", arm_strip_name_encoding (NAME))
8590075Sobrien
8690075Sobrien/* Output a function definition label.  */
8790075Sobrien#undef  ASM_DECLARE_FUNCTION_NAME
8890075Sobrien#define ASM_DECLARE_FUNCTION_NAME(STREAM, NAME, DECL)   	\
8990075Sobrien  do								\
9090075Sobrien    {								\
9190075Sobrien      if (arm_dllexport_name_p (NAME))				\
9290075Sobrien	{							\
9390075Sobrien	  drectve_section ();					\
9490075Sobrien	  fprintf (STREAM, "\t.ascii \" -export:%s\"\n",	\
9590075Sobrien		   arm_strip_name_encoding (NAME));		\
96169689Skan	  switch_to_section (function_section (DECL));		\
9790075Sobrien	}							\
9890075Sobrien      ARM_DECLARE_FUNCTION_NAME (STREAM, NAME, DECL);		\
9990075Sobrien      if (TARGET_THUMB)						\
10090075Sobrien	fprintf (STREAM, "\t.code 16\n");			\
10190075Sobrien      ASM_OUTPUT_LABEL (STREAM, NAME);				\
10290075Sobrien    }								\
10390075Sobrien  while (0)
10490075Sobrien
10590075Sobrien/* Output a common block.  */
10690075Sobrien#undef  ASM_OUTPUT_COMMON
10790075Sobrien#define ASM_OUTPUT_COMMON(STREAM, NAME, SIZE, ROUNDED)	\
10890075Sobrien  do							\
10990075Sobrien    {							\
11090075Sobrien      if (arm_dllexport_name_p (NAME))			\
11190075Sobrien	{						\
11290075Sobrien	  drectve_section ();				\
11390075Sobrien	  fprintf ((STREAM), "\t.ascii \" -export:%s\"\n",\
11490075Sobrien		   arm_strip_name_encoding (NAME));	\
11590075Sobrien	}						\
11690075Sobrien      if (! arm_dllimport_name_p (NAME))		\
11790075Sobrien	{						\
11890075Sobrien	  fprintf ((STREAM), "\t.comm\t"); 		\
11990075Sobrien	  assemble_name ((STREAM), (NAME));		\
12090075Sobrien	  asm_fprintf ((STREAM), ", %d\t%@ %d\n",	\
121132718Skan 		   (int)(ROUNDED), (int)(SIZE));	\
12290075Sobrien	}						\
12390075Sobrien    }							\
12490075Sobrien  while (0)
12590075Sobrien
12690075Sobrien/* Output the label for an initialized variable.  */
12790075Sobrien#undef  ASM_DECLARE_OBJECT_NAME
12890075Sobrien#define ASM_DECLARE_OBJECT_NAME(STREAM, NAME, DECL) 	\
12990075Sobrien  do							\
13090075Sobrien    {							\
13190075Sobrien      if (arm_dllexport_name_p (NAME))			\
13290075Sobrien	{						\
133169689Skan	  section *save_section = in_section;		\
13490075Sobrien	  drectve_section ();				\
13590075Sobrien	  fprintf (STREAM, "\t.ascii \" -export:%s\"\n",\
13690075Sobrien		   arm_strip_name_encoding (NAME));	\
137169689Skan	  switch_to_section (save_section);		\
13890075Sobrien	}						\
13990075Sobrien      ASM_OUTPUT_LABEL ((STREAM), (NAME));		\
14090075Sobrien    }							\
14190075Sobrien  while (0)
14290075Sobrien
14390075Sobrien/* Support the ctors/dtors and other sections.  */
14490075Sobrien
14590075Sobrien#define DRECTVE_SECTION_ASM_OP	"\t.section .drectve"
14690075Sobrien
147169689Skan#define drectve_section() \
148169689Skan  (fprintf (asm_out_file, "%s\n", DRECTVE_SECTION_ASM_OP), \
149169689Skan   in_section = NULL)
150