Back to index

glibc  2.9
sysdep.h
Go to the documentation of this file.
00001 /* Assembler macros for CRIS.
00002    Copyright (C) 1999, 2000, 2001 Free Software Foundation, Inc.
00003    This file is part of the GNU C Library.
00004 
00005    The GNU C Library is free software; you can redistribute it and/or
00006    modify it under the terms of the GNU Lesser General Public
00007    License as published by the Free Software Foundation; either
00008    version 2.1 of the License, or (at your option) any later version.
00009 
00010    The GNU C Library is distributed in the hope that it will be useful,
00011    but WITHOUT ANY WARRANTY; without even the implied warranty of
00012    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013    Lesser General Public License for more details.
00014 
00015    You should have received a copy of the GNU Lesser General Public
00016    License along with the GNU C Library; if not, write to the Free
00017    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
00018    02111-1307 USA.  */
00019 
00020 #include <sysdeps/generic/sysdep.h>
00021 
00022 #ifndef HAVE_ELF
00023 # error ELF is assumed.  Generalize the code and retry.
00024 #endif
00025 
00026 #ifndef NO_UNDERSCORES
00027 # error User-label prefix (underscore) assumed absent.  Generalize the code and retry.
00028 #endif
00029 
00030 #ifdef __ASSEMBLER__
00031 
00032 /* Syntactic details of assembly-code.  */
00033 
00034 /* It is *not* generally true that "ELF uses byte-counts for .align, most
00035    others use log2 of count of bytes", like some neighboring configs say.
00036    See "align" in gas/read.c which is not overridden by
00037    gas/config/obj-elf.c.  It takes a log2 argument.  *Some* targets
00038    override it to take a byte argument.  People should read source instead
00039    of relying on hearsay.  */
00040 # define ALIGNARG(log2) log2
00041 
00042 # define ASM_TYPE_DIRECTIVE(name,typearg) .type name,typearg
00043 # define ASM_SIZE_DIRECTIVE(name) .size name,.-name
00044 
00045 /* The non-PIC jump is preferred, since it does not stall, and does not
00046    invoke generation of a PLT.  These macros assume that $r0 is set up as
00047    GOT register.  */
00048 # ifdef __PIC__
00049 #  define PLTJUMP(_x) \
00050   add.d       C_SYMBOL_NAME (_x):PLT,$pc
00051 
00052 #  define PLTCALL(_x) \
00053   move.d C_SYMBOL_NAME (_x):PLTG,$r9                    @ \
00054   add.d       $r0,$r9                                          @ \
00055   jsr  $r9
00056 
00057 #  define SETUP_PIC \
00058   push $r0                                       @ \
00059   move.d $pc,$r0                                 @ \
00060   sub.d       .:GOTOFF,$r0
00061 
00062 #  define TEARDOWN_PIC pop $r0
00063 # else
00064 #  define PLTJUMP(_x) jump C_SYMBOL_NAME (_x)
00065 #  define PLTCALL(_x) jsr  C_SYMBOL_NAME (_x)
00066 #  define SETUP_PIC
00067 #  define TEARDOWN_PIC
00068 # endif
00069 
00070 /* Define an entry point visible from C.  */
00071 # define ENTRY(name) \
00072   .text                                                 @ \
00073   ASM_GLOBAL_DIRECTIVE C_SYMBOL_NAME (name)             @ \
00074   ASM_TYPE_DIRECTIVE (C_SYMBOL_NAME (name), function)   @ \
00075   .align ALIGNARG (2)                                   @ \
00076   C_LABEL(name)                                         @ \
00077   CALL_MCOUNT
00078 
00079 # undef       END
00080 # define END(name) \
00081   ASM_SIZE_DIRECTIVE (C_SYMBOL_NAME (name))
00082 
00083 /* If compiled for profiling, call `mcount' at the start of each function.
00084    FIXME: Note that profiling is not actually implemented.  This is just
00085    example code which might not even compile, though it is believed to be
00086    correct.  */
00087 # ifdef       PROF
00088 #  define CALL_MCOUNT \
00089   push $srp                                      @ \
00090   push $r9                                       @ \
00091   push $r10                                      @ \
00092   push $r11                                      @ \
00093   push $r12                                      @ \
00094   push $r13                                      @ \
00095   SETUP_PIC                                      @ \
00096   PLTCALL (mcount)                               @ \
00097   TEARDOWN_PIC                                          @ \
00098   pop  $r13                                      @ \
00099   pop  $r12                                      @ \
00100   pop  $r11                                      @ \
00101   pop  $r10                                      @ \
00102   pop  $r9                                       @ \
00103   pop  $srp
00104 # else
00105 #  define CALL_MCOUNT              /* Do nothing.  */
00106 # endif
00107 
00108 /* Since C identifiers are not normally prefixed with an underscore
00109    on this system, the asm identifier `syscall_error' intrudes on the
00110    C name space.  Make sure we use an innocuous name.  */
00111 # define syscall_error      __syscall_error
00112 # define mcount             _mcount
00113 
00114 #endif /* __ASSEMBLER__ */