1dd58ef01SDimitry Andric //===-- AMDGPUHSATargetObjectFile.cpp - AMDGPU Object Files ---------------===//
2dd58ef01SDimitry Andric //
3e6d15924SDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4e6d15924SDimitry Andric // See https://llvm.org/LICENSE.txt for license information.
5e6d15924SDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6dd58ef01SDimitry Andric //
7dd58ef01SDimitry Andric //===----------------------------------------------------------------------===//
8dd58ef01SDimitry Andric
9dd58ef01SDimitry Andric #include "AMDGPUTargetObjectFile.h"
107ab83427SDimitry Andric #include "Utils/AMDGPUBaseInfo.h"
11b60736ecSDimitry Andric #include "llvm/IR/GlobalObject.h"
12b60736ecSDimitry Andric #include "llvm/MC/SectionKind.h"
13b60736ecSDimitry Andric #include "llvm/Target/TargetMachine.h"
14dd58ef01SDimitry Andric using namespace llvm;
15dd58ef01SDimitry Andric
16dd58ef01SDimitry Andric //===----------------------------------------------------------------------===//
17dd58ef01SDimitry Andric // Generic Object File
18dd58ef01SDimitry Andric //===----------------------------------------------------------------------===//
19dd58ef01SDimitry Andric
SelectSectionForGlobal(const GlobalObject * GO,SectionKind Kind,const TargetMachine & TM) const20b915e9e0SDimitry Andric MCSection *AMDGPUTargetObjectFile::SelectSectionForGlobal(
21b915e9e0SDimitry Andric const GlobalObject *GO, SectionKind Kind, const TargetMachine &TM) const {
22044eb2f6SDimitry Andric if (Kind.isReadOnly() && AMDGPU::isReadOnlySegment(GO) &&
23b915e9e0SDimitry Andric AMDGPU::shouldEmitConstantsToTextSection(TM.getTargetTriple()))
24dd58ef01SDimitry Andric return TextSection;
25dd58ef01SDimitry Andric
26b915e9e0SDimitry Andric return TargetLoweringObjectFileELF::SelectSectionForGlobal(GO, Kind, TM);
27dd58ef01SDimitry Andric }
28d8e91e46SDimitry Andric
getExplicitSectionGlobal(const GlobalObject * GO,SectionKind SK,const TargetMachine & TM) const29d8e91e46SDimitry Andric MCSection *AMDGPUTargetObjectFile::getExplicitSectionGlobal(
30d8e91e46SDimitry Andric const GlobalObject *GO, SectionKind SK, const TargetMachine &TM) const {
31d8e91e46SDimitry Andric // Set metadata access for the explicit section
32d8e91e46SDimitry Andric StringRef SectionName = GO->getSection();
33312c0ed1SDimitry Andric if (SectionName.starts_with(".AMDGPU.comment."))
34d8e91e46SDimitry Andric SK = SectionKind::getMetadata();
35d8e91e46SDimitry Andric
36d8e91e46SDimitry Andric return TargetLoweringObjectFileELF::getExplicitSectionGlobal(GO, SK, TM);
37d8e91e46SDimitry Andric }
38