I want to add custom instructions to riscv64-gnu-gcc. I added the following code to riscv-opc.c and riscv-opc.h while referring to the following sites. I am getting an error for some reason. Why? Ubuntu20.04, riscv64-gnu-tool 12.2.0. I plan to run a C program on a RISC-V 32bit IM compatible CPU.
I added these codes.
///home/ubuntu2/riscv-gnu-toolchain/binutils/gdb/opcodes/riscv-opc.c
{"custom", 32, INSN_CLASS_I, "d,s,t", MATCH_CUSTOM, MASK_CUSTOM, match_opcode, 0}
~/riscv-opc.h
#define MATCH_CUSTOM 0x700b
#define MASK_CUSTOM 0xfe00707f
DECLARE_INSN(custom, MATCH_CUSTOM, MASK_CUSTOM)
I did command and got errors.
//terminal
$cd riscv-gnu-toolchain
$make clean
$make build-binutils
$cd /home/sample_code
$riscv64-unknown-linux-gnu-gcc -march=rv32im -mabi=ilp32 custom_.c
custom.c: Assembler messages:
custom.c:2: Error: unrecognized opcode `custom a1,a2,a3'
//custom.c code
int main(void){
asm("custom a1, a2, a3");
}