| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
#ifndef LLVM_CODEGEN_PSEUDOSOURCEVALUE_H |
| 14 |
#define LLVM_CODEGEN_PSEUDOSOURCEVALUE_H |
| 15 |
|
| 16 |
#include "llvm/ADT/StringMap.h" |
| 17 |
#include "llvm/IR/ValueMap.h" |
| 18 |
#include <map> |
| 19 |
|
| 20 |
namespace llvm { |
| 21 |
|
| 22 |
class GlobalValue; |
| 23 |
class MachineFrameInfo; |
| 24 |
class MachineMemOperand; |
| 25 |
class MIRFormatter; |
| 26 |
class PseudoSourceValue; |
| 27 |
class raw_ostream; |
| 28 |
class TargetInstrInfo; |
| 29 |
|
| 30 |
raw_ostream &operator<<(raw_ostream &OS, const PseudoSourceValue* PSV); |
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
class PseudoSourceValue { |
| 36 |
public: |
| 37 |
enum PSVKind : unsigned { |
| 38 |
Stack, |
| 39 |
GOT, |
| 40 |
JumpTable, |
| 41 |
ConstantPool, |
| 42 |
FixedStack, |
| 43 |
GlobalValueCallEntry, |
| 44 |
ExternalSymbolCallEntry, |
| 45 |
TargetCustom |
| 46 |
}; |
| 47 |
|
| 48 |
private: |
| 49 |
unsigned Kind; |
| 50 |
unsigned AddressSpace; |
| 51 |
friend raw_ostream &llvm::operator<<(raw_ostream &OS, |
| 52 |
const PseudoSourceValue* PSV); |
| 53 |
|
| 54 |
friend class MachineMemOperand; |
| 55 |
friend class MIRFormatter; |
| 56 |
|
| 57 |
|
| 58 |
|
| 59 |
virtual void printCustom(raw_ostream &O) const; |
| 60 |
|
| 61 |
public: |
| 62 |
explicit PseudoSourceValue(unsigned Kind, const TargetInstrInfo &TII); |
| 63 |
|
| 64 |
virtual ~PseudoSourceValue(); |
| 65 |
|
| 66 |
unsigned kind() const { return Kind; } |
| 67 |
|
| 68 |
bool isStack() const { return Kind == Stack; } |
| 69 |
bool isGOT() const { return Kind == GOT; } |
| 70 |
bool isConstantPool() const { return Kind == ConstantPool; } |
| 71 |
bool isJumpTable() const { return Kind == JumpTable; } |
| 72 |
|
| 73 |
unsigned getAddressSpace() const { return AddressSpace; } |
| 74 |
|
| 75 |
unsigned getTargetCustom() const { |
| 76 |
return (Kind >= TargetCustom) ? ((Kind+1) - TargetCustom) : 0; |
| 77 |
} |
| 78 |
|
| 79 |
|
| 80 |
|
| 81 |
virtual bool isConstant(const MachineFrameInfo *) const; |
| 82 |
|
| 83 |
|
| 84 |
|
| 85 |
virtual bool isAliased(const MachineFrameInfo *) const; |
| 86 |
|
| 87 |
|
| 88 |
|
| 89 |
virtual bool mayAlias(const MachineFrameInfo *) const; |
| 90 |
}; |
| 91 |
|
| 92 |
|
| 93 |
|
| 94 |
class FixedStackPseudoSourceValue : public PseudoSourceValue { |
| 95 |
const int FI; |
| 96 |
|
| 97 |
public: |
| 98 |
explicit FixedStackPseudoSourceValue(int FI, const TargetInstrInfo &TII) |
| 99 |
: PseudoSourceValue(FixedStack, TII), FI(FI) {} |
| 100 |
|
| 101 |
static bool classof(const PseudoSourceValue *V) { |
| 102 |
return V->kind() == FixedStack; |
| 103 |
} |
| 104 |
|
| 105 |
bool isConstant(const MachineFrameInfo *MFI) const override; |
| 106 |
|
| 107 |
bool isAliased(const MachineFrameInfo *MFI) const override; |
| 108 |
|
| 109 |
bool mayAlias(const MachineFrameInfo *) const override; |
| 110 |
|
| 111 |
void printCustom(raw_ostream &OS) const override; |
| 112 |
|
| 113 |
int getFrameIndex() const { return FI; } |
| 114 |
}; |
| 115 |
|
| 116 |
class CallEntryPseudoSourceValue : public PseudoSourceValue { |
| 117 |
protected: |
| 118 |
CallEntryPseudoSourceValue(unsigned Kind, const TargetInstrInfo &TII); |
| 119 |
|
| 120 |
public: |
| 121 |
bool isConstant(const MachineFrameInfo *) const override; |
| 122 |
bool isAliased(const MachineFrameInfo *) const override; |
| 123 |
bool mayAlias(const MachineFrameInfo *) const override; |
| 124 |
}; |
| 125 |
|
| 126 |
|
| 127 |
class GlobalValuePseudoSourceValue : public CallEntryPseudoSourceValue { |
| 128 |
const GlobalValue *GV; |
| 129 |
|
| 130 |
public: |
| 131 |
GlobalValuePseudoSourceValue(const GlobalValue *GV, |
| 132 |
const TargetInstrInfo &TII); |
| 133 |
|
| 134 |
static bool classof(const PseudoSourceValue *V) { |
| 135 |
return V->kind() == GlobalValueCallEntry; |
| 136 |
} |
| 137 |
|
| 138 |
const GlobalValue *getValue() const { return GV; } |
| 139 |
}; |
| 140 |
|
| 141 |
|
| 142 |
class ExternalSymbolPseudoSourceValue : public CallEntryPseudoSourceValue { |
| 143 |
const char *ES; |
| 144 |
|
| 145 |
public: |
| 146 |
ExternalSymbolPseudoSourceValue(const char *ES, const TargetInstrInfo &TII); |
| 147 |
|
| 148 |
static bool classof(const PseudoSourceValue *V) { |
| 149 |
return V->kind() == ExternalSymbolCallEntry; |
| 150 |
} |
| 151 |
|
| 152 |
const char *getSymbol() const { return ES; } |
| 153 |
}; |
| 154 |
|
| 155 |
|
| 156 |
class PseudoSourceValueManager { |
| 157 |
const TargetInstrInfo &TII; |
| 158 |
const PseudoSourceValue StackPSV, GOTPSV, JumpTablePSV, ConstantPoolPSV; |
| 159 |
std::map<int, std::unique_ptr<FixedStackPseudoSourceValue>> FSValues; |
| 160 |
StringMap<std::unique_ptr<const ExternalSymbolPseudoSourceValue>> |
| 161 |
ExternalCallEntries; |
| 162 |
ValueMap<const GlobalValue *, |
| 163 |
std::unique_ptr<const GlobalValuePseudoSourceValue>> |
| 164 |
GlobalCallEntries; |
| 165 |
|
| 166 |
public: |
| 167 |
PseudoSourceValueManager(const TargetInstrInfo &TII); |
| 168 |
|
| 169 |
|
| 170 |
|
| 171 |
const PseudoSourceValue *getStack(); |
| 172 |
|
| 173 |
|
| 174 |
|
| 175 |
const PseudoSourceValue *getGOT(); |
| 176 |
|
| 177 |
|
| 178 |
|
| 179 |
|
| 180 |
const PseudoSourceValue *getConstantPool(); |
| 181 |
|
| 182 |
|
| 183 |
|
| 184 |
const PseudoSourceValue *getJumpTable(); |
| 185 |
|
| 186 |
|
| 187 |
|
| 188 |
const PseudoSourceValue *getFixedStack(int FI); |
| 189 |
|
| 190 |
const PseudoSourceValue *getGlobalValueCallEntry(const GlobalValue *GV); |
| 191 |
|
| 192 |
const PseudoSourceValue *getExternalSymbolCallEntry(const char *ES); |
| 193 |
}; |
| 194 |
|
| 195 |
} |
| 196 |
|
| 197 |
#endif |