Skip to content

Commit 1d0005a

Browse files
authored
[GlobalISel][NFC] Rename GISelKnownBits to GISelValueTracking (llvm#133466)
- rename `GISelKnownBits` to `GISelValueTracking` to analyze more than just `KnownBits` in the future
1 parent d852cc5 commit 1d0005a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+517
-514
lines changed

llvm/docs/GlobalISel/KnownBits.rst

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -61,23 +61,23 @@ dependency with ``INITIALIZE_PASS_DEPENDENCY``.
6161

6262
.. code-block:: c++
6363

64-
#include "llvm/CodeGen/GlobalISel/GISelKnownBits.h"
64+
#include "llvm/CodeGen/GlobalISel/GISelValueTracking.h"
6565

6666
...
6767

6868
INITIALIZE_PASS_BEGIN(...)
69-
INITIALIZE_PASS_DEPENDENCY(GISelKnownBitsAnalysis)
69+
INITIALIZE_PASS_DEPENDENCY(GISelValueTrackingAnalysis)
7070
INITIALIZE_PASS_END(...)
7171

7272
and require the pass in ``getAnalysisUsage``.
7373

7474
.. code-block:: c++
7575

7676
void MyPass::getAnalysisUsage(AnalysisUsage &AU) const {
77-
AU.addRequired<GISelKnownBitsAnalysis>();
77+
AU.addRequired<GISelValueTrackingAnalysis>();
7878
// Optional: If your pass preserves known bits analysis (many do) then
7979
// indicate that it's preserved for re-use by another pass here.
80-
AU.addPreserved<GISelKnownBitsAnalysis>();
80+
AU.addPreserved<GISelValueTrackingAnalysis>();
8181
}
8282

8383
Then it's just a matter of fetching the analysis and using it:
@@ -86,10 +86,10 @@ Then it's just a matter of fetching the analysis and using it:
8686

8787
bool MyPass::runOnMachineFunction(MachineFunction &MF) {
8888
...
89-
GISelKnownBits &KB = getAnalysis<GISelKnownBitsAnalysis>().get(MF);
89+
GISelValueTracking &VT = getAnalysis<GISelValueTrackingAnalysis>().get(MF);
9090
...
9191
MachineInstr *MI = ...;
92-
KnownBits Known = KB->getKnownBits(MI->getOperand(0).getReg());
92+
KnownBits Known = VT->getKnownBits(MI->getOperand(0).getReg());
9393
if (Known.Zeros & 1) {
9494
// Bit 0 is known to be zero
9595
}

llvm/include/llvm/CodeGen/GlobalISel/Combiner.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ class Combiner : public GIMatchTableExecutor {
5858
/// If CSEInfo is not null, then the Combiner will use CSEInfo as the observer
5959
/// and also create a CSEMIRBuilder. Pass nullptr if CSE is not needed.
6060
Combiner(MachineFunction &MF, CombinerInfo &CInfo,
61-
const TargetPassConfig *TPC, GISelKnownBits *KB,
61+
const TargetPassConfig *TPC, GISelValueTracking *VT,
6262
GISelCSEInfo *CSEInfo = nullptr);
6363
virtual ~Combiner();
6464

@@ -72,7 +72,7 @@ class Combiner : public GIMatchTableExecutor {
7272
MachineIRBuilder &B;
7373
MachineFunction &MF;
7474
MachineRegisterInfo &MRI;
75-
GISelKnownBits *KB;
75+
GISelValueTracking *VT;
7676

7777
const TargetPassConfig *TPC;
7878
GISelCSEInfo *CSEInfo;

llvm/include/llvm/CodeGen/GlobalISel/CombinerHelper.h

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ class MachineInstrBuilder;
3838
class MachineRegisterInfo;
3939
class MachineInstr;
4040
class MachineOperand;
41-
class GISelKnownBits;
41+
class GISelValueTracking;
4242
class MachineDominatorTree;
4343
class LegalizerInfo;
4444
struct LegalityQuery;
@@ -106,7 +106,7 @@ class CombinerHelper {
106106
MachineIRBuilder &Builder;
107107
MachineRegisterInfo &MRI;
108108
GISelChangeObserver &Observer;
109-
GISelKnownBits *KB;
109+
GISelValueTracking *VT;
110110
MachineDominatorTree *MDT;
111111
bool IsPreLegalize;
112112
const LegalizerInfo *LI;
@@ -115,14 +115,11 @@ class CombinerHelper {
115115

116116
public:
117117
CombinerHelper(GISelChangeObserver &Observer, MachineIRBuilder &B,
118-
bool IsPreLegalize,
119-
GISelKnownBits *KB = nullptr,
118+
bool IsPreLegalize, GISelValueTracking *VT = nullptr,
120119
MachineDominatorTree *MDT = nullptr,
121120
const LegalizerInfo *LI = nullptr);
122121

123-
GISelKnownBits *getKnownBits() const {
124-
return KB;
125-
}
122+
GISelValueTracking *getValueTracking() const { return VT; }
126123

127124
MachineIRBuilder &getBuilder() const {
128125
return Builder;

llvm/include/llvm/CodeGen/GlobalISel/GIMatchTableExecutor.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ class MachineBasicBlock;
4141
class ProfileSummaryInfo;
4242
class APInt;
4343
class APFloat;
44-
class GISelKnownBits;
44+
class GISelValueTracking;
4545
class MachineInstr;
4646
class MachineIRBuilder;
4747
class MachineInstrBuilder;
@@ -588,7 +588,7 @@ class GIMatchTableExecutor {
588588
virtual ~GIMatchTableExecutor() = default;
589589

590590
CodeGenCoverage *CoverageInfo = nullptr;
591-
GISelKnownBits *KB = nullptr;
591+
GISelValueTracking *VT = nullptr;
592592
MachineFunction *MF = nullptr;
593593
ProfileSummaryInfo *PSI = nullptr;
594594
BlockFrequencyInfo *BFI = nullptr;
@@ -598,12 +598,12 @@ class GIMatchTableExecutor {
598598
virtual void setupGeneratedPerFunctionState(MachineFunction &MF) = 0;
599599

600600
/// Setup per-MF executor state.
601-
virtual void setupMF(MachineFunction &mf, GISelKnownBits *kb,
601+
virtual void setupMF(MachineFunction &mf, GISelValueTracking *vt,
602602
CodeGenCoverage *covinfo = nullptr,
603603
ProfileSummaryInfo *psi = nullptr,
604604
BlockFrequencyInfo *bfi = nullptr) {
605605
CoverageInfo = covinfo;
606-
KB = kb;
606+
VT = vt;
607607
MF = &mf;
608608
PSI = psi;
609609
BFI = bfi;

llvm/include/llvm/CodeGen/GlobalISel/GISelKnownBits.h renamed to llvm/include/llvm/CodeGen/GlobalISel/GISelValueTracking.h

Lines changed: 18 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//===- llvm/CodeGen/GlobalISel/GISelKnownBits.h ---------------*- C++ -*-===//
1+
//===- llvm/CodeGen/GlobalISel/GISelValueTracking.h -------------*- C++ -*-===//
22
//
33
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
44
// See https://llvm.org/LICENSE.txt for license information.
@@ -11,8 +11,8 @@
1111
///
1212
//===----------------------------------------------------------------------===//
1313

14-
#ifndef LLVM_CODEGEN_GLOBALISEL_GISELKNOWNBITS_H
15-
#define LLVM_CODEGEN_GLOBALISEL_GISELKNOWNBITS_H
14+
#ifndef LLVM_CODEGEN_GLOBALISEL_GISELVALUETRACKING_H
15+
#define LLVM_CODEGEN_GLOBALISEL_GISELVALUETRACKING_H
1616

1717
#include "llvm/ADT/DenseMap.h"
1818
#include "llvm/CodeGen/GlobalISel/GISelChangeObserver.h"
@@ -26,7 +26,7 @@ namespace llvm {
2626
class TargetLowering;
2727
class DataLayout;
2828

29-
class GISelKnownBits : public GISelChangeObserver {
29+
class GISelValueTracking : public GISelChangeObserver {
3030
MachineFunction &MF;
3131
MachineRegisterInfo &MRI;
3232
const TargetLowering &TL;
@@ -36,23 +36,18 @@ class GISelKnownBits : public GISelChangeObserver {
3636
SmallDenseMap<Register, KnownBits, 16> ComputeKnownBitsCache;
3737

3838
void computeKnownBitsMin(Register Src0, Register Src1, KnownBits &Known,
39-
const APInt &DemandedElts,
40-
unsigned Depth = 0);
39+
const APInt &DemandedElts, unsigned Depth = 0);
4140

4241
unsigned computeNumSignBitsMin(Register Src0, Register Src1,
4342
const APInt &DemandedElts, unsigned Depth = 0);
4443

4544
public:
46-
GISelKnownBits(MachineFunction &MF, unsigned MaxDepth = 6);
47-
virtual ~GISelKnownBits() = default;
45+
GISelValueTracking(MachineFunction &MF, unsigned MaxDepth = 6);
46+
virtual ~GISelValueTracking() = default;
4847

49-
const MachineFunction &getMachineFunction() const {
50-
return MF;
51-
}
48+
const MachineFunction &getMachineFunction() const { return MF; }
5249

53-
const DataLayout &getDataLayout() const {
54-
return DL;
55-
}
50+
const DataLayout &getDataLayout() const { return DL; }
5651

5752
virtual void computeKnownBitsImpl(Register R, KnownBits &Known,
5853
const APInt &DemandedElts,
@@ -83,8 +78,7 @@ class GISelKnownBits : public GISelChangeObserver {
8378
/// predicate to simplify operations downstream.
8479
bool signBitIsZero(Register Op);
8580

86-
static void computeKnownBitsForAlignment(KnownBits &Known,
87-
Align Alignment) {
81+
static void computeKnownBitsForAlignment(KnownBits &Known, Align Alignment) {
8882
// The low bits are known zero if the pointer is aligned.
8983
Known.Zero.setLowBits(Log2(Alignment));
9084
}
@@ -103,26 +97,26 @@ class GISelKnownBits : public GISelChangeObserver {
10397
};
10498

10599
/// To use KnownBitsInfo analysis in a pass,
106-
/// KnownBitsInfo &Info = getAnalysis<GISelKnownBitsInfoAnalysis>().get(MF);
100+
/// KnownBitsInfo &Info = getAnalysis<GISelValueTrackingInfoAnalysis>().get(MF);
107101
/// Add to observer if the Info is caching.
108102
/// WrapperObserver.addObserver(Info);
109103

110104
/// Eventually add other features such as caching/ser/deserializing
111-
/// to MIR etc. Those implementations can derive from GISelKnownBits
105+
/// to MIR etc. Those implementations can derive from GISelValueTracking
112106
/// and override computeKnownBitsImpl.
113-
class GISelKnownBitsAnalysis : public MachineFunctionPass {
114-
std::unique_ptr<GISelKnownBits> Info;
107+
class GISelValueTrackingAnalysis : public MachineFunctionPass {
108+
std::unique_ptr<GISelValueTracking> Info;
115109

116110
public:
117111
static char ID;
118-
GISelKnownBitsAnalysis() : MachineFunctionPass(ID) {
119-
initializeGISelKnownBitsAnalysisPass(*PassRegistry::getPassRegistry());
112+
GISelValueTrackingAnalysis() : MachineFunctionPass(ID) {
113+
initializeGISelValueTrackingAnalysisPass(*PassRegistry::getPassRegistry());
120114
}
121-
GISelKnownBits &get(MachineFunction &MF);
115+
GISelValueTracking &get(MachineFunction &MF);
122116
void getAnalysisUsage(AnalysisUsage &AU) const override;
123117
bool runOnMachineFunction(MachineFunction &MF) override;
124118
void releaseMemory() override { Info.reset(); }
125119
};
126120
} // namespace llvm
127121

128-
#endif // LLVM_CODEGEN_GLOBALISEL_GISELKNOWNBITS_H
122+
#endif // LLVM_CODEGEN_GLOBALISEL_GISELVALUETRACKING_H

llvm/include/llvm/CodeGen/GlobalISel/InstructionSelect.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
namespace llvm {
2222

2323
class InstructionSelector;
24-
class GISelKnownBits;
24+
class GISelValueTracking;
2525
class BlockFrequencyInfo;
2626
class ProfileSummaryInfo;
2727

@@ -62,7 +62,7 @@ class InstructionSelect : public MachineFunctionPass {
6262
class MIIteratorMaintainer;
6363

6464
InstructionSelector *ISel = nullptr;
65-
GISelKnownBits *KB = nullptr;
65+
GISelValueTracking *VT = nullptr;
6666
BlockFrequencyInfo *BFI = nullptr;
6767
ProfileSummaryInfo *PSI = nullptr;
6868

llvm/include/llvm/CodeGen/GlobalISel/LegalizationArtifactCombiner.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ class LegalizationArtifactCombiner {
3636
MachineIRBuilder &Builder;
3737
MachineRegisterInfo &MRI;
3838
const LegalizerInfo &LI;
39-
GISelKnownBits *KB;
39+
GISelValueTracking *VT;
4040

4141
static bool isArtifactCast(unsigned Opc) {
4242
switch (Opc) {
@@ -53,8 +53,8 @@ class LegalizationArtifactCombiner {
5353
public:
5454
LegalizationArtifactCombiner(MachineIRBuilder &B, MachineRegisterInfo &MRI,
5555
const LegalizerInfo &LI,
56-
GISelKnownBits *KB = nullptr)
57-
: Builder(B), MRI(MRI), LI(LI), KB(KB) {}
56+
GISelValueTracking *VT = nullptr)
57+
: Builder(B), MRI(MRI), LI(LI), VT(VT) {}
5858

5959
bool tryCombineAnyExt(MachineInstr &MI,
6060
SmallVectorImpl<MachineInstr *> &DeadInsts,
@@ -151,7 +151,7 @@ class LegalizationArtifactCombiner {
151151
// OptLevel results in significant compile-time and O0 code-size
152152
// improvements. Inserting unnecessary instructions between boolean defs
153153
// and uses hinders a lot of folding during ISel.
154-
if (KB && (KB->getKnownZeroes(AndSrc) | ExtMaskVal).isAllOnes()) {
154+
if (VT && (VT->getKnownZeroes(AndSrc) | ExtMaskVal).isAllOnes()) {
155155
replaceRegOrBuildCopy(DstReg, AndSrc, MRI, Builder, UpdatedDefs,
156156
Observer);
157157
} else {
@@ -214,7 +214,7 @@ class LegalizationArtifactCombiner {
214214
TruncSrc = Builder.buildAnyExtOrTrunc(DstTy, TruncSrc).getReg(0);
215215
// Elide G_SEXT_INREG if possible. This is similar to eliding G_AND in
216216
// tryCombineZExt. Refer to the comment in tryCombineZExt for rationale.
217-
if (KB && KB->computeNumSignBits(TruncSrc) >
217+
if (VT && VT->computeNumSignBits(TruncSrc) >
218218
DstTy.getScalarSizeInBits() - SizeInBits)
219219
replaceRegOrBuildCopy(DstReg, TruncSrc, MRI, Builder, UpdatedDefs,
220220
Observer);

llvm/include/llvm/CodeGen/GlobalISel/Legalizer.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323
#include "llvm/ADT/ArrayRef.h"
2424
#include "llvm/ADT/StringRef.h"
25-
#include "llvm/CodeGen/GlobalISel/GISelKnownBits.h"
25+
#include "llvm/CodeGen/GlobalISel/GISelValueTracking.h"
2626
#include "llvm/CodeGen/MachineFunction.h"
2727
#include "llvm/CodeGen/MachineFunctionPass.h"
2828

@@ -77,7 +77,7 @@ class Legalizer : public MachineFunctionPass {
7777
legalizeMachineFunction(MachineFunction &MF, const LegalizerInfo &LI,
7878
ArrayRef<GISelChangeObserver *> AuxObservers,
7979
LostDebugLocObserver &LocObserver,
80-
MachineIRBuilder &MIRBuilder, GISelKnownBits *KB);
80+
MachineIRBuilder &MIRBuilder, GISelValueTracking *VT);
8181
};
8282
} // End namespace llvm.
8383

llvm/include/llvm/CodeGen/GlobalISel/LegalizerHelper.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
#define LLVM_CODEGEN_GLOBALISEL_LEGALIZERHELPER_H
2222

2323
#include "llvm/CodeGen/GlobalISel/CallLowering.h"
24-
#include "llvm/CodeGen/GlobalISel/GISelKnownBits.h"
24+
#include "llvm/CodeGen/GlobalISel/GISelValueTracking.h"
2525
#include "llvm/CodeGen/GlobalISel/MachineIRBuilder.h"
2626
#include "llvm/CodeGen/RuntimeLibcallUtil.h"
2727
#include "llvm/CodeGen/TargetOpcodes.h"
@@ -58,7 +58,7 @@ class LegalizerHelper {
5858
MachineRegisterInfo &MRI;
5959
const LegalizerInfo &LI;
6060
const TargetLowering &TLI;
61-
GISelKnownBits *KB;
61+
GISelValueTracking *VT;
6262

6363
public:
6464
enum LegalizeResult {
@@ -77,13 +77,13 @@ class LegalizerHelper {
7777
/// Expose LegalizerInfo so the clients can re-use.
7878
const LegalizerInfo &getLegalizerInfo() const { return LI; }
7979
const TargetLowering &getTargetLowering() const { return TLI; }
80-
GISelKnownBits *getKnownBits() const { return KB; }
80+
GISelValueTracking *getValueTracking() const { return VT; }
8181

8282
LegalizerHelper(MachineFunction &MF, GISelChangeObserver &Observer,
8383
MachineIRBuilder &B);
8484
LegalizerHelper(MachineFunction &MF, const LegalizerInfo &LI,
8585
GISelChangeObserver &Observer, MachineIRBuilder &B,
86-
GISelKnownBits *KB = nullptr);
86+
GISelValueTracking *VT = nullptr);
8787

8888
/// Replace \p MI by a sequence of legal instructions that can implement the
8989
/// same operation. Note that this means \p MI may be deleted, so any iterator

llvm/include/llvm/CodeGen/GlobalISel/Utils.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class AnalysisUsage;
3131
class LostDebugLocObserver;
3232
class MachineBasicBlock;
3333
class BlockFrequencyInfo;
34-
class GISelKnownBits;
34+
class GISelValueTracking;
3535
class MachineFunction;
3636
class MachineInstr;
3737
class MachineIRBuilder;
@@ -331,7 +331,7 @@ ConstantFoldICmp(unsigned Pred, const Register Op1, const Register Op2,
331331
/// from computeKnownBits in that it doesn't necessarily determine which bit is
332332
/// set.
333333
bool isKnownToBeAPowerOfTwo(Register Val, const MachineRegisterInfo &MRI,
334-
GISelKnownBits *KnownBits = nullptr);
334+
GISelValueTracking *ValueTracking = nullptr);
335335

336336
/// Returns true if \p Val can be assumed to never be a NaN. If \p SNaN is true,
337337
/// this returns if \p Val can be assumed to never be a signaling NaN.

0 commit comments

Comments
 (0)