1 //===-- AMDGPUHSATargetObjectFile.cpp - AMDGPU Object Files ---------------===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
9 #include "AMDGPUTargetObjectFile.h"
11 #include "AMDGPUTargetMachine.h"
12 #include "Utils/AMDGPUBaseInfo.h"
13 #include "llvm/BinaryFormat/ELF.h"
14 #include "llvm/MC/MCContext.h"
15 #include "llvm/MC/MCSectionELF.h"
19 //===----------------------------------------------------------------------===//
20 // Generic Object File
21 //===----------------------------------------------------------------------===//
23 MCSection
*AMDGPUTargetObjectFile::SelectSectionForGlobal(
24 const GlobalObject
*GO
, SectionKind Kind
, const TargetMachine
&TM
) const {
25 if (Kind
.isReadOnly() && AMDGPU::isReadOnlySegment(GO
) &&
26 AMDGPU::shouldEmitConstantsToTextSection(TM
.getTargetTriple()))
29 return TargetLoweringObjectFileELF::SelectSectionForGlobal(GO
, Kind
, TM
);
32 MCSection
*AMDGPUTargetObjectFile::getExplicitSectionGlobal(
33 const GlobalObject
*GO
, SectionKind SK
, const TargetMachine
&TM
) const {
34 // Set metadata access for the explicit section
35 StringRef SectionName
= GO
->getSection();
36 if (SectionName
.startswith(".AMDGPU.comment."))
37 SK
= SectionKind::getMetadata();
39 return TargetLoweringObjectFileELF::getExplicitSectionGlobal(GO
, SK
, TM
);