From 71d5a2540a98c81f5bcaeb48805e0e2881f530ef Mon Sep 17 00:00:00 2001 From: Dimitry Andric Date: Sun, 16 Apr 2017 16:01:22 +0000 Subject: Vendor import of llvm trunk r300422: https://llvm.org/svn/llvm-project/llvm/trunk@300422 --- lib/Target/AMDGPU/R600ControlFlowFinalizer.cpp | 48 ++++++++++++++++---------- 1 file changed, 30 insertions(+), 18 deletions(-) (limited to 'lib/Target/AMDGPU/R600ControlFlowFinalizer.cpp') diff --git a/lib/Target/AMDGPU/R600ControlFlowFinalizer.cpp b/lib/Target/AMDGPU/R600ControlFlowFinalizer.cpp index 45b36d3d3ebb..811b905588b4 100644 --- a/lib/Target/AMDGPU/R600ControlFlowFinalizer.cpp +++ b/lib/Target/AMDGPU/R600ControlFlowFinalizer.cpp @@ -19,10 +19,26 @@ #include "R600InstrInfo.h" #include "R600MachineFunctionInfo.h" #include "R600RegisterInfo.h" +#include "llvm/ADT/SmallVector.h" +#include "llvm/ADT/STLExtras.h" +#include "llvm/ADT/StringRef.h" +#include "llvm/CodeGen/MachineBasicBlock.h" +#include "llvm/CodeGen/MachineFunction.h" #include "llvm/CodeGen/MachineFunctionPass.h" +#include "llvm/CodeGen/MachineInstr.h" #include "llvm/CodeGen/MachineInstrBuilder.h" -#include "llvm/CodeGen/MachineRegisterInfo.h" +#include "llvm/CodeGen/MachineOperand.h" +#include "llvm/IR/CallingConv.h" +#include "llvm/IR/DebugLoc.h" +#include "llvm/Support/MathExtras.h" #include "llvm/Support/raw_ostream.h" +#include +#include +#include +#include +#include +#include +#include using namespace llvm; @@ -43,13 +59,12 @@ struct CFStack { std::vector BranchStack; std::vector LoopStack; unsigned MaxStackSize; - unsigned CurrentEntries; - unsigned CurrentSubEntries; + unsigned CurrentEntries = 0; + unsigned CurrentSubEntries = 0; CFStack(const R600Subtarget *st, CallingConv::ID cc) : ST(st), // We need to reserve a stack entry for CALL_FS in vertex shaders. - MaxStackSize(cc == CallingConv::AMDGPU_VS ? 1 : 0), - CurrentEntries(0), CurrentSubEntries(0) { } + MaxStackSize(cc == CallingConv::AMDGPU_VS ? 1 : 0) {} unsigned getLoopDepth(); bool branchStackContains(CFStack::StackItem); @@ -198,9 +213,8 @@ void CFStack::popLoop() { } class R600ControlFlowFinalizer : public MachineFunctionPass { - private: - typedef std::pair > ClauseFile; + typedef std::pair> ClauseFile; enum ControlFlowInstruction { CF_TC, @@ -217,10 +231,10 @@ private: }; static char ID; - const R600InstrInfo *TII; - const R600RegisterInfo *TRI; + const R600InstrInfo *TII = nullptr; + const R600RegisterInfo *TRI = nullptr; unsigned MaxFetchInst; - const R600Subtarget *ST; + const R600Subtarget *ST = nullptr; bool IsTrivialInst(MachineInstr &MI) const { switch (MI.getOpcode()) { @@ -355,7 +369,7 @@ private: continue; int64_t Imm = Src.second; std::vector::iterator It = - find_if(Lits, [&](MachineOperand *val) { + llvm::find_if(Lits, [&](MachineOperand *val) { return val->isImm() && (val->getImm() == Imm); }); @@ -485,8 +499,7 @@ private: } public: - R600ControlFlowFinalizer(TargetMachine &tm) - : MachineFunctionPass(ID), TII(nullptr), TRI(nullptr), ST(nullptr) {} + R600ControlFlowFinalizer(TargetMachine &tm) : MachineFunctionPass(ID) {} bool runOnMachineFunction(MachineFunction &MF) override { ST = &MF.getSubtarget(); @@ -501,7 +514,7 @@ public: ++MB) { MachineBasicBlock &MBB = *MB; unsigned CfCount = 0; - std::vector > > LoopStack; + std::vector>> LoopStack; std::vector IfThenElseStack; if (MF.getFunction()->getCallingConv() == CallingConv::AMDGPU_VS) { BuildMI(MBB, MBB.begin(), MBB.findDebugLoc(MBB.begin()), @@ -554,7 +567,7 @@ public: MachineInstr *MIb = BuildMI(MBB, MI, MBB.findDebugLoc(MI), getHWInstrDesc(CF_WHILE_LOOP)) .addImm(1); - std::pair > Pair(CfCount, + std::pair> Pair(CfCount, std::set()); Pair.second.insert(MIb); LoopStack.push_back(std::move(Pair)); @@ -564,7 +577,7 @@ public: } case AMDGPU::ENDLOOP: { CFStack.popLoop(); - std::pair > Pair = + std::pair> Pair = std::move(LoopStack.back()); LoopStack.pop_back(); CounterPropagateAddr(Pair.second, CfCount); @@ -693,7 +706,6 @@ char R600ControlFlowFinalizer::ID = 0; } // end anonymous namespace - -llvm::FunctionPass *llvm::createR600ControlFlowFinalizer(TargetMachine &TM) { +FunctionPass *llvm::createR600ControlFlowFinalizer(TargetMachine &TM) { return new R600ControlFlowFinalizer(TM); } -- cgit v1.2.3