branch.h 951 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. /*
  2. * This file is subject to the terms and conditions of the GNU General Public
  3. * License. See the file "COPYING" in the main directory of this archive
  4. * for more details.
  5. *
  6. * Copyright (C) 1996, 1997, 1998, 2001 by Ralf Baechle
  7. */
  8. #ifndef _ASM_BRANCH_H
  9. #define _ASM_BRANCH_H
  10. #include <asm/ptrace.h>
  11. #include <asm/inst.h>
  12. static inline int delay_slot(struct pt_regs *regs)
  13. {
  14. return regs->cp0_cause & CAUSEF_BD;
  15. }
  16. static inline unsigned long exception_epc(struct pt_regs *regs)
  17. {
  18. if (!delay_slot(regs))
  19. return regs->cp0_epc;
  20. return regs->cp0_epc + 4;
  21. }
  22. #define BRANCH_LIKELY_TAKEN 0x0001
  23. extern int __compute_return_epc(struct pt_regs *regs);
  24. extern int __compute_return_epc_for_insn(struct pt_regs *regs,
  25. union mips_instruction insn);
  26. static inline int compute_return_epc(struct pt_regs *regs)
  27. {
  28. if (!delay_slot(regs)) {
  29. regs->cp0_epc += 4;
  30. return 0;
  31. }
  32. return __compute_return_epc(regs);
  33. }
  34. #endif /* _ASM_BRANCH_H */