Index: llvm/trunk/include/llvm/CodeGen/PBQP/Graph.h =================================================================== --- llvm/trunk/include/llvm/CodeGen/PBQP/Graph.h +++ llvm/trunk/include/llvm/CodeGen/PBQP/Graph.h @@ -110,13 +110,6 @@ ThisEdgeAdjIdxs[1] = NodeEntry::getInvalidAdjEdgeIdx(); } - void invalidate() { - NIds[0] = NIds[1] = Graph::invalidNodeId(); - ThisEdgeAdjIdxs[0] = ThisEdgeAdjIdxs[1] = - NodeEntry::getInvalidAdjEdgeIdx(); - Costs = nullptr; - } - void connectToN(Graph &G, EdgeId ThisEdgeId, unsigned NIdx) { assert(ThisEdgeAdjIdxs[NIdx] == NodeEntry::getInvalidAdjEdgeIdx() && "Edge already connected to NIds[NIdx]."); @@ -124,15 +117,6 @@ ThisEdgeAdjIdxs[NIdx] = N.addAdjEdgeId(ThisEdgeId); } - void connectTo(Graph &G, EdgeId ThisEdgeId, NodeId NId) { - if (NId == NIds[0]) - connectToN(G, ThisEdgeId, 0); - else { - assert(NId == NIds[1] && "Edge does not connect NId."); - connectToN(G, ThisEdgeId, 1); - } - } - void connect(Graph &G, EdgeId ThisEdgeId) { connectToN(G, ThisEdgeId, 0); connectToN(G, ThisEdgeId, 1); Index: llvm/trunk/include/llvm/CodeGen/PBQP/Math.h =================================================================== --- llvm/trunk/include/llvm/CodeGen/PBQP/Math.h +++ llvm/trunk/include/llvm/CodeGen/PBQP/Math.h @@ -27,25 +27,17 @@ /// \brief Construct a PBQP vector of the given size. explicit Vector(unsigned Length) - : Length(Length), Data(new PBQPNum[Length]) { - // llvm::dbgs() << "Constructing PBQP::Vector " - // << this << " (length " << Length << ")\n"; - } + : Length(Length), Data(new PBQPNum[Length]) {} /// \brief Construct a PBQP vector with initializer. Vector(unsigned Length, PBQPNum InitVal) : Length(Length), Data(new PBQPNum[Length]) { - // llvm::dbgs() << "Constructing PBQP::Vector " - // << this << " (length " << Length << ", fill " - // << InitVal << ")\n"; std::fill(Data, Data + Length, InitVal); } /// \brief Copy construct a PBQP vector. Vector(const Vector &V) : Length(V.Length), Data(new PBQPNum[Length]) { - // llvm::dbgs() << "Copy-constructing PBQP::Vector " << this - // << " from PBQP::Vector " << &V << "\n"; std::copy(V.Data, V.Data + Length, Data); } @@ -57,31 +49,7 @@ } /// \brief Destroy this vector, return its memory. - ~Vector() { - // llvm::dbgs() << "Deleting PBQP::Vector " << this << "\n"; - delete[] Data; - } - - /// \brief Copy-assignment operator. - Vector& operator=(const Vector &V) { - // llvm::dbgs() << "Assigning to PBQP::Vector " << this - // << " from PBQP::Vector " << &V << "\n"; - delete[] Data; - Length = V.Length; - Data = new PBQPNum[Length]; - std::copy(V.Data, V.Data + Length, Data); - return *this; - } - - /// \brief Move-assignment operator. - Vector& operator=(Vector &&V) { - delete[] Data; - Length = V.Length; - Data = V.Data; - V.Length = 0; - V.Data = nullptr; - return *this; - } + ~Vector() { delete[] Data; } /// \brief Comparison operator. bool operator==(const Vector &V) const { @@ -119,14 +87,6 @@ return *this; } - /// \brief Subtract another vector from this one. - Vector& operator-=(const Vector &V) { - assert(Length != 0 && Data != nullptr && "Invalid vector"); - assert(Length == V.Length && "Vector length mismatch."); - std::transform(Data, Data + Length, V.Data, Data, std::minus()); - return *this; - } - /// \brief Returns the index of the minimum value in this vector unsigned minIndex() const { assert(Length != 0 && Data != nullptr && "Invalid vector"); @@ -193,26 +153,6 @@ /// \brief Destroy this matrix, return its memory. ~Matrix() { delete[] Data; } - /// \brief Copy-assignment operator. - Matrix& operator=(const Matrix &M) { - delete[] Data; - Rows = M.Rows; Cols = M.Cols; - Data = new PBQPNum[Rows * Cols]; - std::copy(M.Data, M.Data + (Rows * Cols), Data); - return *this; - } - - /// \brief Move-assignment operator. - Matrix& operator=(Matrix &&M) { - delete[] Data; - Rows = M.Rows; - Cols = M.Cols; - Data = M.Data; - M.Rows = M.Cols = 0; - M.Data = nullptr; - return *this; - } - /// \brief Comparison operator. bool operator==(const Matrix &M) const { assert(Rows != 0 && Cols != 0 && Data != nullptr && "Invalid matrix"); @@ -265,30 +205,6 @@ return V; } - /// \brief Reset the matrix to the given value. - Matrix& reset(PBQPNum Val = 0) { - assert(Rows != 0 && Cols != 0 && Data != nullptr && "Invalid matrix"); - std::fill(Data, Data + (Rows * Cols), Val); - return *this; - } - - /// \brief Set a single row of this matrix to the given value. - Matrix& setRow(unsigned R, PBQPNum Val) { - assert(Rows != 0 && Cols != 0 && Data != nullptr && "Invalid matrix"); - assert(R < Rows && "Row out of bounds."); - std::fill(Data + (R * Cols), Data + ((R + 1) * Cols), Val); - return *this; - } - - /// \brief Set a single column of this matrix to the given value. - Matrix& setCol(unsigned C, PBQPNum Val) { - assert(Rows != 0 && Cols != 0 && Data != nullptr && "Invalid matrix"); - assert(C < Cols && "Column out of bounds."); - for (unsigned R = 0; R < Rows; ++R) - (*this)[R][C] = Val; - return *this; - } - /// \brief Matrix transpose. Matrix transpose() const { assert(Rows != 0 && Cols != 0 && Data != nullptr && "Invalid matrix"); @@ -299,18 +215,6 @@ return M; } - /// \brief Returns the diagonal of the matrix as a vector. - /// - /// Matrix must be square. - Vector diagonalize() const { - assert(Rows != 0 && Cols != 0 && Data != nullptr && "Invalid matrix"); - assert(Rows == Cols && "Attempt to diagonalize non-square matrix."); - Vector V(Rows); - for (unsigned r = 0; r < Rows; ++r) - V[r] = (*this)[r][r]; - return V; - } - /// \brief Add the given matrix to this one. Matrix& operator+=(const Matrix &M) { assert(Rows != 0 && Cols != 0 && Data != nullptr && "Invalid matrix"); @@ -328,49 +232,6 @@ return Tmp; } - /// \brief Returns the minimum of the given row - PBQPNum getRowMin(unsigned R) const { - assert(Rows != 0 && Cols != 0 && Data != nullptr && "Invalid matrix"); - assert(R < Rows && "Row out of bounds"); - return *std::min_element(Data + (R * Cols), Data + ((R + 1) * Cols)); - } - - /// \brief Returns the minimum of the given column - PBQPNum getColMin(unsigned C) const { - assert(Rows != 0 && Cols != 0 && Data != nullptr && "Invalid matrix"); - PBQPNum MinElem = (*this)[0][C]; - for (unsigned R = 1; R < Rows; ++R) - if ((*this)[R][C] < MinElem) - MinElem = (*this)[R][C]; - return MinElem; - } - - /// \brief Subtracts the given scalar from the elements of the given row. - Matrix& subFromRow(unsigned R, PBQPNum Val) { - assert(Rows != 0 && Cols != 0 && Data != nullptr && "Invalid matrix"); - assert(R < Rows && "Row out of bounds"); - std::transform(Data + (R * Cols), Data + ((R + 1) * Cols), - Data + (R * Cols), - std::bind2nd(std::minus(), Val)); - return *this; - } - - /// \brief Subtracts the given scalar from the elements of the given column. - Matrix& subFromCol(unsigned C, PBQPNum Val) { - assert(Rows != 0 && Cols != 0 && Data != nullptr && "Invalid matrix"); - for (unsigned R = 0; R < Rows; ++R) - (*this)[R][C] -= Val; - return *this; - } - - /// \brief Returns true if this is a zero matrix. - bool isZero() const { - assert(Rows != 0 && Cols != 0 && Data != nullptr && "Invalid matrix"); - return find_if(Data, Data + (Rows * Cols), - std::bind2nd(std::not_equal_to(), 0)) == - Data + (Rows * Cols); - } - private: unsigned Rows, Cols; PBQPNum *Data; Index: llvm/trunk/include/llvm/CodeGen/PBQP/Solution.h =================================================================== --- llvm/trunk/include/llvm/CodeGen/PBQP/Solution.h +++ llvm/trunk/include/llvm/CodeGen/PBQP/Solution.h @@ -38,38 +38,6 @@ Solution() : r0Reductions(0), r1Reductions(0), r2Reductions(0), rNReductions(0) {} - /// \brief Number of nodes for which selections have been made. - /// @return Number of nodes for which selections have been made. - unsigned numNodes() const { return selections.size(); } - - /// \brief Records a reduction via the R0 rule. Should be called from the - /// solver only. - void recordR0() { ++r0Reductions; } - - /// \brief Returns the number of R0 reductions applied to solve the problem. - unsigned numR0Reductions() const { return r0Reductions; } - - /// \brief Records a reduction via the R1 rule. Should be called from the - /// solver only. - void recordR1() { ++r1Reductions; } - - /// \brief Returns the number of R1 reductions applied to solve the problem. - unsigned numR1Reductions() const { return r1Reductions; } - - /// \brief Records a reduction via the R2 rule. Should be called from the - /// solver only. - void recordR2() { ++r2Reductions; } - - /// \brief Returns the number of R2 reductions applied to solve the problem. - unsigned numR2Reductions() const { return r2Reductions; } - - /// \brief Records a reduction via the RN rule. Should be called from the - /// solver only. - void recordRN() { ++ rNReductions; } - - /// \brief Returns the number of RN reductions applied to solve the problem. - unsigned numRNReductions() const { return rNReductions; } - /// \brief Set the selection for a given node. /// @param nodeId Node id. /// @param selection Selection for nodeId. Index: llvm/trunk/include/llvm/CodeGen/RegAllocPBQP.h =================================================================== --- llvm/trunk/include/llvm/CodeGen/RegAllocPBQP.h +++ llvm/trunk/include/llvm/CodeGen/RegAllocPBQP.h @@ -89,26 +89,7 @@ std::copy(OptVec.begin(), OptVec.end(), Opts.get()); } - AllowedRegVector(const AllowedRegVector &Other) - : NumOpts(Other.NumOpts), Opts(new unsigned[NumOpts]) { - std::copy(Other.Opts.get(), Other.Opts.get() + NumOpts, Opts.get()); - } - - AllowedRegVector(AllowedRegVector &&Other) - : NumOpts(std::move(Other.NumOpts)), Opts(std::move(Other.Opts)) {} - - AllowedRegVector& operator=(const AllowedRegVector &Other) { - NumOpts = Other.NumOpts; - Opts.reset(new unsigned[NumOpts]); - std::copy(Other.Opts.get(), Other.Opts.get() + NumOpts, Opts.get()); - return *this; - } - - AllowedRegVector& operator=(AllowedRegVector &&Other) { - NumOpts = std::move(Other.NumOpts); - Opts = std::move(Other.Opts); - return *this; - } + AllowedRegVector(AllowedRegVector &&) = default; unsigned size() const { return NumOpts; } unsigned operator[](size_t I) const { return Opts[I]; } @@ -163,10 +144,6 @@ return VRegItr->second; } - void eraseNodeIdForVReg(unsigned VReg) { - VRegToNodeId.erase(VReg); - } - AllowedRegVecRef getAllowedRegs(AllowedRegVector Allowed) { return AllowedRegVecs.getValue(std::move(Allowed)); } @@ -199,8 +176,6 @@ #endif {} - // FIXME: Re-implementing default behavior to work around MSVC. Remove once - // MSVC synthesizes move constructors properly. NodeMetadata(const NodeMetadata &Other) : RS(Other.RS), NumOpts(Other.NumOpts), DeniedOpts(Other.DeniedOpts), OptUnsafeEdges(new unsigned[NumOpts]), VReg(Other.VReg), @@ -215,48 +190,9 @@ } } - // FIXME: Re-implementing default behavior to work around MSVC. Remove once - // MSVC synthesizes move constructors properly. - NodeMetadata(NodeMetadata &&Other) - : RS(Other.RS), NumOpts(Other.NumOpts), DeniedOpts(Other.DeniedOpts), - OptUnsafeEdges(std::move(Other.OptUnsafeEdges)), VReg(Other.VReg), - AllowedRegs(std::move(Other.AllowedRegs)) -#ifndef NDEBUG - , everConservativelyAllocatable(Other.everConservativelyAllocatable) -#endif - {} - - // FIXME: Re-implementing default behavior to work around MSVC. Remove once - // MSVC synthesizes move constructors properly. - NodeMetadata& operator=(const NodeMetadata &Other) { - RS = Other.RS; - NumOpts = Other.NumOpts; - DeniedOpts = Other.DeniedOpts; - OptUnsafeEdges.reset(new unsigned[NumOpts]); - std::copy(Other.OptUnsafeEdges.get(), Other.OptUnsafeEdges.get() + NumOpts, - OptUnsafeEdges.get()); - VReg = Other.VReg; - AllowedRegs = Other.AllowedRegs; -#ifndef NDEBUG - everConservativelyAllocatable = Other.everConservativelyAllocatable; -#endif - return *this; - } + NodeMetadata(NodeMetadata &&Other) = default; - // FIXME: Re-implementing default behavior to work around MSVC. Remove once - // MSVC synthesizes move constructors properly. - NodeMetadata& operator=(NodeMetadata &&Other) { - RS = Other.RS; - NumOpts = Other.NumOpts; - DeniedOpts = Other.DeniedOpts; - OptUnsafeEdges = std::move(Other.OptUnsafeEdges); - VReg = Other.VReg; - AllowedRegs = std::move(Other.AllowedRegs); -#ifndef NDEBUG - everConservativelyAllocatable = Other.everConservativelyAllocatable; -#endif - return *this; - } + NodeMetadata& operator=(NodeMetadata &&Other) = default; void setVReg(unsigned VReg) { this->VReg = VReg; } unsigned getVReg() const { return VReg; } @@ -284,7 +220,6 @@ #endif } - void handleAddEdge(const MatrixMetadata& MD, bool Transpose) { DeniedOpts += Transpose ? MD.getWorstRow() : MD.getWorstCol(); const bool* UnsafeOpts = @@ -369,11 +304,6 @@ handleReconnectEdge(EId, G.getEdgeNode2Id(EId)); } - void handleRemoveEdge(EdgeId EId) { - handleDisconnectEdge(EId, G.getEdgeNode1Id(EId)); - handleDisconnectEdge(EId, G.getEdgeNode2Id(EId)); - } - void handleDisconnectEdge(EdgeId EId, NodeId NId) { NodeMetadata& NMd = G.getNodeMetadata(NId); const MatrixMetadata& MMd = G.getEdgeCosts(EId).getMetadata();