sysdep.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. /* Assembler macros for CRIS.
  2. Copyright (C) 1999, 2000, 2001 Free Software Foundation, Inc.
  3. This file is part of the GNU C Library.
  4. The GNU C Library is free software; you can redistribute it and/or
  5. modify it under the terms of the GNU Library General Public License as
  6. published by the Free Software Foundation; either version 2 of the
  7. License, or (at your option) any later version.
  8. The GNU C Library is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. Library General Public License for more details.
  12. You should have received a copy of the GNU Library General Public
  13. License along with the GNU C Library; see the file COPYING.LIB. If not,
  14. write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  15. Boston, MA 02111-1307, USA. */
  16. #ifndef C_LABEL
  17. /* Define a macro we can use to construct the asm name for a C symbol. */
  18. #ifdef __STDC__
  19. #define C_LABEL(name) name##:
  20. #else
  21. #define C_LABEL(name) name/**/:
  22. #endif
  23. #endif /* C_LABEL */
  24. #define __STR(x) #x
  25. #define STR(x) __STR(x)
  26. /* Mark the end of function named SYM. This is used on some platforms
  27. to generate correct debugging information. */
  28. #ifndef END
  29. #define END(sym)
  30. #endif
  31. #define C_SYMBOL_NAME(name) name
  32. #ifdef __ASSEMBLER__
  33. /* Syntactic details of assembly-code. */
  34. /* It is *not* generally true that "ELF uses byte-counts for .align, most
  35. others use log2 of count of bytes", like some neighboring configs say.
  36. See "align" in gas/read.c which is not overridden by
  37. gas/config/obj-elf.c. It takes a log2 argument. *Some* targets
  38. override it to take a byte argument. People should read source instead
  39. of relying on hearsay. */
  40. #define ALIGNARG(log2) log2
  41. #define ASM_GLOBAL_DIRECTIVE .globl
  42. #define ASM_TYPE_DIRECTIVE(name,typearg) .type name,typearg
  43. #define ASM_SIZE_DIRECTIVE(name) .size name,.-name
  44. /* The non-PIC jump is preferred, since it does not stall, and does not
  45. invoke generation of a PLT. These macros assume that $r0 is set up as
  46. GOT register. */
  47. #ifdef __PIC__
  48. #define PLTJUMP(_x) \
  49. add.d C_SYMBOL_NAME (_x):PLT,$pc
  50. #define PLTCALL(_x) \
  51. jsr [$r0+C_SYMBOL_NAME (_x):GOTPLT16]
  52. #define SETUP_PIC \
  53. push $r0 @ \
  54. move.d $pc,$r0 @ \
  55. sub.d .:GOTOFF,$r0
  56. #define TEARDOWN_PIC pop $r0
  57. #else
  58. #define PLTJUMP(_x) jump C_SYMBOL_NAME (_x)
  59. #define PLTCALL(_x) jsr C_SYMBOL_NAME (_x)
  60. #define SETUP_PIC
  61. #define TEARDOWN_PIC
  62. #endif
  63. /* Define an entry point visible from C. */
  64. #define ENTRY(name) \
  65. .text @ \
  66. ASM_GLOBAL_DIRECTIVE C_SYMBOL_NAME (name) @ \
  67. ASM_TYPE_DIRECTIVE (C_SYMBOL_NAME (name), function) @ \
  68. .align ALIGNARG (2) @ \
  69. C_LABEL(name) @ \
  70. CALL_MCOUNT
  71. #undef END
  72. #define END(name) \
  73. ASM_SIZE_DIRECTIVE (C_SYMBOL_NAME (name))
  74. /* If compiled for profiling, call `mcount' at the start of each function.
  75. FIXME: Note that profiling is not actually implemented. This is just
  76. example code which might not even compile, though it is believed to be
  77. correct. */
  78. #ifdef PROF
  79. #define CALL_MCOUNT \
  80. push $srp @ \
  81. push $r9 @ \
  82. push $r10 @ \
  83. push $r11 @ \
  84. push $r12 @ \
  85. push $r13 @ \
  86. SETUP_PIC @ \
  87. PLTCALL (mcount) @ \
  88. TEARDOWN_PIC @ \
  89. pop $r13 @ \
  90. pop $r12 @ \
  91. pop $r11 @ \
  92. pop $r10 @ \
  93. pop $r9 @ \
  94. pop $srp
  95. #else
  96. #define CALL_MCOUNT /* Do nothing. */
  97. #endif
  98. /* Since C identifiers are not normally prefixed with an underscore
  99. on this system, the asm identifier `syscall_error' intrudes on the
  100. C name space. Make sure we use an innocuous name. */
  101. #define syscall_error __syscall_error
  102. #define mcount _mcount
  103. #endif /* __ASSEMBLER__ */