[PATCH 2/3] R600/SI: Emit configuration value in the .AMDGPU.config ELF section

Tom Stellard tom at stellard.net
Fri Apr 5 11:56:13 PDT 2013


From: Tom Stellard <thomas.stellard at amd.com>

---
 lib/Target/R600/AMDGPUAsmPrinter.cpp | 10 +++++++++-
 test/CodeGen/R600/elf.ll             |  1 +
 2 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/lib/Target/R600/AMDGPUAsmPrinter.cpp b/lib/Target/R600/AMDGPUAsmPrinter.cpp
index f600144..011c602 100644
--- a/lib/Target/R600/AMDGPUAsmPrinter.cpp
+++ b/lib/Target/R600/AMDGPUAsmPrinter.cpp
@@ -21,7 +21,10 @@
 #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;
 }
diff --git a/test/CodeGen/R600/elf.ll b/test/CodeGen/R600/elf.ll
index 470e4ca..2383148 100644
--- a/test/CodeGen/R600/elf.ll
+++ b/test/CodeGen/R600/elf.ll
@@ -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
-- 
1.8.1.5




More information about the llvm-commits mailing list