Path: blob/main/contrib/llvm-project/llvm/lib/Transforms/Vectorize/VPlanAnalysis.h
35269 views
//===- VPlanAnalysis.h - Various Analyses working on VPlan ------*- C++ -*-===//1//2// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.3// See https://llvm.org/LICENSE.txt for license information.4// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception5//6//===----------------------------------------------------------------------===//78#ifndef LLVM_TRANSFORMS_VECTORIZE_VPLANANALYSIS_H9#define LLVM_TRANSFORMS_VECTORIZE_VPLANANALYSIS_H1011#include "llvm/ADT/DenseMap.h"12#include "llvm/ADT/DenseSet.h"1314namespace llvm {1516class LLVMContext;17class VPValue;18class VPBlendRecipe;19class VPInstruction;20class VPWidenRecipe;21class VPWidenCallRecipe;22class VPWidenIntOrFpInductionRecipe;23class VPWidenMemoryRecipe;24struct VPWidenSelectRecipe;25class VPReplicateRecipe;26class VPRecipeBase;27class VPlan;28class Type;2930/// An analysis for type-inference for VPValues.31/// It infers the scalar type for a given VPValue by bottom-up traversing32/// through defining recipes until root nodes with known types are reached (e.g.33/// live-ins or load recipes). The types are then propagated top down through34/// operations.35/// Note that the analysis caches the inferred types. A new analysis object must36/// be constructed once a VPlan has been modified in a way that invalidates any37/// of the previously inferred types.38class VPTypeAnalysis {39DenseMap<const VPValue *, Type *> CachedTypes;40/// Type of the canonical induction variable. Used for all VPValues without41/// any underlying IR value (like the vector trip count or the backedge-taken42/// count).43Type *CanonicalIVTy;44LLVMContext &Ctx;4546Type *inferScalarTypeForRecipe(const VPBlendRecipe *R);47Type *inferScalarTypeForRecipe(const VPInstruction *R);48Type *inferScalarTypeForRecipe(const VPWidenCallRecipe *R);49Type *inferScalarTypeForRecipe(const VPWidenRecipe *R);50Type *inferScalarTypeForRecipe(const VPWidenIntOrFpInductionRecipe *R);51Type *inferScalarTypeForRecipe(const VPWidenMemoryRecipe *R);52Type *inferScalarTypeForRecipe(const VPWidenSelectRecipe *R);53Type *inferScalarTypeForRecipe(const VPReplicateRecipe *R);5455public:56VPTypeAnalysis(Type *CanonicalIVTy, LLVMContext &Ctx)57: CanonicalIVTy(CanonicalIVTy), Ctx(Ctx) {}5859/// Infer the type of \p V. Returns the scalar type of \p V.60Type *inferScalarType(const VPValue *V);6162/// Return the LLVMContext used by the analysis.63LLVMContext &getContext() { return Ctx; }64};6566// Collect a VPlan's ephemeral recipes (those used only by an assume).67void collectEphemeralRecipesForVPlan(VPlan &Plan,68DenseSet<VPRecipeBase *> &EphRecipes);69} // end namespace llvm7071#endif // LLVM_TRANSFORMS_VECTORIZE_VPLANANALYSIS_H727374