2002-09-06 20:47:31 +00:00
|
|
|
//===-- llvm/Function.h - Class to represent a single function --*- C++ -*-===//
|
2005-04-21 20:19:05 +00:00
|
|
|
//
|
2003-10-20 20:19:47 +00:00
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
2007-12-29 19:59:42 +00:00
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
2005-04-21 20:19:05 +00:00
|
|
|
//
|
2003-10-20 20:19:47 +00:00
|
|
|
//===----------------------------------------------------------------------===//
|
2001-06-06 20:29:01 +00:00
|
|
|
//
|
2005-04-21 20:19:05 +00:00
|
|
|
// This file contains the declaration of the Function class, which represents a
|
2002-09-06 20:47:31 +00:00
|
|
|
// single function/procedure in LLVM.
|
2001-06-06 20:29:01 +00:00
|
|
|
//
|
2002-09-06 20:47:31 +00:00
|
|
|
// A function basically consists of a list of basic blocks, a list of arguments,
|
|
|
|
// and a symbol table.
|
2001-06-06 20:29:01 +00:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2002-03-23 22:47:28 +00:00
|
|
|
#ifndef LLVM_FUNCTION_H
|
|
|
|
#define LLVM_FUNCTION_H
|
2001-06-06 20:29:01 +00:00
|
|
|
|
2001-10-03 14:53:21 +00:00
|
|
|
#include "llvm/GlobalValue.h"
|
2002-06-25 16:12:52 +00:00
|
|
|
#include "llvm/BasicBlock.h"
|
|
|
|
#include "llvm/Argument.h"
|
2004-09-01 22:55:40 +00:00
|
|
|
#include "llvm/Support/Annotation.h"
|
2008-02-19 21:38:47 +00:00
|
|
|
#include "llvm/ParameterAttributes.h"
|
2001-06-06 20:29:01 +00:00
|
|
|
|
2003-11-11 22:41:34 +00:00
|
|
|
namespace llvm {
|
|
|
|
|
2002-03-29 03:30:59 +00:00
|
|
|
class FunctionType;
|
2001-06-06 20:29:01 +00:00
|
|
|
|
2002-06-25 16:12:52 +00:00
|
|
|
// Traits for intrusive list of instructions...
|
|
|
|
template<> struct ilist_traits<BasicBlock>
|
2007-04-17 03:26:42 +00:00
|
|
|
: public SymbolTableListTraits<BasicBlock, Function> {
|
2002-06-25 16:12:52 +00:00
|
|
|
|
2005-01-30 00:09:23 +00:00
|
|
|
// createSentinel is used to create a node that marks the end of the list...
|
|
|
|
static BasicBlock *createSentinel();
|
|
|
|
static void destroySentinel(BasicBlock *BB) { delete BB; }
|
2002-06-25 16:12:52 +00:00
|
|
|
static iplist<BasicBlock> &getList(Function *F);
|
2007-04-17 03:26:42 +00:00
|
|
|
static ValueSymbolTable *getSymTab(Function *ItemParent);
|
2007-04-17 04:04:14 +00:00
|
|
|
static int getListOffset();
|
2002-06-25 16:12:52 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
template<> struct ilist_traits<Argument>
|
2007-04-17 03:26:42 +00:00
|
|
|
: public SymbolTableListTraits<Argument, Function> {
|
2002-06-25 16:12:52 +00:00
|
|
|
|
2005-01-30 00:09:23 +00:00
|
|
|
// createSentinel is used to create a node that marks the end of the list...
|
|
|
|
static Argument *createSentinel();
|
|
|
|
static void destroySentinel(Argument *A) { delete A; }
|
2002-06-25 16:12:52 +00:00
|
|
|
static iplist<Argument> &getList(Function *F);
|
2007-04-17 03:26:42 +00:00
|
|
|
static ValueSymbolTable *getSymTab(Function *ItemParent);
|
2007-04-17 04:04:14 +00:00
|
|
|
static int getListOffset();
|
2002-06-25 16:12:52 +00:00
|
|
|
};
|
|
|
|
|
2004-02-26 08:08:38 +00:00
|
|
|
class Function : public GlobalValue, public Annotable {
|
2001-06-06 20:29:01 +00:00
|
|
|
public:
|
2002-06-25 16:12:52 +00:00
|
|
|
typedef iplist<Argument> ArgumentListType;
|
|
|
|
typedef iplist<BasicBlock> BasicBlockListType;
|
2001-06-27 23:26:41 +00:00
|
|
|
|
|
|
|
// BasicBlock iterators...
|
2002-06-25 16:12:52 +00:00
|
|
|
typedef BasicBlockListType::iterator iterator;
|
|
|
|
typedef BasicBlockListType::const_iterator const_iterator;
|
2001-06-27 23:26:41 +00:00
|
|
|
|
2005-03-14 23:49:40 +00:00
|
|
|
typedef ArgumentListType::iterator arg_iterator;
|
|
|
|
typedef ArgumentListType::const_iterator const_arg_iterator;
|
2002-06-25 16:12:52 +00:00
|
|
|
|
2001-06-06 20:29:01 +00:00
|
|
|
private:
|
2002-04-28 04:44:40 +00:00
|
|
|
// Important things that make up a function!
|
2007-08-18 06:14:52 +00:00
|
|
|
BasicBlockListType BasicBlocks; ///< The basic blocks
|
|
|
|
mutable ArgumentListType ArgumentList; ///< The formal arguments
|
|
|
|
ValueSymbolTable *SymTab; ///< Symbol table of args/instructions
|
2008-03-12 17:45:29 +00:00
|
|
|
PAListPtr ParamAttrs; ///< Parameter attributes
|
2007-04-17 04:31:29 +00:00
|
|
|
|
|
|
|
// The Calling Convention is stored in Value::SubclassData.
|
|
|
|
/*unsigned CallingConvention;*/
|
2005-04-21 20:19:05 +00:00
|
|
|
|
2007-04-17 03:26:42 +00:00
|
|
|
friend class SymbolTableListTraits<Function, Module>;
|
2002-06-25 16:12:52 +00:00
|
|
|
|
2001-06-06 20:29:01 +00:00
|
|
|
void setParent(Module *parent);
|
2002-06-25 16:12:52 +00:00
|
|
|
Function *Prev, *Next;
|
|
|
|
void setNext(Function *N) { Next = N; }
|
|
|
|
void setPrev(Function *N) { Prev = N; }
|
2001-06-06 20:29:01 +00:00
|
|
|
|
2007-04-28 13:45:00 +00:00
|
|
|
// getNext/Prev - Return the next or previous function in the list. These
|
|
|
|
// methods should never be used directly, and are only used to implement the
|
|
|
|
// function list as part of the module.
|
|
|
|
//
|
|
|
|
Function *getNext() { return Next; }
|
|
|
|
const Function *getNext() const { return Next; }
|
|
|
|
Function *getPrev() { return Prev; }
|
|
|
|
const Function *getPrev() const { return Prev; }
|
|
|
|
|
2007-08-18 06:14:52 +00:00
|
|
|
/// hasLazyArguments/CheckLazyArguments - The argument list of a function is
|
|
|
|
/// built on demand, so that the list isn't allocated until the first client
|
|
|
|
/// needs it. The hasLazyArguments predicate returns true if the arg list
|
|
|
|
/// hasn't been set up yet.
|
|
|
|
bool hasLazyArguments() const {
|
|
|
|
return SubclassData & 1;
|
|
|
|
}
|
|
|
|
void CheckLazyArguments() const {
|
|
|
|
if (hasLazyArguments())
|
|
|
|
BuildLazyArguments();
|
|
|
|
}
|
|
|
|
void BuildLazyArguments() const;
|
2008-01-03 00:09:47 +00:00
|
|
|
|
|
|
|
Function(const Function&); // DO NOT IMPLEMENT
|
|
|
|
void operator=(const Function&); // DO NOT IMPLEMENT
|
2008-04-06 20:25:17 +00:00
|
|
|
|
2002-09-06 20:47:31 +00:00
|
|
|
/// Function ctor - If the (optional) Module argument is specified, the
|
|
|
|
/// function is automatically inserted into the end of the function list for
|
|
|
|
/// the module.
|
|
|
|
///
|
2003-04-16 20:28:45 +00:00
|
|
|
Function(const FunctionType *Ty, LinkageTypes Linkage,
|
|
|
|
const std::string &N = "", Module *M = 0);
|
2008-04-06 20:25:17 +00:00
|
|
|
|
|
|
|
public:
|
|
|
|
static Function *Create(const FunctionType *Ty, LinkageTypes Linkage,
|
|
|
|
const std::string &N = "", Module *M = 0) {
|
|
|
|
return new(0) Function(Ty, Linkage, N, M);
|
|
|
|
}
|
|
|
|
|
2007-12-10 02:14:30 +00:00
|
|
|
~Function();
|
2001-06-06 20:29:01 +00:00
|
|
|
|
2002-03-29 03:30:59 +00:00
|
|
|
const Type *getReturnType() const; // Return the type of the ret val
|
|
|
|
const FunctionType *getFunctionType() const; // Return the FunctionType for me
|
2001-06-06 20:29:01 +00:00
|
|
|
|
2005-01-07 07:40:32 +00:00
|
|
|
/// isVarArg - Return true if this function takes a variable number of
|
|
|
|
/// arguments.
|
|
|
|
bool isVarArg() const;
|
|
|
|
|
2007-01-30 20:08:39 +00:00
|
|
|
/// isDeclaration - Is the body of this function unknown? (The basic block
|
|
|
|
/// list is empty if so.) This is true for function declarations, but not
|
|
|
|
/// true for function definitions.
|
2002-08-25 22:54:55 +00:00
|
|
|
///
|
2007-01-30 20:08:39 +00:00
|
|
|
virtual bool isDeclaration() const { return BasicBlocks.empty(); }
|
2001-06-06 20:29:01 +00:00
|
|
|
|
2003-05-08 03:34:12 +00:00
|
|
|
/// getIntrinsicID - This method returns the ID number of the specified
|
2003-11-11 22:41:34 +00:00
|
|
|
/// function, or Intrinsic::not_intrinsic if the function is not an
|
2003-05-08 03:34:12 +00:00
|
|
|
/// instrinsic, or if the pointer is null. This value is always defined to be
|
|
|
|
/// zero to allow easy checking for whether a function is intrinsic or not.
|
|
|
|
/// The particular intrinsic functions which correspond to this value are
|
|
|
|
/// defined in llvm/Intrinsics.h.
|
|
|
|
///
|
2007-04-16 06:54:34 +00:00
|
|
|
unsigned getIntrinsicID(bool noAssert = false) const;
|
2003-05-08 03:34:12 +00:00
|
|
|
bool isIntrinsic() const { return getIntrinsicID() != 0; }
|
|
|
|
|
2005-05-06 20:26:26 +00:00
|
|
|
/// getCallingConv()/setCallingConv(uint) - These method get and set the
|
|
|
|
/// calling convention of this function. The enum values for the known
|
|
|
|
/// calling conventions are defined in CallingConv.h.
|
2007-08-18 06:14:52 +00:00
|
|
|
unsigned getCallingConv() const { return SubclassData >> 1; }
|
|
|
|
void setCallingConv(unsigned CC) {
|
2007-08-20 21:31:08 +00:00
|
|
|
SubclassData = (SubclassData & 1) | (CC << 1);
|
2007-08-18 06:14:52 +00:00
|
|
|
}
|
|
|
|
|
2008-03-13 04:33:03 +00:00
|
|
|
/// getParamAttrs - Return the parameter attributes for this Function.
|
|
|
|
///
|
2008-03-12 17:45:29 +00:00
|
|
|
const PAListPtr &getParamAttrs() const { return ParamAttrs; }
|
|
|
|
|
|
|
|
/// setParamAttrs - Set the parameter attributes for this Function.
|
2008-03-13 04:33:03 +00:00
|
|
|
///
|
2008-03-12 17:45:29 +00:00
|
|
|
void setParamAttrs(const PAListPtr &attrs) { ParamAttrs = attrs; }
|
2007-11-27 13:23:08 +00:00
|
|
|
|
2007-12-10 03:18:06 +00:00
|
|
|
/// hasCollector/getCollector/setCollector/clearCollector - The name of the
|
|
|
|
/// garbage collection algorithm to use during code generation.
|
|
|
|
bool hasCollector() const;
|
|
|
|
const char *getCollector() const;
|
|
|
|
void setCollector(const char *Str);
|
|
|
|
void clearCollector();
|
|
|
|
|
2007-11-28 17:07:01 +00:00
|
|
|
/// @brief Determine whether the function has the given attribute.
|
2008-03-13 05:00:21 +00:00
|
|
|
bool paramHasAttr(unsigned i, ParameterAttributes attr) const {
|
|
|
|
return ParamAttrs.paramHasAttr(i, attr);
|
|
|
|
}
|
2008-05-16 20:39:43 +00:00
|
|
|
|
|
|
|
/// addParamAttr - adds the attribute to the list of attributes.
|
|
|
|
void addParamAttr(unsigned i, ParameterAttributes attr);
|
2008-01-02 23:42:30 +00:00
|
|
|
|
2008-07-08 09:41:30 +00:00
|
|
|
/// removeParamAttr - removes the attribute from the list of attributes.
|
|
|
|
void removeParamAttr(unsigned i, ParameterAttributes attr);
|
|
|
|
|
2008-02-22 17:49:45 +00:00
|
|
|
/// @brief Extract the alignment for a call or parameter (0=unknown).
|
2008-03-13 05:00:21 +00:00
|
|
|
unsigned getParamAlignment(unsigned i) const {
|
|
|
|
return ParamAttrs.getParamAlignment(i);
|
|
|
|
}
|
2008-02-22 17:49:45 +00:00
|
|
|
|
2007-12-03 20:06:50 +00:00
|
|
|
/// @brief Determine if the function does not access memory.
|
2008-03-13 05:00:21 +00:00
|
|
|
bool doesNotAccessMemory() const {
|
|
|
|
return paramHasAttr(0, ParamAttr::ReadNone);
|
|
|
|
}
|
2008-07-08 09:41:30 +00:00
|
|
|
void setDoesNotAccessMemory(bool doesNotAccessMemory = true) {
|
|
|
|
if (doesNotAccessMemory) addParamAttr(0, ParamAttr::ReadNone);
|
|
|
|
else removeParamAttr(0, ParamAttr::ReadNone);
|
|
|
|
}
|
2007-12-03 20:06:50 +00:00
|
|
|
|
|
|
|
/// @brief Determine if the function does not access or only reads memory.
|
2008-03-13 05:00:21 +00:00
|
|
|
bool onlyReadsMemory() const {
|
|
|
|
return doesNotAccessMemory() || paramHasAttr(0, ParamAttr::ReadOnly);
|
|
|
|
}
|
2008-07-08 09:41:30 +00:00
|
|
|
void setOnlyReadsMemory(bool onlyReadsMemory = true) {
|
|
|
|
if (onlyReadsMemory) addParamAttr(0, ParamAttr::ReadOnly);
|
|
|
|
else removeParamAttr(0, ParamAttr::ReadOnly | ParamAttr::ReadNone);
|
|
|
|
}
|
|
|
|
|
|
|
|
/// @brief Determine if the function cannot return.
|
|
|
|
bool doesNotReturn() const {
|
|
|
|
return paramHasAttr(0, ParamAttr::NoReturn);
|
|
|
|
}
|
|
|
|
void setDoesNotReturn(bool doesNotReturn = true) {
|
|
|
|
if (doesNotReturn) addParamAttr(0, ParamAttr::NoReturn);
|
|
|
|
else removeParamAttr(0, ParamAttr::NoReturn);
|
|
|
|
}
|
|
|
|
|
|
|
|
/// @brief Determine if the function cannot unwind.
|
|
|
|
bool doesNotThrow() const {
|
|
|
|
return paramHasAttr(0, ParamAttr::NoUnwind);
|
|
|
|
}
|
|
|
|
void setDoesNotThrow(bool doesNotThrow = true) {
|
|
|
|
if (doesNotThrow) addParamAttr(0, ParamAttr::NoUnwind);
|
|
|
|
else removeParamAttr(0, ParamAttr::NoUnwind);
|
|
|
|
}
|
2007-12-03 20:06:50 +00:00
|
|
|
|
2008-03-03 21:46:28 +00:00
|
|
|
/// @brief Determine if the function returns a structure through first
|
|
|
|
/// pointer argument.
|
2008-03-13 05:00:21 +00:00
|
|
|
bool hasStructRetAttr() const {
|
|
|
|
return paramHasAttr(1, ParamAttr::StructRet);
|
|
|
|
}
|
2007-04-09 15:01:12 +00:00
|
|
|
|
2008-05-26 19:58:59 +00:00
|
|
|
/// copyAttributesFrom - copy all additional attributes (those not needed to
|
|
|
|
/// create a Function) from the Function Src to this one.
|
|
|
|
void copyAttributesFrom(const GlobalValue *Src);
|
|
|
|
|
2003-09-17 04:58:43 +00:00
|
|
|
/// deleteBody - This method deletes the body of the function, and converts
|
|
|
|
/// the linkage to external.
|
2004-03-01 18:31:19 +00:00
|
|
|
///
|
2003-09-17 04:58:43 +00:00
|
|
|
void deleteBody() {
|
|
|
|
dropAllReferences();
|
|
|
|
setLinkage(ExternalLinkage);
|
|
|
|
}
|
|
|
|
|
2004-10-11 22:21:13 +00:00
|
|
|
/// removeFromParent - This method unlinks 'this' from the containing module,
|
|
|
|
/// but does not delete it.
|
|
|
|
///
|
2007-04-29 18:02:48 +00:00
|
|
|
void removeFromParent();
|
2004-10-11 22:21:13 +00:00
|
|
|
|
|
|
|
/// eraseFromParent - This method unlinks 'this' from the containing module
|
|
|
|
/// and deletes it.
|
|
|
|
///
|
2007-04-29 18:02:48 +00:00
|
|
|
void eraseFromParent();
|
2004-10-11 22:21:13 +00:00
|
|
|
|
|
|
|
|
2003-05-09 22:16:18 +00:00
|
|
|
/// Get the underlying elements of the Function... the basic block list is
|
|
|
|
/// empty for external functions.
|
2002-08-25 22:54:55 +00:00
|
|
|
///
|
2007-08-18 06:14:52 +00:00
|
|
|
const ArgumentListType &getArgumentList() const {
|
|
|
|
CheckLazyArguments();
|
|
|
|
return ArgumentList;
|
|
|
|
}
|
|
|
|
ArgumentListType &getArgumentList() {
|
|
|
|
CheckLazyArguments();
|
|
|
|
return ArgumentList;
|
|
|
|
}
|
2001-06-27 23:26:41 +00:00
|
|
|
|
2002-06-25 16:12:52 +00:00
|
|
|
const BasicBlockListType &getBasicBlockList() const { return BasicBlocks; }
|
|
|
|
BasicBlockListType &getBasicBlockList() { return BasicBlocks; }
|
2001-06-06 20:29:01 +00:00
|
|
|
|
2003-09-20 14:36:49 +00:00
|
|
|
const BasicBlock &getEntryBlock() const { return front(); }
|
|
|
|
BasicBlock &getEntryBlock() { return front(); }
|
2002-04-28 04:44:40 +00:00
|
|
|
|
|
|
|
//===--------------------------------------------------------------------===//
|
|
|
|
// Symbol Table Accessing functions...
|
|
|
|
|
2002-11-20 18:07:48 +00:00
|
|
|
/// getSymbolTable() - Return the symbol table...
|
2002-08-25 22:54:55 +00:00
|
|
|
///
|
2007-02-05 20:47:22 +00:00
|
|
|
inline ValueSymbolTable &getValueSymbolTable() { return *SymTab; }
|
|
|
|
inline const ValueSymbolTable &getValueSymbolTable() const { return *SymTab; }
|
2002-04-28 04:44:40 +00:00
|
|
|
|
2005-04-21 20:19:05 +00:00
|
|
|
|
2001-06-27 23:26:41 +00:00
|
|
|
//===--------------------------------------------------------------------===//
|
|
|
|
// BasicBlock iterator forwarding functions
|
|
|
|
//
|
2002-06-25 16:12:52 +00:00
|
|
|
iterator begin() { return BasicBlocks.begin(); }
|
|
|
|
const_iterator begin() const { return BasicBlocks.begin(); }
|
|
|
|
iterator end () { return BasicBlocks.end(); }
|
|
|
|
const_iterator end () const { return BasicBlocks.end(); }
|
|
|
|
|
2004-11-15 19:02:35 +00:00
|
|
|
size_t size() const { return BasicBlocks.size(); }
|
2002-06-25 16:12:52 +00:00
|
|
|
bool empty() const { return BasicBlocks.empty(); }
|
|
|
|
const BasicBlock &front() const { return BasicBlocks.front(); }
|
|
|
|
BasicBlock &front() { return BasicBlocks.front(); }
|
2004-10-19 05:50:34 +00:00
|
|
|
const BasicBlock &back() const { return BasicBlocks.back(); }
|
|
|
|
BasicBlock &back() { return BasicBlocks.back(); }
|
2002-06-25 16:12:52 +00:00
|
|
|
|
|
|
|
//===--------------------------------------------------------------------===//
|
|
|
|
// Argument iterator forwarding functions
|
|
|
|
//
|
2007-08-18 06:14:52 +00:00
|
|
|
arg_iterator arg_begin() {
|
|
|
|
CheckLazyArguments();
|
|
|
|
return ArgumentList.begin();
|
|
|
|
}
|
|
|
|
const_arg_iterator arg_begin() const {
|
|
|
|
CheckLazyArguments();
|
|
|
|
return ArgumentList.begin();
|
|
|
|
}
|
|
|
|
arg_iterator arg_end() {
|
|
|
|
CheckLazyArguments();
|
|
|
|
return ArgumentList.end();
|
|
|
|
}
|
|
|
|
const_arg_iterator arg_end() const {
|
|
|
|
CheckLazyArguments();
|
|
|
|
return ArgumentList.end();
|
|
|
|
}
|
2005-03-14 23:49:40 +00:00
|
|
|
|
2007-08-18 06:14:52 +00:00
|
|
|
size_t arg_size() const;
|
|
|
|
bool arg_empty() const;
|
2005-03-14 23:49:40 +00:00
|
|
|
|
2003-10-30 23:41:19 +00:00
|
|
|
virtual void print(std::ostream &OS) const { print(OS, 0); }
|
2006-12-17 05:15:13 +00:00
|
|
|
void print(std::ostream *OS) const { if (OS) print(*OS); }
|
2003-10-30 23:41:19 +00:00
|
|
|
void print(std::ostream &OS, AssemblyAnnotationWriter *AAW) const;
|
2001-06-06 20:29:01 +00:00
|
|
|
|
2003-10-22 16:03:20 +00:00
|
|
|
/// viewCFG - This function is meant for use from the debugger. You can just
|
|
|
|
/// say 'call F->viewCFG()' and a ghostview window should pop up from the
|
|
|
|
/// program, displaying the CFG of the current function with the code for each
|
|
|
|
/// basic block inside. This depends on there being a 'dot' and 'gv' program
|
|
|
|
/// in your path.
|
|
|
|
///
|
|
|
|
void viewCFG() const;
|
2005-04-21 20:19:05 +00:00
|
|
|
|
2003-10-22 16:03:20 +00:00
|
|
|
/// viewCFGOnly - This function is meant for use from the debugger. It works
|
|
|
|
/// just like viewCFG, but it does not include the contents of basic blocks
|
2004-03-01 18:31:19 +00:00
|
|
|
/// into the nodes, just the label. If you are only interested in the CFG
|
|
|
|
/// this can make the graph smaller.
|
2003-10-22 16:03:20 +00:00
|
|
|
///
|
|
|
|
void viewCFGOnly() const;
|
|
|
|
|
2002-08-25 22:54:55 +00:00
|
|
|
/// Methods for support type inquiry through isa, cast, and dyn_cast:
|
2002-03-23 22:47:28 +00:00
|
|
|
static inline bool classof(const Function *) { return true; }
|
2001-10-02 03:41:24 +00:00
|
|
|
static inline bool classof(const Value *V) {
|
2007-04-13 18:12:09 +00:00
|
|
|
return V->getValueID() == Value::FunctionVal;
|
2001-10-01 16:18:37 +00:00
|
|
|
}
|
2001-06-06 20:29:01 +00:00
|
|
|
|
2003-09-17 04:58:43 +00:00
|
|
|
/// dropAllReferences() - This method causes all the subinstructions to "let
|
2002-08-25 22:54:55 +00:00
|
|
|
/// go" of all references that they are maintaining. This allows one to
|
2003-09-17 04:58:43 +00:00
|
|
|
/// 'delete' a whole module at a time, even though there may be circular
|
2002-08-25 22:54:55 +00:00
|
|
|
/// references... first all references are dropped, and all use counts go to
|
2004-03-01 18:31:19 +00:00
|
|
|
/// zero. Then everything is deleted for real. Note that no operations are
|
2005-04-21 20:19:05 +00:00
|
|
|
/// valid on an object that has "dropped all references", except operator
|
2002-08-25 22:54:55 +00:00
|
|
|
/// delete.
|
|
|
|
///
|
2003-09-17 04:58:43 +00:00
|
|
|
/// Since no other object in the module can have references into the body of a
|
|
|
|
/// function, dropping all references deletes the entire body of the function,
|
|
|
|
/// including any contained basic blocks.
|
|
|
|
///
|
2001-06-06 20:29:01 +00:00
|
|
|
void dropAllReferences();
|
2007-04-17 04:04:14 +00:00
|
|
|
|
|
|
|
static unsigned getBasicBlockListOffset() {
|
|
|
|
Function *Obj = 0;
|
2007-04-17 05:33:04 +00:00
|
|
|
return unsigned(reinterpret_cast<uintptr_t>(&Obj->BasicBlocks));
|
2007-04-17 04:04:14 +00:00
|
|
|
}
|
|
|
|
static unsigned getArgumentListOffset() {
|
|
|
|
Function *Obj = 0;
|
2007-04-17 05:33:04 +00:00
|
|
|
return unsigned(reinterpret_cast<uintptr_t>(&Obj->ArgumentList));
|
2007-04-17 04:04:14 +00:00
|
|
|
}
|
2001-09-28 22:56:31 +00:00
|
|
|
};
|
|
|
|
|
2007-04-17 03:26:42 +00:00
|
|
|
inline ValueSymbolTable *
|
|
|
|
ilist_traits<BasicBlock>::getSymTab(Function *F) {
|
|
|
|
return F ? &F->getValueSymbolTable() : 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline ValueSymbolTable *
|
|
|
|
ilist_traits<Argument>::getSymTab(Function *F) {
|
|
|
|
return F ? &F->getValueSymbolTable() : 0;
|
|
|
|
}
|
|
|
|
|
2007-04-17 04:04:14 +00:00
|
|
|
inline int
|
|
|
|
ilist_traits<BasicBlock>::getListOffset() {
|
|
|
|
return Function::getBasicBlockListOffset();
|
|
|
|
}
|
|
|
|
|
|
|
|
inline int
|
|
|
|
ilist_traits<Argument>::getListOffset() {
|
|
|
|
return Function::getArgumentListOffset();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-11-11 22:41:34 +00:00
|
|
|
} // End llvm namespace
|
|
|
|
|
2001-06-06 20:29:01 +00:00
|
|
|
#endif
|