1 // SPDX-License-Identifier: GPL-2.0
2 /*
3  * Perf annotate functions.
4  *
5  * Copyright (C) 2020-2023 Loongson Technology Corporation Limited
6  */
7 
8 static
9 struct ins_ops *loongarch__associate_ins_ops(struct arch *arch, const char *name)
10 {
11 	struct ins_ops *ops = NULL;
12 
13 	if (!strncmp(name, "beqz", 4) ||
14 	    !strncmp(name, "bnez", 4) ||
15 	    !strncmp(name, "beq", 3) ||
16 	    !strncmp(name, "bne", 3) ||
17 	    !strncmp(name, "blt", 3) ||
18 	    !strncmp(name, "bge", 3) ||
19 	    !strncmp(name, "bltu", 4) ||
20 	    !strncmp(name, "bgeu", 4) ||
21 	    !strncmp(name, "bl", 2))
22 		ops = &call_ops;
23 	else if (!strncmp(name, "jirl", 4))
24 		ops = &ret_ops;
25 	else if (name[0] == 'b')
26 		ops = &jump_ops;
27 	else
28 		return NULL;
29 
30 	arch__associate_ins_ops(arch, name, ops);
31 
32 	return ops;
33 }
34 
35 static
36 int loongarch__annotate_init(struct arch *arch, char *cpuid __maybe_unused)
37 {
38 	if (!arch->initialized) {
39 		arch->associate_instruction_ops = loongarch__associate_ins_ops;
40 		arch->initialized = true;
41 		arch->objdump.comment_char = '#';
42 	}
43 
44 	return 0;
45 }
46