Skip to content

[RISCV] Add Zilsd and Zclsd Extensions #131094

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 45 commits into from
Mar 19, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
bcdf964
Update RISCVSystemOperands.td
dong-miao Jan 4, 2025
30e3fbe
Update rv32-hypervisor-csr-names.s
dong-miao Jan 4, 2025
e41e745
Update rv32-machine-csr-names.s
dong-miao Jan 4, 2025
ea2c1af
Update RISCVSystemOperands.td
dong-miao Jan 5, 2025
6b074f3
Update rv32-only-csr-names.s
dong-miao Jan 5, 2025
f77d8e3
Update RISCVSystemOperands.td
dong-miao Jan 5, 2025
58a1fe2
Merge branch 'main' into main
dong-miao Jan 13, 2025
17b994b
Merge branch 'main' into main
dong-miao Feb 12, 2025
6f57575
Merge branch 'llvm:main' into main
dong-miao Mar 3, 2025
2c3440f
add extensions
dong-miao Mar 13, 2025
faa59c9
Update RISCVDisassembler.cpp
dong-miao Mar 13, 2025
4442de0
Delete $<TARGET_LINKER_FILE:cxx_shared>
dong-miao Mar 13, 2025
20fd842
Update RISCVDisassembler.cpp
dong-miao Mar 13, 2025
1fb709c
Update RISCVDisassembler.cpp
dong-miao Mar 13, 2025
5a6103d
Update RISCVRegisterInfo.td
dong-miao Mar 13, 2025
f7c4cf4
Update RISCVAsmParser.cpp
dong-miao Mar 13, 2025
54780fa
Update riscv-target-features.c
dong-miao Mar 13, 2025
1387e89
Update RISCVUsage.rst
dong-miao Mar 13, 2025
fc52464
Update print-supported-extensions-riscv.c
dong-miao Mar 13, 2025
7f61fd6
Update RISCVDisassembler.cpp
dong-miao Mar 13, 2025
2df1bbf
Update RISCVDisassembler.cpp
dong-miao Mar 13, 2025
ff30cde
Update RISCVRegisterInfo.td
dong-miao Mar 13, 2025
10c800c
Modify relevant files
dong-miao Mar 14, 2025
f7cf00f
Update RISCVDisassembler.cpp
dong-miao Mar 14, 2025
b07f830
Modify disassembly information
dong-miao Mar 15, 2025
e478e03
Update RISCVDisassembler.cpp
dong-miao Mar 15, 2025
2262393
Merge branch 'main' into develop
dong-miao Mar 15, 2025
8a2fd1d
Update rv64c-valid.s
dong-miao Mar 15, 2025
9972069
Merge branch 'llvm:main' into develop
dong-miao Mar 15, 2025
613cf3a
Update RISCVInstrInfo.td
dong-miao Mar 15, 2025
95ddfa1
Merge branch 'main' into develop
dong-miao Mar 15, 2025
a61e604
Merge branch 'main' into develop
dong-miao Mar 16, 2025
bf6ea39
Update print-supported-extensions-riscv.c
dong-miao Mar 17, 2025
4158069
Update print-supported-extensions-riscv.c
dong-miao Mar 17, 2025
cc7a33c
Update print-supported-extensions-riscv.c
dong-miao Mar 17, 2025
1c59ebc
Update RISCVFeatures.td
dong-miao Mar 17, 2025
3b7e25e
Improve the format of test files
dong-miao Mar 18, 2025
faec63f
Modify relevant content
dong-miao Mar 18, 2025
dfda4ae
Update ReleaseNotes.md
dong-miao Mar 18, 2025
e17ca63
Update rv64c-valid.s
dong-miao Mar 18, 2025
4b1709e
Change conflict test file
dong-miao Mar 19, 2025
68c3845
Conflict Resolution
dong-miao Mar 19, 2025
d0a4e32
Merge branch 'main' into develop
dong-miao Mar 19, 2025
89f5a20
Formatting
dong-miao Mar 19, 2025
31b55e8
Rename DecoderNamespace
dong-miao Mar 19, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions clang/test/Driver/print-supported-extensions-riscv.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
// CHECK-NEXT: zihintntl 1.0 'Zihintntl' (Non-Temporal Locality Hints)
// CHECK-NEXT: zihintpause 2.0 'Zihintpause' (Pause Hint)
// CHECK-NEXT: zihpm 2.0 'Zihpm' (Hardware Performance Counters)
// CHECK-NEXT: zilsd 1.0 'Zilsd' (Load/Store Pair Instructions)
// CHECK-NEXT: zimop 1.0 'Zimop' (May-Be-Operations)
// CHECK-NEXT: zmmul 1.0 'Zmmul' (Integer Multiplication)
// CHECK-NEXT: za128rs 1.0 'Za128rs' (Reservation Set Size of at Most 128 Bytes)
Expand All @@ -50,6 +51,7 @@
// CHECK-NEXT: zcd 1.0 'Zcd' (Compressed Double-Precision Floating-Point Instructions)
// CHECK-NEXT: zce 1.0 'Zce' (Compressed extensions for microcontrollers)
// CHECK-NEXT: zcf 1.0 'Zcf' (Compressed Single-Precision Floating-Point Instructions)
// CHECK-NEXT: zclsd 1.0 'Zclsd' (Compressed Load/Store Pair Instructions)
// CHECK-NEXT: zcmop 1.0 'Zcmop' (Compressed May-Be-Operations)
// CHECK-NEXT: zcmp 1.0 'Zcmp' (sequenced instructions for code-size reduction)
// CHECK-NEXT: zcmt 1.0 'Zcmt' (table jump instructions for code-size reduction)
Expand Down
12 changes: 12 additions & 0 deletions clang/test/Preprocessor/riscv-target-features.c
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@
// CHECK-NOT: __riscv_zcd {{.*$}}
// CHECK-NOT: __riscv_zce {{.*$}}
// CHECK-NOT: __riscv_zcf {{.*$}}
// CHECK-NOT: __riscv_zclsd {{.*$}}
// CHECK-NOT: __riscv_zcmop {{.*$}}
// CHECK-NOT: __riscv_zcmp {{.*$}}
// CHECK-NOT: __riscv_zcmt {{.*$}}
Expand All @@ -133,6 +134,7 @@
// CHECK-NOT: __riscv_zihintntl {{.*$}}
// CHECK-NOT: __riscv_zihintpause {{.*$}}
// CHECK-NOT: __riscv_zihpm {{.*$}}
// CHECK-NOT: __riscv_zilsd {{.*$}}
// CHECK-NOT: __riscv_zimop {{.*$}}
// CHECK-NOT: __riscv_zk {{.*$}}
// CHECK-NOT: __riscv_zkn {{.*$}}
Expand Down Expand Up @@ -922,6 +924,11 @@
// RUN: -o - | FileCheck --check-prefix=CHECK-ZCF-EXT %s
// CHECK-ZCF-EXT: __riscv_zcf 1000000{{$}}

