/Users/buildslave/jenkins/sharedspace/clang-stage2-coverage-R@2/llvm/include/llvm/IR/GlobalIndirectSymbol.h
Line | Count | Source (jump to first uncovered line) |
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 | | |
29 | | class GlobalIndirectSymbol : public GlobalValue { |
30 | | protected: |
31 | | GlobalIndirectSymbol(Type *Ty, ValueTy VTy, unsigned AddressSpace, |
32 | | LinkageTypes Linkage, const Twine &Name, Constant *Symbol); |
33 | | |
34 | | public: |
35 | | GlobalIndirectSymbol(const GlobalIndirectSymbol &) = delete; |
36 | | GlobalIndirectSymbol &operator=(const GlobalIndirectSymbol &) = delete; |
37 | | |
38 | | // allocate space for exactly one operand |
39 | 2.53k | void *operator new(size_t s) { |
40 | 2.53k | return User::operator new(s, 1); |
41 | 2.53k | } |
42 | | |
43 | | /// Provide fast operand accessors |
44 | | DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Constant); |
45 | | |
46 | | /// These methods set and retrieve indirect symbol. |
47 | 838 | void setIndirectSymbol(Constant *Symbol) { |
48 | 838 | setOperand(0, Symbol); |
49 | 838 | } |
50 | 14.7k | const Constant *getIndirectSymbol() const { |
51 | 14.7k | return getOperand(0); |
52 | 14.7k | } |
53 | 1.21k | Constant *getIndirectSymbol() { |
54 | 1.21k | return const_cast<Constant *>( |
55 | 1.21k | static_cast<const GlobalIndirectSymbol *>(this)->getIndirectSymbol()); |
56 | 1.21k | } |
57 | | |
58 | 4.44k | const GlobalObject *getBaseObject() const { |
59 | 4.44k | return dyn_cast<GlobalObject>(getIndirectSymbol()->stripInBoundsOffsets()); |
60 | 4.44k | } |
61 | 0 | GlobalObject *getBaseObject() { |
62 | 0 | return const_cast<GlobalObject *>( |
63 | 0 | static_cast<const GlobalIndirectSymbol *>(this)->getBaseObject()); |
64 | 0 | } |
65 | | |
66 | 0 | const GlobalObject *getBaseObject(const DataLayout &DL, APInt &Offset) const { |
67 | 0 | return dyn_cast<GlobalObject>( |
68 | 0 | getIndirectSymbol()->stripAndAccumulateInBoundsConstantOffsets(DL, |
69 | 0 | Offset)); |
70 | 0 | } |
71 | 0 | GlobalObject *getBaseObject(const DataLayout &DL, APInt &Offset) { |
72 | 0 | return const_cast<GlobalObject *>( |
73 | 0 | static_cast<const GlobalIndirectSymbol *>(this) |
74 | 0 | ->getBaseObject(DL, Offset)); |
75 | 0 | } |
76 | | |
77 | | // Methods for support type inquiry through isa, cast, and dyn_cast: |
78 | 643 | static bool classof(const Value *V) { |
79 | 643 | return V->getValueID() == Value::GlobalAliasVal || |
80 | 217 | V->getValueID() == Value::GlobalIFuncVal; |
81 | 643 | } |
82 | | }; |
83 | | |
84 | | template <> |
85 | | struct OperandTraits<GlobalIndirectSymbol> : |
86 | | public FixedNumOperandTraits<GlobalIndirectSymbol, 1> { |
87 | | }; |
88 | | |
89 | | DEFINE_TRANSPARENT_OPERAND_ACCESSORS(GlobalIndirectSymbol, Constant) |
90 | | |
91 | | } // end namespace llvm |
92 | | |
93 | | #endif // LLVM_IR_GLOBALINDIRECTSYMBOL_H |