Fix some comment typos.
[oota-llvm.git] / include / llvm / CodeGen / Analysis.h
1 //===- CodeGen/Analysis.h - CodeGen LLVM IR Analysis Utilities --*- C++ -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file declares several CodeGen-specific LLVM IR analysis utilities.
11 //
12 //===----------------------------------------------------------------------===//
13
14 #ifndef LLVM_CODEGEN_ANALYSIS_H
15 #define LLVM_CODEGEN_ANALYSIS_H
16
17 #include "llvm/ADT/ArrayRef.h"
18 #include "llvm/ADT/SmallVector.h"
19 #include "llvm/CodeGen/ISDOpcodes.h"
20 #include "llvm/IR/CallSite.h"
21 #include "llvm/IR/InlineAsm.h"
22 #include "llvm/IR/Instructions.h"
23
24 namespace llvm {
25 class GlobalValue;
26 class TargetLoweringBase;
27 class TargetLowering;
28 class TargetMachine;
29 class SDNode;
30 class SDValue;
31 class SelectionDAG;
32 struct EVT;
33
34 /// \brief Compute the linearized index of a member in a nested
35 /// aggregate/struct/array.
36 ///
37 /// Given an LLVM IR aggregate type and a sequence of insertvalue or
38 /// extractvalue indices that identify a member, return the linearized index of
39 /// the start of the member, i.e the number of element in memory before the
40 /// sought one. This is disconnected from the number of bytes.
41 ///
42 /// \param Ty is the type indexed by \p Indices.
43 /// \param Indices is an optional pointer in the indices list to the current
44 /// index.
45 /// \param IndicesEnd is the end of the indices list.
46 /// \param CurIndex is the current index in the recursion.
47 ///
48 /// \returns \p CurIndex plus the linear index in \p Ty  the indices list.
49 unsigned ComputeLinearIndex(Type *Ty,
50                             const unsigned *Indices,
51                             const unsigned *IndicesEnd,
52                             unsigned CurIndex = 0);
53
54 inline unsigned ComputeLinearIndex(Type *Ty,
55                                    ArrayRef<unsigned> Indices,
56                                    unsigned CurIndex = 0) {
57   return ComputeLinearIndex(Ty, Indices.begin(), Indices.end(), CurIndex);
58 }
59
60 /// ComputeValueVTs - Given an LLVM IR type, compute a sequence of
61 /// EVTs that represent all the individual underlying
62 /// non-aggregate types that comprise it.
63 ///
64 /// If Offsets is non-null, it points to a vector to be filled in
65 /// with the in-memory offsets of each of the individual values.
66 ///
67 void ComputeValueVTs(const TargetLowering &TLI, const DataLayout &DL, Type *Ty,
68                      SmallVectorImpl<EVT> &ValueVTs,
69                      SmallVectorImpl<uint64_t> *Offsets = nullptr,
70                      uint64_t StartingOffset = 0);
71
72 /// ExtractTypeInfo - Returns the type info, possibly bitcast, encoded in V.
73 GlobalValue *ExtractTypeInfo(Value *V);
74
75 /// hasInlineAsmMemConstraint - Return true if the inline asm instruction being
76 /// processed uses a memory 'm' constraint.
77 bool hasInlineAsmMemConstraint(InlineAsm::ConstraintInfoVector &CInfos,
78                                const TargetLowering &TLI);
79
80 /// getFCmpCondCode - Return the ISD condition code corresponding to
81 /// the given LLVM IR floating-point condition code.  This includes
82 /// consideration of global floating-point math flags.
83 ///
84 ISD::CondCode getFCmpCondCode(FCmpInst::Predicate Pred);
85
86 /// getFCmpCodeWithoutNaN - Given an ISD condition code comparing floats,
87 /// return the equivalent code if we're allowed to assume that NaNs won't occur.
88 ISD::CondCode getFCmpCodeWithoutNaN(ISD::CondCode CC);
89
90 /// getICmpCondCode - Return the ISD condition code corresponding to
91 /// the given LLVM IR integer condition code.
92 ///
93 ISD::CondCode getICmpCondCode(ICmpInst::Predicate Pred);
94
95 /// Test if the given instruction is in a position to be optimized
96 /// with a tail-call. This roughly means that it's in a block with
97 /// a return and there's nothing that needs to be scheduled
98 /// between it and the return.
99 ///
100 /// This function only tests target-independent requirements.
101 bool isInTailCallPosition(ImmutableCallSite CS, const TargetMachine &TM);
102
103 /// Test if given that the input instruction is in the tail call position if the
104 /// return type or any attributes of the function will inhibit tail call
105 /// optimization.
106 bool returnTypeIsEligibleForTailCall(const Function *F,
107                                      const Instruction *I,
108                                      const ReturnInst *Ret,
109                                      const TargetLoweringBase &TLI);
110
111 // True if GV can be left out of the object symbol table. This is the case
112 // for linkonce_odr values whose address is not significant. While legal, it is
113 // not normally profitable to omit them from the .o symbol table. Using this
114 // analysis makes sense when the information can be passed down to the linker
115 // or we are in LTO.
116 bool canBeOmittedFromSymbolTable(const GlobalValue *GV);
117
118 } // End llvm namespace
119
120 #endif