blob: c979c3790e4c577adac54f62582cb2f95809228a [file] [log] [blame]
Marcin Nowakowskie3031b32016-09-30 11:33:45 +02001/*
2 * Copyright (C) 2016 Imagination Technologies
3 * Author: Marcin Nowakowski <marcin.nowakowski@imgtec.com>
4 *
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License as published by the
7 * Free Software Foundation; either version 2 of the License, or (at your
8 * option) any later version.
9 */
10
11#ifndef __PROBES_COMMON_H
12#define __PROBES_COMMON_H
13
14#include <asm/inst.h>
15
16static inline int __insn_has_delay_slot(const union mips_instruction insn)
17{
18 switch (insn.i_format.opcode) {
19 /*
20 * jr and jalr are in r_format format.
21 */
22 case spec_op:
23 switch (insn.r_format.func) {
24 case jalr_op:
25 case jr_op:
26 return 1;
27 }
28 break;
29
30 /*
31 * This group contains:
32 * bltz_op, bgez_op, bltzl_op, bgezl_op,
33 * bltzal_op, bgezal_op, bltzall_op, bgezall_op.
34 */
35 case bcond_op:
36 switch (insn.i_format.rt) {
37 case bltz_op:
38 case bltzl_op:
39 case bgez_op:
40 case bgezl_op:
41 case bltzal_op:
42 case bltzall_op:
43 case bgezal_op:
44 case bgezall_op:
45 case bposge32_op:
46 return 1;
47 }
48 break;
49
50 /*
51 * These are unconditional and in j_format.
52 */
53 case jal_op:
54 case j_op:
55 case beq_op:
56 case beql_op:
57 case bne_op:
58 case bnel_op:
59 case blez_op: /* not really i_format */
60 case blezl_op:
61 case bgtz_op:
62 case bgtzl_op:
63 return 1;
64
65 /*
66 * And now the FPA/cp1 branch instructions.
67 */
68 case cop1_op:
69#ifdef CONFIG_CPU_CAVIUM_OCTEON
70 case lwc2_op: /* This is bbit0 on Octeon */
71 case ldc2_op: /* This is bbit032 on Octeon */
72 case swc2_op: /* This is bbit1 on Octeon */
73 case sdc2_op: /* This is bbit132 on Octeon */
74#endif
75 return 1;
76 }
77
78 return 0;
79}
80
81#endif /* __PROBES_COMMON_H */