cpu-riscv.h 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. /* RISC-V spec version controlling support.
  2. Copyright (C) 2019-2022 Free Software Foundation, Inc.
  3. This file is part of BFD, the Binary File Descriptor library.
  4. This program is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation; either version 3 of the License, or
  7. (at your option) any later version.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with this program; if not, write to the Free Software
  14. Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
  15. MA 02110-1301, USA. */
  16. enum riscv_spec_class
  17. {
  18. /* ISA spec. */
  19. ISA_SPEC_CLASS_NONE = 0,
  20. ISA_SPEC_CLASS_2P2,
  21. ISA_SPEC_CLASS_20190608,
  22. ISA_SPEC_CLASS_20191213,
  23. ISA_SPEC_CLASS_DRAFT,
  24. /* Privileged spec. */
  25. PRIV_SPEC_CLASS_NONE,
  26. PRIV_SPEC_CLASS_1P9P1,
  27. PRIV_SPEC_CLASS_1P10,
  28. PRIV_SPEC_CLASS_1P11,
  29. PRIV_SPEC_CLASS_1P12,
  30. PRIV_SPEC_CLASS_DRAFT,
  31. };
  32. struct riscv_spec
  33. {
  34. const char *name;
  35. enum riscv_spec_class spec_class;
  36. };
  37. extern const struct riscv_spec riscv_isa_specs[];
  38. extern const struct riscv_spec riscv_priv_specs[];
  39. #define RISCV_GET_SPEC_CLASS(UTYPE, LTYPE, NAME, CLASS) \
  40. do \
  41. { \
  42. if (NAME == NULL) \
  43. break; \
  44. \
  45. int i_spec = UTYPE##_SPEC_CLASS_NONE + 1; \
  46. for (; i_spec < UTYPE##_SPEC_CLASS_DRAFT; i_spec++) \
  47. { \
  48. int j_spec = i_spec - UTYPE##_SPEC_CLASS_NONE -1; \
  49. if (riscv_##LTYPE##_specs[j_spec].name \
  50. && strcmp (riscv_##LTYPE##_specs[j_spec].name, NAME) == 0)\
  51. { \
  52. CLASS = riscv_##LTYPE##_specs[j_spec].spec_class; \
  53. break; \
  54. } \
  55. } \
  56. } \
  57. while (0)
  58. #define RISCV_GET_SPEC_NAME(UTYPE, LTYPE, NAME, CLASS) \
  59. (NAME) = riscv_##LTYPE##_specs[(CLASS) - UTYPE##_SPEC_CLASS_NONE - 1].name
  60. #define RISCV_GET_ISA_SPEC_CLASS(NAME, CLASS) \
  61. RISCV_GET_SPEC_CLASS(ISA, isa, NAME, CLASS)
  62. #define RISCV_GET_PRIV_SPEC_CLASS(NAME, CLASS) \
  63. RISCV_GET_SPEC_CLASS(PRIV, priv, NAME, CLASS)
  64. #define RISCV_GET_PRIV_SPEC_NAME(NAME, CLASS) \
  65. RISCV_GET_SPEC_NAME(PRIV, priv, NAME, CLASS)
  66. extern void
  67. riscv_get_priv_spec_class_from_numbers (unsigned int,
  68. unsigned int,
  69. unsigned int,
  70. enum riscv_spec_class *);
  71. extern bool
  72. riscv_elf_is_mapping_symbols (const char *);