source: trunk/gcc/libffi/src/powerpc/asm.h

Last change on this file was 2, checked in by bird, 22 years ago

Initial revision

  • Property cvs2svn:cvs-rev set to 1.1
  • Property svn:eol-style set to native
  • Property svn:executable set to *
File size: 4.3 KB
Line 
1/* -----------------------------------------------------------------------
2 asm.h - Copyright (c) 1998 Geoffrey Keating
3
4 PowerPC Assembly glue.
5
6 $Id: asm.h,v 1.1.1.1 1998/11/29 16:48:16 green Exp $
7
8 Permission is hereby granted, free of charge, to any person obtaining
9 a copy of this software and associated documentation files (the
10 ``Software''), to deal in the Software without restriction, including
11 without limitation the rights to use, copy, modify, merge, publish,
12 distribute, sublicense, and/or sell copies of the Software, and to
13 permit persons to whom the Software is furnished to do so, subject to
14 the following conditions:
15
16 The above copyright notice and this permission notice shall be included
17 in all copies or substantial portions of the Software.
18
19 THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, EXPRESS
20 OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
21 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
22 IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR
23 OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
24 ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
25 OTHER DEALINGS IN THE SOFTWARE.
26 ----------------------------------------------------------------------- */
27
28#define ASM_GLOBAL_DIRECTIVE .globl
29
30
31#define C_SYMBOL_NAME(name) name
32/* Macro for a label. */
33#ifdef __STDC__
34#define C_LABEL(name) name##:
35#else
36#define C_LABEL(name) name/**/:
37#endif
38
39/* This seems to always be the case on PPC. */
40#define ALIGNARG(log2) log2
41/* For ELF we need the `.type' directive to make shared libs work right. */
42#define ASM_TYPE_DIRECTIVE(name,typearg) .type name,typearg;
43#define ASM_SIZE_DIRECTIVE(name) .size name,.-name
44
45/* If compiled for profiling, call `_mcount' at the start of each function. */
46#ifdef PROF
47/* The mcount code relies on a the return address being on the stack
48 to locate our caller and so it can restore it; so store one just
49 for its benefit. */
50#ifdef PIC
51#define CALL_MCOUNT \
52 .pushsection; \
53 .section ".data"; \
54 .align ALIGNARG(2); \
550:.long 0; \
56 .previous; \
57 mflr %r0; \
58 stw %r0,4(%r1); \
59 bl _GLOBAL_OFFSET_TABLE_@local-4; \
60 mflr %r11; \
61 lwz %r0,0b@got(%r11); \
62 bl JUMPTARGET(_mcount);
63#else /* PIC */
64#define CALL_MCOUNT \
65 .section ".data"; \
66 .align ALIGNARG(2); \
670:.long 0; \
68 .previous; \
69 mflr %r0; \
70 lis %r11,0b@ha; \
71 stw %r0,4(%r1); \
72 addi %r0,%r11,0b@l; \
73 bl JUMPTARGET(_mcount);
74#endif /* PIC */
75#else /* PROF */
76#define CALL_MCOUNT /* Do nothing. */
77#endif /* PROF */
78
79#define ENTRY(name) \
80 ASM_GLOBAL_DIRECTIVE C_SYMBOL_NAME(name); \
81 ASM_TYPE_DIRECTIVE (C_SYMBOL_NAME(name),@function) \
82 .align ALIGNARG(2); \
83 C_LABEL(name) \
84 CALL_MCOUNT
85
86#define EALIGN_W_0 /* No words to insert. */
87#define EALIGN_W_1 nop
88#define EALIGN_W_2 nop;nop
89#define EALIGN_W_3 nop;nop;nop
90#define EALIGN_W_4 EALIGN_W_3;nop
91#define EALIGN_W_5 EALIGN_W_4;nop
92#define EALIGN_W_6 EALIGN_W_5;nop
93#define EALIGN_W_7 EALIGN_W_6;nop
94
95/* EALIGN is like ENTRY, but does alignment to 'words'*4 bytes
96 past a 2^align boundary. */
97#ifdef PROF
98#define EALIGN(name, alignt, words) \
99 ASM_GLOBAL_DIRECTIVE C_SYMBOL_NAME(name); \
100 ASM_TYPE_DIRECTIVE (C_SYMBOL_NAME(name),@function) \
101 .align ALIGNARG(2); \
102 C_LABEL(name) \
103 CALL_MCOUNT \
104 b 0f; \
105 .align ALIGNARG(alignt); \
106 EALIGN_W_##words; \
107 0:
108#else /* PROF */
109#define EALIGN(name, alignt, words) \
110 ASM_GLOBAL_DIRECTIVE C_SYMBOL_NAME(name); \
111 ASM_TYPE_DIRECTIVE (C_SYMBOL_NAME(name),@function) \
112 .align ALIGNARG(alignt); \
113 EALIGN_W_##words; \
114 C_LABEL(name)
115#endif
116
117#define END(name) \
118 ASM_SIZE_DIRECTIVE(name)
119
120#ifdef PIC
121#define JUMPTARGET(name) name##@plt
122#else
123#define JUMPTARGET(name) name
124#endif
125
126/* Local labels stripped out by the linker. */
127#define L(x) .L##x
128
Note: See TracBrowser for help on using the repository browser.