LLVM  9.0.0svn
Analysis.h
Go to the documentation of this file.
1 //===- CodeGen/Analysis.h - CodeGen LLVM IR Analysis Utilities --*- 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 // This file declares several CodeGen-specific LLVM IR analysis utilities.
10 //
11 //===----------------------------------------------------------------------===//
12 
13 #ifndef LLVM_CODEGEN_ANALYSIS_H
14 #define LLVM_CODEGEN_ANALYSIS_H
15 
16 #include "llvm/ADT/ArrayRef.h"
17 #include "llvm/ADT/DenseMap.h"
18 #include "llvm/ADT/SmallVector.h"
19 #include "llvm/ADT/Triple.h"
21 #include "llvm/IR/CallSite.h"
22 #include "llvm/IR/InlineAsm.h"
23 #include "llvm/IR/Instructions.h"
24 #include "llvm/Support/CodeGen.h"
25 
26 namespace llvm {
27 class GlobalValue;
28 class MachineBasicBlock;
29 class MachineFunction;
30 class TargetLoweringBase;
31 class TargetLowering;
32 class TargetMachine;
33 class SDNode;
34 class SDValue;
35 class SelectionDAG;
36 struct EVT;
37 
38 /// Compute the linearized index of a member in a nested
39 /// aggregate/struct/array.
40 ///
41 /// Given an LLVM IR aggregate type and a sequence of insertvalue or
42 /// extractvalue indices that identify a member, return the linearized index of
43 /// the start of the member, i.e the number of element in memory before the
44 /// sought one. This is disconnected from the number of bytes.
45 ///
46 /// \param Ty is the type indexed by \p Indices.
47 /// \param Indices is an optional pointer in the indices list to the current
48 /// index.
49 /// \param IndicesEnd is the end of the indices list.
50 /// \param CurIndex is the current index in the recursion.
51 ///
52 /// \returns \p CurIndex plus the linear index in \p Ty the indices list.
53 unsigned ComputeLinearIndex(Type *Ty,
54  const unsigned *Indices,
55  const unsigned *IndicesEnd,
56  unsigned CurIndex = 0);
57 
58 inline unsigned ComputeLinearIndex(Type *Ty,
59  ArrayRef<unsigned> Indices,
60  unsigned CurIndex = 0) {
61  return ComputeLinearIndex(Ty, Indices.begin(), Indices.end(), CurIndex);
62 }
63 
64 /// ComputeValueVTs - Given an LLVM IR type, compute a sequence of
65 /// EVTs that represent all the individual underlying
66 /// non-aggregate types that comprise it.
67 ///
68 /// If Offsets is non-null, it points to a vector to be filled in
69 /// with the in-memory offsets of each of the individual values.
70 ///
71 void ComputeValueVTs(const TargetLowering &TLI, const DataLayout &DL, Type *Ty,
72  SmallVectorImpl<EVT> &ValueVTs,
74  uint64_t StartingOffset = 0);
75 
76 /// ExtractTypeInfo - Returns the type info, possibly bitcast, encoded in V.
78 
79 /// hasInlineAsmMemConstraint - Return true if the inline asm instruction being
80 /// processed uses a memory 'm' constraint.
82  const TargetLowering &TLI);
83 
84 /// getFCmpCondCode - Return the ISD condition code corresponding to
85 /// the given LLVM IR floating-point condition code. This includes
86 /// consideration of global floating-point math flags.
87 ///
89 
90 /// getFCmpCodeWithoutNaN - Given an ISD condition code comparing floats,
91 /// return the equivalent code if we're allowed to assume that NaNs won't occur.
93 
94 /// getICmpCondCode - Return the ISD condition code corresponding to
95 /// the given LLVM IR integer condition code.
96 ///
98 
99 /// Test if the given instruction is in a position to be optimized
100 /// with a tail-call. This roughly means that it's in a block with
101 /// a return and there's nothing that needs to be scheduled
102 /// between it and the return.
103 ///
104 /// This function only tests target-independent requirements.
106 
107 /// Test if given that the input instruction is in the tail call position, if
108 /// there is an attribute mismatch between the caller and the callee that will
109 /// inhibit tail call optimizations.
110 /// \p AllowDifferingSizes is an output parameter which, if forming a tail call
111 /// is permitted, determines whether it's permitted only if the size of the
112 /// caller's and callee's return types match exactly.
113 bool attributesPermitTailCall(const Function *F, const Instruction *I,
114  const ReturnInst *Ret,
115  const TargetLoweringBase &TLI,
116  bool *AllowDifferingSizes = nullptr);
117 
118 /// Test if given that the input instruction is in the tail call position if the
119 /// return type or any attributes of the function will inhibit tail call
120 /// optimization.
122  const ReturnInst *Ret,
123  const TargetLoweringBase &TLI);
124 
127 
128 } // End llvm namespace
129 
130 #endif
Return a value (possibly void), from a function.
A parsed version of the target data layout string in and methods for querying it. ...
Definition: DataLayout.h:110
ISD::CondCode getICmpCondCode(ICmpInst::Predicate Pred)
getICmpCondCode - Return the ISD condition code corresponding to the given LLVM IR integer condition ...
Definition: Analysis.cpp:197
Type
MessagePack types as defined in the standard, with the exception of Integer being divided into a sign...
Definition: MsgPackReader.h:48
This class represents lattice values for constants.
Definition: AllocatorList.h:23
iterator begin() const
Definition: ArrayRef.h:136
Offsets
Offsets in bytes from the start of the input buffer.
Definition: SIInstrInfo.h:1026
F(f)
GlobalValue * ExtractTypeInfo(Value *V)
ExtractTypeInfo - Returns the type info, possibly bitcast, encoded in V.
Definition: Analysis.cpp:117
bool returnTypeIsEligibleForTailCall(const Function *F, const Instruction *I, const ReturnInst *Ret, const TargetLoweringBase &TLI)
Test if given that the input instruction is in the tail call position if the return type or any attri...
Definition: Analysis.cpp:569
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
Definition: APFloat.h:41
This class defines information used to lower LLVM code to legal SelectionDAG operators that the targe...
CondCode
ISD::CondCode enum - These are ordered carefully to make the bitfields below work out...
Definition: ISDOpcodes.h:965
ISD::CondCode getFCmpCondCode(FCmpInst::Predicate Pred)
getFCmpCondCode - Return the ISD condition code corresponding to the given LLVM IR floating-point con...
Definition: Analysis.cpp:160
void ComputeValueVTs(const TargetLowering &TLI, const DataLayout &DL, Type *Ty, SmallVectorImpl< EVT > &ValueVTs, SmallVectorImpl< uint64_t > *Offsets=nullptr, uint64_t StartingOffset=0)
ComputeValueVTs - Given an LLVM IR type, compute a sequence of EVTs that represent all the individual...
Definition: Analysis.cpp:83
bool hasInlineAsmMemConstraint(InlineAsm::ConstraintInfoVector &CInfos, const TargetLowering &TLI)
hasInlineAsmMemConstraint - Return true if the inline asm instruction being processed uses a memory &#39;...
Definition: Analysis.cpp:138
The instances of the Type class are immutable: once they are created, they are never changed...
Definition: Type.h:45
Predicate
This enumeration lists the possible predicates for CmpInst subclasses.
Definition: InstrTypes.h:646
bool isInTailCallPosition(ImmutableCallSite CS, const TargetMachine &TM)
Test if the given instruction is in a position to be optimized with a tail-call.
Definition: Analysis.cpp:470
std::vector< ConstraintInfo > ConstraintInfoVector
Definition: InlineAsm.h:115
This base class for TargetLowering contains the SelectionDAG-independent parts that can be used from ...
iterator end() const
Definition: ArrayRef.h:137
DenseMap< const MachineBasicBlock *, int > getEHScopeMembership(const MachineFunction &MF)
Definition: Analysis.cpp:682
ISD::CondCode getFCmpCodeWithoutNaN(ISD::CondCode CC)
getFCmpCodeWithoutNaN - Given an ISD condition code comparing floats, return the equivalent code if w...
Definition: Analysis.cpp:182
Establish a view to a call site for examination.
Definition: CallSite.h:892
#define I(x, y, z)
Definition: MD5.cpp:58
LLVM Value Representation.
Definition: Value.h:72
Primary interface to the complete machine description for the target machine.
Definition: TargetMachine.h:58
bool attributesPermitTailCall(const Function *F, const Instruction *I, const ReturnInst *Ret, const TargetLoweringBase &TLI, bool *AllowDifferingSizes=nullptr)
Test if given that the input instruction is in the tail call position, if there is an attribute misma...
Definition: Analysis.cpp:512
unsigned ComputeLinearIndex(Type *Ty, const unsigned *Indices, const unsigned *IndicesEnd, unsigned CurIndex=0)
Compute the linearized index of a member in a nested aggregate/struct/array.
Definition: Analysis.cpp:35