[llvm] [RISCV][NFC] Add helpers for RVV register classes (PR #84144)
Wang Pengcheng via llvm-commits
llvm-commits at lists.llvm.org
Wed Mar 6 01:10:44 PST 2024
https://github.com/wangpc-pp updated https://github.com/llvm/llvm-project/pull/84144
>From 1d7ca79a9880a27d6f829bae9ab105d826387216 Mon Sep 17 00:00:00 2001
From: Wang Pengcheng <wangpengcheng.pp at bytedance.com>
Date: Wed, 6 Mar 2024 17:10:06 +0800
Subject: [PATCH] =?UTF-8?q?[=F0=9D=98=80=F0=9D=97=BD=F0=9D=97=BF]=20initia?=
=?UTF-8?q?l=20version?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Created using spr 1.3.4
---
llvm/lib/Target/RISCV/RISCVRegisterInfo.h | 22 ++++++++++++++++++--
llvm/lib/Target/RISCV/RISCVTargetMachine.cpp | 18 +++-------------
2 files changed, 23 insertions(+), 17 deletions(-)
diff --git a/llvm/lib/Target/RISCV/RISCVRegisterInfo.h b/llvm/lib/Target/RISCV/RISCVRegisterInfo.h
index e46fe8ecb900fc..f5b4cac7dffd74 100644
--- a/llvm/lib/Target/RISCV/RISCVRegisterInfo.h
+++ b/llvm/lib/Target/RISCV/RISCVRegisterInfo.h
@@ -110,13 +110,31 @@ struct RISCVRegisterInfo : public RISCVGenRegisterInfo {
return RC;
}
- bool doesRegClassHavePseudoInitUndef(
- const TargetRegisterClass *RC) const override {
+ bool isRVVRegClass(const TargetRegisterClass *RC) const {
return RISCV::VRRegClass.hasSubClassEq(RC) ||
RISCV::VRM2RegClass.hasSubClassEq(RC) ||
RISCV::VRM4RegClass.hasSubClassEq(RC) ||
RISCV::VRM8RegClass.hasSubClassEq(RC);
}
+
+ bool isRVVSegmentRegClass(const TargetRegisterClass *RC) const {
+ return RISCV::VRN2M1RegClass.hasSubClassEq(RC) ||
+ RISCV::VRN2M2RegClass.hasSubClassEq(RC) ||
+ RISCV::VRN2M4RegClass.hasSubClassEq(RC) ||
+ RISCV::VRN3M1RegClass.hasSubClassEq(RC) ||
+ RISCV::VRN3M2RegClass.hasSubClassEq(RC) ||
+ RISCV::VRN4M1RegClass.hasSubClassEq(RC) ||
+ RISCV::VRN4M2RegClass.hasSubClassEq(RC) ||
+ RISCV::VRN5M1RegClass.hasSubClassEq(RC) ||
+ RISCV::VRN6M1RegClass.hasSubClassEq(RC) ||
+ RISCV::VRN7M1RegClass.hasSubClassEq(RC) ||
+ RISCV::VRN8M1RegClass.hasSubClassEq(RC);
+ }
+
+ bool doesRegClassHavePseudoInitUndef(
+ const TargetRegisterClass *RC) const override {
+ return isRVVRegClass(RC);
+ }
};
}
diff --git a/llvm/lib/Target/RISCV/RISCVTargetMachine.cpp b/llvm/lib/Target/RISCV/RISCVTargetMachine.cpp
index 6fe0abaccb9d98..e499f77fb7772b 100644
--- a/llvm/lib/Target/RISCV/RISCVTargetMachine.cpp
+++ b/llvm/lib/Target/RISCV/RISCVTargetMachine.cpp
@@ -14,6 +14,7 @@
#include "MCTargetDesc/RISCVBaseInfo.h"
#include "RISCV.h"
#include "RISCVMachineFunctionInfo.h"
+#include "RISCVRegisterInfo.h"
#include "RISCVTargetObjectFile.h"
#include "RISCVTargetTransformInfo.h"
#include "TargetInfo/RISCVTargetInfo.h"
@@ -278,21 +279,8 @@ class RVVRegisterRegAlloc : public RegisterRegAllocBase<RVVRegisterRegAlloc> {
static bool onlyAllocateRVVReg(const TargetRegisterInfo &TRI,
const TargetRegisterClass &RC) {
- return RISCV::VRRegClass.hasSubClassEq(&RC) ||
- RISCV::VRM2RegClass.hasSubClassEq(&RC) ||
- RISCV::VRM4RegClass.hasSubClassEq(&RC) ||
- RISCV::VRM8RegClass.hasSubClassEq(&RC) ||
- RISCV::VRN2M1RegClass.hasSubClassEq(&RC) ||
- RISCV::VRN2M2RegClass.hasSubClassEq(&RC) ||
- RISCV::VRN2M4RegClass.hasSubClassEq(&RC) ||
- RISCV::VRN3M1RegClass.hasSubClassEq(&RC) ||
- RISCV::VRN3M2RegClass.hasSubClassEq(&RC) ||
- RISCV::VRN4M1RegClass.hasSubClassEq(&RC) ||
- RISCV::VRN4M2RegClass.hasSubClassEq(&RC) ||
- RISCV::VRN5M1RegClass.hasSubClassEq(&RC) ||
- RISCV::VRN6M1RegClass.hasSubClassEq(&RC) ||
- RISCV::VRN7M1RegClass.hasSubClassEq(&RC) ||
- RISCV::VRN8M1RegClass.hasSubClassEq(&RC);
+ auto &RegInfo = static_cast<const RISCVRegisterInfo &>(TRI);
+ return RegInfo.isRVVRegClass(&RC) || RegInfo.isRVVSegmentRegClass(&RC);
}
static FunctionPass *useDefaultRegisterAllocator() { return nullptr; }
More information about the llvm-commits
mailing list