2016-11-02 00:40:28 +01:00
|
|
|
//===-- RISCVInstrFormats.td - RISCV Instruction Formats ---*- tablegen -*-===//
|
|
|
|
//
|
2019-01-19 09:50:56 +01:00
|
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
2016-11-02 00:40:28 +01:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// These instruction format definitions are structured to match the
|
|
|
|
// description in the RISC-V User-Level ISA specification as closely as
|
|
|
|
// possible. For instance, the specification describes instructions with the
|
|
|
|
// MSB (31st bit) on the left and the LSB (0th bit) on the right. This is
|
|
|
|
// reflected in the order of parameters to each instruction class.
|
|
|
|
//
|
|
|
|
// One area of divergence is in the description of immediates. The
|
|
|
|
// specification describes immediate encoding in terms of bit-slicing
|
|
|
|
// operations on the logical value represented. The immediate argument to
|
|
|
|
// these instruction formats instead represents the bit sequence that will be
|
|
|
|
// inserted into the instruction. e.g. although JAL's immediate is logically
|
|
|
|
// a 21-bit value (where the LSB is always zero), we describe it as an imm20
|
|
|
|
// to match how it is encoded.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2017-09-28 10:26:24 +02:00
|
|
|
// Format specifies the encoding used by the instruction. This is used by
|
|
|
|
// RISCVMCCodeEmitter to determine which form of fixup to use. These
|
|
|
|
// definitions must be kept in-sync with RISCVBaseInfo.h.
|
2017-12-07 13:50:32 +01:00
|
|
|
class InstFormat<bits<5> val> {
|
|
|
|
bits<5> Value = val;
|
2017-09-28 10:26:24 +02:00
|
|
|
}
|
|
|
|
def InstFormatPseudo : InstFormat<0>;
|
|
|
|
def InstFormatR : InstFormat<1>;
|
2017-12-07 11:26:05 +01:00
|
|
|
def InstFormatR4 : InstFormat<2>;
|
|
|
|
def InstFormatI : InstFormat<3>;
|
|
|
|
def InstFormatS : InstFormat<4>;
|
|
|
|
def InstFormatB : InstFormat<5>;
|
|
|
|
def InstFormatU : InstFormat<6>;
|
|
|
|
def InstFormatJ : InstFormat<7>;
|
2017-12-07 13:50:32 +01:00
|
|
|
def InstFormatCR : InstFormat<8>;
|
|
|
|
def InstFormatCI : InstFormat<9>;
|
|
|
|
def InstFormatCSS : InstFormat<10>;
|
|
|
|
def InstFormatCIW : InstFormat<11>;
|
|
|
|
def InstFormatCL : InstFormat<12>;
|
|
|
|
def InstFormatCS : InstFormat<13>;
|
2018-11-16 11:33:23 +01:00
|
|
|
def InstFormatCA : InstFormat<14>;
|
|
|
|
def InstFormatCB : InstFormat<15>;
|
|
|
|
def InstFormatCJ : InstFormat<16>;
|
|
|
|
def InstFormatOther : InstFormat<17>;
|
2017-09-28 10:26:24 +02:00
|
|
|
|
2020-12-27 03:47:58 +01:00
|
|
|
class RISCVVConstraint<bits<3> val> {
|
|
|
|
bits<3> Value = val;
|
2019-10-24 06:29:28 +02:00
|
|
|
}
|
2020-12-27 03:47:58 +01:00
|
|
|
def NoConstraint : RISCVVConstraint<0b000>;
|
|
|
|
def VS2Constraint : RISCVVConstraint<0b001>;
|
|
|
|
def VS1Constraint : RISCVVConstraint<0b010>;
|
|
|
|
def VMConstraint : RISCVVConstraint<0b100>;
|
2020-05-21 11:30:20 +02:00
|
|
|
|
2020-12-27 03:47:58 +01:00
|
|
|
// Illegal instructions:
|
|
|
|
//
|
|
|
|
// * The destination vector register group for a masked vector instruction
|
|
|
|
// cannot overlap the source mask register (v0), unless the destination vector
|
|
|
|
// register is being written with a mask value (e.g., comparisons) or the
|
|
|
|
// scalar result of a reduction.
|
|
|
|
//
|
2020-12-28 04:57:41 +01:00
|
|
|
// * Widening: The destination EEW is greater than the source EEW, the source
|
|
|
|
// EMUL is at least 1. The destination vector register group cannot overlap
|
|
|
|
// with the source vector register groups besides the highest-numbered part of
|
|
|
|
// the destination register group.
|
2020-12-27 03:47:58 +01:00
|
|
|
//
|
2020-12-28 04:57:41 +01:00
|
|
|
// * Narrowing: The destination EEW is smaller than the source EEW. The
|
|
|
|
// destination vector register group cannot overlap with the source vector
|
|
|
|
// register groups besides the lowest-numbered part of the source register
|
|
|
|
// group.
|
2020-12-27 03:47:58 +01:00
|
|
|
//
|
2020-12-28 04:57:41 +01:00
|
|
|
// * vmsbf.m/vmsif.m/vmsof.m: The destination register cannot overlap the
|
|
|
|
// source register and, if masked, cannot overlap the mask register ('v0').
|
2020-12-27 03:47:58 +01:00
|
|
|
//
|
2020-12-28 04:57:41 +01:00
|
|
|
// * viota: The destination register cannot overlap the source register and,
|
|
|
|
// if masked, cannot overlap the mask register ('v0').
|
2020-12-27 03:47:58 +01:00
|
|
|
//
|
|
|
|
// * v[f]slide[1]up: The destination vector register group for vslideup cannot
|
|
|
|
// overlap the source vector register group.
|
|
|
|
//
|
|
|
|
// * vrgather: The destination vector register group cannot overlap with the
|
|
|
|
// source vector register groups.
|
|
|
|
//
|
|
|
|
// * vcompress: The destination vector register group cannot overlap the
|
|
|
|
// source vector register group or the source mask register
|
2020-05-21 11:30:20 +02:00
|
|
|
def WidenV : RISCVVConstraint<!or(VS2Constraint.Value,
|
|
|
|
VS1Constraint.Value,
|
|
|
|
VMConstraint.Value)>;
|
|
|
|
def WidenW : RISCVVConstraint<!or(VS1Constraint.Value,
|
|
|
|
VMConstraint.Value)>;
|
|
|
|
def WidenCvt : RISCVVConstraint<!or(VS2Constraint.Value,
|
2020-12-27 03:47:58 +01:00
|
|
|
VMConstraint.Value)>;
|
2020-05-21 11:30:20 +02:00
|
|
|
def Iota : RISCVVConstraint<!or(VS2Constraint.Value,
|
2020-12-27 03:47:58 +01:00
|
|
|
VMConstraint.Value)>;
|
2020-05-21 11:30:20 +02:00
|
|
|
def SlideUp : RISCVVConstraint<!or(VS2Constraint.Value,
|
|
|
|
VMConstraint.Value)>;
|
|
|
|
def Vrgather : RISCVVConstraint<!or(VS2Constraint.Value,
|
|
|
|
VS1Constraint.Value,
|
|
|
|
VMConstraint.Value)>;
|
|
|
|
def Vcompress : RISCVVConstraint<!or(VS2Constraint.Value,
|
|
|
|
VS1Constraint.Value)>;
|
2019-10-24 06:29:28 +02:00
|
|
|
|
2018-11-16 11:33:23 +01:00
|
|
|
// The following opcode names match those given in Table 19.1 in the
|
2017-10-19 16:29:03 +02:00
|
|
|
// RISC-V User-level ISA specification ("RISC-V base opcode map").
|
|
|
|
class RISCVOpcode<bits<7> val> {
|
|
|
|
bits<7> Value = val;
|
|
|
|
}
|
|
|
|
def OPC_LOAD : RISCVOpcode<0b0000011>;
|
|
|
|
def OPC_LOAD_FP : RISCVOpcode<0b0000111>;
|
|
|
|
def OPC_MISC_MEM : RISCVOpcode<0b0001111>;
|
|
|
|
def OPC_OP_IMM : RISCVOpcode<0b0010011>;
|
|
|
|
def OPC_AUIPC : RISCVOpcode<0b0010111>;
|
|
|
|
def OPC_OP_IMM_32 : RISCVOpcode<0b0011011>;
|
|
|
|
def OPC_STORE : RISCVOpcode<0b0100011>;
|
|
|
|
def OPC_STORE_FP : RISCVOpcode<0b0100111>;
|
|
|
|
def OPC_AMO : RISCVOpcode<0b0101111>;
|
|
|
|
def OPC_OP : RISCVOpcode<0b0110011>;
|
|
|
|
def OPC_LUI : RISCVOpcode<0b0110111>;
|
|
|
|
def OPC_OP_32 : RISCVOpcode<0b0111011>;
|
|
|
|
def OPC_MADD : RISCVOpcode<0b1000011>;
|
|
|
|
def OPC_MSUB : RISCVOpcode<0b1000111>;
|
|
|
|
def OPC_NMSUB : RISCVOpcode<0b1001011>;
|
|
|
|
def OPC_NMADD : RISCVOpcode<0b1001111>;
|
|
|
|
def OPC_OP_FP : RISCVOpcode<0b1010011>;
|
2019-10-24 06:29:28 +02:00
|
|
|
def OPC_OP_V : RISCVOpcode<0b1010111>;
|
2017-10-19 16:29:03 +02:00
|
|
|
def OPC_BRANCH : RISCVOpcode<0b1100011>;
|
|
|
|
def OPC_JALR : RISCVOpcode<0b1100111>;
|
|
|
|
def OPC_JAL : RISCVOpcode<0b1101111>;
|
|
|
|
def OPC_SYSTEM : RISCVOpcode<0b1110011>;
|
|
|
|
|
|
|
|
class RVInst<dag outs, dag ins, string opcodestr, string argstr,
|
|
|
|
list<dag> pattern, InstFormat format>
|
2016-11-02 00:40:28 +01:00
|
|
|
: Instruction {
|
|
|
|
field bits<32> Inst;
|
2017-09-17 16:36:28 +02:00
|
|
|
// SoftFail is a field the disassembler can use to provide a way for
|
|
|
|
// instructions to not match without killing the whole decode process. It is
|
|
|
|
// mainly used for ARM, but Tablegen expects this field to exist or it fails
|
|
|
|
// to build the decode table.
|
|
|
|
field bits<32> SoftFail = 0;
|
2016-11-02 00:40:28 +01:00
|
|
|
let Size = 4;
|
|
|
|
|
|
|
|
bits<7> Opcode = 0;
|
|
|
|
|
|
|
|
let Inst{6-0} = Opcode;
|
|
|
|
|
|
|
|
let Namespace = "RISCV";
|
|
|
|
|
|
|
|
dag OutOperandList = outs;
|
|
|
|
dag InOperandList = ins;
|
2017-10-19 16:29:03 +02:00
|
|
|
let AsmString = opcodestr # "\t" # argstr;
|
2016-11-02 00:40:28 +01:00
|
|
|
let Pattern = pattern;
|
2017-09-28 10:26:24 +02:00
|
|
|
|
2017-12-07 13:50:32 +01:00
|
|
|
let TSFlags{4-0} = format.Value;
|
2019-10-24 06:29:28 +02:00
|
|
|
|
|
|
|
// Defaults
|
|
|
|
RISCVVConstraint RVVConstraint = NoConstraint;
|
2020-12-27 03:47:58 +01:00
|
|
|
let TSFlags{7-5} = RVVConstraint.Value;
|
2021-01-11 03:01:23 +01:00
|
|
|
|
|
|
|
bits<3> VLMul = 0;
|
|
|
|
let TSFlags{10-8} = VLMul;
|
|
|
|
|
|
|
|
bit HasDummyMask = 0;
|
|
|
|
let TSFlags{11} = HasDummyMask;
|
|
|
|
|
2021-02-08 18:56:47 +01:00
|
|
|
bit ForceTailAgnostic = false;
|
|
|
|
let TSFlags{12} = ForceTailAgnostic;
|
2021-01-11 03:01:23 +01:00
|
|
|
|
|
|
|
bit HasMergeOp = 0;
|
|
|
|
let TSFlags{13} = HasMergeOp;
|
|
|
|
|
|
|
|
bit HasSEWOp = 0;
|
|
|
|
let TSFlags{14} = HasSEWOp;
|
|
|
|
|
|
|
|
bit HasVLOp = 0;
|
|
|
|
let TSFlags{15} = HasVLOp;
|
2016-11-02 00:40:28 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// Pseudo instructions
|
2018-06-07 17:35:47 +02:00
|
|
|
class Pseudo<dag outs, dag ins, list<dag> pattern, string opcodestr = "", string argstr = "">
|
2020-01-23 21:51:04 +01:00
|
|
|
: RVInst<outs, ins, opcodestr, argstr, pattern, InstFormatPseudo>,
|
|
|
|
Sched<[]> {
|
2016-11-02 00:40:28 +01:00
|
|
|
let isPseudo = 1;
|
2017-02-14 06:17:23 +01:00
|
|
|
let isCodeGenOnly = 1;
|
2016-11-02 00:40:28 +01:00
|
|
|
}
|
|
|
|
|
2019-02-20 04:31:32 +01:00
|
|
|
// Pseudo load instructions.
|
|
|
|
class PseudoLoad<string opcodestr, RegisterClass rdty = GPR>
|
|
|
|
: Pseudo<(outs rdty:$rd), (ins bare_symbol:$addr), [], opcodestr, "$rd, $addr"> {
|
|
|
|
let hasSideEffects = 0;
|
|
|
|
let mayLoad = 1;
|
|
|
|
let mayStore = 0;
|
|
|
|
let isCodeGenOnly = 0;
|
|
|
|
let isAsmParserOnly = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
class PseudoFloatLoad<string opcodestr, RegisterClass rdty = GPR>
|
|
|
|
: Pseudo<(outs rdty:$rd, GPR:$tmp), (ins bare_symbol:$addr), [], opcodestr, "$rd, $addr, $tmp"> {
|
|
|
|
let hasSideEffects = 0;
|
|
|
|
let mayLoad = 1;
|
|
|
|
let mayStore = 0;
|
|
|
|
let isCodeGenOnly = 0;
|
|
|
|
let isAsmParserOnly = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Pseudo store instructions.
|
|
|
|
class PseudoStore<string opcodestr, RegisterClass rsty = GPR>
|
|
|
|
: Pseudo<(outs rsty:$rs, GPR:$tmp), (ins bare_symbol:$addr), [], opcodestr, "$rs, $addr, $tmp"> {
|
|
|
|
let hasSideEffects = 0;
|
|
|
|
let mayLoad = 0;
|
|
|
|
let mayStore = 1;
|
|
|
|
let isCodeGenOnly = 0;
|
|
|
|
let isAsmParserOnly = 1;
|
|
|
|
}
|
|
|
|
|
2017-10-19 16:29:03 +02:00
|
|
|
// Instruction formats are listed in the order they appear in the RISC-V
|
|
|
|
// instruction set manual (R, I, S, B, U, J) with sub-formats (e.g. RVInstR4,
|
|
|
|
// RVInstRAtomic) sorted alphabetically.
|
|
|
|
|
|
|
|
class RVInstR<bits<7> funct7, bits<3> funct3, RISCVOpcode opcode, dag outs,
|
|
|
|
dag ins, string opcodestr, string argstr>
|
|
|
|
: RVInst<outs, ins, opcodestr, argstr, [], InstFormatR> {
|
2016-11-02 00:40:28 +01:00
|
|
|
bits<5> rs2;
|
|
|
|
bits<5> rs1;
|
|
|
|
bits<5> rd;
|
|
|
|
|
|
|
|
let Inst{31-25} = funct7;
|
|
|
|
let Inst{24-20} = rs2;
|
|
|
|
let Inst{19-15} = rs1;
|
|
|
|
let Inst{14-12} = funct3;
|
|
|
|
let Inst{11-7} = rd;
|
2017-10-19 16:29:03 +02:00
|
|
|
let Opcode = opcode.Value;
|
2016-11-02 00:40:28 +01:00
|
|
|
}
|
|
|
|
|
2021-05-06 17:58:58 +02:00
|
|
|
class RVInstR4<bits<2> funct2, bits<3> funct3, RISCVOpcode opcode, dag outs,
|
|
|
|
dag ins, string opcodestr, string argstr>
|
|
|
|
: RVInst<outs, ins, opcodestr, argstr, [], InstFormatR4> {
|
|
|
|
bits<5> rs3;
|
|
|
|
bits<5> rs2;
|
|
|
|
bits<5> rs1;
|
|
|
|
bits<5> rd;
|
|
|
|
|
|
|
|
let Inst{31-27} = rs3;
|
|
|
|
let Inst{26-25} = funct2;
|
|
|
|
let Inst{24-20} = rs2;
|
|
|
|
let Inst{19-15} = rs1;
|
|
|
|
let Inst{14-12} = funct3;
|
|
|
|
let Inst{11-7} = rd;
|
|
|
|
let Opcode = opcode.Value;
|
|
|
|
}
|
|
|
|
|
|
|
|
class RVInstR4Frm<bits<2> funct2, RISCVOpcode opcode, dag outs, dag ins,
|
|
|
|
string opcodestr, string argstr>
|
2017-12-07 11:26:05 +01:00
|
|
|
: RVInst<outs, ins, opcodestr, argstr, [], InstFormatR4> {
|
|
|
|
bits<5> rs3;
|
|
|
|
bits<5> rs2;
|
|
|
|
bits<5> rs1;
|
|
|
|
bits<3> funct3;
|
|
|
|
bits<5> rd;
|
|
|
|
|
|
|
|
let Inst{31-27} = rs3;
|
|
|
|
let Inst{26-25} = funct2;
|
|
|
|
let Inst{24-20} = rs2;
|
|
|
|
let Inst{19-15} = rs1;
|
|
|
|
let Inst{14-12} = funct3;
|
|
|
|
let Inst{11-7} = rd;
|
|
|
|
let Opcode = opcode.Value;
|
|
|
|
}
|
|
|
|
|
2017-11-09 16:00:03 +01:00
|
|
|
class RVInstRAtomic<bits<5> funct5, bit aq, bit rl, bits<3> funct3,
|
|
|
|
RISCVOpcode opcode, dag outs, dag ins, string opcodestr,
|
|
|
|
string argstr>
|
|
|
|
: RVInst<outs, ins, opcodestr, argstr, [], InstFormatR> {
|
|
|
|
bits<5> rs2;
|
|
|
|
bits<5> rs1;
|
|
|
|
bits<5> rd;
|
|
|
|
|
|
|
|
let Inst{31-27} = funct5;
|
|
|
|
let Inst{26} = aq;
|
|
|
|
let Inst{25} = rl;
|
|
|
|
let Inst{24-20} = rs2;
|
|
|
|
let Inst{19-15} = rs1;
|
|
|
|
let Inst{14-12} = funct3;
|
|
|
|
let Inst{11-7} = rd;
|
|
|
|
let Opcode = opcode.Value;
|
|
|
|
}
|
|
|
|
|
2017-12-07 11:26:05 +01:00
|
|
|
class RVInstRFrm<bits<7> funct7, RISCVOpcode opcode, dag outs, dag ins,
|
|
|
|
string opcodestr, string argstr>
|
|
|
|
: RVInst<outs, ins, opcodestr, argstr, [], InstFormatR> {
|
|
|
|
bits<5> rs2;
|
|
|
|
bits<5> rs1;
|
|
|
|
bits<3> funct3;
|
|
|
|
bits<5> rd;
|
|
|
|
|
|
|
|
let Inst{31-25} = funct7;
|
|
|
|
let Inst{24-20} = rs2;
|
|
|
|
let Inst{19-15} = rs1;
|
|
|
|
let Inst{14-12} = funct3;
|
|
|
|
let Inst{11-7} = rd;
|
|
|
|
let Opcode = opcode.Value;
|
|
|
|
}
|
|
|
|
|
2017-10-19 16:29:03 +02:00
|
|
|
class RVInstI<bits<3> funct3, RISCVOpcode opcode, dag outs, dag ins,
|
|
|
|
string opcodestr, string argstr>
|
|
|
|
: RVInst<outs, ins, opcodestr, argstr, [], InstFormatI> {
|
2016-11-02 00:40:28 +01:00
|
|
|
bits<12> imm12;
|
|
|
|
bits<5> rs1;
|
|
|
|
bits<5> rd;
|
|
|
|
|
|
|
|
let Inst{31-20} = imm12;
|
|
|
|
let Inst{19-15} = rs1;
|
|
|
|
let Inst{14-12} = funct3;
|
|
|
|
let Inst{11-7} = rd;
|
2017-10-19 16:29:03 +02:00
|
|
|
let Opcode = opcode.Value;
|
2016-11-02 00:40:28 +01:00
|
|
|
}
|
|
|
|
|
2021-04-15 20:08:26 +02:00
|
|
|
class RVInstIShift<bits<5> imm11_7, bits<3> funct3, RISCVOpcode opcode,
|
2017-10-19 16:29:03 +02:00
|
|
|
dag outs, dag ins, string opcodestr, string argstr>
|
|
|
|
: RVInst<outs, ins, opcodestr, argstr, [], InstFormatI> {
|
2017-12-07 11:53:48 +01:00
|
|
|
bits<6> shamt;
|
|
|
|
bits<5> rs1;
|
|
|
|
bits<5> rd;
|
|
|
|
|
2021-04-15 20:08:26 +02:00
|
|
|
let Inst{31-27} = imm11_7;
|
|
|
|
let Inst{26} = 0;
|
2017-12-07 11:53:48 +01:00
|
|
|
let Inst{25-20} = shamt;
|
|
|
|
let Inst{19-15} = rs1;
|
|
|
|
let Inst{14-12} = funct3;
|
|
|
|
let Inst{11-7} = rd;
|
|
|
|
let Opcode = opcode.Value;
|
|
|
|
}
|
|
|
|
|
2021-04-15 20:08:26 +02:00
|
|
|
class RVInstIShiftW<bits<7> imm11_5, bits<3> funct3, RISCVOpcode opcode,
|
2017-12-07 11:53:48 +01:00
|
|
|
dag outs, dag ins, string opcodestr, string argstr>
|
|
|
|
: RVInst<outs, ins, opcodestr, argstr, [], InstFormatI> {
|
2016-11-02 00:40:28 +01:00
|
|
|
bits<5> shamt;
|
|
|
|
bits<5> rs1;
|
|
|
|
bits<5> rd;
|
|
|
|
|
2021-04-15 20:08:26 +02:00
|
|
|
let Inst{31-25} = imm11_5;
|
2016-11-02 00:40:28 +01:00
|
|
|
let Inst{24-20} = shamt;
|
|
|
|
let Inst{19-15} = rs1;
|
|
|
|
let Inst{14-12} = funct3;
|
|
|
|
let Inst{11-7} = rd;
|
2017-10-19 16:29:03 +02:00
|
|
|
let Opcode = opcode.Value;
|
2016-11-02 00:40:28 +01:00
|
|
|
}
|
|
|
|
|
2017-10-19 16:29:03 +02:00
|
|
|
class RVInstS<bits<3> funct3, RISCVOpcode opcode, dag outs, dag ins,
|
|
|
|
string opcodestr, string argstr>
|
|
|
|
: RVInst<outs, ins, opcodestr, argstr, [], InstFormatS> {
|
2016-11-02 00:40:28 +01:00
|
|
|
bits<12> imm12;
|
|
|
|
bits<5> rs2;
|
|
|
|
bits<5> rs1;
|
|
|
|
|
|
|
|
let Inst{31-25} = imm12{11-5};
|
|
|
|
let Inst{24-20} = rs2;
|
|
|
|
let Inst{19-15} = rs1;
|
|
|
|
let Inst{14-12} = funct3;
|
|
|
|
let Inst{11-7} = imm12{4-0};
|
2017-10-19 16:29:03 +02:00
|
|
|
let Opcode = opcode.Value;
|
2016-11-02 00:40:28 +01:00
|
|
|
}
|
|
|
|
|
2017-10-19 16:29:03 +02:00
|
|
|
class RVInstB<bits<3> funct3, RISCVOpcode opcode, dag outs, dag ins,
|
|
|
|
string opcodestr, string argstr>
|
|
|
|
: RVInst<outs, ins, opcodestr, argstr, [], InstFormatB> {
|
2016-11-02 00:40:28 +01:00
|
|
|
bits<12> imm12;
|
|
|
|
bits<5> rs2;
|
|
|
|
bits<5> rs1;
|
|
|
|
|
|
|
|
let Inst{31} = imm12{11};
|
|
|
|
let Inst{30-25} = imm12{9-4};
|
|
|
|
let Inst{24-20} = rs2;
|
|
|
|
let Inst{19-15} = rs1;
|
|
|
|
let Inst{14-12} = funct3;
|
|
|
|
let Inst{11-8} = imm12{3-0};
|
|
|
|
let Inst{7} = imm12{10};
|
2017-10-19 16:29:03 +02:00
|
|
|
let Opcode = opcode.Value;
|
2016-11-02 00:40:28 +01:00
|
|
|
}
|
|
|
|
|
2017-10-19 16:29:03 +02:00
|
|
|
class RVInstU<RISCVOpcode opcode, dag outs, dag ins, string opcodestr,
|
|
|
|
string argstr>
|
|
|
|
: RVInst<outs, ins, opcodestr, argstr, [], InstFormatU> {
|
2016-11-02 00:40:28 +01:00
|
|
|
bits<20> imm20;
|
|
|
|
bits<5> rd;
|
|
|
|
|
|
|
|
let Inst{31-12} = imm20;
|
|
|
|
let Inst{11-7} = rd;
|
2017-10-19 16:29:03 +02:00
|
|
|
let Opcode = opcode.Value;
|
2016-11-02 00:40:28 +01:00
|
|
|
}
|
|
|
|
|
2017-10-19 16:29:03 +02:00
|
|
|
class RVInstJ<RISCVOpcode opcode, dag outs, dag ins, string opcodestr,
|
|
|
|
string argstr>
|
|
|
|
: RVInst<outs, ins, opcodestr, argstr, [], InstFormatJ> {
|
2016-11-02 00:40:28 +01:00
|
|
|
bits<20> imm20;
|
|
|
|
bits<5> rd;
|
|
|
|
|
|
|
|
let Inst{31} = imm20{19};
|
|
|
|
let Inst{30-21} = imm20{9-0};
|
|
|
|
let Inst{20} = imm20{10};
|
|
|
|
let Inst{19-12} = imm20{18-11};
|
|
|
|
let Inst{11-7} = rd;
|
2017-10-19 16:29:03 +02:00
|
|
|
let Opcode = opcode.Value;
|
2016-11-02 00:40:28 +01:00
|
|
|
}
|