<commit_before>//
//  riscv-format.cc
//

#include <map>
#include <vector>
#include <string>

#include "riscv-opcodes.h"
#include "riscv-types.h"
#include "riscv-imm.h"
#include "riscv-regs.h"
#include "riscv-decode.h"
#include "riscv-regs.h"
#include "riscv-csr.h"
#include "riscv-processor.h"
#include "riscv-compression.h"
#include "riscv-util.h"
#include "riscv-format.h"

const rvf rvf_none[] =               { rvf_z };
const rvf rvf_imm_pc[] =             { rvf_ipc, rvf_z };
const rvf rvf_rs1_rs2[] =            { rvf_rs1, rvf_c, rvf_rs2, rvf_z };
const rvf rvf_rs2_imm[] =            { rvf_rs2, rvf_c, rvf_imm, rvf_z };
const rvf rvf_rd_imm[] =             { rvf_rd, rvf_c, rvf_imm, rvf_z };
const rvf rvf_rd_imm_pc[] =          { rvf_rd, rvf_c, rvf_ipc, rvf_z };
const rvf rvf_rd_rs1_rs2[] =         { rvf_rd, rvf_c, rvf_rs1, rvf_c, rvf_rs2, rvf_z };
const rvf rvf_frd_frs1_frs2[] =      { rvf_frd, rvf_c, rvf_frs1, rvf_c, rvf_frs2, rvf_z };
const rvf rvf_rd_frs1_frs2[] =       { rvf_frd, rvf_c, rvf_rs1, rvf_c, rvf_frs2, rvf_z };
const rvf rvf_frd_frs1_frs2_frs3[] = { rvf_frd, rvf_c, rvf_frs1, rvf_c, rvf_frs2, rvf_c, rvf_frs3, rvf_z };
const rvf rvf_frd_rs1[] =            { rvf_frd, rvf_c, rvf_rs1, rvf_z };
const rvf rvf_frd_frs1[] =           { rvf_frd, rvf_c, rvf_frs1, rvf_z };
const rvf rvf_rd_frs1[] =            { rvf_rd, rvf_c, rvf_frs1, rvf_z };
const rvf rvf_rd_rs1_imm[] =         { rvf_rd, rvf_c, rvf_rs1, rvf_c, rvf_imm, rvf_z };
const rvf rvf_rd_bimm_rs1[] =        { rvf_rd, rvf_c, rvf_imm, rvf_b, rvf_rs1, rvf_d, rvf_z };
const rvf rvf_frd_bimm_rs1[] =       { rvf_frd, rvf_c, rvf_imm, rvf_b, rvf_rs1, rvf_d, rvf_z };
const rvf rvf_rd_csr_rs1[] =         { rvf_rd, rvf_c, rvf_icsr, rvf_c, rvf_rs1, rvf_z };
const rvf rvf_rd_csr_irs1[] =        { rvf_rd, rvf_c, rvf_icsr, rvf_c, rvf_irs1, rvf_z };
const rvf rvf_rs1_rs2_imm[] =        { rvf_rs1, rvf_c, rvf_rs2, rvf_c, rvf_imm, rvf_z };
const rvf rvf_rs2_bimm_rs1[] =       { rvf_rs2, rvf_c, rvf_imm, rvf_b, rvf_rs1, rvf_d, rvf_z };
const rvf rvf_frs2_bimm_rs1[] =      { rvf_frs2, rvf_c, rvf_imm, rvf_b, rvf_rs1, rvf_d, rvf_z };
const rvf rvf_rs1_rs2_imm_pc[] =     { rvf_rs1, rvf_c, rvf_rs2, rvf_c, rvf_ipc, rvf_z };

