1*0b57cec5SDimitry Andric //===-- AMDGPUHSATargetObjectFile.cpp - AMDGPU Object Files ---------------===// 2*0b57cec5SDimitry Andric // 3*0b57cec5SDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4*0b57cec5SDimitry Andric // See https://llvm.org/LICENSE.txt for license information. 5*0b57cec5SDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6*0b57cec5SDimitry Andric // 7*0b57cec5SDimitry Andric //===----------------------------------------------------------------------===// 8*0b57cec5SDimitry Andric 9*0b57cec5SDimitry Andric #include "AMDGPUTargetObjectFile.h" 10*0b57cec5SDimitry Andric #include "AMDGPU.h" 11*0b57cec5SDimitry Andric #include "AMDGPUTargetMachine.h" 12*0b57cec5SDimitry Andric #include "Utils/AMDGPUBaseInfo.h" 13*0b57cec5SDimitry Andric #include "llvm/BinaryFormat/ELF.h" 14*0b57cec5SDimitry Andric #include "llvm/MC/MCContext.h" 15*0b57cec5SDimitry Andric #include "llvm/MC/MCSectionELF.h" 16*0b57cec5SDimitry Andric 17*0b57cec5SDimitry Andric using namespace llvm; 18*0b57cec5SDimitry Andric 19*0b57cec5SDimitry Andric //===----------------------------------------------------------------------===// 20*0b57cec5SDimitry Andric // Generic Object File 21*0b57cec5SDimitry Andric //===----------------------------------------------------------------------===// 22*0b57cec5SDimitry Andric 23*0b57cec5SDimitry Andric MCSection *AMDGPUTargetObjectFile::SelectSectionForGlobal( 24*0b57cec5SDimitry Andric const GlobalObject *GO, SectionKind Kind, const TargetMachine &TM) const { 25*0b57cec5SDimitry Andric if (Kind.isReadOnly() && AMDGPU::isReadOnlySegment(GO) && 26*0b57cec5SDimitry Andric AMDGPU::shouldEmitConstantsToTextSection(TM.getTargetTriple())) 27*0b57cec5SDimitry Andric return TextSection; 28*0b57cec5SDimitry Andric 29*0b57cec5SDimitry Andric return TargetLoweringObjectFileELF::SelectSectionForGlobal(GO, Kind, TM); 30*0b57cec5SDimitry Andric } 31*0b57cec5SDimitry Andric 32*0b57cec5SDimitry Andric MCSection *AMDGPUTargetObjectFile::getExplicitSectionGlobal( 33*0b57cec5SDimitry Andric const GlobalObject *GO, SectionKind SK, const TargetMachine &TM) const { 34*0b57cec5SDimitry Andric // Set metadata access for the explicit section 35*0b57cec5SDimitry Andric StringRef SectionName = GO->getSection(); 36*0b57cec5SDimitry Andric if (SectionName.startswith(".AMDGPU.comment.")) 37*0b57cec5SDimitry Andric SK = SectionKind::getMetadata(); 38*0b57cec5SDimitry Andric 39*0b57cec5SDimitry Andric return TargetLoweringObjectFileELF::getExplicitSectionGlobal(GO, SK, TM); 40*0b57cec5SDimitry Andric } 41