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 utilties.
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/CodeGen/ValueTypes.h"
00021 #include "llvm/IR/InlineAsm.h"
00022 #include "llvm/IR/Instructions.h"
00023 #include "llvm/Support/CallSite.h"
00024 
00025 namespace llvm {
00026 
00027 class GlobalVariable;
00028 class TargetLowering;
00029 class SDNode;
00030 class SDValue;
00031 class SelectionDAG;
00032 
00033 /// ComputeLinearIndex - Given an LLVM IR aggregate type and a sequence
00034 /// of insertvalue or extractvalue indices that identify a member, return
00035 /// the linearized index of the start of the member.
00036 ///
00037 unsigned ComputeLinearIndex(Type *Ty,
00038                             const unsigned *Indices,
00039                             const unsigned *IndicesEnd,
00040                             unsigned CurIndex = 0);
00041 
00042 inline unsigned ComputeLinearIndex(Type *Ty,
00043                                    ArrayRef<unsigned> Indices,
00044                                    unsigned CurIndex = 0) {
00045   return ComputeLinearIndex(Ty, Indices.begin(), Indices.end(), CurIndex);
00046 }
00047 
00048 /// ComputeValueVTs - Given an LLVM IR type, compute a sequence of
00049 /// EVTs that represent all the individual underlying
00050 /// non-aggregate types that comprise it.
00051 ///
00052 /// If Offsets is non-null, it points to a vector to be filled in
00053 /// with the in-memory offsets of each of the individual values.
00054 ///
00055 void ComputeValueVTs(const TargetLowering &TLI, Type *Ty,
00056                      SmallVectorImpl<EVT> &ValueVTs,
00057                      SmallVectorImpl<uint64_t> *Offsets = 0,
00058                      uint64_t StartingOffset = 0);
00059 
00060 /// ExtractTypeInfo - Returns the type info, possibly bitcast, encoded in V.
00061 GlobalVariable *ExtractTypeInfo(Value *V);
00062 
00063 /// hasInlineAsmMemConstraint - Return true if the inline asm instruction being
00064 /// processed uses a memory 'm' constraint.
00065 bool hasInlineAsmMemConstraint(InlineAsm::ConstraintInfoVector &CInfos,
00066                                const TargetLowering &TLI);
00067 
00068 /// getFCmpCondCode - Return the ISD condition code corresponding to
00069 /// the given LLVM IR floating-point condition code.  This includes
00070 /// consideration of global floating-point math flags.
00071 ///
00072 ISD::CondCode getFCmpCondCode(FCmpInst::Predicate Pred);
00073 
00074 /// getFCmpCodeWithoutNaN - Given an ISD condition code comparing floats,
00075 /// return the equivalent code if we're allowed to assume that NaNs won't occur.
00076 ISD::CondCode getFCmpCodeWithoutNaN(ISD::CondCode CC);
00077 
00078 /// getICmpCondCode - Return the ISD condition code corresponding to
00079 /// the given LLVM IR integer condition code.
00080 ///
00081 ISD::CondCode getICmpCondCode(ICmpInst::Predicate Pred);
00082 
00083 /// Test if the given instruction is in a position to be optimized
00084 /// with a tail-call. This roughly means that it's in a block with
00085 /// a return and there's nothing that needs to be scheduled
00086 /// between it and the return.
00087 ///
00088 /// This function only tests target-independent requirements.
00089 bool isInTailCallPosition(ImmutableCallSite CS, const TargetLowering &TLI);
00090 
00091 } // End llvm namespace
00092 
00093 #endif