1 /* 2 * Copyright (c) 2006-2021, RT-Thread Development Team 3 * 4 * SPDX-License-Identifier: Apache-2.0 5 * 6 * Change Logs: 7 * Date Author Notes 8 * 2022-11-09 Shell Add portable asm support 9 */ 10 #ifndef __OPCODE_H__ 11 #define __OPCODE_H__ 12 13 /** 14 * @brief binary opcode pseudo operations 15 * Used to bypass toolchain restriction on extension ISA 16 * 17 */ 18 19 /** 20 * @brief RISC-V instruction formats 21 */ 22 23 /** 24 * R type: .insn r opcode6, func3, func7, rd, rs1, rs2 25 * 26 * +-------+-----+-----+-------+----+---------+ 27 * | func7 | rs2 | rs1 | func3 | rd | opcode6 | 28 * +-------+-----+-----+-------+----+---------+ 29 * 31 25 20 15 12 7 0 30 */ 31 #define __OPC_INSN_FORMAT_R(opcode, func3, func7, rd, rs1, rs2) \ 32 ".insn r "RT_STRINGIFY(opcode)","RT_STRINGIFY(func3)","RT_STRINGIFY(func7)","RT_STRINGIFY(rd)","RT_STRINGIFY(rs1)","RT_STRINGIFY(rs2) 33 34 #ifdef _TOOLCHAIN_SUPP_ZIFENCEI_ISA_ 35 #define OPC_FENCE_I "fence.i" 36 #else /* !_TOOLCHAIN_SUPP_ZIFENCEI_ISA_ */ 37 #define OPC_FENCE_I ".long 0x0000100F" 38 #endif /* _TOOLCHAIN_SUPP_ZIFENCEI_ISA_ */ 39 40 #endif /* __OPCODE_H__ */