R600/SI: Emit configuration value in the .AMDGPU.config ELF section
authorTom Stellard <thomas.stellard@amd.com>
Mon, 15 Apr 2013 17:51:30 +0000 (17:51 +0000)
committerTom Stellard <thomas.stellard@amd.com>
Mon, 15 Apr 2013 17:51:30 +0000 (17:51 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@179545 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/R600/AMDGPUAsmPrinter.cpp
test/CodeGen/R600/elf.ll

index dacb03325bc71a094c29506cbd787576d6b5ac59..72f98ee0b009229ab7d3145624f6ccf3676bd8df 100644 (file)
 #include "AMDGPU.h"
 #include "SIMachineFunctionInfo.h"
 #include "SIRegisterInfo.h"
+#include "llvm/MC/MCContext.h"
+#include "llvm/MC/MCSectionELF.h"
 #include "llvm/MC/MCStreamer.h"
+#include "llvm/Support/ELF.h"
 #include "llvm/Support/TargetRegistry.h"
 #include "llvm/Target/TargetLoweringObjectFile.h"
 
@@ -50,10 +53,15 @@ bool AMDGPUAsmPrinter::runOnMachineFunction(MachineFunction &MF) {
   if (OutStreamer.hasRawTextSupport()) {
     OutStreamer.EmitRawText("@" + MF.getName() + ":");
   }
-  OutStreamer.SwitchSection(getObjFileLowering().getTextSection());
   if (STM.device()->getGeneration() > AMDGPUDeviceInfo::HD6XXX) {
+    const MCSectionELF *ConfigSection = getObjFileLowering().getContext()
+                                                .getELFSection(".AMDGPU.config",
+                                                ELF::SHT_NULL, 0,
+                                                SectionKind::getReadOnly());
+    OutStreamer.SwitchSection(ConfigSection);
     EmitProgramInfo(MF);
   }
+  OutStreamer.SwitchSection(getObjFileLowering().getTextSection());
   EmitFunctionBody();
   return false;
 }
index 470e4cac0fb5bc881a5d669b32de2d767ca71a3b..2383148c533127f6a5b8f9fe166906b16872ae1d 100644 (file)
@@ -1,6 +1,7 @@
 ; RUN: llc < %s -march=r600 -mcpu=SI -filetype=obj | llvm-readobj -s - | FileCheck %s
 
 ; CHECK: Format: ELF32
+; CHECK: Name: .AMDGPU.config
 define void @test(i32 %p) {
    %i = add i32 %p, 2
    %r = bitcast i32 %i to float