sysdep.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  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 _SYSDEP_H_
  17. #define _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. #define C_SYMBOL_NAME(name) name
  34. #ifdef __ASSEMBLER__
  35. /* Syntactic details of assembly-code. */
  36. /* It is *not* generally true that "ELF uses byte-counts for .align, most
  37. others use log2 of count of bytes", like some neighboring configs say.
  38. See "align" in gas/read.c which is not overridden by
  39. gas/config/obj-elf.c. It takes a log2 argument. *Some* targets
  40. override it to take a byte argument. People should read source instead
  41. of relying on hearsay. */
  42. #define ALIGNARG(log2) log2
  43. #define ASM_GLOBAL_DIRECTIVE .globl
  44. #define ASM_TYPE_DIRECTIVE(name,typearg) .type name,typearg
  45. #define ASM_SIZE_DIRECTIVE(name) .size name,.-name
  46. /* The non-PIC jump is preferred, since it does not stall, and does not
  47. invoke generation of a PLT. These macros assume that $r0 is set up as
  48. GOT register. */
  49. #ifdef __PIC__
  50. #define PLTJUMP(_x) \
  51. add.d C_SYMBOL_NAME (_x):PLT,$pc
  52. #define PLTCALL(_x) \
  53. jsr [$r0+C_SYMBOL_NAME (_x):GOTPLT16]
  54. #define SETUP_PIC \
  55. push $r0 @ \
  56. move.d $pc,$r0 @ \
  57. sub.d .:GOTOFF,$r0
  58. #define TEARDOWN_PIC pop $r0
  59. #else
  60. #define PLTJUMP(_x) jump C_SYMBOL_NAME (_x)
  61. #define PLTCALL(_x) jsr C_SYMBOL_NAME (_x)
  62. #define SETUP_PIC
  63. #define TEARDOWN_PIC
  64. #endif
  65. /* Define an entry point visible from C. */
  66. #define ENTRY(name) \
  67. .text @ \
  68. ASM_GLOBAL_DIRECTIVE C_SYMBOL_NAME (name) @ \
  69. ASM_TYPE_DIRECTIVE (C_SYMBOL_NAME (name), function) @ \
  70. .align ALIGNARG (2) @ \
  71. C_LABEL(name) @ \
  72. CALL_MCOUNT
  73. #undef END
  74. #define END(name) \
  75. ASM_SIZE_DIRECTIVE (C_SYMBOL_NAME (name))
  76. #define PSEUDO(name, syscall_name, args) \
  77. ENTRY (name) @ \
  78. DOARGS_##args @ \
  79. movu.w SYS_ify (syscall_name),$r9 @ \
  80. break 13 @ \
  81. cmps.w -4096,$r10 @ \
  82. bhs 0f @ \
  83. nop @ \
  84. UNDOARGS_return_##args
  85. #define PSEUDO_END(name) \
  86. 0: @ \
  87. SETUP_PIC @ \
  88. PLTJUMP (__syscall_error) @ \
  89. END (name)
  90. /* If compiled for profiling, do nothing */
  91. #define CALL_MCOUNT /* Do nothing. */
  92. #endif /* __ASSEMBLER__ */
  93. #endif /* _SYSDEP_H_ */