diff --git a/llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp b/llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp --- a/llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp +++ b/llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp @@ -503,7 +503,23 @@ return false; return (isRV64() && isUInt<5>(Imm)) || isUInt<4>(Imm); } + bool isUImm2() const { + int64_t Imm; + RISCVMCExpr::VariantKind VK = RISCVMCExpr::VK_RISCV_None; + if (!isImm()) + return false; + bool IsConstantImm = evaluateConstantImm(getImm(), Imm, VK); + return IsConstantImm && isUInt<2>(Imm) && VK == RISCVMCExpr::VK_RISCV_None; + } + bool isUImm4() const { + int64_t Imm; + RISCVMCExpr::VariantKind VK = RISCVMCExpr::VK_RISCV_None; + if (!isImm()) + return false; + bool IsConstantImm = evaluateConstantImm(getImm(), Imm, VK); + return IsConstantImm && isUInt<4>(Imm) && VK == RISCVMCExpr::VK_RISCV_None; + } bool isUImm5() const { int64_t Imm; RISCVMCExpr::VariantKind VK = RISCVMCExpr::VK_RISCV_None; @@ -1044,6 +1060,10 @@ if (isRV64()) return generateImmOutOfRangeError(Operands, ErrorInfo, 0, (1 << 5) - 1); return generateImmOutOfRangeError(Operands, ErrorInfo, 0, (1 << 4) - 1); + case Match_InvalidUImm2: + return generateImmOutOfRangeError(Operands, ErrorInfo, 0, (1 << 2) - 1); + case Match_InvalidUImm4: + return generateImmOutOfRangeError(Operands, ErrorInfo, 0, (1 << 4) - 1); case Match_InvalidUImm5: return generateImmOutOfRangeError(Operands, ErrorInfo, 0, (1 << 5) - 1); case Match_InvalidSImm5: diff --git a/llvm/lib/Target/RISCV/MCTargetDesc/RISCVBaseInfo.h b/llvm/lib/Target/RISCV/MCTargetDesc/RISCVBaseInfo.h --- a/llvm/lib/Target/RISCV/MCTargetDesc/RISCVBaseInfo.h +++ b/llvm/lib/Target/RISCV/MCTargetDesc/RISCVBaseInfo.h @@ -111,7 +111,8 @@ namespace RISCVOp { enum OperandType : unsigned { OPERAND_FIRST_RISCV_IMM = MCOI::OPERAND_FIRST_TARGET, - OPERAND_UIMM4 = OPERAND_FIRST_RISCV_IMM, + OPERAND_UIMM2 = OPERAND_FIRST_RISCV_IMM, + OPERAND_UIMM4, OPERAND_UIMM5, OPERAND_UIMM12, OPERAND_SIMM12, diff --git a/llvm/lib/Target/RISCV/RISCV.td b/llvm/lib/Target/RISCV/RISCV.td --- a/llvm/lib/Target/RISCV/RISCV.td +++ b/llvm/lib/Target/RISCV/RISCV.td @@ -187,7 +187,13 @@ def HasStdExtZvamo : Predicate<"Subtarget->hasStdExtZvamo()">, AssemblerPredicate<(all_of FeatureExtZvamo), "'Zvamo'(Vector AMO Operations)">; - +def FeatureStdExtK + : SubtargetFeature<"experimental-k", "HasStdExtK", "true", + "'K' (Scalar Cryptography Instructions)">; +def HasStdExtK : Predicate<"Subtarget->hasStdExtK()">, + AssemblerPredicate<(all_of FeatureStdExtK), + "'K' (Scalar Cryptography Instructions)">; + def Feature64Bit : SubtargetFeature<"64bit", "HasRV64", "true", "Implements RV64">; def IsRV64 : Predicate<"Subtarget->is64Bit()">, 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 @@ -128,6 +128,21 @@ let OperandNamespace = "RISCVOp"; } +def uimm2 : Operand, ImmLeaf(Imm);}]> { + let ParserMatchClass = UImmAsmOperand<2>; + let DecoderMethod = "decodeUImmOperand<2>"; + let OperandType = "OPERAND_UIMM2"; + let OperandNamespace = "RISCVOp"; +} + +def uimm4 : Operand, ImmLeaf(Imm);}]> { + let ParserMatchClass = UImmAsmOperand<4>; + let EncoderMethod = "getImmOpValue"; + let DecoderMethod = "decodeUImmOperand<4>"; + let OperandType = "OPERAND_UIMM4"; + let OperandNamespace = "RISCVOp"; +} + def uimm5 : Operand, ImmLeaf(Imm);}]> { let ParserMatchClass = UImmAsmOperand<5>; let DecoderMethod = "decodeUImmOperand<5>"; @@ -1260,4 +1275,5 @@ include "RISCVInstrInfoC.td" include "RISCVInstrInfoB.td" include "RISCVInstrInfoV.td" +include "RISCVInstrInfoK.td" include "RISCVInstrInfoZfh.td" diff --git a/llvm/lib/Target/RISCV/RISCVInstrInfoK.td b/llvm/lib/Target/RISCV/RISCVInstrInfoK.td new file mode 100644 --- /dev/null +++ b/llvm/lib/Target/RISCV/RISCVInstrInfoK.td @@ -0,0 +1,132 @@ +//===-- RISCVInstrInfoK.td - RISC-V 'K' 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 RISC-K instructions from the standard 'K' +/// scalar cryptography extension, version 0.8.1. +/// +//===----------------------------------------------------------------------===// + +//===----------------------------------------------------------------------===// +// Instruction class templates +//===----------------------------------------------------------------------===// + +let hasSideEffects = 0, mayLoad = 0, mayStore = 0 in { + // op rd, rs1 + class RVKUnary funct7, bits<5> funct5, bits<3> funct3, string opcodestr> + : RVInstR{ + let Inst{24-20} = funct5; + } + + // op rd rs1 rs2 + class RVKBinary funct7, bits<3> funct3, string opcodestr> + : RVInstR; + + // op rt rs2 bs + class RVKByteSelect funct5, string opcodestr> + : RVInstS<0b000, OPC_OP, (outs GPR:$rt), (ins GPR:$rs2, uimm2:$bs), + opcodestr, "$rt, $rs2, $bs">{ + bits<2> bs; + bits<5> rt; + + let Inst{31-30}=bs; + let Inst{29-25}=funct5; + let Inst{19-15}=rt; + let Inst{11-7}=0b00000; + } + // op rd rs1 rcon + class RVKUnary_rcon funct7, bits<3> funct3, string opcodestr> + : RVInstI { + bits<4> rcon; + + let Inst{31-25} = funct7; + let Inst{24} = 1; + let Inst{23-20} = rcon; + } + +} // hasSideEffects = 0, mayLoad = 0, mayStore = 0 + +let Predicates = [HasStdExtK] in { + // RVKUnary + def SHA256SUM0 : RVKUnary<0b0001000, 0b00000, 0b001, "sha256sum0">, + Sched<[]>; + def SHA256SUM1 : RVKUnary<0b0001000, 0b00001, 0b001, "sha256sum1">, + Sched<[]>; + def SHA256SIG0 : RVKUnary<0b0001000, 0b00010, 0b001, "sha256sig0">, + Sched<[]>; + def SHA256SIG1 : RVKUnary<0b0001000, 0b00011, 0b001, "sha256sig1">, + Sched<[]>; + def SM3P0 : RVKUnary<0b0001000, 0b01000, 0b001, "sm3p0">, + Sched<[]>; + def SM3P1 : RVKUnary<0b0001000, 0b01001, 0b001, "sm3p1">, + Sched<[]>; + //RVKByteSelect + def SM4ED : RVKByteSelect<0b11000, "sm4ed">, + Sched<[]>; + def SM4KS : RVKByteSelect<0b11010, "sm4ks">, + Sched<[]>; + // Pseudo Instructions + def GETNOISE : InstAlias<"getnoise $rd", (CSRRS GPR:$rd, MNOISE.Encoding, X0)>, + Sched<[]>; + def POLLENTROPY: InstAlias<"pollentropy $rd", (CSRRS GPR:$rd, MENTROPY.Encoding, X0)>, + Sched<[]>; +} // Predicates = [HasStdExtK] + +let Predicates = [HasStdExtK, IsRV32] in { + // RVKBinary + def SHA512SUM0R : RVKBinary<0b0101000, 0b000, "sha512sum0r">, + Sched<[]>; + def SHA512SUM1R : RVKBinary<0b0101001, 0b000, "sha512sum1r">, + Sched<[]>; + def SHA512SIG0L : RVKBinary<0b0101010, 0b000, "sha512sig0l">, + Sched<[]>; + def SHA512SIG0H : RVKBinary<0b0101110, 0b000, "sha512sig0h">, + Sched<[]>; + def SHA512SIG1L : RVKBinary<0b0101011, 0b000, "sha512sig1l">, + Sched<[]>; + def SHA512SIG1H : RVKBinary<0b0101111, 0b000, "sha512sig1h">, + Sched<[]>; + // RVKByteSelect + def AES32ESMI : RVKByteSelect<0b11011, "aes32esmi">, + Sched<[]>; + def AES32ESI : RVKByteSelect<0b11001, "aes32esi">, + Sched<[]>; + def AES32DSMI : RVKByteSelect<0b11111, "aes32dsmi">, + Sched<[]>; + def AES32DSI : RVKByteSelect<0b11101, "aes32dsi">, + Sched<[]>; +} // Predicates = [HasStdExtK, IsRV32] + +let Predicates = [HasStdExtK, IsRV64] in { + // RVK Unary + def SHA512SUM0 : RVKUnary<0b0001000, 0b00100, 0b001, "sha512sum0">, + Sched<[]>; + def SHA512SUM1 : RVKUnary<0b0001000, 0b00101, 0b001, "sha512sum1">, + Sched<[]>; + def SHA512SIG0 : RVKUnary<0b0001000, 0b00110, 0b001, "sha512sig0">, + Sched<[]>; + def SHA512SIG1 : RVKUnary<0b0001000, 0b00111, 0b001, "sha512sig1">, + Sched<[]>; + def AES64IM : RVKUnary<0b0011000, 0b00000, 0b001, "aes64im">, + Sched<[]>; + // RVK Binary + def AES64KS2 : RVKBinary<0b0111111, 0b000, "aes64ks2">, + Sched<[]>; + def AES64ESM : RVKBinary<0b0011011, 0b000, "aes64esm">, + Sched<[]>; + def AES64ES : RVKBinary<0b0011001, 0b000, "aes64es">, + Sched<[]>; + def AES64DSM : RVKBinary<0b0011111, 0b000, "aes64dsm">, + Sched<[]>; + def AES64DS : RVKBinary<0b0011101, 0b000, "aes64ds">, + Sched<[]>; + // RVKUnary_rcon + def AES64KS1I : RVKUnary_rcon<0b0011000, 0b001, "aes64ks1i">, + Sched<[]>; +} // Predicates = [HasStdExtK, IsRV64] \ No newline at end of file diff --git a/llvm/lib/Target/RISCV/RISCVSubtarget.h b/llvm/lib/Target/RISCV/RISCVSubtarget.h --- a/llvm/lib/Target/RISCV/RISCVSubtarget.h +++ b/llvm/lib/Target/RISCV/RISCVSubtarget.h @@ -52,6 +52,7 @@ bool HasStdExtZbt = false; bool HasStdExtZbproposedc = false; bool HasStdExtV = false; + bool HasStdExtK = false; bool HasStdExtZvlsseg = false; bool HasStdExtZvamo = false; bool HasStdExtZfh = false; @@ -119,6 +120,7 @@ bool hasStdExtZbt() const { return HasStdExtZbt; } bool hasStdExtZbproposedc() const { return HasStdExtZbproposedc; } bool hasStdExtV() const { return HasStdExtV; } + bool hasStdExtK() const { return HasStdExtK; } bool hasStdExtZvlsseg() const { return HasStdExtZvlsseg; } bool hasStdExtZvamo() const { return HasStdExtZvamo; } bool hasStdExtZfh() const { return HasStdExtZfh; } diff --git a/llvm/lib/Target/RISCV/RISCVSystemOperands.td b/llvm/lib/Target/RISCV/RISCVSystemOperands.td --- a/llvm/lib/Target/RISCV/RISCVSystemOperands.td +++ b/llvm/lib/Target/RISCV/RISCVSystemOperands.td @@ -372,3 +372,9 @@ def : SysReg<"vl", 0xC20>; def : SysReg<"vtype", 0xC21>; def : SysReg<"vlenb", 0xC22>; + +//===----------------------------------------------- +// K ext CSRs +//===----------------------------------------------- +def MENTROPY : SysReg<"mentropy", 0xF15>; +def MNOISE : SysReg<"mnoise", 0x7A9>; diff --git a/llvm/test/MC/RISCV/rvk/rv32k.s b/llvm/test/MC/RISCV/rvk/rv32k.s new file mode 100644 --- /dev/null +++ b/llvm/test/MC/RISCV/rvk/rv32k.s @@ -0,0 +1,143 @@ +# RUN: llvm-mc -triple=riscv32 -show-encoding --mattr=+experimental-k %s \ +# RUN: | FileCheck %s --check-prefixes=CHECK-ENCODING,CHECK-INST +# RUN: not llvm-mc -triple=riscv32 -show-encoding %s 2>&1 \ +# RUN: | FileCheck %s --check-prefix=CHECK-ERROR +# RUN: llvm-mc -triple=riscv32 -filetype=obj --mattr=+experimental-k %s \ +# RUN: | llvm-objdump -d --mattr=+experimental-k - \ +# RUN: | FileCheck %s --check-prefix=CHECK-INST +# RUN: llvm-mc -triple=riscv32 -filetype=obj --mattr=+experimental-k %s \ +# RUN: | llvm-objdump -d - | FileCheck %s --check-prefix=CHECK-UNKNOWN + +sha256sum0 a0, a1 +# CHECK-INST: sha256sum0 a0, a1 +# CHECK-ENCODING: [0x13,0x95,0x05,0x10] +# CHECK-ERROR: instruction requires the following: 'K' (Scalar Cryptography Instructions) +# CHECK-UNKNOWN: 13 95 05 10 + +sha256sum1 a0, a1 +# CHECK-INST: sha256sum1 a0, a1 +# CHECK-ENCODING: [0x13,0x95,0x15,0x10] +# CHECK-ERROR: instruction requires the following: 'K' (Scalar Cryptography Instructions) +# CHECK-UNKNOWN: 13 95 15 10 + +sha256sig0 a0, a1 +# CHECK-INST: sha256sig0 a0, a1 +# CHECK-ENCODING: [0x13,0x95,0x25,0x10] +# CHECK-ERROR: instruction requires the following: 'K' (Scalar Cryptography Instructions) +# CHECK-UNKNOWN: 13 95 25 10 + +sha256sig1 a0, a1 +# CHECK-INST: sha256sig1 a0, a1 +# CHECK-ENCODING: [0x13,0x95,0x35,0x10] +# CHECK-ERROR: instruction requires the following: 'K' (Scalar Cryptography Instructions) +# CHECK-UNKNOWN: 13 95 35 10 + +sm3p0 a0, a1 +# CHECK-INST: sm3p0 a0, a1 +# CHECK-ENCODING: [0x13,0x95,0x85,0x10] +# CHECK-ERROR: instruction requires the following: 'K' (Scalar Cryptography Instructions) +# CHECK-UNKNOWN: 13 95 85 10 + +sm3p1 a0, a1 +# CHECK-INST: sm3p1 a0, a1 +# CHECK-ENCODING: [0x13,0x95,0x95,0x10] +# CHECK-ERROR: instruction requires the following: 'K' (Scalar Cryptography Instructions) +# CHECK-UNKNOWN: 13 95 95 10 + +getnoise a0 +# CHECK-INST: csrr a0, mnoise +# CHECK-ENCODING: [0x73,0x25,0x90,0x7a] +# CHECK-ERROR: instruction requires the following: 'K' (Scalar Cryptography Instructions) +# CHECK-UNKNOWN: 73 25 90 7a + +pollentropy a0 +# CHECK-INST: csrr a0, mentropy +# CHECK-ENCODING: [0x73,0x25,0x50,0xf1] +# CHECK-ERROR: instruction requires the following: 'K' (Scalar Cryptography Instructions) +# CHECK-UNKNOWN: 73 25 50 f1 + +# RV32 only + +sha512sum0r a0, a1, a2 +# CHECK-INST: sha512sum0r a0, a1, a2 +# CHECK-ENCODING: [0x33,0x85,0xc5,0x50] +# CHECK-ERROR: instruction requires the following: 'K' (Scalar Cryptography Instructions) +# CHECK-UNKNOWN: 33 85 c5 50 + +sha512sum1r a0, a1, a2 +# CHECK-INST: sha512sum1r a0, a1, a2 +# CHECK-ENCODING: [0x33,0x85,0xc5,0x52] +# CHECK-ERROR: instruction requires the following: 'K' (Scalar Cryptography Instructions) +# CHECK-UNKNOWN: 33 85 c5 52 + +sha512sig0l a0, a1, a2 +# CHECK-INST: sha512sig0l a0, a1, a2 +# CHECK-ENCODING: [0x33,0x85,0xc5,0x54] +# CHECK-ERROR: instruction requires the following: 'K' (Scalar Cryptography Instructions) +# CHECK-UNKNOWN: 33 85 c5 54 + +sha512sig0h a0, a1, a2 +# CHECK-INST: sha512sig0h a0, a1, a2 +# CHECK-ENCODING: [0x33,0x85,0xc5,0x5c] +# CHECK-ERROR: instruction requires the following: 'K' (Scalar Cryptography Instructions) +# CHECK-UNKNOWN: 33 85 c5 5c + +sha512sig1l a0, a1, a2 +# CHECK-INST: sha512sig1l a0, a1, a2 +# CHECK-ENCODING: [0x33,0x85,0xc5,0x56] +# CHECK-ERROR: instruction requires the following: 'K' (Scalar Cryptography Instructions) +# CHECK-UNKNOWN: 33 85 c5 56 + +sha512sig1h a0, a1, a2 +# CHECK-INST: sha512sig1h a0, a1, a2 +# CHECK-ENCODING: [0x33,0x85,0xc5,0x5e] +# CHECK-ERROR: instruction requires the following: 'K' (Scalar Cryptography Instructions) +# CHECK-UNKNOWN: 33 85 c5 5e + +getnoise a0 +# CHECK-INST: csrr a0, mnoise +# CHECK-ENCODING: [0x73,0x25,0x90,0x7a] +# CHECK-ERROR: instruction requires the following: 'K' (Scalar Cryptography Instructions) +# CHECK-UNKNOWN: 73 25 90 7a csrr a0, mnoise + +pollentropy a0 +# CHECK-INST: csrr a0, mentropy +# CHECK-ENCODING: [0x73,0x25,0x50,0xf1] +# CHECK-ERROR: instruction requires the following: 'K' (Scalar Cryptography Instructions) +# CHECK-UNKNOWN: 73 25 50 f1 csrr a0, mentropy + +sm4ed t0, a2, 3 +# CHECK-INST: sm4ed t0, a2, 3 +# CHECK-ENCODING: [0x33,0x80,0xc2,0xf0] +# CHECK-ERROR: instruction requires the following: 'K' (Scalar Cryptography Instructions) +# CHECK-UNKNOWN: 33 80 c2 f0 + +sm4ks t0, a2, 3 +# CHECK-INST: sm4ks t0, a2, 3 +# CHECK-ENCODING: [0x33,0x80,0xc2,0xf4] +# CHECK-ERROR: instruction requires the following: 'K' (Scalar Cryptography Instructions) +# CHECK-UNKNOWN: 33 80 c2 f4 + +aes32esmi t0, a2, 3 +# CHECK-INST: aes32esmi t0, a2, 3 +# CHECK-ENCODING: [0x33,0x80,0xc2,0xf6] +# CHECK-ERROR: instruction requires the following: 'K' (Scalar Cryptography Instructions) +# CHECK-UNKNOWN: 33 80 c2 f6 + +aes32esi t0, a2, 3 +# CHECK-INST: aes32esi t0, a2, 3 +# CHECK-ENCODING: [0x33,0x80,0xc2,0xf2] +# CHECK-ERROR: instruction requires the following: 'K' (Scalar Cryptography Instructions) +# CHECK-UNKNOWN: 33 80 c2 f2 + +aes32dsmi t0, a2, 3 +# CHECK-INST: aes32dsmi t0, a2, 3 +# CHECK-ENCODING: [0x33,0x80,0xc2,0xfe] +# CHECK-ERROR: instruction requires the following: 'K' (Scalar Cryptography Instructions) +# CHECK-UNKNOWN: 33 80 c2 fe + +aes32dsi t0, a2, 3 +# CHECK-INST: aes32dsi t0, a2, 3 +# CHECK-ENCODING: [0x33,0x80,0xc2,0xfa] +# CHECK-ERROR: instruction requires the following: 'K' (Scalar Cryptography Instructions) +# CHECK-UNKNOWN: 33 80 c2 fa \ No newline at end of file diff --git a/llvm/test/MC/RISCV/rvk/rv64k.s b/llvm/test/MC/RISCV/rvk/rv64k.s new file mode 100644 --- /dev/null +++ b/llvm/test/MC/RISCV/rvk/rv64k.s @@ -0,0 +1,125 @@ +# RUN: llvm-mc -triple=riscv64 -show-encoding --mattr=+experimental-k %s \ +# RUN: | FileCheck %s --check-prefixes=CHECK-ENCODING,CHECK-INST +# RUN: not llvm-mc -triple=riscv64 -show-encoding %s 2>&1 \ +# RUN: | FileCheck %s --check-prefix=CHECK-ERROR +# RUN: llvm-mc -triple=riscv64 -filetype=obj --mattr=+experimental-k %s \ +# RUN: | llvm-objdump -d --mattr=+experimental-k - \ +# RUN: | FileCheck %s --check-prefix=CHECK-INST +# RUN: llvm-mc -triple=riscv64 -filetype=obj --mattr=+experimental-k %s \ +# RUN: | llvm-objdump -d - | FileCheck %s --check-prefix=CHECK-UNKNOWN + +sha256sum0 a0, a1 +# CHECK-INST: sha256sum0 a0, a1 +# CHECK-ENCODING: [0x13,0x95,0x05,0x10] +# CHECK-ERROR: instruction requires the following: 'K' (Scalar Cryptography Instructions) +# CHECK-UNKNOWN: 13 95 05 10 + +sha256sum1 a0, a1 +# CHECK-INST: sha256sum1 a0, a1 +# CHECK-ENCODING: [0x13,0x95,0x15,0x10] +# CHECK-ERROR: instruction requires the following: 'K' (Scalar Cryptography Instructions) +# CHECK-UNKNOWN: 13 95 15 10 + +sha256sig0 a0, a1 +# CHECK-INST: sha256sig0 a0, a1 +# CHECK-ENCODING: [0x13,0x95,0x25,0x10] +# CHECK-ERROR: instruction requires the following: 'K' (Scalar Cryptography Instructions) +# CHECK-UNKNOWN: 13 95 25 10 + +sha256sig1 a0, a1 +# CHECK-INST: sha256sig1 a0, a1 +# CHECK-ENCODING: [0x13,0x95,0x35,0x10] +# CHECK-ERROR: instruction requires the following: 'K' (Scalar Cryptography Instructions) +# CHECK-UNKNOWN: 13 95 35 10 + +sm3p0 a0, a1 +# CHECK-INST: sm3p0 a0, a1 +# CHECK-ENCODING: [0x13,0x95,0x85,0x10] +# CHECK-ERROR: instruction requires the following: 'K' (Scalar Cryptography Instructions) +# CHECK-UNKNOWN: 13 95 85 10 + +sm3p1 a0, a1 +# CHECK-INST: sm3p1 a0, a1 +# CHECK-ENCODING: [0x13,0x95,0x95,0x10] +# CHECK-ERROR: instruction requires the following: 'K' (Scalar Cryptography Instructions) +# CHECK-UNKNOWN: 13 95 95 10 + +getnoise a0 +# CHECK-INST: csrr a0, mnoise +# CHECK-ENCODING: [0x73,0x25,0x90,0x7a] +# CHECK-ERROR: instruction requires the following: 'K' (Scalar Cryptography Instructions) +# CHECK-UNKNOWN: 73 25 90 7a + +pollentropy a0 +# CHECK-INST: csrr a0, mentropy +# CHECK-ENCODING: [0x73,0x25,0x50,0xf1] +# CHECK-ERROR: instruction requires the following: 'K' (Scalar Cryptography Instructions) +# CHECK-UNKNOWN: 73 25 50 f1 + +# RV64 only + +sha512sum0 a0, a1 +# CHECK-INST: sha512sum0 a0, a1 +# CHECK-ENCODING: [0x13,0x95,0x45,0x10] +# CHECK-ERROR: instruction requires the following: 'K' (Scalar Cryptography Instructions) +# CHECK-UNKNOWN: 13 95 45 10 + +sha512sum1 a0, a1 +# CHECK-INST: sha512sum1 a0, a1 +# CHECK-ENCODING: [0x13,0x95,0x55,0x10] +# CHECK-ERROR: instruction requires the following: 'K' (Scalar Cryptography Instructions) +# CHECK-UNKNOWN: 13 95 55 10 + +sha512sig0 a0, a1 +# CHECK-INST: sha512sig0 a0, a1 +# CHECK-ENCODING: [0x13,0x95,0x65,0x10] +# CHECK-ERROR: instruction requires the following: 'K' (Scalar Cryptography Instructions) +# CHECK-UNKNOWN: 13 95 65 10 + +sha512sig1 a0, a1 +# CHECK-INST: sha512sig1 a0, a1 +# CHECK-ENCODING: [0x13,0x95,0x75,0x10] +# CHECK-ERROR: instruction requires the following: 'K' (Scalar Cryptography Instructions) +# CHECK-UNKNOWN: 13 95 75 10 + +aes64im a0, a1 +# CHECK-INST: aes64im a0, a1 +# CHECK-ENCODING: [0x13,0x95,0x05,0x30] +# CHECK-ERROR: instruction requires the following: 'K' (Scalar Cryptography Instructions) +# CHECK-UNKNOWN: 13 95 05 30 + +aes64ks2 a0, a1, a2 +# CHECK-INST: aes64ks2 a0, a1, a2 +# CHECK-ENCODING: [0x33,0x85,0xc5,0x7e] +# CHECK-ERROR: instruction requires the following: 'K' (Scalar Cryptography Instructions) +# CHECK-UNKNOWN: 33 85 c5 7e + +aes64esm a0, a1, a2 +# CHECK-INST: aes64esm a0, a1, a2 +# CHECK-ENCODING: [0x33,0x85,0xc5,0x36] +# CHECK-ERROR: instruction requires the following: 'K' (Scalar Cryptography Instructions) +# CHECK-UNKNOWN: 33 85 c5 36 + +aes64es a0, a1, a2 +# CHECK-INST: aes64es a0, a1, a2 +# CHECK-ENCODING: [0x33,0x85,0xc5,0x32] +# CHECK-ERROR: instruction requires the following: 'K' (Scalar Cryptography Instructions) +# CHECK-UNKNOWN: 33 85 c5 32 + +aes64dsm a0, a1, a2 +# CHECK-INST: aes64dsm a0, a1, a2 +# CHECK-ENCODING: [0x33,0x85,0xc5,0x3e] +# CHECK-ERROR: instruction requires the following: 'K' (Scalar Cryptography Instructions) +# CHECK-UNKNOWN: 33 85 c5 3e + +aes64es a0, a1, a2 +# CHECK-INST: aes64es a0, a1, a2 +# CHECK-ENCODING: [0x33,0x85,0xc5,0x32] +# CHECK-ERROR: instruction requires the following: 'K' (Scalar Cryptography Instructions) +# CHECK-UNKNOWN: 33 85 c5 32 + +aes64ks1i a0, a1, 5 +# CHECK-INST: aes64ks1i a0, a1, 5 +# CHECK-ENCODING: [0x13,0x95,0x55,0x31] +# CHECK-ERROR: instruction requires the following: 'K' (Scalar Cryptography Instructions) +# CHECK-UNKNOWN: 13 95 55 31 \ No newline at end of file diff --git a/llvm/test/MC/RISCV/rvk/rvk-invalid.s b/llvm/test/MC/RISCV/rvk/rvk-invalid.s new file mode 100644 --- /dev/null +++ b/llvm/test/MC/RISCV/rvk/rvk-invalid.s @@ -0,0 +1,20 @@ +# RUN: not llvm-mc -triple riscv32 -mattr=+experimental-k < %s 2>&1 \ +# RUN: | FileCheck %s --check-prefix=CHECK-ERROR + +sm4ed t0, a2, 8 +# CHECK-ERROR: immediate must be an integer in the range [0, 3] + +sm4ks t0, a2, 8 +# CHECK-ERROR: immediate must be an integer in the range [0, 3] + +aes32esmi t0, a2, 8 +# CHECK-ERROR: immediate must be an integer in the range [0, 3] + +aes32esi t0, a2, 8 +# CHECK-ERROR: immediate must be an integer in the range [0, 3] + +aes32dsmi t0, a2, 8 +# CHECK-ERROR: immediate must be an integer in the range [0, 3] + +aes32dsi t0, a2, 8 +# CHECK-ERROR: immediate must be an integer in the range [0, 3]