]> git.ipfire.org Git - thirdparty/glibc.git/blob - sysdeps/csky/sysdep.h
cff0ead958671e74eaf890f00f30db9ebcca4779
[thirdparty/glibc.git] / sysdeps / csky / sysdep.h
1 /* Assembler macros for C-SKY.
2 Copyright (C) 2018-2020 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
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, see
17 <https://www.gnu.org/licenses/>. */
18
19 #include <sysdeps/generic/sysdep.h>
20 #include <features.h>
21
22 #ifdef __ASSEMBLER__
23
24 # define ASM_SIZE_DIRECTIVE(name) .size name,.-name
25
26 /* Define an entry point visible from C. */
27 # define ENTRY(name) \
28 .globl name; \
29 .type name,@function; \
30 .align 4; \
31 name##:; \
32 cfi_startproc; \
33 CALL_MCOUNT
34
35 # undef END
36 # define END(name) \
37 cfi_endproc; \
38 ASM_SIZE_DIRECTIVE(name)
39
40 /* If compiled for profiling, call `mcount' at the start of each function. */
41 # ifdef PROF
42 # ifdef __PIC__
43 # define CALL_MCOUNT \
44 subi sp, 4; \
45 stw lr, (sp, 0); \
46 grs t0, .Lgetpc; \
47 .Lgetpc: \
48 lrw gb, .Lgetpc@GOTPC; \
49 addu gb, t0; \
50 lrw t1, _mcount@PLT; \
51 ldr.w t0, (gb, t1 << 0); \
52 jmp t0;
53 # else
54 # define CALL_MCOUNT \
55 subi sp, 4; \
56 stw lr, (sp, 0); \
57 jbsr _mcount;
58 # endif
59 # else
60 # define CALL_MCOUNT /* Do nothing. */
61 # endif
62
63 # if defined (__CK860__)
64 /* Instruction fetch will be faster when the label is 16 bytes aligned.
65 Filling with nop instruction to avoid extra jump. */
66 # define LABLE_ALIGN \
67 .balignw 16, 0x6c03
68
69 # define PRE_BNEZAD(R)
70
71 # define BNEZAD(R, L) \
72 bnezad R, L
73 # else
74 # define LABLE_ALIGN \
75 .balignw 8, 0x6c03
76
77 # define PRE_BNEZAD(R) \
78 subi R, 1
79
80 # define BNEZAD(R, L) \
81 bnez R, L
82 # endif
83
84 #endif