const riscv_inst_type_metadata riscv_inst_type_table[] = {
	{ riscv_inst_type_unknown,      rvf_none },
	{ riscv_inst_type_c_fld,        rvf_frd_bimm_rs1 },
	{ riscv_inst_type_c_none,       rvf_none },
	{ riscv_inst_type_cb,           rvf_imm_pc },
	{ riscv_inst_type_ci,           rvf_rd_imm },
	{ riscv_inst_type_ci_16sp,      rvf_rd_rs1_imm },
	{ riscv_inst_type_ci_ldsp,      rvf_rd_imm },
	{ riscv_inst_type_ci_li,        rvf_rd_imm },
	{ riscv_inst_type_ci_lui,       rvf_rd_imm },
	{ riscv_inst_type_ci_lwsp,      rvf_rd_imm },
	{ riscv_inst_type_ciw_4spn,     rvf_rd_rs1_imm },
	{ riscv_inst_type_cj,           rvf_imm_pc },
	{ riscv_inst_type_cl_d,         rvf_rd_imm },
	{ riscv_inst_type_cl_w,         rvf_rd_imm },
	{ riscv_inst_type_cr,           rvf_rs1_rs2 },
	{ riscv_inst_type_cr_jalr,      rvf_rs1_rs2 },
	{ riscv_inst_type_cr_jr,        rvf_rs1_rs2 },
	{ riscv_inst_type_cs,           rvf_rs1_rs2 },
	{ riscv_inst_type_cs_d,         rvf_rs1_rs2_imm },
	{ riscv_inst_type_cs_w,         rvf_rs1_rs2_imm },
	{ riscv_inst_type_css_swsp,     rvf_rs2_bimm_rs1 },
	{ riscv_inst_type_css_sdsp,     rvf_rs2_bimm_rs1 },
	{ riscv_inst_type_i,            rvf_rd_rs1_imm },
	{ riscv_inst_type_i_csr,        rvf_rd_csr_rs1 },
	{ riscv_inst_type_i_csri,       rvf_rd_csr_irs1 },
	{ riscv_inst_type_i_l,          rvf_rd_bimm_rs1 },
	{ riscv_inst_type_i_lf,         rvf_frd_bimm_rs1 },
	{ riscv_inst_type_i_none,       rvf_none },
	{ riscv_inst_type_i_sh5,        rvf_rd_rs1_imm },
	{ riscv_inst_type_i_sh6,        rvf_rd_rs1_imm },
	{ riscv_inst_type_r,            rvf_rd_rs1_rs2 },
	{ riscv_inst_type_r_3f,         rvf_frd_frs1_frs2},
	{ riscv_inst_type_r_4f,         rvf_frd_frs1_frs2_frs3},
	{ riscv_inst_type_r_ff,         rvf_frd_frs1},
	{ riscv_inst_type_r_fr,         rvf_frd_rs1 },
	{ riscv_inst_type_r_rf,         rvf_rd_frs1},
	{ riscv_inst_type_r_rff,        rvf_rd_frs1_frs2},
	{ riscv_inst_type_s,            rvf_rs2_bimm_rs1 },
	{ riscv_inst_type_sb,           rvf_rs1_rs2_imm_pc },
	{ riscv_inst_type_s_f,          rvf_frs2_bimm_rs1 },
	{ riscv_inst_type_u,            rvf_rd_imm },
	{ riscv_inst_type_uj,           rvf_rd_imm_pc },
	{ riscv_inst_type_unknown,      nullptr }
};


/* Metadata Tables */

