]>
Commit | Line | Data |
---|---|---|
847b055c AJ |
1 | /* Assembler macros for s390. |
2 | Copyright (C) 2000 Free Software Foundation, Inc. | |
3 | Contributed by Martin Schwidefsky (schwidefsky@de.ibm.com). | |
4 | This file is part of the GNU C Library. | |
5 | ||
6 | The GNU C Library is free software; you can redistribute it and/or | |
7 | modify it under the terms of the GNU Library General Public License as | |
8 | published by the Free Software Foundation; either version 2 of the | |
9 | License, or (at your option) any later version. | |
10 | ||
11 | The GNU C Library is distributed in the hope that it will be useful, | |
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
14 | Library General Public License for more details. | |
15 | ||
16 | You should have received a copy of the GNU Library General Public | |
17 | License along with the GNU C Library; see the file COPYING.LIB. If not, | |
18 | write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
19 | Boston, MA 02111-1307, USA. */ | |
20 | ||
21 | #include <sysdeps/generic/sysdep.h> | |
22 | ||
23 | #ifdef __ASSEMBLER__ | |
24 | ||
25 | /* Syntactic details of assembler. */ | |
26 | ||
27 | #ifdef HAVE_ELF | |
28 | ||
29 | /* ELF uses byte-counts for .align, most others use log2 of count of bytes. */ | |
30 | #define ALIGNARG(log2) 1<<log2 | |
31 | /* For ELF we need the `.type' directive to make shared libs work right. */ | |
32 | #define ASM_TYPE_DIRECTIVE(name,typearg) .type name,typearg; | |
33 | #define ASM_SIZE_DIRECTIVE(name) .size name,.-name; | |
34 | ||
35 | /* In ELF C symbols are asm symbols. */ | |
36 | #undef NO_UNDERSCORES | |
37 | #define NO_UNDERSCORES | |
38 | ||
39 | #else | |
40 | ||
41 | #define ALIGNARG(log2) log2 | |
42 | #define ASM_TYPE_DIRECTIVE(name,type) /* Nothing is specified. */ | |
43 | #define ASM_SIZE_DIRECTIVE(name) /* Nothing is specified. */ | |
44 | ||
45 | #endif | |
46 | ||
47 | ||
48 | /* Define an entry point visible from C. */ | |
49 | #define ENTRY(name) \ | |
50 | ASM_GLOBAL_DIRECTIVE C_SYMBOL_NAME(name); \ | |
51 | ASM_TYPE_DIRECTIVE (C_SYMBOL_NAME(name),@function) \ | |
52 | .align ALIGNARG(2); \ | |
53 | C_LABEL(name) \ | |
54 | CALL_MCOUNT | |
55 | ||
56 | #undef END | |
57 | #define END(name) \ | |
58 | ASM_SIZE_DIRECTIVE(name) \ | |
59 | ||
60 | /* If compiled for profiling, call `mcount' at the start of each function. */ | |
61 | #ifdef PROF | |
62 | #ifdef PIC | |
63 | #define CALL_MCOUNT \ | |
64 | lr 0,14 ; bras 14,.+12 ; .long _GLOBAL_OFFSET_TABLE_ - . ; .long 0f-. ; \ | |
65 | lr 1,14 ; al 1,4(14) ; al 14,0(14) ; l 14,_mcount@GOT(14) ; \ | |
66 | basr 14,14 ; lr 14,0 ; .data ; .align 4 ; 0: .long 0 ; .text ; | |
67 | #else | |
68 | #define CALL_MCOUNT \ | |
69 | lr 0,14 ; bras 14,.+12 ; .long _mcount ; .long 0f ; \ | |
70 | l 1,4(14) ; l 14,0(14) ; basr 14,14 ; lr 14,0 ; \ | |
71 | .data ; .align 4 ; 0: .long 0 ; .text ; | |
72 | #endif | |
73 | #else | |
74 | #define CALL_MCOUNT /* Do nothing. */ | |
75 | #endif | |
76 | ||
77 | #ifdef NO_UNDERSCORES | |
78 | /* Since C identifiers are not normally prefixed with an underscore | |
79 | on this system, the asm identifier `syscall_error' intrudes on the | |
80 | C name space. Make sure we use an innocuous name. */ | |
81 | #define syscall_error __syscall_error | |
82 | #define mcount _mcount | |
83 | #endif | |
84 | ||
85 | #define PSEUDO(name, syscall_name, args) \ | |
86 | lose: SYSCALL_PIC_SETUP \ | |
87 | JUMPTARGET(syscall_error) \ | |
88 | .globl syscall_error; \ | |
89 | ENTRY (name) \ | |
90 | DO_CALL (syscall_name, args); \ | |
91 | jm lose | |
92 | ||
93 | #undef PSEUDO_END | |
94 | #define PSEUDO_END(name) \ | |
95 | END (name) | |
96 | ||
97 | #ifdef PIC | |
98 | #define JUMPTARGET(name) \ | |
99 | basr %r1,0 \ | |
100 | 0: al %r1,1f-0b(0,%r1) \ | |
101 | br %r1 \ | |
102 | 1: .long name##@PLT - 0b | |
103 | #define SYSCALL_PIC_SETUP \ | |
104 | bras %r12,1f \ | |
105 | 0: .long _GLOBAL_OFFSET_TABLE_-0b \ | |
106 | 1: al %r12,0(%r12) | |
107 | #else | |
108 | #define JUMPTARGET(name) \ | |
109 | basr %r1,0 \ | |
110 | 0: al %r1,1f-0b(0,%r1) \ | |
111 | br %r1 \ | |
112 | 1: .long name - 0b | |
113 | #define SYSCALL_PIC_SETUP /* Nothing. */ | |
114 | #endif | |
115 | ||
116 | /* Local label name for asm code. */ | |
117 | #ifndef L | |
118 | #define L(name) name | |
119 | #endif | |
120 | ||
121 | #endif /* __ASSEMBLER__ */ |