LLVM  13.0.0git
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  void copyAttributesFrom(const GlobalValue *Src) {
47  }
48 
49  /// These methods set and retrieve indirect symbol.
51  setOperand(0, Symbol);
52  }
53  const Constant *getIndirectSymbol() const {
54  return getOperand(0);
55  }
57  return const_cast<Constant *>(
58  static_cast<const GlobalIndirectSymbol *>(this)->getIndirectSymbol());
59  }
60 
61  const GlobalObject *getBaseObject() const;
63  return const_cast<GlobalObject *>(
64  static_cast<const GlobalIndirectSymbol *>(this)->getBaseObject());
65  }
66 
68  return dyn_cast<GlobalObject>(
70  Offset));
71  }
73  return const_cast<GlobalObject *>(
74  static_cast<const GlobalIndirectSymbol *>(this)
75  ->getBaseObject(DL, Offset));
76  }
77 
78  // Methods for support type inquiry through isa, cast, and dyn_cast:
79  static bool classof(const Value *V) {
80  return V->getValueID() == Value::GlobalAliasVal ||
81  V->getValueID() == Value::GlobalIFuncVal;
82  }
83 };
84 
85 template <>
87  public FixedNumOperandTraits<GlobalIndirectSymbol, 1> {
88 };
89 
91 
92 } // end namespace llvm
93 
94 #endif // LLVM_IR_GLOBALINDIRECTSYMBOL_H
llvm
Definition: AllocatorList.h:23
llvm::DataLayout
A parsed version of the target data layout string in and methods for querying it.
Definition: DataLayout.h:112
llvm::GlobalIndirectSymbol::setIndirectSymbol
void setIndirectSymbol(Constant *Symbol)
These methods set and retrieve indirect symbol.
Definition: GlobalIndirectSymbol.h:50
llvm::GlobalIndirectSymbol
Definition: GlobalIndirectSymbol.h:28
llvm::Type
The instances of the Type class are immutable: once they are created, they are never changed.
Definition: Type.h:46
DEFINE_TRANSPARENT_OPERAND_ACCESSORS
#define DEFINE_TRANSPARENT_OPERAND_ACCESSORS(CLASS, VALUECLASS)
Macro for generating out-of-class operand accessor definitions.
Definition: OperandTraits.h:125
GlobalObject.h
Offset
uint64_t Offset
Definition: ELFObjHandler.cpp:81
llvm::GlobalIndirectSymbol::copyAttributesFrom
void copyAttributesFrom(const GlobalValue *Src)
Definition: GlobalIndirectSymbol.h:45
llvm::GlobalValue::LinkageTypes
LinkageTypes
An enumeration for the kinds of linkage for global values.
Definition: GlobalValue.h:47
llvm::GlobalIndirectSymbol::getBaseObject
const GlobalObject * getBaseObject(const DataLayout &DL, APInt &Offset) const
Definition: GlobalIndirectSymbol.h:67
GlobalValue.h
llvm::OperandTraits
Compile-time customization of User operands.
Definition: User.h:42
llvm::GlobalObject
Definition: GlobalObject.h:28
llvm::GlobalValue::copyAttributesFrom
void copyAttributesFrom(const GlobalValue *Src)
Copy all additional attributes (those not needed to create a GlobalValue) from the GlobalValue Src to...
Definition: Globals.cpp:65
llvm::GlobalIndirectSymbol::GlobalIndirectSymbol
GlobalIndirectSymbol(Type *Ty, ValueTy VTy, unsigned AddressSpace, LinkageTypes Linkage, const Twine &Name, Constant *Symbol)
Definition: Globals.cpp:427
llvm::Value::getValueID
unsigned getValueID() const
Return an ID for the concrete type of this object.
Definition: Value.h:529
OperandTraits.h
llvm::AddressSpace
AddressSpace
Definition: NVPTXBaseInfo.h:21
llvm::GlobalIndirectSymbol::getBaseObject
const GlobalObject * getBaseObject() const
Definition: Globals.cpp:467
llvm::GlobalValue
Definition: GlobalValue.h:44
llvm::Constant
This is an important base class in LLVM.
Definition: Constant.h:41
llvm::GlobalIndirectSymbol::getIndirectSymbol
Constant * getIndirectSymbol()
Definition: GlobalIndirectSymbol.h:56
s
multiplies can be turned into SHL s
Definition: README.txt:370
llvm::GlobalValue::Linkage
unsigned Linkage
Definition: GlobalValue.h:94
llvm::GlobalIndirectSymbol::getBaseObject
GlobalObject * getBaseObject()
Definition: GlobalIndirectSymbol.h:62
llvm::GlobalIndirectSymbol::DECLARE_TRANSPARENT_OPERAND_ACCESSORS
DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Constant)
Provide fast operand accessors.
llvm::APInt
Class for arbitrary precision integers.
Definition: APInt.h:70
llvm::User::setOperand
void setOperand(unsigned i, Value *Val)
Definition: User.h:174
llvm::Value::ValueTy
ValueTy
Concrete subclass of this.
Definition: Value.h:510
DL
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
Definition: AArch64SLSHardening.cpp:76
llvm::GlobalIndirectSymbol::getIndirectSymbol
const Constant * getIndirectSymbol() const
Definition: GlobalIndirectSymbol.h:53
llvm::Value::stripAndAccumulateInBoundsConstantOffsets
const Value * stripAndAccumulateInBoundsConstantOffsets(const DataLayout &DL, APInt &Offset) const
This is a wrapper around stripAndAccumulateConstantOffsets with the in-bounds requirement set to fals...
Definition: Value.h:719
llvm::Twine
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
Definition: Twine.h:80
llvm::GraphProgram::Name
Name
Definition: GraphWriter.h:52
llvm::GlobalIndirectSymbol::getBaseObject
GlobalObject * getBaseObject(const DataLayout &DL, APInt &Offset)
Definition: GlobalIndirectSymbol.h:72
Casting.h
llvm::ARMBuildAttrs::Symbol
@ Symbol
Definition: ARMBuildAttributes.h:79
User.h
llvm::GlobalIndirectSymbol::operator=
GlobalIndirectSymbol & operator=(const GlobalIndirectSymbol &)=delete
llvm::GlobalIndirectSymbol::classof
static bool classof(const Value *V)
Definition: GlobalIndirectSymbol.h:79
llvm::FixedNumOperandTraits
FixedNumOperandTraits - determine the allocation regime of the Use array when it is a prefix to the U...
Definition: OperandTraits.h:30
llvm::User::getOperand
Value * getOperand(unsigned i) const
Definition: User.h:169
Value.h
llvm::Value
LLVM Value Representation.
Definition: Value.h:75