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