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" 14 using namespace llvm; 15 16 //===----------------------------------------------------------------------===// 17 // Generic Object File 18 //===----------------------------------------------------------------------===// 19 20 MCSection *AMDGPUTargetObjectFile::SelectSectionForGlobal( 21 const GlobalObject *GO, SectionKind Kind, const TargetMachine &TM) const { 22 if (Kind.isReadOnly() && AMDGPU::isReadOnlySegment(GO) && 23 AMDGPU::shouldEmitConstantsToTextSection(TM.getTargetTriple())) 24 return TextSection; 25 26 return TargetLoweringObjectFileELF::SelectSectionForGlobal(GO, Kind, TM); 27 } 28 29 MCSection *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(); 33 if (SectionName.startswith(".AMDGPU.comment.")) 34 SK = SectionKind::getMetadata(); 35 36 return TargetLoweringObjectFileELF::getExplicitSectionGlobal(GO, SK, TM); 37 } 38