LLVM  9.0.0svn
GlobalIndirectSymbol.h
Go to the documentation of this file.
1 //===- llvm/GlobalIndirectSymbol.h - GlobalIndirectSymbol class -*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This file contains the declaration of the GlobalIndirectSymbol class, which
10 // is a base class for GlobalAlias and GlobalIFunc. It contains all common code
11 // for aliases and ifuncs.
12 //
13 //===----------------------------------------------------------------------===//
14 
15 #ifndef LLVM_IR_GLOBALINDIRECTSYMBOL_H
16 #define LLVM_IR_GLOBALINDIRECTSYMBOL_H
17 
18 #include "llvm/IR/GlobalObject.h"
19 #include "llvm/IR/GlobalValue.h"
20 #include "llvm/IR/OperandTraits.h"
21 #include "llvm/IR/User.h"
22 #include "llvm/IR/Value.h"
23 #include "llvm/Support/Casting.h"
24 #include <cstddef>
25 
26 namespace llvm {
27 
29 protected:
30  GlobalIndirectSymbol(Type *Ty, ValueTy VTy, unsigned AddressSpace,
32 
33 public:
36 
37  // allocate space for exactly one operand
38  void *operator new(size_t s) {
39  return User::operator new(s, 1);
40  }
41 
42  /// Provide fast operand accessors
44 
45  /// These methods set and retrieve indirect symbol.
46  void setIndirectSymbol(Constant *Symbol) {
47  setOperand(0, Symbol);
48  }
49  const Constant *getIndirectSymbol() const {
50  return getOperand(0);
51  }
53  return const_cast<Constant *>(
54  static_cast<const GlobalIndirectSymbol *>(this)->getIndirectSymbol());
55  }
56 
57  const GlobalObject *getBaseObject() const {
59  }
61  return const_cast<GlobalObject *>(
62  static_cast<const GlobalIndirectSymbol *>(this)->getBaseObject());
63  }
64 
65  const GlobalObject *getBaseObject(const DataLayout &DL, APInt &Offset) const {
66  return dyn_cast<GlobalObject>(
68  Offset));
69  }
71  return const_cast<GlobalObject *>(
72  static_cast<const GlobalIndirectSymbol *>(this)
73  ->getBaseObject(DL, Offset));
74  }
75 
76  // Methods for support type inquiry through isa, cast, and dyn_cast:
77  static bool classof(const Value *V) {
78  return V->getValueID() == Value::GlobalAliasVal ||
79  V->getValueID() == Value::GlobalIFuncVal;
80  }
81 };
82 
83 template <>
85  public FixedNumOperandTraits<GlobalIndirectSymbol, 1> {
86 };
87 
89 
90 } // end namespace llvm
91 
92 #endif // LLVM_IR_GLOBALINDIRECTSYMBOL_H
A parsed version of the target data layout string in and methods for querying it. ...
Definition: DataLayout.h:110
const GlobalObject * getBaseObject() const
unsigned getValueID() const
Return an ID for the concrete type of this object.
Definition: Value.h:463
const Value * stripInBoundsOffsets() const
Strip off pointer casts and inbounds GEPs.
Definition: Value.cpp:600
This class represents lattice values for constants.
Definition: AllocatorList.h:23
amdgpu Simplify well known AMD library false FunctionCallee Value const Twine & Name
void setIndirectSymbol(Constant *Symbol)
These methods set and retrieve indirect symbol.
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
Definition: Twine.h:80
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:169
The instances of the Type class are immutable: once they are created, they are never changed...
Definition: Type.h:45
This is an important base class in LLVM.
Definition: Constant.h:41
static bool classof(const Value *V)
const GlobalObject * getBaseObject(const DataLayout &DL, APInt &Offset) const
AddressSpace
Definition: NVPTXBaseInfo.h:21
unsigned Linkage
Definition: GlobalValue.h:94
ValueTy
Concrete subclass of this.
Definition: Value.h:444
void setOperand(unsigned i, Value *Val)
Definition: User.h:174
const Value * stripAndAccumulateInBoundsConstantOffsets(const DataLayout &DL, APInt &Offset) const
Accumulate offsets from stripInBoundsConstantOffsets().
Definition: Value.cpp:558
Class for arbitrary precision integers.
Definition: APInt.h:69
LinkageTypes
An enumeration for the kinds of linkage for global values.
Definition: GlobalValue.h:47
Compile-time customization of User operands.
Definition: User.h:42
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:332
const Constant * getIndirectSymbol() const
LLVM Value Representation.
Definition: Value.h:72
GlobalObject * getBaseObject(const DataLayout &DL, APInt &Offset)
GlobalIndirectSymbol(Type *Ty, ValueTy VTy, unsigned AddressSpace, LinkageTypes Linkage, const Twine &Name, Constant *Symbol)
Definition: Globals.cpp:423
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:30