-
Notifications
You must be signed in to change notification settings - Fork 12.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[RISCV] MC layer support for the standard RV32D instruction set exten…
…sion As the FPR32 and FPR64 registers have the same names, use validateTargetOperandClass in RISCVAsmParser to coerce a parsed FPR32 to an FPR64 when necessary. The rest of this patch is very similar to the RV32F patch. Differential Revision: https://reviews.llvm.org/D39895 llvm-svn: 320023
- Loading branch information
Showing
10 changed files
with
441 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,131 @@ | ||
| //===-- RISCVInstrInfoD.td - RISC-V 'D' instructions -------*- tablegen -*-===// | ||
| // | ||
| // The LLVM Compiler Infrastructure | ||
| // | ||
| // This file is distributed under the University of Illinois Open Source | ||
| // License. See LICENSE.TXT for details. | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
| // | ||
| // This file describes the RISC-V instructions from the standard 'D', | ||
| // Double-Precision Floating-Point instruction set extension. | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| //===----------------------------------------------------------------------===// | ||
| // Instruction Class Templates | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| let hasSideEffects = 0, mayLoad = 0, mayStore = 0 in | ||
| class FPFMAD_rrr_frm<RISCVOpcode opcode, string opcodestr> | ||
| : RVInstR4<0b01, opcode, (outs FPR64:$rd), | ||
| (ins FPR64:$rs1, FPR64:$rs2, FPR64:$rs3, frmarg:$funct3), | ||
| opcodestr, "$rd, $rs1, $rs2, $rs3, $funct3">; | ||
|
|
||
| class FPFMADDynFrmAlias<FPFMAD_rrr_frm Inst, string OpcodeStr> | ||
| : InstAlias<OpcodeStr#" $rd, $rs1, $rs2, $rs3", | ||
| (Inst FPR64:$rd, FPR64:$rs1, FPR64:$rs2, FPR64:$rs3, 0b111)>; | ||
|
|
||
| let hasSideEffects = 0, mayLoad = 0, mayStore = 0 in | ||
| class FPALUD_rr<bits<7> funct7, bits<3> funct3, string opcodestr> | ||
| : RVInstR<funct7, funct3, OPC_OP_FP, (outs FPR64:$rd), | ||
| (ins FPR64:$rs1, FPR64:$rs2), opcodestr, "$rd, $rs1, $rs2">; | ||
|
|
||
| let hasSideEffects = 0, mayLoad = 0, mayStore = 0 in | ||
| class FPALUD_rr_frm<bits<7> funct7, string opcodestr> | ||
| : RVInstRFrm<funct7, OPC_OP_FP, (outs FPR64:$rd), | ||
| (ins FPR64:$rs1, FPR64:$rs2, frmarg:$funct3), opcodestr, | ||
| "$rd, $rs1, $rs2, $funct3">; | ||
|
|
||
| class FPALUDDynFrmAlias<FPALUD_rr_frm Inst, string OpcodeStr> | ||
| : InstAlias<OpcodeStr#" $rd, $rs1, $rs2", | ||
| (Inst FPR64:$rd, FPR64:$rs1, FPR64:$rs2, 0b111)>; | ||
|
|
||
| let hasSideEffects = 0, mayLoad = 0, mayStore = 0 in | ||
| class FPCmpD_rr<bits<3> funct3, string opcodestr> | ||
| : RVInstR<0b1010001, funct3, OPC_OP_FP, (outs GPR:$rd), | ||
| (ins FPR64:$rs1, FPR64:$rs2), opcodestr, "$rd, $rs1, $rs2">; | ||
|
|
||
| //===----------------------------------------------------------------------===// | ||
| // Instructions | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| let Predicates = [HasStdExtD] in { | ||
|
|
||
| let hasSideEffects = 0, mayLoad = 1, mayStore = 0 in | ||
| def FLD : RVInstI<0b011, OPC_LOAD_FP, (outs FPR64:$rd), | ||
| (ins GPR:$rs1, simm12:$imm12), | ||
| "fld", "$rd, ${imm12}(${rs1})">; | ||
|
|
||
| // Operands for stores are in the order srcreg, base, offset rather than | ||
| // reflecting the order these fields are specified in the instruction | ||
| // encoding. | ||
| let hasSideEffects = 0, mayLoad = 0, mayStore = 1 in | ||
| def FSD : RVInstS<0b011, OPC_STORE_FP, (outs), | ||
| (ins FPR64:$rs2, GPR:$rs1, simm12:$imm12), | ||
| "fsd", "$rs2, ${imm12}(${rs1})">; | ||
|
|
||
| def FMADD_D : FPFMAD_rrr_frm<OPC_MADD, "fmadd.d">; | ||
| def : FPFMADDynFrmAlias<FMADD_D, "fmadd.d">; | ||
| def FMSUB_D : FPFMAD_rrr_frm<OPC_MSUB, "fmsub.d">; | ||
| def : FPFMADDynFrmAlias<FMSUB_D, "fmsub.d">; | ||
| def FNMSUB_D : FPFMAD_rrr_frm<OPC_NMSUB, "fnmsub.d">; | ||
| def : FPFMADDynFrmAlias<FNMSUB_D, "fnmsub.d">; | ||
| def FNMADD_D : FPFMAD_rrr_frm<OPC_NMADD, "fnmadd.d">; | ||
| def : FPFMADDynFrmAlias<FNMADD_D, "fnmadd.d">; | ||
|
|
||
| def FADD_D : FPALUD_rr_frm<0b0000001, "fadd.d">; | ||
| def : FPALUDDynFrmAlias<FADD_D, "fadd.d">; | ||
| def FSUB_D : FPALUD_rr_frm<0b0000101, "fsub.d">; | ||
| def : FPALUDDynFrmAlias<FSUB_D, "fsub.d">; | ||
| def FMUL_D : FPALUD_rr_frm<0b0001001, "fmul.d">; | ||
| def : FPALUDDynFrmAlias<FMUL_D, "fmul.d">; | ||
| def FDIV_D : FPALUD_rr_frm<0b0001101, "fdiv.d">; | ||
| def : FPALUDDynFrmAlias<FDIV_D, "fdiv.d">; | ||
|
|
||
| def FSQRT_D : FPUnaryOp_r_frm<0b0101101, FPR64, FPR64, "fsqrt.d"> { | ||
| let rs2 = 0b00000; | ||
| } | ||
| def : FPUnaryOpDynFrmAlias<FSQRT_D, "fsqrt.d", FPR64, FPR64>; | ||
|
|
||
| def FSGNJ_D : FPALUD_rr<0b0010001, 0b000, "fsgnj.d">; | ||
| def FSGNJN_D : FPALUD_rr<0b0010001, 0b001, "fsgnjn.d">; | ||
| def FSGNJX_D : FPALUD_rr<0b0010001, 0b010, "fsgnjx.d">; | ||
| def FMIN_D : FPALUD_rr<0b0010101, 0b000, "fmin.d">; | ||
| def FMAX_D : FPALUD_rr<0b0010101, 0b001, "fmax.d">; | ||
|
|
||
| def FCVT_S_D : FPUnaryOp_r_frm<0b0100000, FPR32, FPR64, "fcvt.s.d"> { | ||
| let rs2 = 0b00001; | ||
| } | ||
| def : FPUnaryOpDynFrmAlias<FCVT_S_D, "fcvt.s.d", FPR32, FPR64>; | ||
|
|
||
| def FCVT_D_S : FPUnaryOp_r<0b0100001, 0b000, FPR64, FPR32, "fcvt.d.s"> { | ||
| let rs2 = 0b00000; | ||
| } | ||
|
|
||
| def FEQ_D : FPCmpD_rr<0b010, "feq.d">; | ||
| def FLT_D : FPCmpD_rr<0b001, "flt.d">; | ||
| def FLE_D : FPCmpD_rr<0b000, "fle.d">; | ||
|
|
||
| def FCLASS_D : FPUnaryOp_r<0b1110001, 0b001, GPR, FPR64, "fclass.d"> { | ||
| let rs2 = 0b00000; | ||
| } | ||
|
|
||
| def FCVT_W_D : FPUnaryOp_r_frm<0b1100001, GPR, FPR64, "fcvt.w.d"> { | ||
| let rs2 = 0b00000; | ||
| } | ||
| def : FPUnaryOpDynFrmAlias<FCVT_W_D, "fcvt.w.d", GPR, FPR64>; | ||
|
|
||
| def FCVT_WU_D : FPUnaryOp_r_frm<0b1100001, GPR, FPR64, "fcvt.wu.d"> { | ||
| let rs2 = 0b00001; | ||
| } | ||
| def : FPUnaryOpDynFrmAlias<FCVT_WU_D, "fcvt.wu.d", GPR, FPR64>; | ||
|
|
||
| def FCVT_D_W : FPUnaryOp_r<0b1101001, 0b000, FPR64, GPR, "fcvt.d.w"> { | ||
| let rs2 = 0b00000; | ||
| } | ||
|
|
||
| def FCVT_D_WU : FPUnaryOp_r<0b1101001, 0b000, FPR64, GPR, "fcvt.d.wu"> { | ||
| let rs2 = 0b00001; | ||
| } | ||
| } // Predicates = [HasStdExtD] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| # RUN: not llvm-mc -triple riscv32 -mattr=+d < %s 2>&1 | FileCheck %s | ||
|
|
||
| # Out of range immediates | ||
| ## simm12 | ||
| fld ft1, -2049(a0) # CHECK: :[[@LINE]]:10: error: immediate must be an integer in the range [-2048, 2047] | ||
| fsd ft2, 2048(a1) # CHECK: :[[@LINE]]:10: error: immediate must be an integer in the range [-2048, 2047] | ||
|
|
||
| # Memory operand not formatted correctly | ||
| fld ft1, a0, -200 # CHECK: :[[@LINE]]:10: error: immediate must be an integer in the range [-2048, 2047] | ||
| fsd ft2, a1, 100 # CHECK: :[[@LINE]]:10: error: immediate must be an integer in the range [-2048, 2047] | ||
|
|
||
| # Invalid register names | ||
| fld ft15, 100(a0) # CHECK: :[[@LINE]]:5: error: invalid operand for instruction | ||
| fld ft1, 100(a10) # CHECK: :[[@LINE]]:14: error: expected register | ||
| fsgnjn.d fa100, fa2, fa3 # CHECK: :[[@LINE]]:10: error: invalid operand for instruction | ||
|
|
||
| # Integer registers where FP regs are expected | ||
| fadd.d a2, a1, a0 # CHECK: :[[@LINE]]:8: error: invalid operand for instruction | ||
|
|
||
| # FP registers where integer regs are expected | ||
| fcvt.wu.d ft2, a1 # CHECK: :[[@LINE]]:11: error: invalid operand for instruction |
Oops, something went wrong.