LLVM API Documentation
00001 //===-------- llvm/GlobalAlias.h - GlobalAlias class ------------*- 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 contains the declaration of the GlobalAlias class, which 00011 // represents a single function or variable alias in the IR. 00012 // 00013 //===----------------------------------------------------------------------===// 00014 00015 #ifndef LLVM_IR_GLOBALALIAS_H 00016 #define LLVM_IR_GLOBALALIAS_H 00017 00018 #include "llvm/ADT/Twine.h" 00019 #include "llvm/ADT/ilist_node.h" 00020 #include "llvm/IR/GlobalValue.h" 00021 #include "llvm/IR/OperandTraits.h" 00022 00023 namespace llvm { 00024 00025 class Module; 00026 template<typename ValueSubClass, typename ItemParentClass> 00027 class SymbolTableListTraits; 00028 00029 class GlobalAlias : public GlobalValue, public ilist_node<GlobalAlias> { 00030 friend class SymbolTableListTraits<GlobalAlias, Module>; 00031 void operator=(const GlobalAlias &) LLVM_DELETED_FUNCTION; 00032 GlobalAlias(const GlobalAlias &) LLVM_DELETED_FUNCTION; 00033 00034 void setParent(Module *parent); 00035 00036 public: 00037 // allocate space for exactly one operand 00038 void *operator new(size_t s) { 00039 return User::operator new(s, 1); 00040 } 00041 /// GlobalAlias ctor - If a parent module is specified, the alias is 00042 /// automatically inserted into the end of the specified module's alias list. 00043 GlobalAlias(Type *Ty, LinkageTypes Linkage, const Twine &Name = "", 00044 Constant* Aliasee = 0, Module *Parent = 0); 00045 00046 /// Provide fast operand accessors 00047 DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Constant); 00048 00049 /// removeFromParent - This method unlinks 'this' from the containing module, 00050 /// but does not delete it. 00051 /// 00052 virtual void removeFromParent(); 00053 00054 /// eraseFromParent - This method unlinks 'this' from the containing module 00055 /// and deletes it. 00056 /// 00057 virtual void eraseFromParent(); 00058 00059 /// set/getAliasee - These methods retrive and set alias target. 00060 void setAliasee(Constant *GV); 00061 const Constant *getAliasee() const { 00062 return getOperand(0); 00063 } 00064 Constant *getAliasee() { 00065 return getOperand(0); 00066 } 00067 /// getAliasedGlobal() - Aliasee can be either global or bitcast of 00068 /// global. This method retrives the global for both aliasee flavours. 00069 const GlobalValue *getAliasedGlobal() const; 00070 00071 /// resolveAliasedGlobal() - This method tries to ultimately resolve the alias 00072 /// by going through the aliasing chain and trying to find the very last 00073 /// global. Returns NULL if a cycle was found. If stopOnWeak is false, then 00074 /// the whole chain aliasing chain is traversed, otherwise - only strong 00075 /// aliases. 00076 const GlobalValue *resolveAliasedGlobal(bool stopOnWeak = true) const; 00077 00078 // Methods for support type inquiry through isa, cast, and dyn_cast: 00079 static inline bool classof(const Value *V) { 00080 return V->getValueID() == Value::GlobalAliasVal; 00081 } 00082 }; 00083 00084 template <> 00085 struct OperandTraits<GlobalAlias> : 00086 public FixedNumOperandTraits<GlobalAlias, 1> { 00087 }; 00088 00089 DEFINE_TRANSPARENT_OPERAND_ACCESSORS(GlobalAlias, Constant) 00090 00091 } // End llvm namespace 00092 00093 #endif