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