1c93fc11fSTom Stellard //===-- AMDGPUHSATargetObjectFile.cpp - AMDGPU Object Files ---------------===//
2c93fc11fSTom Stellard //
3c93fc11fSTom Stellard //                     The LLVM Compiler Infrastructure
4c93fc11fSTom Stellard //
5c93fc11fSTom Stellard // This file is distributed under the University of Illinois Open Source
6c93fc11fSTom Stellard // License. See LICENSE.TXT for details.
7c93fc11fSTom Stellard //
8c93fc11fSTom Stellard //===----------------------------------------------------------------------===//
9c93fc11fSTom Stellard 
10c93fc11fSTom Stellard #include "AMDGPUTargetObjectFile.h"
11c93fc11fSTom Stellard #include "AMDGPU.h"
126bda14b3SChandler Carruth #include "AMDGPUTargetMachine.h"
136bda14b3SChandler Carruth #include "Utils/AMDGPUBaseInfo.h"
14264b5d9eSZachary Turner #include "llvm/BinaryFormat/ELF.h"
15c93fc11fSTom Stellard #include "llvm/MC/MCContext.h"
16c93fc11fSTom Stellard #include "llvm/MC/MCSectionELF.h"
17c93fc11fSTom Stellard 
18c93fc11fSTom Stellard using namespace llvm;
19c93fc11fSTom Stellard 
20c93fc11fSTom Stellard //===----------------------------------------------------------------------===//
21c93fc11fSTom Stellard // Generic Object File
22c93fc11fSTom Stellard //===----------------------------------------------------------------------===//
23c93fc11fSTom Stellard 
244367c7fbSEric Christopher MCSection *AMDGPUTargetObjectFile::SelectSectionForGlobal(
256733564eSPeter Collingbourne     const GlobalObject *GO, SectionKind Kind, const TargetMachine &TM) const {
26435151adSKonstantin Zhuravlyov   if (Kind.isReadOnly() && AMDGPU::isReadOnlySegment(GO) &&
2708326b62SKonstantin Zhuravlyov       AMDGPU::shouldEmitConstantsToTextSection(TM.getTargetTriple()))
28c93fc11fSTom Stellard     return TextSection;
29c93fc11fSTom Stellard 
306733564eSPeter Collingbourne   return TargetLoweringObjectFileELF::SelectSectionForGlobal(GO, Kind, TM);
31c93fc11fSTom Stellard }
323732b4ceSPiotr Sobczak 
333732b4ceSPiotr Sobczak MCSection *AMDGPUTargetObjectFile::getExplicitSectionGlobal(
343732b4ceSPiotr Sobczak     const GlobalObject *GO, SectionKind SK, const TargetMachine &TM) const {
353732b4ceSPiotr Sobczak   // Set metadata access for the explicit section
363732b4ceSPiotr Sobczak   StringRef SectionName = GO->getSection();
37*3abef8f9SPiotr Sobczak   if (SectionName.startswith(".AMDGPU.comment."))
383732b4ceSPiotr Sobczak     SK = SectionKind::getMetadata();
393732b4ceSPiotr Sobczak 
403732b4ceSPiotr Sobczak   return TargetLoweringObjectFileELF::getExplicitSectionGlobal(GO, SK, TM);
413732b4ceSPiotr Sobczak }
42