1 // SPDX-License-Identifier: GPL-2.0
3 static int is_branch_cond(const char *cond
)
8 if (cond
[0] == 'a' && cond
[1] == '\0')
12 (cond
[1] == 'c' || cond
[1] == 's') &&
18 (cond
[1] == 'q' && cond
[2] == '\0')))
23 (cond
[1] == 't' && cond
[2] == '\0') ||
24 (cond
[1] == 'e' && cond
[2] == '\0') ||
25 (cond
[1] == 'e' && cond
[2] == 'u' && cond
[3] == '\0')))
30 (cond
[1] == 't' && cond
[2] == '\0') ||
31 (cond
[1] == 'u' && cond
[2] == '\0') ||
32 (cond
[1] == 'e' && cond
[2] == '\0') ||
33 (cond
[1] == 'e' && cond
[2] == 'u' && cond
[3] == '\0')))
38 (cond
[1] == 'e' && cond
[2] == '\0') ||
39 (cond
[1] == 'z' && cond
[2] == '\0') ||
40 (cond
[1] == 'e' && cond
[2] == 'g' && cond
[3] == '\0')))
51 (cond
[1] == 'c' || cond
[1] == 's') &&
63 static int is_branch_reg_cond(const char *cond
)
65 if ((cond
[0] == 'n' || cond
[0] == 'l') &&
74 if ((cond
[0] == 'g' || cond
[0] == 'l') &&
88 static int is_branch_float_cond(const char *cond
)
93 if ((cond
[0] == 'a' || cond
[0] == 'e' ||
94 cond
[0] == 'z' || cond
[0] == 'g' ||
95 cond
[0] == 'l' || cond
[0] == 'n' ||
96 cond
[0] == 'o' || cond
[0] == 'u') &&
100 if (((cond
[0] == 'g' && cond
[1] == 'e') ||
101 (cond
[0] == 'l' && (cond
[1] == 'e' ||
103 (cond
[0] == 'n' && (cond
[1] == 'e' ||
105 (cond
[0] == 'u' && (cond
[1] == 'e' ||
111 if (cond
[0] == 'u' &&
112 (cond
[1] == 'g' || cond
[1] == 'l') &&
120 static struct ins_ops
*sparc__associate_instruction_ops(struct arch
*arch
, const char *name
)
122 struct ins_ops
*ops
= NULL
;
124 if (!strcmp(name
, "call") ||
125 !strcmp(name
, "jmp") ||
126 !strcmp(name
, "jmpl")) {
128 } else if (!strcmp(name
, "ret") ||
129 !strcmp(name
, "retl") ||
130 !strcmp(name
, "return")) {
132 } else if (!strcmp(name
, "mov")) {
135 if (name
[0] == 'c' &&
136 (name
[1] == 'w' || name
[1] == 'x'))
139 if (name
[0] == 'b') {
140 const char *cond
= name
+ 1;
142 if (cond
[0] == 'r') {
143 if (is_branch_reg_cond(cond
+ 1))
145 } else if (is_branch_cond(cond
)) {
148 } else if (name
[0] == 'f' && name
[1] == 'b') {
149 if (is_branch_float_cond(name
+ 2))
155 arch__associate_ins_ops(arch
, name
, ops
);
160 static int sparc__annotate_init(struct arch
*arch
, char *cpuid __maybe_unused
)
162 if (!arch
->initialized
) {
163 arch
->initialized
= true;
164 arch
->associate_instruction_ops
= sparc__associate_instruction_ops
;
165 arch
->objdump
.comment_char
= '#';