Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
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
4 changes: 4 additions & 0 deletions llvm/include/llvm/IR/IntrinsicsRISCVXCV.td
Original file line number Diff line number Diff line change
Expand Up @@ -90,4 +90,8 @@ let TargetPrefix = "riscv" in {
def int_riscv_cv_mac_machhuRN : ScalarCoreVMacGprGprGprImmIntrinsic;
def int_riscv_cv_mac_macsRN : ScalarCoreVMacGprGprGprImmIntrinsic;
def int_riscv_cv_mac_machhsRN : ScalarCoreVMacGprGprGprImmIntrinsic;

def int_riscv_cv_elw_elw
: Intrinsic<[llvm_i32_ty], [llvm_ptr_ty],
[IntrReadMem, IntrArgMemOnly, IntrHasSideEffects]>;
} // TargetPrefix = "riscv"
3 changes: 3 additions & 0 deletions llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4082,6 +4082,9 @@ bool RISCVAsmParser::processInstruction(MCInst &Inst, SMLoc IDLoc,

return false;
}
case RISCV::PseudoCV_ELW:
emitLoadStoreSymbol(Inst, RISCV::CV_ELW, IDLoc, Out, /*HasTmpReg=*/false);
return false;
}

emitToStreamer(Out, Inst);
Expand Down
9 changes: 8 additions & 1 deletion llvm/lib/Target/RISCV/RISCVInstrInfoXCV.td
Original file line number Diff line number Diff line change
Expand Up @@ -633,8 +633,9 @@ let Predicates = [HasVendorXCVmem, IsRV32] in {
def CV_SW_rr : CVStore_rr<0b011, 0b0010110, "cv.sw">;
}

let Predicates = [HasVendorXCVelw, IsRV32], hasSideEffects = 0,
let Predicates = [HasVendorXCVelw, IsRV32], hasSideEffects = 1,
mayLoad = 1, mayStore = 0 in {
def PseudoCV_ELW : PseudoLoad<"cv.elw">;
// Event load
def CV_ELW : CVLoad_ri<0b011, "cv.elw">;
}
Expand Down Expand Up @@ -706,6 +707,12 @@ let Predicates = [HasVendorXCVmem, IsRV32], AddedComplexity = 1 in {
def : CVStrrPat<store, CV_SW_rr>;
}

let Predicates = [HasVendorXCVelw, IsRV32] in {
def : Pat<(int_riscv_cv_elw_elw (XLenVT GPR:$rs1)), (PseudoCV_ELW GPR:$rs1)>;
def : Pat<(int_riscv_cv_elw_elw (AddrRegImm (XLenVT GPR:$rs1), simm12:$imm12)),
(CV_ELW GPR:$rs1, simm12:$imm12)>;
}

multiclass PatCoreVBitManip<Intrinsic intr> {
def : PatGprGpr<intr, !cast<RVInst>("CV_" # NAME # "R")>;
def : Pat<(intr GPR:$rs1, cv_uimm10:$imm),
Expand Down
27 changes: 27 additions & 0 deletions llvm/test/CodeGen/RISCV/xcvelw.ll
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
; RUN: llc -O0 -mtriple=riscv32 -mattr=+xcvelw -verify-machineinstrs < %s \
; RUN: | FileCheck %s

declare i32 @llvm.riscv.cv.elw.elw(i8*)

define i32 @test.cv.elw.elw(i8* %a) {
; CHECK-LABEL: test.cv.elw.elw:
; CHECK: # %bb.0:
; CHECK-NEXT: cv.elw a0, 0(a0)
; CHECK-NEXT: ret
%1 = call i32 @llvm.riscv.cv.elw.elw(i8* %a)
ret i32 %1
}

define i32 @test.cv.elw.elw2(i8* %a, i32 %b) {
; CHECK-LABEL: test.cv.elw.elw2:
; CHECK: # %bb.0:
; CHECK-NEXT: add a0, a1, a0
; CHECK-NEXT: cv.elw a0, 7(a0)
; CHECK-NEXT: ret
%c = add i32 %b, 4
%d = add i32 %c, 3
%e = getelementptr i8, i8* %a, i32 %d
%1 = call i32 @llvm.riscv.cv.elw.elw(i8* %e)
ret i32 %1
}
11 changes: 11 additions & 0 deletions llvm/test/MC/RISCV/corev/XCVelw-pseudo.s
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# RUN: llvm-mc %s -triple=riscv32 --mattr=+xcvelw | FileCheck %s

# CHECK: .Lpcrel_hi0:
# CHECK: auipc a2, %pcrel_hi(a_symbol)
# CHECK: cv.elw a2, %pcrel_lo(.Lpcrel_hi0)(a2)
cv.elw a2, a_symbol

# CHECK: .Lpcrel_hi1:
# CHECK: auipc a3, %pcrel_hi(a_symbol)
# CHECK: cv.elw a3, %pcrel_lo(.Lpcrel_hi1)(a3)
cv.elw a3, a_symbol
Loading