1 // SPDX-License-Identifier: GPL-2.0 2 /* 3 * Copyright (C) 2020-2022 Loongson Technology Corporation Limited 4 */ 5 #include <asm/inst.h> 6 7 u32 larch_insn_gen_lu32id(enum loongarch_gpr rd, int imm) 8 { 9 union loongarch_instruction insn; 10 11 insn.reg1i20_format.opcode = lu32id_op; 12 insn.reg1i20_format.rd = rd; 13 insn.reg1i20_format.immediate = imm; 14 15 return insn.word; 16 } 17 18 u32 larch_insn_gen_lu52id(enum loongarch_gpr rd, enum loongarch_gpr rj, int imm) 19 { 20 union loongarch_instruction insn; 21 22 insn.reg2i12_format.opcode = lu52id_op; 23 insn.reg2i12_format.rd = rd; 24 insn.reg2i12_format.rj = rj; 25 insn.reg2i12_format.immediate = imm; 26 27 return insn.word; 28 } 29 30 u32 larch_insn_gen_jirl(enum loongarch_gpr rd, enum loongarch_gpr rj, unsigned long pc, unsigned long dest) 31 { 32 union loongarch_instruction insn; 33 34 insn.reg2i16_format.opcode = jirl_op; 35 insn.reg2i16_format.rd = rd; 36 insn.reg2i16_format.rj = rj; 37 insn.reg2i16_format.immediate = (dest - pc) >> 2; 38 39 return insn.word; 40 } 41