Add Changelog ...
[glibc.git] / sysdeps / tile / sysdep.h
blob58432eb032de81d4163c908026cb6d52c2624773
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.
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.
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.
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library. If not, see
17 <http://www.gnu.org/licenses/>. */
19 #include <sysdeps/generic/sysdep.h>
20 #include <bits/wordsize.h>
21 #include <arch/abi.h>
23 #if defined __ASSEMBLER__ || defined REQUEST_ASSEMBLER_MACROS
25 #include <feedback.h>
27 /* Make use of .type and .size directives. */
28 #define ASM_TYPE_DIRECTIVE(name,typearg) .type name,typearg;
29 #define ASM_SIZE_DIRECTIVE(name) .size name,.-name;
31 /* Define an entry point visible from C. */
32 #define ENTRY(name) \
33 ASM_GLOBAL_DIRECTIVE C_SYMBOL_NAME(name); \
34 ASM_TYPE_DIRECTIVE (C_SYMBOL_NAME(name),@function) \
35 .align 8; \
36 C_LABEL(name) \
37 cfi_startproc; \
38 CALL_MCOUNT
40 #undef END
41 #define END(name) \
42 cfi_endproc; \
43 ASM_SIZE_DIRECTIVE(name)
45 /* Since C identifiers are not normally prefixed with an underscore
46 on this system, the asm identifier `syscall_error' intrudes on the
47 C name space. Make sure we use an innocuous name. */
48 #define syscall_error __syscall_error
49 #define mcount __mcount
51 /* If compiled for profiling, call `mcount' at the start of each function.
52 The mcount code requires the caller PC in r10. The `mcount' function
53 sets lr back to the value r10 had on entry when it returns. */
54 #ifdef PROF
55 #define CALL_MCOUNT { move r10, lr; jal mcount }
56 #else
57 #define CALL_MCOUNT /* Do nothing. */
58 #endif
60 /* Local label name for asm code. */
61 #define L(name) .L##name
63 /* Specify the size in bytes of a machine register. */
64 #ifdef __tilegx__
65 #define REGSIZE 8
66 #else
67 #define REGSIZE 4
68 #endif
70 /* Support a limited form of shared assembly between tile and tilegx.
71 The presumption is that LD/ST are used for manipulating registers.
72 Since opcode parsing is case-insensitive, we don't need to provide
73 definitions for these on tilegx. */
74 #ifndef __tilegx__
75 #define LD lw
76 #define LD4U lw
77 #define ST sw
78 #define ST4 sw
79 #define BNEZ bnz
80 #define BEQZ bz
81 #define BEQZT bzt
82 #define BGTZ bgz
83 #define CMPEQI seqi
84 #define CMPEQ seq
85 #define CMOVEQZ mvz
86 #define CMOVNEZ mvnz
87 #endif
89 /* Provide "pointer-oriented" instruction variants. These differ not
90 just for tile vs tilegx, but also for tilegx -m64 vs -m32. */
91 #if defined __tilegx__ && __WORDSIZE == 32
92 #define ADD_PTR addx
93 #define ADDI_PTR addxi
94 #define ADDLI_PTR addxli
95 #define LD_PTR ld4s
96 #define ST_PTR st4
97 #define SHL_PTR_ADD shl2add
98 #else
99 #define ADD_PTR add
100 #define ADDI_PTR addi
101 #define ADDLI_PTR addli
102 #define LD_PTR LD
103 #define ST_PTR ST
104 #ifdef __tilegx__
105 #define SHL_PTR_ADD shl3add
106 #else
107 #define SHL_PTR_ADD s2a
108 #endif
109 #endif
111 #endif /* __ASSEMBLER__ */