Skip to content

Commit 522da43

Browse files
committed
Address topperc's comments
1 parent c8fed1e commit 522da43

File tree

4 files changed

+16
-17
lines changed

4 files changed

+16
-17
lines changed

llvm/lib/Target/RISCV/RISCVAsmPrinter.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -991,10 +991,10 @@ void RISCVAsmPrinter::emitMachineConstantPoolValue(
991991
MCSymbol *MCSym;
992992

993993
if (RCPV->isGlobalValue()) {
994-
auto GV = cast<RISCVConstantPoolConstant>(RCPV)->getGlobalValue();
994+
auto *GV = cast<RISCVConstantPoolConstant>(RCPV)->getGlobalValue();
995995
MCSym = getSymbol(GV);
996996
} else if (RCPV->isBlockAddress()) {
997-
auto BA = cast<RISCVConstantPoolConstant>(RCPV)->getBlockAddress();
997+
auto *BA = cast<RISCVConstantPoolConstant>(RCPV)->getBlockAddress();
998998
MCSym = GetBlockAddressSymbol(BA);
999999
} else {
10001000
assert(RCPV->isExtSymbol() && "unrecognized constant pool value");

llvm/lib/Target/RISCV/RISCVConstantPoolValue.cpp

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,15 +40,14 @@ RISCVConstantPoolConstant::RISCVConstantPoolConstant(Type *Ty,
4040
: RISCVConstantPoolValue(Ty, Kind), CVal(GV) {}
4141

4242
RISCVConstantPoolConstant *
43-
RISCVConstantPoolConstant::Create(const GlobalValue *GV,
44-
RISCVCP::RISCVCPKind Kind) {
45-
return new RISCVConstantPoolConstant(GV->getType(), GV, Kind);
43+
RISCVConstantPoolConstant::Create(const GlobalValue *GV) {
44+
return new RISCVConstantPoolConstant(GV->getType(), GV, RISCVCP::GlobalValue);
4645
}
4746

4847
RISCVConstantPoolConstant *
49-
RISCVConstantPoolConstant::Create(const Constant *C,
50-
RISCVCP::RISCVCPKind Kind) {
51-
return new RISCVConstantPoolConstant(C->getType(), C, Kind);
48+
RISCVConstantPoolConstant::Create(const BlockAddress *BA) {
49+
return new RISCVConstantPoolConstant(BA->getType(), BA,
50+
RISCVCP::BlockAddress);
5251
}
5352

5453
int RISCVConstantPoolConstant::getExistingMachineCPValue(

llvm/lib/Target/RISCV/RISCVConstantPoolValue.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#ifndef LLVM_LIB_TARGET_RISCV_RISCVCONSTANTPOOLVALUE_H
1414
#define LLVM_LIB_TARGET_RISCV_RISCVCONSTANTPOOLVALUE_H
1515

16+
#include "llvm/ADT/StringRef.h"
1617
#include "llvm/CodeGen/MachineConstantPool.h"
1718
#include "llvm/Support/Casting.h"
1819
#include "llvm/Support/ErrorHandling.h"
@@ -74,10 +75,8 @@ class RISCVConstantPoolConstant : public RISCVConstantPoolValue {
7475
RISCVCP::RISCVCPKind Kind);
7576

7677
public:
77-
static RISCVConstantPoolConstant *Create(const GlobalValue *GV,
78-
RISCVCP::RISCVCPKind Kind);
79-
static RISCVConstantPoolConstant *Create(const Constant *C,
80-
RISCVCP::RISCVCPKind Kind);
78+
static RISCVConstantPoolConstant *Create(const GlobalValue *GV);
79+
static RISCVConstantPoolConstant *Create(const BlockAddress *BA);
8180

8281
const GlobalValue *getGlobalValue() const;
8382
const BlockAddress *getBlockAddress() const;
@@ -99,14 +98,14 @@ class RISCVConstantPoolConstant : public RISCVConstantPoolValue {
9998
};
10099

101100
class RISCVConstantPoolSymbol : public RISCVConstantPoolValue {
102-
const std::string S;
101+
const StringRef S;
103102

104103
RISCVConstantPoolSymbol(LLVMContext &C, StringRef s);
105104

106105
public:
107106
static RISCVConstantPoolSymbol *Create(LLVMContext &C, StringRef s);
108107

109-
std::string getSymbol() const { return S; }
108+
StringRef getSymbol() const { return S; }
110109

111110
int getExistingMachineCPValue(MachineConstantPool *CP,
112111
Align Alignment) override;
@@ -116,6 +115,7 @@ class RISCVConstantPoolSymbol : public RISCVConstantPoolValue {
116115
void print(raw_ostream &O) const override;
117116

118117
bool equals(const RISCVConstantPoolSymbol *A) const { return S == A->S; }
118+
119119
static bool classof(const RISCVConstantPoolValue *RCPV) {
120120
return RCPV->isExtSymbol();
121121
}

llvm/lib/Target/RISCV/RISCVISelLowering.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6435,7 +6435,7 @@ static SDValue getTargetNode(JumpTableSDNode *N, const SDLoc &DL, EVT Ty,
64356435
static SDValue getLargeGlobalAddress(GlobalAddressSDNode *N, SDLoc DL, EVT Ty,
64366436
SelectionDAG &DAG) {
64376437
RISCVConstantPoolConstant *CPV =
6438-
RISCVConstantPoolConstant::Create(N->getGlobal(), RISCVCP::GlobalValue);
6438+
RISCVConstantPoolConstant::Create(N->getGlobal());
64396439
SDValue CPAddr = DAG.getTargetConstantPool(CPV, Ty, Align(8));
64406440
SDValue LC = DAG.getNode(RISCVISD::LLA, DL, Ty, CPAddr);
64416441
return DAG.getLoad(
@@ -6445,8 +6445,8 @@ static SDValue getLargeGlobalAddress(GlobalAddressSDNode *N, SDLoc DL, EVT Ty,
64456445

64466446
static SDValue getLargeBlockAddress(BlockAddressSDNode *N, SDLoc DL, EVT Ty,
64476447
SelectionDAG &DAG) {
6448-
RISCVConstantPoolConstant *CPV = RISCVConstantPoolConstant::Create(
6449-
N->getBlockAddress(), RISCVCP::BlockAddress);
6448+
RISCVConstantPoolConstant *CPV =
6449+
RISCVConstantPoolConstant::Create(N->getBlockAddress());
64506450
SDValue CPAddr = DAG.getTargetConstantPool(CPV, Ty, Align(8));
64516451
SDValue LC = DAG.getNode(RISCVISD::LLA, DL, Ty, CPAddr);
64526452
return DAG.getLoad(

0 commit comments

Comments
 (0)