| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
#ifndef LLVM_TARGET_TARGETLOWERINGOBJECTFILE_H |
| 15 |
#define LLVM_TARGET_TARGETLOWERINGOBJECTFILE_H |
| 16 |
|
| 17 |
#include "llvm/MC/MCObjectFileInfo.h" |
| 18 |
#include "llvm/MC/MCRegister.h" |
| 19 |
#include <cstdint> |
| 20 |
|
| 21 |
namespace llvm { |
| 22 |
|
| 23 |
class Constant; |
| 24 |
class DataLayout; |
| 25 |
class Function; |
| 26 |
class GlobalObject; |
| 27 |
class GlobalValue; |
| 28 |
class MachineBasicBlock; |
| 29 |
class MachineModuleInfo; |
| 30 |
class Mangler; |
| 31 |
class MCContext; |
| 32 |
class MCExpr; |
| 33 |
class MCSection; |
| 34 |
class MCSymbol; |
| 35 |
class MCSymbolRefExpr; |
| 36 |
class MCStreamer; |
| 37 |
class MCValue; |
| 38 |
class Module; |
| 39 |
class SectionKind; |
| 40 |
class StringRef; |
| 41 |
class TargetMachine; |
| 42 |
class DSOLocalEquivalent; |
| 43 |
|
| 44 |
class TargetLoweringObjectFile : public MCObjectFileInfo { |
| 45 |
|
| 46 |
Mangler *Mang = nullptr; |
| 47 |
|
| 48 |
protected: |
| 49 |
bool SupportIndirectSymViaGOTPCRel = false; |
| 50 |
bool SupportGOTPCRelWithOffset = true; |
| 51 |
bool SupportDebugThreadLocalLocation = true; |
| 52 |
bool SupportDSOLocalEquivalentLowering = false; |
| 53 |
|
| 54 |
|
| 55 |
|
| 56 |
unsigned PersonalityEncoding = 0; |
| 57 |
unsigned LSDAEncoding = 0; |
| 58 |
unsigned TTypeEncoding = 0; |
| 59 |
unsigned CallSiteEncoding = 0; |
| 60 |
|
| 61 |
|
| 62 |
MCSection *StaticCtorSection = nullptr; |
| 63 |
|
| 64 |
|
| 65 |
MCSection *StaticDtorSection = nullptr; |
| 66 |
|
| 67 |
const TargetMachine *TM = nullptr; |
| 68 |
|
| 69 |
public: |
| 70 |
TargetLoweringObjectFile() = default; |
| 71 |
TargetLoweringObjectFile(const TargetLoweringObjectFile &) = delete; |
| 72 |
TargetLoweringObjectFile & |
| 73 |
operator=(const TargetLoweringObjectFile &) = delete; |
| 74 |
virtual ~TargetLoweringObjectFile(); |
| 75 |
|
| 76 |
Mangler &getMangler() const { return *Mang; } |
| 77 |
|
| 78 |
|
| 79 |
|
| 80 |
|
| 81 |
virtual void Initialize(MCContext &ctx, const TargetMachine &TM); |
| 82 |
|
| 83 |
virtual void emitPersonalityValue(MCStreamer &Streamer, const DataLayout &TM, |
| 84 |
const MCSymbol *Sym) const; |
| 85 |
|
| 86 |
|
| 87 |
virtual void emitModuleMetadata(MCStreamer &Streamer, Module &M) const {} |
| 88 |
|
| 89 |
|
| 90 |
void emitCGProfileMetadata(MCStreamer &Streamer, Module &M) const; |
| 91 |
|
| 92 |
|
| 93 |
virtual void getModuleMetadata(Module &M) {} |
| 94 |
|
| 95 |
|
| 96 |
|
| 97 |
virtual MCSection *getSectionForConstant(const DataLayout &DL, |
| 98 |
SectionKind Kind, const Constant *C, |
| 99 |
Align &Alignment) const; |
| 100 |
|
| 101 |
virtual MCSection * |
| 102 |
getSectionForMachineBasicBlock(const Function &F, |
| 103 |
const MachineBasicBlock &MBB, |
| 104 |
const TargetMachine &TM) const; |
| 105 |
|
| 106 |
virtual MCSection * |
| 107 |
getUniqueSectionForFunction(const Function &F, |
| 108 |
const TargetMachine &TM) const; |
| 109 |
|
| 110 |
|
| 111 |
|
| 112 |
static SectionKind getKindForGlobal(const GlobalObject *GO, |
| 113 |
const TargetMachine &TM); |
| 114 |
|
| 115 |
|
| 116 |
|
| 117 |
|
| 118 |
MCSection *SectionForGlobal(const GlobalObject *GO, SectionKind Kind, |
| 119 |
const TargetMachine &TM) const; |
| 120 |
|
| 121 |
|
| 122 |
|
| 123 |
|
| 124 |
MCSection *SectionForGlobal(const GlobalObject *GO, |
| 125 |
const TargetMachine &TM) const; |
| 126 |
|
| 127 |
virtual void getNameWithPrefix(SmallVectorImpl<char> &OutName, |
| 128 |
const GlobalValue *GV, |
| 129 |
const TargetMachine &TM) const; |
| 130 |
|
| 131 |
virtual MCSection *getSectionForJumpTable(const Function &F, |
| 132 |
const TargetMachine &TM) const; |
| 133 |
virtual MCSection *getSectionForLSDA(const Function &, const MCSymbol &, |
| 134 |
const TargetMachine &) const { |
| 135 |
return LSDASection; |
| 136 |
} |
| 137 |
|
| 138 |
virtual bool shouldPutJumpTableInFunctionSection(bool UsesLabelDifference, |
| 139 |
const Function &F) const; |
| 140 |
|
| 141 |
|
| 142 |
|
| 143 |
|
| 144 |
virtual MCSection * |
| 145 |
getExplicitSectionGlobal(const GlobalObject *GO, SectionKind Kind, |
| 146 |
const TargetMachine &TM) const = 0; |
| 147 |
|
| 148 |
|
| 149 |
|
| 150 |
virtual const MCExpr *getTTypeGlobalReference(const GlobalValue *GV, |
| 151 |
unsigned Encoding, |
| 152 |
const TargetMachine &TM, |
| 153 |
MachineModuleInfo *MMI, |
| 154 |
MCStreamer &Streamer) const; |
| 155 |
|
| 156 |
|
| 157 |
|
| 158 |
MCSymbol *getSymbolWithGlobalValueBase(const GlobalValue *GV, |
| 159 |
StringRef Suffix, |
| 160 |
const TargetMachine &TM) const; |
| 161 |
|
| 162 |
|
| 163 |
virtual MCSymbol *getCFIPersonalitySymbol(const GlobalValue *GV, |
| 164 |
const TargetMachine &TM, |
| 165 |
MachineModuleInfo *MMI) const; |
| 166 |
|
| 167 |
unsigned getPersonalityEncoding() const { return PersonalityEncoding; } |
| 168 |
unsigned getLSDAEncoding() const { return LSDAEncoding; } |
| 169 |
unsigned getTTypeEncoding() const { return TTypeEncoding; } |
| 170 |
unsigned getCallSiteEncoding() const; |
| 171 |
|
| 172 |
const MCExpr *getTTypeReference(const MCSymbolRefExpr *Sym, unsigned Encoding, |
| 173 |
MCStreamer &Streamer) const; |
| 174 |
|
| 175 |
virtual MCSection *getStaticCtorSection(unsigned Priority, |
| 176 |
const MCSymbol *KeySym) const { |
| 177 |
return StaticCtorSection; |
| 178 |
} |
| 179 |
|
| 180 |
virtual MCSection *getStaticDtorSection(unsigned Priority, |
| 181 |
const MCSymbol *KeySym) const { |
| 182 |
return StaticDtorSection; |
| 183 |
} |
| 184 |
|
| 185 |
|
| 186 |
|
| 187 |
virtual const MCExpr *getDebugThreadLocalSymbol(const MCSymbol *Sym) const; |
| 188 |
|
| 189 |
virtual const MCExpr *lowerRelativeReference(const GlobalValue *LHS, |
| 190 |
const GlobalValue *RHS, |
| 191 |
const TargetMachine &TM) const { |
| 192 |
return nullptr; |
| 193 |
} |
| 194 |
|
| 195 |
|
| 196 |
|
| 197 |
bool supportDSOLocalEquivalentLowering() const { |
| 198 |
return SupportDSOLocalEquivalentLowering; |
| 199 |
} |
| 200 |
|
| 201 |
virtual const MCExpr *lowerDSOLocalEquivalent(const DSOLocalEquivalent *Equiv, |
| 202 |
const TargetMachine &TM) const { |
| 203 |
return nullptr; |
| 204 |
} |
| 205 |
|
| 206 |
|
| 207 |
|
| 208 |
bool supportIndirectSymViaGOTPCRel() const { |
| 209 |
return SupportIndirectSymViaGOTPCRel; |
| 210 |
} |
| 211 |
|
| 212 |
|
| 213 |
|
| 214 |
bool supportGOTPCRelWithOffset() const { |
| 215 |
return SupportGOTPCRelWithOffset; |
| 216 |
} |
| 217 |
|
| 218 |
|
| 219 |
bool supportDebugThreadLocalLocation() const { |
| 220 |
return SupportDebugThreadLocalLocation; |
| 221 |
} |
| 222 |
|
| 223 |
|
| 224 |
virtual MCRegister getStaticBase() const { return MCRegister::NoRegister; } |
| 225 |
|
| 226 |
|
| 227 |
virtual const MCExpr *getIndirectSymViaRWPI(const MCSymbol *Sym) const { |
| 228 |
return nullptr; |
| 229 |
} |
| 230 |
|
| 231 |
|
| 232 |
virtual const MCExpr *getIndirectSymViaGOTPCRel(const GlobalValue *GV, |
| 233 |
const MCSymbol *Sym, |
| 234 |
const MCValue &MV, |
| 235 |
int64_t Offset, |
| 236 |
MachineModuleInfo *MMI, |
| 237 |
MCStreamer &Streamer) const { |
| 238 |
return nullptr; |
| 239 |
} |
| 240 |
|
| 241 |
|
| 242 |
|
| 243 |
virtual MCSection *getSectionForCommandLines() const { |
| 244 |
return nullptr; |
| 245 |
} |
| 246 |
|
| 247 |
|
| 248 |
|
| 249 |
virtual MCSection * |
| 250 |
getSectionForFunctionDescriptor(const Function *F, |
| 251 |
const TargetMachine &TM) const { |
| 252 |
return nullptr; |
| 253 |
} |
| 254 |
|
| 255 |
|
| 256 |
|
| 257 |
|
| 258 |
virtual MCSection *getSectionForTOCEntry(const MCSymbol *S, |
| 259 |
const TargetMachine &TM) const { |
| 260 |
return nullptr; |
| 261 |
} |
| 262 |
|
| 263 |
|
| 264 |
|
| 265 |
virtual MCSection * |
| 266 |
getSectionForExternalReference(const GlobalObject *GO, |
| 267 |
const TargetMachine &TM) const { |
| 268 |
return nullptr; |
| 269 |
} |
| 270 |
|
| 271 |
|
| 272 |
|
| 273 |
virtual MCSymbol *getTargetSymbol(const GlobalValue *GV, |
| 274 |
const TargetMachine &TM) const { |
| 275 |
return nullptr; |
| 276 |
} |
| 277 |
|
| 278 |
|
| 279 |
|
| 280 |
|
| 281 |
virtual MCSymbol *getFunctionEntryPointSymbol(const GlobalValue *Func, |
| 282 |
const TargetMachine &TM) const { |
| 283 |
return nullptr; |
| 284 |
} |
| 285 |
|
| 286 |
protected: |
| 287 |
virtual MCSection *SelectSectionForGlobal(const GlobalObject *GO, |
| 288 |
SectionKind Kind, |
| 289 |
const TargetMachine &TM) const = 0; |
| 290 |
}; |
| 291 |
|
| 292 |
} |
| 293 |
|
| 294 |
#endif |