1 // SPDX-License-Identifier: GPL-2.0 2 // Copyright (C) 2019 Hangzhou C-SKY Microsystems co.,ltd. 3 #include <string.h> 4 #include <linux/compiler.h> 5 #include "../disasm.h" 6 7 static const struct ins_ops *csky__associate_ins_ops(struct arch *arch, 8 const char *name) 9 { 10 const struct ins_ops *ops = NULL; 11 12 /* catch all kind of jumps */ 13 if (!strcmp(name, "bt") || 14 !strcmp(name, "bf") || 15 !strcmp(name, "bez") || 16 !strcmp(name, "bnez") || 17 !strcmp(name, "bnezad") || 18 !strcmp(name, "bhsz") || 19 !strcmp(name, "bhz") || 20 !strcmp(name, "blsz") || 21 !strcmp(name, "blz") || 22 !strcmp(name, "br") || 23 !strcmp(name, "jmpi") || 24 !strcmp(name, "jmp")) 25 ops = &jump_ops; 26 27 /* catch function call */ 28 if (!strcmp(name, "bsr") || 29 !strcmp(name, "jsri") || 30 !strcmp(name, "jsr")) 31 ops = &call_ops; 32 33 /* catch function return */ 34 if (!strcmp(name, "rts")) 35 ops = &ret_ops; 36 37 if (ops) 38 arch__associate_ins_ops(arch, name, ops); 39 return ops; 40 } 41 42 int csky__annotate_init(struct arch *arch, char *cpuid __maybe_unused) 43 { 44 arch->initialized = true; 45 arch->objdump.comment_char = '/'; 46 arch->associate_instruction_ops = csky__associate_ins_ops; 47 return 0; 48 } 49