LLVM: lib/Target/CSKY/MCTargetDesc/CSKYELFStreamer.cpp Source File (original) (raw)

1

2

3

4

5

6

7

8

9

10

11

12

28

29using namespace llvm;

30

31

37

38 unsigned EFlags = W.getELFHeaderEFlags();

39

41

42 if (Features[CSKY::ProcCK801])

44 else if (Features[CSKY::ProcCK802])

46 else if (Features[CSKY::ProcCK803])

48 else if (Features[CSKY::ProcCK804])

50 else if (Features[CSKY::ProcCK805])

52 else if (Features[CSKY::ProcCK807])

54 else if (Features[CSKY::ProcCK810])

56 else if (Features[CSKY::ProcCK860])

58 else

60

61 if (Features[CSKY::FeatureFPUV2_SF] || Features[CSKY::FeatureFPUV3_SF])

63

65

66 W.setELFHeaderEFlags(EFlags);

67}

68

72

73void CSKYTargetELFStreamer::emitAttribute(unsigned Attribute, unsigned Value) {

74 setAttributeItem(Attribute, Value, true);

75}

76

77void CSKYTargetELFStreamer::emitTextAttribute(unsigned Attribute,

79 setAttributeItem(Attribute, String, true);

80}

81

83 if (Contents.empty())

84 return;

85

86 if (AttributeSection) {

87 Streamer.switchSection(AttributeSection);

88 } else {

92 Streamer.switchSection(AttributeSection);

94 }

95

96

97 const size_t VendorHeaderSize = 4 + CurrentVendor.size() + 1;

98

99

100 const size_t TagHeaderSize = 1 + 4;

101

102 const size_t ContentsSize = calculateContentSize();

103

104 Streamer.emitInt32(VendorHeaderSize + TagHeaderSize + ContentsSize);

105 Streamer.emitBytes(CurrentVendor);

106 Streamer.emitInt8(0);

107

109 Streamer.emitInt32(TagHeaderSize + ContentsSize);

110

111

112

113 for (AttributeItem item : Contents) {

114 Streamer.emitULEB128IntValue(item.Tag);

115 switch (item.Type) {

116 default:

118 case AttributeType::Numeric:

119 Streamer.emitULEB128IntValue(item.IntValue);

120 break;

121 case AttributeType::Text:

122 Streamer.emitBytes(item.StringValue);

123 Streamer.emitInt8(0);

124 break;

125 case AttributeType::NumericAndText:

126 Streamer.emitULEB128IntValue(item.IntValue);

127 Streamer.emitBytes(item.StringValue);

128 Streamer.emitInt8(0);

129 break;

130 }

131 }

132

133 Contents.clear();

134}

135

136size_t CSKYTargetELFStreamer::calculateContentSize() const {

138 for (AttributeItem item : Contents) {

139 switch (item.Type) {

140 case AttributeType::Hidden:

141 break;

142 case AttributeType::Numeric:

145 break;

146 case AttributeType::Text:

148 Result += item.StringValue.size() + 1;

149 break;

150 case AttributeType::NumericAndText:

153 Result += item.StringValue.size() + 1;

154 break;

155 }

156 }

158}

159

160void CSKYELFStreamer::EmitMappingSymbol(StringRef Name) {

162 return;

164 return;

167 return;

168 }

169

171

175

178}

179

