Skip to content

Commit 311402f

Browse files
toppercaaryanshukla
authored andcommitted
[RISCV] Store a std::unique_ptr<RISCVRegisterBankInfo> in RISCVSubtarget. NFC (llvm#98375)
Instead of std::unique_ptr<RegisterBankInfo>. This allows us to return a RISCVRegisterBankInfo* from getRegBankInfo so we can avoid a static_cast. This does require an additional header file to be included in RISCVSubtarget.h, but I don't think it's a big deal.
1 parent 1b7c09d commit 311402f

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed

llvm/lib/Target/RISCV/RISCVSubtarget.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
#include "RISCVSubtarget.h"
1414
#include "GISel/RISCVCallLowering.h"
1515
#include "GISel/RISCVLegalizerInfo.h"
16-
#include "GISel/RISCVRegisterBankInfo.h"
1716
#include "RISCV.h"
1817
#include "RISCVFrameLowering.h"
1918
#include "RISCVTargetMachine.h"
@@ -109,7 +108,7 @@ InstructionSelector *RISCVSubtarget::getInstructionSelector() const {
109108
if (!InstSelector) {
110109
InstSelector.reset(createRISCVInstructionSelector(
111110
*static_cast<const RISCVTargetMachine *>(&TLInfo.getTargetMachine()),
112-
*this, *static_cast<const RISCVRegisterBankInfo *>(getRegBankInfo())));
111+
*this, *getRegBankInfo()));
113112
}
114113
return InstSelector.get();
115114
}
@@ -120,7 +119,7 @@ const LegalizerInfo *RISCVSubtarget::getLegalizerInfo() const {
120119
return Legalizer.get();
121120
}
122121

123-
const RegisterBankInfo *RISCVSubtarget::getRegBankInfo() const {
122+
const RISCVRegisterBankInfo *RISCVSubtarget::getRegBankInfo() const {
124123
if (!RegBankInfo)
125124
RegBankInfo.reset(new RISCVRegisterBankInfo(getHwMode()));
126125
return RegBankInfo.get();

llvm/lib/Target/RISCV/RISCVSubtarget.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,14 @@
1313
#ifndef LLVM_LIB_TARGET_RISCV_RISCVSUBTARGET_H
1414
#define LLVM_LIB_TARGET_RISCV_RISCVSUBTARGET_H
1515

16+
#include "GISel/RISCVRegisterBankInfo.h"
1617
#include "MCTargetDesc/RISCVBaseInfo.h"
1718
#include "RISCVFrameLowering.h"
1819
#include "RISCVISelLowering.h"
1920
#include "RISCVInstrInfo.h"
2021
#include "llvm/CodeGen/GlobalISel/CallLowering.h"
2122
#include "llvm/CodeGen/GlobalISel/InstructionSelector.h"
2223
#include "llvm/CodeGen/GlobalISel/LegalizerInfo.h"
23-
#include "llvm/CodeGen/RegisterBankInfo.h"
2424
#include "llvm/CodeGen/SelectionDAGTargetInfo.h"
2525
#include "llvm/CodeGen/TargetSubtargetInfo.h"
2626
#include "llvm/IR/DataLayout.h"
@@ -248,7 +248,7 @@ class RISCVSubtarget : public RISCVGenSubtargetInfo {
248248
mutable std::unique_ptr<CallLowering> CallLoweringInfo;
249249
mutable std::unique_ptr<InstructionSelector> InstSelector;
250250
mutable std::unique_ptr<LegalizerInfo> Legalizer;
251-
mutable std::unique_ptr<RegisterBankInfo> RegBankInfo;
251+
mutable std::unique_ptr<RISCVRegisterBankInfo> RegBankInfo;
252252

253253
// Return the known range for the bit length of RVV data registers as set
254254
// at the command line. A value of 0 means nothing is known about that particular
@@ -261,7 +261,7 @@ class RISCVSubtarget : public RISCVGenSubtargetInfo {
261261
const CallLowering *getCallLowering() const override;
262262
InstructionSelector *getInstructionSelector() const override;
263263
const LegalizerInfo *getLegalizerInfo() const override;
264-
const RegisterBankInfo *getRegBankInfo() const override;
264+
const RISCVRegisterBankInfo *getRegBankInfo() const override;
265265

266266
bool isTargetAndroid() const { return getTargetTriple().isAndroid(); }
267267
bool isTargetFuchsia() const { return getTargetTriple().isOSFuchsia(); }

0 commit comments

Comments
 (0)