1//===-- AMDGPUHSATargetObjectFile.cpp - AMDGPU Object Files ---------------===//
2//
3// 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
6//
7//===----------------------------------------------------------------------===//
8
9#include "AMDGPUTargetObjectFile.h"
10#include "Utils/AMDGPUBaseInfo.h"
11#include "llvm/IR/GlobalObject.h"
12#include "llvm/MC/SectionKind.h"
13#include "llvm/Target/TargetMachine.h"
14using namespace llvm;
15
16//===----------------------------------------------------------------------===//
17// Generic Object File
18//===----------------------------------------------------------------------===//
19
20MCSection *AMDGPUTargetObjectFile::SelectSectionForGlobal(
21 const GlobalObject *GO, SectionKind Kind, const TargetMachine &TM) const {
22 if (Kind.isReadOnly() && AMDGPU::isReadOnlySegment(GV: GO) &&
23 AMDGPU::shouldEmitConstantsToTextSection(
24 TT: GO->getParent()->getTargetTriple()))
25 return TextSection;
26
27 return TargetLoweringObjectFileELF::SelectSectionForGlobal(GO, Kind, TM);
28}
29
30MCSection *AMDGPUTargetObjectFile::getExplicitSectionGlobal(
31 const GlobalObject *GO, SectionKind SK, const TargetMachine &TM) const {
32 // Set metadata access for the explicit section
33 StringRef SectionName = GO->getSection();
34 if (SectionName.starts_with(Prefix: ".AMDGPU.comment."))
35 SK = SectionKind::getMetadata();
36
37 return TargetLoweringObjectFileELF::getExplicitSectionGlobal(GO, Kind: SK, TM);
38}
39