Make the variable names match the name of the metadata they control.

Rename Vectorizer to Vectorize and VectorizeUnroll to InterleaveCount.

llvm-svn: 242241
This commit is contained in:
Tyler Nowicki 2015-07-14 23:03:09 +00:00
parent 775993ca7d
commit da46d0ea8c
3 changed files with 38 additions and 39 deletions

View File

@ -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<Metadata *, 4> 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)

View File

@ -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.

View File

@ -741,7 +741,7 @@ static void emitSafelenClause(CodeGenFunction &CGF,
RValue Len = CGF.EmitAnyExpr(C->getSafelen(), AggValueSlot::ignored(),
/*ignoreResult=*/true);
llvm::ConstantInt *Val = cast<llvm::ConstantInt>(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);
}