altivec_registers.h 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. /* Altivec registers, for PSIM, the PowerPC simulator.
  2. Copyright 2003-2022 Free Software Foundation, Inc.
  3. Contributed by Red Hat Inc; developed under contract from Motorola.
  4. Written by matthew green <mrg@redhat.com>.
  5. This file is part of GDB.
  6. This program is free software; you can redistribute it and/or modify
  7. it under the terms of the GNU General Public License as published by
  8. the Free Software Foundation; either version 3 of the License, or
  9. (at your option) any later version.
  10. This program is distributed in the hope that it will be useful,
  11. but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. GNU General Public License for more details.
  14. You should have received a copy of the GNU General Public License
  15. along with this program. If not, see <http://www.gnu.org/licenses/>. */
  16. /* Manage this as 4 32-bit entities, 8 16-bit entities or 16 8-bit
  17. entities. */
  18. typedef union
  19. {
  20. uint8_t b[16];
  21. uint16_t h[8];
  22. uint32_t w[4];
  23. } vreg;
  24. typedef uint32_t vscreg;
  25. struct altivec_regs {
  26. /* AltiVec Registers */
  27. vreg vr[32];
  28. vscreg vscr;
  29. };
  30. /* AltiVec registers */
  31. #define VR(N) cpu_registers(processor)->altivec.vr[N]
  32. /* AltiVec vector status and control register */
  33. #define VSCR cpu_registers(processor)->altivec.vscr
  34. /* AltiVec endian helpers, wrong endian hosts vs targets need to be
  35. sure to get the right bytes/halfs/words when the order matters.
  36. Note that many AltiVec instructions do not depend on byte order and
  37. work on N independant bits of data. This is only for the
  38. instructions that actually move data around. */
  39. #if (HOST_BYTE_ORDER == BIG_ENDIAN)
  40. #define AV_BINDEX(x) ((x) & 15)
  41. #define AV_HINDEX(x) ((x) & 7)
  42. #else
  43. static char endian_b2l_bindex[16] = { 3, 2, 1, 0, 7, 6, 5, 4,
  44. 11, 10, 9, 8, 15, 14, 13, 12 };
  45. static char endian_b2l_hindex[16] = { 1, 0, 3, 2, 5, 4, 7, 6 };
  46. #define AV_BINDEX(x) endian_b2l_bindex[(x) & 15]
  47. #define AV_HINDEX(x) endian_b2l_hindex[(x) & 7]
  48. #endif