instructions.c 1.1 KB

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