idecode_branch.h 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. /* This file is part of the program psim.
  2. Copyright (C) 1994-1995, Andrew Cagney <cagney@highland.com.au>
  3. This program is free software; you can redistribute it and/or modify
  4. it under the terms of the GNU General Public License as published by
  5. the Free Software Foundation; either version 3 of the License, or
  6. (at your option) any later version.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU General Public License for more details.
  11. You should have received a copy of the GNU General Public License
  12. along with this program; if not, see <http://www.gnu.org/licenses/>.
  13. */
  14. /* branch macro's:
  15. The macro's below implement the semantics of the PowerPC jump
  16. instructions. */
  17. /* If so required, update the Link Register with the next sequential
  18. instruction address */
  19. #define UPDATE_LK \
  20. do { \
  21. if (update_LK) { \
  22. ppc_ia target = cia + 4; \
  23. ppc_spr new_address = (ppc_spr)IEA_MASKED(ppc_is_64bit(processor), \
  24. target); \
  25. LR = new_address; \
  26. } \
  27. ITRACE(trace_branch, \
  28. ("UPDATE_LK - update_LK=%d lr=0x%x cia=0x%x\n", \
  29. update_LK, LR, cia); \
  30. } while (0)
  31. /* take the branch - absolute or relative - possibly updating the link
  32. register */
  33. #define BRANCH(ADDRESS) \
  34. do { \
  35. UPDATE_LK; \
  36. if (update_AA) { \
  37. ppc_ia target = (ppc_ia)(ADDRESS); \
  38. nia = (ppc_ia)IEA_MASKED(ppc_is_64bit(processor), target); \
  39. } \
  40. else { \
  41. ppc_ia target = cia + ADDRESS; \
  42. nia = (ppc_ia)IEA_MASKED(ppc_is_64bit(processor), target); \
  43. } \
  44. PTRACE(trace_branch, \
  45. ("BRANCH - update_AA=%d update_LK=%d nia=0x%x cia=0x%x\n", \
  46. update_AA, update_LK, nia, cia); \
  47. } while (0)