Skip to content

[RISCV][VCIX] Add vcix_state to GNU inline assembly register set #106914

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 1 commit into from
Oct 1, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion clang/lib/Basic/Targets/RISCV.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ ArrayRef<const char *> RISCVTargetInfo::getGCCRegNames() const {
"v24", "v25", "v26", "v27", "v28", "v29", "v30", "v31",

// CSRs
"fflags", "frm", "vtype", "vl", "vxsat", "vxrm"
"fflags", "frm", "vtype", "vl", "vxsat", "vxrm", "sf.vcix_state"
};
// clang-format on
return llvm::ArrayRef(GCCRegNames);
Expand Down
6 changes: 6 additions & 0 deletions llvm/lib/Target/RISCV/RISCVRegisterInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -715,6 +715,12 @@ Register RISCVRegisterInfo::getFrameRegister(const MachineFunction &MF) const {
return TFI->hasFP(MF) ? RISCV::X8 : RISCV::X2;
}

StringRef RISCVRegisterInfo::getRegAsmName(MCRegister Reg) const {
if (Reg == RISCV::SF_VCIX_STATE)
return "sf.vcix_state";
return TargetRegisterInfo::getRegAsmName(Reg);
}

const uint32_t *
RISCVRegisterInfo::getCallPreservedMask(const MachineFunction & MF,
CallingConv::ID CC) const {
Expand Down
2 changes: 2 additions & 0 deletions llvm/lib/Target/RISCV/RISCVRegisterInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,8 @@ struct RISCVRegisterInfo : public RISCVGenRegisterInfo {

Register getFrameRegister(const MachineFunction &MF) const override;

StringRef getRegAsmName(MCRegister Reg) const override;

bool requiresRegisterScavenging(const MachineFunction &MF) const override {
return true;
}
Expand Down
4 changes: 4 additions & 0 deletions llvm/lib/Target/RISCV/RISCVRegisterInfo.td
Original file line number Diff line number Diff line change
Expand Up @@ -666,3 +666,7 @@ def SSP : RISCVReg<0, "ssp">;

// Dummy SiFive VCIX state register
def SF_VCIX_STATE : RISCVReg<0, "sf.vcix_state">;
def : RISCVRegisterClass<[XLenVT], 32, (add SF_VCIX_STATE)> {
let RegInfos = XLenRI;
let isAllocatable = 0;
}
22 changes: 22 additions & 0 deletions llvm/test/CodeGen/RISCV/inline-asm-xsfvcp.ll
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 5
; RUN: sed 's/iXLen/i32/g' %s | llc -mtriple=riscv32 -mattr=+v,+xsfvcp \
; RUN: -verify-machineinstrs | FileCheck %s --check-prefixes=CHECK
; RUN: sed 's/iXLen/i64/g' %s | llc -mtriple=riscv64 -mattr=+v,+xsfvcp \
; RUN: -verify-machineinstrs | FileCheck %s --check-prefixes=CHECK

; VCIX instructions can not reorder between each other.
define void @test_reorder(<vscale x 1 x i64> %vreg) {
; CHECK-LABEL: test_reorder:
; CHECK: # %bb.0: # %entry
; CHECK-NEXT: vsetivli zero, 0, e64, m1, ta, ma
; CHECK-NEXT: sf.vc.iv 0, 0, v8, 0
; CHECK-NEXT: #APP
; CHECK-NEXT: sf.vc.vv 3, 0, v8, v8
; CHECK-EMPTY:
; CHECK-NEXT: #NO_APP
; CHECK-NEXT: ret
entry:
call void @llvm.riscv.sf.vc.iv.se.iXLen.nxv1i64.iXLen.iXLen(iXLen 0, iXLen 0, <vscale x 1 x i64> %vreg, iXLen 0, iXLen 0)
call iXLen asm sideeffect "sf.vc.vv 0x3, 0x0, $1, $1;", "=r,^vr,~{memory},~{vl},~{sf.vcix_state}"(<vscale x 1 x i64> %vreg)
ret void
}
Loading