diff options
Diffstat (limited to 'llvm/lib')
7 files changed, 25 insertions, 1 deletions
diff --git a/llvm/lib/Target/AMDGPU/AMDGPUAsmPrinter.cpp b/llvm/lib/Target/AMDGPU/AMDGPUAsmPrinter.cpp index 1c438b24e6a..b677caa6c2c 100644 --- a/llvm/lib/Target/AMDGPU/AMDGPUAsmPrinter.cpp +++ b/llvm/lib/Target/AMDGPU/AMDGPUAsmPrinter.cpp @@ -137,7 +137,7 @@ static bool isModuleLinkage(const GlobalValue *GV) { void AMDGPUAsmPrinter::EmitGlobalVariable(const GlobalVariable *GV) { if (TM.getTargetTriple().getOS() != Triple::AMDHSA || - GV->isDeclaration() || AMDGPU::isReadOnlySegment(GV)) { + GV->isDeclaration()) { AsmPrinter::EmitGlobalVariable(GV); return; } diff --git a/llvm/lib/Target/AMDGPU/AMDGPUHSATargetObjectFile.cpp b/llvm/lib/Target/AMDGPU/AMDGPUHSATargetObjectFile.cpp index ee42eaacf54..32f53edeb77 100644 --- a/llvm/lib/Target/AMDGPU/AMDGPUHSATargetObjectFile.cpp +++ b/llvm/lib/Target/AMDGPU/AMDGPUHSATargetObjectFile.cpp @@ -26,6 +26,7 @@ void AMDGPUHSATargetObjectFile::Initialize(MCContext &Ctx, DataGlobalAgentSection = AMDGPU::getHSADataGlobalAgentSection(Ctx); DataGlobalProgramSection = AMDGPU::getHSADataGlobalProgramSection(Ctx); + RodataReadonlyAgentSection = AMDGPU::getHSARodataReadonlyAgentSection(Ctx); } bool AMDGPUHSATargetObjectFile::isAgentAllocationSection( @@ -63,5 +64,8 @@ MCSection *AMDGPUHSATargetObjectFile::SelectSectionForGlobal( return DataGlobalProgramSection; } + if (Kind.isReadOnly() && AMDGPU::isReadOnlySegment(GV)) + return RodataReadonlyAgentSection; + return TargetLoweringObjectFileELF::SelectSectionForGlobal(GV, Kind, Mang, TM); } diff --git a/llvm/lib/Target/AMDGPU/AMDGPUHSATargetObjectFile.h b/llvm/lib/Target/AMDGPU/AMDGPUHSATargetObjectFile.h index 3697a96ffaf..9ea51ec9b29 100644 --- a/llvm/lib/Target/AMDGPU/AMDGPUHSATargetObjectFile.h +++ b/llvm/lib/Target/AMDGPU/AMDGPUHSATargetObjectFile.h @@ -25,6 +25,7 @@ class AMDGPUHSATargetObjectFile final : public TargetLoweringObjectFileELF { private: MCSection *DataGlobalAgentSection; MCSection *DataGlobalProgramSection; + MCSection *RodataReadonlyAgentSection; bool isAgentAllocationSection(const char *SectionName) const; bool isAgentAllocation(const GlobalValue *GV) const; diff --git a/llvm/lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp b/llvm/lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp index b360f2de0cb..7359cfee7f2 100644 --- a/llvm/lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp +++ b/llvm/lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp @@ -369,6 +369,7 @@ private: bool ParseDirectiveAMDGPUHsaProgramGlobal(); bool ParseSectionDirectiveHSADataGlobalAgent(); bool ParseSectionDirectiveHSADataGlobalProgram(); + bool ParseSectionDirectiveHSARodataReadonlyAgent(); public: public: @@ -1004,6 +1005,12 @@ bool AMDGPUAsmParser::ParseSectionDirectiveHSADataGlobalProgram() { return false; } +bool AMDGPUAsmParser::ParseSectionDirectiveHSARodataReadonlyAgent() { + getParser().getStreamer().SwitchSection( + AMDGPU::getHSARodataReadonlyAgentSection(getContext())); + return false; +} + bool AMDGPUAsmParser::ParseDirective(AsmToken DirectiveID) { StringRef IDVal = DirectiveID.getString(); @@ -1034,6 +1041,9 @@ bool AMDGPUAsmParser::ParseDirective(AsmToken DirectiveID) { if (IDVal == ".hsadata_global_program") return ParseSectionDirectiveHSADataGlobalProgram(); + if (IDVal == ".hsarodata_readonly_agent") + return ParseSectionDirectiveHSARodataReadonlyAgent(); + return true; } diff --git a/llvm/lib/Target/AMDGPU/MCTargetDesc/AMDGPUMCAsmInfo.cpp b/llvm/lib/Target/AMDGPU/MCTargetDesc/AMDGPUMCAsmInfo.cpp index 89fa212de95..68b1d1ae83c 100644 --- a/llvm/lib/Target/AMDGPU/MCTargetDesc/AMDGPUMCAsmInfo.cpp +++ b/llvm/lib/Target/AMDGPU/MCTargetDesc/AMDGPUMCAsmInfo.cpp @@ -38,5 +38,6 @@ AMDGPUMCAsmInfo::AMDGPUMCAsmInfo(const Triple &TT) : MCAsmInfoELF() { bool AMDGPUMCAsmInfo::shouldOmitSectionDirective(StringRef SectionName) const { return SectionName == ".hsatext" || SectionName == ".hsadata_global_agent" || SectionName == ".hsadata_global_program" || + SectionName == ".hsarodata_readonly_agent" || MCAsmInfo::shouldOmitSectionDirective(SectionName); } diff --git a/llvm/lib/Target/AMDGPU/Utils/AMDGPUBaseInfo.cpp b/llvm/lib/Target/AMDGPU/Utils/AMDGPUBaseInfo.cpp index e3c93384bd8..441baed9b43 100644 --- a/llvm/lib/Target/AMDGPU/Utils/AMDGPUBaseInfo.cpp +++ b/llvm/lib/Target/AMDGPU/Utils/AMDGPUBaseInfo.cpp @@ -81,6 +81,12 @@ MCSection *getHSADataGlobalProgramSection(MCContext &Ctx) { ELF::SHF_AMDGPU_HSA_GLOBAL); } +MCSection *getHSARodataReadonlyAgentSection(MCContext &Ctx) { + return Ctx.getELFSection(".hsarodata_readonly_agent", ELF::SHT_PROGBITS, + ELF::SHF_ALLOC | ELF::SHF_AMDGPU_HSA_READONLY | + ELF::SHF_AMDGPU_HSA_AGENT); +} + bool isGroupSegment(const GlobalValue *GV) { return GV->getType()->getAddressSpace() == AMDGPUAS::LOCAL_ADDRESS; } diff --git a/llvm/lib/Target/AMDGPU/Utils/AMDGPUBaseInfo.h b/llvm/lib/Target/AMDGPU/Utils/AMDGPUBaseInfo.h index cc70064dbc0..7b3c858e7c3 100644 --- a/llvm/lib/Target/AMDGPU/Utils/AMDGPUBaseInfo.h +++ b/llvm/lib/Target/AMDGPU/Utils/AMDGPUBaseInfo.h @@ -36,6 +36,8 @@ MCSection *getHSADataGlobalAgentSection(MCContext &Ctx); MCSection *getHSADataGlobalProgramSection(MCContext &Ctx); +MCSection *getHSARodataReadonlyAgentSection(MCContext &Ctx); + bool isGroupSegment(const GlobalValue *GV); bool isGlobalSegment(const GlobalValue *GV); bool isReadOnlySegment(const GlobalValue *GV); |