Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Mapping.c
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,7 @@ static inline bool char_ends_mnem(const char c, cs_arch arch)
default:
return (!c || c == ' ' || c == '\t' || c == '.');
case CS_ARCH_PPC:
case CS_ARCH_RISCV:
return (!c || c == ' ' || c == '\t');
case CS_ARCH_SPARC:
return (!c || c == ' ' || c == '\t' || c == ',');
Expand Down
1 change: 1 addition & 0 deletions arch/RISCV/RISCVInstPrinter.c
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,7 @@ void RISCV_LLVM_printInstruction(MCInst *MI, SStream *O,
RISCV_add_groups(MI);
RISCV_add_missing_write_access(MI);
RISCV_compact_operands(MI);
RISCV_set_alias_id(MI, O);
}

const char *getSysRegName(unsigned reg)
Expand Down
30 changes: 24 additions & 6 deletions arch/RISCV/RISCVMapping.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,13 @@ const insn_map *RISCV_insns = insns;
const unsigned int RISCV_insn_count = ARR_SIZE(insns);

#ifndef CAPSTONE_DIET

static const map_insn_ops insn_operands[] = {
#include "RISCVGenCSMappingInsnOp.inc"
};

static const name_map insn_alias_mnem_map[] = {
#include "RISCVGenCSAliasMnemMap.inc"
};
#endif

void RISCV_add_cs_detail_0(MCInst *MI, riscv_op_group opgroup, unsigned OpNum)
Expand Down Expand Up @@ -359,16 +361,26 @@ static const char *const insn_name_maps[] = {
#include "RISCVGenCSMappingInsnName.inc"
};

// called from RISCV_LLVM_printInstruction() to avoid exporting
// insn_alias_mnem_map and its size via extern declarations
void RISCV_set_alias_id(MCInst *MI, SStream *O)
{
#ifndef CAPSTONE_DIET
map_set_alias_id(MI, O, insn_alias_mnem_map,
ARR_SIZE(insn_alias_mnem_map));
#endif
}

const char *RISCV_insn_name(csh handle, unsigned int id)
{
#ifndef CAPSTONE_DIET
if (id >= RISCV_INS_ENDING)
return NULL;
if (id < RISCV_INS_ENDING)
return insn_name_maps[id];

return insn_name_maps[id];
#else
return NULL;
if (id < RISCV_INS_ALIAS_END)
return insn_alias_mnem_map[id - RISCV_INS_ALIAS_BEGIN - 1].name;
Comment thread
Rot127 marked this conversation as resolved.
#endif
return NULL;
}

#ifndef CAPSTONE_DIET
Expand Down Expand Up @@ -413,6 +425,12 @@ riscv_insn RISCV_map_insn(const char *name)
if (!strcmp(name, insn_name_maps[i]))
return i;
}
#ifndef CAPSTONE_DIET
for (i = 0; i < ARR_SIZE(insn_alias_mnem_map); i++) {
if (!strcmp(name, insn_alias_mnem_map[i].name))
return insn_alias_mnem_map[i].id;
}
#endif
return RISCV_INS_INVALID;
}

Expand Down
2 changes: 2 additions & 0 deletions arch/RISCV/RISCVMapping.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ extern const unsigned int RISCV_insn_count;
// given internal insn id, return public instruction info
void RISCV_get_insn_id(cs_struct *h, cs_insn *insn, unsigned int id);

void RISCV_set_alias_id(MCInst *MI, SStream *O);

const char *RISCV_insn_name(csh handle, unsigned int id);

const char *RISCV_group_name(csh handle, unsigned int id);
Expand Down
Loading