1867d70fcSchristos /* C-SKY assembler/disassembler support. 2*c42dbd0eSchristos Copyright (C) 2004-2022 Free Software Foundation, Inc. 3867d70fcSchristos Contributed by C-SKY Microsystems and Mentor Graphics. 4867d70fcSchristos 5867d70fcSchristos This file is part of GDB and GAS. 6867d70fcSchristos 7867d70fcSchristos GDB and GAS are free software; you can redistribute it and/or 8867d70fcSchristos modify it under the terms of the GNU General Public License as 9867d70fcSchristos published by the Free Software Foundation; either version 3, or (at 10867d70fcSchristos your option) any later version. 11867d70fcSchristos 12867d70fcSchristos GDB and GAS are distributed in the hope that it will be useful, but 13867d70fcSchristos WITHOUT ANY WARRANTY; without even the implied warranty of 14867d70fcSchristos MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15867d70fcSchristos General Public License for more details. 16867d70fcSchristos 17867d70fcSchristos You should have received a copy of the GNU General Public License 18867d70fcSchristos along with GDB or GAS; see the file COPYING3. If not, write to the 19867d70fcSchristos Free Software Foundation, 51 Franklin Street - Fifth Floor, Boston, 20867d70fcSchristos MA 02110-1301, USA. */ 21867d70fcSchristos 22867d70fcSchristos #include "dis-asm.h" 23867d70fcSchristos 24867d70fcSchristos /* The following bitmasks control instruction set architecture. */ 25*c42dbd0eSchristos #define CSKYV1_ISA_E1 ((uint64_t) 1 << 0) 26*c42dbd0eSchristos #define CSKYV2_ISA_E1 ((uint64_t) 1 << 1) 27*c42dbd0eSchristos #define CSKYV2_ISA_1E2 ((uint64_t) 1 << 2) 28*c42dbd0eSchristos #define CSKYV2_ISA_2E3 ((uint64_t) 1 << 3) 29*c42dbd0eSchristos #define CSKYV2_ISA_3E7 ((uint64_t) 1 << 4) 30*c42dbd0eSchristos #define CSKYV2_ISA_7E10 ((uint64_t) 1 << 5) 31*c42dbd0eSchristos #define CSKYV2_ISA_3E3R1 ((uint64_t) 1 << 6) 32*c42dbd0eSchristos #define CSKYV2_ISA_3E3R2 ((uint64_t) 1 << 7) 33*c42dbd0eSchristos #define CSKYV2_ISA_10E60 ((uint64_t) 1 << 8) 34*c42dbd0eSchristos #define CSKYV2_ISA_3E3R3 ((uint64_t) 1 << 9) 35867d70fcSchristos 36*c42dbd0eSchristos #define CSKY_ISA_TRUST ((uint64_t) 1 << 11) 37*c42dbd0eSchristos #define CSKY_ISA_CACHE ((uint64_t) 1 << 12) 38*c42dbd0eSchristos #define CSKY_ISA_NVIC ((uint64_t) 1 << 13) 39*c42dbd0eSchristos #define CSKY_ISA_CP ((uint64_t) 1 << 14) 40*c42dbd0eSchristos #define CSKY_ISA_MP ((uint64_t) 1 << 15) 41*c42dbd0eSchristos #define CSKY_ISA_MP_1E2 ((uint64_t) 1 << 16) 42*c42dbd0eSchristos #define CSKY_ISA_JAVA ((uint64_t) 1 << 17) 43*c42dbd0eSchristos #define CSKY_ISA_MAC ((uint64_t) 1 << 18) 44*c42dbd0eSchristos #define CSKY_ISA_MAC_DSP ((uint64_t) 1 << 19) 45867d70fcSchristos 46867d70fcSchristos /* Base ISA for csky v1 and v2. */ 47*c42dbd0eSchristos #define CSKY_ISA_DSP ((uint64_t) 1 << 20) 48*c42dbd0eSchristos #define CSKY_ISA_DSP_1E2 ((uint64_t) 1 << 21) 49*c42dbd0eSchristos #define CSKY_ISA_DSP_ENHANCE ((uint64_t) 1 << 22) 50*c42dbd0eSchristos #define CSKY_ISA_DSPE60 ((uint64_t) 1 << 23) 51867d70fcSchristos 52867d70fcSchristos /* Base float instruction (803f & 810f). */ 53*c42dbd0eSchristos #define CSKY_ISA_FLOAT_E1 ((uint64_t) 1 << 25) 54867d70fcSchristos /* M_FLOAT support (810f). */ 55*c42dbd0eSchristos #define CSKY_ISA_FLOAT_1E2 ((uint64_t) 1 << 26) 56867d70fcSchristos /* 803 support (803f). */ 57*c42dbd0eSchristos #define CSKY_ISA_FLOAT_1E3 ((uint64_t) 1 << 27) 58867d70fcSchristos /* 807 support (803f & 807f). */ 59*c42dbd0eSchristos #define CSKY_ISA_FLOAT_3E4 ((uint64_t) 1 << 28) 60*c42dbd0eSchristos /* 860 support. */ 61*c42dbd0eSchristos #define CSKY_ISA_FLOAT_7E60 ((uint64_t) 1 << 36) 62867d70fcSchristos /* Vector DSP support. */ 63*c42dbd0eSchristos #define CSKY_ISA_VDSP ((uint64_t) 1 << 29) 64*c42dbd0eSchristos #define CSKY_ISA_VDSP_2 ((uint64_t) 1 << 30) 65867d70fcSchristos 66867d70fcSchristos /* The following bitmasks control cpu architecture for CSKY. */ 67867d70fcSchristos #define CSKY_ABI_V1 (1 << 28) 68867d70fcSchristos #define CSKY_ABI_V2 (2 << 28) 69867d70fcSchristos #define CSKY_ARCH_MASK 0x0000001F 70867d70fcSchristos #define CSKY_ABI_MASK 0xF0000000 71867d70fcSchristos 72867d70fcSchristos #define CSKY_ARCH_510 0x1 73867d70fcSchristos #define CSKY_ARCH_610 0x2 74867d70fcSchristos #define CSKY_ARCH_801 0xa 75867d70fcSchristos #define CSKY_ARCH_802 0x10 76867d70fcSchristos #define CSKY_ARCH_803 0x9 77*c42dbd0eSchristos /* 804 use the same arch flag as 803 yet. */ 78*c42dbd0eSchristos #define CSKY_ARCH_804 0x9 79*c42dbd0eSchristos #define CSKY_ARCH_805 0x11 80867d70fcSchristos #define CSKY_ARCH_807 0x6 81867d70fcSchristos #define CSKY_ARCH_810 0x8 82*c42dbd0eSchristos #define CSKY_ARCH_860 0xb 83*c42dbd0eSchristos /* 800 is a special arch supporting all instructions for ABIV2. */ 84*c42dbd0eSchristos #define CSKY_ARCH_800 0x1f 85867d70fcSchristos 86867d70fcSchristos #define CSKY_ARCH_MAC (1 << 15) 87867d70fcSchristos #define CSKY_ARCH_DSP (1 << 14) 88867d70fcSchristos #define CSKY_ARCH_FLOAT (1 << 13) 89867d70fcSchristos #define CSKY_ARCH_SIMD (1 << 12) 90867d70fcSchristos #define CSKY_ARCH_CP (1 << 11) 91867d70fcSchristos #define CSKY_ARCH_MP (1 << 10) 92867d70fcSchristos #define CSKY_ARCH_CACHE (1 << 9) 93867d70fcSchristos #define CSKY_ARCH_JAVA (1 << 8) 94867d70fcSchristos #define CSKY_ARCH_APS (1 << 7) 95867d70fcSchristos 96*c42dbd0eSchristos /* eflag's Versions. */ 97*c42dbd0eSchristos #define CSKY_VERSION_V1 (1 << 24) 98*c42dbd0eSchristos #define CSKY_VERSION_V2 (2 << 24) 99*c42dbd0eSchristos #define CSKY_VERSION_V3 (3 << 24) 100*c42dbd0eSchristos 101867d70fcSchristos #define IS_CSKY_V1(a) \ 102867d70fcSchristos (((a) & CSKY_ABI_MASK) == CSKY_ABI_V1) 103867d70fcSchristos #define IS_CSKY_V2(a) \ 104867d70fcSchristos (((a) & CSKY_ABI_MASK) == CSKY_ABI_V2) 105867d70fcSchristos #define IS_CSKY_ARCH_V1(a) \ 106867d70fcSchristos (((a) & CSKY_ARCH_MASK) == CSKY_ARCH_510 \ 107867d70fcSchristos || ((a) & CSKY_ARCH_MASK) == CSKY_ARCH_610) 108867d70fcSchristos #define IS_CSKY_ARCH_V2(a) \ 109867d70fcSchristos (!(IS_CSKY_ARCH_V1 (a))) 110867d70fcSchristos 111867d70fcSchristos #define IS_CSKY_ARCH_510(a) (((a) & CSKY_ARCH_MASK) == CSKY_ARCH_510) 112867d70fcSchristos #define IS_CSKY_ARCH_610(a) (((a) & CSKY_ARCH_MASK) == CSKY_ARCH_610) 113867d70fcSchristos #define IS_CSKY_ARCH_801(a) (((a) & CSKY_ARCH_MASK) == CSKY_ARCH_801) 114867d70fcSchristos #define IS_CSKY_ARCH_802(a) (((a) & CSKY_ARCH_MASK) == CSKY_ARCH_802) 115867d70fcSchristos #define IS_CSKY_ARCH_803(a) (((a) & CSKY_ARCH_MASK) == CSKY_ARCH_803) 116867d70fcSchristos #define IS_CSKY_ARCH_807(a) (((a) & CSKY_ARCH_MASK) == CSKY_ARCH_807) 117867d70fcSchristos #define IS_CSKY_ARCH_810(a) (((a) & CSKY_ARCH_MASK) == CSKY_ARCH_810) 118867d70fcSchristos 119867d70fcSchristos #define CPU_ARCH_MASK \ 120867d70fcSchristos (CSKY_ARCH_JAVA | CSKY_ARCH_FLOAT | CSKY_ARCH_DSP | CSKY_ARCH_MASK) 121867d70fcSchristos 122867d70fcSchristos #ifdef __cplusplus 123867d70fcSchristos extern "C" { 124867d70fcSchristos #endif 125867d70fcSchristos extern int print_insn_csky (bfd_vma memaddr, struct disassemble_info *info); 126867d70fcSchristos #ifdef __cplusplus 127867d70fcSchristos } 128867d70fcSchristos #endif 129