1c93fc11fSTom Stellard //===-- AMDGPUHSATargetObjectFile.cpp - AMDGPU Object Files ---------------===//
2c93fc11fSTom Stellard //
3*2946cd70SChandler Carruth // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4*2946cd70SChandler Carruth // See https://llvm.org/LICENSE.txt for license information.
5*2946cd70SChandler Carruth // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6c93fc11fSTom Stellard //
7c93fc11fSTom Stellard //===----------------------------------------------------------------------===//
8c93fc11fSTom Stellard 
9c93fc11fSTom Stellard #include "AMDGPUTargetObjectFile.h"
10c93fc11fSTom Stellard #include "AMDGPU.h"
116bda14b3SChandler Carruth #include "AMDGPUTargetMachine.h"
126bda14b3SChandler Carruth #include "Utils/AMDGPUBaseInfo.h"
13264b5d9eSZachary Turner #include "llvm/BinaryFormat/ELF.h"
14c93fc11fSTom Stellard #include "llvm/MC/MCContext.h"
15c93fc11fSTom Stellard #include "llvm/MC/MCSectionELF.h"
16c93fc11fSTom Stellard 
17c93fc11fSTom Stellard using namespace llvm;
18c93fc11fSTom Stellard 
19c93fc11fSTom Stellard //===----------------------------------------------------------------------===//
20c93fc11fSTom Stellard // Generic Object File
21c93fc11fSTom Stellard //===----------------------------------------------------------------------===//
22c93fc11fSTom Stellard 
234367c7fbSEric Christopher MCSection *AMDGPUTargetObjectFile::SelectSectionForGlobal(
246733564eSPeter Collingbourne     const GlobalObject *GO, SectionKind Kind, const TargetMachine &TM) const {
25435151adSKonstantin Zhuravlyov   if (Kind.isReadOnly() && AMDGPU::isReadOnlySegment(GO) &&
2608326b62SKonstantin Zhuravlyov       AMDGPU::shouldEmitConstantsToTextSection(TM.getTargetTriple()))
27c93fc11fSTom Stellard     return TextSection;
28c93fc11fSTom Stellard 
296733564eSPeter Collingbourne   return TargetLoweringObjectFileELF::SelectSectionForGlobal(GO, Kind, TM);
30c93fc11fSTom Stellard }
313732b4ceSPiotr Sobczak 
323732b4ceSPiotr Sobczak MCSection *AMDGPUTargetObjectFile::getExplicitSectionGlobal(
333732b4ceSPiotr Sobczak     const GlobalObject *GO, SectionKind SK, const TargetMachine &TM) const {
343732b4ceSPiotr Sobczak   // Set metadata access for the explicit section
353732b4ceSPiotr Sobczak   StringRef SectionName = GO->getSection();
363abef8f9SPiotr Sobczak   if (SectionName.startswith(".AMDGPU.comment."))
373732b4ceSPiotr Sobczak     SK = SectionKind::getMetadata();
383732b4ceSPiotr Sobczak 
393732b4ceSPiotr Sobczak   return TargetLoweringObjectFileELF::getExplicitSectionGlobal(GO, SK, TM);
403732b4ceSPiotr Sobczak }
41