fe481a24d44a26d49d459b1c65eb601fd0e6928c
[platform/upstream/glibc.git] / sysdeps / tile / sysdep.h
1 /* Copyright (C) 2011 Free Software Foundation, Inc.
2    This file is part of the GNU C Library.
3    Contributed by Chris Metcalf <cmetcalf@tilera.com>, 2011.
4
5    The GNU C Library is free software; you can redistribute it and/or
6    modify it under the terms of the GNU Lesser General Public
7    License as published by the Free Software Foundation; either
8    version 2.1 of the License, or (at your option) any later version.
9
10    The GNU C Library is distributed in the hope that it will be useful,
11    but WITHOUT ANY WARRANTY; without even the implied warranty of
12    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13    Lesser General Public License for more details.
14
15    You should have received a copy of the GNU Lesser General Public
16    License along with the GNU C Library; if not, write to the Free
17    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
18    02111-1307 USA.  */
19
20 #include <sysdeps/generic/sysdep.h>
21 #include <bits/wordsize.h>
22 #include <arch/abi.h>
23
24 #if defined __ASSEMBLER__ || defined REQUEST_ASSEMBLER_MACROS
25
26 #include <feedback.h>
27
28 /* Make use of .type and .size directives.  */
29 #define ASM_TYPE_DIRECTIVE(name,typearg) .type name,typearg;
30 #define ASM_SIZE_DIRECTIVE(name) .size name,.-name;
31
32 /* Define an entry point visible from C.  */
33 #define ENTRY(name)                                                           \
34   ASM_GLOBAL_DIRECTIVE C_SYMBOL_NAME(name);                                   \
35   ASM_TYPE_DIRECTIVE (C_SYMBOL_NAME(name),@function)                          \
36   .align 8;                                                                   \
37   C_LABEL(name)                                                               \
38   cfi_startproc;                                                              \
39   CALL_MCOUNT
40
41 #undef  END
42 #define END(name)                                                             \
43   cfi_endproc;                                                                \
44   ASM_SIZE_DIRECTIVE(name)
45
46 /* Since C identifiers are not normally prefixed with an underscore
47    on this system, the asm identifier `syscall_error' intrudes on the
48    C name space.  Make sure we use an innocuous name.  */
49 #define syscall_error   __syscall_error
50 #define mcount          __mcount
51
52 /* If compiled for profiling, call `mcount' at the start of each function.
53    The mcount code requires the caller PC in r10.  The `mcount' function
54    sets lr back to the value r10 had on entry when it returns.  */
55 #ifdef  PROF
56 #define CALL_MCOUNT { move r10, lr; jal mcount }
57 #else
58 #define CALL_MCOUNT             /* Do nothing.  */
59 #endif
60
61 /* Local label name for asm code. */
62 #define L(name)         .L##name
63
64 /* Specify the size in bytes of a machine register.  */
65 #ifdef __tilegx__
66 #define REGSIZE         8
67 #else
68 #define REGSIZE         4
69 #endif
70
71 /* Support a limited form of shared assembly between tile and tilegx.
72    The presumption is that LD/ST are used for manipulating registers.
73    Since opcode parsing is case-insensitive, we don't need to provide
74    definitions for these on tilegx.  */
75 #ifndef __tilegx__
76 #define LD              lw
77 #define LD4U            lw
78 #define ST              sw
79 #define ST4             sw
80 #define BNEZ            bnz
81 #define BEQZ            bz
82 #define BEQZT           bzt
83 #define BGTZ            bgz
84 #define CMPEQI          seqi
85 #define CMPEQ           seq
86 #define CMOVEQZ         mvz
87 #define CMOVNEZ         mvnz
88 #endif
89
90 /* Provide "pointer-oriented" instruction variants.  These differ not
91    just for tile vs tilegx, but also for tilegx -m64 vs -m32.  */
92 #if defined __tilegx__ && __WORDSIZE == 32
93 #define ADD_PTR         addx
94 #define ADDI_PTR        addxi
95 #define ADDLI_PTR       addxli
96 #define LD_PTR          ld4s
97 #define ST_PTR          st4
98 #define SHL_PTR_ADD     shl2add
99 #else
100 #define ADD_PTR         add
101 #define ADDI_PTR        addi
102 #define ADDLI_PTR       addli
103 #define LD_PTR          LD
104 #define ST_PTR          ST
105 #ifdef __tilegx__
106 #define SHL_PTR_ADD     shl3add
107 #else
108 #define SHL_PTR_ADD     s2a
109 #endif
110 #endif
111
112 #endif /* __ASSEMBLER__ */