Skip to content

Commit 84d8dd8

Browse files
committed
Additional cleanup + format
1 parent 0600e2f commit 84d8dd8

File tree

6 files changed

+100
-64
lines changed

6 files changed

+100
-64
lines changed

llvm/include/llvm/CodeGen/TargetRegisterInfo.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -436,7 +436,7 @@ class TargetRegisterInfo : public MCRegisterInfo {
436436
/// \returns an empty set if there is no set of covering sub registers.
437437
std::vector<unsigned>
438438
getMinimalSpanningSubRegIdxSetForLaneMask(const TargetRegisterClass *RC,
439-
LaneBitmask mask) const;
439+
LaneBitmask Mask) const;
440440

441441
/// The lane masks returned by getSubRegIndexLaneMask() above can only be
442442
/// used to determine if sub-registers overlap - they can't be used to

llvm/lib/CodeGen/TargetRegisterInfo.cpp

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -730,14 +730,14 @@ void TargetRegisterInfo::dumpReg(Register Reg, unsigned SubRegIndex,
730730

731731
std::vector<unsigned>
732732
TargetRegisterInfo::getMinimalSpanningSubRegIdxSetForLaneMask(
733-
const TargetRegisterClass *RC, LaneBitmask mask) const {
733+
const TargetRegisterClass *RC, LaneBitmask Mask) const {
734734
// TODO: this could replace the code it was copied from in SplitKit.cpp
735735

736736
// First pass: Try to find a perfectly matching subregister index.
737737
// If none exists find the one covering the most lanemask bits.
738738
SmallVector<unsigned, 8> PossibleIndexes;
739739
unsigned BestIdx = 0;
740-
const LaneBitmask avoid = ~mask;
740+
const LaneBitmask Avoid = ~Mask;
741741
{
742742
unsigned BestCover = 0;
743743
for (unsigned Idx = 1, E = getNumSubRegIndices(); Idx < E; ++Idx) {
@@ -746,13 +746,13 @@ TargetRegisterInfo::getMinimalSpanningSubRegIdxSetForLaneMask(
746746
continue;
747747
LaneBitmask SubRegMask = getSubRegIndexLaneMask(Idx);
748748
// Early exit if we found a perfect match.
749-
if (SubRegMask == mask) {
749+
if (SubRegMask == Mask) {
750750
BestIdx = Idx;
751751
break;
752752
}
753753

754754
// The index must not cover any lanes outside
755-
if ((SubRegMask & avoid).any())
755+
if ((SubRegMask & Avoid).any())
756756
continue;
757757

758758
unsigned PopCount = SubRegMask.getNumLanes();
@@ -767,36 +767,36 @@ TargetRegisterInfo::getMinimalSpanningSubRegIdxSetForLaneMask(
767767
// Abort if we cannot possibly implement the COPY with the given indexes.
768768
if (BestIdx == 0) {
769769
LLVM_DEBUG(dbgs() << "Unable to find minimal spanning sub register(s) for "
770-
<< getRegClassName(RC) << " mask " << PrintLaneMask(mask)
770+
<< getRegClassName(RC) << " mask " << PrintLaneMask(Mask)
771771
<< '\n');
772772
assert(false && "Impossible to span reg class");
773773
return std::vector<unsigned>();
774774
}
775775

776-
std::vector<unsigned> result;
777-
result.push_back(BestIdx);
776+
std::vector<unsigned> Result;
777+
Result.push_back(BestIdx);
778778

779779
// Greedy heuristic: Keep iterating keeping the best covering subreg index
780780
// each time.
781-
mask &= ~(getSubRegIndexLaneMask(BestIdx));
782-
while (mask.any()) {
781+
Mask &= ~(getSubRegIndexLaneMask(BestIdx));
782+
while (Mask.any()) {
783783
BestIdx = 0;
784784
int BestCover = std::numeric_limits<int>::min();
785785
for (unsigned Idx : PossibleIndexes) {
786786
LaneBitmask SubRegMask = getSubRegIndexLaneMask(Idx);
787787
// Early exit if we found a perfect match.
788-
if (SubRegMask == mask) {
788+
if (SubRegMask == Mask) {
789789
BestIdx = Idx;
790790
break;
791791
}
792792

793793
// Guaranteed above
794-
assert((SubRegMask & avoid).none());
794+
assert((SubRegMask & Avoid).none());
795795

796796
// Try to cover as much of the remaining lanes as possible but as few of
797797
// the already covered lanes as possible.
798-
int Cover = (SubRegMask & mask).getNumLanes() -
799-
(SubRegMask & ~mask).getNumLanes();
798+
int Cover = (SubRegMask & Mask).getNumLanes() -
799+
(SubRegMask & ~Mask).getNumLanes();
800800
if (Cover > BestCover) {
801801
BestCover = Cover;
802802
BestIdx = Idx;
@@ -805,16 +805,16 @@ TargetRegisterInfo::getMinimalSpanningSubRegIdxSetForLaneMask(
805805

806806
if (BestIdx == 0) {
807807
LLVM_DEBUG(dbgs() << "Unable to find minimal spanning sub register(s) for "
808-
<< getRegClassName(RC) << " mask " << PrintLaneMask(mask)
808+
<< getRegClassName(RC) << " mask " << PrintLaneMask(Mask)
809809
<< '\n');
810810
assert(false && "Impossible to span reg class");
811811
return std::vector<unsigned>();
812812
}
813813

814-
result.push_back(BestIdx);
815-
mask &= ~getSubRegIndexLaneMask(BestIdx);
814+
Result.push_back(BestIdx);
815+
Mask &= ~getSubRegIndexLaneMask(BestIdx);
816816
}
817817

818-
return result;
818+
return Result;
819819
}
820820

llvm/lib/Target/AMDGPU/AMDGPUHotBlockRematerialize.cpp

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3287,7 +3287,8 @@ void sortSubExpCandidates(std::vector<SubExp> &SubExpCandidates) {
32873287
MapVector<SubExp *, SortNode> SortMap;
32883288
for (auto It : InputMap) {
32893289
unsigned Reg = It.first;
3290-
MapVector<Register, SetVector<SubExp *>>::iterator OutIt = OutputMap.find(Reg);
3290+
MapVector<Register, SetVector<SubExp *>>::iterator OutIt =
3291+
OutputMap.find(Reg);
32913292
if (OutIt == OutputMap.end())
32923293
continue;
32933294
auto &InExps = It.second;
@@ -3622,8 +3623,7 @@ collectPassThrus(MachineBasicBlock *MBB,
36223623
return PassThrus;
36233624
}
36243625
// Try to build a free subExp which all input is passThrus.
3625-
SubExp buildFreeSubExp(SubExp &Exp,
3626-
GCNRPTracker::LiveRegSet &PassThrus,
3626+
SubExp buildFreeSubExp(SubExp &Exp, GCNRPTracker::LiveRegSet &PassThrus,
36273627
MachineRegisterInfo &MRI, const SIRegisterInfo *SIRI) {
36283628
SubExp FreeExp;
36293629
// Try to split the subExp to find a help case.
@@ -3777,8 +3777,7 @@ std::vector<SubExp> buildSubExpCandidates(
37773777
}
37783778
if (!canHelpPressureWhenSink(Exp, PassThrus, MRI, SIRI, MLI, DT,
37793779
IsCanClone, IsSgprBound)) {
3780-
if (AllowPartialUseInSubExp &&
3781-
Exp.isSafeToMove(MRI)) {
3780+
if (AllowPartialUseInSubExp && Exp.isSafeToMove(MRI)) {
37823781
SubExp FreeSubExp = buildFreeSubExp(Exp, PassThrus, MRI, SIRI);
37833782
if (canHelpPressureWhenSink(FreeSubExp, PassThrus, MRI, SIRI, MLI, DT,
37843783
IsCanClone, IsSgprBound)) {
@@ -4249,9 +4248,8 @@ bool perBlockPassthruRemat(Remat *Remat, std::vector<HotBlock> &HotBlocks,
42494248
continue;
42504249

42514250
// Collect pass thru regs.
4252-
GCNRPTracker::LiveRegSet PassThrus =
4253-
collectPassThrus(MBB, InputLive, OutputLive,
4254-
LiveRegCandidates, MRI, IsCanClone);
4251+
GCNRPTracker::LiveRegSet PassThrus = collectPassThrus(
4252+
MBB, InputLive, OutputLive, LiveRegCandidates, MRI, IsCanClone);
42554253

42564254
// Group pass thru regs by def MBB.
42574255
SmallVector<std::pair<MachineBasicBlock *, GCNRPTracker::LiveRegSet>>

llvm/lib/Target/AMDGPU/AMDGPUMIRUtils.cpp

Lines changed: 40 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
//===------- AMDGPUMIRUtils.cpp - Helpers for MIR passes ------------------===//
2+
//
3+
// The LLVM Compiler Infrastructure
4+
//
5+
// This file is distributed under the University of Illinois Open Source
6+
// License. See LICENSE.TXT for details.
7+
//
8+
//===----------------------------------------------------------------------===//
9+
//
10+
/// \file
11+
/// \brief Helper functions for MIR passes.
12+
//
13+
//===----------------------------------------------------------------------===//
14+
115
#include "SIInstrInfo.h"
216
#include "SIMachineFunctionInfo.h"
317
#include "SIRegisterInfo.h"
@@ -383,8 +397,9 @@ struct Piece {
383397
}
384398
};
385399

386-
static void updateSubReg(MachineOperand &UseMO, const llvm::TargetRegisterClass *NewRC,
387-
unsigned Offset, const SIRegisterInfo *SIRI) {
400+
static void updateSubReg(MachineOperand &UseMO,
401+
const llvm::TargetRegisterClass *NewRC,
402+
unsigned Offset, const SIRegisterInfo *SIRI) {
388403
unsigned Size = NewRC->getLaneMask().getNumLanes();
389404
if (Size == 1) {
390405
UseMO.setSubReg(0);
@@ -529,21 +544,23 @@ bool removeUnusedLanes(llvm::MachineInstr &MI, MachineRegisterInfo &MRI,
529544
case 1:
530545
return reduceChannel(Piece.Offset, MI,
531546
SIII->get(IsImm ? AMDGPU::S_BUFFER_LOAD_DWORD_IMM
532-
: AMDGPU::S_BUFFER_LOAD_DWORD_SGPR),
547+
: AMDGPU::S_BUFFER_LOAD_DWORD_SGPR),
533548
MRI, SIRI, SIII, SlotIndexes);
534549
case 2:
535550
return reduceChannel(Piece.Offset, MI,
536-
SIII->get(IsImm ? AMDGPU::S_BUFFER_LOAD_DWORDX2_IMM
537-
: AMDGPU::S_BUFFER_LOAD_DWORDX2_SGPR),
551+
SIII->get(IsImm
552+
? AMDGPU::S_BUFFER_LOAD_DWORDX2_IMM
553+
: AMDGPU::S_BUFFER_LOAD_DWORDX2_SGPR),
538554
MRI, SIRI, SIII, SlotIndexes);
539555
case 3:
540556
if (FullMask == 0xf)
541557
return false;
542558
LLVM_FALLTHROUGH;
543559
case 4:
544560
return reduceChannel(Piece.Offset, MI,
545-
SIII->get(IsImm ? AMDGPU::S_BUFFER_LOAD_DWORDX4_IMM
546-
: AMDGPU::S_BUFFER_LOAD_DWORDX4_SGPR),
561+
SIII->get(IsImm
562+
? AMDGPU::S_BUFFER_LOAD_DWORDX4_IMM
563+
: AMDGPU::S_BUFFER_LOAD_DWORDX4_SGPR),
547564
MRI, SIRI, SIII, SlotIndexes);
548565
case 5:
549566
case 6:
@@ -553,8 +570,9 @@ bool removeUnusedLanes(llvm::MachineInstr &MI, MachineRegisterInfo &MRI,
553570
LLVM_FALLTHROUGH;
554571
case 8:
555572
return reduceChannel(Piece.Offset, MI,
556-
SIII->get(IsImm ? AMDGPU::S_BUFFER_LOAD_DWORDX8_IMM
557-
: AMDGPU::S_BUFFER_LOAD_DWORDX8_SGPR),
573+
SIII->get(IsImm
574+
? AMDGPU::S_BUFFER_LOAD_DWORDX8_IMM
575+
: AMDGPU::S_BUFFER_LOAD_DWORDX8_SGPR),
558576
MRI, SIRI, SIII, SlotIndexes);
559577
}
560578

@@ -751,19 +769,19 @@ unsigned get_reg_size(unsigned Reg, const MachineRegisterInfo &MRI,
751769
void write_live(unsigned Reg, LaneBitmask Mask, const MachineRegisterInfo &MRI,
752770
const SIRegisterInfo *SIRI, raw_ostream &OS) {
753771
if (Mask.none()) {
754-
unsigned size = get_reg_size(Reg, MRI, SIRI);
755-
Mask = LaneBitmask((1 << size) - 1);
772+
unsigned Size = get_reg_size(Reg, MRI, SIRI);
773+
Mask = LaneBitmask((1 << Size) - 1);
756774
}
757-
unsigned mask = Mask.getAsInteger();
775+
unsigned IntMask = Mask.getAsInteger();
758776
for (unsigned i = 0; i <= Mask.getHighestLane(); i++) {
759-
if (mask & (1 << i)) {
777+
if (IntMask & (1 << i)) {
760778
write_reg(Reg, i, MRI, SIRI, OS);
761779
OS << ",\n";
762780
}
763781
}
764782
}
765783

766-
void write_dag_input_node(unsigned ID, unsigned reg, unsigned mask,
784+
void write_dag_input_node(unsigned ID, unsigned Reg, unsigned Mask,
767785
const MachineRegisterInfo &MRI,
768786
const SIRegisterInfo *SIRI, raw_ostream &OS) {
769787
OS << "{";
@@ -773,13 +791,13 @@ void write_dag_input_node(unsigned ID, unsigned reg, unsigned mask,
773791

774792
OS << ",";
775793

776-
auto WriteReg = [&reg, &MRI, &SIRI, &OS]() { print_reg(reg, MRI, SIRI, OS); };
794+
auto WriteReg = [&Reg, &MRI, &SIRI, &OS]() { print_reg(Reg, MRI, SIRI, OS); };
777795

778796
json_pair("reg", WriteReg, OS);
779797

780798
OS << ",";
781799

782-
auto WriteMask = [&mask, &OS]() { OS << mask; };
800+
auto WriteMask = [&Mask, &OS]() { OS << Mask; };
783801

784802
json_pair("mask", WriteMask, OS);
785803

@@ -1220,8 +1238,8 @@ void write_file(const MDNode *FileNode, raw_ostream &OS) {
12201238
OS << ",\n";
12211239

12221240
const MDString *Content = cast<MDString>(FileNode->getOperand(1).get());
1223-
std::string str = get_legal_str(Content);
1224-
auto WriteContent = [&str, &OS]() { OS << str; };
1241+
std::string Str = get_legal_str(Content);
1242+
auto WriteContent = [&Str, &OS]() { OS << Str; };
12251243
json_pair("content", WriteContent, OS);
12261244
OS << "\n},\n";
12271245
}
@@ -1468,8 +1486,7 @@ void write_function(MachineFunction &MF, LiveIntervals *LIS,
14681486
// Check debug info.
14691487
const Function &F = MF.getFunction();
14701488
const Module *M = F.getParent();
1471-
const NamedMDNode *SourceMD =
1472-
M->getNamedMetadata("dx.source.contents");
1489+
const NamedMDNode *SourceMD = M->getNamedMetadata("dx.source.contents");
14731490
if (SourceMD) {
14741491
write_dbg_info(MF, LIS, MRI, SIII, SIRI, SlotIndexes, SourceMD, OS);
14751492
}
@@ -1530,7 +1547,8 @@ class ContributionList {
15301547

15311548
void buildMIContribution(MachineInstr &MI,
15321549
DenseSet<MachineInstr *> &ContributorSet,
1533-
DenseSet<MachineInstr *> &ContributedSet, MachineRegisterInfo &MRI) {
1550+
DenseSet<MachineInstr *> &ContributedSet,
1551+
MachineRegisterInfo &MRI) {
15341552
for (MachineOperand &UseMO : MI.uses()) {
15351553
if (!UseMO.isReg())
15361554
continue;
@@ -1938,8 +1956,7 @@ MachineBasicBlock::iterator llvm::findOrCreateInsertionPointForSccDef(
19381956
// MI
19391957
// S_CMP_LG_U32 %SavedSCC, 0 # Restore SCC
19401958
//
1941-
Register TmpScc =
1942-
MRI->createVirtualRegister(&AMDGPU::SReg_32_XM0RegClass);
1959+
Register TmpScc = MRI->createVirtualRegister(&AMDGPU::SReg_32_XM0RegClass);
19431960
DebugLoc DL = MI->getDebugLoc();
19441961
BuildMI(*MBB, MI, DL, TII->get(AMDGPU::S_CSELECT_B32), TmpScc)
19451962
.addImm(-1)

llvm/lib/Target/AMDGPU/AMDGPUMIRUtils.h

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,20 @@
1+
//===------- AMDGPUMIRUtils.h - Helpers for MIR passes --------------------===//
2+
//
3+
// The LLVM Compiler Infrastructure
4+
//
5+
// This file is distributed under the University of Illinois Open Source
6+
// License. See LICENSE.TXT for details.
7+
//
8+
//===----------------------------------------------------------------------===//
9+
//
10+
/// \file
11+
/// \brief Helper functions for MIR passes.
12+
//
13+
//===----------------------------------------------------------------------===//
14+
115
#ifndef LLVM_LIB_TARGET_AMDGPU_AMDGPUMIRUTILS_H
216
#define LLVM_LIB_TARGET_AMDGPU_AMDGPUMIRUTILS_H
317

4-
#pragma once
5-
618
#include "llvm/ADT/DenseMap.h"
719
#include "llvm/ADT/DenseSet.h"
820
#include "llvm/CodeGen/MachineBasicBlock.h"
@@ -51,9 +63,9 @@ bool isSub0Sub1SingleDef(unsigned Reg, const llvm::MachineRegisterInfo &MRI);
5163

5264
llvm::LaneBitmask getRegMask(const llvm::MachineOperand &MO,
5365
const llvm::MachineRegisterInfo &MRI);
54-
void andLiveRegSet(LiveSet &targetSet, const LiveSet &inputSet);
55-
void andNotLiveRegSet(LiveSet &targetSet, const LiveSet &inputSet);
56-
void mergeLiveRegSet(LiveSet &targetSet, const LiveSet &inputSet);
66+
void andLiveRegSet(LiveSet &TargetSet, const LiveSet &InputSet);
67+
void andNotLiveRegSet(LiveSet &TargetSet, const LiveSet &InputSet);
68+
void mergeLiveRegSet(LiveSet &TargetSet, const LiveSet &InputSet);
5769
llvm::MachineBasicBlock *split(llvm::MachineInstr *I);
5870

5971
// For inst like S_BUFFER_LOAD_DWORDX16, change to S_BUFFER_LOAD_DWORDX4 if only
@@ -71,9 +83,6 @@ bool reach_block(llvm::MachineBasicBlock *FromBB,
7183
void viewCFGWithPhi(llvm::MachineFunction &MF);
7284
void write_contribution_list(llvm::MachineFunction &MF, const char *Filename);
7385

74-
llvm::MachineBasicBlock *createNullExportBlock(llvm::MachineFunction &MF,
75-
const llvm::SIInstrInfo *TII);
76-
7786
bool getNonDebugMBBEnd(llvm::MachineBasicBlock::reverse_iterator &BBEnd,
7887
llvm::MachineBasicBlock &MBB);
7988

@@ -128,7 +137,7 @@ llvm::MachineBasicBlock::iterator findOrCreateInsertionPointForSccDef(
128137
// local.
129138
bool isLocalLiveInterval(
130139
const llvm::LiveInterval &LI, llvm::SlotIndexes *Indexes,
131-
llvm::SmallDenseSet<llvm::MachineBasicBlock *, 2> &touchedMBBSet);
140+
llvm::SmallDenseSet<llvm::MachineBasicBlock *, 2> &TouchedMBBSet);
132141
bool isLocalLiveInterval(const llvm::LiveInterval &LI,
133142
llvm::SlotIndexes *Indexes);
134143

@@ -149,13 +158,12 @@ bool isFastMathInst(llvm::MachineInstr &MI);
149158

150159
namespace pressure {
151160
void print_reg(llvm::Register Reg, const llvm::MachineRegisterInfo &MRI,
152-
const llvm::SIRegisterInfo *SIRI, llvm::raw_ostream &os);
161+
const llvm::SIRegisterInfo *SIRI, llvm::raw_ostream &OS);
153162
void write_pressure(llvm::MachineFunction &MF, llvm::LiveIntervals *LIS,
154163
const char *Filename);
155164
void write_pressure(llvm::MachineFunction &MF, llvm::LiveIntervals *LIS,
156-
llvm::raw_ostream &os);
165+
llvm::raw_ostream &OS);
157166
} // namespace pressure
158-
// bool IsLdsSpillSupportedForHwStage(xmd::HwStage Stage);
159167

160168
// Look for the successor `Succ` of the given `MBB`.
161169
// Returns MBB->succ_end() if `Succ` is not a successor of MBB.

0 commit comments

Comments
 (0)