1 static struct ins_ops *powerpc__associate_instruction_ops(struct arch *arch, const char *name)
2 {
3 	int i;
4 	struct ins_ops *ops;
5 
6 	/*
7 	 * - Interested only if instruction starts with 'b'.
8 	 * - Few start with 'b', but aren't branch instructions.
9 	 */
10 	if (name[0] != 'b'             ||
11 	    !strncmp(name, "bcd", 3)   ||
12 	    !strncmp(name, "brinc", 5) ||
13 	    !strncmp(name, "bper", 4))
14 		return NULL;
15 
16 	ops = &jump_ops;
17 
18 	i = strlen(name) - 1;
19 	if (i < 0)
20 		return NULL;
21 
22 	/* ignore optional hints at the end of the instructions */
23 	if (name[i] == '+' || name[i] == '-')
24 		i--;
25 
26 	if (name[i] == 'l' || (name[i] == 'a' && name[i-1] == 'l')) {
27 		/*
28 		 * if the instruction ends up with 'l' or 'la', then
29 		 * those are considered 'calls' since they update LR.
30 		 * ... except for 'bnl' which is branch if not less than
31 		 * and the absolute form of the same.
32 		 */
33 		if (strcmp(name, "bnl") && strcmp(name, "bnl+") &&
34 		    strcmp(name, "bnl-") && strcmp(name, "bnla") &&
35 		    strcmp(name, "bnla+") && strcmp(name, "bnla-"))
36 			ops = &call_ops;
37 	}
38 	if (name[i] == 'r' && name[i-1] == 'l')
39 		/*
40 		 * instructions ending with 'lr' are considered to be
41 		 * return instructions
42 		 */
43 		ops = &ret_ops;
44 
45 	arch__associate_ins_ops(arch, name, ops);
46 	return ops;
47 }
48 
49 static int powerpc__annotate_init(struct arch *arch)
50 {
51 	if (!arch->initialized) {
52 		arch->initialized = true;
53 		arch->associate_instruction_ops = powerpc__associate_instruction_ops;
54 		arch->objdump.comment_char      = '#';
55 	}
56 
57 	return 0;
58 }
59