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