LLVM  8.0.1
GlobalIndirectSymbol.h
Go to the documentation of this file.
1 //===- llvm/GlobalIndirectSymbol.h - GlobalIndirectSymbol 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 GlobalIndirectSymbol class, which
11 // is a base class for GlobalAlias and GlobalIFunc. It contains all common code
12 // for aliases and ifuncs.
13 //
14 //===----------------------------------------------------------------------===//
15 
16 #ifndef LLVM_IR_GLOBALINDIRECTSYMBOL_H
17 #define LLVM_IR_GLOBALINDIRECTSYMBOL_H
18 
19 #include "llvm/IR/GlobalObject.h"
20 #include "llvm/IR/GlobalValue.h"
21 #include "llvm/IR/OperandTraits.h"
22 #include "llvm/IR/User.h"
23 #include "llvm/IR/Value.h"
24 #include "llvm/Support/Casting.h"
25 #include <cstddef>
26 
27 namespace llvm {
28 
30 protected:
31  GlobalIndirectSymbol(Type *Ty, ValueTy VTy, unsigned AddressSpace,
33 
34 public:
37 
38  // allocate space for exactly one operand
39  void *operator new(size_t s) {
40  return User::operator new(s, 1);
41  }
42 
43  /// Provide fast operand accessors
45 
46  /// These methods set and retrieve indirect symbol.
47  void setIndirectSymbol(Constant *Symbol) {
48  setOperand(0, Symbol);
49  }
50  const Constant *getIndirectSymbol() const {
51  return getOperand(0);
52  }
54  return const_cast<Constant *>(
55  static_cast<const GlobalIndirectSymbol *>(this)->getIndirectSymbol());
56  }
57 
58  const GlobalObject *getBaseObject() const {
60  }
62  return const_cast<GlobalObject *>(
63  static_cast<const GlobalIndirectSymbol *>(this)->getBaseObject());
64  }
65 
66  const GlobalObject *getBaseObject(const DataLayout &DL, APInt &Offset) const {
67  return dyn_cast<GlobalObject>(
69  Offset));
70  }
72  return const_cast<GlobalObject *>(
73  static_cast<const GlobalIndirectSymbol *>(this)
74  ->getBaseObject(DL, Offset));
75  }
76 
77  // Methods for support type inquiry through isa, cast, and dyn_cast:
78  static bool classof(const Value *V) {
79  return V->getValueID() == Value::GlobalAliasVal ||
80  V->getValueID() == Value::GlobalIFuncVal;
81  }
82 };
83 
84 template <>
86  public FixedNumOperandTraits<GlobalIndirectSymbol, 1> {
87 };
88 
90 
91 } // end namespace llvm
92 
93 #endif // LLVM_IR_GLOBALINDIRECTSYMBOL_H
A parsed version of the target data layout string in and methods for querying it. ...
Definition: DataLayout.h:111
const GlobalObject * getBaseObject() const
unsigned getValueID() const
Return an ID for the concrete type of this object.
Definition: Value.h:464
const Value * stripInBoundsOffsets() const
Strip off pointer casts and inbounds GEPs.
Definition: Value.cpp:589
This class represents lattice values for constants.
Definition: AllocatorList.h:24
void setIndirectSymbol(Constant *Symbol)
These methods set and retrieve indirect symbol.
amdgpu Simplify well known AMD library false Value Value const Twine & Name
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
Definition: Twine.h:81
GlobalIndirectSymbol & operator=(const GlobalIndirectSymbol &)=delete
#define DEFINE_TRANSPARENT_OPERAND_ACCESSORS(CLASS, VALUECLASS)
Macro for generating out-of-class operand accessor definitions.
Value * getOperand(unsigned i) const
Definition: User.h:170
The instances of the Type class are immutable: once they are created, they are never changed...
Definition: Type.h:46
This is an important base class in LLVM.
Definition: Constant.h:42
static bool classof(const Value *V)
const GlobalObject * getBaseObject(const DataLayout &DL, APInt &Offset) const
AddressSpace
Definition: NVPTXBaseInfo.h:22
unsigned Linkage
Definition: GlobalValue.h:95
ValueTy
Concrete subclass of this.
Definition: Value.h:445
void setOperand(unsigned i, Value *Val)
Definition: User.h:175
const Value * stripAndAccumulateInBoundsConstantOffsets(const DataLayout &DL, APInt &Offset) const
Accumulate offsets from stripInBoundsConstantOffsets().
Definition: Value.cpp:547
Class for arbitrary precision integers.
Definition: APInt.h:70
LinkageTypes
An enumeration for the kinds of linkage for global values.
Definition: GlobalValue.h:48
Compile-time customization of User operands.
Definition: User.h:43
LLVM_NODISCARD std::enable_if<!is_simple_type< Y >::value, typename cast_retty< X, const Y >::ret_type >::type dyn_cast(const Y &Val)
Definition: Casting.h:323
const Constant * getIndirectSymbol() const
LLVM Value Representation.
Definition: Value.h:73
GlobalObject * getBaseObject(const DataLayout &DL, APInt &Offset)
GlobalIndirectSymbol(Type *Ty, ValueTy VTy, unsigned AddressSpace, LinkageTypes Linkage, const Twine &Name, Constant *Symbol)
Definition: Globals.cpp:402
DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Constant)
Provide fast operand accessors.
FixedNumOperandTraits - determine the allocation regime of the Use array when it is a prefix to the U...
Definition: OperandTraits.h:31