Skip to content

Commit 292d34c

Browse files
realqhcNandniJamnadas
authored andcommitted
1 parent 8263119 commit 292d34c

File tree

5 files changed

+42
-1
lines changed

5 files changed

+42
-1
lines changed

llvm/include/llvm/IR/IntrinsicsRISCV.td

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1768,4 +1768,7 @@ def int_riscv_cv_mac_macurn : ScalarCoreVMacGprGprGprImmIntrinsic;
17681768
def int_riscv_cv_mac_machhurn : ScalarCoreVMacGprGprGprImmIntrinsic;
17691769
def int_riscv_cv_mac_macsrn : ScalarCoreVMacGprGprGprImmIntrinsic;
17701770
def int_riscv_cv_mac_machhsrn : ScalarCoreVMacGprGprGprImmIntrinsic;
1771+
1772+
def int_riscv_cv_elw_elw
1773+
: Intrinsic<[llvm_i32_ty], [llvm_ptr_ty], [IntrReadMem, IntrArgMemOnly]>;
17711774
} // TargetPrefix = "riscv"

llvm/lib/Support/RISCVISAInfo.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,8 @@ static const RISCVSupportedExtension SupportedExtensions[] = {
107107
{"xcvsimd", RISCVExtensionVersion{1, 0}},
108108
{"xcvbitmanip", RISCVExtensionVersion{1, 0}},
109109
{"xcvbi", RISCVExtensionVersion{1, 0}},
110-
{"xcvmac", RISCVExtensionVersion{1, 0}}
110+
{"xcvmac", RISCVExtensionVersion{1, 0}},
111+
{"xcvelw", RISCVExtensionVersion{1, 0}}
111112
};
112113

113114
static const RISCVSupportedExtension SupportedExperimentalExtensions[] = {

llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2800,6 +2800,9 @@ bool RISCVAsmParser::processInstruction(MCInst &Inst, SMLoc IDLoc,
28002800
case RISCV::PseudoFSD:
28012801
emitLoadStoreSymbol(Inst, RISCV::FSD, IDLoc, Out, /*HasTmpReg=*/true);
28022802
return false;
2803+
case RISCV::PseudoCV_ELW:
2804+
emitLoadStoreSymbol(Inst, RISCV::CV_ELW, IDLoc, Out, /*HasTmpReg=*/true);
2805+
return false;
28032806
case RISCV::PseudoAddTPRel:
28042807
if (checkPseudoAddTPRel(Inst, Operands))
28052808
return true;

llvm/lib/Target/RISCV/RISCVInstrInfoCOREV.td

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -629,6 +629,7 @@ let Predicates = [HasExtXcvbitmanip, IsRV32], hasSideEffects = 0, mayLoad = 0, m
629629
}
630630

631631
let Predicates = [HasExtXcvelw], hasSideEffects = 0, mayLoad = 1, mayStore = 0 in {
632+
def PseudoCV_ELW : PseudoLoad<"cv.elw">;
632633
def CV_ELW : RVInstLoad_ri_inc<0b011, (outs GPR:$rd), (ins GPR:$rs1, simm12:$imm12),
633634
"cv.elw", "$rd, ${imm12}(${rs1})", []>,
634635
Sched<[]>;
@@ -1136,6 +1137,12 @@ let Predicates = [HasExtXcvbitmanip, IsRV32] in {
11361137
(CV_BITREV GPR:$rs1, cv_tuimm5:$pts, cv_tuimm2:$radix)>;
11371138
}
11381139

1140+
let Predicates = [HasExtXcvelw, IsRV32] in {
1141+
def : Pat<(int_riscv_cv_elw_elw GPR:$rs1), (PseudoCV_ELW GPR:$rs1)>;
1142+
def : Pat<(int_riscv_cv_elw_elw (AddrRegImm GPR:$rs1, simm12:$imm12)),
1143+
(CV_ELW GPR:$rs1, simm12:$imm12)>;
1144+
}
1145+
11391146
//===----------------------------------------------------------------------===//
11401147
// Pseudo instructions and patterns for hardware loop generation
11411148
//===----------------------------------------------------------------------===//

llvm/test/CodeGen/RISCV/corev/elw.ll

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2+
; RUN: llc -O0 -mtriple=riscv32 -mattr=+xcvelw -verify-machineinstrs < %s \
3+
; RUN: | FileCheck %s
4+
5+
declare i32 @llvm.riscv.cv.elw.elw(i8*)
6+
7+
define i32 @test.cv.elw.elw(i8* %a) {
8+
; CHECK-LABEL: test.cv.elw.elw:
9+
; CHECK: # %bb.0:
10+
; CHECK-NEXT: cv.elw a0, 0(a0)
11+
; CHECK-NEXT: ret
12+
%1 = call i32 @llvm.riscv.cv.elw.elw(i8* %a)
13+
ret i32 %1
14+
}
15+
16+
define i32 @test.cv.elw.elw2(i8* %a, i32 %b) {
17+
; CHECK-LABEL: test.cv.elw.elw2:
18+
; CHECK: # %bb.0:
19+
; CHECK-NEXT: add a0, a1, a0
20+
; CHECK-NEXT: cv.elw a0, 7(a0)
21+
; CHECK-NEXT: ret
22+
%c = add i32 %b, 4
23+
%d = add i32 %c, 3
24+
%e = getelementptr i8, i8* %a, i32 %d
25+
%1 = call i32 @llvm.riscv.cv.elw.elw(i8* %e)
26+
ret i32 %1
27+
}

0 commit comments

Comments
 (0)