dyngen-exec.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. /*
  2. * dyngen defines for micro operation code
  3. *
  4. * Copyright (c) 2003 Fabrice Bellard
  5. *
  6. * This library is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU Lesser General Public
  8. * License as published by the Free Software Foundation; either
  9. * version 2 of the License, or (at your option) any later version.
  10. *
  11. * This library is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * Lesser General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU Lesser General Public
  17. * License along with this library; if not, see <http://www.gnu.org/licenses/>.
  18. */
  19. #if !defined(__DYNGEN_EXEC_H__)
  20. #define __DYNGEN_EXEC_H__
  21. #include "qemu-common.h"
  22. #ifdef __OpenBSD__
  23. #include <sys/types.h>
  24. #endif
  25. /* XXX: This may be wrong for 64-bit ILP32 hosts. */
  26. typedef void * host_reg_t;
  27. #if defined(__i386__)
  28. #define AREG0 "ebp"
  29. #elif defined(__x86_64__)
  30. #define AREG0 "r14"
  31. #elif defined(_ARCH_PPC)
  32. #define AREG0 "r27"
  33. #elif defined(__arm__)
  34. #define AREG0 "r7"
  35. #elif defined(__hppa__)
  36. #define AREG0 "r17"
  37. #elif defined(__mips__)
  38. #define AREG0 "s0"
  39. #elif defined(__sparc__)
  40. #ifdef CONFIG_SOLARIS
  41. #define AREG0 "g2"
  42. #else
  43. #ifdef __sparc_v9__
  44. #define AREG0 "g5"
  45. #else
  46. #define AREG0 "g6"
  47. #endif
  48. #endif
  49. #elif defined(__s390__)
  50. #define AREG0 "r10"
  51. #elif defined(__alpha__)
  52. /* Note $15 is the frame pointer, so anything in op-i386.c that would
  53. require a frame pointer, like alloca, would probably loose. */
  54. #define AREG0 "$15"
  55. #elif defined(__mc68000)
  56. #define AREG0 "%a5"
  57. #elif defined(__ia64__)
  58. #define AREG0 "r7"
  59. #else
  60. #error unsupported CPU
  61. #endif
  62. #define xglue(x, y) x ## y
  63. #define glue(x, y) xglue(x, y)
  64. #define stringify(s) tostring(s)
  65. #define tostring(s) #s
  66. /* The return address may point to the start of the next instruction.
  67. Subtracting one gets us the call instruction itself. */
  68. #if defined(__s390__) && !defined(__s390x__)
  69. # define GETPC() ((void*)(((unsigned long)__builtin_return_address(0) & 0x7fffffffUL) - 1))
  70. #elif defined(__arm__)
  71. /* Thumb return addresses have the low bit set, so we need to subtract two.
  72. This is still safe in ARM mode because instructions are 4 bytes. */
  73. # define GETPC() ((void *)((unsigned long)__builtin_return_address(0) - 2))
  74. #else
  75. # define GETPC() ((void *)((unsigned long)__builtin_return_address(0) - 1))
  76. #endif
  77. #endif /* !defined(__DYNGEN_EXEC_H__) */