arc.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. /* Copyright (C) 2017-2022 Free Software Foundation, Inc.
  2. This file is part of GDB.
  3. This program is free software; you can redistribute it and/or modify
  4. it under the terms of the GNU General Public License as published by
  5. the Free Software Foundation; either version 3 of the License, or
  6. (at your option) any later version.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU General Public License for more details.
  11. You should have received a copy of the GNU General Public License
  12. along with this program. If not, see <http://www.gnu.org/licenses/>. */
  13. #ifndef ARCH_ARC_H
  14. #define ARCH_ARC_H
  15. #include "gdbsupport/tdesc.h"
  16. /* Supported ARC ISAs. */
  17. enum arc_isa
  18. {
  19. ARC_ISA_ARCV1 = 1, /* a.k.a. ARCompact (ARC600, ARC700) */
  20. ARC_ISA_ARCV2 /* such as ARC EM and ARC HS */
  21. };
  22. struct arc_arch_features
  23. {
  24. arc_arch_features (int reg_size, arc_isa isa)
  25. : reg_size (reg_size), isa (isa)
  26. {}
  27. /* Register size in bytes. Possible values are 4, and 8. A 0 indicates
  28. an uninitialised value. */
  29. const int reg_size;
  30. /* See ARC_ISA enum. */
  31. const arc_isa isa;
  32. /* Equality operator. */
  33. bool operator== (const struct arc_arch_features &rhs) const
  34. {
  35. return (reg_size == rhs.reg_size && isa == rhs.isa);
  36. }
  37. /* Inequality operator. */
  38. bool operator!= (const struct arc_arch_features &rhs) const
  39. {
  40. return !(*this == rhs);
  41. }
  42. /* Used by std::unordered_map to hash the feature sets. The hash is
  43. calculated in the manner below:
  44. REG_SIZE | ISA
  45. 5-bits | 4-bits */
  46. std::size_t hash () const noexcept
  47. {
  48. std::size_t val = ((reg_size & 0x1f) << 8 | (isa & 0xf) << 0);
  49. return val;
  50. }
  51. };
  52. #ifdef GDBSERVER
  53. /* Create and return a target description that is compatible with FEATURES.
  54. The only external client of this must be the gdbserver which manipulates
  55. the returned data. */
  56. target_desc_up arc_create_target_description
  57. (const struct arc_arch_features &features);
  58. #else
  59. /* Lookup the cache for a target description matching the FEATURES.
  60. If nothing is found, then create one and return it. */
  61. const target_desc *arc_lookup_target_description
  62. (const struct arc_arch_features &features);
  63. #endif /* GDBSERVER */
  64. #endif /* ARCH_ARC_H */