struct riscv_inst_type_map : std::map<riscv_inst_type,const riscv_inst_type_metadata*>
{<commit_msg>Minor whitespace change<commit_after>//
//  riscv-format.cc
//

#include <map>
#include <vector>
#include <string>

#include "riscv-opcodes.h"
#include "riscv-types.h"
#include "riscv-imm.h"
#include "riscv-regs.h"
#include "riscv-decode.h"
#include "riscv-regs.h"
#include "riscv-csr.h"
#include "riscv-processor.h"
#include "riscv-compression.h"
#include "riscv-util.h"
#include "riscv-format.h"

const rvf rvf_none[] =               { rvf_z };
const rvf rvf_imm_pc[] =             { rvf_ipc, rvf_z };
const rvf rvf_rs1_rs2[] =            { rvf_rs1, rvf_c, rvf_rs2, rvf_z };
const rvf rvf_rs2_imm[] =            { rvf_rs2, rvf_c, rvf_imm, rvf_z };
const rvf rvf_rd_imm[] =             { rvf_rd, rvf_c, rvf_imm, rvf_z };
const rvf rvf_rd_imm_pc[] =          { rvf_rd, rvf_c, rvf_ipc, rvf_z };
const rvf rvf_rd_rs1_rs2[] =         { rvf_rd, rvf_c, rvf_rs1, rvf_c, rvf_rs2, rvf_z };
const rvf rvf_frd_frs1_frs2[] =      { rvf_frd, rvf_c, rvf_frs1, rvf_c, rvf_frs2, rvf_z };
const rvf rvf_rd_frs1_frs2[] =       { rvf_frd, rvf_c, rvf_rs1, rvf_c, rvf_frs2, rvf_z };
const rvf rvf_frd_frs1_frs2_frs3[] = { rvf_frd, rvf_c, rvf_frs1, rvf_c, rvf_frs2, rvf_c, rvf_frs3, rvf_z };
const rvf rvf_frd_rs1[] =            { rvf_frd, rvf_c, rvf_rs1, rvf_z };
const rvf rvf_frd_frs1[] =           { rvf_frd, rvf_c, rvf_frs1, rvf_z };
const rvf rvf_rd_frs1[] =            { rvf_rd, rvf_c, rvf_frs1, rvf_z };
const rvf rvf_rd_rs1_imm[] =         { rvf_rd, rvf_c, rvf_rs1, rvf_c, rvf_imm, rvf_z };
const rvf rvf_rd_bimm_rs1[] =        { rvf_rd, rvf_c, rvf_imm, rvf_b, rvf_rs1, rvf_d, rvf_z };
const rvf rvf_frd_bimm_rs1[] =       { rvf_frd, rvf_c, rvf_imm, rvf_b, rvf_rs1, rvf_d, rvf_z };
const rvf rvf_rd_csr_rs1[] =         { rvf_rd, rvf_c, rvf_icsr, rvf_c, rvf_rs1, rvf_z };
const rvf rvf_rd_csr_irs1[] =        { rvf_rd, rvf_c, rvf_icsr, rvf_c, rvf_irs1, rvf_z };
const rvf rvf_rs1_rs2_imm[] =        { rvf_rs1, rvf_c, rvf_rs2, rvf_c, rvf_imm, rvf_z };
const rvf rvf_rs2_bimm_rs1[] =       { rvf_rs2, rvf_c, rvf_imm, rvf_b, rvf_rs1, rvf_d, rvf_z };
const rvf rvf_frs2_bimm_rs1[] =      { rvf_frs2, rvf_c, rvf_imm, rvf_b, rvf_rs1, rvf_d, rvf_z };
const rvf rvf_rs1_rs2_imm_pc[] =     { rvf_rs1, rvf_c, rvf_rs2, rvf_c, rvf_ipc, rvf_z };

const riscv_inst_type_metadata riscv_inst_type_table[] = {
	{ riscv_inst_type_unknown,      rvf_none },
	{ riscv_inst_type_c_fld,        rvf_frd_bimm_rs1 },
	{ riscv_inst_type_c_none,       rvf_none },
	{ riscv_inst_type_cb,           rvf_imm_pc },
	{ riscv_inst_type_ci,           rvf_rd_imm },
	{ riscv_inst_type_ci_16sp,      rvf_rd_rs1_imm },
	{ riscv_inst_type_ci_ldsp,      rvf_rd_imm },
	{ riscv_inst_type_ci_li,        rvf_rd_imm },
	{ riscv_inst_type_ci_lui,       rvf_rd_imm },
	{ riscv_inst_type_ci_lwsp,      rvf_rd_imm },
	{ riscv_inst_type_ciw_4spn,     rvf_rd_rs1_imm },
	{ riscv_inst_type_cj,           rvf_imm_pc },
	{ riscv_inst_type_cl_d,         rvf_rd_imm },
	{ riscv_inst_type_cl_w,         rvf_rd_imm },
	{ riscv_inst_type_cr,           rvf_rs1_rs2 },
	{ riscv_inst_type_cr_jalr,      rvf_rs1_rs2 },
	{ riscv_inst_type_cr_jr,        rvf_rs1_rs2 },
	{ riscv_inst_type_cs,           rvf_rs1_rs2 },
	{ riscv_inst_type_cs_d,         rvf_rs1_rs2_imm },
	{ riscv_inst_type_cs_w,         rvf_rs1_rs2_imm },
	{ riscv_inst_type_css_swsp,     rvf_rs2_bimm_rs1 },
	{ riscv_inst_type_css_sdsp,     rvf_rs2_bimm_rs1 },
	{ riscv_inst_type_i,            rvf_rd_rs1_imm },
	{ riscv_inst_type_i_csr,        rvf_rd_csr_rs1 },
	{ riscv_inst_type_i_csri,       rvf_rd_csr_irs1 },
	{ riscv_inst_type_i_l,          rvf_rd_bimm_rs1 },
	{ riscv_inst_type_i_lf,         rvf_frd_bimm_rs1 },
	{ riscv_inst_type_i_none,       rvf_none },
	{ riscv_inst_type_i_sh5,        rvf_rd_rs1_imm },
	{ riscv_inst_type_i_sh6,        rvf_rd_rs1_imm },
	{ riscv_inst_type_r,            rvf_rd_rs1_rs2 },
	{ riscv_inst_type_r_3f,         rvf_frd_frs1_frs2 },
	{ riscv_inst_type_r_4f,         rvf_frd_frs1_frs2_frs3 },
	{ riscv_inst_type_r_ff,         rvf_frd_frs1 },
	{ riscv_inst_type_r_fr,         rvf_frd_rs1 },
	{ riscv_inst_type_r_rf,         rvf_rd_frs1},
	{ riscv_inst_type_r_rff,        rvf_rd_frs1_frs2 },
	{ riscv_inst_type_s,            rvf_rs2_bimm_rs1 },
	{ riscv_inst_type_sb,           rvf_rs1_rs2_imm_pc },
	{ riscv_inst_type_s_f,          rvf_frs2_bimm_rs1 },
	{ riscv_inst_type_u,            rvf_rd_imm },
	{ riscv_inst_type_uj,           rvf_rd_imm_pc },
	{ riscv_inst_type_unknown,      nullptr }
};


/* Metadata Tables */

struct riscv_inst_type_map : std::map<riscv_inst_type,const riscv_inst_type_metadata*>
{
{'fraction_non_alphanumeric': 0.10799469964664311, 'fraction_numerical': 0.023630742049469966, 'mean_word_length': 3.3026128266033252, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2929063', 'n_tokens_mistral': 4587, 'n_tokens_neox': 4700, 'n_words': 614}