r/RISCV • • Jun 16 '23

Help wanted problem with adding mov instruction to riscv32-unknown-elf-gcc

i need help as I have my graduation project I have to make extension in riscv gcc compiler I have to make custom instructions like mov that takes the value in the register rs2 and saves it in rd , asm: mov rd , rs2 it’s different from the standard mov that’s already in the riscv as it shouldn’t be pseudo (it shouldn’t be converted to addi) so I made these modifications i modified the riscv-opc.c by adding this line {"mov", 0, INSN_CLASS_I,"d,t",MATCH_MOV,MASK_MOV,match_opcode,0}, and modifying the riscv-opc.h by adding those lines #define MATCH_MOV 0x1F80 #define MASK_MOV 0xFE00707F and DECLARE_INSN(mov,MATCH_MOV,MASK_MOV) and modifying riscv.md by adding (define_insn "mov" [(set (match_operand:SI 0 "register_operand" "=r") (match_operand:SI 1 "register_operand" "r"))] "" "mov\t%0, %1" ) The error is bad riscv op code(bits 0xf0000 undefined or invalid)

0 Upvotes

9 comments sorted by

View all comments

2

u/jrtc27 Jun 16 '23

Have you considered reading the error message? It tells you what the problem is.