blob: f854c8c16e5aa4d5e26bb6816fc54a3f32016a6c [file] [log] [blame]
Tom Stellarde135ffd2015-09-25 21:41:28 +00001//===-- AMDGPUHSATargetObjectFile.cpp - AMDGPU Object Files ---------------===//
2//
Chandler Carruth2946cd72019-01-19 08:50:56 +00003// 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
Tom Stellarde135ffd2015-09-25 21:41:28 +00006//
7//===----------------------------------------------------------------------===//
8
Tom Stellardc93fc112015-12-10 02:13:01 +00009#include "AMDGPUTargetObjectFile.h"
Chandler Carruth6bda14b2017-06-06 11:49:48 +000010#include "Utils/AMDGPUBaseInfo.h"
dfukalov6a87e9b2020-12-25 18:52:14 +030011#include "llvm/IR/GlobalObject.h"
12#include "llvm/MC/SectionKind.h"
13#include "llvm/Target/TargetMachine.h"
Tom Stellarde135ffd2015-09-25 21:41:28 +000014using namespace llvm;
15
Tom Stellardc93fc112015-12-10 02:13:01 +000016//===----------------------------------------------------------------------===//
17// Generic Object File
18//===----------------------------------------------------------------------===//
19
Eric Christopher4367c7f2016-09-16 07:33:15 +000020MCSection *AMDGPUTargetObjectFile::SelectSectionForGlobal(
Peter Collingbourne67335642016-10-24 19:23:39 +000021 const GlobalObject *GO, SectionKind Kind, const TargetMachine &TM) const {
Konstantin Zhuravlyov435151a2017-11-01 19:12:38 +000022 if (Kind.isReadOnly() && AMDGPU::isReadOnlySegment(GO) &&
Konstantin Zhuravlyov08326b62016-10-20 18:12:38 +000023 AMDGPU::shouldEmitConstantsToTextSection(TM.getTargetTriple()))
Tom Stellardc93fc112015-12-10 02:13:01 +000024 return TextSection;
25
Peter Collingbourne67335642016-10-24 19:23:39 +000026 return TargetLoweringObjectFileELF::SelectSectionForGlobal(GO, Kind, TM);
Tom Stellardc93fc112015-12-10 02:13:01 +000027}
Piotr Sobczak3732b4c2018-12-12 11:20:04 +000028
29MCSection *AMDGPUTargetObjectFile::getExplicitSectionGlobal(
30 const GlobalObject *GO, SectionKind SK, const TargetMachine &TM) const {
31 // Set metadata access for the explicit section
32 StringRef SectionName = GO->getSection();
Piotr Sobczak3abef8f2019-01-03 11:22:58 +000033 if (SectionName.startswith(".AMDGPU.comment."))
Piotr Sobczak3732b4c2018-12-12 11:20:04 +000034 SK = SectionKind::getMetadata();
35
36 return TargetLoweringObjectFileELF::getExplicitSectionGlobal(GO, SK, TM);
37}