Skip to content

Commit 1f1ebfb

Browse files
committed
[RISCV] Add MC support for zicldst
1 parent f78d288 commit 1f1ebfb

File tree

4 files changed

+56
-0
lines changed

4 files changed

+56
-0
lines changed

llvm/lib/Target/RISCV/RISCVFeatures.td

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,13 @@ def HasStdExtZicond : Predicate<"Subtarget->hasStdExtZicond()">,
130130
AssemblerPredicate<(all_of FeatureStdExtZicond),
131131
"'Zicond' (Integer Conditional Operations)">;
132132

133+
def FeatureStdExtZicldst
134+
: RISCVExtension<"zicldst", 1, 0,
135+
"'Zicldst' (Integer Conditional Load Store)">;
136+
def HasStdExtZicldst : Predicate<"Subtarget->hasStdExtZicldst()">,
137+
AssemblerPredicate<(all_of FeatureStdExtZicldst),
138+
"'Zicldst' (Integer Conditional Load Store)">;
139+
133140
def FeatureStdExtZifencei
134141
: RISCVExtension<"zifencei", 2, 0,
135142
"'Zifencei' (fence.i)">;

llvm/lib/Target/RISCV/RISCVInstrInfo.td

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2068,6 +2068,7 @@ include "RISCVInstrInfoZcmop.td"
20682068
include "RISCVInstrInfoZimop.td"
20692069
include "RISCVInstrInfoZicbo.td"
20702070
include "RISCVInstrInfoZicond.td"
2071+
include "RISCVInstrInfoZicldst.td"
20712072
include "RISCVInstrInfoZicfiss.td"
20722073

20732074
//===----------------------------------------------------------------------===//
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
//===-- RISCVInstrInfoZicldst.td ---------------------------*- tablegen -*-===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
//
9+
// This file describes the RISC-V instructions from the standard Integer
10+
// Conditional Load Store operations extension (Zicldst).
11+
//
12+
//===----------------------------------------------------------------------===//
13+
14+
let hasSideEffects = 0, mayLoad = 1, mayStore = 0 in {
15+
class CondLoad_ri<bits<3> funct3, string opcodestr>
16+
: RVInstI<funct3, OPC_CUSTOM_0, (outs GPR:$rd), (ins GPRMem:$rs1, simm12:$imm12),
17+
opcodestr, "$rd, ${imm12}(${rs1})">;
18+
}
19+
20+
let hasSideEffects = 0, mayLoad = 0, mayStore = 1 in {
21+
class CondStore_rri<bits<3> funct3, string opcodestr>
22+
: RVInstS<funct3, OPC_CUSTOM_1, (outs),
23+
(ins GPR:$rs2, GPRMem:$rs1, simm12:$imm12),
24+
opcodestr, "$rs2, ${imm12}(${rs1})">;
25+
}
26+
27+
let Predicates = [HasStdExtZicldst] in {
28+
29+
let IsSignExtendingOpW = 1 in {
30+
def CLB : CondLoad_ri<0b000, "clb">, Sched<[WriteLDB, ReadMemBase]>;
31+
def CLH : CondLoad_ri<0b001, "clh">, Sched<[WriteLDH, ReadMemBase]>;
32+
def CLW : CondLoad_ri<0b010, "clw">, Sched<[WriteLDW, ReadMemBase]>;
33+
def CLBU : CondLoad_ri<0b100, "clbu">, Sched<[WriteLDB, ReadMemBase]>;
34+
def CLHU : CondLoad_ri<0b101, "clhu">, Sched<[WriteLDH, ReadMemBase]>;
35+
}
36+
37+
def CSB : CondStore_rri<0b000, "csb">, Sched<[WriteSTB, ReadStoreData, ReadMemBase]>;
38+
def CSH : CondStore_rri<0b001, "csh">, Sched<[WriteSTH, ReadStoreData, ReadMemBase]>;
39+
def CSW : CondStore_rri<0b010, "csw">, Sched<[WriteSTW, ReadStoreData, ReadMemBase]>;
40+
41+
} // Predicates = [HasStdExtZcildst]
42+
43+
let Predicates = [HasStdExtZicldst, IsRV64] in {
44+
def CLWU : CondLoad_ri<0b110, "clwu">, Sched<[WriteLDW, ReadMemBase]>;
45+
def CLD : CondLoad_ri<0b011, "cld">, Sched<[WriteLDD, ReadMemBase]>;
46+
def CSD : CondStore_rri<0b011, "csd">, Sched<[WriteSTD, ReadStoreData, ReadMemBase]>;
47+
} // Predicates = [HasStdExtZicldst, IsRV64]

llvm/unittests/TargetParser/RISCVISAInfoTest.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -879,6 +879,7 @@ R"(All available -march extensions for RISC-V
879879
ziccif 1.0
880880
zicclsm 1.0
881881
ziccrse 1.0
882+
zicldst 1.0
882883
zicntr 2.0
883884
zicond 1.0
884885
zicsr 2.0

0 commit comments

Comments
 (0)