Analysis.h revision 263508
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 utilties. 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/CodeGen/ValueTypes.h" 21#include "llvm/IR/InlineAsm.h" 22#include "llvm/IR/Instructions.h" 23#include "llvm/Support/CallSite.h" 24 25namespace llvm { 26 27class GlobalVariable; 28class TargetLowering; 29class TargetLoweringBase; 30class SDNode; 31class SDValue; 32class SelectionDAG; 33 34/// ComputeLinearIndex - Given an LLVM IR aggregate type and a sequence 35/// of insertvalue or extractvalue indices that identify a member, return 36/// the linearized index of the start of the member. 37/// 38unsigned ComputeLinearIndex(Type *Ty, 39 const unsigned *Indices, 40 const unsigned *IndicesEnd, 41 unsigned CurIndex = 0); 42 43inline unsigned ComputeLinearIndex(Type *Ty, 44 ArrayRef<unsigned> Indices, 45 unsigned CurIndex = 0) { 46 return ComputeLinearIndex(Ty, Indices.begin(), Indices.end(), CurIndex); 47} 48 49/// ComputeValueVTs - Given an LLVM IR type, compute a sequence of 50/// EVTs that represent all the individual underlying 51/// non-aggregate types that comprise it. 52/// 53/// If Offsets is non-null, it points to a vector to be filled in 54/// with the in-memory offsets of each of the individual values. 55/// 56void ComputeValueVTs(const TargetLowering &TLI, Type *Ty, 57 SmallVectorImpl<EVT> &ValueVTs, 58 SmallVectorImpl<uint64_t> *Offsets = 0, 59 uint64_t StartingOffset = 0); 60 61/// ExtractTypeInfo - Returns the type info, possibly bitcast, encoded in V. 62GlobalVariable *ExtractTypeInfo(Value *V); 63 64/// hasInlineAsmMemConstraint - Return true if the inline asm instruction being 65/// processed uses a memory 'm' constraint. 66bool hasInlineAsmMemConstraint(InlineAsm::ConstraintInfoVector &CInfos, 67 const TargetLowering &TLI); 68 69/// getFCmpCondCode - Return the ISD condition code corresponding to 70/// the given LLVM IR floating-point condition code. This includes 71/// consideration of global floating-point math flags. 72/// 73ISD::CondCode getFCmpCondCode(FCmpInst::Predicate Pred); 74 75/// getFCmpCodeWithoutNaN - Given an ISD condition code comparing floats, 76/// return the equivalent code if we're allowed to assume that NaNs won't occur. 77ISD::CondCode getFCmpCodeWithoutNaN(ISD::CondCode CC); 78 79/// getICmpCondCode - Return the ISD condition code corresponding to 80/// the given LLVM IR integer condition code. 81/// 82ISD::CondCode getICmpCondCode(ICmpInst::Predicate Pred); 83 84/// Test if the given instruction is in a position to be optimized 85/// with a tail-call. This roughly means that it's in a block with 86/// a return and there's nothing that needs to be scheduled 87/// between it and the return. 88/// 89/// This function only tests target-independent requirements. 90bool isInTailCallPosition(ImmutableCallSite CS, const TargetLowering &TLI); 91 92/// Test if given that the input instruction is in the tail call position if the 93/// return type or any attributes of the function will inhibit tail call 94/// optimization. 95bool returnTypeIsEligibleForTailCall(const Function *F, 96 const Instruction *I, 97 const ReturnInst *Ret, 98 const TargetLoweringBase &TLI); 99 100} // End llvm namespace 101 102#endif 103