diff --git a/llvm/docs/RISCVUsage.rst b/llvm/docs/RISCVUsage.rst --- a/llvm/docs/RISCVUsage.rst +++ b/llvm/docs/RISCVUsage.rst @@ -279,3 +279,6 @@ ``XSfvcp`` LLVM implements `version 1.0.0 of the SiFive Vector Coprocessor Interface (VCIX) Software Specification `_ by SiFive. All instructions are prefixed with `sf.vc.` as described in the specification, and the riscv-toolchain-convention document linked above. + +``XCVmac`` + LLVM implements `version 1.3.1 of the Core-V Multiply-Accumulate (MAC) custom instructions specification `_ by Core-V. All instructions are prefixed with `cv.mac.` as described in the specification. These instructions are only available for riscv32 at this time. diff --git a/llvm/lib/Target/RISCV/Disassembler/RISCVDisassembler.cpp b/llvm/lib/Target/RISCV/Disassembler/RISCVDisassembler.cpp --- a/llvm/lib/Target/RISCV/Disassembler/RISCVDisassembler.cpp +++ b/llvm/lib/Target/RISCV/Disassembler/RISCVDisassembler.cpp @@ -558,6 +558,8 @@ "XTHeadVdot custom opcode table"); TRY_TO_DECODE_FEATURE(RISCV::FeatureVendorXSfvcp, DecoderTableXSfvcp32, "SiFive VCIX custom opcode table"); + TRY_TO_DECODE_FEATURE(RISCV::FeatureVendorXCVmac, DecoderTableXCVmac32, + "CORE-V MAC custom opcode table"); TRY_TO_DECODE(true, DecoderTable32, "RISCV32 table"); return MCDisassembler::Fail; diff --git a/llvm/lib/Target/RISCV/RISCVFeatures.td b/llvm/lib/Target/RISCV/RISCVFeatures.td --- a/llvm/lib/Target/RISCV/RISCVFeatures.td +++ b/llvm/lib/Target/RISCV/RISCVFeatures.td @@ -752,6 +752,13 @@ AssemblerPredicate<(all_of FeatureVendorXSfvcp), "'XSfvcp' (SiFive Custom Vector Coprocessor Interface Instructions)">; +def FeatureVendorXCVmac + : SubtargetFeature<"xcvmac", "HasVendorXCVmac", "true", + "'XCVmac' (Multiply-Accumulate)">; +def HasVendorXCVmac : Predicate<"Subtarget->hasVendorXCVmac()">, + AssemblerPredicate<(all_of FeatureVendorXCVmac), + "'XCVmac' (Multiply-Accumulate)">; + //===----------------------------------------------------------------------===// // LLVM specific features and extensions //===----------------------------------------------------------------------===// diff --git a/llvm/lib/Target/RISCV/RISCVInstrInfo.td b/llvm/lib/Target/RISCV/RISCVInstrInfo.td --- a/llvm/lib/Target/RISCV/RISCVInstrInfo.td +++ b/llvm/lib/Target/RISCV/RISCVInstrInfo.td @@ -1919,3 +1919,4 @@ include "RISCVInstrInfoXVentana.td" include "RISCVInstrInfoXTHead.td" include "RISCVInstrInfoXSf.td" +include "RISCVInstrInfoXCV.td" diff --git a/llvm/lib/Target/RISCV/RISCVInstrInfoXCV.td b/llvm/lib/Target/RISCV/RISCVInstrInfoXCV.td new file mode 100644 --- /dev/null +++ b/llvm/lib/Target/RISCV/RISCVInstrInfoXCV.td @@ -0,0 +1,125 @@ +//===-- RISCVInstrInfoXCV.td - CORE-V instructions ---------*- tablegen -*-===// +// +// 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 +// +//===----------------------------------------------------------------------===// +// +// This file describes the vendor extensions defined by Core-V extension. +// +//===----------------------------------------------------------------------===// + +class CVInstMac funct7, bits<3> funct3, dag outs, dag ins, + string opcodestr, string argstr, list pattern> + : RVInst { + 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; + let Opcode = OPC_CUSTOM_1.Value; + let DecoderNamespace = "XCVmac"; +} + +class CVInstMac16I funct2, bits<3> funct3, dag outs, dag ins, + string opcodestr, string argstr, list pattern> + : RVInst { + bits<5> imm5; + bits<5> rs2; + bits<5> rs1; + bits<5> rd; + + let Inst{31-30} = funct2; + let Inst{29-25} = imm5; + let Inst{24-20} = rs2; + let Inst{19-15} = rs1; + let Inst{14-12} = funct3; + let Inst{11-7} = rd; + let Opcode = OPC_CUSTOM_2.Value; + let DecoderNamespace = "XCVmac"; +} + +let Predicates = [HasVendorXCVmac, IsRV32], hasSideEffects = 0, mayLoad = 0, mayStore = 0, Constraints = "$rd = $rd_wb" in { + // 32x32 bit macs + def CV_MAC : CVInstMac<0b1001000, 0b011, (outs GPR:$rd_wb), (ins GPR:$rd, GPR:$rs1, GPR:$rs2), + "cv.mac", "$rd, $rs1, $rs2", []>, + Sched<[]>; + def CV_MSU : CVInstMac<0b1001001, 0b011, (outs GPR:$rd_wb), (ins GPR:$rd, GPR:$rs1, GPR:$rs2), + "cv.msu", "$rd, $rs1, $rs2", []>, + Sched<[]>; + + // Signed 16x16 bit macs with imm + def CV_MACSN : CVInstMac16I<0b00, 0b110, (outs GPR:$rd_wb), (ins GPR:$rd, GPR:$rs1, GPR:$rs2, uimm5:$imm5), + "cv.macsn", "$rd, $rs1, $rs2, $imm5", []>, + Sched<[]>; + def CV_MACHHSN : CVInstMac16I<0b01, 0b110, (outs GPR:$rd_wb), (ins GPR:$rd, GPR:$rs1, GPR:$rs2, uimm5:$imm5), + "cv.machhsn", "$rd, $rs1, $rs2, $imm5", []>, + Sched<[]>; + def CV_MACSRN : CVInstMac16I<0b10, 0b110, (outs GPR:$rd_wb), (ins GPR:$rd, GPR:$rs1, GPR:$rs2, uimm5:$imm5), + "cv.macsrn", "$rd, $rs1, $rs2, $imm5", []>, + Sched<[]>; + def CV_MACHHSRN : CVInstMac16I<0b11, 0b110, (outs GPR:$rd_wb), (ins GPR:$rd, GPR:$rs1, GPR:$rs2, uimm5:$imm5), + "cv.machhsrn", "$rd, $rs1, $rs2, $imm5", []>, + Sched<[]>; + + // Unsigned 16x16 bit macs with imm + def CV_MACUN : CVInstMac16I<0b00, 0b111, (outs GPR:$rd_wb), (ins GPR:$rd, GPR:$rs1, GPR:$rs2, uimm5:$imm5), + "cv.macun", "$rd, $rs1, $rs2, $imm5", []>, + Sched<[]>; + def CV_MACHHUN : CVInstMac16I<0b01, 0b111, (outs GPR:$rd_wb), (ins GPR:$rd, GPR:$rs1, GPR:$rs2, uimm5:$imm5), + "cv.machhun", "$rd, $rs1, $rs2, $imm5", []>, + Sched<[]>; + def CV_MACURN : CVInstMac16I<0b10, 0b111, (outs GPR:$rd_wb), (ins GPR:$rd, GPR:$rs1, GPR:$rs2, uimm5:$imm5), + "cv.macurn", "$rd, $rs1, $rs2, $imm5", []>, + Sched<[]>; + def CV_MACHHURN : CVInstMac16I<0b11, 0b111, (outs GPR:$rd_wb), (ins GPR:$rd, GPR:$rs1, GPR:$rs2, uimm5:$imm5), + "cv.machhurn", "$rd, $rs1, $rs2, $imm5", []>, + Sched<[]>; +} // Predicates = [HasVendorXCVmac, IsRV32], hasSideEffects = 0, mayLoad = 0, mayStore = 0, Constraints = "$rd = $rd_wb" + +let Predicates = [HasVendorXCVmac, IsRV32], hasSideEffects = 0, mayLoad = 0, mayStore = 0 in { + // Signed 16x16 bit muls with imm + def CV_MULSN : CVInstMac16I<0b00, 0b100, (outs GPR:$rd), (ins GPR:$rs1, GPR:$rs2, uimm5:$imm5), + "cv.mulsn", "$rd, $rs1, $rs2, $imm5", []>, + Sched<[]>; + def CV_MULHHSN : CVInstMac16I<0b01, 0b100, (outs GPR:$rd), (ins GPR:$rs1, GPR:$rs2, uimm5:$imm5), + "cv.mulhhsn", "$rd, $rs1, $rs2, $imm5", []>, + Sched<[]>; + def CV_MULSRN : CVInstMac16I<0b10, 0b100, (outs GPR:$rd), (ins GPR:$rs1, GPR:$rs2, uimm5:$imm5), + "cv.mulsrn", "$rd, $rs1, $rs2, $imm5", []>, + Sched<[]>; + def CV_MULHHSRN : CVInstMac16I<0b11, 0b100, (outs GPR:$rd), (ins GPR:$rs1, GPR:$rs2, uimm5:$imm5), + "cv.mulhhsrn", "$rd, $rs1, $rs2, $imm5", []>, + Sched<[]>; + + + // Unsigned 16x16 bit muls with imm + def CV_MULUN : CVInstMac16I<0b00, 0b101, (outs GPR:$rd), (ins GPR:$rs1, GPR:$rs2, uimm5:$imm5), + "cv.mulun", "$rd, $rs1, $rs2, $imm5", []>, + Sched<[]>; + def CV_MULHHUN : CVInstMac16I<0b01, 0b101, (outs GPR:$rd), (ins GPR:$rs1, GPR:$rs2, uimm5:$imm5), + "cv.mulhhun", "$rd, $rs1, $rs2, $imm5", []>, + Sched<[]>; + def CV_MULURN : CVInstMac16I<0b10, 0b101, (outs GPR:$rd), (ins GPR:$rs1, GPR:$rs2, uimm5:$imm5), + "cv.mulurn", "$rd, $rs1, $rs2, $imm5", []>, + Sched<[]>; + def CV_MULHHURN : CVInstMac16I<0b11, 0b101, (outs GPR:$rd), (ins GPR:$rs1, GPR:$rs2, uimm5:$imm5), + "cv.mulhhurn", "$rd, $rs1, $rs2, $imm5", []>, + Sched<[]>; +} // Predicates = [HasVendorXCVmac, IsRV32], hasSideEffects = 0, mayLoad = 0, mayStore = 0 + +let Predicates = [HasVendorXCVmac, IsRV32] in { + // Xcvmac Pseudo Instructions + // Signed 16x16 bit muls + def : InstAlias<"cv.muls $rd1, $rs1, $rs2", (CV_MULSN GPR:$rd1, GPR:$rs1, GPR:$rs2, 0)>; + def : InstAlias<"cv.mulhhs $rd1, $rs1, $rs2", (CV_MULHHSN GPR:$rd1, GPR:$rs1, GPR:$rs2, 0)>; + + // Unsigned 16x16 bit muls + def : InstAlias<"cv.mulu $rd1, $rs1, $rs2", (CV_MULUN GPR:$rd1, GPR:$rs1, GPR:$rs2, 0)>; + def : InstAlias<"cv.mulhhu $rd1, $rs1, $rs2", (CV_MULHHUN GPR:$rd1, GPR:$rs1, GPR:$rs2, 0)>; +} // Predicates = [HasVendorXCVmac, IsRV32] diff --git a/llvm/test/MC/RISCV/corev/XCVmac-invalid.s b/llvm/test/MC/RISCV/corev/XCVmac-invalid.s new file mode 100644 --- /dev/null +++ b/llvm/test/MC/RISCV/corev/XCVmac-invalid.s @@ -0,0 +1,476 @@ +# RUN: not llvm-mc -triple=riscv32 --mattr=+xcvmac %s 2>&1 \ +# RUN: | FileCheck %s --check-prefixes=CHECK-ERROR + +cv.mac t0, t1, 0 +# CHECK-ERROR: invalid operand for instruction + +cv.mac t0, 0, t2 +# CHECK-ERROR: invalid operand for instruction + +cv.mac 0, t1, t2 +# CHECK-ERROR: invalid operand for instruction + +cv.mac t0, t1 +# CHECK-ERROR: too few operands for instruction + +cv.mac t0, t1, t2, t4 +# CHECK-ERROR: invalid operand for instruction + +cv.machhsn t0, t1, t2, -1 +# CHECK-ERROR: immediate must be an integer in the range [0, 31] + +cv.machhsn t0, t1, t2, 32 +# CHECK-ERROR: immediate must be an integer in the range [0, 31] + +cv.machhsn t0, t1, t2, a0 +# CHECK-ERROR: immediate must be an integer in the range [0, 31] + +cv.machhsn t0, t1, 0, 0 +# CHECK-ERROR: invalid operand for instruction + +cv.machhsn t0, 0, t2, 0 +# CHECK-ERROR: invalid operand for instruction + +cv.machhsn 0, t1, t2, 0 +# CHECK-ERROR: invalid operand for instruction + +cv.machhsn t0, t1, t2 +# CHECK-ERROR: too few operands for instruction + +cv.machhsn t0, t1, t2, 0, a0 +# CHECK-ERROR: invalid operand for instruction + +cv.machhsrn t0, t1, t2, -1 +# CHECK-ERROR: immediate must be an integer in the range [0, 31] + +cv.machhsrn t0, t1, t2, 32 +# CHECK-ERROR: immediate must be an integer in the range [0, 31] + +cv.machhsrn t0, t1, t2, a0 +# CHECK-ERROR: immediate must be an integer in the range [0, 31] + +cv.machhsrn t0, t1, 0, 0 +# CHECK-ERROR: invalid operand for instruction + +cv.machhsrn t0, 0, t2, 0 +# CHECK-ERROR: invalid operand for instruction + +cv.machhsrn 0, t1, t2, 0 +# CHECK-ERROR: invalid operand for instruction + +cv.machhsrn t0, t1, t2 +# CHECK-ERROR: too few operands for instruction + +cv.machhsrn t0, t1, t2, 0, a0 +# CHECK-ERROR: invalid operand for instruction + +cv.machhun t0, t1, t2, -1 +# CHECK-ERROR: immediate must be an integer in the range [0, 31] + +cv.machhun t0, t1, t2, 32 +# CHECK-ERROR: immediate must be an integer in the range [0, 31] + +cv.machhun t0, t1, t2, a0 +# CHECK-ERROR: immediate must be an integer in the range [0, 31] + +cv.machhun t0, t1, 0, 0 +# CHECK-ERROR: invalid operand for instruction + +cv.machhun t0, 0, t2, 0 +# CHECK-ERROR: invalid operand for instruction + +cv.machhun 0, t1, t2, 0 +# CHECK-ERROR: invalid operand for instruction + +cv.machhun t0, t1, t2 +# CHECK-ERROR: too few operands for instruction + +cv.machhun t0, t1, t2, 0, a0 +# CHECK-ERROR: invalid operand for instruction + +cv.machhurn t0, t1, t2, -1 +# CHECK-ERROR: immediate must be an integer in the range [0, 31] + +cv.machhurn t0, t1, t2, 32 +# CHECK-ERROR: immediate must be an integer in the range [0, 31] + +cv.machhurn t0, t1, t2, a0 +# CHECK-ERROR: immediate must be an integer in the range [0, 31] + +cv.machhurn t0, t1, 0, 0 +# CHECK-ERROR: invalid operand for instruction + +cv.machhurn t0, 0, t2, 0 +# CHECK-ERROR: invalid operand for instruction + +cv.machhurn 0, t1, t2, 0 +# CHECK-ERROR: invalid operand for instruction + +cv.machhurn t0, t1, t2 +# CHECK-ERROR: too few operands for instruction + +cv.machhurn t0, t1, t2, 0, a0 +# CHECK-ERROR: invalid operand for instruction + +cv.macsn t0, t1, t2, -1 +# CHECK-ERROR: immediate must be an integer in the range [0, 31] + +cv.macsn t0, t1, t2, 32 +# CHECK-ERROR: immediate must be an integer in the range [0, 31] + +cv.macsn t0, t1, t2, a0 +# CHECK-ERROR: immediate must be an integer in the range [0, 31] + +cv.macsn t0, t1, 0, 0 +# CHECK-ERROR: invalid operand for instruction + +cv.macsn t0, 0, t2, 0 +# CHECK-ERROR: invalid operand for instruction + +cv.macsn 0, t1, t2, 0 +# CHECK-ERROR: invalid operand for instruction + +cv.macsn t0, t1, t2 +# CHECK-ERROR: too few operands for instruction + +cv.macsn t0, t1, t2, 0, a0 +# CHECK-ERROR: invalid operand for instruction + +cv.macsrn t0, t1, t2, -1 +# CHECK-ERROR: immediate must be an integer in the range [0, 31] + +cv.macsrn t0, t1, t2, 32 +# CHECK-ERROR: immediate must be an integer in the range [0, 31] + +cv.macsrn t0, t1, t2, a0 +# CHECK-ERROR: immediate must be an integer in the range [0, 31] + +cv.macsrn t0, t1, 0, 0 +# CHECK-ERROR: invalid operand for instruction + +cv.macsrn t0, 0, t2, 0 +# CHECK-ERROR: invalid operand for instruction + +cv.macsrn 0, t1, t2, 0 +# CHECK-ERROR: invalid operand for instruction + +cv.macsrn t0, t1, t2 +# CHECK-ERROR: too few operands for instruction + +cv.macsrn t0, t1, t2, 0, a0 +# CHECK-ERROR: invalid operand for instruction + +cv.macun t0, t1, t2, -1 +# CHECK-ERROR: immediate must be an integer in the range [0, 31] + +cv.macun t0, t1, t2, 32 +# CHECK-ERROR: immediate must be an integer in the range [0, 31] + +cv.macun t0, t1, t2, a0 +# CHECK-ERROR: immediate must be an integer in the range [0, 31] + +cv.macun t0, t1, 0, 0 +# CHECK-ERROR: invalid operand for instruction + +cv.macun t0, 0, t2, 0 +# CHECK-ERROR: invalid operand for instruction + +cv.macun 0, t1, t2, 0 +# CHECK-ERROR: invalid operand for instruction + +cv.macun t0, t1, t2 +# CHECK-ERROR: too few operands for instruction + +cv.macun t0, t1, t2, 0, a0 +# CHECK-ERROR: invalid operand for instruction + +cv.macurn t0, t1, t2, -1 +# CHECK-ERROR: immediate must be an integer in the range [0, 31] + +cv.macurn t0, t1, t2, 32 +# CHECK-ERROR: immediate must be an integer in the range [0, 31] + +cv.macurn t0, t1, t2, a0 +# CHECK-ERROR: immediate must be an integer in the range [0, 31] + +cv.macurn t0, t1, 0, 0 +# CHECK-ERROR: invalid operand for instruction + +cv.macurn t0, 0, t2, 0 +# CHECK-ERROR: invalid operand for instruction + +cv.macurn 0, t1, t2, 0 +# CHECK-ERROR: invalid operand for instruction + +cv.macurn t0, t1, t2 +# CHECK-ERROR: too few operands for instruction + +cv.macurn t0, t1, t2, 0, a0 +# CHECK-ERROR: invalid operand for instruction + +cv.msu t0, t1, 0 +# CHECK-ERROR: invalid operand for instruction + +cv.msu t0, 0, t2 +# CHECK-ERROR: invalid operand for instruction + +cv.msu 0, t1, t2 +# CHECK-ERROR: invalid operand for instruction + +cv.msu t0, t1 +# CHECK-ERROR: too few operands for instruction + +cv.msu t0, t1, t2, t4 +# CHECK-ERROR: invalid operand for instruction + +cv.mulhhs t0, t1, 0 +# CHECK-ERROR: invalid operand for instruction + +cv.mulhhs t0, 0, t2 +# CHECK-ERROR: invalid operand for instruction + +cv.mulhhs 0, t1, t2 +# CHECK-ERROR: invalid operand for instruction + +cv.mulhhs t0, t1 +# CHECK-ERROR: too few operands for instruction + +cv.mulhhs t0, t1, t2, t4 +# CHECK-ERROR: invalid operand for instruction + +cv.mulhhsn t0, t1, t2, -1 +# CHECK-ERROR: immediate must be an integer in the range [0, 31] + +cv.mulhhsn t0, t1, t2, 32 +# CHECK-ERROR: immediate must be an integer in the range [0, 31] + +cv.mulhhsn t0, t1, t2, a0 +# CHECK-ERROR: immediate must be an integer in the range [0, 31] + +cv.mulhhsn t0, t1, 0, 0 +# CHECK-ERROR: invalid operand for instruction + +cv.mulhhsn t0, 0, t2, 0 +# CHECK-ERROR: invalid operand for instruction + +cv.mulhhsn 0, t1, t2, 0 +# CHECK-ERROR: invalid operand for instruction + +cv.mulhhsn t0, t1, t2 +# CHECK-ERROR: too few operands for instruction + +cv.mulhhsn t0, t1, t2, 0, a0 +# CHECK-ERROR: invalid operand for instruction + +cv.mulhhsrn t0, t1, t2, -1 +# CHECK-ERROR: immediate must be an integer in the range [0, 31] + +cv.mulhhsrn t0, t1, t2, 32 +# CHECK-ERROR: immediate must be an integer in the range [0, 31] + +cv.mulhhsrn t0, t1, t2, a0 +# CHECK-ERROR: immediate must be an integer in the range [0, 31] + +cv.mulhhsrn t0, t1, 0, 0 +# CHECK-ERROR: invalid operand for instruction + +cv.mulhhsrn t0, 0, t2, 0 +# CHECK-ERROR: invalid operand for instruction + +cv.mulhhsrn 0, t1, t2, 0 +# CHECK-ERROR: invalid operand for instruction + +cv.mulhhsrn t0, t1, t2 +# CHECK-ERROR: too few operands for instruction + +cv.mulhhsrn t0, t1, t2, 0, a0 +# CHECK-ERROR: invalid operand for instruction + +cv.mulhhu t0, t1, 0 +# CHECK-ERROR: invalid operand for instruction + +cv.mulhhu t0, 0, t2 +# CHECK-ERROR: invalid operand for instruction + +cv.mulhhu 0, t1, t2 +# CHECK-ERROR: invalid operand for instruction + +cv.mulhhu t0, t1 +# CHECK-ERROR: too few operands for instruction + +cv.mulhhu t0, t1, t2, t4 +# CHECK-ERROR: invalid operand for instruction + +cv.mulhhun t0, t1, t2, -1 +# CHECK-ERROR: immediate must be an integer in the range [0, 31] + +cv.mulhhun t0, t1, t2, 32 +# CHECK-ERROR: immediate must be an integer in the range [0, 31] + +cv.mulhhun t0, t1, t2, a0 +# CHECK-ERROR: immediate must be an integer in the range [0, 31] + +cv.mulhhun t0, t1, 0, 0 +# CHECK-ERROR: invalid operand for instruction + +cv.mulhhun t0, 0, t2, 0 +# CHECK-ERROR: invalid operand for instruction + +cv.mulhhun 0, t1, t2, 0 +# CHECK-ERROR: invalid operand for instruction + +cv.mulhhun t0, t1, t2 +# CHECK-ERROR: too few operands for instruction + +cv.mulhhun t0, t1, t2, 0, a0 +# CHECK-ERROR: invalid operand for instruction + +cv.mulhhurn t0, t1, t2, -1 +# CHECK-ERROR: immediate must be an integer in the range [0, 31] + +cv.mulhhurn t0, t1, t2, 32 +# CHECK-ERROR: immediate must be an integer in the range [0, 31] + +cv.mulhhurn t0, t1, t2, a0 +# CHECK-ERROR: immediate must be an integer in the range [0, 31] + +cv.mulhhurn t0, t1, 0, 0 +# CHECK-ERROR: invalid operand for instruction + +cv.mulhhurn t0, 0, t2, 0 +# CHECK-ERROR: invalid operand for instruction + +cv.mulhhurn 0, t1, t2, 0 +# CHECK-ERROR: invalid operand for instruction + +cv.mulhhurn t0, t1, t2 +# CHECK-ERROR: too few operands for instruction + +cv.mulhhurn t0, t1, t2, 0, a0 +# CHECK-ERROR: invalid operand for instruction + +cv.muls t0, t1, 0 +# CHECK-ERROR: invalid operand for instruction + +cv.muls t0, 0, t2 +# CHECK-ERROR: invalid operand for instruction + +cv.muls 0, t1, t2 +# CHECK-ERROR: invalid operand for instruction + +cv.muls t0, t1 +# CHECK-ERROR: too few operands for instruction + +cv.muls t0, t1, t2, t4 +# CHECK-ERROR: invalid operand for instruction + +cv.mulsn t0, t1, t2, -1 +# CHECK-ERROR: immediate must be an integer in the range [0, 31] + +cv.mulsn t0, t1, t2, 32 +# CHECK-ERROR: immediate must be an integer in the range [0, 31] + +cv.mulsn t0, t1, t2, a0 +# CHECK-ERROR: immediate must be an integer in the range [0, 31] + +cv.mulsn t0, t1, 0, 0 +# CHECK-ERROR: invalid operand for instruction + +cv.mulsn t0, 0, t2, 0 +# CHECK-ERROR: invalid operand for instruction + +cv.mulsn 0, t1, t2, 0 +# CHECK-ERROR: invalid operand for instruction + +cv.mulsn t0, t1, t2 +# CHECK-ERROR: too few operands for instruction + +cv.mulsn t0, t1, t2, 0, a0 +# CHECK-ERROR: invalid operand for instruction + +cv.mulsrn t0, t1, t2, -1 +# CHECK-ERROR: immediate must be an integer in the range [0, 31] + +cv.mulsrn t0, t1, t2, 32 +# CHECK-ERROR: immediate must be an integer in the range [0, 31] + +cv.mulsrn t0, t1, t2, a0 +# CHECK-ERROR: immediate must be an integer in the range [0, 31] + +cv.mulsrn t0, t1, 0, 0 +# CHECK-ERROR: invalid operand for instruction + +cv.mulsrn t0, 0, t2, 0 +# CHECK-ERROR: invalid operand for instruction + +cv.mulsrn 0, t1, t2, 0 +# CHECK-ERROR: invalid operand for instruction + +cv.mulsrn t0, t1, t2 +# CHECK-ERROR: too few operands for instruction + +cv.mulsrn t0, t1, t2, 0, a0 +# CHECK-ERROR: invalid operand for instruction + +cv.mulu t0, t1, 0 +# CHECK-ERROR: invalid operand for instruction + +cv.mulu t0, 0, t2 +# CHECK-ERROR: invalid operand for instruction + +cv.mulu 0, t1, t2 +# CHECK-ERROR: invalid operand for instruction + +cv.mulu t0, t1 +# CHECK-ERROR: too few operands for instruction + +cv.mulu t0, t1, t2, t4 +# CHECK-ERROR: invalid operand for instruction + +cv.mulun t0, t1, t2, -1 +# CHECK-ERROR: immediate must be an integer in the range [0, 31] + +cv.mulun t0, t1, t2, 32 +# CHECK-ERROR: immediate must be an integer in the range [0, 31] + +cv.mulun t0, t1, t2, a0 +# CHECK-ERROR: immediate must be an integer in the range [0, 31] + +cv.mulun t0, t1, 0, 0 +# CHECK-ERROR: invalid operand for instruction + +cv.mulun t0, 0, t2, 0 +# CHECK-ERROR: invalid operand for instruction + +cv.mulun 0, t1, t2, 0 +# CHECK-ERROR: invalid operand for instruction + +cv.mulun t0, t1, t2 +# CHECK-ERROR: too few operands for instruction + +cv.mulun t0, t1, t2, 0, a0 +# CHECK-ERROR: invalid operand for instruction + +cv.mulurn t0, t1, t2, -1 +# CHECK-ERROR: immediate must be an integer in the range [0, 31] + +cv.mulurn t0, t1, t2, 32 +# CHECK-ERROR: immediate must be an integer in the range [0, 31] + +cv.mulurn t0, t1, t2, a0 +# CHECK-ERROR: immediate must be an integer in the range [0, 31] + +cv.mulurn t0, t1, 0, 0 +# CHECK-ERROR: invalid operand for instruction + +cv.mulurn t0, 0, t2, 0 +# CHECK-ERROR: invalid operand for instruction + +cv.mulurn 0, t1, t2, 0 +# CHECK-ERROR: invalid operand for instruction + +cv.mulurn t0, t1, t2 +# CHECK-ERROR: too few operands for instruction + +cv.mulurn t0, t1, t2, 0, a0 +# CHECK-ERROR: invalid operand for instruction diff --git a/llvm/test/MC/RISCV/corev/XCVmac-valid.s b/llvm/test/MC/RISCV/corev/XCVmac-valid.s new file mode 100644 --- /dev/null +++ b/llvm/test/MC/RISCV/corev/XCVmac-valid.s @@ -0,0 +1,308 @@ +# RUN: llvm-mc -triple=riscv32 --mattr=+xcvmac -riscv-no-aliases -show-encoding %s \ +# RUN: | FileCheck %s --check-prefixes=CHECK-ENCODING,CHECK-INSTR +# RUN: llvm-mc -filetype=obj -triple=riscv32 -mattr=+xcvmac < %s \ +# RUN: | llvm-objdump --mattr=+xcvmac -M no-aliases -d -r - \ +# RUN: | FileCheck --check-prefix=CHECK-INSTR %s +# RUN: not llvm-mc -triple riscv32 %s 2>&1 \ +# RUN: | FileCheck -check-prefix=CHECK-NO-EXT %s + +cv.mac t0, t1, t2 +# CHECK-INSTR: cv.mac t0, t1, t2 +# CHECK-ENCODING: [0xab,0x32,0x73,0x90] +# CHECK-NO-EXT: instruction requires the following: 'XCVmac' (Multiply-Accumulate){{$}} + +cv.mac t0, t1, zero +# CHECK-INSTR: cv.mac t0, t1, zero +# CHECK-ENCODING: [0xab,0x32,0x03,0x90] +# CHECK-NO-EXT: instruction requires the following: 'XCVmac' (Multiply-Accumulate){{$}} + +cv.machhsn t0, t1, t2, 0 +# CHECK-INSTR: cv.machhsn t0, t1, t2, 0 +# CHECK-ENCODING: [0xdb,0x62,0x73,0x40] +# CHECK-NO-EXT: instruction requires the following: 'XCVmac' (Multiply-Accumulate){{$}} + +cv.machhsn t0, t1, zero, 16 +# CHECK-INSTR: cv.machhsn t0, t1, zero, 16 +# CHECK-ENCODING: [0xdb,0x62,0x03,0x60] +# CHECK-NO-EXT: instruction requires the following: 'XCVmac' (Multiply-Accumulate){{$}} + +cv.machhsn t0, t1, zero, 31 +# CHECK-INSTR: cv.machhsn t0, t1, zero, 31 +# CHECK-ENCODING: [0xdb,0x62,0x03,0x7e] +# CHECK-NO-EXT: instruction requires the following: 'XCVmac' (Multiply-Accumulate){{$}} + +cv.machhsrn t0, t1, t2, 0 +# CHECK-INSTR: cv.machhsrn t0, t1, t2, 0 +# CHECK-ENCODING: [0xdb,0x62,0x73,0xc0] +# CHECK-NO-EXT: instruction requires the following: 'XCVmac' (Multiply-Accumulate){{$}} + +cv.machhsrn t0, t1, zero, 16 +# CHECK-INSTR: cv.machhsrn t0, t1, zero, 16 +# CHECK-ENCODING: [0xdb,0x62,0x03,0xe0] +# CHECK-NO-EXT: instruction requires the following: 'XCVmac' (Multiply-Accumulate){{$}} + +cv.machhsrn t0, t1, zero, 31 +# CHECK-INSTR: cv.machhsrn t0, t1, zero, 31 +# CHECK-ENCODING: [0xdb,0x62,0x03,0xfe] +# CHECK-NO-EXT: instruction requires the following: 'XCVmac' (Multiply-Accumulate){{$}} + +cv.machhun t0, t1, t2, 0 +# CHECK-INSTR: cv.machhun t0, t1, t2, 0 +# CHECK-ENCODING: [0xdb,0x72,0x73,0x40] +# CHECK-NO-EXT: instruction requires the following: 'XCVmac' (Multiply-Accumulate){{$}} + +cv.machhun t0, t1, zero, 16 +# CHECK-INSTR: cv.machhun t0, t1, zero, 16 +# CHECK-ENCODING: [0xdb,0x72,0x03,0x60] +# CHECK-NO-EXT: instruction requires the following: 'XCVmac' (Multiply-Accumulate){{$}} + +cv.machhun t0, t1, zero, 31 +# CHECK-INSTR: cv.machhun t0, t1, zero, 31 +# CHECK-ENCODING: [0xdb,0x72,0x03,0x7e] +# CHECK-NO-EXT: instruction requires the following: 'XCVmac' (Multiply-Accumulate){{$}} + +cv.machhurn t0, t1, t2, 0 +# CHECK-INSTR: cv.machhurn t0, t1, t2, 0 +# CHECK-ENCODING: [0xdb,0x72,0x73,0xc0] +# CHECK-NO-EXT: instruction requires the following: 'XCVmac' (Multiply-Accumulate){{$}} + +cv.machhurn t0, t1, zero, 16 +# CHECK-INSTR: cv.machhurn t0, t1, zero, 16 +# CHECK-ENCODING: [0xdb,0x72,0x03,0xe0] +# CHECK-NO-EXT: instruction requires the following: 'XCVmac' (Multiply-Accumulate){{$}} + +cv.machhurn t0, t1, zero, 31 +# CHECK-INSTR: cv.machhurn t0, t1, zero, 31 +# CHECK-ENCODING: [0xdb,0x72,0x03,0xfe] +# CHECK-NO-EXT: instruction requires the following: 'XCVmac' (Multiply-Accumulate){{$}} + +cv.macsn t0, t1, t2, 0 +# CHECK-INSTR: cv.macsn t0, t1, t2, 0 +# CHECK-ENCODING: [0xdb,0x62,0x73,0x00] +# CHECK-NO-EXT: instruction requires the following: 'XCVmac' (Multiply-Accumulate){{$}} + +cv.macsn t0, t1, zero, 16 +# CHECK-INSTR: cv.macsn t0, t1, zero, 16 +# CHECK-ENCODING: [0xdb,0x62,0x03,0x20] +# CHECK-NO-EXT: instruction requires the following: 'XCVmac' (Multiply-Accumulate){{$}} + +cv.macsn t0, t1, zero, 31 +# CHECK-INSTR: cv.macsn t0, t1, zero, 31 +# CHECK-ENCODING: [0xdb,0x62,0x03,0x3e] +# CHECK-NO-EXT: instruction requires the following: 'XCVmac' (Multiply-Accumulate){{$}} + +cv.macsrn t0, t1, t2, 0 +# CHECK-INSTR: cv.macsrn t0, t1, t2, 0 +# CHECK-ENCODING: [0xdb,0x62,0x73,0x80] +# CHECK-NO-EXT: instruction requires the following: 'XCVmac' (Multiply-Accumulate){{$}} + +cv.macsrn t0, t1, zero, 16 +# CHECK-INSTR: cv.macsrn t0, t1, zero, 16 +# CHECK-ENCODING: [0xdb,0x62,0x03,0xa0] +# CHECK-NO-EXT: instruction requires the following: 'XCVmac' (Multiply-Accumulate){{$}} + +cv.macsrn t0, t1, zero, 31 +# CHECK-INSTR: cv.macsrn t0, t1, zero, 31 +# CHECK-ENCODING: [0xdb,0x62,0x03,0xbe] +# CHECK-NO-EXT: instruction requires the following: 'XCVmac' (Multiply-Accumulate){{$}} + +cv.macun t0, t1, t2, 0 +# CHECK-INSTR: cv.macun t0, t1, t2, 0 +# CHECK-ENCODING: [0xdb,0x72,0x73,0x00] +# CHECK-NO-EXT: instruction requires the following: 'XCVmac' (Multiply-Accumulate){{$}} + +cv.macun t0, t1, zero, 16 +# CHECK-INSTR: cv.macun t0, t1, zero, 16 +# CHECK-ENCODING: [0xdb,0x72,0x03,0x20] +# CHECK-NO-EXT: instruction requires the following: 'XCVmac' (Multiply-Accumulate){{$}} + +cv.macun t0, t1, zero, 31 +# CHECK-INSTR: cv.macun t0, t1, zero, 31 +# CHECK-ENCODING: [0xdb,0x72,0x03,0x3e] +# CHECK-NO-EXT: instruction requires the following: 'XCVmac' (Multiply-Accumulate){{$}} + +cv.macurn t0, t1, t2, 0 +# CHECK-INSTR: cv.macurn t0, t1, t2, 0 +# CHECK-ENCODING: [0xdb,0x72,0x73,0x80] +# CHECK-NO-EXT: instruction requires the following: 'XCVmac' (Multiply-Accumulate){{$}} + +cv.macurn t0, t1, zero, 16 +# CHECK-INSTR: cv.macurn t0, t1, zero, 16 +# CHECK-ENCODING: [0xdb,0x72,0x03,0xa0] +# CHECK-NO-EXT: instruction requires the following: 'XCVmac' (Multiply-Accumulate){{$}} + +cv.macurn t0, t1, zero, 31 +# CHECK-INSTR: cv.macurn t0, t1, zero, 31 +# CHECK-ENCODING: [0xdb,0x72,0x03,0xbe] +# CHECK-NO-EXT: instruction requires the following: 'XCVmac' (Multiply-Accumulate){{$}} + +cv.msu t0, t1, t2 +# CHECK-INSTR: cv.msu t0, t1, t2 +# CHECK-ENCODING: [0xab,0x32,0x73,0x92] +# CHECK-NO-EXT: instruction requires the following: 'XCVmac' (Multiply-Accumulate){{$}} + +cv.msu t0, t1, zero +# CHECK-INSTR: cv.msu t0, t1, zero +# CHECK-ENCODING: [0xab,0x32,0x03,0x92] +# CHECK-NO-EXT: instruction requires the following: 'XCVmac' (Multiply-Accumulate){{$}} + +cv.mulhhs t0, t1, t2 +# CHECK-INSTR: cv.mulhhsn t0, t1, t2, 0 +# CHECK-ENCODING: [0xdb,0x42,0x73,0x40] +# CHECK-NO-EXT: instruction requires the following: 'XCVmac' (Multiply-Accumulate){{$}} + +cv.mulhhs t0, t1, zero +# CHECK-INSTR: cv.mulhhsn t0, t1, zero, 0 +# CHECK-ENCODING: [0xdb,0x42,0x03,0x40] +# CHECK-NO-EXT: instruction requires the following: 'XCVmac' (Multiply-Accumulate){{$}} + +cv.mulhhsn t0, t1, t2, 0 +# CHECK-INSTR: cv.mulhhsn t0, t1, t2, 0 +# CHECK-ENCODING: [0xdb,0x42,0x73,0x40] +# CHECK-NO-EXT: instruction requires the following: 'XCVmac' (Multiply-Accumulate){{$}} + +cv.mulhhsn t0, t1, zero, 16 +# CHECK-INSTR: cv.mulhhsn t0, t1, zero, 16 +# CHECK-ENCODING: [0xdb,0x42,0x03,0x60] +# CHECK-NO-EXT: instruction requires the following: 'XCVmac' (Multiply-Accumulate){{$}} + +cv.mulhhsn t0, t1, zero, 31 +# CHECK-INSTR: cv.mulhhsn t0, t1, zero, 31 +# CHECK-ENCODING: [0xdb,0x42,0x03,0x7e] +# CHECK-NO-EXT: instruction requires the following: 'XCVmac' (Multiply-Accumulate){{$}} + +cv.mulhhsrn t0, t1, t2, 0 +# CHECK-INSTR: cv.mulhhsrn t0, t1, t2, 0 +# CHECK-ENCODING: [0xdb,0x42,0x73,0xc0] +# CHECK-NO-EXT: instruction requires the following: 'XCVmac' (Multiply-Accumulate){{$}} + +cv.mulhhsrn t0, t1, zero, 16 +# CHECK-INSTR: cv.mulhhsrn t0, t1, zero, 16 +# CHECK-ENCODING: [0xdb,0x42,0x03,0xe0] +# CHECK-NO-EXT: instruction requires the following: 'XCVmac' (Multiply-Accumulate){{$}} + +cv.mulhhsrn t0, t1, zero, 31 +# CHECK-INSTR: cv.mulhhsrn t0, t1, zero, 31 +# CHECK-ENCODING: [0xdb,0x42,0x03,0xfe] +# CHECK-NO-EXT: instruction requires the following: 'XCVmac' (Multiply-Accumulate){{$}} + +cv.mulhhu t0, t1, t2 +# CHECK-INSTR: cv.mulhhun t0, t1, t2, 0 +# CHECK-ENCODING: [0xdb,0x52,0x73,0x40] +# CHECK-NO-EXT: instruction requires the following: 'XCVmac' (Multiply-Accumulate){{$}} + +cv.mulhhu t0, t1, zero +# CHECK-INSTR: cv.mulhhun t0, t1, zero, 0 +# CHECK-ENCODING: [0xdb,0x52,0x03,0x40] +# CHECK-NO-EXT: instruction requires the following: 'XCVmac' (Multiply-Accumulate){{$}} + +cv.mulhhun t0, t1, t2, 0 +# CHECK-INSTR: cv.mulhhun t0, t1, t2, 0 +# CHECK-ENCODING: [0xdb,0x52,0x73,0x40] +# CHECK-NO-EXT: instruction requires the following: 'XCVmac' (Multiply-Accumulate){{$}} + + +cv.mulhhun t0, t1, zero, 16 +# CHECK-INSTR: cv.mulhhun t0, t1, zero, 16 +# CHECK-ENCODING: [0xdb,0x52,0x03,0x60] +# CHECK-NO-EXT: instruction requires the following: 'XCVmac' (Multiply-Accumulate){{$}} + +cv.mulhhun t0, t1, zero, 31 +# CHECK-INSTR: cv.mulhhun t0, t1, zero, 31 +# CHECK-ENCODING: [0xdb,0x52,0x03,0x7e] +# CHECK-NO-EXT: instruction requires the following: 'XCVmac' (Multiply-Accumulate){{$}} + +cv.mulhhurn t0, t1, t2, 0 +# CHECK-INSTR: cv.mulhhurn t0, t1, t2, 0 +# CHECK-ENCODING: [0xdb,0x52,0x73,0xc0] +# CHECK-NO-EXT: instruction requires the following: 'XCVmac' (Multiply-Accumulate){{$}} + +cv.mulhhurn t0, t1, zero, 16 +# CHECK-INSTR: cv.mulhhurn t0, t1, zero, 16 +# CHECK-ENCODING: [0xdb,0x52,0x03,0xe0] +# CHECK-NO-EXT: instruction requires the following: 'XCVmac' (Multiply-Accumulate){{$}} + +cv.mulhhurn t0, t1, zero, 31 +# CHECK-INSTR: cv.mulhhurn t0, t1, zero, 31 +# CHECK-ENCODING: [0xdb,0x52,0x03,0xfe] +# CHECK-NO-EXT: instruction requires the following: 'XCVmac' (Multiply-Accumulate){{$}} + +cv.muls t0, t1, t2 +# CHECK-INSTR: cv.mulsn t0, t1, t2, 0 +# CHECK-ENCODING: [0xdb,0x42,0x73,0x00] +# CHECK-NO-EXT: instruction requires the following: 'XCVmac' (Multiply-Accumulate){{$}} + +cv.muls t0, t1, zero +# CHECK-INSTR: cv.mulsn t0, t1, zero, 0 +# CHECK-ENCODING: [0xdb,0x42,0x03,0x00] +# CHECK-NO-EXT: instruction requires the following: 'XCVmac' (Multiply-Accumulate){{$}} + +cv.mulsn t0, t1, t2, 0 +# CHECK-INSTR: cv.mulsn t0, t1, t2, 0 +# CHECK-ENCODING: [0xdb,0x42,0x73,0x00] +# CHECK-NO-EXT: instruction requires the following: 'XCVmac' (Multiply-Accumulate){{$}} + +cv.mulsn t0, t1, zero, 16 +# CHECK-INSTR: cv.mulsn t0, t1, zero, 16 +# CHECK-ENCODING: [0xdb,0x42,0x03,0x20] +# CHECK-NO-EXT: instruction requires the following: 'XCVmac' (Multiply-Accumulate){{$}} + +cv.mulsn t0, t1, zero, 31 +# CHECK-INSTR: cv.mulsn t0, t1, zero, 31 +# CHECK-ENCODING: [0xdb,0x42,0x03,0x3e] +# CHECK-NO-EXT: instruction requires the following: 'XCVmac' (Multiply-Accumulate){{$}} + +cv.mulsrn t0, t1, t2, 0 +# CHECK-INSTR: cv.mulsrn t0, t1, t2, 0 +# CHECK-ENCODING: [0xdb,0x42,0x73,0x80] +# CHECK-NO-EXT: instruction requires the following: 'XCVmac' (Multiply-Accumulate){{$}} + +cv.mulsrn t0, t1, zero, 16 +# CHECK-INSTR: cv.mulsrn t0, t1, zero, 16 +# CHECK-ENCODING: [0xdb,0x42,0x03,0xa0] +# CHECK-NO-EXT: instruction requires the following: 'XCVmac' (Multiply-Accumulate){{$}} + +cv.mulsrn t0, t1, zero, 31 +# CHECK-INSTR: cv.mulsrn t0, t1, zero, 31 +# CHECK-ENCODING: [0xdb,0x42,0x03,0xbe] +# CHECK-NO-EXT: instruction requires the following: 'XCVmac' (Multiply-Accumulate){{$}} + +cv.mulu t0, t1, t2 +# CHECK-INSTR: cv.mulun t0, t1, t2, 0 +# CHECK-ENCODING: [0xdb,0x52,0x73,0x00] +# CHECK-NO-EXT: instruction requires the following: 'XCVmac' (Multiply-Accumulate){{$}} + +cv.mulu t0, t1, zero +# CHECK-INSTR: cv.mulun t0, t1, zero, 0 +# CHECK-ENCODING: [0xdb,0x52,0x03,0x00] +# CHECK-NO-EXT: instruction requires the following: 'XCVmac' (Multiply-Accumulate){{$}} + +cv.mulun t0, t1, t2, 0 +# CHECK-INSTR: cv.mulun t0, t1, t2, 0 +# CHECK-ENCODING: [0xdb,0x52,0x73,0x00] +# CHECK-NO-EXT: instruction requires the following: 'XCVmac' (Multiply-Accumulate){{$}} + +cv.mulun t0, t1, zero, 16 +# CHECK-INSTR: cv.mulun t0, t1, zero, 16 +# CHECK-ENCODING: [0xdb,0x52,0x03,0x20] +# CHECK-NO-EXT: instruction requires the following: 'XCVmac' (Multiply-Accumulate){{$}} + +cv.mulun t0, t1, zero, 31 +# CHECK-INSTR: cv.mulun t0, t1, zero, 31 +# CHECK-ENCODING: [0xdb,0x52,0x03,0x3e] +# CHECK-NO-EXT: instruction requires the following: 'XCVmac' (Multiply-Accumulate){{$}} + +cv.mulurn t0, t1, t2, 0 +# CHECK-INSTR: cv.mulurn t0, t1, t2, 0 +# CHECK-ENCODING: [0xdb,0x52,0x73,0x80] +# CHECK-NO-EXT: instruction requires the following: 'XCVmac' (Multiply-Accumulate){{$}} + +cv.mulurn t0, t1, zero, 16 +# CHECK-INSTR: cv.mulurn t0, t1, zero, 16 +# CHECK-ENCODING: [0xdb,0x52,0x03,0xa0] +# CHECK-NO-EXT: instruction requires the following: 'XCVmac' (Multiply-Accumulate){{$}} + +cv.mulurn t0, t1, zero, 31 +# CHECK-INSTR: cv.mulurn t0, t1, zero, 31 +# CHECK-ENCODING: [0xdb,0x52,0x03,0xbe] +# CHECK-NO-EXT: instruction requires the following: 'XCVmac' (Multiply-Accumulate){{$}}