HI,
I tried adding one custom instruction to existing riscv-gnu-toolchain. Below are the steps i followed. I basically want to add instruction ‘mod’(modulus)
- New instruction called 'mod is added to the existing riscv_opcodes structure. like below
{“mod”, 0, INSN_CLASS_I, “d,s,t”, MATCH_MOD, MASK_MOD, match_opcode, 0},
in riscv-gnu-toolchain\riscv-binutils\opcodes\riscv-opc.c
- I have defined MATCH_MOD and MASK_MODE as
#define MATCH_MOD 0x200006b
#define MASK_MOD 0xfe00707f
and added DECLARE_INSN(mod, MATCH_MOD, MASK_MOD)
in riscv-gnu-toolchain\riscv-binutils\include\opcode\riscv-opc.h
Now i tried to rebuild my gnu toolchain and i got following error
internal error: can’t hash `add’: exists
Assembler messages:
Fatal error: Broken assembler. No assembly attempted.
I got this error during build phase of newlib
here is the command-line option logged in config.log
/opt/riscv-gnu-toolchain/riscv-gnu-toolchain/riscv-newlib/newlib/configure --srcdir=/opt/riscv-gnu-toolchain/riscv-gnu-toolchain/build_custom/…/riscv-newlib/newlib --cache-file=./config.cache --with-newlib --enable-multilib --with-cross-host=x86_64-pc-linux-gnu --prefix=/opt/riscv32_custom --enable-newlib-io-long-double --enable-newlib-io-long-long --enable-newlib-io-c99-formats --enable-newlib-register-fini --program-transform-name=s&^&riscv32-unknown-elf-& --disable-option-checking --with-target-subdir=riscv32-unknown-elf --build=x86_64-pc-linux-gnu --host=riscv32-unknown-elf --target=riscv32-unknown-elf
Can u suggest me what is going wrong here ? Is there any other place i have to add the new instruction encoding ?
there is another file called riscv-opc.h and riscv-opc.c in \riscv-gdb\opcodes folder. should i also modify the structure table there also ?
basically i want disassembler to emit this new instruction.