[PATCH] D138807: [RISCV] Support vector crypto extension ISA string and assembly
Eric Gouriou via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Jan 3 11:05:04 PST 2023
ego added a comment.
FYI, more issues with v0 not being accepted as an operand with unmasked instructions.
================
Comment at: llvm/test/MC/RISCV/rvv/rv64zvkns.s:59
+
+vaeskf1.vi v10, v9, 1
+# CHECK-INST: vaeskf1.vi v10, v9, 1
----------------
ego wrote:
> craig.topper wrote:
> > ego wrote:
> > > If I replaces "v10" with "v0", the test fails with an assertion failure. My own patch uses a slightly different class hierarchy but hits the same assertion.
> > >
> > >
> > > ```
> > > FAIL: LLVM :: MC/RISCV/rvv/rv64zvkns.s (3 of 8)
> > > ******************** TEST 'LLVM :: MC/RISCV/rvv/rv64zvkns.s' FAILED ********************
> > > Script:
> > > --
> > > : 'RUN: at line 1'; /Users/ego/root-dirs/scratch/projects/llvm-project/build/bin/llvm-mc -triple=riscv64 -show-encoding --mattr=+zve32x --mattr=+experimental-zvkns /Users/ego/root-dirs/scratch/projects/llvm-project/llvm/test/MC/RISCV/rvv/rv64zvkns.s | /Users/ego/root-dirs/scratch/projects/llvm-project/build/bin/FileCheck /Users/ego/root-dirs/scratch/projects/llvm-project/llvm/test/MC/RISCV/rvv/rv64zvkns.s --check-prefixes=CHECK-ENCODING,CHECK-INST
> > > : 'RUN: at line 3'; not /Users/ego/root-dirs/scratch/projects/llvm-project/build/bin/llvm-mc -triple=riscv64 -show-encoding /Users/ego/root-dirs/scratch/projects/llvm-project/llvm/test/MC/RISCV/rvv/rv64zvkns.s 2>&1 | /Users/ego/root-dirs/scratch/projects/llvm-project/build/bin/FileCheck /Users/ego/root-dirs/scratch/projects/llvm-project/llvm/test/MC/RISCV/rvv/rv64zvkns.s --check-prefix=CHECK-ERROR
> > > : 'RUN: at line 5'; /Users/ego/root-dirs/scratch/projects/llvm-project/build/bin/llvm-mc -triple=riscv64 -filetype=obj --mattr=+zve32x --mattr=+experimental-zvkns /Users/ego/root-dirs/scratch/projects/llvm-project/llvm/test/MC/RISCV/rvv/rv64zvkns.s | /Users/ego/root-dirs/scratch/projects/llvm-project/build/bin/llvm-objdump -d --mattr=+zve32x --mattr=+experimental-zvkns - | /Users/ego/root-dirs/scratch/projects/llvm-project/build/bin/FileCheck /Users/ego/root-dirs/scratch/projects/llvm-project/llvm/test/MC/RISCV/rvv/rv64zvkns.s --check-prefix=CHECK-INST
> > > : 'RUN: at line 8'; /Users/ego/root-dirs/scratch/projects/llvm-project/build/bin/llvm-mc -triple=riscv64 -filetype=obj --mattr=+zve32x --mattr=+experimental-zvkns /Users/ego/root-dirs/scratch/projects/llvm-project/llvm/test/MC/RISCV/rvv/rv64zvkns.s | /Users/ego/root-dirs/scratch/projects/llvm-project/build/bin/llvm-objdump -d - | /Users/ego/root-dirs/scratch/projects/llvm-project/build/bin/FileCheck /Users/ego/root-dirs/scratch/projects/llvm-project/llvm/test/MC/RISCV/rvv/rv64zvkns.s --check-prefix=CHECK-UNKNOWN
> > > --
> > > Exit Code: 2
> > >
> > > Command Output (stderr):
> > > --
> > > Assertion failed: (isReg() && "This is not a register operand!"), function getReg, file MCInst.h, line 70.
> > > PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
> > > Stack dump:
> > > 0. Program arguments: /Users/ego/root-dirs/scratch/projects/llvm-project/build/bin/llvm-mc -triple=riscv64 -show-encoding --mattr=+zve32x --mattr=+experimental-zvkns /Users/ego/root-dirs/scratch/projects/llvm-project/llvm/test/MC/RISCV/rvv/rv64zvkns.s
> > > Stack dump without symbol names (ensure you have llvm-symbolizer in your PATH or set the environment var `LLVM_SYMBOLIZER_PATH` to point to it):
> > > 0 libLLVMSupport.dylib 0x00000001023015e8 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) + 56
> > > 1 libLLVMSupport.dylib 0x0000000102300840 llvm::sys::RunSignalHandlers() + 112
> > > 2 libLLVMSupport.dylib 0x0000000102301c28 SignalHandler(int) + 304
> > > 3 libsystem_platform.dylib 0x00000001914f82a4 _sigtramp + 56
> > > 4 libsystem_pthread.dylib 0x00000001914c9cec pthread_kill + 288
> > > 5 libsystem_c.dylib 0x00000001914032c8 abort + 180
> > > 6 libsystem_c.dylib 0x0000000191402620 err + 0
> > > 7 libLLVMRISCVAsmParser.dylib 0x0000000100666208 (anonymous namespace)::RISCVAsmParser::MatchAndEmitInstruction(llvm::SMLoc, unsigned int&, llvm::SmallVectorImpl<std::__1::unique_ptr<llvm::MCParsedAsmOperand, std::__1::default_delete<llvm::MCParsedAsmOperand>>>&, llvm::MCStreamer&, unsigned long long&, bool) (.cold.42) + 0
> > > 8 libLLVMRISCVAsmParser.dylib 0x0000000100655084 (anonymous namespace)::RISCVAsmParser::MatchAndEmitInstruction(llvm::SMLoc, unsigned int&, llvm::SmallVectorImpl<std::__1::unique_ptr<llvm::MCParsedAsmOperand, std::__1::default_delete<llvm::MCParsedAsmOperand>>>&, llvm::MCStreamer&, unsigned long long&, bool) + 7268
> > > 9 libLLVMMCParser.dylib 0x0000000100c36c08 (anonymous namespace)::AsmParser::parseAndMatchAndEmitTargetInstruction((anonymous namespace)::ParseStatementInfo&, llvm::StringRef, llvm::AsmToken, llvm::SMLoc) + 1356
> > > 10 libLLVMMCParser.dylib 0x0000000100c2d1d0 (anonymous namespace)::AsmParser::parseStatement((anonymous namespace)::ParseStatementInfo&, llvm::MCAsmParserSemaCallback*) + 3492
> > > 11 libLLVMMCParser.dylib 0x0000000100c27884 (anonymous namespace)::AsmParser::Run(bool, bool) + 500
> > > 12 llvm-mc 0x000000010051ffc8 main + 6608
> > > 13 dyld 0x000000019119fe50 start + 2544
> > > FileCheck error: '<stdin>' is empty.
> > > FileCheck command line: /Users/ego/root-dirs/scratch/projects/llvm-project/build/bin/FileCheck /Users/ego/root-dirs/scratch/projects/llvm-project/llvm/test/MC/RISCV/rvv/rv64zvkns.s --check-prefixes=CHECK-ENCODING,CHECK-INST
> > >
> > > --
> > >
> > > ```
> > Looks like it ended up with `RVVConstraint = VMConstraint` due to the classes it inherited. This caused validateInstruction to look for a mask operand that doesn't exist. Need to force it to the NoConstraint.
> Thanks Craig, that "NoConstraint" worked for me.
>
> It would be good to check if the same issue exists with other instructions in their no-mask uses.
Indeed the same issue affects other instructions. I found "vaesem .vv v0, v11" to lead to an assertion failure. I expect this will also affect all vaes[ed]* instructions.
The code using v0 was in zvkns.s in this [[ https://github.com/rivosinc/riscv-code-samples/tree/main/zvk-vector-crypto | repo ]] demonstrating Zvk uses. Some of that code is know to have issues (e..g, vaeskf2 rnum are still 1-13 instead of 2-14 per the current spec),
For quick experiments I compiled that code using this command:
```
/scratch/install/llvm/bin/clang -c -v -v -menable-experimental-extensions -march=rv64gcv_zvkns0p1_zvknhb0p1_zvkb0p1_zvksed0p1_zvksh0p1_zvkg0p1 --gcc-toolchain=/rivos/riscv-gnu-toolchain --sysroot=/rivos/riscv-gnu-toolchain/sysroot -o zvkns.o zvkns.s
```
Of course the /rivos/riscv-gnu-toolchain paths should point to your own riscv-gnu-toolchain install.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D138807/new/
https://reviews.llvm.org/D138807
More information about the cfe-commits
mailing list