1 //===-- AMDGPUHSATargetObjectFile.cpp - AMDGPU Object Files ---------------===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9
10 #include "AMDGPUTargetObjectFile.h"
11 #include "AMDGPU.h"
12 #include "AMDGPUTargetMachine.h"
13 #include "Utils/AMDGPUBaseInfo.h"
14 #include "llvm/BinaryFormat/ELF.h"
15 #include "llvm/MC/MCContext.h"
16 #include "llvm/MC/MCSectionELF.h"
17
18 using namespace llvm;
19
20 //===----------------------------------------------------------------------===//
21 // Generic Object File
22 //===----------------------------------------------------------------------===//
23
SelectSectionForGlobal(const GlobalObject * GO,SectionKind Kind,const TargetMachine & TM) const24 MCSection *AMDGPUTargetObjectFile::SelectSectionForGlobal(
25 const GlobalObject *GO, SectionKind Kind, const TargetMachine &TM) const {
26 if (Kind.isReadOnly() && AMDGPU::isReadOnlySegment(GO) &&
27 AMDGPU::shouldEmitConstantsToTextSection(TM.getTargetTriple()))
28 return TextSection;
29
30 return TargetLoweringObjectFileELF::SelectSectionForGlobal(GO, Kind, TM);
31 }
32
getExplicitSectionGlobal(const GlobalObject * GO,SectionKind SK,const TargetMachine & TM) const33 MCSection *AMDGPUTargetObjectFile::getExplicitSectionGlobal(
34 const GlobalObject *GO, SectionKind SK, const TargetMachine &TM) const {
35 // Set metadata access for the explicit section
36 StringRef SectionName = GO->getSection();
37 if (SectionName.startswith(".AMDGPU.comment."))
38 SK = SectionKind::getMetadata();
39
40 return TargetLoweringObjectFileELF::getExplicitSectionGlobal(GO, SK, TM);
41 }
42