LLVM API Documentation

CodeGen/Analysis.h
Go to the documentation of this file.
00001 //===- CodeGen/Analysis.h - CodeGen LLVM IR Analysis Utilities --*- C++ -*-===//
00002 //
00003 //                     The LLVM Compiler Infrastructure
00004 //
00005 // This file is distributed under the University of Illinois Open Source
00006 // License. See LICENSE.TXT for details.
00007 //
00008 //===----------------------------------------------------------------------===//
00009 //
00010 // This file declares several CodeGen-specific LLVM IR analysis utilities.
00011 //
00012 //===----------------------------------------------------------------------===//
00013 
00014 #ifndef LLVM_CODEGEN_ANALYSIS_H
00015 #define LLVM_CODEGEN_ANALYSIS_H
00016 
00017 #include "llvm/ADT/ArrayRef.h"
00018 #include "llvm/ADT/SmallVector.h"
00019 #include "llvm/CodeGen/ISDOpcodes.h"
00020 #include "llvm/IR/CallSite.h"
00021 #include "llvm/IR/InlineAsm.h"
00022 #include "llvm/IR/Instructions.h"
00023 
00024 namespace llvm {
00025 class GlobalVariable;
00026 class TargetLoweringBase;
00027 class TargetLowering;
00028 class TargetMachine;
00029 class SDNode;
00030 class SDValue;
00031 class SelectionDAG;
00032 struct EVT;
00033 
00034 /// ComputeLinearIndex - Given an LLVM IR aggregate type and a sequence
00035 /// of insertvalue or extractvalue indices that identify a member, return
00036 /// the linearized index of the start of the member.
00037 ///
00038 unsigned ComputeLinearIndex(Type *Ty,
00039                             const unsigned *Indices,
00040                             const unsigned *IndicesEnd,
00041                             unsigned CurIndex = 0);
00042 
00043 inline unsigned ComputeLinearIndex(Type *Ty,
00044                                    ArrayRef<unsigned> Indices,
00045                                    unsigned CurIndex = 0) {
00046   return ComputeLinearIndex(Ty, Indices.begin(), Indices.end(), CurIndex);
00047 }
00048 
00049 /// ComputeValueVTs - Given an LLVM IR type, compute a sequence of
00050 /// EVTs that represent all the individual underlying
00051 /// non-aggregate types that comprise it.
00052 ///
00053 /// If Offsets is non-null, it points to a vector to be filled in
00054 /// with the in-memory offsets of each of the individual values.
00055 ///
00056 void ComputeValueVTs(const TargetLowering &TLI, Type *Ty,
00057                      SmallVectorImpl<EVT> &ValueVTs,
00058                      SmallVectorImpl<uint64_t> *Offsets = nullptr,
00059                      uint64_t StartingOffset = 0);
00060 
00061 /// ExtractTypeInfo - Returns the type info, possibly bitcast, encoded in V.
00062 GlobalVariable *ExtractTypeInfo(Value *V);
00063 
00064 /// hasInlineAsmMemConstraint - Return true if the inline asm instruction being
00065 /// processed uses a memory 'm' constraint.
00066 bool hasInlineAsmMemConstraint(InlineAsm::ConstraintInfoVector &CInfos,
00067                                const TargetLowering &TLI);
00068 
00069 /// getFCmpCondCode - Return the ISD condition code corresponding to
00070 /// the given LLVM IR floating-point condition code.  This includes
00071 /// consideration of global floating-point math flags.
00072 ///
00073 ISD::CondCode getFCmpCondCode(FCmpInst::Predicate Pred);
00074 
00075 /// getFCmpCodeWithoutNaN - Given an ISD condition code comparing floats,
00076 /// return the equivalent code if we're allowed to assume that NaNs won't occur.
00077 ISD::CondCode getFCmpCodeWithoutNaN(ISD::CondCode CC);
00078 
00079 /// getICmpCondCode - Return the ISD condition code corresponding to
00080 /// the given LLVM IR integer condition code.
00081 ///
00082 ISD::CondCode getICmpCondCode(ICmpInst::Predicate Pred);
00083 
00084 /// Test if the given instruction is in a position to be optimized
00085 /// with a tail-call. This roughly means that it's in a block with
00086 /// a return and there's nothing that needs to be scheduled
00087 /// between it and the return.
00088 ///
00089 /// This function only tests target-independent requirements.
00090 bool isInTailCallPosition(ImmutableCallSite CS, const TargetMachine &TM);
00091 
00092 /// Test if given that the input instruction is in the tail call position if the
00093 /// return type or any attributes of the function will inhibit tail call
00094 /// optimization.
00095 bool returnTypeIsEligibleForTailCall(const Function *F,
00096                                      const Instruction *I,
00097                                      const ReturnInst *Ret,
00098                                      const TargetLoweringBase &TLI);
00099 
00100 // True if GV can be left out of the object symbol table. This is the case
00101 // for linkonce_odr values whose address is not significant. While legal, it is
00102 // not normally profitable to omit them from the .o symbol table. Using this
00103 // analysis makes sense when the information can be passed down to the linker
00104 // or we are in LTO.
00105 bool canBeOmittedFromSymbolTable(const GlobalValue *GV);
00106 
00107 } // End llvm namespace
00108 
00109 #endif