LLVM: lib/Target/Mips/MipsTargetObjectFile.cpp Source File (original) (raw)

1

2

3

4

5

6

7

8

20using namespace llvm;

21

24 cl::desc("Small data and bss section threshold size (default=8)"),

26

29 cl::desc("MIPS: Use gp_rel for object-local data."),

31

34 cl::desc("MIPS: Use gp_rel for data that is not defined by the "

35 "current object."),

37

40 cl::desc("MIPS: Try to allocate variables in the following"

41 " sections if possible: .rodata, .sdata, .data ."),

43

46

50

55}

56

57

58

59

61

62

64}

65

66

67

68bool MipsTargetObjectFile::IsGlobalInSmallSection(

70

71

72

74 return IsGlobalInSmallSectionImpl(GO, TM);

75

76 return IsGlobalInSmallSection(GO, TM, getKindForGlobal(GO, TM));

77}

78

79

80

81bool MipsTargetObjectFile::

84 return IsGlobalInSmallSectionImpl(GO, TM) &&

85 (Kind.isData() || Kind.isBSS() || Kind.isCommon() ||

86 Kind.isReadOnly());

87}

88

89

90

91

92bool MipsTargetObjectFile::

93IsGlobalInSmallSectionImpl(const GlobalObject *GO,

97

98

100 return false;

101

102

103 const GlobalVariable *GVA = dyn_cast(GO);

104 if (!GVA)

105 return false;

106

107

108

111

112

113

114 if (Section == ".sdata" || Section == ".sbss")

115 return true;

116

117

118

119

120 return false;

121 }

122

123

125 return false;

126

127

130 return false;

131

132

134 return false;

135

137

138

139

140

142 return false;

143

146}

147

150

151

152

153

154 if (Kind.isBSS() && IsGlobalInSmallSection(GO, TM, Kind))

155 return SmallBSSSection;

156 if (Kind.isData() && IsGlobalInSmallSection(GO, TM, Kind))

157 return SmallDataSection;

158 if (Kind.isReadOnly() && IsGlobalInSmallSection(GO, TM, Kind))

159 return SmallDataSection;

160

161

163}

164

165

169 .getSubtargetImpl()

170 ->useSmallSection() &&

172}

173

174

178 Align &Alignment) const {

180 return SmallDataSection;

181

182

184 Alignment);

185}

186

194}

MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL

static cl::opt< unsigned > SSThreshold("lanai-ssection-threshold", cl::Hidden, cl::desc("Small data and bss section threshold size (default=0)"), cl::init(0))

static cl::opt< bool > ExternSData("mextern-sdata", cl::Hidden, cl::desc("MIPS: Use gp_rel for data that is not defined by the " "current object."), cl::init(true))

static cl::opt< unsigned > SSThreshold("mips-ssection-threshold", cl::Hidden, cl::desc("Small data and bss section threshold size (default=8)"), cl::init(8))

static cl::opt< bool > LocalSData("mlocal-sdata", cl::Hidden, cl::desc("MIPS: Use gp_rel for object-local data."), cl::init(true))

static bool IsInSmallSection(uint64_t Size)

static cl::opt< bool > EmbeddedData("membedded-data", cl::Hidden, cl::desc("MIPS: Try to allocate variables in the following" " sections if possible: .rodata, .sdata, .data ."), cl::init(false))

This is an important base class in LLVM.

A parsed version of the target data layout string in and methods for querying it.

TypeSize getTypeAllocSize(Type *Ty) const

Returns the offset in bytes between successive objects of the specified type, including alignment pad...

StringRef getSection() const

Get the custom section of this global if it has one.

bool hasSection() const

Check if this global has a custom object file section.

bool hasExternalLinkage() const

bool isDeclaration() const

Return true if the primary definition of this global value is outside of the current translation unit...

bool hasLocalLinkage() const

const DataLayout & getDataLayout() const

Get the data layout of the module this global belongs to.

bool hasCommonLinkage() const

bool hasAvailableExternallyLinkage() const

Type * getValueType() const

bool isConstant() const

If the value is a global constant, its value is immutable throughout the runtime execution of the pro...

static const MCBinaryExpr * createAdd(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx)

static const MCConstantExpr * create(int64_t Value, MCContext &Ctx, bool PrintInHex=false, unsigned SizeInBytes=0)

Context object for machine code objects.

MCSectionELF * getELFSection(const Twine &Section, unsigned Type, unsigned Flags)

Base class for the full range of assembler expressions which are needed for parsing.

MCContext & getContext() const

Instances of this class represent a uniqued identifier for a section in the current translation unit.

static const MCSymbolRefExpr * create(const MCSymbol *Symbol, MCContext &Ctx)

MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...

static const MipsMCExpr * create(MipsExprKind Kind, const MCExpr *Expr, MCContext &Ctx)

bool useSmallSection() const

MCSection * getSectionForConstant(const DataLayout &DL, SectionKind Kind, const Constant *C, Align &Alignment) const override

Return true if this constant should be placed into small data section.

MCSection * SelectSectionForGlobal(const GlobalObject *GO, SectionKind Kind, const TargetMachine &TM) const override

const MCExpr * getDebugThreadLocalSymbol(const MCSymbol *Sym) const override

Describe a TLS variable address within debug info.

bool IsConstantInSmallSection(const DataLayout &DL, const Constant *CN, const TargetMachine &TM) const

Return true if this constant should be placed into small data section.

void Initialize(MCContext &Ctx, const TargetMachine &TM) override

This method must be called before any actual lowering is done.

SectionKind - This is a simple POD value that classifies the properties of a section.

StringRef - Represent a constant reference to a string, i.e.

void Initialize(MCContext &Ctx, const TargetMachine &TM) override

This method must be called before any actual lowering is done.

MCSection * getSectionForConstant(const DataLayout &DL, SectionKind Kind, const Constant *C, Align &Alignment) const override

Given a constant with the SectionKind, return a section that it should be placed in.

MCSection * SelectSectionForGlobal(const GlobalObject *GO, SectionKind Kind, const TargetMachine &TM) const override

static SectionKind getKindForGlobal(const GlobalObject *GO, const TargetMachine &TM)

Classify the specified global variable into a set of target independent categories embodied in Sectio...

Primary interface to the complete machine description for the target machine.

The instances of the Type class are immutable: once they are created, they are never changed.

bool isSized(SmallPtrSetImpl< Type * > *Visited=nullptr) const

Return true if it makes sense to take the size of this type.

Type * getType() const

All values are typed, get the type of this value.

@ C

The default llvm calling convention, compatible with C.

initializer< Ty > init(const Ty &Val)

This is an optimization pass for GlobalISel generic memory operations.

This struct is a compact representation of a valid (non-zero power of two) alignment.