Eugene Zelenko | 076468c | 2017-09-20 21:35:51 +0000 | [diff] [blame] | 1 | //===- ARMConstantPoolValue.h - ARM constantpool value ----------*- C++ -*-===// |
Evan Cheng | 10043e2 | 2007-01-19 07:51:42 +0000 | [diff] [blame] | 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
Chris Lattner | f3ebc3f | 2007-12-29 20:36:04 +0000 | [diff] [blame] | 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
Evan Cheng | 10043e2 | 2007-01-19 07:51:42 +0000 | [diff] [blame] | 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | // |
| 10 | // This file implements the ARM specific constantpool value class. |
| 11 | // |
| 12 | //===----------------------------------------------------------------------===// |
| 13 | |
Benjamin Kramer | a7c40ef | 2014-08-13 16:26:38 +0000 | [diff] [blame] | 14 | #ifndef LLVM_LIB_TARGET_ARM_ARMCONSTANTPOOLVALUE_H |
| 15 | #define LLVM_LIB_TARGET_ARM_ARMCONSTANTPOOLVALUE_H |
Evan Cheng | 10043e2 | 2007-01-19 07:51:42 +0000 | [diff] [blame] | 16 | |
Saleem Abdulrasool | 5fba8ba | 2017-09-07 04:00:13 +0000 | [diff] [blame] | 17 | #include "llvm/ADT/SmallPtrSet.h" |
Eugene Zelenko | 076468c | 2017-09-20 21:35:51 +0000 | [diff] [blame] | 18 | #include "llvm/ADT/StringRef.h" |
| 19 | #include "llvm/ADT/iterator_range.h" |
Evan Cheng | 10043e2 | 2007-01-19 07:51:42 +0000 | [diff] [blame] | 20 | #include "llvm/CodeGen/MachineConstantPool.h" |
Benjamin Kramer | 2ef689c | 2013-09-16 10:17:31 +0000 | [diff] [blame] | 21 | #include "llvm/Support/Casting.h" |
Eugene Zelenko | e79c077 | 2017-01-27 23:58:02 +0000 | [diff] [blame] | 22 | #include <string> |
| 23 | #include <vector> |
Evan Cheng | 10043e2 | 2007-01-19 07:51:42 +0000 | [diff] [blame] | 24 | |
| 25 | namespace llvm { |
| 26 | |
Bob Wilson | 433ab09 | 2009-11-02 16:59:06 +0000 | [diff] [blame] | 27 | class BlockAddress; |
Bill Wendling | a1127b2 | 2011-09-29 23:48:44 +0000 | [diff] [blame] | 28 | class Constant; |
Dan Gohman | 0597e5b | 2008-07-11 20:38:31 +0000 | [diff] [blame] | 29 | class GlobalValue; |
James Molloy | 9abb2fa | 2016-09-26 07:26:24 +0000 | [diff] [blame] | 30 | class GlobalVariable; |
Owen Anderson | 55f1c09 | 2009-08-13 21:58:54 +0000 | [diff] [blame] | 31 | class LLVMContext; |
Bill Wendling | a1127b2 | 2011-09-29 23:48:44 +0000 | [diff] [blame] | 32 | class MachineBasicBlock; |
Eugene Zelenko | 076468c | 2017-09-20 21:35:51 +0000 | [diff] [blame] | 33 | class raw_ostream; |
| 34 | class Type; |
Dan Gohman | 0597e5b | 2008-07-11 20:38:31 +0000 | [diff] [blame] | 35 | |
Jim Grosbach | 20eac92 | 2009-09-01 01:57:56 +0000 | [diff] [blame] | 36 | namespace ARMCP { |
Eugene Zelenko | e79c077 | 2017-01-27 23:58:02 +0000 | [diff] [blame] | 37 | |
Jim Grosbach | 20eac92 | 2009-09-01 01:57:56 +0000 | [diff] [blame] | 38 | enum ARMCPKind { |
| 39 | CPValue, |
Bob Wilson | 433ab09 | 2009-11-02 16:59:06 +0000 | [diff] [blame] | 40 | CPExtSymbol, |
| 41 | CPBlockAddress, |
Bill Wendling | a1127b2 | 2011-09-29 23:48:44 +0000 | [diff] [blame] | 42 | CPLSDA, |
James Molloy | 9abb2fa | 2016-09-26 07:26:24 +0000 | [diff] [blame] | 43 | CPMachineBasicBlock, |
| 44 | CPPromotedGlobal |
Jim Grosbach | 20eac92 | 2009-09-01 01:57:56 +0000 | [diff] [blame] | 45 | }; |
Jim Grosbach | a942ad4 | 2010-11-09 21:36:17 +0000 | [diff] [blame] | 46 | |
| 47 | enum ARMCPModifier { |
Saleem Abdulrasool | ce4eee4 | 2016-06-07 03:15:01 +0000 | [diff] [blame] | 48 | no_modifier, /// None |
| 49 | TLSGD, /// Thread Local Storage (General Dynamic Mode) |
| 50 | GOT_PREL, /// Global Offset Table, PC Relative |
| 51 | GOTTPOFF, /// Global Offset Table, Thread Pointer Offset |
| 52 | TPOFF, /// Thread Pointer Offset |
Saleem Abdulrasool | 532dcbc | 2016-06-07 03:15:07 +0000 | [diff] [blame] | 53 | SECREL, /// Section Relative (Windows TLS) |
Oliver Stannard | 8331aae | 2016-08-08 15:28:31 +0000 | [diff] [blame] | 54 | SBREL, /// Static Base Relative (RWPI) |
Jim Grosbach | a942ad4 | 2010-11-09 21:36:17 +0000 | [diff] [blame] | 55 | }; |
Eugene Zelenko | e79c077 | 2017-01-27 23:58:02 +0000 | [diff] [blame] | 56 | |
| 57 | } // end namespace ARMCP |
Jim Grosbach | 20eac92 | 2009-09-01 01:57:56 +0000 | [diff] [blame] | 58 | |
Evan Cheng | 10043e2 | 2007-01-19 07:51:42 +0000 | [diff] [blame] | 59 | /// ARMConstantPoolValue - ARM specific constantpool value. This is used to |
Bob Wilson | 4c00a52 | 2009-11-02 17:10:37 +0000 | [diff] [blame] | 60 | /// represent PC-relative displacement between the address of the load |
Bob Wilson | 433ab09 | 2009-11-02 16:59:06 +0000 | [diff] [blame] | 61 | /// instruction and the constant being loaded, i.e. (&GV-(LPIC+8)). |
Evan Cheng | 10043e2 | 2007-01-19 07:51:42 +0000 | [diff] [blame] | 62 | class ARMConstantPoolValue : public MachineConstantPoolValue { |
Evan Cheng | 10043e2 | 2007-01-19 07:51:42 +0000 | [diff] [blame] | 63 | unsigned LabelId; // Label id of the load. |
Bob Wilson | 433ab09 | 2009-11-02 16:59:06 +0000 | [diff] [blame] | 64 | ARMCP::ARMCPKind Kind; // Kind of constant. |
Bob Wilson | 4c00a52 | 2009-11-02 17:10:37 +0000 | [diff] [blame] | 65 | unsigned char PCAdjust; // Extra adjustment if constantpool is pc-relative. |
Evan Cheng | 10043e2 | 2007-01-19 07:51:42 +0000 | [diff] [blame] | 66 | // 8 for ARM, 4 for Thumb. |
Jim Grosbach | a942ad4 | 2010-11-09 21:36:17 +0000 | [diff] [blame] | 67 | ARMCP::ARMCPModifier Modifier; // GV modifier i.e. (&GV(modifier)-(LPIC+8)) |
Lauro Ramos Venancio | c39c12a | 2007-04-27 13:54:47 +0000 | [diff] [blame] | 68 | bool AddCurrentAddress; |
Evan Cheng | 10043e2 | 2007-01-19 07:51:42 +0000 | [diff] [blame] | 69 | |
Bill Wendling | 396c211 | 2011-10-01 06:40:33 +0000 | [diff] [blame] | 70 | protected: |
| 71 | ARMConstantPoolValue(Type *Ty, unsigned id, ARMCP::ARMCPKind Kind, |
| 72 | unsigned char PCAdj, ARMCP::ARMCPModifier Modifier, |
| 73 | bool AddCurrentAddress); |
| 74 | |
Bill Wendling | d7fa016 | 2011-10-01 08:36:59 +0000 | [diff] [blame] | 75 | ARMConstantPoolValue(LLVMContext &C, unsigned id, ARMCP::ARMCPKind Kind, |
| 76 | unsigned char PCAdj, ARMCP::ARMCPModifier Modifier, |
| 77 | bool AddCurrentAddress); |
Benjamin Kramer | 2ef689c | 2013-09-16 10:17:31 +0000 | [diff] [blame] | 78 | |
| 79 | template <typename Derived> |
| 80 | int getExistingMachineCPValueImpl(MachineConstantPool *CP, |
| 81 | unsigned Alignment) { |
| 82 | unsigned AlignMask = Alignment - 1; |
| 83 | const std::vector<MachineConstantPoolEntry> &Constants = CP->getConstants(); |
| 84 | for (unsigned i = 0, e = Constants.size(); i != e; ++i) { |
| 85 | if (Constants[i].isMachineConstantPoolEntry() && |
| 86 | (Constants[i].getAlignment() & AlignMask) == 0) { |
Saleem Abdulrasool | 5fba8ba | 2017-09-07 04:00:13 +0000 | [diff] [blame] | 87 | auto *CPV = |
| 88 | static_cast<ARMConstantPoolValue*>(Constants[i].Val.MachineCPVal); |
Benjamin Kramer | 2ef689c | 2013-09-16 10:17:31 +0000 | [diff] [blame] | 89 | if (Derived *APC = dyn_cast<Derived>(CPV)) |
| 90 | if (cast<Derived>(this)->equals(APC)) |
| 91 | return i; |
| 92 | } |
| 93 | } |
| 94 | |
| 95 | return -1; |
| 96 | } |
| 97 | |
Evan Cheng | 10043e2 | 2007-01-19 07:51:42 +0000 | [diff] [blame] | 98 | public: |
Alexander Kornienko | f817c1c | 2015-04-11 02:11:45 +0000 | [diff] [blame] | 99 | ~ARMConstantPoolValue() override; |
Lauro Ramos Venancio | ee2d164 | 2007-04-22 00:04:12 +0000 | [diff] [blame] | 100 | |
Jim Grosbach | a942ad4 | 2010-11-09 21:36:17 +0000 | [diff] [blame] | 101 | ARMCP::ARMCPModifier getModifier() const { return Modifier; } |
Mehdi Amini | 5b00770 | 2016-10-05 01:41:06 +0000 | [diff] [blame] | 102 | StringRef getModifierText() const; |
Jim Grosbach | a942ad4 | 2010-11-09 21:36:17 +0000 | [diff] [blame] | 103 | bool hasModifier() const { return Modifier != ARMCP::no_modifier; } |
Bill Wendling | e8e4dbf | 2011-09-30 18:42:06 +0000 | [diff] [blame] | 104 | |
Lauro Ramos Venancio | c39c12a | 2007-04-27 13:54:47 +0000 | [diff] [blame] | 105 | bool mustAddCurrentAddress() const { return AddCurrentAddress; } |
Bill Wendling | e8e4dbf | 2011-09-30 18:42:06 +0000 | [diff] [blame] | 106 | |
Evan Cheng | 10043e2 | 2007-01-19 07:51:42 +0000 | [diff] [blame] | 107 | unsigned getLabelId() const { return LabelId; } |
Evan Cheng | 10043e2 | 2007-01-19 07:51:42 +0000 | [diff] [blame] | 108 | unsigned char getPCAdjustment() const { return PCAdjust; } |
Bill Wendling | e8e4dbf | 2011-09-30 18:42:06 +0000 | [diff] [blame] | 109 | |
Bob Wilson | 433ab09 | 2009-11-02 16:59:06 +0000 | [diff] [blame] | 110 | bool isGlobalValue() const { return Kind == ARMCP::CPValue; } |
| 111 | bool isExtSymbol() const { return Kind == ARMCP::CPExtSymbol; } |
Bill Wendling | 396c211 | 2011-10-01 06:40:33 +0000 | [diff] [blame] | 112 | bool isBlockAddress() const { return Kind == ARMCP::CPBlockAddress; } |
Bill Wendling | e8e4dbf | 2011-09-30 18:42:06 +0000 | [diff] [blame] | 113 | bool isLSDA() const { return Kind == ARMCP::CPLSDA; } |
Bill Wendling | 6dbc9fe | 2011-10-01 09:19:10 +0000 | [diff] [blame] | 114 | bool isMachineBasicBlock() const{ return Kind == ARMCP::CPMachineBasicBlock; } |
James Molloy | 9abb2fa | 2016-09-26 07:26:24 +0000 | [diff] [blame] | 115 | bool isPromotedGlobal() const{ return Kind == ARMCP::CPPromotedGlobal; } |
Fangrui Song | f78650a | 2018-07-30 19:41:25 +0000 | [diff] [blame] | 116 | |
Craig Topper | 6bc27bf | 2014-03-10 02:09:33 +0000 | [diff] [blame] | 117 | int getExistingMachineCPValue(MachineConstantPool *CP, |
| 118 | unsigned Alignment) override; |
Evan Cheng | 10043e2 | 2007-01-19 07:51:42 +0000 | [diff] [blame] | 119 | |
Craig Topper | 6bc27bf | 2014-03-10 02:09:33 +0000 | [diff] [blame] | 120 | void addSelectionDAGCSEId(FoldingSetNodeID &ID) override; |
Evan Cheng | 10043e2 | 2007-01-19 07:51:42 +0000 | [diff] [blame] | 121 | |
Bill Wendling | 396c211 | 2011-10-01 06:40:33 +0000 | [diff] [blame] | 122 | /// hasSameValue - Return true if this ARM constpool value can share the same |
| 123 | /// constantpool entry as another ARM constpool value. |
| 124 | virtual bool hasSameValue(ARMConstantPoolValue *ACPV); |
Evan Cheng | 7ff8319 | 2009-11-07 03:52:02 +0000 | [diff] [blame] | 125 | |
Bill Wendling | f977ff5 | 2011-10-01 12:44:28 +0000 | [diff] [blame] | 126 | bool equals(const ARMConstantPoolValue *A) const { |
| 127 | return this->LabelId == A->LabelId && |
| 128 | this->PCAdjust == A->PCAdjust && |
| 129 | this->Modifier == A->Modifier; |
| 130 | } |
| 131 | |
Craig Topper | 6bc27bf | 2014-03-10 02:09:33 +0000 | [diff] [blame] | 132 | void print(raw_ostream &O) const override; |
Evan Cheng | de9dbc5 | 2008-10-29 23:55:17 +0000 | [diff] [blame] | 133 | void print(raw_ostream *O) const { if (O) print(*O); } |
Evan Cheng | de9dbc5 | 2008-10-29 23:55:17 +0000 | [diff] [blame] | 134 | void dump() const; |
Evan Cheng | 10043e2 | 2007-01-19 07:51:42 +0000 | [diff] [blame] | 135 | }; |
Evan Cheng | de9dbc5 | 2008-10-29 23:55:17 +0000 | [diff] [blame] | 136 | |
Evan Cheng | de9dbc5 | 2008-10-29 23:55:17 +0000 | [diff] [blame] | 137 | inline raw_ostream &operator<<(raw_ostream &O, const ARMConstantPoolValue &V) { |
| 138 | V.print(O); |
| 139 | return O; |
| 140 | } |
| 141 | |
Bill Wendling | 396c211 | 2011-10-01 06:40:33 +0000 | [diff] [blame] | 142 | /// ARMConstantPoolConstant - ARM-specific constant pool values for Constants, |
| 143 | /// Functions, and BlockAddresses. |
| 144 | class ARMConstantPoolConstant : public ARMConstantPoolValue { |
| 145 | const Constant *CVal; // Constant being loaded. |
Saleem Abdulrasool | 5fba8ba | 2017-09-07 04:00:13 +0000 | [diff] [blame] | 146 | SmallPtrSet<const GlobalVariable*, 1> GVars; |
Bill Wendling | 396c211 | 2011-10-01 06:40:33 +0000 | [diff] [blame] | 147 | |
| 148 | ARMConstantPoolConstant(const Constant *C, |
| 149 | unsigned ID, |
| 150 | ARMCP::ARMCPKind Kind, |
| 151 | unsigned char PCAdj, |
| 152 | ARMCP::ARMCPModifier Modifier, |
| 153 | bool AddCurrentAddress); |
Bill Wendling | f117a35 | 2011-10-01 07:52:37 +0000 | [diff] [blame] | 154 | ARMConstantPoolConstant(Type *Ty, const Constant *C, |
| 155 | unsigned ID, |
| 156 | ARMCP::ARMCPKind Kind, |
| 157 | unsigned char PCAdj, |
| 158 | ARMCP::ARMCPModifier Modifier, |
| 159 | bool AddCurrentAddress); |
James Molloy | 9abb2fa | 2016-09-26 07:26:24 +0000 | [diff] [blame] | 160 | ARMConstantPoolConstant(const GlobalVariable *GV, const Constant *Init); |
Bill Wendling | f117a35 | 2011-10-01 07:52:37 +0000 | [diff] [blame] | 161 | |
Bill Wendling | 396c211 | 2011-10-01 06:40:33 +0000 | [diff] [blame] | 162 | public: |
| 163 | static ARMConstantPoolConstant *Create(const Constant *C, unsigned ID); |
Bill Wendling | f117a35 | 2011-10-01 07:52:37 +0000 | [diff] [blame] | 164 | static ARMConstantPoolConstant *Create(const GlobalValue *GV, |
| 165 | ARMCP::ARMCPModifier Modifier); |
James Molloy | 9abb2fa | 2016-09-26 07:26:24 +0000 | [diff] [blame] | 166 | static ARMConstantPoolConstant *Create(const GlobalVariable *GV, |
| 167 | const Constant *Initializer); |
Bill Wendling | 6722556 | 2011-10-01 06:44:24 +0000 | [diff] [blame] | 168 | static ARMConstantPoolConstant *Create(const Constant *C, unsigned ID, |
| 169 | ARMCP::ARMCPKind Kind, |
| 170 | unsigned char PCAdj); |
Bill Wendling | f117a35 | 2011-10-01 07:52:37 +0000 | [diff] [blame] | 171 | static ARMConstantPoolConstant *Create(const Constant *C, unsigned ID, |
| 172 | ARMCP::ARMCPKind Kind, |
| 173 | unsigned char PCAdj, |
| 174 | ARMCP::ARMCPModifier Modifier, |
| 175 | bool AddCurrentAddress); |
Bill Wendling | 396c211 | 2011-10-01 06:40:33 +0000 | [diff] [blame] | 176 | |
| 177 | const GlobalValue *getGV() const; |
Bill Wendling | f117a35 | 2011-10-01 07:52:37 +0000 | [diff] [blame] | 178 | const BlockAddress *getBlockAddress() const; |
Eugene Zelenko | e79c077 | 2017-01-27 23:58:02 +0000 | [diff] [blame] | 179 | |
Eugene Zelenko | 076468c | 2017-09-20 21:35:51 +0000 | [diff] [blame] | 180 | using promoted_iterator = SmallPtrSet<const GlobalVariable *, 1>::iterator; |
| 181 | |
Saleem Abdulrasool | 5fba8ba | 2017-09-07 04:00:13 +0000 | [diff] [blame] | 182 | iterator_range<promoted_iterator> promotedGlobals() { |
| 183 | return iterator_range<promoted_iterator>(GVars.begin(), GVars.end()); |
James Molloy | 9abb2fa | 2016-09-26 07:26:24 +0000 | [diff] [blame] | 184 | } |
Eugene Zelenko | e79c077 | 2017-01-27 23:58:02 +0000 | [diff] [blame] | 185 | |
James Molloy | 9abb2fa | 2016-09-26 07:26:24 +0000 | [diff] [blame] | 186 | const Constant *getPromotedGlobalInit() const { |
| 187 | return CVal; |
| 188 | } |
Bill Wendling | f117a35 | 2011-10-01 07:52:37 +0000 | [diff] [blame] | 189 | |
Craig Topper | 6bc27bf | 2014-03-10 02:09:33 +0000 | [diff] [blame] | 190 | int getExistingMachineCPValue(MachineConstantPool *CP, |
| 191 | unsigned Alignment) override; |
Bill Wendling | 396c211 | 2011-10-01 06:40:33 +0000 | [diff] [blame] | 192 | |
| 193 | /// hasSameValue - Return true if this ARM constpool value can share the same |
| 194 | /// constantpool entry as another ARM constpool value. |
Craig Topper | 6bc27bf | 2014-03-10 02:09:33 +0000 | [diff] [blame] | 195 | bool hasSameValue(ARMConstantPoolValue *ACPV) override; |
Bill Wendling | 396c211 | 2011-10-01 06:40:33 +0000 | [diff] [blame] | 196 | |
Craig Topper | 6bc27bf | 2014-03-10 02:09:33 +0000 | [diff] [blame] | 197 | void addSelectionDAGCSEId(FoldingSetNodeID &ID) override; |
Bill Wendling | 396c211 | 2011-10-01 06:40:33 +0000 | [diff] [blame] | 198 | |
Craig Topper | 6bc27bf | 2014-03-10 02:09:33 +0000 | [diff] [blame] | 199 | void print(raw_ostream &O) const override; |
Eugene Zelenko | e79c077 | 2017-01-27 23:58:02 +0000 | [diff] [blame] | 200 | |
Bill Wendling | 396c211 | 2011-10-01 06:40:33 +0000 | [diff] [blame] | 201 | static bool classof(const ARMConstantPoolValue *APV) { |
James Molloy | 9abb2fa | 2016-09-26 07:26:24 +0000 | [diff] [blame] | 202 | return APV->isGlobalValue() || APV->isBlockAddress() || APV->isLSDA() || |
| 203 | APV->isPromotedGlobal(); |
Bill Wendling | 396c211 | 2011-10-01 06:40:33 +0000 | [diff] [blame] | 204 | } |
Benjamin Kramer | 2ef689c | 2013-09-16 10:17:31 +0000 | [diff] [blame] | 205 | |
| 206 | bool equals(const ARMConstantPoolConstant *A) const { |
| 207 | return CVal == A->CVal && ARMConstantPoolValue::equals(A); |
| 208 | } |
Bill Wendling | 396c211 | 2011-10-01 06:40:33 +0000 | [diff] [blame] | 209 | }; |
| 210 | |
Bill Wendling | d7fa016 | 2011-10-01 08:36:59 +0000 | [diff] [blame] | 211 | /// ARMConstantPoolSymbol - ARM-specific constantpool values for external |
| 212 | /// symbols. |
| 213 | class ARMConstantPoolSymbol : public ARMConstantPoolValue { |
Benjamin Kramer | 9d46110 | 2012-12-24 19:23:30 +0000 | [diff] [blame] | 214 | const std::string S; // ExtSymbol being loaded. |
Bill Wendling | d7fa016 | 2011-10-01 08:36:59 +0000 | [diff] [blame] | 215 | |
Mehdi Amini | 5b00770 | 2016-10-05 01:41:06 +0000 | [diff] [blame] | 216 | ARMConstantPoolSymbol(LLVMContext &C, StringRef s, unsigned id, |
Bill Wendling | d7fa016 | 2011-10-01 08:36:59 +0000 | [diff] [blame] | 217 | unsigned char PCAdj, ARMCP::ARMCPModifier Modifier, |
| 218 | bool AddCurrentAddress); |
| 219 | |
| 220 | public: |
Mehdi Amini | 5b00770 | 2016-10-05 01:41:06 +0000 | [diff] [blame] | 221 | static ARMConstantPoolSymbol *Create(LLVMContext &C, StringRef s, unsigned ID, |
| 222 | unsigned char PCAdj); |
Bill Wendling | c214cb0 | 2011-10-01 08:58:29 +0000 | [diff] [blame] | 223 | |
Mehdi Amini | 5b00770 | 2016-10-05 01:41:06 +0000 | [diff] [blame] | 224 | StringRef getSymbol() const { return S; } |
Bill Wendling | d7fa016 | 2011-10-01 08:36:59 +0000 | [diff] [blame] | 225 | |
Craig Topper | 6bc27bf | 2014-03-10 02:09:33 +0000 | [diff] [blame] | 226 | int getExistingMachineCPValue(MachineConstantPool *CP, |
| 227 | unsigned Alignment) override; |
Bill Wendling | d7fa016 | 2011-10-01 08:36:59 +0000 | [diff] [blame] | 228 | |
Craig Topper | 6bc27bf | 2014-03-10 02:09:33 +0000 | [diff] [blame] | 229 | void addSelectionDAGCSEId(FoldingSetNodeID &ID) override; |
Bill Wendling | d7fa016 | 2011-10-01 08:36:59 +0000 | [diff] [blame] | 230 | |
| 231 | /// hasSameValue - Return true if this ARM constpool value can share the same |
| 232 | /// constantpool entry as another ARM constpool value. |
Craig Topper | 6bc27bf | 2014-03-10 02:09:33 +0000 | [diff] [blame] | 233 | bool hasSameValue(ARMConstantPoolValue *ACPV) override; |
Bill Wendling | d7fa016 | 2011-10-01 08:36:59 +0000 | [diff] [blame] | 234 | |
Craig Topper | 6bc27bf | 2014-03-10 02:09:33 +0000 | [diff] [blame] | 235 | void print(raw_ostream &O) const override; |
Bill Wendling | d7fa016 | 2011-10-01 08:36:59 +0000 | [diff] [blame] | 236 | |
| 237 | static bool classof(const ARMConstantPoolValue *ACPV) { |
| 238 | return ACPV->isExtSymbol(); |
| 239 | } |
Benjamin Kramer | 2ef689c | 2013-09-16 10:17:31 +0000 | [diff] [blame] | 240 | |
| 241 | bool equals(const ARMConstantPoolSymbol *A) const { |
| 242 | return S == A->S && ARMConstantPoolValue::equals(A); |
| 243 | } |
Bill Wendling | d7fa016 | 2011-10-01 08:36:59 +0000 | [diff] [blame] | 244 | }; |
| 245 | |
Bill Wendling | 6dbc9fe | 2011-10-01 09:19:10 +0000 | [diff] [blame] | 246 | /// ARMConstantPoolMBB - ARM-specific constantpool value of a machine basic |
| 247 | /// block. |
| 248 | class ARMConstantPoolMBB : public ARMConstantPoolValue { |
Bill Wendling | 4a4772f | 2011-10-01 09:30:42 +0000 | [diff] [blame] | 249 | const MachineBasicBlock *MBB; // Machine basic block. |
Bill Wendling | 6dbc9fe | 2011-10-01 09:19:10 +0000 | [diff] [blame] | 250 | |
Bill Wendling | 4a4772f | 2011-10-01 09:30:42 +0000 | [diff] [blame] | 251 | ARMConstantPoolMBB(LLVMContext &C, const MachineBasicBlock *mbb, unsigned id, |
Bill Wendling | 6dbc9fe | 2011-10-01 09:19:10 +0000 | [diff] [blame] | 252 | unsigned char PCAdj, ARMCP::ARMCPModifier Modifier, |
| 253 | bool AddCurrentAddress); |
| 254 | |
| 255 | public: |
Bill Wendling | 4a4772f | 2011-10-01 09:30:42 +0000 | [diff] [blame] | 256 | static ARMConstantPoolMBB *Create(LLVMContext &C, |
| 257 | const MachineBasicBlock *mbb, |
Bill Wendling | 6dbc9fe | 2011-10-01 09:19:10 +0000 | [diff] [blame] | 258 | unsigned ID, unsigned char PCAdj); |
| 259 | |
| 260 | const MachineBasicBlock *getMBB() const { return MBB; } |
| 261 | |
Craig Topper | 6bc27bf | 2014-03-10 02:09:33 +0000 | [diff] [blame] | 262 | int getExistingMachineCPValue(MachineConstantPool *CP, |
| 263 | unsigned Alignment) override; |
Bill Wendling | 6dbc9fe | 2011-10-01 09:19:10 +0000 | [diff] [blame] | 264 | |
Craig Topper | 6bc27bf | 2014-03-10 02:09:33 +0000 | [diff] [blame] | 265 | void addSelectionDAGCSEId(FoldingSetNodeID &ID) override; |
Bill Wendling | 6dbc9fe | 2011-10-01 09:19:10 +0000 | [diff] [blame] | 266 | |
| 267 | /// hasSameValue - Return true if this ARM constpool value can share the same |
| 268 | /// constantpool entry as another ARM constpool value. |
Craig Topper | 6bc27bf | 2014-03-10 02:09:33 +0000 | [diff] [blame] | 269 | bool hasSameValue(ARMConstantPoolValue *ACPV) override; |
Bill Wendling | 6dbc9fe | 2011-10-01 09:19:10 +0000 | [diff] [blame] | 270 | |
Craig Topper | 6bc27bf | 2014-03-10 02:09:33 +0000 | [diff] [blame] | 271 | void print(raw_ostream &O) const override; |
Bill Wendling | 6dbc9fe | 2011-10-01 09:19:10 +0000 | [diff] [blame] | 272 | |
| 273 | static bool classof(const ARMConstantPoolValue *ACPV) { |
| 274 | return ACPV->isMachineBasicBlock(); |
| 275 | } |
Benjamin Kramer | 2ef689c | 2013-09-16 10:17:31 +0000 | [diff] [blame] | 276 | |
| 277 | bool equals(const ARMConstantPoolMBB *A) const { |
| 278 | return MBB == A->MBB && ARMConstantPoolValue::equals(A); |
| 279 | } |
Bill Wendling | 6dbc9fe | 2011-10-01 09:19:10 +0000 | [diff] [blame] | 280 | }; |
| 281 | |
Eugene Zelenko | e79c077 | 2017-01-27 23:58:02 +0000 | [diff] [blame] | 282 | } // end namespace llvm |
Evan Cheng | 10043e2 | 2007-01-19 07:51:42 +0000 | [diff] [blame] | 283 | |
Eugene Zelenko | e79c077 | 2017-01-27 23:58:02 +0000 | [diff] [blame] | 284 | #endif // LLVM_LIB_TARGET_ARM_ARMCONSTANTPOOLVALUE_H |