// RUN: %clang --target=riscv32-unknown-linux-gnu \
// RUN: -march=rv32i_zclsd1p0 -E -dM %s \
// RUN: -o - | FileCheck --check-prefix=CHECK-ZCLSD-EXT %s
// CHECK-ZCLSD-EXT: __riscv_zclsd 1000000{{$}}

// RUN: %clang --target=riscv32-unknown-linux-gnu \
// RUN: -march=rv32i_zcmop1p0 -E -dM %s \
// RUN: -o - | FileCheck --check-prefix=CHECK-ZCMOP-EXT %s
Expand Down Expand Up @@ -1118,6 +1125,11 @@
// RUN: -o - | FileCheck --check-prefix=CHECK-ZIHPM-EXT %s
// CHECK-ZIHPM-EXT: __riscv_zihpm 2000000{{$}}

// RUN: %clang --target=riscv32-unknown-linux-gnu \
// RUN: -march=rv32i_zilsd1p0 -E -dM %s \
// RUN: -o - | FileCheck --check-prefix=CHECK-ZILSD-EXT %s
// CHECK-ZILSD-EXT: __riscv_zilsd 1000000{{$}}

// RUN: %clang --target=riscv32-unknown-linux-gnu \
// RUN: -march=rv32i_zimop1p0 -E -dM %s \
// RUN: -o - | FileCheck --check-prefix=CHECK-ZIMOP-EXT %s
Expand Down
2 changes: 2 additions & 0 deletions llvm/docs/RISCVUsage.rst
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ on support follow.
``Zcb`` Supported
``Zcd`` Supported
``Zcf`` Supported
``Zclsd`` Assembly Support
``Zcmop`` Supported
``Zcmp`` Supported
``Zcmt`` Assembly Support
Expand All @@ -205,6 +206,7 @@ on support follow.
``Zihintntl`` Supported
``Zihintpause`` Assembly Support
``Zihpm`` (`See Note <#riscv-i2p1-note>`__)
``Zilsd`` Assembly Support
``Zimop`` Supported
``Zkn`` Supported
``Zknd`` Supported (`See note <#riscv-scalar-crypto-note2>`__)
Expand Down
4 changes: 4 additions & 0 deletions llvm/docs/ReleaseNotes.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,10 @@ Changes to the RISC-V Backend
* Added non-quadratic ``log-vrgather`` cost model for ``vrgather.vv`` instruction
* Adds experimental assembler support for the Qualcomm uC 'Xqcisim` (Simulation Hint)
extension.
* Adds assembler support for the 'Zilsd` (Load/Store Pair Instructions)
extension.
* Adds assembler support for the 'Zclsd` (Compressed Load/Store Pair Instructions)
extension.

