diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,17 @@ +image: ubuntu:20.04 + +before_script: + - export RUNNER_MAX_LINK_JOBS=`free --giga | grep Mem | awk '{print int($2 / 16)}'` + +build: + stage: build + tags: + - llvm + + script: + - mkdir build + - cd build + - cmake -DLLVM_PARALLEL_LINK_JOBS=${RUNNER_MAX_LINK_JOBS} -DLLVM_TARGETS_TO_BUILD="X86;RISCV" -DLLVM_ENABLE_PROJECTS="clang" -G Ninja ../llvm + - ninja + - ninja check + 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 @@ -519,6 +519,15 @@ return IsConstantImm && isUInt<2>(Imm) && VK == RISCVMCExpr::VK_RISCV_None; } + 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 isUImm3() const { int64_t Imm; RISCVMCExpr::VariantKind VK = RISCVMCExpr::VK_RISCV_None; @@ -739,6 +748,16 @@ VK == RISCVMCExpr::VK_RISCV_None; } + bool isRnumArg() 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 @@ -2464,8 +2483,7 @@ } const MCInstrDesc &MCID = MII.get(Inst.getOpcode()); - RISCVII::VConstraintType Constraints = - RISCVII::getConstraint(MCID.TSFlags); + RISCVII::VConstraintType Constraints = RISCVII::getConstraint(MCID.TSFlags); if (Constraints == RISCVII::NoConstraint) return false; 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 @@ -1463,4 +1463,5 @@ include "RISCVInstrInfoZb.td" include "RISCVInstrInfoZk.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,130 @@ +//===-- 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.2. +/// +/// This version is still experimental as the 'K' extension hasn't been +/// ratified yet. +/// +//===----------------------------------------------------------------------===// + +def RnumArg : AsmOperandClass { + let Name = "RnumArg"; + let RenderMethod = "addImmOperands"; + let DiagnosticType = "InvalidRnumArg"; +} + +def rnum : Operand, ImmLeaf(Imm);}]> { + let ParserMatchClass = RnumArg; + 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> + : RVInstR<{0b00, funct5}, 0b000, OPC_OP, (outs GPR:$rd), (ins GPR:$rs1, GPR:$rs2, uimm2:$bs), + opcodestr, "$rd, $rs1, $rs2, $bs"> { + bits<2> bs; + let Inst{31-30}=bs; + } + +let hasSideEffects = 0, mayLoad = 0, mayStore = 0 in +class RVKUnary_rnum funct7, bits<3> funct3, string opcodestr> + : RVInstI { + bits<4> rnum; + + let Inst{31-25} = funct7; + let Inst{24} = 1; + let Inst{23-20} = rnum; +} + +//===----------------------------------------------------------------------===// +// 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<0b10001, "aes32esi">; +def AES32ESMI : RVKByteSelect<0b10011, "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_rnum<0b0011000, 0b001, "aes64ks1i">; +} // Predicates = [HasStdExtZkne, IsRV64] + +let Predicates = [HasStdExtZknd, IsRV32] in { +def AES32DSI : RVKByteSelect<0b10101, "aes32dsi">; +def AES32DSMI : RVKByteSelect<0b10111, "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/RISCVSubtarget.h b/llvm/lib/Target/RISCV/RISCVSubtarget.h --- a/llvm/lib/Target/RISCV/RISCVSubtarget.h +++ b/llvm/lib/Target/RISCV/RISCVSubtarget.h @@ -66,6 +66,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; @@ -145,6 +156,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/test/MC/RISCV/attribute-arch.s b/llvm/test/MC/RISCV/attribute-arch.s --- a/llvm/test/MC/RISCV/attribute-arch.s +++ b/llvm/test/MC/RISCV/attribute-arch.s @@ -113,3 +113,6 @@ .attribute arch, "rv32iv_zvamo0p10_zvlsseg" # CHECK: attribute 5, "rv32i2p0_v0p10_zvamo0p10_zvlsseg0p10" + +.attribute arch, "rv32ik" +# CHECK: attribute 5, "rv32i2p0_k0p9_zbc0p93_zbp0p93_zkb0p9_zkg0p9_zkn0p9_zknd0p9_zkne0p9_zknh0p9_zkr0p9" 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 -M 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 -M 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 -M 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 -M 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/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/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 -M 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 -M 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 -M 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 -M 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 -M 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 -M 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 -M 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 -M 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/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-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 a0, a1, a2, 3 +# CHECK-ENCODING: [0x33,0x85,0xc5,0xf0] +# CHECK-ERROR: instruction requires the following: 'Zksed' (SM4 Instructions) +# CHECK-UNKNOWN: 33 85 c5 f0 +sm4ed a0, a1, a2, 3 + +# CHECK-INST: sm4ks a0, a1, a2, 3 +# CHECK-ENCODING: [0x33,0x85,0xc5,0xf4] +# CHECK-ERROR: instruction requires the following: 'Zksed' (SM4 Instructions) +# CHECK-UNKNOWN: 33 85 c5 f4 +sm4ks a0, a1, 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