| 1 | //===-- RISCVInstPrinter.cpp - Convert RISCV MCInst to asm syntax ---------===//cxx . . $ `<file>/arch/RISCV/RISCVInstPrinter.c`/ |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | // |
| 10 | // This class prints an RISCV MCInst to a .s file. |
| 11 | // |
| 12 | //===----------------------------------------------------------------------===// |
| 13 | |
| 14 | #ifdef CAPSTONE_HAS_RISCVcxx . . $ `<built-in>:425:9`! |
| 15 | |
| 16 | #include <stdio.h> // DEBUG |
| 17 | #include <stdlib.h> |
| 18 | #include <string.h> |
| 19 | #include <capstone/platform.h>cxx . . $ `<file>/include/capstone/platform.h`/ |
| 20 | |
| 21 | #include "RISCVInstPrinter.h"cxx . . $ `<file>/arch/RISCV/RISCVInstPrinter.h`/ |
| 22 | #include "RISCVBaseInfo.h"cxx . . $ `<file>/arch/RISCV/RISCVBaseInfo.h`/ |
| 23 | #include "../../MCInst.h"cxx . . $ `<file>/MCInst.h`/ |
| 24 | #include "../../SStream.h"cxx . . $ `<file>/SStream.h`/ |
| 25 | #include "../../MCRegisterInfo.h"cxx . . $ `<file>/MCRegisterInfo.h`/ |
| 26 | #include "../../utils.h"cxx . . $ `<file>/utils.h`/ |
| 27 | #include "RISCVMapping.h"cxx . . $ `<file>/arch/RISCV/RISCVMapping.h`/ |
| 28 | |
| 29 | //#include "RISCVDisassembler.h" |
| 30 | |
| 31 | #define GET_REGINFO_ENUMcxx . . $ `arch/RISCV/RISCVInstPrinter.c:31:9`! |
| 32 | #define GET_REGINFO_MC_DESCcxx . . $ `arch/RISCV/RISCVInstPrinter.c:32:9`! |
| 33 | #include "RISCVGenRegisterInfo.inc"cxx . . $ `<file>/arch/RISCV/RISCVGenRegisterInfo.inc`/ |
| 34 | #define GET_INSTRINFO_ENUMcxx . . $ `arch/RISCV/RISCVInstPrinter.c:34:9`! |
| 35 | #include "RISCVGenInstrInfo.inc"cxx . . $ `<file>/arch/RISCV/RISCVGenInstrInfo.inc`/ |
| 36 | |
| 37 | // Autogenerated by tblgen. |
| 38 | static void printInstructioncxx . . $ printInstruction(d9e99caf10670d9f).(MCInstcxx . . $ MCInst# *MI, SStreamcxx . . $ SStream# *O, MCRegisterInfocxx . . $ MCRegisterInfo# *MRI); |
| 39 | static boolcxx . . $ `<external>/13015445228558014418/stdbool.h:36:9`! printAliasInstrcxx . . $ printAliasInstr(8a73546db2bc21ce).(MCInstcxx . . $ MCInst# *MI, SStreamcxx . . $ SStream# *OS, void *info); |
| 40 | static void printOperandcxx . . $ printOperand(2c3fef4aec20445).(MCInstcxx . . $ MCInst# *MI, unsigned OpNo, SStreamcxx . . $ SStream# *O); |
| 41 | static void printFenceArgcxx . . $ printFenceArg(2c3fef4aec20445).(MCInstcxx . . $ MCInst# *MI, unsigned OpNo, SStreamcxx . . $ SStream# *O); |
| 42 | static void printCSRSystemRegistercxx . . $ printCSRSystemRegister(2c3fef4aec20445).(MCInstcxx . . $ MCInst#*, unsigned, SStreamcxx . . $ SStream# *); |
| 43 | static void printFRMArgcxx . . $ printFRMArg(2c3fef4aec20445).(MCInstcxx . . $ MCInst# *MI, unsigned OpNo, SStreamcxx . . $ SStream# *O); |
| 44 | static void printCustomAliasOperandcxx . . $ printCustomAliasOperand(cd93bebea1f4dc2e).( MCInstcxx . . $ MCInst# *, unsigned, unsigned, SStreamcxx . . $ SStream# *); |
| 45 | /// getRegisterName - This method is automatically generated by tblgen |
| 46 | /// from the register set description. This returns the assembler name |
| 47 | /// for the specified register. |
| 48 | static const char *getRegisterNamecxx . . $ getRegisterName(f1aafdd40709cfa1).(unsigned RegNo, unsigned AltIdx); |
| 49 | |
| 50 | // Include the auto-generated portion of the assembly writer. |
| 51 | #define PRINT_ALIAS_INSTRcxx . . $ `arch/RISCV/RISCVInstPrinter.c:51:9`! |
| 52 | #include "RISCVGenAsmWriter.inc"cxx . . $ `<file>/arch/RISCV/RISCVGenAsmWriter.inc`/ |
| 53 | |
| 54 | |
| 55 | static void fixDetailOfEffectiveAddrcxx . . $ fixDetailOfEffectiveAddr(94c8a3269074abe9).(MCInstcxx . . $ MCInst# *MI) |
| 56 | { |
| 57 | unsigned reg = 0; |
| 58 | int64_tcxx . . $ int64_t# imm = 0; |
| 59 | |
| 60 | CS_ASSERTcxx . . $ `cs_priv.h:103:9`!(3 == MI->flat_insn->detail->riscv.op_count); |
| 61 | CS_ASSERTcxx . . $ `cs_priv.h:103:9`!(RISCV_OP_REG == MI->flat_insn->detail->riscv.operands[0].type); |
| 62 | |
| 63 | if (RISCV_OP_IMMcxx . . $ RISCV_OP_IMM. == MI->flat_insncxx . . $ MCInst#flat_insn.->detailcxx . . $ cs_insn#detail.->riscvcxx . . $ cs_detail#$anonymous_type_0#riscv..operandscxx . . $ cs_riscv#operands.[1].typecxx . . $ cs_riscv_op#type.) { |
| 64 | CS_ASSERTcxx . . $ `cs_priv.h:103:9`!(RISCV_OP_REG == MI->flat_insn->detail->riscv.operands[2].type); |
| 65 | imm = MI->flat_insncxx . . $ MCInst#flat_insn.->detailcxx . . $ cs_insn#detail.->riscvcxx . . $ cs_detail#$anonymous_type_0#riscv..operandscxx . . $ cs_riscv#operands.[1].immcxx . . $ cs_riscv_op#$anonymous_type_0#imm.; |
| 66 | reg = MI->flat_insncxx . . $ MCInst#flat_insn.->detailcxx . . $ cs_insn#detail.->riscvcxx . . $ cs_detail#$anonymous_type_0#riscv..operandscxx . . $ cs_riscv#operands.[2].regcxx . . $ cs_riscv_op#$anonymous_type_0#reg.; |
| 67 | } else if (RISCV_OP_REGcxx . . $ RISCV_OP_REG. == MI->flat_insncxx . . $ MCInst#flat_insn.->detailcxx . . $ cs_insn#detail.->riscvcxx . . $ cs_detail#$anonymous_type_0#riscv..operandscxx . . $ cs_riscv#operands.[1].typecxx . . $ cs_riscv_op#type.) { |
| 68 | CS_ASSERTcxx . . $ `cs_priv.h:103:9`!(RISCV_OP_IMM == MI->flat_insn->detail->riscv.operands[2].type); |
| 69 | reg = MI->flat_insncxx . . $ MCInst#flat_insn.->detailcxx . . $ cs_insn#detail.->riscvcxx . . $ cs_detail#$anonymous_type_0#riscv..operandscxx . . $ cs_riscv#operands.[1].regcxx . . $ cs_riscv_op#$anonymous_type_0#reg.; |
| 70 | imm = MI->flat_insncxx . . $ MCInst#flat_insn.->detailcxx . . $ cs_insn#detail.->riscvcxx . . $ cs_detail#$anonymous_type_0#riscv..operandscxx . . $ cs_riscv#operands.[2].immcxx . . $ cs_riscv_op#$anonymous_type_0#imm.; |
| 71 | } |
| 72 | |
| 73 | // set up effective address. |
| 74 | MI->flat_insncxx . . $ MCInst#flat_insn.->detailcxx . . $ cs_insn#detail.->riscvcxx . . $ cs_detail#$anonymous_type_0#riscv..operandscxx . . $ cs_riscv#operands.[1].typecxx . . $ cs_riscv_op#type. = RISCV_OP_MEMcxx . . $ RISCV_OP_MEM.; |
| 75 | MI->flat_insncxx . . $ MCInst#flat_insn.->detailcxx . . $ cs_insn#detail.->riscvcxx . . $ cs_detail#$anonymous_type_0#riscv..op_countcxx . . $ cs_riscv#op_count.--; |
| 76 | MI->flat_insncxx . . $ MCInst#flat_insn.->detailcxx . . $ cs_insn#detail.->riscvcxx . . $ cs_detail#$anonymous_type_0#riscv..operandscxx . . $ cs_riscv#operands.[1].memcxx . . $ cs_riscv_op#$anonymous_type_0#mem..basecxx . . $ riscv_op_mem#base. = reg; |
| 77 | MI->flat_insncxx . . $ MCInst#flat_insn.->detailcxx . . $ cs_insn#detail.->riscvcxx . . $ cs_detail#$anonymous_type_0#riscv..operandscxx . . $ cs_riscv#operands.[1].memcxx . . $ cs_riscv_op#$anonymous_type_0#mem..dispcxx . . $ riscv_op_mem#disp. = imm; |
| 78 | |
| 79 | return; |
| 80 | } |
| 81 | |
| 82 | |
| 83 | //void RISCVInstPrinter::printInst(const MCInst *MI, raw_ostream &O, |
| 84 | // StringRef Annot, const MCSubtargetInfo &STI) |
| 85 | void RISCV_printInstcxx . . $ RISCV_printInst(6238f66e5ea10f57).(MCInstcxx . . $ MCInst# *MI, SStreamcxx . . $ SStream# *O, void *info) |
| 86 | { |
| 87 | MCRegisterInfocxx . . $ MCRegisterInfo# *MRI = (MCRegisterInfocxx . . $ MCRegisterInfo# *) info; |
| 88 | //bool Res = false; |
| 89 | //MCInst *NewMI = MI; |
| 90 | // TODO: RISCV compressd instructions. |
| 91 | //MCInst UncompressedMI; |
| 92 | //if (!NoAliases) |
| 93 | //Res = uncompressInst(UncompressedMI, *MI, MRI, STI); |
| 94 | //if (Res) |
| 95 | //NewMI = const_cast<MCInst *>(&UncompressedMI); |
| 96 | if (/*NoAliases ||*/ !printAliasInstrcxx . . $ printAliasInstr(8a73546db2bc21ce).(MI, O, info)) |
| 97 | printInstructioncxx . . $ printInstruction(d9e99caf10670d9f).(MI, O, MRI); |
| 98 | //printAnnotation(O, Annot); |
| 99 | // fix load/store type insttuction |
| 100 | if (MI->cshcxx . . $ MCInst#csh.->detailcxx . . $ cs_struct#detail. && |
| 101 | MI->flat_insncxx . . $ MCInst#flat_insn.->detailcxx . . $ cs_insn#detail.->riscvcxx . . $ cs_detail#$anonymous_type_0#riscv..need_effective_addrcxx . . $ cs_riscv#need_effective_addr.) |
| 102 | fixDetailOfEffectiveAddrcxx . . $ fixDetailOfEffectiveAddr(94c8a3269074abe9).(MI); |
| 103 | |
| 104 | return; |
| 105 | } |
| 106 | |
| 107 | static void printRegNamecxx . . $ printRegName(2cfdcacebbcb5657).(SStreamcxx . . $ SStream# *OS, unsigned RegNo) |
| 108 | { |
| 109 | SStream_concat0cxx . . $ SStream_concat0(a720692b9b1c0c27).(OS, getRegisterNamecxx . . $ getRegisterName(f1aafdd40709cfa1).(RegNo, RISCV_ABIRegAltNamecxx . . $ RISCV_ABIRegAltName.)); |
| 110 | } |
| 111 | |
| 112 | /** |
| 113 | void RISCVInstPrinter::printOperand(const MCInst *MI, unsigned OpNo, |
| 114 | raw_ostream &O, const char *Modifier) |
| 115 | */ |
| 116 | static void printOperandcxx . . $ printOperand(2c3fef4aec20445).(MCInstcxx . . $ MCInst# *MI, unsigned OpNo, SStreamcxx . . $ SStream# *O) |
| 117 | { |
| 118 | unsigned reg; |
| 119 | int64_tcxx . . $ int64_t# Imm = 0; |
| 120 | |
| 121 | MCOperandcxx . . $ MCOperand# *MO = MCInst_getOperandcxx . . $ MCInst_getOperand(4687f87e75986a5b).(MI, OpNo); |
| 122 | |
| 123 | if (MCOperand_isRegcxx . . $ MCOperand_isReg(8be14e8515538be0).(MO)) { |
| 124 | reg = MCOperand_getRegcxx . . $ MCOperand_getReg(2f0d38ead81b409a).(MO); |
| 125 | printRegNamecxx . . $ printRegName(2cfdcacebbcb5657).(O, reg); |
| 126 | if (MI->cshcxx . . $ MCInst#csh.->detailcxx . . $ cs_struct#detail.) { |
| 127 | MI->flat_insncxx . . $ MCInst#flat_insn.->detailcxx . . $ cs_insn#detail.->riscvcxx . . $ cs_detail#$anonymous_type_0#riscv..operandscxx . . $ cs_riscv#operands.[MI->flat_insncxx . . $ MCInst#flat_insn.->detailcxx . . $ cs_insn#detail.->riscvcxx . . $ cs_detail#$anonymous_type_0#riscv..op_countcxx . . $ cs_riscv#op_count.].typecxx . . $ cs_riscv_op#type. = RISCV_OP_REGcxx . . $ RISCV_OP_REG.; |
| 128 | MI->flat_insncxx . . $ MCInst#flat_insn.->detailcxx . . $ cs_insn#detail.->riscvcxx . . $ cs_detail#$anonymous_type_0#riscv..operandscxx . . $ cs_riscv#operands.[MI->flat_insncxx . . $ MCInst#flat_insn.->detailcxx . . $ cs_insn#detail.->riscvcxx . . $ cs_detail#$anonymous_type_0#riscv..op_countcxx . . $ cs_riscv#op_count.].regcxx . . $ cs_riscv_op#$anonymous_type_0#reg. = reg; |
| 129 | MI->flat_insncxx . . $ MCInst#flat_insn.->detailcxx . . $ cs_insn#detail.->riscvcxx . . $ cs_detail#$anonymous_type_0#riscv..op_countcxx . . $ cs_riscv#op_count.++; |
| 130 | } |
| 131 | } else { |
| 132 | CS_ASSERTcxx . . $ `cs_priv.h:103:9`!(MCOperand_isImm(MO) && "Unknown operand kind in printOperand"); |
| 133 | Imm = MCOperand_getImmcxx . . $ MCOperand_getImm(e2e9552a97d88948).(MO); |
| 134 | if (Imm >= 0) { |
| 135 | if (Imm > HEX_THRESHOLDcxx . . $ `utils.h:17:9`!) |
| 136 | SStream_concatcxx . . $ SStream_concat(72515e07697b04b4).(O, "0x%" PRIx64cxx . . $ `<external>/15933738808807975373/inttypes.h:126:10`!, Imm); |
| 137 | else |
| 138 | SStream_concatcxx . . $ SStream_concat(72515e07697b04b4).(O, "%" PRIu64cxx . . $ `<external>/15933738808807975373/inttypes.h:110:10`!, Imm); |
| 139 | } else { |
| 140 | if (Imm < -HEX_THRESHOLDcxx . . $ `utils.h:17:9`!) |
| 141 | SStream_concatcxx . . $ SStream_concat(72515e07697b04b4).(O, "-0x%" PRIx64cxx . . $ `<external>/15933738808807975373/inttypes.h:126:10`!, -Imm); |
| 142 | else |
| 143 | SStream_concatcxx . . $ SStream_concat(72515e07697b04b4).(O, "-%" PRIu64cxx . . $ `<external>/15933738808807975373/inttypes.h:110:10`!, -Imm); |
| 144 | } |
| 145 | |
| 146 | if (MI->cshcxx . . $ MCInst#csh.->detailcxx . . $ cs_struct#detail.) { |
| 147 | MI->flat_insncxx . . $ MCInst#flat_insn.->detailcxx . . $ cs_insn#detail.->riscvcxx . . $ cs_detail#$anonymous_type_0#riscv..operandscxx . . $ cs_riscv#operands.[MI->flat_insncxx . . $ MCInst#flat_insn.->detailcxx . . $ cs_insn#detail.->riscvcxx . . $ cs_detail#$anonymous_type_0#riscv..op_countcxx . . $ cs_riscv#op_count.].typecxx . . $ cs_riscv_op#type. = RISCV_OP_IMMcxx . . $ RISCV_OP_IMM.; |
| 148 | MI->flat_insncxx . . $ MCInst#flat_insn.->detailcxx . . $ cs_insn#detail.->riscvcxx . . $ cs_detail#$anonymous_type_0#riscv..operandscxx . . $ cs_riscv#operands.[MI->flat_insncxx . . $ MCInst#flat_insn.->detailcxx . . $ cs_insn#detail.->riscvcxx . . $ cs_detail#$anonymous_type_0#riscv..op_countcxx . . $ cs_riscv#op_count.].immcxx . . $ cs_riscv_op#$anonymous_type_0#imm. = Imm; |
| 149 | MI->flat_insncxx . . $ MCInst#flat_insn.->detailcxx . . $ cs_insn#detail.->riscvcxx . . $ cs_detail#$anonymous_type_0#riscv..op_countcxx . . $ cs_riscv#op_count.++; |
| 150 | } |
| 151 | } |
| 152 | |
| 153 | //CS_ASSERT(MO.isExpr() && "Unknown operand kind in printOperand"); |
| 154 | |
| 155 | return; |
| 156 | } |
| 157 | |
| 158 | static const char *getCSRSystemRegisterNamecxx . . $ getCSRSystemRegisterName(81a3ae90da26a711).(unsigned CsrNo) |
| 159 | { |
| 160 | switch (CsrNo) { |
| 161 | /* |
| 162 | * From RISC-V Privileged Architecture Version 1.10. |
| 163 | * In the same order as Table 2.5. |
| 164 | */ |
| 165 | case 0x0000: return "ustatus"; |
| 166 | case 0x0004: return "uie"; |
| 167 | case 0x0005: return "utvec"; |
| 168 | |
| 169 | case 0x0040: return "uscratch"; |
| 170 | case 0x0041: return "uepc"; |
| 171 | case 0x0042: return "ucause"; |
| 172 | case 0x0043: return "utval"; |
| 173 | case 0x0044: return "uip"; |
| 174 | |
| 175 | case 0x0001: return "fflags"; |
| 176 | case 0x0002: return "frm"; |
| 177 | case 0x0003: return "fcsr"; |
| 178 | |
| 179 | case 0x0c00: return "cycle"; |
| 180 | case 0x0c01: return "time"; |
| 181 | case 0x0c02: return "instret"; |
| 182 | case 0x0c03: return "hpmcounter3"; |
| 183 | case 0x0c04: return "hpmcounter4"; |
| 184 | case 0x0c05: return "hpmcounter5"; |
| 185 | case 0x0c06: return "hpmcounter6"; |
| 186 | case 0x0c07: return "hpmcounter7"; |
| 187 | case 0x0c08: return "hpmcounter8"; |
| 188 | case 0x0c09: return "hpmcounter9"; |
| 189 | case 0x0c0a: return "hpmcounter10"; |
| 190 | case 0x0c0b: return "hpmcounter11"; |
| 191 | case 0x0c0c: return "hpmcounter12"; |
| 192 | case 0x0c0d: return "hpmcounter13"; |
| 193 | case 0x0c0e: return "hpmcounter14"; |
| 194 | case 0x0c0f: return "hpmcounter15"; |
| 195 | case 0x0c10: return "hpmcounter16"; |
| 196 | case 0x0c11: return "hpmcounter17"; |
| 197 | case 0x0c12: return "hpmcounter18"; |
| 198 | case 0x0c13: return "hpmcounter19"; |
| 199 | case 0x0c14: return "hpmcounter20"; |
| 200 | case 0x0c15: return "hpmcounter21"; |
| 201 | case 0x0c16: return "hpmcounter22"; |
| 202 | case 0x0c17: return "hpmcounter23"; |
| 203 | case 0x0c18: return "hpmcounter24"; |
| 204 | case 0x0c19: return "hpmcounter25"; |
| 205 | case 0x0c1a: return "hpmcounter26"; |
| 206 | case 0x0c1b: return "hpmcounter27"; |
| 207 | case 0x0c1c: return "hpmcounter28"; |
| 208 | case 0x0c1d: return "hpmcounter29"; |
| 209 | case 0x0c1e: return "hpmcounter30"; |
| 210 | case 0x0c1f: return "hpmcounter31"; |
| 211 | case 0x0c80: return "cycleh"; |
| 212 | case 0x0c81: return "timeh"; |
| 213 | case 0x0c82: return "instreth"; |
| 214 | case 0x0c83: return "hpmcounter3h"; |
| 215 | case 0x0c84: return "hpmcounter4h"; |
| 216 | case 0x0c85: return "hpmcounter5h"; |
| 217 | case 0x0c86: return "hpmcounter6h"; |
| 218 | case 0x0c87: return "hpmcounter7h"; |
| 219 | case 0x0c88: return "hpmcounter8h"; |
| 220 | case 0x0c89: return "hpmcounter9h"; |
| 221 | case 0x0c8a: return "hpmcounter10h"; |
| 222 | case 0x0c8b: return "hpmcounter11h"; |
| 223 | case 0x0c8c: return "hpmcounter12h"; |
| 224 | case 0x0c8d: return "hpmcounter13h"; |
| 225 | case 0x0c8e: return "hpmcounter14h"; |
| 226 | case 0x0c8f: return "hpmcounter15h"; |
| 227 | case 0x0c90: return "hpmcounter16h"; |
| 228 | case 0x0c91: return "hpmcounter17h"; |
| 229 | case 0x0c92: return "hpmcounter18h"; |
| 230 | case 0x0c93: return "hpmcounter19h"; |
| 231 | case 0x0c94: return "hpmcounter20h"; |
| 232 | case 0x0c95: return "hpmcounter21h"; |
| 233 | case 0x0c96: return "hpmcounter22h"; |
| 234 | case 0x0c97: return "hpmcounter23h"; |
| 235 | case 0x0c98: return "hpmcounter24h"; |
| 236 | case 0x0c99: return "hpmcounter25h"; |
| 237 | case 0x0c9a: return "hpmcounter26h"; |
| 238 | case 0x0c9b: return "hpmcounter27h"; |
| 239 | case 0x0c9c: return "hpmcounter28h"; |
| 240 | case 0x0c9d: return "hpmcounter29h"; |
| 241 | case 0x0c9e: return "hpmcounter30h"; |
| 242 | case 0x0c9f: return "hpmcounter31h"; |
| 243 | |
| 244 | case 0x0100: return "sstatus"; |
| 245 | case 0x0102: return "sedeleg"; |
| 246 | case 0x0103: return "sideleg"; |
| 247 | case 0x0104: return "sie"; |
| 248 | case 0x0105: return "stvec"; |
| 249 | case 0x0106: return "scounteren"; |
| 250 | |
| 251 | case 0x0140: return "sscratch"; |
| 252 | case 0x0141: return "sepc"; |
| 253 | case 0x0142: return "scause"; |
| 254 | case 0x0143: return "stval"; |
| 255 | case 0x0144: return "sip"; |
| 256 | |
| 257 | case 0x0180: return "satp"; |
| 258 | |
| 259 | case 0x0f11: return "mvendorid"; |
| 260 | case 0x0f12: return "marchid"; |
| 261 | case 0x0f13: return "mimpid"; |
| 262 | case 0x0f14: return "mhartid"; |
| 263 | |
| 264 | case 0x0300: return "mstatus"; |
| 265 | case 0x0301: return "misa"; |
| 266 | case 0x0302: return "medeleg"; |
| 267 | case 0x0303: return "mideleg"; |
| 268 | case 0x0304: return "mie"; |
| 269 | case 0x0305: return "mtvec"; |
| 270 | case 0x0306: return "mcounteren"; |
| 271 | |
| 272 | case 0x0340: return "mscratch"; |
| 273 | case 0x0341: return "mepc"; |
| 274 | case 0x0342: return "mcause"; |
| 275 | case 0x0343: return "mtval"; |
| 276 | case 0x0344: return "mip"; |
| 277 | |
| 278 | case 0x03a0: return "pmpcfg0"; |
| 279 | case 0x03a1: return "pmpcfg1"; |
| 280 | case 0x03a2: return "pmpcfg2"; |
| 281 | case 0x03a3: return "pmpcfg3"; |
| 282 | case 0x03b0: return "pmpaddr0"; |
| 283 | case 0x03b1: return "pmpaddr1"; |
| 284 | case 0x03b2: return "pmpaddr2"; |
| 285 | case 0x03b3: return "pmpaddr3"; |
| 286 | case 0x03b4: return "pmpaddr4"; |
| 287 | case 0x03b5: return "pmpaddr5"; |
| 288 | case 0x03b6: return "pmpaddr6"; |
| 289 | case 0x03b7: return "pmpaddr7"; |
| 290 | case 0x03b8: return "pmpaddr8"; |
| 291 | case 0x03b9: return "pmpaddr9"; |
| 292 | case 0x03ba: return "pmpaddr10"; |
| 293 | case 0x03bb: return "pmpaddr11"; |
| 294 | case 0x03bc: return "pmpaddr12"; |
| 295 | case 0x03bd: return "pmpaddr14"; |
| 296 | case 0x03be: return "pmpaddr13"; |
| 297 | case 0x03bf: return "pmpaddr15"; |
| 298 | |
| 299 | case 0x0b00: return "mcycle"; |
| 300 | case 0x0b02: return "minstret"; |
| 301 | case 0x0b03: return "mhpmcounter3"; |
| 302 | case 0x0b04: return "mhpmcounter4"; |
| 303 | case 0x0b05: return "mhpmcounter5"; |
| 304 | case 0x0b06: return "mhpmcounter6"; |
| 305 | case 0x0b07: return "mhpmcounter7"; |
| 306 | case 0x0b08: return "mhpmcounter8"; |
| 307 | case 0x0b09: return "mhpmcounter9"; |
| 308 | case 0x0b0a: return "mhpmcounter10"; |
| 309 | case 0x0b0b: return "mhpmcounter11"; |
| 310 | case 0x0b0c: return "mhpmcounter12"; |
| 311 | case 0x0b0d: return "mhpmcounter13"; |
| 312 | case 0x0b0e: return "mhpmcounter14"; |
| 313 | case 0x0b0f: return "mhpmcounter15"; |
| 314 | case 0x0b10: return "mhpmcounter16"; |
| 315 | case 0x0b11: return "mhpmcounter17"; |
| 316 | case 0x0b12: return "mhpmcounter18"; |
| 317 | case 0x0b13: return "mhpmcounter19"; |
| 318 | case 0x0b14: return "mhpmcounter20"; |
| 319 | case 0x0b15: return "mhpmcounter21"; |
| 320 | case 0x0b16: return "mhpmcounter22"; |
| 321 | case 0x0b17: return "mhpmcounter23"; |
| 322 | case 0x0b18: return "mhpmcounter24"; |
| 323 | case 0x0b19: return "mhpmcounter25"; |
| 324 | case 0x0b1a: return "mhpmcounter26"; |
| 325 | case 0x0b1b: return "mhpmcounter27"; |
| 326 | case 0x0b1c: return "mhpmcounter28"; |
| 327 | case 0x0b1d: return "mhpmcounter29"; |
| 328 | case 0x0b1e: return "mhpmcounter30"; |
| 329 | case 0x0b1f: return "mhpmcounter31"; |
| 330 | case 0x0b80: return "mcycleh"; |
| 331 | case 0x0b82: return "minstreth"; |
| 332 | case 0x0b83: return "mhpmcounter3h"; |
| 333 | case 0x0b84: return "mhpmcounter4h"; |
| 334 | case 0x0b85: return "mhpmcounter5h"; |
| 335 | case 0x0b86: return "mhpmcounter6h"; |
| 336 | case 0x0b87: return "mhpmcounter7h"; |
| 337 | case 0x0b88: return "mhpmcounter8h"; |
| 338 | case 0x0b89: return "mhpmcounter9h"; |
| 339 | case 0x0b8a: return "mhpmcounter10h"; |
| 340 | case 0x0b8b: return "mhpmcounter11h"; |
| 341 | case 0x0b8c: return "mhpmcounter12h"; |
| 342 | case 0x0b8d: return "mhpmcounter13h"; |
| 343 | case 0x0b8e: return "mhpmcounter14h"; |
| 344 | case 0x0b8f: return "mhpmcounter15h"; |
| 345 | case 0x0b90: return "mhpmcounter16h"; |
| 346 | case 0x0b91: return "mhpmcounter17h"; |
| 347 | case 0x0b92: return "mhpmcounter18h"; |
| 348 | case 0x0b93: return "mhpmcounter19h"; |
| 349 | case 0x0b94: return "mhpmcounter20h"; |
| 350 | case 0x0b95: return "mhpmcounter21h"; |
| 351 | case 0x0b96: return "mhpmcounter22h"; |
| 352 | case 0x0b97: return "mhpmcounter23h"; |
| 353 | case 0x0b98: return "mhpmcounter24h"; |
| 354 | case 0x0b99: return "mhpmcounter25h"; |
| 355 | case 0x0b9a: return "mhpmcounter26h"; |
| 356 | case 0x0b9b: return "mhpmcounter27h"; |
| 357 | case 0x0b9c: return "mhpmcounter28h"; |
| 358 | case 0x0b9d: return "mhpmcounter29h"; |
| 359 | case 0x0b9e: return "mhpmcounter30h"; |
| 360 | case 0x0b9f: return "mhpmcounter31h"; |
| 361 | |
| 362 | case 0x0323: return "mhpmevent3"; |
| 363 | case 0x0324: return "mhpmevent4"; |
| 364 | case 0x0325: return "mhpmevent5"; |
| 365 | case 0x0326: return "mhpmevent6"; |
| 366 | case 0x0327: return "mhpmevent7"; |
| 367 | case 0x0328: return "mhpmevent8"; |
| 368 | case 0x0329: return "mhpmevent9"; |
| 369 | case 0x032a: return "mhpmevent10"; |
| 370 | case 0x032b: return "mhpmevent11"; |
| 371 | case 0x032c: return "mhpmevent12"; |
| 372 | case 0x032d: return "mhpmevent13"; |
| 373 | case 0x032e: return "mhpmevent14"; |
| 374 | case 0x032f: return "mhpmevent15"; |
| 375 | case 0x0330: return "mhpmevent16"; |
| 376 | case 0x0331: return "mhpmevent17"; |
| 377 | case 0x0332: return "mhpmevent18"; |
| 378 | case 0x0333: return "mhpmevent19"; |
| 379 | case 0x0334: return "mhpmevent20"; |
| 380 | case 0x0335: return "mhpmevent21"; |
| 381 | case 0x0336: return "mhpmevent22"; |
| 382 | case 0x0337: return "mhpmevent23"; |
| 383 | case 0x0338: return "mhpmevent24"; |
| 384 | case 0x0339: return "mhpmevent25"; |
| 385 | case 0x033a: return "mhpmevent26"; |
| 386 | case 0x033b: return "mhpmevent27"; |
| 387 | case 0x033c: return "mhpmevent28"; |
| 388 | case 0x033d: return "mhpmevent29"; |
| 389 | case 0x033e: return "mhpmevent30"; |
| 390 | case 0x033f: return "mhpmevent31"; |
| 391 | |
| 392 | case 0x07a0: return "tselect"; |
| 393 | case 0x07a1: return "tdata1"; |
| 394 | case 0x07a2: return "tdata2"; |
| 395 | case 0x07a3: return "tdata3"; |
| 396 | |
| 397 | case 0x07b0: return "dcsr"; |
| 398 | case 0x07b1: return "dpc"; |
| 399 | case 0x07b2: return "dscratch"; |
| 400 | } |
| 401 | return NULLcxx . . $ `<external>/16391990256953433862/stddef.h:419:9`!; |
| 402 | } |
| 403 | |
| 404 | static void printCSRSystemRegistercxx . . $ printCSRSystemRegister(2c3fef4aec20445).(MCInstcxx . . $ MCInst# *MI, unsigned OpNo, |
| 405 | //const MCSubtargetInfo &STI, |
| 406 | SStreamcxx . . $ SStream# *O) |
| 407 | { |
| 408 | unsigned Imm = MCOperand_getImmcxx . . $ MCOperand_getImm(e2e9552a97d88948).(MCInst_getOperandcxx . . $ MCInst_getOperand(4687f87e75986a5b).(MI, OpNo)); |
| 409 | const char *Name = getCSRSystemRegisterNamecxx . . $ getCSRSystemRegisterName(81a3ae90da26a711).(Imm); |
| 410 | |
| 411 | if (Name) { |
| 412 | SStream_concat0cxx . . $ SStream_concat0(a720692b9b1c0c27).(O, Name); |
| 413 | } else { |
| 414 | SStream_concatcxx . . $ SStream_concat(72515e07697b04b4).(O, "%u", Imm); |
| 415 | } |
| 416 | } |
| 417 | |
| 418 | static void printFenceArgcxx . . $ printFenceArg(2c3fef4aec20445).(MCInstcxx . . $ MCInst# *MI, unsigned OpNo, SStreamcxx . . $ SStream# *O) |
| 419 | { |
| 420 | unsigned FenceArg = MCOperand_getImmcxx . . $ MCOperand_getImm(e2e9552a97d88948).(MCInst_getOperandcxx . . $ MCInst_getOperand(4687f87e75986a5b).(MI, OpNo)); |
| 421 | //CS_ASSERT (((FenceArg >> 4) == 0) && "Invalid immediate in printFenceArg"); |
| 422 | |
| 423 | if ((FenceArg & RISCVFenceField_Icxx . . $ RISCVFenceField_I.) != 0) |
| 424 | SStream_concat0cxx . . $ SStream_concat0(a720692b9b1c0c27).(O, "i"); |
| 425 | if ((FenceArg & RISCVFenceField_Ocxx . . $ RISCVFenceField_O.) != 0) |
| 426 | SStream_concat0cxx . . $ SStream_concat0(a720692b9b1c0c27).(O, "o"); |
| 427 | if ((FenceArg & RISCVFenceField_Rcxx . . $ RISCVFenceField_R.) != 0) |
| 428 | SStream_concat0cxx . . $ SStream_concat0(a720692b9b1c0c27).(O, "r"); |
| 429 | if ((FenceArg & RISCVFenceField_Wcxx . . $ RISCVFenceField_W.) != 0) |
| 430 | SStream_concat0cxx . . $ SStream_concat0(a720692b9b1c0c27).(O, "w"); |
| 431 | if (FenceArg == 0) |
| 432 | SStream_concat0cxx . . $ SStream_concat0(a720692b9b1c0c27).(O, "unknown"); |
| 433 | } |
| 434 | |
| 435 | static void printFRMArgcxx . . $ printFRMArg(2c3fef4aec20445).(MCInstcxx . . $ MCInst# *MI, unsigned OpNo, SStreamcxx . . $ SStream# *O) |
| 436 | { |
| 437 | enum RoundingModecxx . . $ RoundingMode# FRMArg = |
| 438 | (enum RoundingModecxx . . $ RoundingMode#)MCOperand_getImmcxx . . $ MCOperand_getImm(e2e9552a97d88948).(MCInst_getOperandcxx . . $ MCInst_getOperand(4687f87e75986a5b).(MI, OpNo)); |
| 439 | #if 0 |
| 440 | auto FRMArg = |
| 441 | static_cast<RISCVFPRndMode::RoundingMode>(MI->getOperand(OpNo).getImm()); |
| 442 | O << RISCVFPRndMode::roundingModeToString(FRMArg); |
| 443 | #endif |
| 444 | SStream_concat0cxx . . $ SStream_concat0(a720692b9b1c0c27).(O, roundingModeToStringcxx . . $ roundingModeToString(ae5af424b5d2d5).(FRMArg)); |
| 445 | } |
| 446 | |
| 447 | #endif // CAPSTONE_HAS_RISCV |