1/* Definitions for SH running NetBSD using ELF
2   Copyright (C) 2002-2015 Free Software Foundation, Inc.
3   Contributed by Wasabi Systems, Inc.
4
5This file is part of GCC.
6
7GCC is free software; you can redistribute it and/or modify
8it under the terms of the GNU General Public License as published by
9the Free Software Foundation; either version 3, or (at your option)
10any later version.
11
12GCC is distributed in the hope that it will be useful,
13but WITHOUT ANY WARRANTY; without even the implied warranty of
14MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15GNU General Public License for more details.
16
17You should have received a copy of the GNU General Public License
18along with GCC; see the file COPYING3.  If not see
19<http://www.gnu.org/licenses/>.  */
20
21/* Run-time Target Specification.  */
22
23/* Extra specs needed for NetBSD SuperH ELF targets.  */
24
25#undef SUBTARGET_EXTRA_SPECS
26#define SUBTARGET_EXTRA_SPECS						\
27  { "netbsd_entry_point", NETBSD_ENTRY_POINT },
28
29
30#define TARGET_OS_CPP_BUILTINS()					\
31  do									\
32    {									\
33      NETBSD_OS_CPP_BUILTINS_ELF();					\
34      builtin_define ("__NO_LEADING_UNDERSCORES__");			\
35    }									\
36  while (0)
37
38/* Provide a LINK_SPEC appropriate for a NetBSD/sh ELF target.
39   We use the SH_LINK_SPEC from sh/sh.h, and define the appropriate
40   SUBTARGET_LINK_SPEC that pulls in what we need from a generic
41   NetBSD ELF LINK_SPEC.  */
42
43/* LINK_EMUL_PREFIX from sh/elf.h */
44#undef SUBTARGET_LINK_EMUL_SUFFIX
45#define SUBTARGET_LINK_EMUL_SUFFIX "_nbsd"
46
47#undef SUBTARGET_LINK_SPEC
48#define SUBTARGET_LINK_SPEC NETBSD_LINK_SPEC_ELF
49
50#undef LINK_SPEC
51#define LINK_SPEC SH_LINK_SPEC
52
53#define NETBSD_ENTRY_POINT "__start"
54
55/* Provide a CPP_SPEC appropriate for NetBSD.  */
56#undef SUBTARGET_CPP_SPEC
57#define SUBTARGET_CPP_SPEC NETBSD_CPP_SPEC
58
59#undef TARGET_DEFAULT
60#define TARGET_DEFAULT \
61  (TARGET_CPU_DEFAULT | TARGET_ENDIAN_DEFAULT)
62
63/* Define because we use the label and we do not need them.  */
64#define NO_PROFILE_COUNTERS 1
65
66#undef FUNCTION_PROFILER
67#define FUNCTION_PROFILER(STREAM,LABELNO)				\
68do									\
69  {									\
70    if (TARGET_SHMEDIA32 || TARGET_SHMEDIA64)				\
71      {									\
72	/* FIXME */							\
73	sorry ("unimplemented-shmedia profiling");			\
74      }									\
75    else								\
76      {									\
77        fprintf((STREAM), "\tmov.l\t%sLP%d,r1\n",			\
78                LOCAL_LABEL_PREFIX, (LABELNO));				\
79        fprintf((STREAM), "\tmova\t%sLP%dr,r0\n",			\
80                LOCAL_LABEL_PREFIX, (LABELNO));				\
81        fprintf((STREAM), "\tjmp\t@r1\n");				\
82        fprintf((STREAM), "\tnop\n");					\
83        fprintf((STREAM), "\t.align\t2\n");				\
84        fprintf((STREAM), "%sLP%d:\t.long\t__mcount\n",			\
85                LOCAL_LABEL_PREFIX, (LABELNO));				\
86        fprintf((STREAM), "%sLP%dr:\n", LOCAL_LABEL_PREFIX, (LABELNO));	\
87      }									\
88  }									\
89while (0)
90
91/* Since libgcc is compiled with -fpic for this target, we can't use
92   __sdivsi3_1 as the division strategy for -O0 and -Os.  */
93#undef SH_DIV_STRATEGY_DEFAULT
94#define SH_DIV_STRATEGY_DEFAULT SH_DIV_CALL2
95#undef SH_DIV_STR_FOR_SIZE
96#define SH_DIV_STR_FOR_SIZE "call2"
97
98#undef SUBTARGET_OVERRIDE_OPTIONS
99#define SUBTARGET_OVERRIDE_OPTIONS					\
100  do									\
101    {									\
102      /* Set -musermode if it hasn't been specified.  */		\
103      if (global_options_set.x_TARGET_USERMODE == 0)			\
104	TARGET_USERMODE = true;						\
105    }									\
106  while (0)
107