Changes to the WebAssembly Backend
----------------------------------
Expand Down
12 changes: 12 additions & 0 deletions llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -487,6 +487,18 @@ struct RISCVOperand final : public MCParsedAsmOperand {
Reg.RegNum);
}

bool isGPRPairC() const {
return Kind == KindTy::Register &&
RISCVMCRegisterClasses[RISCV::GPRPairCRegClassID].contains(
Reg.RegNum);
}

bool isGPRPairNoX0() const {
return Kind == KindTy::Register &&
RISCVMCRegisterClasses[RISCV::GPRPairNoX0RegClassID].contains(
Reg.RegNum);
}

bool isGPRF16() const {
return Kind == KindTy::Register &&
RISCVMCRegisterClasses[RISCV::GPRF16RegClassID].contains(Reg.RegNum);
Expand Down
16 changes: 16 additions & 0 deletions llvm/lib/Target/RISCV/Disassembler/RISCVDisassembler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,22 @@ static DecodeStatus DecodeGPRPairRegisterClass(MCInst &Inst, uint32_t RegNo,
return MCDisassembler::Success;
}

static DecodeStatus DecodeGPRPairCRegisterClass(MCInst &Inst, uint32_t RegNo,
uint64_t Address,
const MCDisassembler *Decoder) {
if (RegNo >= 8 || RegNo % 2)
return MCDisassembler::Fail;

const RISCVDisassembler *Dis =
static_cast<const RISCVDisassembler *>(Decoder);
const MCRegisterInfo *RI = Dis->getContext().getRegisterInfo();
MCRegister Reg = RI->getMatchingSuperReg(
RISCV::X8 + RegNo, RISCV::sub_gpr_even,
&RISCVMCRegisterClasses[RISCV::GPRPairCRegClassID]);
Inst.addOperand(MCOperand::createReg(Reg));
return MCDisassembler::Success;
}

static DecodeStatus DecodeSR07RegisterClass(MCInst &Inst, uint32_t RegNo,
uint64_t Address,
const void *Decoder) {
Expand Down
15 changes: 15 additions & 0 deletions llvm/lib/Target/RISCV/RISCVFeatures.td
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,13 @@ def HasStdExtZicfiss : Predicate<"Subtarget->hasStdExtZicfiss()">,
"'Zicfiss' (Shadow stack)">;
def NoHasStdExtZicfiss : Predicate<"!Subtarget->hasStdExtZicfiss()">;

def FeatureStdExtZilsd
: RISCVExtension<1, 0,
"Load/Store Pair Instructions">;
def HasStdExtZilsd : Predicate<"Subtarget->hasStdExtZilsd()">,
AssemblerPredicate<(all_of FeatureStdExtZilsd),
"'Zilsd' (Load/Store pair instructions)">;

// Multiply Extensions

def FeatureStdExtZmmul
Expand Down Expand Up @@ -401,6 +408,14 @@ def FeatureStdExtZcf
"Compressed Single-Precision Floating-Point Instructions",
[FeatureStdExtF, FeatureStdExtZca]>;

def FeatureStdExtZclsd
: RISCVExtension<1, 0,
"Compressed Load/Store Pair Instructions",
[FeatureStdExtZilsd,FeatureStdExtZca]>;
def HasStdExtZclsd : Predicate<"Subtarget->hasStdExtZclsd()">,
AssemblerPredicate<(all_of FeatureStdExtZclsd),
"'Zclsd' (Compressed Load/Store pair instructions)">;

def FeatureStdExtZcmp
: RISCVExtension<1, 0,
"sequenced instructions for code-size reduction",
Expand Down
2 changes: 2 additions & 0 deletions llvm/lib/Target/RISCV/RISCVInstrInfo.td
Original file line number Diff line number Diff line change
Expand Up @@ -2142,11 +2142,13 @@ include "RISCVInstrInfoZimop.td"
include "RISCVInstrInfoZicbo.td"
include "RISCVInstrInfoZicond.td"
include "RISCVInstrInfoZicfiss.td"
include "RISCVInstrInfoZilsd.td"

// Compressed
include "RISCVInstrInfoC.td"
include "RISCVInstrInfoZc.td"
include "RISCVInstrInfoZcmop.td"
include "RISCVInstrInfoZclsd.td"

//===----------------------------------------------------------------------===//
// Vendor extensions
Expand Down
107 changes: 107 additions & 0 deletions llvm/lib/Target/RISCV/RISCVInstrInfoZclsd.td
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
//===-- RISCVInstrInfoZclsd.td -----------------------------*- 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 'Zclsd',
// Compressed Load/Store pair instructions extension.
//
//===----------------------------------------------------------------------===//

//===----------------------------------------------------------------------===//
// Instruction Class Templates
//===----------------------------------------------------------------------===//

def GPRPairNoX0RV32Operand : AsmOperandClass {
let Name = "GPRPairNoX0RV32";
let ParserMethod = "parseGPRPair<false>";
let PredicateMethod = "isGPRPairNoX0";
let RenderMethod = "addRegOperands";
}

def GPRPairNoX0RV32 : RegisterOperand<GPRPairNoX0> {
let ParserMatchClass = GPRPairNoX0RV32Operand;
}

def GPRPairCRV32Operand : AsmOperandClass {
let Name = "GPRPairCRV32";
let ParserMethod = "parseGPRPair<false>";
let PredicateMethod = "isGPRPairC";
let RenderMethod = "addRegOperands";
}

def GPRPairCRV32 : RegisterOperand<GPRPairC> {
let ParserMatchClass = GPRPairCRV32Operand;
}

let hasSideEffects = 0, mayLoad = 1, mayStore = 0 in
class PairCStackLoad<bits<3> funct3, string OpcodeStr,
DAGOperand RC, DAGOperand opnd>
: RVInst16CI<funct3, 0b10, (outs RC:$rd), (ins SPMem:$rs1, opnd:$imm),
OpcodeStr, "$rd, ${imm}(${rs1})">;

let hasSideEffects = 0, mayLoad = 0, mayStore = 1 in
class PairCStackStore<bits<3> funct3, string OpcodeStr,
DAGOperand RC, DAGOperand opnd>
: RVInst16CSS<funct3, 0b10, (outs), (ins RC:$rs2, SPMem:$rs1, opnd:$imm),
OpcodeStr, "$rs2, ${imm}(${rs1})">;

let hasSideEffects = 0, mayLoad = 1, mayStore = 0 in
class PairCLoad_ri<bits<3> funct3, string OpcodeStr,
DAGOperand RC, DAGOperand opnd>
: RVInst16CL<funct3, 0b00, (outs RC:$rd), (ins GPRCMem:$rs1, opnd:$imm),
OpcodeStr, "$rd, ${imm}(${rs1})">;

let hasSideEffects = 0, mayLoad = 0, mayStore = 1 in
class PairCStore_rri<bits<3> funct3, string OpcodeStr,
DAGOperand RC, DAGOperand opnd>
: RVInst16CS<funct3, 0b00, (outs), (ins RC:$rs2,GPRCMem:$rs1, opnd:$imm),
OpcodeStr, "$rs2, ${imm}(${rs1})">;

//===----------------------------------------------------------------------===//
// Instructions
//===----------------------------------------------------------------------===//

let Predicates = [HasStdExtZclsd, IsRV32], DecoderNamespace = "ZcOverlap" in {
def C_LDSP_RV32 : PairCStackLoad<0b011, "c.ldsp", GPRPairNoX0RV32, uimm9_lsb000>,
Sched<[WriteLDD, ReadMemBase]> {
let Inst{4-2} = imm{8-6};
}

def C_SDSP_RV32 : PairCStackStore<0b111, "c.sdsp", GPRPairRV32, uimm9_lsb000>,
Sched<[WriteSTD, ReadStoreData, ReadMemBase]> {
let Inst{9-7} = imm{8-6};
}

def C_LD_RV32 : PairCLoad_ri<0b011, "c.ld", GPRPairCRV32, uimm8_lsb000>,
Sched<[WriteLDD, ReadMemBase]> {
bits<8> imm;
let Inst{12-10} = imm{5-3};
let Inst{6-5} = imm{7-6};
}

def C_SD_RV32 : PairCStore_rri<0b111, "c.sd", GPRPairCRV32, uimm8_lsb000>,
Sched<[WriteSTD, ReadStoreData, ReadMemBase]> {
bits<8> imm;
let Inst{12-10} = imm{5-3};
let Inst{6-5} = imm{7-6};
}
}// Predicates = [HasStdExtZclsd, IsRV32], DecoderNamespace = "ZcOverlap"

//===----------------------------------------------------------------------===//
// Compress Instruction tablegen backend.
//===----------------------------------------------------------------------===//

let Predicates = [HasStdExtZclsd, IsRV32] in {
def : CompressPat<(LD_RV32 GPRPairNoX0RV32:$rd, SPMem:$rs1, uimm9_lsb000:$imm),
(C_LDSP_RV32 GPRPairNoX0RV32:$rd, SPMem:$rs1, uimm9_lsb000:$imm)>;
def : CompressPat<(SD_RV32 GPRPairRV32:$rs2, SPMem:$rs1, uimm9_lsb000:$imm),
(C_SDSP_RV32 GPRPairRV32:$rs2, SPMem:$rs1, uimm9_lsb000:$imm)>;
def : CompressPat<(LD_RV32 GPRPairCRV32:$rd, GPRCMem:$rs1, uimm8_lsb000:$imm),
(C_LD_RV32 GPRPairCRV32:$rd, GPRCMem:$rs1, uimm8_lsb000:$imm)>;
def : CompressPat<(SD_RV32 GPRPairCRV32:$rs2, GPRCMem:$rs1, uimm8_lsb000:$imm),
(C_SD_RV32 GPRPairCRV32:$rs2, GPRCMem:$rs1, uimm8_lsb000:$imm)>;
} // Predicates = [HasStdExtZclsd, IsRV32]
38 changes: 38 additions & 0 deletions llvm/lib/Target/RISCV/RISCVInstrInfoZilsd.td
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
//===-- RISCVInstrInfoZilsd.td -----------------------------*- 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 'Zilsd',
// Load/Store pair instructions extension.
//
//===----------------------------------------------------------------------===//

//===----------------------------------------------------------------------===//
// Instruction Class Templates
//===----------------------------------------------------------------------===//

let hasSideEffects = 0, mayLoad = 1, mayStore = 0 in
class PairLoad_ri<string opcodestr, DAGOperand RC>
: RVInstI<0b011, OPC_LOAD, (outs RC:$rd),
(ins GPRMem:$rs1, simm12:$imm12),
opcodestr, "${rd}, ${imm12}(${rs1})">;

let hasSideEffects = 0, mayLoad = 0, mayStore = 1 in
class PairStore_rri<string opcodestr, DAGOperand RC>
: RVInstS<0b011, OPC_STORE, (outs),
(ins RC:$rs2, GPRMem:$rs1, simm12:$imm12),
opcodestr, "${rs2}, ${imm12}(${rs1})">;

//===----------------------------------------------------------------------===//
// Instructions
//===----------------------------------------------------------------------===//

let Predicates = [HasStdExtZilsd, IsRV32], DecoderNamespace = "RV32Only" in {
def LD_RV32 : PairLoad_ri<"ld", GPRPairRV32>, Sched<[WriteLDD, ReadMemBase]>;
def SD_RV32 : PairStore_rri<"sd", GPRPairRV32>, Sched<[WriteSTD, ReadStoreData,
ReadMemBase]>;
} // Predicates = [HasStdExtZilsd, IsRV32], DecoderNamespace = "RV32Only"
8 changes: 8 additions & 0 deletions llvm/lib/TargetParser/RISCVISAInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -780,6 +780,14 @@ Error RISCVISAInfo::checkDependency() {
return getIncompatibleError("xwchc", "zcb");
}

if (Exts.count("zclsd") != 0) {
if (XLen != 32)
return getError("'zclsd' is only supported for 'rv32'");

if (Exts.count("zcf") != 0)
return getIncompatibleError("zclsd", "zcf");
}

for (auto Ext : XqciExts)
if (Exts.count(Ext.str()) && (XLen != 32))
return getError("'" + Twine(Ext) + "'" + " is only supported for 'rv32'");
Expand Down
4 changes: 4 additions & 0 deletions llvm/test/CodeGen/RISCV/attributes.ll
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,9 @@
; RUN: llc -mtriple=riscv32 -mattr=+zve32x -mattr=+zvkt %s -o - | FileCheck --check-prefix=RV32ZVKT %s
; RUN: llc -mtriple=riscv32 -mattr=+zvfh %s -o - | FileCheck --check-prefix=RV32ZVFH %s
; RUN: llc -mtriple=riscv32 -mattr=+zicond %s -o - | FileCheck --check-prefix=RV32ZICOND %s
; RUN: llc -mtriple=riscv32 -mattr=+zilsd %s -o - | FileCheck --check-prefix=RV32ZILSD %s
; RUN: llc -mtriple=riscv32 -mattr=+zimop %s -o - | FileCheck --check-prefix=RV32ZIMOP %s
; RUN: llc -mtriple=riscv32 -mattr=+zclsd %s -o - | FileCheck --check-prefix=RV32ZCLSD %s
; RUN: llc -mtriple=riscv32 -mattr=+zcmop %s -o - | FileCheck --check-prefix=RV32ZCMOP %s
; RUN: llc -mtriple=riscv32 -mattr=+smaia %s -o - | FileCheck --check-prefixes=CHECK,RV32SMAIA %s
; RUN: llc -mtriple=riscv32 -mattr=+ssaia %s -o - | FileCheck --check-prefixes=CHECK,RV32SSAIA %s
Expand Down Expand Up @@ -453,7 +455,9 @@
; RV32ZVKT: .attribute 5, "rv32i2p1_zicsr2p0_zve32x1p0_zvkt1p0_zvl32b1p0"
; RV32ZVFH: .attribute 5, "rv32i2p1_f2p2_zicsr2p0_zfhmin1p0_zve32f1p0_zve32x1p0_zvfh1p0_zvfhmin1p0_zvl32b1p0"
; RV32ZICOND: .attribute 5, "rv32i2p1_zicond1p0"
; RV32ZILSD: .attribute 5, "rv32i2p1_zilsd1p0"
; RV32ZIMOP: .attribute 5, "rv32i2p1_zimop1p0"
; RV32ZCLSD: .attribute 5, "rv32i2p1_zilsd1p0_zca1p0_zclsd1p0"
; RV32ZCMOP: .attribute 5, "rv32i2p1_zca1p0_zcmop1p0"
; RV32SMAIA: .attribute 5, "rv32i2p1_smaia1p0"
; RV32SSAIA: .attribute 5, "rv32i2p1_ssaia1p0"
Expand Down
6 changes: 6 additions & 0 deletions llvm/test/MC/RISCV/attribute-arch.s
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,9 @@
.attribute arch, "rv32izcb1p0"
# CHECK: attribute 5, "rv32i2p1_zca1p0_zcb1p0"

.attribute arch, "rv32izclsd1p0"
# CHECK: attribute 5, "rv32i2p1_zilsd1p0_zca1p0_zclsd1p0"

.attribute arch, "rv32izcmp1p0"
# CHECK: attribute 5, "rv32i2p1_zca1p0_zcmp1p0"

Expand Down Expand Up @@ -429,6 +432,9 @@
.attribute arch, "rv32i_zicfiss1p0"
# CHECK: .attribute 5, "rv32i2p1_zicfiss1p0_zicsr2p0_zimop1p0"

.attribute arch, "rv32i_zilsd1p0"
# CHECK: .attribute 5, "rv32i2p1_zilsd1p0"

.attribute arch, "rv64i_xsfvfwmaccqqq"
# CHECK: attribute 5, "rv64i2p1_f2p2_zicsr2p0_zve32f1p0_zve32x1p0_zvfbfmin1p0_zvl32b1p0_xsfvfwmaccqqq1p0"

Expand Down
22 changes: 22 additions & 0 deletions llvm/test/MC/RISCV/rv32zclsd-invalid.s
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# RUN: not llvm-mc -triple=riscv32 -mattr=+zclsd < %s 2>&1 | FileCheck %s

## GPRPairC
c.ld t1, 4(sp) # CHECK: :[[@LINE]]:6: error: invalid operand for instruction
c.sd s2, 4(sp) # CHECK: :[[@LINE]]:6: error: invalid operand for instruction

## GPRPairNoX0
c.ldsp x0, 4(sp) # CHECK: :[[@LINE]]:9: error: invalid operand for instruction
c.ldsp zero, 4(sp) # CHECK: :[[@LINE]]:9: error: invalid operand for instruction

## uimm9_lsb000
c.ldsp t1, 512(sp) # CHECK: :[[@LINE]]:12: error: immediate must be a multiple of 8 bytes in the range [0, 504]
c.sdsp t1, -8(sp) # CHECK: :[[@LINE]]:12: error: immediate must be a multiple of 8 bytes in the range [0, 504]
## uimm8_lsb000
c.ld s0, -8(sp) # CHECK: :[[@LINE]]:11: error: immediate must be a multiple of 8 bytes in the range [0, 248]
c.sd s0, 256(sp) # CHECK: :[[@LINE]]:11: error: immediate must be a multiple of 8 bytes in the range [0, 248]

# Invalid register names
c.ld a1, 4(sp) # CHECK: :[[@LINE]]:6: error: register must be even
c.sd a3, 4(sp) # CHECK: :[[@LINE]]:6: error: register must be even
c.ldsp ra, 4(sp) # CHECK: :[[@LINE]]:8: error: register must be even
c.ldsp t0, 4(sp) # CHECK: :[[@LINE]]:8: error: register must be even
Loading