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 @@ -504,6 +504,24 @@ 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; @@ -697,6 +715,16 @@ VK == RISCVMCExpr::VK_RISCV_None; } + bool isRconArg() const { + int64_t Imm; + RISCVMCExpr::VariantKind VK = RISCVMCExpr::VK_RISCV_None; + if (!isImm()) + return false; + bool IsConstantImm = evaluateConstantImm(getImm(), Imm, VK); + return IsConstantImm && Imm>= INT64_C(0) && Imm <= INT64_C(10) && + VK == RISCVMCExpr::VK_RISCV_None; + } + /// getStartLoc - Gets location of the first token of this operand SMLoc getStartLoc() const override { return StartLoc; } /// getEndLoc - Gets location of the last token of this operand @@ -1044,6 +1072,8 @@ 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_InvalidUImm5: return generateImmOutOfRangeError(Operands, ErrorInfo, 0, (1 << 5) - 1); case Match_InvalidSImm5: @@ -1165,6 +1195,9 @@ (1 << 4), "immediate must be in the range"); } + case Match_InvalidRconArg: { + return generateImmOutOfRangeError(Operands, ErrorInfo, 0, (1 << 4) - 6); + } } llvm_unreachable("Unknown match type detected!"); 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 @@ -188,6 +188,86 @@ AssemblerPredicate<(all_of FeatureExtZvamo), "'Zvamo'(Vector AMO Operations)">; +def FeatureExtZkb + : SubtargetFeature<"experimental-zkb", "HasStdExtZkb", "true", + "'Zkb'(Bitmanip subset included in the scalar cryptography extension)", + [FeatureExtZbp]>; +def HasStdExtZkb : Predicate<"Subtarget->hasStdExtZkb()">, + AssemblerPredicate<(all_of FeatureExtZkb), + "'Zkb'(Bitmanip subset included in the scalar cryptography extension)">; +def FeatureExtZkg + : SubtargetFeature<"experimental-zkg", "HasStdExtZkg", "true", + "'Zkg'(Constant time carry-less multiply for Galois/Counter Mode)", + [FeatureExtZbc]>; +def HasStdExtZkg : Predicate<"Subtarget->hasStdExtZkg()">, + AssemblerPredicate<(all_of FeatureExtZkg), + "'Zkg'(Constant time carry-less multiply for Galois/Counter Mode)">; +def FeatureExtZksh + : SubtargetFeature<"experimental-zksh", "HasStdExtZksh", "true", + "'Zksh'(SM3 Hash function instructions)">; +def HasStdExtZksh : Predicate<"Subtarget->hasStdExtZksh()">, + AssemblerPredicate<(all_of FeatureExtZksh), + "'Zksh'(SM3 Hash function instructions)">; +def FeatureExtZksed + : SubtargetFeature<"experimental-zksed", "HasStdExtZksed", "true", + "'Zksed'(SM4 Instructions)">; +def HasStdExtZksed : Predicate<"Subtarget->hasStdExtZksed()">, + AssemblerPredicate<(all_of FeatureExtZksed), + "'Zksed'(SM4 Instructions)">; +def FeatureExtZks + : SubtargetFeature<"experimental-zks", "HasStdExtZks", "true", + "'Zks'(ShangMi (SM) algorithm suite)", + [FeatureExtZksed, + FeatureExtZksh, + FeatureExtZkg, + FeatureExtZkb]>; +def HasStdExtZks : Predicate<"Subtarget->hasStdExtZks()">, + AssemblerPredicate<(all_of FeatureExtZks), + "'Zks'(ShangMi (SM) algorithm suite)">; +def FeatureExtZknh + : SubtargetFeature<"experimental-zknh", "HasStdExtZknh", "true", + "'Zknh'(NIST SHA2 Hash function instructions)">; +def HasStdExtZknh : Predicate<"Subtarget->hasStdExtZknh()">, + AssemblerPredicate<(all_of FeatureExtZknh), + "'Zknh'(NIST SHA2 Hash function instructions)">; +def FeatureExtZkne + : SubtargetFeature<"experimental-zkne", "HasStdExtZkne", "true", + "'Zkne'(NIST AES Encryption Instructions)">; +def HasStdExtZkne : Predicate<"Subtarget->hasStdExtZkne()">, + AssemblerPredicate<(all_of FeatureExtZkne), + "'Zkne'(NIST AES Encryption Instructions)">; +def FeatureExtZknd + : SubtargetFeature<"experimental-zknd", "HasStdExtZknd", "true", + "'Zknd'(NIST AES Decryption Instructions)">; +def HasStdExtZknd : Predicate<"Subtarget->hasStdExtZknd()">, + AssemblerPredicate<(all_of FeatureExtZknd), + "'Zknd'(NIST AES Decryption Instructions)">; +def FeatureExtZkn + : SubtargetFeature<"experimental-zkn", "HasStdExtZkn", "true", + "'Zkn'(NIST algorithm suite)", + [FeatureExtZknd, + FeatureExtZkne, + FeatureExtZknh, + FeatureExtZkg, + FeatureExtZkb]>; +def HasStdExtZkn : Predicate<"Subtarget->hasStdExtZkn()">, + AssemblerPredicate<(all_of FeatureExtZkn), + "'Zkn'(NIST algorithm suite)">; +def FeatureExtZkr + : SubtargetFeature<"experimental-zkr", "HasStdExtZkr", "true", + "'Zkr'(Entropy source for seeding random number generators)">; +def HasStdExtZkr : Predicate<"Subtarget->hasStdExtZkr()">, + AssemblerPredicate<(all_of FeatureExtZkr), + "'Zkr'(Entropy source for seeding random number generators)">; +def FeatureStdExtK + : SubtargetFeature<"experimental-k", "HasStdExtK", "true", + "'K' (Scalar Cryptography Instructions)", + [FeatureExtZkr, + FeatureExtZkn]>; +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,13 @@ let OperandNamespace = "RISCVOp"; } +def uimm2 : Operand, ImmLeaf(Imm);}]> { + let ParserMatchClass = UImmAsmOperand<2>; + let DecoderMethod = "decodeUImmOperand<2>"; + let OperandType = "OPERAND_UIMM2"; + let OperandNamespace = "RISCVOp"; +} + def uimm5 : Operand, ImmLeaf(Imm);}]> { let ParserMatchClass = UImmAsmOperand<5>; let DecoderMethod = "decodeUImmOperand<5>"; @@ -1260,4 +1267,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,136 @@ +//===-- 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-V instructions from the standard 'K' +/// scalar cryptography extension, version 0.9.0. +/// +/// This version is still experimental as the 'K' extension hasn't been +/// ratified yet. +/// +//===----------------------------------------------------------------------===// + +def RconArg : AsmOperandClass { + let Name = "RconArg"; + let RenderMethod = "addImmOperands"; + let DiagnosticType = "InvalidRconArg"; +} + +def rcon : Operand, ImmLeaf(Imm);}]> { + let ParserMatchClass = RconArg; + let EncoderMethod = "getImmOpValue"; + let DecoderMethod = "decodeUImmOperand<4>"; + let OperandType = "OPERAND_UIMM4"; + let OperandNamespace = "RISCVOp"; +} + +//===----------------------------------------------------------------------===// +// Instruction class templates +//===----------------------------------------------------------------------===// + +let hasSideEffects = 0, mayLoad = 0, mayStore = 0 in +class RVKUnary funct7, bits<5> funct5, bits<3> funct3, string opcodestr> + : RVInstR{ + let Inst{24-20} = funct5; + } + +let hasSideEffects = 0, mayLoad = 0, mayStore = 0 in +class RVKBinary funct7, bits<3> funct3, string opcodestr> + : RVInstR; + +let hasSideEffects = 0, mayLoad = 0, mayStore = 0 in +class RVKByteSelect funct5, string opcodestr> + : RVInstS<0b000, OPC_OP, (outs GPR:$rt), (ins GPR:$rs1, GPR:$rs2, uimm2:$bs), + opcodestr, "$rt, $rs2, $bs">{ + bits<2> bs; + bits<5> rt; + + let Constraints = "$rt = $rs1"; + let Inst{31-30}=bs; + let Inst{29-25}=funct5; + let Inst{19-15}=rt; + let Inst{11-7}=0b00000; + } + +let hasSideEffects = 0, mayLoad = 0, mayStore = 0 in +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; +} + +//===----------------------------------------------------------------------===// +// Instructions +//===----------------------------------------------------------------------===// + +let Predicates = [HasStdExtZkr] in { +// Assembler Pseudo Instructions +def : InstAlias<"getnoise $rd", (CSRRS GPR:$rd, MNOISE.Encoding, X0)>; +def : InstAlias<"pollentropy $rd", (CSRRS GPR:$rd, MENTROPY.Encoding, X0)>; +}// Predicates = [HasStdExtZkr] + +let Predicates = [HasStdExtZkne, IsRV32] in { +def AES32ESI : RVKByteSelect<0b11001, "aes32esi">; +def AES32ESMI : RVKByteSelect<0b11011, "aes32esmi">; +} // Predicates = [HasStdExtZkne, IsRV32] + +let Predicates = [HasStdExtZkne, IsRV64] in { +def AES64ES : RVKBinary<0b0011001, 0b000, "aes64es">; +def AES64ESM : RVKBinary<0b0011011, 0b000, "aes64esm">; +def AES64KS2 : RVKBinary<0b0111111, 0b000, "aes64ks2">; +def AES64KS1I : RVKUnary_rcon<0b0011000, 0b001, "aes64ks1i">; +} // Predicates = [HasStdExtZkne, IsRV64] + +let Predicates = [HasStdExtZknd, IsRV32] in { +def AES32DSI : RVKByteSelect<0b11101, "aes32dsi">; +def AES32DSMI : RVKByteSelect<0b11111, "aes32dsmi">; +} // Predicates = [HasStdExtZknd, IsRV32] + +let Predicates = [HasStdExtZknd, IsRV64] in { +def AES64DS : RVKBinary<0b0011101, 0b000, "aes64ds">; +def AES64IM : RVKUnary<0b0011000, 0b00000, 0b001, "aes64im">; + +def AES64DSM : RVKBinary<0b0011111, 0b000, "aes64dsm">; +} // Predicates = [HasStdExtZknd, IsRV64] + +let Predicates = [HasStdExtZknh] in { +def SHA256SUM0 : RVKUnary<0b0001000, 0b00000, 0b001, "sha256sum0">; +def SHA256SUM1 : RVKUnary<0b0001000, 0b00001, 0b001, "sha256sum1">; +def SHA256SIG0 : RVKUnary<0b0001000, 0b00010, 0b001, "sha256sig0">; +def SHA256SIG1 : RVKUnary<0b0001000, 0b00011, 0b001, "sha256sig1">; +} // Predicates = [HasStdExtZknh] + +let Predicates = [HasStdExtZknh, IsRV32] in { +def SHA512SUM0R : RVKBinary<0b0101000, 0b000, "sha512sum0r">; +def SHA512SUM1R : RVKBinary<0b0101001, 0b000, "sha512sum1r">; +def SHA512SIG0L : RVKBinary<0b0101010, 0b000, "sha512sig0l">; +def SHA512SIG0H : RVKBinary<0b0101110, 0b000, "sha512sig0h">; +def SHA512SIG1L : RVKBinary<0b0101011, 0b000, "sha512sig1l">; +def SHA512SIG1H : RVKBinary<0b0101111, 0b000, "sha512sig1h">; +} // Predicates = [HasStdExtZknh, IsRV32] + +let Predicates = [HasStdExtZknh, IsRV64] in { +def SHA512SUM0 : RVKUnary<0b0001000, 0b00100, 0b001, "sha512sum0">; +def SHA512SUM1 : RVKUnary<0b0001000, 0b00101, 0b001, "sha512sum1">; +def SHA512SIG0 : RVKUnary<0b0001000, 0b00110, 0b001, "sha512sig0">; +def SHA512SIG1 : RVKUnary<0b0001000, 0b00111, 0b001, "sha512sig1">; +} // Predicates = [HasStdExtZknh, IsRV64] + +let Predicates = [HasStdExtZksed] in { +def SM4ED : RVKByteSelect<0b11000, "sm4ed">; +def SM4KS : RVKByteSelect<0b11010, "sm4ks">; +} // Predicates = [HasStdExtZksed] + +let Predicates = [HasStdExtZksh] in { +def SM3P0 : RVKUnary<0b0001000, 0b01000, 0b001, "sm3p0">; +def SM3P1 : RVKUnary<0b0001000, 0b01001, 0b001, "sm3p1">; +} // Predicates = [HasStdExtZksh] diff --git a/llvm/lib/Target/RISCV/RISCVSchedRocket.td b/llvm/lib/Target/RISCV/RISCVSchedRocket.td --- a/llvm/lib/Target/RISCV/RISCVSchedRocket.td +++ b/llvm/lib/Target/RISCV/RISCVSchedRocket.td @@ -16,7 +16,7 @@ let IssueWidth = 1; // 1 micro-op is dispatched per cycle. let LoadLatency = 3; let MispredictPenalty = 3; - let UnsupportedFeatures = [HasStdExtV, HasStdExtZvamo, HasStdExtZvlsseg]; + let UnsupportedFeatures = [HasStdExtV, HasStdExtZvamo, HasStdExtZvlsseg, HasStdExtZkr, HasStdExtZknd, HasStdExtZkne, HasStdExtZknh, HasStdExtZksed, HasStdExtZksh]; } //===----------------------------------------------------------------------===// diff --git a/llvm/lib/Target/RISCV/RISCVSchedSiFive7.td b/llvm/lib/Target/RISCV/RISCVSchedSiFive7.td --- a/llvm/lib/Target/RISCV/RISCVSchedSiFive7.td +++ b/llvm/lib/Target/RISCV/RISCVSchedSiFive7.td @@ -15,7 +15,7 @@ let LoadLatency = 3; let MispredictPenalty = 3; let CompleteModel = 0; - let UnsupportedFeatures = [HasStdExtV, HasStdExtZvamo, HasStdExtZvlsseg]; + let UnsupportedFeatures = [HasStdExtV, HasStdExtZvamo, HasStdExtZvlsseg, HasStdExtZkr, HasStdExtZknd, HasStdExtZkne, HasStdExtZknh, HasStdExtZksed, HasStdExtZksh]; } // The SiFive7 microarchitecure has two pipelines: A and B. 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 @@ -55,6 +55,17 @@ bool HasStdExtZvlsseg = false; bool HasStdExtZvamo = false; bool HasStdExtZfh = false; + bool HasStdExtK = false; + bool HasStdExtZkb = false; + bool HasStdExtZkg = false; + bool HasStdExtZkn = false; + bool HasStdExtZknd = false; + bool HasStdExtZkne = false; + bool HasStdExtZknh = false; + bool HasStdExtZkr = false; + bool HasStdExtZks = false; + bool HasStdExtZksh = false; + bool HasStdExtZksed = false; bool HasRV64 = false; bool IsRV32E = false; bool EnableLinkerRelax = false; @@ -122,6 +133,17 @@ bool hasStdExtZvlsseg() const { return HasStdExtZvlsseg; } bool hasStdExtZvamo() const { return HasStdExtZvamo; } bool hasStdExtZfh() const { return HasStdExtZfh; } + bool hasStdExtK() const { return HasStdExtK; } + bool hasStdExtZkb() const { return HasStdExtZkb; } + bool hasStdExtZkg() const { return HasStdExtZkg; } + bool hasStdExtZkn() const { return HasStdExtZkn; } + bool hasStdExtZknd() const { return HasStdExtZknd; } + bool hasStdExtZkne() const { return HasStdExtZkne; } + bool hasStdExtZknh() const { return HasStdExtZknh; } + bool hasStdExtZkr() const { return HasStdExtZkr; } + bool hasStdExtZks() const { return HasStdExtZks; } + bool hasStdExtZksh() const { return HasStdExtZksh; } + bool hasStdExtZksed() const { return HasStdExtZksed; } bool is64Bit() const { return HasRV64; } bool isRV32E() const { return IsRV32E; } bool enableLinkerRelax() const { return EnableLinkerRelax; } 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>; + +//===----------------------------------------------- +// Machine Scalar Cryptography CSRs +//===----------------------------------------------- +def MENTROPY : SysReg<"mentropy", 0xF15>; +def MNOISE : SysReg<"mnoise", 0x7A9>; diff --git a/llvm/test/MC/RISCV/rv32zkb-aliases-valid.s b/llvm/test/MC/RISCV/rv32zkb-aliases-valid.s new file mode 100644 --- /dev/null +++ b/llvm/test/MC/RISCV/rv32zkb-aliases-valid.s @@ -0,0 +1,60 @@ +# With K extension: +# RUN: llvm-mc %s -triple=riscv32 -mattr=+experimental-k -riscv-no-aliases \ +# RUN: | FileCheck -check-prefixes=CHECK-S-OBJ-NOALIAS %s +# RUN: llvm-mc %s -triple=riscv32 -mattr=+experimental-k \ +# RUN: | FileCheck -check-prefixes=CHECK-S-OBJ %s +# RUN: llvm-mc -filetype=obj -triple riscv32 -mattr=+experimental-k < %s \ +# RUN: | llvm-objdump -d -r --riscv-no-aliases --mattr=+experimental-k - \ +# RUN: | FileCheck -check-prefixes=CHECK-S-OBJ-NOALIAS %s +# RUN: llvm-mc -filetype=obj -triple riscv32 -mattr=+experimental-k < %s \ +# RUN: | llvm-objdump -d -r --mattr=+experimental-k - \ +# RUN: | FileCheck -check-prefixes=CHECK-S-OBJ %s + +# With Zkn extension: +# RUN: llvm-mc %s -triple=riscv32 -mattr=+experimental-zkn -riscv-no-aliases \ +# RUN: | FileCheck -check-prefixes=CHECK-S-OBJ-NOALIAS %s +# RUN: llvm-mc %s -triple=riscv32 -mattr=+experimental-zkn \ +# RUN: | FileCheck -check-prefixes=CHECK-S-OBJ %s +# RUN: llvm-mc -filetype=obj -triple riscv32 -mattr=+experimental-zkn < %s \ +# RUN: | llvm-objdump -d -r --riscv-no-aliases --mattr=+experimental-zkn - \ +# RUN: | FileCheck -check-prefixes=CHECK-S-OBJ-NOALIAS %s +# RUN: llvm-mc -filetype=obj -triple riscv32 -mattr=+experimental-zkn < %s \ +# RUN: | llvm-objdump -d -r --mattr=+experimental-zkn - \ +# RUN: | FileCheck -check-prefixes=CHECK-S-OBJ %s + +# With Zks extension: +# RUN: llvm-mc %s -triple=riscv32 -mattr=+experimental-zks -riscv-no-aliases \ +# RUN: | FileCheck -check-prefixes=CHECK-S-OBJ-NOALIAS %s +# RUN: llvm-mc %s -triple=riscv32 -mattr=+experimental-zks \ +# RUN: | FileCheck -check-prefixes=CHECK-S-OBJ %s +# RUN: llvm-mc -filetype=obj -triple riscv32 -mattr=+experimental-zks < %s \ +# RUN: | llvm-objdump -d -r --riscv-no-aliases --mattr=+experimental-zks - \ +# RUN: | FileCheck -check-prefixes=CHECK-S-OBJ-NOALIAS %s +# RUN: llvm-mc -filetype=obj -triple riscv32 -mattr=+experimental-zks < %s \ +# RUN: | llvm-objdump -d -r --mattr=+experimental-zks - \ +# RUN: | FileCheck -check-prefixes=CHECK-S-OBJ %s + +# With Zkb extension: +# RUN: llvm-mc %s -triple=riscv32 -mattr=+experimental-zkb -riscv-no-aliases \ +# RUN: | FileCheck -check-prefixes=CHECK-S-OBJ-NOALIAS %s +# RUN: llvm-mc %s -triple=riscv32 -mattr=+experimental-zkb \ +# RUN: | FileCheck -check-prefixes=CHECK-S-OBJ %s +# RUN: llvm-mc -filetype=obj -triple riscv32 -mattr=+experimental-zkb < %s \ +# RUN: | llvm-objdump -d -r --riscv-no-aliases --mattr=+experimental-zkb - \ +# RUN: | FileCheck -check-prefixes=CHECK-S-OBJ-NOALIAS %s +# RUN: llvm-mc -filetype=obj -triple riscv32 -mattr=+experimental-zkb < %s \ +# RUN: | llvm-objdump -d -r --mattr=+experimental-zkb - \ +# RUN: | FileCheck -check-prefixes=CHECK-S-OBJ %s + + +# CHECK-S-OBJ-NOALIAS: grevi t0, t1, 7 +# CHECK-S-OBJ: rev.b t0, t1 +rev.b x5, x6 + +# CHECK-S-OBJ-NOALIAS: shfli t0, t1, 15 +# CHECK-S-OBJ: zip t0, t1 +zip x5, x6 + +# CHECK-S-OBJ-NOALIAS: unshfli t0, t1, 15 +# CHECK-S-OBJ: unzip t0, t1 +unzip x5, x6 diff --git a/llvm/test/MC/RISCV/rv32zkb-valid.s b/llvm/test/MC/RISCV/rv32zkb-valid.s new file mode 100644 --- /dev/null +++ b/llvm/test/MC/RISCV/rv32zkb-valid.s @@ -0,0 +1,92 @@ +# With K extension: +# RUN: llvm-mc -triple=riscv32 -show-encoding --mattr=+experimental-k %s \ +# RUN: | FileCheck -check-prefixes=CHECK-ASM,CHECK-ASM-AND-OBJ %s +# RUN: llvm-mc -triple=riscv32 -filetype=obj --mattr=+experimental-k %s \ +# RUN: | llvm-objdump -d --mattr=+experimental-k - \ +# RUN: | FileCheck %s --check-prefixes=CHECK-ASM-AND-OBJ + +# With Zkn extension: +# RUN: llvm-mc -triple=riscv32 -show-encoding --mattr=+experimental-zkn %s \ +# RUN: | FileCheck -check-prefixes=CHECK-ASM,CHECK-ASM-AND-OBJ %s +# RUN: llvm-mc -triple=riscv32 -filetype=obj --mattr=+experimental-zkn %s \ +# RUN: | llvm-objdump -d --mattr=+experimental-zkn - \ +# RUN: | FileCheck %s --check-prefixes=CHECK-ASM-AND-OBJ + +# With Zks extension: +# RUN: llvm-mc -triple=riscv32 -show-encoding --mattr=+experimental-zks %s \ +# RUN: | FileCheck -check-prefixes=CHECK-ASM,CHECK-ASM-AND-OBJ %s +# RUN: llvm-mc -triple=riscv32 -filetype=obj --mattr=+experimental-zks %s \ +# RUN: | llvm-objdump -d --mattr=+experimental-zks - \ +# RUN: | FileCheck %s --check-prefixes=CHECK-ASM-AND-OBJ + +# With Zkb extension: +# RUN: llvm-mc -triple=riscv32 -show-encoding --mattr=+experimental-zkb %s \ +# RUN: | FileCheck -check-prefixes=CHECK-ASM,CHECK-ASM-AND-OBJ %s +# RUN: llvm-mc -triple=riscv32 -filetype=obj --mattr=+experimental-zkb %s \ +# RUN: | llvm-objdump -d --mattr=+experimental-zkb - \ +# RUN: | FileCheck %s --check-prefixes=CHECK-ASM-AND-OBJ + + +# CHECK-ASM-AND-OBJ: xperm.n t0, t1, t2 +# CHECK-ASM: encoding: [0xb3,0x22,0x73,0x28] +xperm.n t0, t1, t2 + +# CHECK-ASM-AND-OBJ: xperm.b t0, t1, t2 +# CHECK-ASM: encoding: [0xb3,0x42,0x73,0x28] +xperm.b t0, t1, t2 + +# CHECK-ASM-AND-OBJ: ror t0, t1, t2 +# CHECK-ASM: encoding: [0xb3,0x52,0x73,0x60] +ror t0, t1, t2 + +# CHECK-ASM-AND-OBJ: rol t0, t1, t2 +# CHECK-ASM: encoding: [0xb3,0x12,0x73,0x60] +rol t0, t1, t2 + +# CHECK-ASM-AND-OBJ: rori t0, t1, 31 +# CHECK-ASM: encoding: [0x93,0x52,0xf3,0x61] +rori t0, t1, 31 + +# CHECK-ASM-AND-OBJ: rori t0, t1, 0 +# CHECK-ASM: encoding: [0x93,0x52,0x03,0x60] +rori t0, t1, 0 + +# CHECK-ASM-AND-OBJ: andn t0, t1, t2 +# CHECK-ASM: encoding: [0xb3,0x72,0x73,0x40] +andn t0, t1, t2 + +# CHECK-ASM-AND-OBJ: orn t0, t1, t2 +# CHECK-ASM: encoding: [0xb3,0x62,0x73,0x40] +orn t0, t1, t2 + +# CHECK-ASM-AND-OBJ: xnor t0, t1, t2 +# CHECK-ASM: encoding: [0xb3,0x42,0x73,0x40] +xnor t0, t1, t2 + +# CHECK-ASM-AND-OBJ: pack t0, t1, t2 +# CHECK-ASM: encoding: [0xb3,0x42,0x73,0x08] +pack t0, t1, t2 + +# CHECK-ASM-AND-OBJ: packu t0, t1, t2 +# CHECK-ASM: encoding: [0xb3,0x42,0x73,0x48] +packu t0, t1, t2 + +# CHECK-ASM-AND-OBJ: packh t0, t1, t2 +# CHECK-ASM: encoding: [0xb3,0x72,0x73,0x08] +packh t0, t1, t2 + +# CHECK-ASM-AND-OBJ: rev8 t0, t1 +# CHECK-ASM: encoding: [0x93,0x52,0x83,0x69] +rev8 t0, t1 + +# CHECK-ASM-AND-OBJ: grevi t0, t1, 0 +# CHECK-ASM: encoding: [0x93,0x52,0x03,0x68] +grevi t0, t1, 0 + +# CHECK-ASM-AND-OBJ: shfli t0, t1, 0 +# CHECK-ASM: encoding: [0x93,0x12,0x03,0x08] +shfli t0, t1, 0 + +# CHECK-ASM-AND-OBJ: unshfli t0, t1, 0 +# CHECK-ASM: encoding: [0x93,0x52,0x03,0x08] +unshfli t0, t1, 0 diff --git a/llvm/test/MC/RISCV/rv32zkg-valid.s b/llvm/test/MC/RISCV/rv32zkg-valid.s new file mode 100644 --- /dev/null +++ b/llvm/test/MC/RISCV/rv32zkg-valid.s @@ -0,0 +1,35 @@ +# With K extension: +# RUN: llvm-mc -triple=riscv32 -show-encoding --mattr=+experimental-k %s \ +# RUN: | FileCheck %s --check-prefixes=CHECK-ENCODING,CHECK-INST +# 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 + +# With Zkn extension: +# RUN: llvm-mc -triple=riscv32 -show-encoding --mattr=+experimental-zkn %s \ +# RUN: | FileCheck %s --check-prefixes=CHECK-ENCODING,CHECK-INST +# RUN: llvm-mc -triple=riscv32 -filetype=obj --mattr=+experimental-zkn %s \ +# RUN: | llvm-objdump -d --mattr=+experimental-zkn - \ +# RUN: | FileCheck %s --check-prefix=CHECK-INST + +# With Zks extension: +# RUN: llvm-mc -triple=riscv32 -show-encoding --mattr=+experimental-zks %s \ +# RUN: | FileCheck %s --check-prefixes=CHECK-ENCODING,CHECK-INST +# RUN: llvm-mc -triple=riscv32 -filetype=obj --mattr=+experimental-zks %s \ +# RUN: | llvm-objdump -d --mattr=+experimental-zks - \ +# RUN: | FileCheck %s --check-prefix=CHECK-INST + +# With Zkg extension: +# RUN: llvm-mc -triple=riscv32 -show-encoding --mattr=+experimental-zkg %s \ +# RUN: | FileCheck %s --check-prefixes=CHECK-ENCODING,CHECK-INST +# RUN: llvm-mc -triple=riscv32 -filetype=obj --mattr=+experimental-zkg %s \ +# RUN: | llvm-objdump -d --mattr=+experimental-zkg - \ +# RUN: | FileCheck %s --check-prefix=CHECK-INST + +# CHECK-INST: clmul t0, t1, t2 +# CHECK-ENCODING: [0xb3,0x12,0x73,0x0a] +clmul t0, t1, t2 + +# CHECK-INST: clmulh t0, t1, t2 +# CHECK-ENCODING: [0xb3,0x32,0x73,0x0a] +clmulh t0, t1, t2 diff --git a/llvm/test/MC/RISCV/rv32zknd-only-invalid.s b/llvm/test/MC/RISCV/rv32zknd-only-invalid.s new file mode 100644 --- /dev/null +++ b/llvm/test/MC/RISCV/rv32zknd-only-invalid.s @@ -0,0 +1,17 @@ +# With K extension: +# RUN: not llvm-mc -triple=riscv32 -mattr=+experimental-k < %s 2>&1 \ +# RUN: | FileCheck %s --check-prefix=CHECK-ERROR + +# With Zkn extension: +# RUN: not llvm-mc -triple=riscv32 -mattr=+experimental-zkn < %s 2>&1 \ +# RUN: | FileCheck %s --check-prefix=CHECK-ERROR + +# With Zknd extension: +# RUN: not llvm-mc -triple=riscv32 -mattr=+experimental-zknd < %s 2>&1 \ +# RUN: | FileCheck %s --check-prefix=CHECK-ERROR + +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] diff --git a/llvm/test/MC/RISCV/rv32zknd-only-valid.s b/llvm/test/MC/RISCV/rv32zknd-only-valid.s new file mode 100644 --- /dev/null +++ b/llvm/test/MC/RISCV/rv32zknd-only-valid.s @@ -0,0 +1,44 @@ +# With K extension: +# 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 + +# With Zkn extension: +# RUN: llvm-mc -triple=riscv32 -show-encoding --mattr=+experimental-zkn %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-zkn %s \ +# RUN: | llvm-objdump -d --mattr=+experimental-zkn - \ +# RUN: | FileCheck %s --check-prefix=CHECK-INST +# RUN: llvm-mc -triple=riscv32 -filetype=obj --mattr=+experimental-zkn %s \ +# RUN: | llvm-objdump -d - | FileCheck %s --check-prefix=CHECK-UNKNOWN + +# With Zknd extension: +# RUN: llvm-mc -triple=riscv32 -show-encoding --mattr=+experimental-zknd %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-zknd %s \ +# RUN: | llvm-objdump -d --mattr=+experimental-zknd - \ +# RUN: | FileCheck %s --check-prefix=CHECK-INST +# RUN: llvm-mc -triple=riscv32 -filetype=obj --mattr=+experimental-zknd %s \ +# RUN: | llvm-objdump -d - | FileCheck %s --check-prefix=CHECK-UNKNOWN + +# CHECK-INST: aes32dsi t0, a2, 3 +# CHECK-ENCODING: [0x33,0x80,0xc2,0xfa] +# CHECK-ERROR: instruction requires the following: 'Zknd'(NIST AES Decryption Instructions) +# CHECK-UNKNOWN: 33 80 c2 fa +aes32dsi t0, a2, 3 + +# CHECK-INST: aes32dsmi t0, a2, 3 +# CHECK-ENCODING: [0x33,0x80,0xc2,0xfe] +# CHECK-ERROR: instruction requires the following: 'Zknd'(NIST AES Decryption Instructions) +# CHECK-UNKNOWN: 33 80 c2 fe +aes32dsmi t0, a2, 3 diff --git a/llvm/test/MC/RISCV/rv32zkne-only-invalid.s b/llvm/test/MC/RISCV/rv32zkne-only-invalid.s new file mode 100644 --- /dev/null +++ b/llvm/test/MC/RISCV/rv32zkne-only-invalid.s @@ -0,0 +1,17 @@ +# With K extension: +# RUN: not llvm-mc -triple=riscv32 -mattr=+experimental-k < %s 2>&1 \ +# RUN: | FileCheck %s --check-prefix=CHECK-ERROR + +# With Zkn extension: +# RUN: not llvm-mc -triple=riscv32 -mattr=+experimental-zkn < %s 2>&1 \ +# RUN: | FileCheck %s --check-prefix=CHECK-ERROR + +# With Zkne extension: +# RUN: not llvm-mc -triple=riscv32 -mattr=+experimental-zkne < %s 2>&1 \ +# RUN: | FileCheck %s --check-prefix=CHECK-ERROR + +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] diff --git a/llvm/test/MC/RISCV/rv32zkne-only-valid.s b/llvm/test/MC/RISCV/rv32zkne-only-valid.s new file mode 100644 --- /dev/null +++ b/llvm/test/MC/RISCV/rv32zkne-only-valid.s @@ -0,0 +1,44 @@ +# With K extension: +# 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 + +# With Zkn extension: +# RUN: llvm-mc -triple=riscv32 -show-encoding --mattr=+experimental-zkn %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-zkn %s \ +# RUN: | llvm-objdump -d --mattr=+experimental-zkn - \ +# RUN: | FileCheck %s --check-prefix=CHECK-INST +# RUN: llvm-mc -triple=riscv32 -filetype=obj --mattr=+experimental-zkn %s \ +# RUN: | llvm-objdump -d - | FileCheck %s --check-prefix=CHECK-UNKNOWN + +# With Zkne extension: +# RUN: llvm-mc -triple=riscv32 -show-encoding --mattr=+experimental-zkne %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-zkne %s \ +# RUN: | llvm-objdump -d --mattr=+experimental-zkne - \ +# RUN: | FileCheck %s --check-prefix=CHECK-INST +# RUN: llvm-mc -triple=riscv32 -filetype=obj --mattr=+experimental-zkne %s \ +# RUN: | llvm-objdump -d - | FileCheck %s --check-prefix=CHECK-UNKNOWN + +# CHECK-INST: aes32esi t0, a2, 3 +# CHECK-ENCODING: [0x33,0x80,0xc2,0xf2] +# CHECK-ERROR: instruction requires the following: 'Zkne'(NIST AES Encryption Instructions) +# CHECK-UNKNOWN: 33 80 c2 f2 +aes32esi t0, a2, 3 + +# CHECK-INST: aes32esmi t0, a2, 3 +# CHECK-ENCODING: [0x33,0x80,0xc2,0xf6] +# CHECK-ERROR: instruction requires the following: 'Zkne'(NIST AES Encryption Instructions) +# CHECK-UNKNOWN: 33 80 c2 f6 +aes32esmi t0, a2, 3 diff --git a/llvm/test/MC/RISCV/rv32zknh-only-valid.s b/llvm/test/MC/RISCV/rv32zknh-only-valid.s new file mode 100644 --- /dev/null +++ b/llvm/test/MC/RISCV/rv32zknh-only-valid.s @@ -0,0 +1,68 @@ +# With K extension: +# 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 + +# With Zkn extension: +# RUN: llvm-mc -triple=riscv32 -show-encoding --mattr=+experimental-zkn %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-zkn %s \ +# RUN: | llvm-objdump -d --mattr=+experimental-zkn - \ +# RUN: | FileCheck %s --check-prefix=CHECK-INST +# RUN: llvm-mc -triple=riscv32 -filetype=obj --mattr=+experimental-zkn %s \ +# RUN: | llvm-objdump -d - | FileCheck %s --check-prefix=CHECK-UNKNOWN + +# With Zknh extension: +# RUN: llvm-mc -triple=riscv32 -show-encoding --mattr=+experimental-zknh %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-zknh %s \ +# RUN: | llvm-objdump -d --mattr=+experimental-zknh - \ +# RUN: | FileCheck %s --check-prefix=CHECK-INST +# RUN: llvm-mc -triple=riscv32 -filetype=obj --mattr=+experimental-zknh %s \ +# RUN: | llvm-objdump -d - | FileCheck %s --check-prefix=CHECK-UNKNOWN + +# CHECK-INST: sha512sig0h a0, a1, a2 +# CHECK-ENCODING: [0x33,0x85,0xc5,0x5c] +# CHECK-ERROR: instruction requires the following: 'Zknh'(NIST SHA2 Hash function instructions) +# CHECK-UNKNOWN: 33 85 c5 5c +sha512sig0h a0, a1, a2 + +# CHECK-INST: sha512sig1h a0, a1, a2 +# CHECK-ENCODING: [0x33,0x85,0xc5,0x5e] +# CHECK-ERROR: instruction requires the following: 'Zknh'(NIST SHA2 Hash function instructions) +# CHECK-UNKNOWN: 33 85 c5 5e +sha512sig1h a0, a1, a2 + +# CHECK-INST: sha512sig0l a0, a1, a2 +# CHECK-ENCODING: [0x33,0x85,0xc5,0x54] +# CHECK-ERROR: instruction requires the following: 'Zknh'(NIST SHA2 Hash function instructions) +# CHECK-UNKNOWN: 33 85 c5 54 +sha512sig0l a0, a1, a2 + +# CHECK-INST: sha512sig1l a0, a1, a2 +# CHECK-ENCODING: [0x33,0x85,0xc5,0x56] +# CHECK-ERROR: instruction requires the following: 'Zknh'(NIST SHA2 Hash function instructions) +# CHECK-UNKNOWN: 33 85 c5 56 +sha512sig1l a0, a1, a2 + +# CHECK-INST: sha512sum0r a0, a1, a2 +# CHECK-ENCODING: [0x33,0x85,0xc5,0x50] +# CHECK-ERROR: instruction requires the following: 'Zknh'(NIST SHA2 Hash function instructions) +# CHECK-UNKNOWN: 33 85 c5 50 +sha512sum0r a0, a1, a2 + +# CHECK-INST: sha512sum1r a0, a1, a2 +# CHECK-ENCODING: [0x33,0x85,0xc5,0x52] +# CHECK-ERROR: instruction requires the following: 'Zknh'(NIST SHA2 Hash function instructions) +# CHECK-UNKNOWN: 33 85 c5 52 +sha512sum1r a0, a1, a2 diff --git a/llvm/test/MC/RISCV/rv32zknh-valid.s b/llvm/test/MC/RISCV/rv32zknh-valid.s new file mode 100644 --- /dev/null +++ b/llvm/test/MC/RISCV/rv32zknh-valid.s @@ -0,0 +1,56 @@ +# With K extension: +# 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 + +# With Zkn extension: +# RUN: llvm-mc -triple=riscv32 -show-encoding --mattr=+experimental-zkn %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-zkn %s \ +# RUN: | llvm-objdump -d --mattr=+experimental-zkn - \ +# RUN: | FileCheck %s --check-prefix=CHECK-INST +# RUN: llvm-mc -triple=riscv32 -filetype=obj --mattr=+experimental-zkn %s \ +# RUN: | llvm-objdump -d - | FileCheck %s --check-prefix=CHECK-UNKNOWN + +# With Zknh extension: +# RUN: llvm-mc -triple=riscv32 -show-encoding --mattr=+experimental-zknh %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-zknh %s \ +# RUN: | llvm-objdump -d --mattr=+experimental-zknh - \ +# RUN: | FileCheck %s --check-prefix=CHECK-INST +# RUN: llvm-mc -triple=riscv32 -filetype=obj --mattr=+experimental-zknh %s \ +# RUN: | llvm-objdump -d - | FileCheck %s --check-prefix=CHECK-UNKNOWN + +# CHECK-INST: sha256sig0 a0, a1 +# CHECK-ENCODING: [0x13,0x95,0x25,0x10] +# CHECK-ERROR: instruction requires the following: 'Zknh'(NIST SHA2 Hash function instructions) +# CHECK-UNKNOWN: 13 95 25 10 +sha256sig0 a0, a1 + +# CHECK-INST: sha256sig1 a0, a1 +# CHECK-ENCODING: [0x13,0x95,0x35,0x10] +# CHECK-ERROR: instruction requires the following: 'Zknh'(NIST SHA2 Hash function instructions) +# CHECK-UNKNOWN: 13 95 35 10 +sha256sig1 a0, a1 + +# CHECK-INST: sha256sum0 a0, a1 +# CHECK-ENCODING: [0x13,0x95,0x05,0x10] +# CHECK-ERROR: instruction requires the following: 'Zknh'(NIST SHA2 Hash function instructions) +# CHECK-UNKNOWN: 13 95 05 10 +sha256sum0 a0, a1 + +# CHECK-INST: sha256sum1 a0, a1 +# CHECK-ENCODING: [0x13,0x95,0x15,0x10] +# CHECK-ERROR: instruction requires the following: 'Zknh'(NIST SHA2 Hash function instructions) +# CHECK-UNKNOWN: 13 95 15 10 +sha256sum1 a0, a1 diff --git a/llvm/test/MC/RISCV/rv32zkr-valid.s b/llvm/test/MC/RISCV/rv32zkr-valid.s new file mode 100644 --- /dev/null +++ b/llvm/test/MC/RISCV/rv32zkr-valid.s @@ -0,0 +1,33 @@ +# With K extension: +# 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 + +# With Zkr extension: +# RUN: llvm-mc -triple=riscv32 -show-encoding --mattr=+experimental-zkr %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-zkr %s \ +# RUN: | llvm-objdump -d --mattr=+experimental-zkr - \ +# RUN: | FileCheck %s --check-prefix=CHECK-INST +# RUN: llvm-mc -triple=riscv32 -filetype=obj --mattr=+experimental-zkr %s \ +# RUN: | llvm-objdump -d - | FileCheck %s --check-prefix=CHECK-UNKNOWN + +# CHECK-INST: csrr a0, mnoise +# CHECK-ENCODING: [0x73,0x25,0x90,0x7a] +# CHECK-ERROR: instruction requires the following: 'Zkr'(Entropy source for seeding random number generators) +# CHECK-UNKNOWN: 73 25 90 7a +getnoise a0 + +# CHECK-INST: csrr a0, mentropy +# CHECK-ENCODING: [0x73,0x25,0x50,0xf1] +# CHECK-ERROR: instruction requires the following: 'Zkr'(Entropy source for seeding random number generators) +# CHECK-UNKNOWN: 73 25 50 f1 +pollentropy a0 diff --git a/llvm/test/MC/RISCV/rv32zksed-invalid.s b/llvm/test/MC/RISCV/rv32zksed-invalid.s new file mode 100644 --- /dev/null +++ b/llvm/test/MC/RISCV/rv32zksed-invalid.s @@ -0,0 +1,13 @@ +# With Zks extension: +# RUN: not llvm-mc -triple=riscv32 -mattr=+experimental-zks < %s 2>&1 \ +# RUN: | FileCheck %s --check-prefix=CHECK-ERROR + +# With Zksed extension: +# RUN: not llvm-mc -triple=riscv32 -mattr=+experimental-zksed < %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] diff --git a/llvm/test/MC/RISCV/rv32zksed-valid.s b/llvm/test/MC/RISCV/rv32zksed-valid.s new file mode 100644 --- /dev/null +++ b/llvm/test/MC/RISCV/rv32zksed-valid.s @@ -0,0 +1,33 @@ +# With Zks extension: +# RUN: llvm-mc -triple=riscv32 -show-encoding --mattr=+experimental-zks %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-zks %s \ +# RUN: | llvm-objdump -d --mattr=+experimental-zks - \ +# RUN: | FileCheck %s --check-prefix=CHECK-INST +# RUN: llvm-mc -triple=riscv32 -filetype=obj --mattr=+experimental-zks %s \ +# RUN: | llvm-objdump -d - | FileCheck %s --check-prefix=CHECK-UNKNOWN + +# With Zksed extension: +# RUN: llvm-mc -triple=riscv32 -show-encoding --mattr=+experimental-zksed %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-zksed %s \ +# RUN: | llvm-objdump -d --mattr=+experimental-zksed - \ +# RUN: | FileCheck %s --check-prefix=CHECK-INST +# RUN: llvm-mc -triple=riscv32 -filetype=obj --mattr=+experimental-zksed %s \ +# RUN: | llvm-objdump -d - | FileCheck %s --check-prefix=CHECK-UNKNOWN + +# CHECK-INST: sm4ed t0, a2, 3 +# CHECK-ENCODING: [0x33,0x80,0xc2,0xf0] +# CHECK-ERROR: instruction requires the following: 'Zksed'(SM4 Instructions) +# CHECK-UNKNOWN: 33 80 c2 f0 +sm4ed t0, a2, 3 + +# CHECK-INST: sm4ks t0, a2, 3 +# CHECK-ENCODING: [0x33,0x80,0xc2,0xf4] +# CHECK-ERROR: instruction requires the following: 'Zksed'(SM4 Instructions) +# CHECK-UNKNOWN: 33 80 c2 f4 +sm4ks t0, a2, 3 diff --git a/llvm/test/MC/RISCV/rv32zksh-valid.s b/llvm/test/MC/RISCV/rv32zksh-valid.s new file mode 100644 --- /dev/null +++ b/llvm/test/MC/RISCV/rv32zksh-valid.s @@ -0,0 +1,34 @@ +# With Zks extension: +# RUN: llvm-mc -triple=riscv32 -show-encoding --mattr=+experimental-zks %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-zks %s \ +# RUN: | llvm-objdump -d --mattr=+experimental-zks - \ +# RUN: | FileCheck %s --check-prefix=CHECK-INST +# RUN: llvm-mc -triple=riscv32 -filetype=obj --mattr=+experimental-zks %s \ +# RUN: | llvm-objdump -d - | FileCheck %s --check-prefix=CHECK-UNKNOWN + +# With Zksh extension: +# RUN: llvm-mc -triple=riscv32 -show-encoding --mattr=+experimental-zksh %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-zksh %s \ +# RUN: | llvm-objdump -d --mattr=+experimental-zksh - \ +# RUN: | FileCheck %s --check-prefix=CHECK-INST +# RUN: llvm-mc -triple=riscv32 -filetype=obj --mattr=+experimental-zksh %s \ +# RUN: | llvm-objdump -d - | FileCheck %s --check-prefix=CHECK-UNKNOWN + + +# CHECK-INST: sm3p0 a0, a1 +# CHECK-ENCODING: [0x13,0x95,0x85,0x10] +# CHECK-ERROR: instruction requires the following: 'Zksh'(SM3 Hash function instructions) +# CHECK-UNKNOWN: 13 95 85 10 +sm3p0 a0, a1 + +# CHECK-INST: sm3p1 a0, a1 +# CHECK-ENCODING: [0x13,0x95,0x95,0x10] +# CHECK-ERROR: instruction requires the following: 'Zksh'(SM3 Hash function instructions) +# CHECK-UNKNOWN: 13 95 95 10 +sm3p1 a0, a1 diff --git a/llvm/test/MC/RISCV/rv64zkb-aliases-valid.s b/llvm/test/MC/RISCV/rv64zkb-aliases-valid.s new file mode 100644 --- /dev/null +++ b/llvm/test/MC/RISCV/rv64zkb-aliases-valid.s @@ -0,0 +1,60 @@ +# With K extension: +# RUN: llvm-mc %s -triple=riscv64 -mattr=+experimental-k -riscv-no-aliases \ +# RUN: | FileCheck -check-prefixes=CHECK-S-OBJ-NOALIAS %s +# RUN: llvm-mc %s -triple=riscv64 -mattr=+experimental-k \ +# RUN: | FileCheck -check-prefixes=CHECK-S-OBJ %s +# RUN: llvm-mc -filetype=obj -triple riscv64 -mattr=+experimental-k < %s \ +# RUN: | llvm-objdump -d -r --riscv-no-aliases --mattr=+experimental-k - \ +# RUN: | FileCheck -check-prefixes=CHECK-S-OBJ-NOALIAS %s +# RUN: llvm-mc -filetype=obj -triple riscv64 -mattr=+experimental-k < %s \ +# RUN: | llvm-objdump -d -r --mattr=+experimental-k - \ +# RUN: | FileCheck -check-prefixes=CHECK-S-OBJ %s + +# With Zkn extension: +# RUN: llvm-mc %s -triple=riscv64 -mattr=+experimental-zkn -riscv-no-aliases \ +# RUN: | FileCheck -check-prefixes=CHECK-S-OBJ-NOALIAS %s +# RUN: llvm-mc %s -triple=riscv64 -mattr=+experimental-zkn \ +# RUN: | FileCheck -check-prefixes=CHECK-S-OBJ %s +# RUN: llvm-mc -filetype=obj -triple riscv64 -mattr=+experimental-zkn < %s \ +# RUN: | llvm-objdump -d -r --riscv-no-aliases --mattr=+experimental-zkn - \ +# RUN: | FileCheck -check-prefixes=CHECK-S-OBJ-NOALIAS %s +# RUN: llvm-mc -filetype=obj -triple riscv64 -mattr=+experimental-zkn < %s \ +# RUN: | llvm-objdump -d -r --mattr=+experimental-zkn - \ +# RUN: | FileCheck -check-prefixes=CHECK-S-OBJ %s + +# With Zks extension: +# RUN: llvm-mc %s -triple=riscv64 -mattr=+experimental-zks -riscv-no-aliases \ +# RUN: | FileCheck -check-prefixes=CHECK-S-OBJ-NOALIAS %s +# RUN: llvm-mc %s -triple=riscv64 -mattr=+experimental-zks \ +# RUN: | FileCheck -check-prefixes=CHECK-S-OBJ %s +# RUN: llvm-mc -filetype=obj -triple riscv64 -mattr=+experimental-zks < %s \ +# RUN: | llvm-objdump -d -r --riscv-no-aliases --mattr=+experimental-zks - \ +# RUN: | FileCheck -check-prefixes=CHECK-S-OBJ-NOALIAS %s +# RUN: llvm-mc -filetype=obj -triple riscv64 -mattr=+experimental-zks < %s \ +# RUN: | llvm-objdump -d -r --mattr=+experimental-zks - \ +# RUN: | FileCheck -check-prefixes=CHECK-S-OBJ %s + +# With Zkb extension: +# RUN: llvm-mc %s -triple=riscv64 -mattr=+experimental-zkb -riscv-no-aliases \ +# RUN: | FileCheck -check-prefixes=CHECK-S-OBJ-NOALIAS %s +# RUN: llvm-mc %s -triple=riscv64 -mattr=+experimental-zkb \ +# RUN: | FileCheck -check-prefixes=CHECK-S-OBJ %s +# RUN: llvm-mc -filetype=obj -triple riscv64 -mattr=+experimental-zkb < %s \ +# RUN: | llvm-objdump -d -r --riscv-no-aliases --mattr=+experimental-zkb - \ +# RUN: | FileCheck -check-prefixes=CHECK-S-OBJ-NOALIAS %s +# RUN: llvm-mc -filetype=obj -triple riscv64 -mattr=+experimental-zkb < %s \ +# RUN: | llvm-objdump -d -r --mattr=+experimental-zkb - \ +# RUN: | FileCheck -check-prefixes=CHECK-S-OBJ %s + + +# CHECK-S-OBJ-NOALIAS: grevi t0, t1, 7 +# CHECK-S-OBJ: rev.b t0, t1 +rev.b x5, x6 + +# CHECK-S-OBJ-NOALIAS: shfli t0, t1, 31 +# CHECK-S-OBJ: zip t0, t1 +zip x5, x6 + +# CHECK-S-OBJ-NOALIAS: unshfli t0, t1, 31 +# CHECK-S-OBJ: unzip t0, t1 +unzip x5, x6 diff --git a/llvm/test/MC/RISCV/rv64zkb-only-aliases-valid.s b/llvm/test/MC/RISCV/rv64zkb-only-aliases-valid.s new file mode 100644 --- /dev/null +++ b/llvm/test/MC/RISCV/rv64zkb-only-aliases-valid.s @@ -0,0 +1,52 @@ +# With K extension: +# RUN: llvm-mc %s -triple=riscv64 -mattr=+experimental-k -riscv-no-aliases \ +# RUN: | FileCheck -check-prefixes=CHECK-S-OBJ-NOALIAS %s +# RUN: llvm-mc %s -triple=riscv64 -mattr=+experimental-k \ +# RUN: | FileCheck -check-prefixes=CHECK-S-OBJ %s +# RUN: llvm-mc -filetype=obj -triple riscv64 -mattr=+experimental-k < %s \ +# RUN: | llvm-objdump -d -r --riscv-no-aliases --mattr=+experimental-k - \ +# RUN: | FileCheck -check-prefixes=CHECK-S-OBJ-NOALIAS %s +# RUN: llvm-mc -filetype=obj -triple riscv64 -mattr=+experimental-k < %s \ +# RUN: | llvm-objdump -d -r --mattr=+experimental-k - \ +# RUN: | FileCheck -check-prefixes=CHECK-S-OBJ %s + +# With Zkn extension: +# RUN: llvm-mc %s -triple=riscv64 -mattr=+experimental-zkn -riscv-no-aliases \ +# RUN: | FileCheck -check-prefixes=CHECK-S-OBJ-NOALIAS %s +# RUN: llvm-mc %s -triple=riscv64 -mattr=+experimental-zkn \ +# RUN: | FileCheck -check-prefixes=CHECK-S-OBJ %s +# RUN: llvm-mc -filetype=obj -triple riscv64 -mattr=+experimental-zkn < %s \ +# RUN: | llvm-objdump -d -r --riscv-no-aliases --mattr=+experimental-zkn - \ +# RUN: | FileCheck -check-prefixes=CHECK-S-OBJ-NOALIAS %s +# RUN: llvm-mc -filetype=obj -triple riscv64 -mattr=+experimental-zkn < %s \ +# RUN: | llvm-objdump -d -r --mattr=+experimental-zkn - \ +# RUN: | FileCheck -check-prefixes=CHECK-S-OBJ %s + +# With Zks extension: +# RUN: llvm-mc %s -triple=riscv64 -mattr=+experimental-zks -riscv-no-aliases \ +# RUN: | FileCheck -check-prefixes=CHECK-S-OBJ-NOALIAS %s +# RUN: llvm-mc %s -triple=riscv64 -mattr=+experimental-zks \ +# RUN: | FileCheck -check-prefixes=CHECK-S-OBJ %s +# RUN: llvm-mc -filetype=obj -triple riscv64 -mattr=+experimental-zks < %s \ +# RUN: | llvm-objdump -d -r --riscv-no-aliases --mattr=+experimental-zks - \ +# RUN: | FileCheck -check-prefixes=CHECK-S-OBJ-NOALIAS %s +# RUN: llvm-mc -filetype=obj -triple riscv64 -mattr=+experimental-zks < %s \ +# RUN: | llvm-objdump -d -r --mattr=+experimental-zks - \ +# RUN: | FileCheck -check-prefixes=CHECK-S-OBJ %s + +# With Zkb extension: +# RUN: llvm-mc %s -triple=riscv64 -mattr=+experimental-zkb -riscv-no-aliases \ +# RUN: | FileCheck -check-prefixes=CHECK-S-OBJ-NOALIAS %s +# RUN: llvm-mc %s -triple=riscv64 -mattr=+experimental-zkb \ +# RUN: | FileCheck -check-prefixes=CHECK-S-OBJ %s +# RUN: llvm-mc -filetype=obj -triple riscv64 -mattr=+experimental-zkb < %s \ +# RUN: | llvm-objdump -d -r --riscv-no-aliases --mattr=+experimental-zkb - \ +# RUN: | FileCheck -check-prefixes=CHECK-S-OBJ-NOALIAS %s +# RUN: llvm-mc -filetype=obj -triple riscv64 -mattr=+experimental-zkb < %s \ +# RUN: | llvm-objdump -d -r --mattr=+experimental-zkb - \ +# RUN: | FileCheck -check-prefixes=CHECK-S-OBJ %s + + +# CHECK-S-OBJ-NOALIAS: grevi t0, t1, 24 +# CHECK-S-OBJ: rev8.w t0, t1 +rev8.w x5, x6 diff --git a/llvm/test/MC/RISCV/rv64zkb-only-valid.s b/llvm/test/MC/RISCV/rv64zkb-only-valid.s new file mode 100644 --- /dev/null +++ b/llvm/test/MC/RISCV/rv64zkb-only-valid.s @@ -0,0 +1,44 @@ +# With K extension: +# RUN: llvm-mc -triple=riscv64 -show-encoding --mattr=+experimental-k %s \ +# RUN: | FileCheck -check-prefixes=CHECK-ASM,CHECK-ASM-AND-OBJ %s +# RUN: llvm-mc -triple=riscv64 -filetype=obj --mattr=+experimental-k %s \ +# RUN: | llvm-objdump -d --mattr=+experimental-k - \ +# RUN: | FileCheck %s --check-prefixes=CHECK-ASM-AND-OBJ + +# With Zkn extension: +# RUN: llvm-mc -triple=riscv64 -show-encoding --mattr=+experimental-zkn %s \ +# RUN: | FileCheck -check-prefixes=CHECK-ASM,CHECK-ASM-AND-OBJ %s +# RUN: llvm-mc -triple=riscv64 -filetype=obj --mattr=+experimental-zkn %s \ +# RUN: | llvm-objdump -d --mattr=+experimental-zkn - \ +# RUN: | FileCheck %s --check-prefixes=CHECK-ASM-AND-OBJ + +# With Zks extension: +# RUN: llvm-mc -triple=riscv64 -show-encoding --mattr=+experimental-zks %s \ +# RUN: | FileCheck -check-prefixes=CHECK-ASM,CHECK-ASM-AND-OBJ %s +# RUN: llvm-mc -triple=riscv64 -filetype=obj --mattr=+experimental-zks %s \ +# RUN: | llvm-objdump -d --mattr=+experimental-zks - \ +# RUN: | FileCheck %s --check-prefixes=CHECK-ASM-AND-OBJ + +# With Zkb extension: +# RUN: llvm-mc -triple=riscv64 -show-encoding --mattr=+experimental-zkb %s \ +# RUN: | FileCheck -check-prefixes=CHECK-ASM,CHECK-ASM-AND-OBJ %s +# RUN: llvm-mc -triple=riscv64 -filetype=obj --mattr=+experimental-zkb %s \ +# RUN: | llvm-objdump -d --mattr=+experimental-zkb - \ +# RUN: | FileCheck %s --check-prefixes=CHECK-ASM-AND-OBJ + + +# CHECK-ASM-AND-OBJ: roriw t0, t1, 31 +# CHECK-ASM: encoding: [0x9b,0x52,0xf3,0x61] +roriw t0, t1, 31 + +# CHECK-ASM-AND-OBJ: roriw t0, t1, 0 +# CHECK-ASM: encoding: [0x9b,0x52,0x03,0x60] +roriw t0, t1, 0 + +# CHECK-ASM-AND-OBJ: packw t0, t1, t2 +# CHECK-ASM: encoding: [0xbb,0x42,0x73,0x08] +packw t0, t1, t2 + +# CHECK-ASM-AND-OBJ: packuw t0, t1, t2 +# CHECK-ASM: encoding: [0xbb,0x42,0x73,0x48] +packuw t0, t1, t2 diff --git a/llvm/test/MC/RISCV/rv64zkb-valid.s b/llvm/test/MC/RISCV/rv64zkb-valid.s new file mode 100644 --- /dev/null +++ b/llvm/test/MC/RISCV/rv64zkb-valid.s @@ -0,0 +1,92 @@ +# With K extension: +# RUN: llvm-mc -triple=riscv64 -show-encoding --mattr=+experimental-k %s \ +# RUN: | FileCheck -check-prefixes=CHECK-ASM,CHECK-ASM-AND-OBJ %s +# RUN: llvm-mc -triple=riscv64 -filetype=obj --mattr=+experimental-k %s \ +# RUN: | llvm-objdump -d --mattr=+experimental-k - \ +# RUN: | FileCheck %s --check-prefixes=CHECK-ASM-AND-OBJ + +# With Zkn extension: +# RUN: llvm-mc -triple=riscv64 -show-encoding --mattr=+experimental-zkn %s \ +# RUN: | FileCheck -check-prefixes=CHECK-ASM,CHECK-ASM-AND-OBJ %s +# RUN: llvm-mc -triple=riscv64 -filetype=obj --mattr=+experimental-zkn %s \ +# RUN: | llvm-objdump -d --mattr=+experimental-zkn - \ +# RUN: | FileCheck %s --check-prefixes=CHECK-ASM-AND-OBJ + +# With Zks extension: +# RUN: llvm-mc -triple=riscv64 -show-encoding --mattr=+experimental-zks %s \ +# RUN: | FileCheck -check-prefixes=CHECK-ASM,CHECK-ASM-AND-OBJ %s +# RUN: llvm-mc -triple=riscv64 -filetype=obj --mattr=+experimental-zks %s \ +# RUN: | llvm-objdump -d --mattr=+experimental-zks - \ +# RUN: | FileCheck %s --check-prefixes=CHECK-ASM-AND-OBJ + +# With Zkb extension: +# RUN: llvm-mc -triple=riscv64 -show-encoding --mattr=+experimental-zkb %s \ +# RUN: | FileCheck -check-prefixes=CHECK-ASM,CHECK-ASM-AND-OBJ %s +# RUN: llvm-mc -triple=riscv64 -filetype=obj --mattr=+experimental-zkb %s \ +# RUN: | llvm-objdump -d --mattr=+experimental-zkb - \ +# RUN: | FileCheck %s --check-prefixes=CHECK-ASM-AND-OBJ + + +# CHECK-ASM-AND-OBJ: xperm.n t0, t1, t2 +# CHECK-ASM: encoding: [0xb3,0x22,0x73,0x28] +xperm.n t0, t1, t2 + +# CHECK-ASM-AND-OBJ: xperm.b t0, t1, t2 +# CHECK-ASM: encoding: [0xb3,0x42,0x73,0x28] +xperm.b t0, t1, t2 + +# CHECK-ASM-AND-OBJ: ror t0, t1, t2 +# CHECK-ASM: encoding: [0xb3,0x52,0x73,0x60] +ror t0, t1, t2 + +# CHECK-ASM-AND-OBJ: rol t0, t1, t2 +# CHECK-ASM: encoding: [0xb3,0x12,0x73,0x60] +rol t0, t1, t2 + +# CHECK-ASM-AND-OBJ: rori t0, t1, 31 +# CHECK-ASM: encoding: [0x93,0x52,0xf3,0x61] +rori t0, t1, 31 + +# CHECK-ASM-AND-OBJ: rori t0, t1, 0 +# CHECK-ASM: encoding: [0x93,0x52,0x03,0x60] +rori t0, t1, 0 + +# CHECK-ASM-AND-OBJ: andn t0, t1, t2 +# CHECK-ASM: encoding: [0xb3,0x72,0x73,0x40] +andn t0, t1, t2 + +# CHECK-ASM-AND-OBJ: orn t0, t1, t2 +# CHECK-ASM: encoding: [0xb3,0x62,0x73,0x40] +orn t0, t1, t2 + +# CHECK-ASM-AND-OBJ: xnor t0, t1, t2 +# CHECK-ASM: encoding: [0xb3,0x42,0x73,0x40] +xnor t0, t1, t2 + +# CHECK-ASM-AND-OBJ: pack t0, t1, t2 +# CHECK-ASM: encoding: [0xb3,0x42,0x73,0x08] +pack t0, t1, t2 + +# CHECK-ASM-AND-OBJ: packu t0, t1, t2 +# CHECK-ASM: encoding: [0xb3,0x42,0x73,0x48] +packu t0, t1, t2 + +# CHECK-ASM-AND-OBJ: packh t0, t1, t2 +# CHECK-ASM: encoding: [0xb3,0x72,0x73,0x08] +packh t0, t1, t2 + +# CHECK-ASM-AND-OBJ: rev8 t0, t1 +# CHECK-ASM: encoding: [0x93,0x52,0x83,0x6b] +rev8 t0, t1 + +# CHECK-ASM-AND-OBJ: grevi t0, t1, 0 +# CHECK-ASM: encoding: [0x93,0x52,0x03,0x68] +grevi t0, t1, 0 + +# CHECK-ASM-AND-OBJ: shfli t0, t1, 0 +# CHECK-ASM: encoding: [0x93,0x12,0x03,0x08] +shfli t0, t1, 0 + +# CHECK-ASM-AND-OBJ: unshfli t0, t1, 0 +# CHECK-ASM: encoding: [0x93,0x52,0x03,0x08] +unshfli t0, t1, 0 diff --git a/llvm/test/MC/RISCV/rv64zkg-valid.s b/llvm/test/MC/RISCV/rv64zkg-valid.s new file mode 100644 --- /dev/null +++ b/llvm/test/MC/RISCV/rv64zkg-valid.s @@ -0,0 +1,35 @@ +# With K extension: +# RUN: llvm-mc -triple=riscv64 -show-encoding --mattr=+experimental-k %s \ +# RUN: | FileCheck %s --check-prefixes=CHECK-ENCODING,CHECK-INST +# 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 + +# With Zkn extension: +# RUN: llvm-mc -triple=riscv64 -show-encoding --mattr=+experimental-zkn %s \ +# RUN: | FileCheck %s --check-prefixes=CHECK-ENCODING,CHECK-INST +# RUN: llvm-mc -triple=riscv64 -filetype=obj --mattr=+experimental-zkn %s \ +# RUN: | llvm-objdump -d --mattr=+experimental-zkn - \ +# RUN: | FileCheck %s --check-prefix=CHECK-INST + +# With Zks extension: +# RUN: llvm-mc -triple=riscv64 -show-encoding --mattr=+experimental-zks %s \ +# RUN: | FileCheck %s --check-prefixes=CHECK-ENCODING,CHECK-INST +# RUN: llvm-mc -triple=riscv64 -filetype=obj --mattr=+experimental-zks %s \ +# RUN: | llvm-objdump -d --mattr=+experimental-zks - \ +# RUN: | FileCheck %s --check-prefix=CHECK-INST + +# With Zkg extension: +# RUN: llvm-mc -triple=riscv64 -show-encoding --mattr=+experimental-zkg %s \ +# RUN: | FileCheck %s --check-prefixes=CHECK-ENCODING,CHECK-INST +# RUN: llvm-mc -triple=riscv64 -filetype=obj --mattr=+experimental-zkg %s \ +# RUN: | llvm-objdump -d --mattr=+experimental-zkg - \ +# RUN: | FileCheck %s --check-prefix=CHECK-INST + +# CHECK-INST: clmul t0, t1, t2 +# CHECK-ENCODING: [0xb3,0x12,0x73,0x0a] +clmul t0, t1, t2 + +# CHECK-INST: clmulh t0, t1, t2 +# CHECK-ENCODING: [0xb3,0x32,0x73,0x0a] +clmulh t0, t1, t2 diff --git a/llvm/test/MC/RISCV/rv64zknd-only-valid.s b/llvm/test/MC/RISCV/rv64zknd-only-valid.s new file mode 100644 --- /dev/null +++ b/llvm/test/MC/RISCV/rv64zknd-only-valid.s @@ -0,0 +1,50 @@ +# With K extension: +# 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 + +# With Zkn extension: +# RUN: llvm-mc -triple=riscv64 -show-encoding --mattr=+experimental-zkn %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-zkn %s \ +# RUN: | llvm-objdump -d --mattr=+experimental-zkn - \ +# RUN: | FileCheck %s --check-prefix=CHECK-INST +# RUN: llvm-mc -triple=riscv64 -filetype=obj --mattr=+experimental-zkn %s \ +# RUN: | llvm-objdump -d - | FileCheck %s --check-prefix=CHECK-UNKNOWN + +# With Zknd extension: +# RUN: llvm-mc -triple=riscv64 -show-encoding --mattr=+experimental-zknd %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-zknd %s \ +# RUN: | llvm-objdump -d --mattr=+experimental-zknd - \ +# RUN: | FileCheck %s --check-prefix=CHECK-INST +# RUN: llvm-mc -triple=riscv64 -filetype=obj --mattr=+experimental-zknd %s \ +# RUN: | llvm-objdump -d - | FileCheck %s --check-prefix=CHECK-UNKNOWN + +# CHECK-INST: aes64ds a0, a1, a2 +# CHECK-ENCODING: [0x33,0x85,0xc5,0x3a] +# CHECK-ERROR: instruction requires the following: 'Zknd'(NIST AES Decryption Instructions) +# CHECK-UNKNOWN: 33 85 c5 3a +aes64ds a0, a1, a2 + +# CHECK-INST: aes64dsm a0, a1, a2 +# CHECK-ENCODING: [0x33,0x85,0xc5,0x3e] +# CHECK-ERROR: instruction requires the following: 'Zknd'(NIST AES Decryption Instructions) +# CHECK-UNKNOWN: 33 85 c5 3e +aes64dsm a0, a1, a2 + +# CHECK-INST: aes64im a0, a1 +# CHECK-ENCODING: [0x13,0x95,0x05,0x30] +# CHECK-ERROR: instruction requires the following: 'Zknd'(NIST AES Decryption Instructions) +# CHECK-UNKNOWN: 13 95 05 30 +aes64im a0, a1 diff --git a/llvm/test/MC/RISCV/rv64zkne-only-invalid.s b/llvm/test/MC/RISCV/rv64zkne-only-invalid.s new file mode 100644 --- /dev/null +++ b/llvm/test/MC/RISCV/rv64zkne-only-invalid.s @@ -0,0 +1,17 @@ +# With K extension: +# RUN: not llvm-mc -triple=riscv64 -mattr=+experimental-k < %s 2>&1 \ +# RUN: | FileCheck %s --check-prefix=CHECK-ERROR + +# With Zkn extension: +# RUN: not llvm-mc -triple=riscv64 -mattr=+experimental-zkn < %s 2>&1 \ +# RUN: | FileCheck %s --check-prefix=CHECK-ERROR + +# With Zkne extension: +# RUN: not llvm-mc -triple=riscv64 -mattr=+experimental-zkne < %s 2>&1 \ +# RUN: | FileCheck %s --check-prefix=CHECK-ERROR + +aes64ks1i a0, a1, 11 +# CHECK-ERROR: immediate must be an integer in the range [0, 10] + +aes64ks1i a0, a1, -1 +# CHECK-ERROR: immediate must be an integer in the range [0, 10] diff --git a/llvm/test/MC/RISCV/rv64zkne-only-valid.s b/llvm/test/MC/RISCV/rv64zkne-only-valid.s new file mode 100644 --- /dev/null +++ b/llvm/test/MC/RISCV/rv64zkne-only-valid.s @@ -0,0 +1,56 @@ +# With K extension: +# 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 + +# With Zkn extension: +# RUN: llvm-mc -triple=riscv64 -show-encoding --mattr=+experimental-zkn %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-zkn %s \ +# RUN: | llvm-objdump -d --mattr=+experimental-zkn - \ +# RUN: | FileCheck %s --check-prefix=CHECK-INST +# RUN: llvm-mc -triple=riscv64 -filetype=obj --mattr=+experimental-zkn %s \ +# RUN: | llvm-objdump -d - | FileCheck %s --check-prefix=CHECK-UNKNOWN + +# With Zkne extension: +# RUN: llvm-mc -triple=riscv64 -show-encoding --mattr=+experimental-zkne %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-zkne %s \ +# RUN: | llvm-objdump -d --mattr=+experimental-zkne - \ +# RUN: | FileCheck %s --check-prefix=CHECK-INST +# RUN: llvm-mc -triple=riscv64 -filetype=obj --mattr=+experimental-zkne %s \ +# RUN: | llvm-objdump -d - | FileCheck %s --check-prefix=CHECK-UNKNOWN + +# CHECK-INST: aes64esm a0, a1, a2 +# CHECK-ENCODING: [0x33,0x85,0xc5,0x36] +# CHECK-ERROR: instruction requires the following: 'Zkne'(NIST AES Encryption Instructions) +# CHECK-UNKNOWN: 33 85 c5 36 +aes64esm a0, a1, a2 + +# CHECK-INST: aes64es a0, a1, a2 +# CHECK-ENCODING: [0x33,0x85,0xc5,0x32] +# CHECK-ERROR: instruction requires the following: 'Zkne'(NIST AES Encryption Instructions) +# CHECK-UNKNOWN: 33 85 c5 32 +aes64es a0, a1, a2 + +# CHECK-INST: aes64ks1i a0, a1, 5 +# CHECK-ENCODING: [0x13,0x95,0x55,0x31] +# CHECK-ERROR: instruction requires the following: 'Zkne'(NIST AES Encryption Instructions) +# CHECK-UNKNOWN: 13 95 55 31 +aes64ks1i a0, a1, 5 + +# CHECK-INST: aes64ks2 a0, a1, a2 +# CHECK-ENCODING: [0x33,0x85,0xc5,0x7e] +# CHECK-ERROR: instruction requires the following: 'Zkne'(NIST AES Encryption Instructions) +# CHECK-UNKNOWN: 33 85 c5 7e +aes64ks2 a0, a1, a2 diff --git a/llvm/test/MC/RISCV/rv64zknh-only-valid.s b/llvm/test/MC/RISCV/rv64zknh-only-valid.s new file mode 100644 --- /dev/null +++ b/llvm/test/MC/RISCV/rv64zknh-only-valid.s @@ -0,0 +1,56 @@ +# With K extension: +# 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 + +# With Zkn extension: +# RUN: llvm-mc -triple=riscv64 -show-encoding --mattr=+experimental-zkn %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-zkn %s \ +# RUN: | llvm-objdump -d --mattr=+experimental-zkn - \ +# RUN: | FileCheck %s --check-prefix=CHECK-INST +# RUN: llvm-mc -triple=riscv64 -filetype=obj --mattr=+experimental-zkn %s \ +# RUN: | llvm-objdump -d - | FileCheck %s --check-prefix=CHECK-UNKNOWN + +# With Zknh extension: +# RUN: llvm-mc -triple=riscv64 -show-encoding --mattr=+experimental-zknh %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-zknh %s \ +# RUN: | llvm-objdump -d --mattr=+experimental-zknh - \ +# RUN: | FileCheck %s --check-prefix=CHECK-INST +# RUN: llvm-mc -triple=riscv64 -filetype=obj --mattr=+experimental-zknh %s \ +# RUN: | llvm-objdump -d - | FileCheck %s --check-prefix=CHECK-UNKNOWN + +# CHECK-INST: sha512sig0 a0, a1 +# CHECK-ENCODING: [0x13,0x95,0x65,0x10] +# CHECK-ERROR: instruction requires the following: 'Zknh'(NIST SHA2 Hash function instructions) +# CHECK-UNKNOWN: 13 95 65 10 +sha512sig0 a0, a1 + +# CHECK-INST: sha512sig1 a0, a1 +# CHECK-ENCODING: [0x13,0x95,0x75,0x10] +# CHECK-ERROR: instruction requires the following: 'Zknh'(NIST SHA2 Hash function instructions) +# CHECK-UNKNOWN: 13 95 75 10 +sha512sig1 a0, a1 + +# CHECK-INST: sha512sum0 a0, a1 +# CHECK-ENCODING: [0x13,0x95,0x45,0x10] +# CHECK-ERROR: instruction requires the following: 'Zknh'(NIST SHA2 Hash function instructions) +# CHECK-UNKNOWN: 13 95 45 10 +sha512sum0 a0, a1 + +# CHECK-INST: sha512sum1 a0, a1 +# CHECK-ENCODING: [0x13,0x95,0x55,0x10] +# CHECK-ERROR: instruction requires the following: 'Zknh'(NIST SHA2 Hash function instructions) +# CHECK-UNKNOWN: 13 95 55 10 +sha512sum1 a0, a1 diff --git a/llvm/test/MC/RISCV/rv64zknh-valid.s b/llvm/test/MC/RISCV/rv64zknh-valid.s new file mode 100644 --- /dev/null +++ b/llvm/test/MC/RISCV/rv64zknh-valid.s @@ -0,0 +1,56 @@ +# With K extension: +# 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 + +# With Zkn extension: +# RUN: llvm-mc -triple=riscv64 -show-encoding --mattr=+experimental-zkn %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-zkn %s \ +# RUN: | llvm-objdump -d --mattr=+experimental-zkn - \ +# RUN: | FileCheck %s --check-prefix=CHECK-INST +# RUN: llvm-mc -triple=riscv64 -filetype=obj --mattr=+experimental-zkn %s \ +# RUN: | llvm-objdump -d - | FileCheck %s --check-prefix=CHECK-UNKNOWN + +# With Zknh extension: +# RUN: llvm-mc -triple=riscv64 -show-encoding --mattr=+experimental-zknh %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-zknh %s \ +# RUN: | llvm-objdump -d --mattr=+experimental-zknh - \ +# RUN: | FileCheck %s --check-prefix=CHECK-INST +# RUN: llvm-mc -triple=riscv64 -filetype=obj --mattr=+experimental-zknh %s \ +# RUN: | llvm-objdump -d - | FileCheck %s --check-prefix=CHECK-UNKNOWN + +# CHECK-INST: sha256sig0 a0, a1 +# CHECK-ENCODING: [0x13,0x95,0x25,0x10] +# CHECK-ERROR: instruction requires the following: 'Zknh'(NIST SHA2 Hash function instructions) +# CHECK-UNKNOWN: 13 95 25 10 +sha256sig0 a0, a1 + +# CHECK-INST: sha256sig1 a0, a1 +# CHECK-ENCODING: [0x13,0x95,0x35,0x10] +# CHECK-ERROR: instruction requires the following: 'Zknh'(NIST SHA2 Hash function instructions) +# CHECK-UNKNOWN: 13 95 35 10 +sha256sig1 a0, a1 + +# CHECK-INST: sha256sum0 a0, a1 +# CHECK-ENCODING: [0x13,0x95,0x05,0x10] +# CHECK-ERROR: instruction requires the following: 'Zknh'(NIST SHA2 Hash function instructions) +# CHECK-UNKNOWN: 13 95 05 10 +sha256sum0 a0, a1 + +# CHECK-INST: sha256sum1 a0, a1 +# CHECK-ENCODING: [0x13,0x95,0x15,0x10] +# CHECK-ERROR: instruction requires the following: 'Zknh'(NIST SHA2 Hash function instructions) +# CHECK-UNKNOWN: 13 95 15 10 +sha256sum1 a0, a1 diff --git a/llvm/test/MC/RISCV/rv64zkr-valid.s b/llvm/test/MC/RISCV/rv64zkr-valid.s new file mode 100644 --- /dev/null +++ b/llvm/test/MC/RISCV/rv64zkr-valid.s @@ -0,0 +1,33 @@ +# With K extension: +# 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 + +# With Zkr extension: +# RUN: llvm-mc -triple=riscv64 -show-encoding --mattr=+experimental-zkr %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-zkr %s \ +# RUN: | llvm-objdump -d --mattr=+experimental-zkr - \ +# RUN: | FileCheck %s --check-prefix=CHECK-INST +# RUN: llvm-mc -triple=riscv64 -filetype=obj --mattr=+experimental-zkr %s \ +# RUN: | llvm-objdump -d - | FileCheck %s --check-prefix=CHECK-UNKNOWN + +# CHECK-INST: csrr a0, mnoise +# CHECK-ENCODING: [0x73,0x25,0x90,0x7a] +# CHECK-ERROR: instruction requires the following: 'Zkr'(Entropy source for seeding random number generators) +# CHECK-UNKNOWN: 73 25 90 7a +getnoise a0 + +# CHECK-INST: csrr a0, mentropy +# CHECK-ENCODING: [0x73,0x25,0x50,0xf1] +# CHECK-ERROR: instruction requires the following: 'Zkr'(Entropy source for seeding random number generators) +# CHECK-UNKNOWN: 73 25 50 f1 +pollentropy a0 diff --git a/llvm/test/MC/RISCV/rv64zksed-invalid.s b/llvm/test/MC/RISCV/rv64zksed-invalid.s new file mode 100644 --- /dev/null +++ b/llvm/test/MC/RISCV/rv64zksed-invalid.s @@ -0,0 +1,13 @@ +# With Zks extension: +# RUN: not llvm-mc -triple=riscv64 -mattr=+experimental-zks < %s 2>&1 \ +# RUN: | FileCheck %s --check-prefix=CHECK-ERROR + +# With Zksed extension: +# RUN: not llvm-mc -triple=riscv64 -mattr=+experimental-zksed < %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] diff --git a/llvm/test/MC/RISCV/rv64zksed-valid.s b/llvm/test/MC/RISCV/rv64zksed-valid.s new file mode 100644 --- /dev/null +++ b/llvm/test/MC/RISCV/rv64zksed-valid.s @@ -0,0 +1,34 @@ +# With Zks extension: +# RUN: llvm-mc -triple=riscv64 -show-encoding --mattr=+experimental-zks %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-zks %s \ +# RUN: | llvm-objdump -d --mattr=+experimental-zks - \ +# RUN: | FileCheck %s --check-prefix=CHECK-INST +# RUN: llvm-mc -triple=riscv64 -filetype=obj --mattr=+experimental-zks %s \ +# RUN: | llvm-objdump -d - | FileCheck %s --check-prefix=CHECK-UNKNOWN + +# With Zksed extension: +# RUN: llvm-mc -triple=riscv64 -show-encoding --mattr=+experimental-zksed %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-zksed %s \ +# RUN: | llvm-objdump -d --mattr=+experimental-zksed - \ +# RUN: | FileCheck %s --check-prefix=CHECK-INST +# RUN: llvm-mc -triple=riscv64 -filetype=obj --mattr=+experimental-zksed %s \ +# RUN: | llvm-objdump -d - | FileCheck %s --check-prefix=CHECK-UNKNOWN + + +# CHECK-INST: sm4ed t0, a2, 3 +# CHECK-ENCODING: [0x33,0x80,0xc2,0xf0] +# CHECK-ERROR: instruction requires the following: 'Zksed'(SM4 Instructions) +# CHECK-UNKNOWN: 33 80 c2 f0 +sm4ed t0, a2, 3 + +# CHECK-INST: sm4ks t0, a2, 3 +# CHECK-ENCODING: [0x33,0x80,0xc2,0xf4] +# CHECK-ERROR: instruction requires the following: 'Zksed'(SM4 Instructions) +# CHECK-UNKNOWN: 33 80 c2 f4 +sm4ks t0, a2, 3 diff --git a/llvm/test/MC/RISCV/rv64zksh-valid.s b/llvm/test/MC/RISCV/rv64zksh-valid.s new file mode 100644 --- /dev/null +++ b/llvm/test/MC/RISCV/rv64zksh-valid.s @@ -0,0 +1,33 @@ +# With Zks extension: +# RUN: llvm-mc -triple=riscv64 -show-encoding --mattr=+experimental-zks %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-zks %s \ +# RUN: | llvm-objdump -d --mattr=+experimental-zks - \ +# RUN: | FileCheck %s --check-prefix=CHECK-INST +# RUN: llvm-mc -triple=riscv64 -filetype=obj --mattr=+experimental-zks %s \ +# RUN: | llvm-objdump -d - | FileCheck %s --check-prefix=CHECK-UNKNOWN + +# With Zksh extension: +# RUN: llvm-mc -triple=riscv64 -show-encoding --mattr=+experimental-zksh %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-zksh %s \ +# RUN: | llvm-objdump -d --mattr=+experimental-zksh - \ +# RUN: | FileCheck %s --check-prefix=CHECK-INST +# RUN: llvm-mc -triple=riscv64 -filetype=obj --mattr=+experimental-zksh %s \ +# RUN: | llvm-objdump -d - | FileCheck %s --check-prefix=CHECK-UNKNOWN + +# CHECK-INST: sm3p0 a0, a1 +# CHECK-ENCODING: [0x13,0x95,0x85,0x10] +# CHECK-ERROR: instruction requires the following: 'Zksh'(SM3 Hash function instructions) +# CHECK-UNKNOWN: 13 95 85 10 +sm3p0 a0, a1 + +# CHECK-INST: sm3p1 a0, a1 +# CHECK-ENCODING: [0x13,0x95,0x95,0x10] +# CHECK-ERROR: instruction requires the following: 'Zksh'(SM3 Hash function instructions) +# CHECK-UNKNOWN: 13 95 95 10 +sm3p1 a0, a1