180void CSKYTargetELFStreamer::emitTargetAttributes(const MCSubtargetInfo &STI) {

181 StringRef CPU = STI.getCPU();

183

184 if (ArchID == CSKY::ArchKind::CK804)

185 ArchID = CSKY::ArchKind::CK803;

186

188

189 if (ArchID == CSKY::ArchKind::INVALID) {

190 CPU = "ck810";

191 CPU_ARCH = "ck810";

192 }

195

196 unsigned ISAFlag = 0;

199

202

205

208

211

212 if (STI.hasFeature(CSKY::Has3r1E3r2))

214

215 if (STI.hasFeature(CSKY::Has3r2E3r3))

217

220

223

226

229

230 if (STI.hasFeature(CSKY::FeatureTrust))

232

233 if (STI.hasFeature(CSKY::FeatureJAVA))

235

236 if (STI.hasFeature(CSKY::FeatureCache))

238

239 if (STI.hasFeature(CSKY::FeatureNVIC))

241

242 if (STI.hasFeature(CSKY::FeatureDSP))

244

247

250

251 if (STI.hasFeature(CSKY::FeatureDSPV2))

253

254 if (STI.hasFeature(CSKY::FeatureDSP_Silan))

256

257 if (STI.hasFeature(CSKY::FeatureVDSPV1_128))

259

260 if (STI.hasFeature(CSKY::FeatureVDSPV2))

262

263 if (STI.hasFeature(CSKY::HasVDSP2E3))

265

266 if (STI.hasFeature(CSKY::HasVDSP2E60F))

268

270

271 unsigned ISAExtFlag = 0;

272 if (STI.hasFeature(CSKY::HasFLOATE1))

274

275 if (STI.hasFeature(CSKY::HasFLOAT1E2))

277

278 if (STI.hasFeature(CSKY::HasFLOAT1E3))

280

281 if (STI.hasFeature(CSKY::HasFLOAT3E4))

283

284 if (STI.hasFeature(CSKY::HasFLOAT7E60))

286

288

289 if (STI.hasFeature(CSKY::FeatureDSP))

292 if (STI.hasFeature(CSKY::FeatureDSPV2))

294

295 if (STI.hasFeature(CSKY::FeatureVDSPV2))

297

298 if (STI.hasFeature(CSKY::FeatureFPUV2_SF) ||

299 STI.hasFeature(CSKY::FeatureFPUV2_DF))

301 else if (STI.hasFeature(CSKY::FeatureFPUV3_HF) ||

302 STI.hasFeature(CSKY::FeatureFPUV3_SF) ||

303 STI.hasFeature(CSKY::FeatureFPUV3_DF))

305

306 bool hasAnyFloatExt = STI.hasFeature(CSKY::FeatureFPUV2_SF) ||

307 STI.hasFeature(CSKY::FeatureFPUV2_DF) ||

308 STI.hasFeature(CSKY::FeatureFPUV3_HF) ||

309 STI.hasFeature(CSKY::FeatureFPUV3_SF) ||

310 STI.hasFeature(CSKY::FeatureFPUV3_DF);

311

312 if (hasAnyFloatExt && STI.hasFeature(CSKY::ModeHardFloat) &&

313 STI.hasFeature(CSKY::ModeHardFloatABI))

315 else if (hasAnyFloatExt && STI.hasFeature(CSKY::ModeHardFloat))

317 else

319

320 unsigned HardFPFlag = 0;

321 if (STI.hasFeature(CSKY::FeatureFPUV3_HF))

323 if (STI.hasFeature(CSKY::FeatureFPUV2_SF) ||

324 STI.hasFeature(CSKY::FeatureFPUV3_SF))

326 if (STI.hasFeature(CSKY::FeatureFPUV2_DF) ||

327 STI.hasFeature(CSKY::FeatureFPUV3_DF))

329

330 if (HardFPFlag != 0) {

335 }

336}

Functions, function parameters, and return types can have attributes to indicate how they should be t...

MCELFStreamer & getStreamer()

Definition CSKYELFStreamer.cpp:69

CSKYTargetELFStreamer(MCStreamer &S, const MCSubtargetInfo &STI)

Definition CSKYELFStreamer.cpp:32

virtual void finishAttributeSection()

CSKYTargetStreamer(MCStreamer &S)

Container class for subtarget features.

MCContext & getContext() const

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

LLVM_ABI MCSymbol * createLocalSymbol(StringRef Name)

Create a local, non-temporary symbol like an ELF mapping symbol.

ELFObjectWriter & getWriter()

void emitLabel(MCSymbol *Symbol, SMLoc Loc=SMLoc()) override

Emit a label for Symbol into the current section.

MCAssembler & getAssembler()

Streaming machine code generation interface.

MCContext & getContext() const

Generic base class for all target subtargets.

bool hasFeature(unsigned Feature) const

const FeatureBitset & getFeatureBits() const

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

LLVM Value Representation.

#define llvm_unreachable(msg)

Marks that the current location is not supposed to be reachable.

LLVM_ABI ArchKind parseCPUArch(StringRef CPU)

LLVM_ABI StringRef getArchName(ArchKind AK)

This is an optimization pass for GlobalISel generic memory operations.

LLVM_ABI unsigned getULEB128Size(uint64_t Value)

Utility function to get the size of the ULEB128-encoded value.