1 /* Definitions for TILEPro running Linux-based GNU systems with ELF.
2    Copyright (C) 2011-2021 Free Software Foundation, Inc.
3    Contributed by Walter Lee (walt@tilera.com)
4 
5    This file is part of GCC.
6 
7    GCC is free software; you can redistribute it and/or modify it
8    under the terms of the GNU General Public License as published
9    by the Free Software Foundation; either version 3, or (at your
10    option) any later version.
11 
12    GCC is distributed in the hope that it will be useful, but WITHOUT
13    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
14    or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public
15    License for more details.
16 
17    You should have received a copy of the GNU General Public License
18    along with GCC; see the file COPYING3.  If not see
19    <http://www.gnu.org/licenses/>.  */
20 
21 #undef CPP_SPEC
22 #define CPP_SPEC "%{pthread:-D_REENTRANT}"
23 
24 #undef	LINK_SPEC
25 #define LINK_SPEC "\
26   %{shared:-shared} \
27   %{!shared: \
28     %{!static: \
29       %{rdynamic:-export-dynamic} \
30       -dynamic-linker /lib/ld.so.1} \
31     %{static:-static}}"
32 
33 #define NO_PROFILE_COUNTERS	1
34 
35 #undef MCOUNT_NAME
36 #define MCOUNT_NAME "__mcount"
37 
38 #undef NEED_INDICATE_EXEC_STACK
39 #define NEED_INDICATE_EXEC_STACK 1
40 
41 #ifdef TARGET_LIBC_PROVIDES_SSP
42 /* TILEPro glibc provides __stack_chk_guard two pointer-size words before
43    tp. */
44 #define TARGET_THREAD_SSP_OFFSET (-2 * GET_MODE_SIZE (ptr_mode))
45 #endif
46 
47 /* For __clear_cache in libgcc2.c.  */
48 #ifdef IN_LIBGCC2
49 
50 /* Use the minimum page size of 4K.  Alternatively we can call
51    getpagesize() but it introduces a libc dependence.
52    See Linux arch/tile/include/uapi/arch/icache.h for more commentary.  */
53 #undef CLEAR_INSN_CACHE
54 #define CLEAR_INSN_CACHE(BEG, END)                                      \
55 {                                                                       \
56   long size = (long) (END) - (long) (BEG);                              \
57   if (size)                                                             \
58     {                                                                   \
59       const char *start = (const char *) ((unsigned long) (BEG) & -64L);\
60       const char *end =  start + (size < 16384 ? size : 16384) - 1;     \
61       long num_passes = 4;                                              \
62       __insn_mf ();                                                     \
63       do                                                                \
64       {                                                                 \
65         const char *p;                                                  \
66         for (p = start; p <= end; p += 64)                              \
67           __insn_icoh (p);                                              \
68         start += 4096;                                                  \
69         end += 4096;                                                    \
70       }                                                                 \
71       while (--num_passes > 0);                                         \
72       __insn_drain ();                                                  \
73     }                                                                   \
74 }
75 
76 #else
77 
78 /* define CLEAR_INSN_CACHE so that gcc knows to expand __builtin__clear_cache
79    to the libraray call.  */
80 #undef CLEAR_INSN_CACHE
81 #define CLEAR_INSN_CACHE 1
82 
83 #endif
84