GlobalIFunc.h 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. #pragma once
  2. #ifdef __GNUC__
  3. #pragma GCC diagnostic push
  4. #pragma GCC diagnostic ignored "-Wunused-parameter"
  5. #endif
  6. //===-------- llvm/GlobalIFunc.h - GlobalIFunc class ------------*- C++ -*-===//
  7. //
  8. // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  9. // See https://llvm.org/LICENSE.txt for license information.
  10. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  11. //
  12. //===----------------------------------------------------------------------===//
  13. ///
  14. /// \brief
  15. /// This file contains the declaration of the GlobalIFunc class, which
  16. /// represents a single indirect function in the IR. Indirect function uses
  17. /// ELF symbol type extension to mark that the address of a declaration should
  18. /// be resolved at runtime by calling a resolver function.
  19. ///
  20. //===----------------------------------------------------------------------===//
  21. #ifndef LLVM_IR_GLOBALIFUNC_H
  22. #define LLVM_IR_GLOBALIFUNC_H
  23. #include "llvm/ADT/ilist_node.h"
  24. #include "llvm/IR/GlobalIndirectSymbol.h"
  25. #include "llvm/IR/Value.h"
  26. namespace llvm {
  27. class Twine;
  28. class Module;
  29. // Traits class for using GlobalIFunc in symbol table in Module.
  30. template <typename ValueSubClass> class SymbolTableListTraits;
  31. class GlobalIFunc final : public GlobalIndirectSymbol,
  32. public ilist_node<GlobalIFunc> {
  33. friend class SymbolTableListTraits<GlobalIFunc>;
  34. GlobalIFunc(Type *Ty, unsigned AddressSpace, LinkageTypes Linkage,
  35. const Twine &Name, Constant *Resolver, Module *Parent);
  36. public:
  37. GlobalIFunc(const GlobalIFunc &) = delete;
  38. GlobalIFunc &operator=(const GlobalIFunc &) = delete;
  39. /// If a parent module is specified, the ifunc is automatically inserted into
  40. /// the end of the specified module's ifunc list.
  41. static GlobalIFunc *create(Type *Ty, unsigned AddressSpace,
  42. LinkageTypes Linkage, const Twine &Name,
  43. Constant *Resolver, Module *Parent);
  44. /// This method unlinks 'this' from the containing module, but does not
  45. /// delete it.
  46. void removeFromParent();
  47. /// This method unlinks 'this' from the containing module and deletes it.
  48. void eraseFromParent();
  49. /// These methods retrieve and set ifunc resolver function.
  50. void setResolver(Constant *Resolver) {
  51. setIndirectSymbol(Resolver);
  52. }
  53. const Constant *getResolver() const {
  54. return getIndirectSymbol();
  55. }
  56. Constant *getResolver() {
  57. return getIndirectSymbol();
  58. }
  59. // Methods for support type inquiry through isa, cast, and dyn_cast:
  60. static bool classof(const Value *V) {
  61. return V->getValueID() == Value::GlobalIFuncVal;
  62. }
  63. };
  64. } // end namespace llvm
  65. #endif // LLVM_IR_GLOBALIFUNC_H
  66. #ifdef __GNUC__
  67. #pragma GCC diagnostic pop
  68. #endif