radeon/llvm: Add subtarget feature: DumpCode
authorTom Stellard <thomas.stellard@amd.com>
Tue, 1 May 2012 17:08:26 +0000 (13:08 -0400)
committerTom Stellard <thomas.stellard@amd.com>
Tue, 1 May 2012 17:12:27 +0000 (13:12 -0400)
With this feature enabled, the LLVM backend will dump the MachineIntrs
prior to emitting code.  The mesa env variable R600_DUMP_SHADERS will enable
this feature in the backend.

src/gallium/drivers/radeon/AMDGPUTargetMachine.h
src/gallium/drivers/radeon/AMDILBase.td
src/gallium/drivers/radeon/AMDILSubtarget.h
src/gallium/drivers/radeon/R600CodeEmitter.cpp
src/gallium/drivers/radeon/radeon_llvm_emit.cpp

index d4165b09e84ee0b0f8c1225dae88c105fe4edb51..7f621d88e0aba2c4f791ffba600a1d7c10a6ab44 100644 (file)
@@ -52,9 +52,6 @@ public:
                                               formatted_raw_ostream &Out,
                                               CodeGenFileType FileType,
                                               bool DisableVerify);
-public:
-   void dumpCode() { mDump = true; }
-   bool shouldDumpCode() const { return mDump; }
 };
 
 } /* End namespace llvm */
index 2706b211f2d82161dbf4d2b2f94b88c689e89870..31ebed31d726f2ae33148af7c81b1102cb85f0be 100644 (file)
@@ -60,6 +60,11 @@ def FeatureDebug : SubtargetFeature<"debug",
         "CapsOverride[AMDILDeviceInfo::Debug]",
         "true",
         "Debug mode is enabled, so disable hardware accelerated address spaces.">;
+def FeatureDumpCode : SubtargetFeature <"DumpCode",
+        "mDumpCode",
+        "true",
+        "Dump MachineInstrs in the CodeEmitter">;
+
 
 //===----------------------------------------------------------------------===//
 // Register File, Calling Conv, Instruction Descriptions
index a4b0e34ada70971702600b0bc5f7af7480ccb9ee..38fcb859ac643af932d5d6e11ca2150c11a57ce2 100644 (file)
@@ -42,6 +42,7 @@ namespace llvm {
       uint32_t mVersion;
       bool mIs64bit;
       bool mIs32on64bit;
+      bool mDumpCode;
     public:
       AMDILSubtarget(llvm::StringRef TT, llvm::StringRef CPU, llvm::StringRef FS);
       virtual ~AMDILSubtarget();
@@ -67,6 +68,7 @@ namespace llvm {
         ParseSubtargetFeatures(
             llvm::StringRef CPU,
             llvm::StringRef FS);
+      bool dumpCode() const { return mDumpCode; }
 
   };
 
index 8faf0deb8c50e673971c5229e9efc0c7cf1c7816..53fdd1592c49f1c2990a4fca55ba80a3742b688d 100644 (file)
@@ -155,10 +155,8 @@ bool R600CodeEmitter::runOnMachineFunction(MachineFunction &MF) {
   } else {
     evergreenEncoding = true;
   }
-  const AMDGPUTargetMachine *amdtm =
-    static_cast<const AMDGPUTargetMachine *>(&MF.getTarget());
 
-  if (amdtm->shouldDumpCode()) {
+  if (STM.dumpCode()) {
     MF.dump();
   }
 
index b409cb2175e64b681f28f51d0e6840ef0b43835f..3431316cd3ce1462850a5f552bf0deea6d9f02bc 100644 (file)
@@ -105,6 +105,7 @@ radeon_llvm_compile(LLVMModuleRef M, unsigned char ** bytes,
    /* XXX: Use TargetMachine.Options in 3.0 */
    if (dump) {
       mod->dump();
+      FS += ",DumpCode";
    }
    PassManager PM;
    PM.add(new TargetData(*AMDGPUTargetMachine.getTargetData()));