LLVM 20.0.0git
VPlanAnalysis.h
Go to the documentation of this file.
1//===- VPlanAnalysis.h - Various Analyses working on VPlan ------*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef LLVM_TRANSFORMS_VECTORIZE_VPLANANALYSIS_H
10#define LLVM_TRANSFORMS_VECTORIZE_VPLANANALYSIS_H
11
12#include "llvm/ADT/DenseMap.h"
13#include "llvm/ADT/DenseSet.h"
14#include "llvm/IR/Type.h"
15
16namespace llvm {
17
18class LLVMContext;
19class VPValue;
20class VPBlendRecipe;
21class VPInstruction;
22class VPWidenRecipe;
23class VPWidenCallRecipe;
24class VPWidenIntOrFpInductionRecipe;
25class VPWidenMemoryRecipe;
26struct VPWidenSelectRecipe;
27class VPReplicateRecipe;
28class VPRecipeBase;
29class VPlan;
30class Type;
31
32/// An analysis for type-inference for VPValues.
33/// It infers the scalar type for a given VPValue by bottom-up traversing
34/// through defining recipes until root nodes with known types are reached (e.g.
35/// live-ins or load recipes). The types are then propagated top down through
36/// operations.
37/// Note that the analysis caches the inferred types. A new analysis object must
38/// be constructed once a VPlan has been modified in a way that invalidates any
39/// of the previously inferred types.
42 /// Type of the canonical induction variable. Used for all VPValues without
43 /// any underlying IR value (like the vector trip count or the backedge-taken
44 /// count).
45 Type *CanonicalIVTy;
46 LLVMContext &Ctx;
47
48 Type *inferScalarTypeForRecipe(const VPBlendRecipe *R);
49 Type *inferScalarTypeForRecipe(const VPInstruction *R);
50 Type *inferScalarTypeForRecipe(const VPWidenCallRecipe *R);
51 Type *inferScalarTypeForRecipe(const VPWidenRecipe *R);
52 Type *inferScalarTypeForRecipe(const VPWidenIntOrFpInductionRecipe *R);
53 Type *inferScalarTypeForRecipe(const VPWidenMemoryRecipe *R);
54 Type *inferScalarTypeForRecipe(const VPWidenSelectRecipe *R);
55 Type *inferScalarTypeForRecipe(const VPReplicateRecipe *R);
56
57public:
58 VPTypeAnalysis(Type *CanonicalIVTy)
59 : CanonicalIVTy(CanonicalIVTy), Ctx(CanonicalIVTy->getContext()) {}
60
61 /// Infer the type of \p V. Returns the scalar type of \p V.
62 Type *inferScalarType(const VPValue *V);
63
64 /// Return the LLVMContext used by the analysis.
65 LLVMContext &getContext() { return Ctx; }
66};
67
68// Collect a VPlan's ephemeral recipes (those used only by an assume).
69void collectEphemeralRecipesForVPlan(VPlan &Plan,
70 DenseSet<VPRecipeBase *> &EphRecipes);
71} // end namespace llvm
72
73#endif // LLVM_TRANSFORMS_VECTORIZE_VPLANANALYSIS_H
RelocType Type
Definition: COFFYAML.cpp:410
This file defines the DenseMap class.
This file defines the DenseSet and SmallDenseSet classes.
This is an important class for using LLVM in a threaded context.
Definition: LLVMContext.h:67
The instances of the Type class are immutable: once they are created, they are never changed.
Definition: Type.h:45
A recipe for vectorizing a phi-node as a sequence of mask-based select instructions.
Definition: VPlan.h:2425
This is a concrete Recipe that models a single VPlan-level instruction.
Definition: VPlan.h:1197
VPReplicateRecipe replicates a given instruction producing multiple scalar copies of the original sca...
Definition: VPlan.h:2706
An analysis for type-inference for VPValues.
Definition: VPlanAnalysis.h:40
LLVMContext & getContext()
Return the LLVMContext used by the analysis.
Definition: VPlanAnalysis.h:65
VPTypeAnalysis(Type *CanonicalIVTy)
Definition: VPlanAnalysis.h:58
Type * inferScalarType(const VPValue *V)
Infer the type of V. Returns the scalar type of V.
A recipe for widening Call instructions using library calls.
Definition: VPlan.h:1716
A recipe for handling phi nodes of integer and floating-point inductions, producing their vector valu...
Definition: VPlan.h:2129
A common base class for widening memory operations.
Definition: VPlan.h:2879
VPWidenRecipe is a recipe for producing a widened instruction using the opcode and operands of the re...
Definition: VPlan.h:1431
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
void collectEphemeralRecipesForVPlan(VPlan &Plan, DenseSet< VPRecipeBase * > &EphRecipes)
A recipe for widening select instructions.
Definition: VPlan.h:1813