Counter Strike : Global Offensive Source Code
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

94 lines
3.1 KiB

  1. //===-------- llvm/GlobalAlias.h - GlobalAlias class ------------*- C++ -*-===//
  2. //
  3. // The LLVM Compiler Infrastructure
  4. //
  5. // This file is distributed under the University of Illinois Open Source
  6. // License. See LICENSE.TXT for details.
  7. //
  8. //===----------------------------------------------------------------------===//
  9. //
  10. // This file contains the declaration of the GlobalAlias class, which
  11. // represents a single function or variable alias in the IR.
  12. //
  13. //===----------------------------------------------------------------------===//
  14. #ifndef LLVM_GLOBAL_ALIAS_H
  15. #define LLVM_GLOBAL_ALIAS_H
  16. #include "llvm/GlobalValue.h"
  17. #include "llvm/OperandTraits.h"
  18. #include "llvm/ADT/ilist_node.h"
  19. #include "llvm/ADT/Twine.h"
  20. namespace llvm {
  21. class Module;
  22. template<typename ValueSubClass, typename ItemParentClass>
  23. class SymbolTableListTraits;
  24. class GlobalAlias : public GlobalValue, public ilist_node<GlobalAlias> {
  25. friend class SymbolTableListTraits<GlobalAlias, Module>;
  26. void operator=(const GlobalAlias &) LLVM_DELETED_FUNCTION;
  27. GlobalAlias(const GlobalAlias &) LLVM_DELETED_FUNCTION;
  28. void setParent(Module *parent);
  29. public:
  30. // allocate space for exactly one operand
  31. void *operator new(size_t s) {
  32. return User::operator new(s, 1);
  33. }
  34. /// GlobalAlias ctor - If a parent module is specified, the alias is
  35. /// automatically inserted into the end of the specified module's alias list.
  36. GlobalAlias(Type *Ty, LinkageTypes Linkage, const Twine &Name = "",
  37. Constant* Aliasee = 0, Module *Parent = 0);
  38. /// Provide fast operand accessors
  39. DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Constant);
  40. /// removeFromParent - This method unlinks 'this' from the containing module,
  41. /// but does not delete it.
  42. ///
  43. virtual void removeFromParent();
  44. /// eraseFromParent - This method unlinks 'this' from the containing module
  45. /// and deletes it.
  46. ///
  47. virtual void eraseFromParent();
  48. /// set/getAliasee - These methods retrive and set alias target.
  49. void setAliasee(Constant *GV);
  50. const Constant *getAliasee() const {
  51. return getOperand(0);
  52. }
  53. Constant *getAliasee() {
  54. return getOperand(0);
  55. }
  56. /// getAliasedGlobal() - Aliasee can be either global or bitcast of
  57. /// global. This method retrives the global for both aliasee flavours.
  58. const GlobalValue *getAliasedGlobal() const;
  59. /// resolveAliasedGlobal() - This method tries to ultimately resolve the alias
  60. /// by going through the aliasing chain and trying to find the very last
  61. /// global. Returns NULL if a cycle was found. If stopOnWeak is false, then
  62. /// the whole chain aliasing chain is traversed, otherwise - only strong
  63. /// aliases.
  64. const GlobalValue *resolveAliasedGlobal(bool stopOnWeak = true) const;
  65. // Methods for support type inquiry through isa, cast, and dyn_cast:
  66. static inline bool classof(const GlobalAlias *) { return true; }
  67. static inline bool classof(const Value *V) {
  68. return V->getValueID() == Value::GlobalAliasVal;
  69. }
  70. };
  71. template <>
  72. struct OperandTraits<GlobalAlias> :
  73. public FixedNumOperandTraits<GlobalAlias, 1> {
  74. };
  75. DEFINE_TRANSPARENT_OPERAND_ACCESSORS(GlobalAlias, Constant)
  76. } // End llvm namespace
  77. #endif