sysdep.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  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. #ifdef __ASSEMBLER__
  34. /* Syntactic details of assembly-code. */
  35. /* It is *not* generally true that "ELF uses byte-counts for .align, most
  36. others use log2 of count of bytes", like some neighboring configs say.
  37. See "align" in gas/read.c which is not overridden by
  38. gas/config/obj-elf.c. It takes a log2 argument. *Some* targets
  39. override it to take a byte argument. People should read source instead
  40. of relying on hearsay. */
  41. #define ALIGNARG(log2) log2
  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. #define PSEUDO(name, syscall_name, args) \
  75. ENTRY (name) @ \
  76. DOARGS_##args @ \
  77. movu.w SYS_ify (syscall_name),$r9 @ \
  78. break 13 @ \
  79. cmps.w -4096,$r10 @ \
  80. bhs 0f @ \
  81. nop @ \
  82. UNDOARGS_return_##args
  83. #define PSEUDO_END(name) \
  84. 0: @ \
  85. SETUP_PIC @ \
  86. PLTJUMP (__syscall_error) @ \
  87. END (name)
  88. /* If compiled for profiling, do nothing */
  89. #define CALL_MCOUNT /* Do nothing. */
  90. #endif /* __ASSEMBLER__ */
  91. #endif /* _SYSDEP_H_ */