From da46d0ea8c44e673dcfc25e7d65f8a7631e2de04 Mon Sep 17 00:00:00 2001 From: Tyler Nowicki Date: Tue, 14 Jul 2015 23:03:09 +0000 Subject: [PATCH] Make the variable names match the name of the metadata they control. Rename Vectorizer to Vectorize and VectorizeUnroll to InterleaveCount. llvm-svn: 242241 --- clang/lib/CodeGen/CGLoopInfo.cpp | 41 +++++++++++++++--------------- clang/lib/CodeGen/CGLoopInfo.h | 32 +++++++++++------------ clang/lib/CodeGen/CGStmtOpenMP.cpp | 4 +-- 3 files changed, 38 insertions(+), 39 deletions(-) diff --git a/clang/lib/CodeGen/CGLoopInfo.cpp b/clang/lib/CodeGen/CGLoopInfo.cpp index 1163d63b4a20..63de2d98fd7f 100644 --- a/clang/lib/CodeGen/CGLoopInfo.cpp +++ b/clang/lib/CodeGen/CGLoopInfo.cpp @@ -20,9 +20,9 @@ using namespace llvm; static MDNode *createMetadata(LLVMContext &Ctx, const LoopAttributes &Attrs) { - if (!Attrs.IsParallel && Attrs.VectorizerWidth == 0 && - Attrs.VectorizerUnroll == 0 && - Attrs.VectorizerEnable == LoopAttributes::VecUnspecified) + if (!Attrs.IsParallel && Attrs.VectorizeWidth == 0 && + Attrs.InterleaveCount == 0 && + Attrs.VectorizeEnable == LoopAttributes::Unspecified) return nullptr; SmallVector Args; @@ -30,29 +30,28 @@ static MDNode *createMetadata(LLVMContext &Ctx, const LoopAttributes &Attrs) { auto TempNode = MDNode::getTemporary(Ctx, None); Args.push_back(TempNode.get()); - // Setting vectorizer.width - if (Attrs.VectorizerWidth > 0) { + // Setting vectorize.width + if (Attrs.VectorizeWidth > 0) { Metadata *Vals[] = {MDString::get(Ctx, "llvm.loop.vectorize.width"), ConstantAsMetadata::get(ConstantInt::get( - Type::getInt32Ty(Ctx), Attrs.VectorizerWidth))}; + Type::getInt32Ty(Ctx), Attrs.VectorizeWidth))}; Args.push_back(MDNode::get(Ctx, Vals)); } - // Setting vectorizer.unroll - if (Attrs.VectorizerUnroll > 0) { + // Setting interleave.count + if (Attrs.InterleaveCount > 0) { Metadata *Vals[] = {MDString::get(Ctx, "llvm.loop.interleave.count"), ConstantAsMetadata::get(ConstantInt::get( - Type::getInt32Ty(Ctx), Attrs.VectorizerUnroll))}; + Type::getInt32Ty(Ctx), Attrs.InterleaveCount))}; Args.push_back(MDNode::get(Ctx, Vals)); } - // Setting vectorizer.enable - if (Attrs.VectorizerEnable != LoopAttributes::VecUnspecified) { - Metadata *Vals[] = { - MDString::get(Ctx, "llvm.loop.vectorize.enable"), - ConstantAsMetadata::get(ConstantInt::get( - Type::getInt1Ty(Ctx), - (Attrs.VectorizerEnable == LoopAttributes::VecEnable)))}; + // Setting vectorize.enable + if (Attrs.VectorizeEnable != LoopAttributes::Unspecified) { + Metadata *Vals[] = {MDString::get(Ctx, "llvm.loop.vectorize.enable"), + ConstantAsMetadata::get(ConstantInt::get( + Type::getInt1Ty(Ctx), (Attrs.VectorizeEnable == + LoopAttributes::Enable)))}; Args.push_back(MDNode::get(Ctx, Vals)); } @@ -63,14 +62,14 @@ static MDNode *createMetadata(LLVMContext &Ctx, const LoopAttributes &Attrs) { } LoopAttributes::LoopAttributes(bool IsParallel) - : IsParallel(IsParallel), VectorizerEnable(LoopAttributes::VecUnspecified), - VectorizerWidth(0), VectorizerUnroll(0) {} + : IsParallel(IsParallel), VectorizeEnable(LoopAttributes::Unspecified), + VectorizeWidth(0), InterleaveCount(0) {} void LoopAttributes::clear() { IsParallel = false; - VectorizerWidth = 0; - VectorizerUnroll = 0; - VectorizerEnable = LoopAttributes::VecUnspecified; + VectorizeWidth = 0; + InterleaveCount = 0; + VectorizeEnable = LoopAttributes::Unspecified; } LoopInfo::LoopInfo(BasicBlock *Header, const LoopAttributes &Attrs) diff --git a/clang/lib/CodeGen/CGLoopInfo.h b/clang/lib/CodeGen/CGLoopInfo.h index 2249937cd0d0..8822c22c91c8 100644 --- a/clang/lib/CodeGen/CGLoopInfo.h +++ b/clang/lib/CodeGen/CGLoopInfo.h @@ -39,17 +39,17 @@ struct LoopAttributes { /// \brief Generate llvm.loop.parallel metadata for loads and stores. bool IsParallel; - /// \brief Values of llvm.loop.vectorize.enable metadata. - enum LVEnableState { VecUnspecified, VecEnable, VecDisable }; + /// \brief State of loop vectorization or unrolling. + enum LVEnableState { Unspecified, Enable, Disable }; - /// \brief llvm.loop.vectorize.enable - LVEnableState VectorizerEnable; + /// \brief Value for llvm.loop.vectorize.enable metadata. + LVEnableState VectorizeEnable; - /// \brief llvm.loop.vectorize.width - unsigned VectorizerWidth; + /// \brief Value for llvm.loop.vectorize.width metadata. + unsigned VectorizeWidth; - /// \brief llvm.loop.interleave.count - unsigned VectorizerUnroll; + /// \brief Value for llvm.loop.interleave.count metadata. + unsigned InterleaveCount; }; /// \brief Information used when generating a structured loop. @@ -109,17 +109,17 @@ public: /// \brief Set the next pushed loop as parallel. void setParallel(bool Enable = true) { StagedAttrs.IsParallel = Enable; } - /// \brief Set the next pushed loop 'vectorizer.enable' - void setVectorizerEnable(bool Enable = true) { - StagedAttrs.VectorizerEnable = - Enable ? LoopAttributes::VecEnable : LoopAttributes::VecDisable; + /// \brief Set the next pushed loop 'vectorize.enable' + void setVectorizeEnable(bool Enable = true) { + StagedAttrs.VectorizeEnable = + Enable ? LoopAttributes::Enable : LoopAttributes::Disable; } - /// \brief Set the vectorizer width for the next loop pushed. - void setVectorizerWidth(unsigned W) { StagedAttrs.VectorizerWidth = W; } + /// \brief Set the vectorize width for the next loop pushed. + void setVectorizeWidth(unsigned W) { StagedAttrs.VectorizeWidth = W; } - /// \brief Set the vectorizer unroll for the next loop pushed. - void setVectorizerUnroll(unsigned U) { StagedAttrs.VectorizerUnroll = U; } + /// \brief Set the interleave count for the next loop pushed. + void setInterleaveCount(unsigned C) { StagedAttrs.InterleaveCount = C; } private: /// \brief Returns true if there is LoopInfo on the stack. diff --git a/clang/lib/CodeGen/CGStmtOpenMP.cpp b/clang/lib/CodeGen/CGStmtOpenMP.cpp index a1f093a8d866..b11372bbcb7b 100644 --- a/clang/lib/CodeGen/CGStmtOpenMP.cpp +++ b/clang/lib/CodeGen/CGStmtOpenMP.cpp @@ -741,7 +741,7 @@ static void emitSafelenClause(CodeGenFunction &CGF, RValue Len = CGF.EmitAnyExpr(C->getSafelen(), AggValueSlot::ignored(), /*ignoreResult=*/true); llvm::ConstantInt *Val = cast(Len.getScalarVal()); - CGF.LoopStack.setVectorizerWidth(Val->getZExtValue()); + CGF.LoopStack.setVectorizeWidth(Val->getZExtValue()); // In presence of finite 'safelen', it may be unsafe to mark all // the memory instructions parallel, because loop-carried // dependences of 'safelen' iterations are possible. @@ -752,7 +752,7 @@ static void emitSafelenClause(CodeGenFunction &CGF, void CodeGenFunction::EmitOMPSimdInit(const OMPLoopDirective &D) { // Walk clauses and process safelen/lastprivate. LoopStack.setParallel(); - LoopStack.setVectorizerEnable(true); + LoopStack.setVectorizeEnable(true); emitSafelenClause(*this, D); }