Tom Stellard | e135ffd | 2015-09-25 21:41:28 +0000 | [diff] [blame] | 1 | //===-- AMDGPUHSATargetObjectFile.cpp - AMDGPU Object Files ---------------===// |
| 2 | // |
Chandler Carruth | 2946cd7 | 2019-01-19 08:50:56 +0000 | [diff] [blame] | 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 |
Tom Stellard | e135ffd | 2015-09-25 21:41:28 +0000 | [diff] [blame] | 6 | // |
| 7 | //===----------------------------------------------------------------------===// |
| 8 | |
Tom Stellard | c93fc11 | 2015-12-10 02:13:01 +0000 | [diff] [blame] | 9 | #include "AMDGPUTargetObjectFile.h" |
Chandler Carruth | 6bda14b | 2017-06-06 11:49:48 +0000 | [diff] [blame] | 10 | #include "Utils/AMDGPUBaseInfo.h" |
dfukalov | 6a87e9b | 2020-12-25 18:52:14 +0300 | [diff] [blame] | 11 | #include "llvm/IR/GlobalObject.h" |
| 12 | #include "llvm/MC/SectionKind.h" |
| 13 | #include "llvm/Target/TargetMachine.h" |
Tom Stellard | e135ffd | 2015-09-25 21:41:28 +0000 | [diff] [blame] | 14 | using namespace llvm; |
| 15 | |
Tom Stellard | c93fc11 | 2015-12-10 02:13:01 +0000 | [diff] [blame] | 16 | //===----------------------------------------------------------------------===// |
| 17 | // Generic Object File |
| 18 | //===----------------------------------------------------------------------===// |
| 19 | |
Eric Christopher | 4367c7f | 2016-09-16 07:33:15 +0000 | [diff] [blame] | 20 | MCSection *AMDGPUTargetObjectFile::SelectSectionForGlobal( |
Peter Collingbourne | 6733564 | 2016-10-24 19:23:39 +0000 | [diff] [blame] | 21 | const GlobalObject *GO, SectionKind Kind, const TargetMachine &TM) const { |
Konstantin Zhuravlyov | 435151a | 2017-11-01 19:12:38 +0000 | [diff] [blame] | 22 | if (Kind.isReadOnly() && AMDGPU::isReadOnlySegment(GO) && |
Konstantin Zhuravlyov | 08326b6 | 2016-10-20 18:12:38 +0000 | [diff] [blame] | 23 | AMDGPU::shouldEmitConstantsToTextSection(TM.getTargetTriple())) |
Tom Stellard | c93fc11 | 2015-12-10 02:13:01 +0000 | [diff] [blame] | 24 | return TextSection; |
| 25 | |
Peter Collingbourne | 6733564 | 2016-10-24 19:23:39 +0000 | [diff] [blame] | 26 | return TargetLoweringObjectFileELF::SelectSectionForGlobal(GO, Kind, TM); |
Tom Stellard | c93fc11 | 2015-12-10 02:13:01 +0000 | [diff] [blame] | 27 | } |
Piotr Sobczak | 3732b4c | 2018-12-12 11:20:04 +0000 | [diff] [blame] | 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(); |
Piotr Sobczak | 3abef8f | 2019-01-03 11:22:58 +0000 | [diff] [blame] | 33 | if (SectionName.startswith(".AMDGPU.comment.")) |
Piotr Sobczak | 3732b4c | 2018-12-12 11:20:04 +0000 | [diff] [blame] | 34 | SK = SectionKind::getMetadata(); |
| 35 | |
| 36 | return TargetLoweringObjectFileELF::getExplicitSectionGlobal(GO, SK, TM); |
| 37 | } |