1c93fc11fSTom Stellard //===-- AMDGPUHSATargetObjectFile.cpp - AMDGPU Object Files ---------------===//
2c93fc11fSTom Stellard //
32946cd70SChandler Carruth // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
42946cd70SChandler Carruth // See https://llvm.org/LICENSE.txt for license information.
52946cd70SChandler Carruth // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6c93fc11fSTom Stellard //
7c93fc11fSTom Stellard //===----------------------------------------------------------------------===//
8c93fc11fSTom Stellard 
9c93fc11fSTom Stellard #include "AMDGPUTargetObjectFile.h"
106bda14b3SChandler Carruth #include "Utils/AMDGPUBaseInfo.h"
11*6a87e9b0Sdfukalov #include "llvm/IR/GlobalObject.h"
12*6a87e9b0Sdfukalov #include "llvm/MC/SectionKind.h"
13*6a87e9b0Sdfukalov #include "llvm/Target/TargetMachine.h"
14c93fc11fSTom Stellard using namespace llvm;
15c93fc11fSTom Stellard 
16c93fc11fSTom Stellard //===----------------------------------------------------------------------===//
17c93fc11fSTom Stellard // Generic Object File
18c93fc11fSTom Stellard //===----------------------------------------------------------------------===//
19c93fc11fSTom Stellard 
SelectSectionForGlobal(const GlobalObject * GO,SectionKind Kind,const TargetMachine & TM) const204367c7fbSEric Christopher MCSection *AMDGPUTargetObjectFile::SelectSectionForGlobal(
216733564eSPeter Collingbourne     const GlobalObject *GO, SectionKind Kind, const TargetMachine &TM) const {
22435151adSKonstantin Zhuravlyov   if (Kind.isReadOnly() && AMDGPU::isReadOnlySegment(GO) &&
2308326b62SKonstantin Zhuravlyov       AMDGPU::shouldEmitConstantsToTextSection(TM.getTargetTriple()))
24c93fc11fSTom Stellard     return TextSection;
25c93fc11fSTom Stellard 
266733564eSPeter Collingbourne   return TargetLoweringObjectFileELF::SelectSectionForGlobal(GO, Kind, TM);
27c93fc11fSTom Stellard }
283732b4ceSPiotr Sobczak 
getExplicitSectionGlobal(const GlobalObject * GO,SectionKind SK,const TargetMachine & TM) const293732b4ceSPiotr Sobczak MCSection *AMDGPUTargetObjectFile::getExplicitSectionGlobal(
303732b4ceSPiotr Sobczak     const GlobalObject *GO, SectionKind SK, const TargetMachine &TM) const {
313732b4ceSPiotr Sobczak   // Set metadata access for the explicit section
323732b4ceSPiotr Sobczak   StringRef SectionName = GO->getSection();
333abef8f9SPiotr Sobczak   if (SectionName.startswith(".AMDGPU.comment."))
343732b4ceSPiotr Sobczak     SK = SectionKind::getMetadata();
353732b4ceSPiotr Sobczak 
363732b4ceSPiotr Sobczak   return TargetLoweringObjectFileELF::getExplicitSectionGlobal(GO, SK, TM);
373732b4ceSPiotr Sobczak }
38