sysdep.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  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. see <http://www.gnu.org/licenses/>. */
  15. #ifndef _SYSDEP_H_
  16. #define _SYSDEP_H_
  17. #include <common/sysdep.h>
  18. #ifndef C_LABEL
  19. /* Define a macro we can use to construct the asm name for a C symbol. */
  20. #ifdef __STDC__
  21. #define C_LABEL(name) name##:
  22. #else
  23. #define C_LABEL(name) name/**/:
  24. #endif
  25. #endif /* C_LABEL */
  26. #define __STR(x) #x
  27. #define STR(x) __STR(x)
  28. /* Mark the end of function named SYM. This is used on some platforms
  29. to generate correct debugging information. */
  30. #ifndef END
  31. #define END(sym)
  32. #endif
  33. #undef SYS_ify
  34. #define SYS_ify(syscall_name) (__NR_##syscall_name)
  35. #ifdef __ASSEMBLER__
  36. #undef SYS_ify
  37. #define SYS_ify(syscall_name) __NR_##syscall_name
  38. /* Syntactic details of assembly-code. */
  39. /* It is *not* generally true that "ELF uses byte-counts for .align, most
  40. others use log2 of count of bytes", like some neighboring configs say.
  41. See "align" in gas/read.c which is not overridden by
  42. gas/config/obj-elf.c. It takes a log2 argument. *Some* targets
  43. override it to take a byte argument. People should read source instead
  44. of relying on hearsay. */
  45. #define ALIGNARG(log2) log2
  46. #define ASM_TYPE_DIRECTIVE(name,typearg) .type name,typearg
  47. #define ASM_SIZE_DIRECTIVE(name) .size name,.-name
  48. /* The non-PIC jump is preferred, since it does not stall, and does not
  49. invoke generation of a PLT. These macros assume that $r0 is set up as
  50. GOT register. */
  51. #ifdef __arch_v32
  52. #ifdef __PIC__
  53. #define PLTJUMP(_x) \
  54. ba C_SYMBOL_NAME (_x):PLT @ \
  55. nop
  56. #define PLTCALL(_x) \
  57. bsr C_SYMBOL_NAME (_x):PLT @ \
  58. nop
  59. #define SETUP_PIC \
  60. subq 4,$sp @ \
  61. move.d $r0,[$sp] @ \
  62. lapc _GLOBAL_OFFSET_TABLE_,$r0
  63. #define TEARDOWN_PIC move.d [$sp+],$r0
  64. #else
  65. #define PLTJUMP(_x) \
  66. ba C_SYMBOL_NAME (_x) @ \
  67. nop
  68. #define PLTCALL(_x) \
  69. bsr C_SYMBOL_NAME (_x) @ \
  70. nop
  71. #define SETUP_PIC
  72. #define TEARDOWN_PIC
  73. #endif
  74. #else
  75. #ifdef __PIC__
  76. #define PLTJUMP(_x) \
  77. add.d C_SYMBOL_NAME (_x):PLT,$pc
  78. #define PLTCALL(_x) \
  79. jsr [$r0+C_SYMBOL_NAME (_x):GOTPLT16]
  80. #define SETUP_PIC \
  81. push $r0 @ \
  82. move.d $pc,$r0 @ \
  83. sub.d .:GOTOFF,$r0
  84. #define TEARDOWN_PIC pop $r0
  85. #else
  86. #define PLTJUMP(_x) jump C_SYMBOL_NAME (_x)
  87. #define PLTCALL(_x) jsr C_SYMBOL_NAME (_x)
  88. #define SETUP_PIC
  89. #define TEARDOWN_PIC
  90. #endif
  91. #endif /* __arch_v32 */
  92. /* Define an entry point visible from C. */
  93. #define ENTRY(name) \
  94. .text @ \
  95. .globl C_SYMBOL_NAME (name) @ \
  96. ASM_TYPE_DIRECTIVE (C_SYMBOL_NAME (name), function) @ \
  97. .align ALIGNARG (2) @ \
  98. C_LABEL(name)
  99. #define HIDDEN_ENTRY(name) \
  100. .text @ \
  101. .globl C_SYMBOL_NAME (name) @ \
  102. .hidden C_SYMBOL_NAME (name) @ \
  103. ASM_TYPE_DIRECTIVE (C_SYMBOL_NAME (name), function) @ \
  104. .align ALIGNARG (2) @ \
  105. C_LABEL(name)
  106. #undef END
  107. #define END(name) \
  108. ASM_SIZE_DIRECTIVE (C_SYMBOL_NAME (name))
  109. #define PSEUDO(name, syscall_name, args) \
  110. ENTRY (name) @ \
  111. DOARGS_##args @ \
  112. movu.w SYS_ify (syscall_name),$r9 @ \
  113. break 13 @ \
  114. cmps.w -4096,$r10 @ \
  115. bhs 0f @ \
  116. nop @ \
  117. UNDOARGS_return_##args
  118. #define PSEUDO_END(name) \
  119. 0: @ \
  120. SETUP_PIC @ \
  121. PLTJUMP (__syscall_error) @ \
  122. END (name)
  123. #endif /* __ASSEMBLER__ */
  124. #endif /* _SYSDEP_H_ */