1207618Srdivacky//===- CodeGen/Analysis.h - CodeGen LLVM IR Analysis Utilities --*- C++ -*-===// 2207618Srdivacky// 3207618Srdivacky// The LLVM Compiler Infrastructure 4207618Srdivacky// 5207618Srdivacky// This file is distributed under the University of Illinois Open Source 6207618Srdivacky// License. See LICENSE.TXT for details. 7207618Srdivacky// 8207618Srdivacky//===----------------------------------------------------------------------===// 9207618Srdivacky// 10207618Srdivacky// This file declares several CodeGen-specific LLVM IR analysis utilties. 11207618Srdivacky// 12207618Srdivacky//===----------------------------------------------------------------------===// 13207618Srdivacky 14207618Srdivacky#ifndef LLVM_CODEGEN_ANALYSIS_H 15207618Srdivacky#define LLVM_CODEGEN_ANALYSIS_H 16207618Srdivacky 17224145Sdim#include "llvm/ADT/ArrayRef.h" 18207618Srdivacky#include "llvm/ADT/SmallVector.h" 19249423Sdim#include "llvm/CodeGen/ISDOpcodes.h" 20207618Srdivacky#include "llvm/CodeGen/ValueTypes.h" 21249423Sdim#include "llvm/IR/InlineAsm.h" 22249423Sdim#include "llvm/IR/Instructions.h" 23207618Srdivacky#include "llvm/Support/CallSite.h" 24207618Srdivacky 25207618Srdivackynamespace llvm { 26207618Srdivacky 27218893Sdimclass GlobalVariable; 28207618Srdivackyclass TargetLowering; 29263508Sdimclass TargetLoweringBase; 30218893Sdimclass SDNode; 31234353Sdimclass SDValue; 32218893Sdimclass SelectionDAG; 33207618Srdivacky 34207618Srdivacky/// ComputeLinearIndex - Given an LLVM IR aggregate type and a sequence 35207618Srdivacky/// of insertvalue or extractvalue indices that identify a member, return 36207618Srdivacky/// the linearized index of the start of the member. 37207618Srdivacky/// 38226633Sdimunsigned ComputeLinearIndex(Type *Ty, 39207618Srdivacky const unsigned *Indices, 40207618Srdivacky const unsigned *IndicesEnd, 41207618Srdivacky unsigned CurIndex = 0); 42207618Srdivacky 43226633Sdiminline unsigned ComputeLinearIndex(Type *Ty, 44224145Sdim ArrayRef<unsigned> Indices, 45224145Sdim unsigned CurIndex = 0) { 46224145Sdim return ComputeLinearIndex(Ty, Indices.begin(), Indices.end(), CurIndex); 47224145Sdim} 48224145Sdim 49207618Srdivacky/// ComputeValueVTs - Given an LLVM IR type, compute a sequence of 50207618Srdivacky/// EVTs that represent all the individual underlying 51207618Srdivacky/// non-aggregate types that comprise it. 52207618Srdivacky/// 53207618Srdivacky/// If Offsets is non-null, it points to a vector to be filled in 54207618Srdivacky/// with the in-memory offsets of each of the individual values. 55207618Srdivacky/// 56226633Sdimvoid ComputeValueVTs(const TargetLowering &TLI, Type *Ty, 57207618Srdivacky SmallVectorImpl<EVT> &ValueVTs, 58207618Srdivacky SmallVectorImpl<uint64_t> *Offsets = 0, 59207618Srdivacky uint64_t StartingOffset = 0); 60207618Srdivacky 61207618Srdivacky/// ExtractTypeInfo - Returns the type info, possibly bitcast, encoded in V. 62207618SrdivackyGlobalVariable *ExtractTypeInfo(Value *V); 63207618Srdivacky 64207618Srdivacky/// hasInlineAsmMemConstraint - Return true if the inline asm instruction being 65207618Srdivacky/// processed uses a memory 'm' constraint. 66218893Sdimbool hasInlineAsmMemConstraint(InlineAsm::ConstraintInfoVector &CInfos, 67207618Srdivacky const TargetLowering &TLI); 68207618Srdivacky 69207618Srdivacky/// getFCmpCondCode - Return the ISD condition code corresponding to 70207618Srdivacky/// the given LLVM IR floating-point condition code. This includes 71207618Srdivacky/// consideration of global floating-point math flags. 72207618Srdivacky/// 73207618SrdivackyISD::CondCode getFCmpCondCode(FCmpInst::Predicate Pred); 74207618Srdivacky 75234353Sdim/// getFCmpCodeWithoutNaN - Given an ISD condition code comparing floats, 76234353Sdim/// return the equivalent code if we're allowed to assume that NaNs won't occur. 77234353SdimISD::CondCode getFCmpCodeWithoutNaN(ISD::CondCode CC); 78234353Sdim 79207618Srdivacky/// getICmpCondCode - Return the ISD condition code corresponding to 80207618Srdivacky/// the given LLVM IR integer condition code. 81207618Srdivacky/// 82207618SrdivackyISD::CondCode getICmpCondCode(ICmpInst::Predicate Pred); 83207618Srdivacky 84207618Srdivacky/// Test if the given instruction is in a position to be optimized 85207618Srdivacky/// with a tail-call. This roughly means that it's in a block with 86207618Srdivacky/// a return and there's nothing that needs to be scheduled 87207618Srdivacky/// between it and the return. 88207618Srdivacky/// 89207618Srdivacky/// This function only tests target-independent requirements. 90249423Sdimbool isInTailCallPosition(ImmutableCallSite CS, const TargetLowering &TLI); 91207618Srdivacky 92263508Sdim/// Test if given that the input instruction is in the tail call position if the 93263508Sdim/// return type or any attributes of the function will inhibit tail call 94263508Sdim/// optimization. 95263508Sdimbool returnTypeIsEligibleForTailCall(const Function *F, 96263508Sdim const Instruction *I, 97263508Sdim const ReturnInst *Ret, 98263508Sdim const TargetLoweringBase &TLI); 99263508Sdim 100207618Srdivacky} // End llvm namespace 101207618Srdivacky 102207618Srdivacky#endif 103