Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-10 08:44:00

0001 //===-------- llvm/GlobalAlias.h - GlobalAlias class ------------*- C++ -*-===//
0002 //
0003 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
0004 // See https://llvm.org/LICENSE.txt for license information.
0005 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
0006 //
0007 //===----------------------------------------------------------------------===//
0008 //
0009 // This file contains the declaration of the GlobalAlias class, which
0010 // represents a single function or variable alias in the IR.
0011 //
0012 //===----------------------------------------------------------------------===//
0013 
0014 #ifndef LLVM_IR_GLOBALALIAS_H
0015 #define LLVM_IR_GLOBALALIAS_H
0016 
0017 #include "llvm/ADT/ilist_node.h"
0018 #include "llvm/IR/GlobalValue.h"
0019 #include "llvm/IR/OperandTraits.h"
0020 #include "llvm/IR/Value.h"
0021 
0022 namespace llvm {
0023 
0024 class Twine;
0025 class Module;
0026 template <typename ValueSubClass, typename... Args> class SymbolTableListTraits;
0027 
0028 class GlobalAlias : public GlobalValue, public ilist_node<GlobalAlias> {
0029   friend class SymbolTableListTraits<GlobalAlias>;
0030 
0031   constexpr static IntrusiveOperandsAllocMarker AllocMarker{1};
0032 
0033   GlobalAlias(Type *Ty, unsigned AddressSpace, LinkageTypes Linkage,
0034               const Twine &Name, Constant *Aliasee, Module *Parent);
0035 
0036 public:
0037   GlobalAlias(const GlobalAlias &) = delete;
0038   GlobalAlias &operator=(const GlobalAlias &) = delete;
0039 
0040   /// If a parent module is specified, the alias is automatically inserted into
0041   /// the end of the specified module's alias list.
0042   static GlobalAlias *create(Type *Ty, unsigned AddressSpace,
0043                              LinkageTypes Linkage, const Twine &Name,
0044                              Constant *Aliasee, Module *Parent);
0045 
0046   // Without the Aliasee.
0047   static GlobalAlias *create(Type *Ty, unsigned AddressSpace,
0048                              LinkageTypes Linkage, const Twine &Name,
0049                              Module *Parent);
0050 
0051   // The module is taken from the Aliasee.
0052   static GlobalAlias *create(Type *Ty, unsigned AddressSpace,
0053                              LinkageTypes Linkage, const Twine &Name,
0054                              GlobalValue *Aliasee);
0055 
0056   // Type, Parent and AddressSpace taken from the Aliasee.
0057   static GlobalAlias *create(LinkageTypes Linkage, const Twine &Name,
0058                              GlobalValue *Aliasee);
0059 
0060   // Linkage, Type, Parent and AddressSpace taken from the Aliasee.
0061   static GlobalAlias *create(const Twine &Name, GlobalValue *Aliasee);
0062 
0063   // allocate space for exactly one operand
0064   void *operator new(size_t S) { return User::operator new(S, AllocMarker); }
0065   void operator delete(void *Ptr) { User::operator delete(Ptr); }
0066 
0067   /// Provide fast operand accessors
0068   DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Constant);
0069 
0070   void copyAttributesFrom(const GlobalAlias *Src) {
0071     GlobalValue::copyAttributesFrom(Src);
0072   }
0073 
0074   /// removeFromParent - This method unlinks 'this' from the containing module,
0075   /// but does not delete it.
0076   ///
0077   void removeFromParent();
0078 
0079   /// eraseFromParent - This method unlinks 'this' from the containing module
0080   /// and deletes it.
0081   ///
0082   void eraseFromParent();
0083 
0084   /// These methods retrieve and set alias target.
0085   void setAliasee(Constant *Aliasee);
0086   const Constant *getAliasee() const {
0087     return static_cast<Constant *>(Op<0>().get());
0088   }
0089   Constant *getAliasee() { return static_cast<Constant *>(Op<0>().get()); }
0090 
0091   const GlobalObject *getAliaseeObject() const;
0092   GlobalObject *getAliaseeObject() {
0093     return const_cast<GlobalObject *>(
0094         static_cast<const GlobalAlias *>(this)->getAliaseeObject());
0095   }
0096 
0097   static bool isValidLinkage(LinkageTypes L) {
0098     return isExternalLinkage(L) || isLocalLinkage(L) || isWeakLinkage(L) ||
0099            isLinkOnceLinkage(L) || isAvailableExternallyLinkage(L);
0100   }
0101 
0102   // Methods for support type inquiry through isa, cast, and dyn_cast:
0103   static bool classof(const Value *V) {
0104     return V->getValueID() == Value::GlobalAliasVal;
0105   }
0106 };
0107 
0108 template <>
0109 struct OperandTraits<GlobalAlias>
0110     : public FixedNumOperandTraits<GlobalAlias, 1> {};
0111 
0112 DEFINE_TRANSPARENT_OPERAND_ACCESSORS(GlobalAlias, Constant)
0113 
0114 } // end namespace llvm
0115 
0116 #endif // LLVM_IR_GLOBALALIAS_H