diff options
author | Eugene Zelenko <eugene.zelenko@gmail.com> | 2017-08-08 00:47:13 +0000 |
---|---|---|
committer | Eugene Zelenko <eugene.zelenko@gmail.com> | 2017-08-08 00:47:13 +0000 |
commit | 59e128266c9de11ba334450e1c3b7101155bd55b (patch) | |
tree | 9acc16f76a927edf4694897083f75b7a6ace9d24 /llvm/lib/Target/AMDGPU/SIFixSGPRCopies.cpp | |
parent | 7ec1a56baf4d2f30abf525a851971f671ec04d93 (diff) | |
download | bcm5719-llvm-59e128266c9de11ba334450e1c3b7101155bd55b.tar.gz bcm5719-llvm-59e128266c9de11ba334450e1c3b7101155bd55b.zip |
[AMDGPU] Fix some Clang-tidy modernize-use-using and Include What You Use warnings; other minor fixes (NFC).
llvm-svn: 310328
Diffstat (limited to 'llvm/lib/Target/AMDGPU/SIFixSGPRCopies.cpp')
-rw-r--r-- | llvm/lib/Target/AMDGPU/SIFixSGPRCopies.cpp | 51 |
1 files changed, 32 insertions, 19 deletions
diff --git a/llvm/lib/Target/AMDGPU/SIFixSGPRCopies.cpp b/llvm/lib/Target/AMDGPU/SIFixSGPRCopies.cpp index 86ad8df2a21..73a9158475e 100644 --- a/llvm/lib/Target/AMDGPU/SIFixSGPRCopies.cpp +++ b/llvm/lib/Target/AMDGPU/SIFixSGPRCopies.cpp @@ -1,4 +1,4 @@ -//===-- SIFixSGPRCopies.cpp - Remove potential VGPR => SGPR copies --------===// +//===- SIFixSGPRCopies.cpp - Remove potential VGPR => SGPR copies ---------===// // // The LLVM Compiler Infrastructure // @@ -68,14 +68,33 @@ #include "AMDGPU.h" #include "AMDGPUSubtarget.h" #include "SIInstrInfo.h" +#include "SIRegisterInfo.h" #include "llvm/ADT/DenseSet.h" +#include "llvm/ADT/STLExtras.h" +#include "llvm/ADT/SmallSet.h" +#include "llvm/ADT/SmallVector.h" +#include "llvm/CodeGen/MachineBasicBlock.h" #include "llvm/CodeGen/MachineDominators.h" +#include "llvm/CodeGen/MachineFunction.h" #include "llvm/CodeGen/MachineFunctionPass.h" +#include "llvm/CodeGen/MachineInstr.h" #include "llvm/CodeGen/MachineInstrBuilder.h" +#include "llvm/CodeGen/MachineOperand.h" #include "llvm/CodeGen/MachineRegisterInfo.h" +#include "llvm/Pass.h" +#include "llvm/Support/CodeGen.h" +#include "llvm/Support/CommandLine.h" #include "llvm/Support/Debug.h" #include "llvm/Support/raw_ostream.h" #include "llvm/Target/TargetMachine.h" +#include "llvm/Target/TargetRegisterInfo.h" +#include <cassert> +#include <cstdint> +#include <iterator> +#include <list> +#include <map> +#include <tuple> +#include <utility> using namespace llvm; @@ -89,13 +108,12 @@ static cl::opt<bool> EnableM0Merge( namespace { class SIFixSGPRCopies : public MachineFunctionPass { - MachineDominatorTree *MDT; public: static char ID; - SIFixSGPRCopies() : MachineFunctionPass(ID) { } + SIFixSGPRCopies() : MachineFunctionPass(ID) {} bool runOnMachineFunction(MachineFunction &MF) override; @@ -109,7 +127,7 @@ public: } }; -} // End anonymous namespace +} // end anonymous namespace INITIALIZE_PASS_BEGIN(SIFixSGPRCopies, DEBUG_TYPE, "SI Fix SGPR copies", false, false) @@ -117,7 +135,6 @@ INITIALIZE_PASS_DEPENDENCY(MachineDominatorTree) INITIALIZE_PASS_END(SIFixSGPRCopies, DEBUG_TYPE, "SI Fix SGPR copies", false, false) - char SIFixSGPRCopies::ID = 0; char &llvm::SIFixSGPRCopiesID = SIFixSGPRCopies::ID; @@ -287,7 +304,6 @@ static bool phiHasVGPROperands(const MachineInstr &PHI, const MachineRegisterInfo &MRI, const SIRegisterInfo *TRI, const SIInstrInfo *TII) { - for (unsigned i = 1; i < PHI.getNumOperands(); i += 2) { unsigned Reg = PHI.getOperand(i).getReg(); if (TRI->hasVGPRs(MRI.getRegClass(Reg))) @@ -295,10 +311,10 @@ static bool phiHasVGPROperands(const MachineInstr &PHI, } return false; } + static bool phiHasBreakDef(const MachineInstr &PHI, const MachineRegisterInfo &MRI, SmallSet<unsigned, 8> &Visited) { - for (unsigned i = 1; i < PHI.getNumOperands(); i += 2) { unsigned Reg = PHI.getOperand(i).getReg(); if (Visited.count(Reg)) @@ -337,7 +353,6 @@ static bool isSafeToFoldImmIntoCopy(const MachineInstr *Copy, const SIInstrInfo *TII, unsigned &SMovOp, int64_t &Imm) { - if (Copy->getOpcode() != AMDGPU::COPY) return false; @@ -371,13 +386,12 @@ template <class UnaryPredicate> bool searchPredecessors(const MachineBasicBlock *MBB, const MachineBasicBlock *CutOff, UnaryPredicate Predicate) { - if (MBB == CutOff) return false; - DenseSet<const MachineBasicBlock*> Visited; - SmallVector<MachineBasicBlock*, 4> Worklist(MBB->pred_begin(), - MBB->pred_end()); + DenseSet<const MachineBasicBlock *> Visited; + SmallVector<MachineBasicBlock *, 4> Worklist(MBB->pred_begin(), + MBB->pred_end()); while (!Worklist.empty()) { MachineBasicBlock *MBB = Worklist.pop_back_val(); @@ -433,7 +447,7 @@ static bool hoistAndMergeSGPRInits(unsigned Reg, const MachineRegisterInfo &MRI, MachineDominatorTree &MDT) { // List of inits by immediate value. - typedef std::map<unsigned, std::list<MachineInstr*>> InitListMap; + using InitListMap = std::map<unsigned, std::list<MachineInstr *>>; InitListMap Inits; // List of clobbering instructions. SmallVector<MachineInstr*, 8> Clobbers; @@ -490,9 +504,10 @@ static bool hoistAndMergeSGPRInits(unsigned Reg, MDT.properlyDominates(Clobber->getParent(), MBBTo)); }; - return (any_of(Clobbers, interferes)) || - (any_of(Inits, [&](InitListMap::value_type &C) { - return C.first != Init.first && any_of(C.second, interferes); + return (llvm::any_of(Clobbers, interferes)) || + (llvm::any_of(Inits, [&](InitListMap::value_type &C) { + return C.first != Init.first && + llvm::any_of(C.second, interferes); })); }; @@ -558,7 +573,6 @@ bool SIFixSGPRCopies::runOnMachineFunction(MachineFunction &MF) { for (MachineFunction::iterator BI = MF.begin(), BE = MF.end(); BI != BE; ++BI) { - MachineBasicBlock &MBB = *BI; for (MachineBasicBlock::iterator I = MBB.begin(), E = MBB.end(); I != E; ++I) { @@ -661,7 +675,7 @@ bool SIFixSGPRCopies::runOnMachineFunction(MachineFunction &MF) { } break; } - case AMDGPU::REG_SEQUENCE: { + case AMDGPU::REG_SEQUENCE: if (TRI->hasVGPRs(TII->getOpRegClass(MI, 0)) || !hasVGPROperands(MI, TRI)) { foldVGPRCopyIntoRegSequence(MI, TRI, TII, MRI); @@ -672,7 +686,6 @@ bool SIFixSGPRCopies::runOnMachineFunction(MachineFunction &MF) { TII->moveToVALU(MI); break; - } case AMDGPU::INSERT_SUBREG: { const TargetRegisterClass *DstRC, *Src0RC, *Src1RC; DstRC = MRI.getRegClass(MI.getOperand(0).getReg()); |