|
|
|||
File indexing completed on 2026-05-10 08:43:26
0001 //===- CodeGen/Analysis.h - CodeGen LLVM IR Analysis Utilities --*- C++ -*-===// 0002 // 0003 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 0004 // See https://llvm.org/LICENSE.txt for license information. 0005 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 0006 // 0007 //===----------------------------------------------------------------------===// 0008 // 0009 // This file declares several CodeGen-specific LLVM IR analysis utilities. 0010 // 0011 //===----------------------------------------------------------------------===// 0012 0013 #ifndef LLVM_CODEGEN_ANALYSIS_H 0014 #define LLVM_CODEGEN_ANALYSIS_H 0015 0016 #include "llvm/ADT/ArrayRef.h" 0017 #include "llvm/ADT/DenseMap.h" 0018 #include "llvm/CodeGen/ISDOpcodes.h" 0019 #include "llvm/IR/Instructions.h" 0020 0021 namespace llvm { 0022 template <typename T> class SmallVectorImpl; 0023 class GlobalValue; 0024 class LLT; 0025 class MachineBasicBlock; 0026 class MachineFunction; 0027 class TargetLoweringBase; 0028 class TargetLowering; 0029 class TargetMachine; 0030 struct EVT; 0031 0032 /// Compute the linearized index of a member in a nested 0033 /// aggregate/struct/array. 0034 /// 0035 /// Given an LLVM IR aggregate type and a sequence of insertvalue or 0036 /// extractvalue indices that identify a member, return the linearized index of 0037 /// the start of the member, i.e the number of element in memory before the 0038 /// sought one. This is disconnected from the number of bytes. 0039 /// 0040 /// \param Ty is the type indexed by \p Indices. 0041 /// \param Indices is an optional pointer in the indices list to the current 0042 /// index. 0043 /// \param IndicesEnd is the end of the indices list. 0044 /// \param CurIndex is the current index in the recursion. 0045 /// 0046 /// \returns \p CurIndex plus the linear index in \p Ty the indices list. 0047 unsigned ComputeLinearIndex(Type *Ty, 0048 const unsigned *Indices, 0049 const unsigned *IndicesEnd, 0050 unsigned CurIndex = 0); 0051 0052 inline unsigned ComputeLinearIndex(Type *Ty, 0053 ArrayRef<unsigned> Indices, 0054 unsigned CurIndex = 0) { 0055 return ComputeLinearIndex(Ty, Indices.begin(), Indices.end(), CurIndex); 0056 } 0057 0058 /// ComputeValueVTs - Given an LLVM IR type, compute a sequence of 0059 /// EVTs that represent all the individual underlying 0060 /// non-aggregate types that comprise it. 0061 /// 0062 /// If Offsets is non-null, it points to a vector to be filled in 0063 /// with the in-memory offsets of each of the individual values. 0064 /// 0065 void ComputeValueVTs(const TargetLowering &TLI, const DataLayout &DL, Type *Ty, 0066 SmallVectorImpl<EVT> &ValueVTs, 0067 SmallVectorImpl<EVT> *MemVTs, 0068 SmallVectorImpl<TypeSize> *Offsets = nullptr, 0069 TypeSize StartingOffset = TypeSize::getZero()); 0070 void ComputeValueVTs(const TargetLowering &TLI, const DataLayout &DL, Type *Ty, 0071 SmallVectorImpl<EVT> &ValueVTs, 0072 SmallVectorImpl<EVT> *MemVTs, 0073 SmallVectorImpl<uint64_t> *FixedOffsets, 0074 uint64_t StartingOffset); 0075 0076 /// Variant of ComputeValueVTs that don't produce memory VTs. 0077 inline void ComputeValueVTs(const TargetLowering &TLI, const DataLayout &DL, 0078 Type *Ty, SmallVectorImpl<EVT> &ValueVTs, 0079 SmallVectorImpl<TypeSize> *Offsets = nullptr, 0080 TypeSize StartingOffset = TypeSize::getZero()) { 0081 ComputeValueVTs(TLI, DL, Ty, ValueVTs, nullptr, Offsets, StartingOffset); 0082 } 0083 inline void ComputeValueVTs(const TargetLowering &TLI, const DataLayout &DL, 0084 Type *Ty, SmallVectorImpl<EVT> &ValueVTs, 0085 SmallVectorImpl<uint64_t> *FixedOffsets, 0086 uint64_t StartingOffset) { 0087 ComputeValueVTs(TLI, DL, Ty, ValueVTs, nullptr, FixedOffsets, StartingOffset); 0088 } 0089 0090 /// computeValueLLTs - Given an LLVM IR type, compute a sequence of 0091 /// LLTs that represent all the individual underlying 0092 /// non-aggregate types that comprise it. 0093 /// 0094 /// If Offsets is non-null, it points to a vector to be filled in 0095 /// with the in-memory offsets of each of the individual values. 0096 /// 0097 void computeValueLLTs(const DataLayout &DL, Type &Ty, 0098 SmallVectorImpl<LLT> &ValueTys, 0099 SmallVectorImpl<uint64_t> *Offsets = nullptr, 0100 uint64_t StartingOffset = 0); 0101 0102 /// ExtractTypeInfo - Returns the type info, possibly bitcast, encoded in V. 0103 GlobalValue *ExtractTypeInfo(Value *V); 0104 0105 /// getFCmpCondCode - Return the ISD condition code corresponding to 0106 /// the given LLVM IR floating-point condition code. This includes 0107 /// consideration of global floating-point math flags. 0108 /// 0109 ISD::CondCode getFCmpCondCode(FCmpInst::Predicate Pred); 0110 0111 /// getFCmpCodeWithoutNaN - Given an ISD condition code comparing floats, 0112 /// return the equivalent code if we're allowed to assume that NaNs won't occur. 0113 ISD::CondCode getFCmpCodeWithoutNaN(ISD::CondCode CC); 0114 0115 /// getICmpCondCode - Return the ISD condition code corresponding to 0116 /// the given LLVM IR integer condition code. 0117 ISD::CondCode getICmpCondCode(ICmpInst::Predicate Pred); 0118 0119 /// getICmpCondCode - Return the LLVM IR integer condition code 0120 /// corresponding to the given ISD integer condition code. 0121 ICmpInst::Predicate getICmpCondCode(ISD::CondCode Pred); 0122 0123 /// Test if the given instruction is in a position to be optimized 0124 /// with a tail-call. This roughly means that it's in a block with 0125 /// a return and there's nothing that needs to be scheduled 0126 /// between it and the return. 0127 /// 0128 /// This function only tests target-independent requirements. 0129 bool isInTailCallPosition(const CallBase &Call, const TargetMachine &TM, 0130 bool ReturnsFirstArg = false); 0131 0132 /// Test if given that the input instruction is in the tail call position, if 0133 /// there is an attribute mismatch between the caller and the callee that will 0134 /// inhibit tail call optimizations. 0135 /// \p AllowDifferingSizes is an output parameter which, if forming a tail call 0136 /// is permitted, determines whether it's permitted only if the size of the 0137 /// caller's and callee's return types match exactly. 0138 bool attributesPermitTailCall(const Function *F, const Instruction *I, 0139 const ReturnInst *Ret, 0140 const TargetLoweringBase &TLI, 0141 bool *AllowDifferingSizes = nullptr); 0142 0143 /// Test if given that the input instruction is in the tail call position if the 0144 /// return type or any attributes of the function will inhibit tail call 0145 /// optimization. 0146 bool returnTypeIsEligibleForTailCall(const Function *F, const Instruction *I, 0147 const ReturnInst *Ret, 0148 const TargetLoweringBase &TLI, 0149 bool ReturnsFirstArg = false); 0150 0151 /// Returns true if the parent of \p CI returns CI's first argument after 0152 /// calling \p CI. 0153 bool funcReturnsFirstArgOfCall(const CallInst &CI); 0154 0155 DenseMap<const MachineBasicBlock *, int> 0156 getEHScopeMembership(const MachineFunction &MF); 0157 0158 } // End llvm namespace 0159 0160 #endif
| [ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
|
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
|