//===- TargetTransformInfo.h ------------------------------------*- C++ -*-===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// /// \file /// This pass exposes codegen information to IR-level passes. Every /// transformation that uses codegen information is broken into three parts: /// 1. The IR-level analysis pass. /// 2. The IR-level transformation interface which provides the needed /// information. /// 3. Codegen-level implementation which uses target-specific hooks. /// /// This file defines #2, which is the interface that IR-level transformations /// use for querying the codegen. /// //===----------------------------------------------------------------------===// #ifndef LLVM_ANALYSIS_TARGETTRANSFORMINFO_H #define LLVM_ANALYSIS_TARGETTRANSFORMINFO_H #include "llvm/ADT/APInt.h" #include "llvm/IR/FMF.h" #include "llvm/IR/InstrTypes.h" #include "llvm/IR/PassManager.h" #include "llvm/Pass.h" #include "llvm/Support/AtomicOrdering.h" #include "llvm/Support/BranchProbability.h" #include "llvm/Support/InstructionCost.h" #include <functional> #include <optional> #include <utility> namespace llvm { namespace Intrinsic { ID; } class AllocaInst; class AssumptionCache; class BlockFrequencyInfo; class DominatorTree; class BranchInst; class Function; class GlobalValue; class InstCombiner; class OptimizationRemarkEmitter; class InterleavedAccessInfo; class IntrinsicInst; class LoadInst; class Loop; class LoopInfo; class LoopVectorizationLegality; class ProfileSummaryInfo; class RecurrenceDescriptor; class SCEV; class ScalarEvolution; class SmallBitVector; class StoreInst; class SwitchInst; class TargetLibraryInfo; class Type; class VPIntrinsic; struct KnownBits; /// Information about a load/store intrinsic defined by the target. struct MemIntrinsicInfo { … }; /// Attributes of a target dependent hardware loop. struct HardwareLoopInfo { … }; class IntrinsicCostAttributes { … }; enum class TailFoldingStyle { … }; struct TailFoldingInfo { … }; class TargetTransformInfo; TTI; /// This pass provides access to the codegen interfaces that are needed /// for IR-level transformations. class TargetTransformInfo { … }; class TargetTransformInfo::Concept { … }; template <typename T> class TargetTransformInfo::Model final : public TargetTransformInfo::Concept { … }; template <typename T> TargetTransformInfo::TargetTransformInfo(T Impl) : TTIImpl(new Model<T>(Impl)) { … } /// Analysis pass providing the \c TargetTransformInfo. /// /// The core idea of the TargetIRAnalysis is to expose an interface through /// which LLVM targets can analyze and provide information about the middle /// end's target-independent IR. This supports use cases such as target-aware /// cost modeling of IR constructs. /// /// This is a function analysis because much of the cost modeling for targets /// is done in a subtarget specific way and LLVM supports compiling different /// functions targeting different subtargets in order to support runtime /// dispatch according to the observed subtarget. class TargetIRAnalysis : public AnalysisInfoMixin<TargetIRAnalysis> { … }; /// Wrapper pass for TargetTransformInfo. /// /// This pass can be constructed from a TTI object which it stores internally /// and is queried by passes. class TargetTransformInfoWrapperPass : public ImmutablePass { … }; /// Create an analysis pass wrapper around a TTI object. /// /// This analysis pass just holds the TTI instance and makes it available to /// clients. ImmutablePass *createTargetTransformInfoWrapperPass(TargetIRAnalysis TIRA); } // namespace llvm #endif