Analysis.h revision 44ab89eb376af838d1123293a79975aede501464
15eb6d65a27fd77a0bf10bd49f5cccb9f1796d98bDan Gohman//===- CodeGen/Analysis.h - CodeGen LLVM IR Analysis Utilities --*- C++ -*-===// 25eb6d65a27fd77a0bf10bd49f5cccb9f1796d98bDan Gohman// 35eb6d65a27fd77a0bf10bd49f5cccb9f1796d98bDan Gohman// The LLVM Compiler Infrastructure 45eb6d65a27fd77a0bf10bd49f5cccb9f1796d98bDan Gohman// 55eb6d65a27fd77a0bf10bd49f5cccb9f1796d98bDan Gohman// This file is distributed under the University of Illinois Open Source 65eb6d65a27fd77a0bf10bd49f5cccb9f1796d98bDan Gohman// License. See LICENSE.TXT for details. 75eb6d65a27fd77a0bf10bd49f5cccb9f1796d98bDan Gohman// 85eb6d65a27fd77a0bf10bd49f5cccb9f1796d98bDan Gohman//===----------------------------------------------------------------------===// 95eb6d65a27fd77a0bf10bd49f5cccb9f1796d98bDan Gohman// 105eb6d65a27fd77a0bf10bd49f5cccb9f1796d98bDan Gohman// This file declares several CodeGen-specific LLVM IR analysis utilties. 115eb6d65a27fd77a0bf10bd49f5cccb9f1796d98bDan Gohman// 125eb6d65a27fd77a0bf10bd49f5cccb9f1796d98bDan Gohman//===----------------------------------------------------------------------===// 135eb6d65a27fd77a0bf10bd49f5cccb9f1796d98bDan Gohman 145eb6d65a27fd77a0bf10bd49f5cccb9f1796d98bDan Gohman#ifndef LLVM_CODEGEN_ANALYSIS_H 155eb6d65a27fd77a0bf10bd49f5cccb9f1796d98bDan Gohman#define LLVM_CODEGEN_ANALYSIS_H 165eb6d65a27fd77a0bf10bd49f5cccb9f1796d98bDan Gohman 175eb6d65a27fd77a0bf10bd49f5cccb9f1796d98bDan Gohman#include "llvm/Instructions.h" 185eb6d65a27fd77a0bf10bd49f5cccb9f1796d98bDan Gohman#include "llvm/InlineAsm.h" 195eb6d65a27fd77a0bf10bd49f5cccb9f1796d98bDan Gohman#include "llvm/ADT/SmallVector.h" 205eb6d65a27fd77a0bf10bd49f5cccb9f1796d98bDan Gohman#include "llvm/CodeGen/ValueTypes.h" 215eb6d65a27fd77a0bf10bd49f5cccb9f1796d98bDan Gohman#include "llvm/CodeGen/ISDOpcodes.h" 225eb6d65a27fd77a0bf10bd49f5cccb9f1796d98bDan Gohman#include "llvm/Support/CallSite.h" 235eb6d65a27fd77a0bf10bd49f5cccb9f1796d98bDan Gohman 245eb6d65a27fd77a0bf10bd49f5cccb9f1796d98bDan Gohmannamespace llvm { 255eb6d65a27fd77a0bf10bd49f5cccb9f1796d98bDan Gohman 265eb6d65a27fd77a0bf10bd49f5cccb9f1796d98bDan Gohmanclass TargetLowering; 275eb6d65a27fd77a0bf10bd49f5cccb9f1796d98bDan Gohmanclass GlobalVariable; 285eb6d65a27fd77a0bf10bd49f5cccb9f1796d98bDan Gohman 295eb6d65a27fd77a0bf10bd49f5cccb9f1796d98bDan Gohman/// ComputeLinearIndex - Given an LLVM IR aggregate type and a sequence 305eb6d65a27fd77a0bf10bd49f5cccb9f1796d98bDan Gohman/// of insertvalue or extractvalue indices that identify a member, return 315eb6d65a27fd77a0bf10bd49f5cccb9f1796d98bDan Gohman/// the linearized index of the start of the member. 325eb6d65a27fd77a0bf10bd49f5cccb9f1796d98bDan Gohman/// 330dadb15927b912c98918e8a9e7466af77062149fDan Gohmanunsigned ComputeLinearIndex(const Type *Ty, 345eb6d65a27fd77a0bf10bd49f5cccb9f1796d98bDan Gohman const unsigned *Indices, 355eb6d65a27fd77a0bf10bd49f5cccb9f1796d98bDan Gohman const unsigned *IndicesEnd, 365eb6d65a27fd77a0bf10bd49f5cccb9f1796d98bDan Gohman unsigned CurIndex = 0); 375eb6d65a27fd77a0bf10bd49f5cccb9f1796d98bDan Gohman 385eb6d65a27fd77a0bf10bd49f5cccb9f1796d98bDan Gohman/// ComputeValueVTs - Given an LLVM IR type, compute a sequence of 395eb6d65a27fd77a0bf10bd49f5cccb9f1796d98bDan Gohman/// EVTs that represent all the individual underlying 405eb6d65a27fd77a0bf10bd49f5cccb9f1796d98bDan Gohman/// non-aggregate types that comprise it. 415eb6d65a27fd77a0bf10bd49f5cccb9f1796d98bDan Gohman/// 425eb6d65a27fd77a0bf10bd49f5cccb9f1796d98bDan Gohman/// If Offsets is non-null, it points to a vector to be filled in 435eb6d65a27fd77a0bf10bd49f5cccb9f1796d98bDan Gohman/// with the in-memory offsets of each of the individual values. 445eb6d65a27fd77a0bf10bd49f5cccb9f1796d98bDan Gohman/// 455eb6d65a27fd77a0bf10bd49f5cccb9f1796d98bDan Gohmanvoid ComputeValueVTs(const TargetLowering &TLI, const Type *Ty, 465eb6d65a27fd77a0bf10bd49f5cccb9f1796d98bDan Gohman SmallVectorImpl<EVT> &ValueVTs, 475eb6d65a27fd77a0bf10bd49f5cccb9f1796d98bDan Gohman SmallVectorImpl<uint64_t> *Offsets = 0, 485eb6d65a27fd77a0bf10bd49f5cccb9f1796d98bDan Gohman uint64_t StartingOffset = 0); 495eb6d65a27fd77a0bf10bd49f5cccb9f1796d98bDan Gohman 505eb6d65a27fd77a0bf10bd49f5cccb9f1796d98bDan Gohman/// ExtractTypeInfo - Returns the type info, possibly bitcast, encoded in V. 515eb6d65a27fd77a0bf10bd49f5cccb9f1796d98bDan GohmanGlobalVariable *ExtractTypeInfo(Value *V); 525eb6d65a27fd77a0bf10bd49f5cccb9f1796d98bDan Gohman 535eb6d65a27fd77a0bf10bd49f5cccb9f1796d98bDan Gohman/// hasInlineAsmMemConstraint - Return true if the inline asm instruction being 545eb6d65a27fd77a0bf10bd49f5cccb9f1796d98bDan Gohman/// processed uses a memory 'm' constraint. 5544ab89eb376af838d1123293a79975aede501464John Thompsonbool hasInlineAsmMemConstraint(InlineAsm::ConstraintInfoVector &CInfos, 565eb6d65a27fd77a0bf10bd49f5cccb9f1796d98bDan Gohman const TargetLowering &TLI); 575eb6d65a27fd77a0bf10bd49f5cccb9f1796d98bDan Gohman 585eb6d65a27fd77a0bf10bd49f5cccb9f1796d98bDan Gohman/// getFCmpCondCode - Return the ISD condition code corresponding to 595eb6d65a27fd77a0bf10bd49f5cccb9f1796d98bDan Gohman/// the given LLVM IR floating-point condition code. This includes 605eb6d65a27fd77a0bf10bd49f5cccb9f1796d98bDan Gohman/// consideration of global floating-point math flags. 615eb6d65a27fd77a0bf10bd49f5cccb9f1796d98bDan Gohman/// 625eb6d65a27fd77a0bf10bd49f5cccb9f1796d98bDan GohmanISD::CondCode getFCmpCondCode(FCmpInst::Predicate Pred); 635eb6d65a27fd77a0bf10bd49f5cccb9f1796d98bDan Gohman 645eb6d65a27fd77a0bf10bd49f5cccb9f1796d98bDan Gohman/// getICmpCondCode - Return the ISD condition code corresponding to 655eb6d65a27fd77a0bf10bd49f5cccb9f1796d98bDan Gohman/// the given LLVM IR integer condition code. 665eb6d65a27fd77a0bf10bd49f5cccb9f1796d98bDan Gohman/// 675eb6d65a27fd77a0bf10bd49f5cccb9f1796d98bDan GohmanISD::CondCode getICmpCondCode(ICmpInst::Predicate Pred); 685eb6d65a27fd77a0bf10bd49f5cccb9f1796d98bDan Gohman 695eb6d65a27fd77a0bf10bd49f5cccb9f1796d98bDan Gohman/// Test if the given instruction is in a position to be optimized 705eb6d65a27fd77a0bf10bd49f5cccb9f1796d98bDan Gohman/// with a tail-call. This roughly means that it's in a block with 715eb6d65a27fd77a0bf10bd49f5cccb9f1796d98bDan Gohman/// a return and there's nothing that needs to be scheduled 725eb6d65a27fd77a0bf10bd49f5cccb9f1796d98bDan Gohman/// between it and the return. 735eb6d65a27fd77a0bf10bd49f5cccb9f1796d98bDan Gohman/// 745eb6d65a27fd77a0bf10bd49f5cccb9f1796d98bDan Gohman/// This function only tests target-independent requirements. 755eb6d65a27fd77a0bf10bd49f5cccb9f1796d98bDan Gohmanbool isInTailCallPosition(ImmutableCallSite CS, Attributes CalleeRetAttr, 765eb6d65a27fd77a0bf10bd49f5cccb9f1796d98bDan Gohman const TargetLowering &TLI); 775eb6d65a27fd77a0bf10bd49f5cccb9f1796d98bDan Gohman 785eb6d65a27fd77a0bf10bd49f5cccb9f1796d98bDan Gohman} // End llvm namespace 795eb6d65a27fd77a0bf10bd49f5cccb9f1796d98bDan Gohman 805eb6d65a27fd77a0bf10bd49f5cccb9f1796d98bDan Gohman#endif 81