1*6881a400Schristos /* Copyright (C) 2017-2023 Free Software Foundation, Inc. 27d62b00eSchristos 37d62b00eSchristos This file is part of GDB. 47d62b00eSchristos 57d62b00eSchristos This program is free software; you can redistribute it and/or modify 67d62b00eSchristos it under the terms of the GNU General Public License as published by 77d62b00eSchristos the Free Software Foundation; either version 3 of the License, or 87d62b00eSchristos (at your option) any later version. 97d62b00eSchristos 107d62b00eSchristos This program is distributed in the hope that it will be useful, 117d62b00eSchristos but WITHOUT ANY WARRANTY; without even the implied warranty of 127d62b00eSchristos MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 137d62b00eSchristos GNU General Public License for more details. 147d62b00eSchristos 157d62b00eSchristos You should have received a copy of the GNU General Public License 167d62b00eSchristos along with this program. If not, see <http://www.gnu.org/licenses/>. */ 177d62b00eSchristos 187d62b00eSchristos #ifndef ARCH_ARC_H 197d62b00eSchristos #define ARCH_ARC_H 207d62b00eSchristos 217d62b00eSchristos #include "gdbsupport/tdesc.h" 227d62b00eSchristos 237d62b00eSchristos /* Supported ARC ISAs. */ 247d62b00eSchristos enum arc_isa 257d62b00eSchristos { 267d62b00eSchristos ARC_ISA_ARCV1 = 1, /* a.k.a. ARCompact (ARC600, ARC700) */ 277d62b00eSchristos ARC_ISA_ARCV2 /* such as ARC EM and ARC HS */ 287d62b00eSchristos }; 297d62b00eSchristos 30*6881a400Schristos struct arc_arch_features 317d62b00eSchristos { 32*6881a400Schristos arc_arch_features (int reg_size, arc_isa isa) 337d62b00eSchristos : reg_size (reg_size), isa (isa) 347d62b00eSchristos {} 357d62b00eSchristos 367d62b00eSchristos /* Register size in bytes. Possible values are 4, and 8. A 0 indicates 377d62b00eSchristos an uninitialised value. */ 387d62b00eSchristos const int reg_size; 397d62b00eSchristos 407d62b00eSchristos /* See ARC_ISA enum. */ 417d62b00eSchristos const arc_isa isa; 427d62b00eSchristos 437d62b00eSchristos /* Equality operator. */ 44*6881a400Schristos bool operator== (const struct arc_arch_features &rhs) const 457d62b00eSchristos { 467d62b00eSchristos return (reg_size == rhs.reg_size && isa == rhs.isa); 477d62b00eSchristos } 487d62b00eSchristos 497d62b00eSchristos /* Inequality operator. */ 50*6881a400Schristos bool operator!= (const struct arc_arch_features &rhs) const 517d62b00eSchristos { 527d62b00eSchristos return !(*this == rhs); 537d62b00eSchristos } 547d62b00eSchristos 557d62b00eSchristos /* Used by std::unordered_map to hash the feature sets. The hash is 567d62b00eSchristos calculated in the manner below: 577d62b00eSchristos REG_SIZE | ISA 587d62b00eSchristos 5-bits | 4-bits */ 597d62b00eSchristos 607d62b00eSchristos std::size_t hash () const noexcept 617d62b00eSchristos { 627d62b00eSchristos std::size_t val = ((reg_size & 0x1f) << 8 | (isa & 0xf) << 0); 637d62b00eSchristos return val; 647d62b00eSchristos } 657d62b00eSchristos }; 667d62b00eSchristos 677d62b00eSchristos #ifdef GDBSERVER 687d62b00eSchristos 697d62b00eSchristos /* Create and return a target description that is compatible with FEATURES. 707d62b00eSchristos The only external client of this must be the gdbserver which manipulates 717d62b00eSchristos the returned data. */ 727d62b00eSchristos 73*6881a400Schristos target_desc_up arc_create_target_description 74*6881a400Schristos (const struct arc_arch_features &features); 757d62b00eSchristos 767d62b00eSchristos #else 777d62b00eSchristos 787d62b00eSchristos /* Lookup the cache for a target description matching the FEATURES. 797d62b00eSchristos If nothing is found, then create one and return it. */ 807d62b00eSchristos 817d62b00eSchristos const target_desc *arc_lookup_target_description 82*6881a400Schristos (const struct arc_arch_features &features); 837d62b00eSchristos 847d62b00eSchristos #endif /* GDBSERVER */ 857d62b00eSchristos 867d62b00eSchristos 877d62b00eSchristos #endif /* ARCH_ARC_H */ 88