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 "AMDGPU.h" 11 #include "AMDGPUTargetMachine.h" 12 #include "Utils/AMDGPUBaseInfo.h" 13 #include "llvm/BinaryFormat/ELF.h" 14 #include "llvm/MC/MCContext.h" 15 #include "llvm/MC/MCSectionELF.h" 16 17 using namespace llvm; 18 19 //===----------------------------------------------------------------------===// 20 // Generic Object File 21 //===----------------------------------------------------------------------===// 22 23 MCSection *AMDGPUTargetObjectFile::SelectSectionForGlobal( 24 const GlobalObject *GO, SectionKind Kind, const TargetMachine &TM) const { 25 if (Kind.isReadOnly() && AMDGPU::isReadOnlySegment(GO) && 26 AMDGPU::shouldEmitConstantsToTextSection(TM.getTargetTriple())) 27 return TextSection; 28 29 return TargetLoweringObjectFileELF::SelectSectionForGlobal(GO, Kind, TM); 30 } 31 32 MCSection *AMDGPUTargetObjectFile::getExplicitSectionGlobal( 33 const GlobalObject *GO, SectionKind SK, const TargetMachine &TM) const { 34 // Set metadata access for the explicit section 35 StringRef SectionName = GO->getSection(); 36 if (SectionName.startswith(".AMDGPU.comment.")) 37 SK = SectionKind::getMetadata(); 38 39 return TargetLoweringObjectFileELF::getExplicitSectionGlobal(GO, SK, TM); 40 } 41