radeon/llvm: Change the tablegen target from AMDIL to AMDGPU
authorTom Stellard <thomas.stellard@amd.com>
Fri, 27 Jul 2012 17:46:40 +0000 (17:46 +0000)
committerTom Stellard <thomas.stellard@amd.com>
Mon, 30 Jul 2012 20:31:56 +0000 (20:31 +0000)
15 files changed:
src/gallium/drivers/radeon/AMDGPUCodeEmitter.h [new file with mode: 0644]
src/gallium/drivers/radeon/AMDGPUSubtarget.cpp [new file with mode: 0644]
src/gallium/drivers/radeon/AMDGPUSubtarget.h
src/gallium/drivers/radeon/AMDILBase.td
src/gallium/drivers/radeon/AMDILCodeEmitter.h [deleted file]
src/gallium/drivers/radeon/AMDILInstrInfo.cpp
src/gallium/drivers/radeon/AMDILInstrInfo.h
src/gallium/drivers/radeon/AMDILRegisterInfo.cpp
src/gallium/drivers/radeon/AMDILRegisterInfo.h
src/gallium/drivers/radeon/AMDILSubtarget.cpp
src/gallium/drivers/radeon/AMDILSubtarget.h
src/gallium/drivers/radeon/MCTargetDesc/AMDILMCTargetDesc.cpp
src/gallium/drivers/radeon/Makefile.sources
src/gallium/drivers/radeon/R600CodeEmitter.cpp
src/gallium/drivers/radeon/SICodeEmitter.cpp

diff --git a/src/gallium/drivers/radeon/AMDGPUCodeEmitter.h b/src/gallium/drivers/radeon/AMDGPUCodeEmitter.h
new file mode 100644 (file)
index 0000000..f1daec1
--- /dev/null
@@ -0,0 +1,48 @@
+//===-- AMDGPUCodeEmitter.h - AMDGPU Code Emitter interface -----------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// CodeEmitter interface for R600 and SI codegen.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef AMDGPUCODEEMITTER_H
+#define AMDGPUCODEEMITTER_H
+
+namespace llvm {
+
+  class AMDGPUCodeEmitter {
+  public:
+    uint64_t getBinaryCodeForInstr(const MachineInstr &MI) const;
+    virtual uint64_t getMachineOpValue(const MachineInstr &MI,
+                                   const MachineOperand &MO) const { return 0; }
+    virtual unsigned GPR4AlignEncode(const MachineInstr  &MI,
+                                     unsigned OpNo) const {
+      return 0;
+    }
+    virtual unsigned GPR2AlignEncode(const MachineInstr &MI,
+                                     unsigned OpNo) const {
+      return 0;
+    }
+    virtual uint64_t VOPPostEncode(const MachineInstr &MI,
+                                   uint64_t Value) const {
+      return Value;
+    }
+    virtual uint64_t i32LiteralEncode(const MachineInstr &MI,
+                                      unsigned OpNo) const {
+      return 0;
+    }
+    virtual uint32_t SMRDmemriEncode(const MachineInstr &MI, unsigned OpNo)
+                                                                     const {
+      return 0;
+    }
+  };
+
+} // End namespace llvm
+
+#endif // AMDGPUCODEEMITTER_H
diff --git a/src/gallium/drivers/radeon/AMDGPUSubtarget.cpp b/src/gallium/drivers/radeon/AMDGPUSubtarget.cpp
new file mode 100644 (file)
index 0000000..0b18278
--- /dev/null
@@ -0,0 +1,79 @@
+
+#include "AMDGPUSubtarget.h"
+
+using namespace llvm;
+
+#define GET_SUBTARGETINFO_ENUM
+#define GET_SUBTARGETINFO_TARGET_DESC
+#include "AMDGPUGenSubtargetInfo.inc"
+
+AMDGPUSubtarget::AMDGPUSubtarget(StringRef TT, StringRef CPU, StringRef FS) :
+  AMDILSubtarget(TT, CPU, FS) {
+    InstrItins = getInstrItineraryForCPU(CPU);
+
+  memset(CapsOverride, 0, sizeof(*CapsOverride)
+      * AMDILDeviceInfo::MaxNumberCapabilities);
+  // Default card
+  std::string GPU = "rv770";
+  GPU = CPU;
+  mIs64bit = false;
+  mVersion = 0;
+  SmallVector<StringRef, DEFAULT_VEC_SLOTS> Features;
+  SplitString(FS, Features, ",");
+  mDefaultSize[0] = 64;
+  mDefaultSize[1] = 1;
+  mDefaultSize[2] = 1;
+  std::string newFeatures = "";
+#if defined(_DEBUG) || defined(DEBUG)
+  bool useTest = false;
+#endif
+  for (size_t x = 0; x < Features.size(); ++x) {
+    if (Features[x].startswith("+mwgs")) {
+      SmallVector<StringRef, DEFAULT_VEC_SLOTS> sizes;
+      SplitString(Features[x], sizes, "-");
+      size_t mDim = ::atoi(sizes[1].data());
+      if (mDim > 3) {
+        mDim = 3;
+      }
+      for (size_t y = 0; y < mDim; ++y) {
+        mDefaultSize[y] = ::atoi(sizes[y+2].data());
+      }
+#if defined(_DEBUG) || defined(DEBUG)
+    } else if (!Features[x].compare("test")) {
+      useTest = true;
+#endif
+    } else if (Features[x].startswith("+cal")) {
+      SmallVector<StringRef, DEFAULT_VEC_SLOTS> version;
+      SplitString(Features[x], version, "=");
+      mVersion = ::atoi(version[1].data());
+    } else {
+      GPU = CPU;
+      if (x > 0) newFeatures += ',';
+      newFeatures += Features[x];
+    }
+  }
+  // If we don't have a version then set it to
+  // -1 which enables everything. This is for
+  // offline devices.
+  if (!mVersion) {
+    mVersion = (uint32_t)-1;
+  }
+  for (int x = 0; x < 3; ++x) {
+    if (!mDefaultSize[x]) {
+      mDefaultSize[x] = 1;
+    }
+  }
+#if defined(_DEBUG) || defined(DEBUG)
+  if (useTest) {
+    GPU = "kauai";
+  }
+#endif
+  ParseSubtargetFeatures(GPU, newFeatures);
+#if defined(_DEBUG) || defined(DEBUG)
+  if (useTest) {
+    GPU = "test";
+  }
+#endif
+  mDevName = GPU;
+  mDevice = AMDILDeviceInfo::getDeviceFromName(mDevName, this, mIs64bit);
+}
index 96ace88b47686dcfc599e81dfc985b922360e092..09e57e52b12f4a685e7a22e208c9963a90570ff8 100644 (file)
@@ -14,6 +14,8 @@
 #ifndef _AMDGPUSUBTARGET_H_
 #define _AMDGPUSUBTARGET_H_
 #include "AMDILSubtarget.h"
+#include "llvm/ADT/StringExtras.h"
+#include "llvm/ADT/StringRef.h"
 
 namespace llvm {
 
@@ -22,13 +24,11 @@ class AMDGPUSubtarget : public AMDILSubtarget
   InstrItineraryData InstrItins;
 
 public:
-  AMDGPUSubtarget(StringRef TT, StringRef CPU, StringRef FS) :
-    AMDILSubtarget(TT, CPU, FS)
-  {
-    InstrItins = getInstrItineraryForCPU(CPU);
-  }
+  AMDGPUSubtarget(StringRef TT, StringRef CPU, StringRef FS);
 
   const InstrItineraryData &getInstrItineraryData() const { return InstrItins; }
+  virtual void ParseSubtargetFeatures(llvm::StringRef CPU, llvm::StringRef FS);
+
 };
 
 } // End namespace llvm
index 8a2d34a63244108936a21ea5e89dbae5b0dc59ba..66c78e5ba00b94fa5bcd1b5cf3e16c073115aa4f 100644 (file)
@@ -89,9 +89,10 @@ def AMDILInstrInfo : InstrInfo {}
 //===----------------------------------------------------------------------===//
 // Declare the target which we are implementing
 //===----------------------------------------------------------------------===//
-def AMDILAsmWriter : AsmWriter {
-    string AsmWriterClassName = "AsmPrinter";
+def AMDGPUAsmWriter : AsmWriter {
+    string AsmWriterClassName = "InstPrinter";
     int Variant = 0;
+    bit isMCAsmWriter = 1;
 }
 
 def AMDILAsmParser : AsmParser {
@@ -105,9 +106,9 @@ def AMDILAsmParser : AsmParser {
 }
 
 
-def AMDIL : Target {
+def AMDGPU : Target {
   // Pull in Instruction Info:
   let InstructionSet = AMDILInstrInfo;
-  let AssemblyWriters = [AMDILAsmWriter];
+  let AssemblyWriters = [AMDGPUAsmWriter];
   let AssemblyParsers = [AMDILAsmParser];
 }
diff --git a/src/gallium/drivers/radeon/AMDILCodeEmitter.h b/src/gallium/drivers/radeon/AMDILCodeEmitter.h
deleted file mode 100644 (file)
index 0c7ae59..0000000
+++ /dev/null
@@ -1,48 +0,0 @@
-//===-- AMDILCodeEmitter.h - AMDIL Code Emitter interface -----------------===//
-//
-//                     The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-//
-// CodeEmitter interface for R600 and SI codegen.
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef AMDILCODEEMITTER_H
-#define AMDILCODEEMITTER_H
-
-namespace llvm {
-
-  class AMDILCodeEmitter {
-  public:
-    uint64_t getBinaryCodeForInstr(const MachineInstr &MI) const;
-    virtual uint64_t getMachineOpValue(const MachineInstr &MI,
-                                   const MachineOperand &MO) const { return 0; }
-    virtual unsigned GPR4AlignEncode(const MachineInstr  &MI,
-                                     unsigned OpNo) const {
-      return 0;
-    }
-    virtual unsigned GPR2AlignEncode(const MachineInstr &MI,
-                                     unsigned OpNo) const {
-      return 0;
-    }
-    virtual uint64_t VOPPostEncode(const MachineInstr &MI,
-                                   uint64_t Value) const {
-      return Value;
-    }
-    virtual uint64_t i32LiteralEncode(const MachineInstr &MI,
-                                      unsigned OpNo) const {
-      return 0;
-    }
-    virtual uint32_t SMRDmemriEncode(const MachineInstr &MI, unsigned OpNo)
-                                                                     const {
-      return 0;
-    }
-  };
-
-} // End namespace llvm
-
-#endif // AMDILCODEEMITTER_H
index 723d5a133a6ae8402faea1997e056003e1ef481d..953b1a92f91fd6d0ae8d3d0b660b69c2dc985867 100644 (file)
@@ -27,7 +27,7 @@
 using namespace llvm;
 
 AMDILInstrInfo::AMDILInstrInfo(TargetMachine &tm)
-  : AMDILGenInstrInfo(),
+  : AMDGPUGenInstrInfo(),
     RI(tm, *this),
     TM(tm) {
 }
index bff729b4685832073ec3b4ecc68880c6f811b1ae..94b0006b2d58503dd49f7c64dceb649006510d77 100644 (file)
@@ -25,7 +25,7 @@ namespace llvm {
   // instruction info tracks.
   //
   //class AMDILTargetMachine;
-class AMDILInstrInfo : public AMDILGenInstrInfo {
+class AMDILInstrInfo : public AMDGPUGenInstrInfo {
 private:
   const AMDILRegisterInfo RI;
   TargetMachine &TM;
index 989ccd9faf740d6cb2c612b4bd2f42be68cdc68b..76545a5bc41a533218399109fd0e467e8a748939 100644 (file)
@@ -29,7 +29,7 @@ using namespace llvm;
 
 AMDILRegisterInfo::AMDILRegisterInfo(TargetMachine &tm,
     const TargetInstrInfo &tii)
-: AMDILGenRegisterInfo(0), // RA???
+: AMDGPUGenRegisterInfo(0), // RA???
   TM(tm), TII(tii)
 {
   baseOffset = 0;
index 892350b9e9ecce9c602183d8ba4e8936f15bac54..1be001cf7db77b74e7e26e4ac11357b38c0f3fc8 100644 (file)
@@ -34,7 +34,7 @@ namespace llvm
     };
   }
 
-  struct AMDILRegisterInfo : public AMDILGenRegisterInfo
+  struct AMDILRegisterInfo : public AMDGPUGenRegisterInfo
   {
     TargetMachine &TM;
     const TargetInstrInfo &TII;
index 723037e2e723e20e6a702696313a07d90dba5b5f..0e7d2b568748a74373c93b3b9006946d5920d1a8 100644 (file)
 #include "AMDILDevices.h"
 #include "AMDILUtilityFunctions.h"
 #include "llvm/ADT/SmallVector.h"
-#include "llvm/ADT/StringExtras.h"
-#include "llvm/ADT/StringRef.h"
 #include "llvm/MC/SubtargetFeature.h"
 
 using namespace llvm;
 
-#define GET_SUBTARGETINFO_ENUM
 #define GET_SUBTARGETINFO_CTOR
-#define GET_SUBTARGETINFO_TARGET_DESC
 #include "AMDGPUGenSubtargetInfo.inc"
 
-AMDILSubtarget::AMDILSubtarget(llvm::StringRef TT, llvm::StringRef CPU, llvm::StringRef FS) : AMDILGenSubtargetInfo( TT, CPU, FS ),
+AMDILSubtarget::AMDILSubtarget(llvm::StringRef TT, llvm::StringRef CPU, llvm::StringRef FS) : AMDGPUGenSubtargetInfo( TT, CPU, FS ),
   mDumpCode(false)
 {
-  memset(CapsOverride, 0, sizeof(*CapsOverride)
-      * AMDILDeviceInfo::MaxNumberCapabilities);
-  // Default card
-  std::string GPU = "rv770";
-  GPU = CPU;
-  mIs64bit = false;
-  mVersion = 0;
-  SmallVector<StringRef, DEFAULT_VEC_SLOTS> Features;
-  SplitString(FS, Features, ",");
-  mDefaultSize[0] = 64;
-  mDefaultSize[1] = 1;
-  mDefaultSize[2] = 1;
-  std::string newFeatures = "";
-#if defined(_DEBUG) || defined(DEBUG)
-  bool useTest = false;
-#endif
-  for (size_t x = 0; x < Features.size(); ++x) {
-    if (Features[x].startswith("+mwgs")) {
-      SmallVector<StringRef, DEFAULT_VEC_SLOTS> sizes;
-      SplitString(Features[x], sizes, "-");
-      size_t mDim = ::atoi(sizes[1].data());
-      if (mDim > 3) {
-        mDim = 3;
-      }
-      for (size_t y = 0; y < mDim; ++y) {
-        mDefaultSize[y] = ::atoi(sizes[y+2].data());
-      }
-#if defined(_DEBUG) || defined(DEBUG)
-    } else if (!Features[x].compare("test")) {
-      useTest = true;
-#endif
-    } else if (Features[x].startswith("+cal")) {
-      SmallVector<StringRef, DEFAULT_VEC_SLOTS> version;
-      SplitString(Features[x], version, "=");
-      mVersion = ::atoi(version[1].data());
-    } else {
-      GPU = CPU;
-      if (x > 0) newFeatures += ',';
-      newFeatures += Features[x];
-    }
-  }
-  // If we don't have a version then set it to
-  // -1 which enables everything. This is for
-  // offline devices.
-  if (!mVersion) {
-    mVersion = (uint32_t)-1;
-  }
-  for (int x = 0; x < 3; ++x) {
-    if (!mDefaultSize[x]) {
-      mDefaultSize[x] = 1;
-    }
-  }
-#if defined(_DEBUG) || defined(DEBUG)
-  if (useTest) {
-    GPU = "kauai";
-  }
-#endif
-  ParseSubtargetFeatures(GPU, newFeatures);
-#if defined(_DEBUG) || defined(DEBUG)
-  if (useTest) {
-    GPU = "test";
-  }
-#endif
-  mDevName = GPU;
-  mDevice = AMDILDeviceInfo::getDeviceFromName(mDevName, this, mIs64bit);
 }
 AMDILSubtarget::~AMDILSubtarget()
 {
index e3d8c814d0a18a7c08eb5684fe9dcd5d19faf615..cc0649300760baed5f326c1ae9dbfa4c6dbfb45d 100644 (file)
@@ -30,8 +30,8 @@ namespace llvm {
   class AMDILKernelManager;
   class AMDILGlobalManager;
   class AMDILDevice;
-  class AMDILSubtarget : public AMDILGenSubtargetInfo {
-    private:
+  class AMDILSubtarget : public AMDGPUGenSubtargetInfo {
+    protected:
       bool CapsOverride[AMDILDeviceInfo::MaxNumberCapabilities];
       mutable AMDILGlobalManager *mGM;
       mutable AMDILKernelManager *mKM;
@@ -64,10 +64,10 @@ namespace llvm {
       // ParseSubtargetFeatures - Parses features string setting specified
       // subtarget options.  Definition of function is
       //auto generated by tblgen.
-      void
+      virtual void
         ParseSubtargetFeatures(
             llvm::StringRef CPU,
-            llvm::StringRef FS);
+            llvm::StringRef FS) { assert(!"Unimplemented"); }
       bool dumpCode() const { return mDumpCode; }
 
   };
index 52c5faa6930b26b9d205c38bfc7379d2fed14860..fd35e9e17d9ba4f1fabd64a875a11ad52b95b9c4 100644 (file)
 
 using namespace llvm;
 
-static MCInstrInfo *createAMDILMCInstrInfo() {
+static MCInstrInfo *createAMDGPUMCInstrInfo() {
   MCInstrInfo *X = new MCInstrInfo();
-  InitAMDILMCInstrInfo(X);
+  InitAMDGPUMCInstrInfo(X);
   return X;
 }
 
-static MCRegisterInfo *createAMDILMCRegisterInfo(StringRef TT) {
+static MCRegisterInfo *createAMDGPUMCRegisterInfo(StringRef TT) {
   MCRegisterInfo *X = new MCRegisterInfo();
-  InitAMDILMCRegisterInfo(X, 0);
+  InitAMDGPUMCRegisterInfo(X, 0);
   return X;
 }
 
-static MCSubtargetInfo *createAMDILMCSubtargetInfo(StringRef TT, StringRef CPU,
+static MCSubtargetInfo *createAMDGPUMCSubtargetInfo(StringRef TT, StringRef CPU,
                                                    StringRef FS) {
   MCSubtargetInfo * X = new MCSubtargetInfo();
-  InitAMDILMCSubtargetInfo(X, TT, CPU, FS);
+  InitAMDGPUMCSubtargetInfo(X, TT, CPU, FS);
   return X;
 }
 
-static MCCodeGenInfo *createAMDILMCCodeGenInfo(StringRef TT, Reloc::Model RM,
+static MCCodeGenInfo *createAMDGPUMCCodeGenInfo(StringRef TT, Reloc::Model RM,
                                                CodeModel::Model CM,
                                                CodeGenOpt::Level OL) {
   MCCodeGenInfo *X = new MCCodeGenInfo();
@@ -50,12 +50,12 @@ extern "C" void LLVMInitializeAMDGPUTargetMC() {
 
   RegisterMCAsmInfo<AMDILMCAsmInfo> Y(TheAMDGPUTarget);
 
-  TargetRegistry::RegisterMCCodeGenInfo(TheAMDGPUTarget, createAMDILMCCodeGenInfo);
+  TargetRegistry::RegisterMCCodeGenInfo(TheAMDGPUTarget, createAMDGPUMCCodeGenInfo);
 
-  TargetRegistry::RegisterMCInstrInfo(TheAMDGPUTarget, createAMDILMCInstrInfo);
+  TargetRegistry::RegisterMCInstrInfo(TheAMDGPUTarget, createAMDGPUMCInstrInfo);
 
-  TargetRegistry::RegisterMCRegInfo(TheAMDGPUTarget, createAMDILMCRegisterInfo);
+  TargetRegistry::RegisterMCRegInfo(TheAMDGPUTarget, createAMDGPUMCRegisterInfo);
 
-  TargetRegistry::RegisterMCSubtargetInfo(TheAMDGPUTarget, createAMDILMCSubtargetInfo);
+  TargetRegistry::RegisterMCSubtargetInfo(TheAMDGPUTarget, createAMDGPUMCSubtargetInfo);
 
 }
index fc7b6520377d4e0082c34cc63316b9388191015d..d6e80d13624e35fc0559074eb6c74dff0a7417e4 100644 (file)
@@ -31,6 +31,7 @@ CPP_SOURCES := \
        AMDILRegisterInfo.cpp           \
        AMDILSIDevice.cpp               \
        AMDILSubtarget.cpp              \
+       AMDGPUSubtarget.cpp             \
        AMDGPUTargetMachine.cpp         \
        AMDGPUISelLowering.cpp          \
        AMDGPUConvertToISA.cpp          \
index 0c84633417abfba999483245b10d8336ea670049..c6b64c3db3ac4d4054cd3a0d5dee8970d490fe9f 100644 (file)
@@ -17,8 +17,8 @@
 //===----------------------------------------------------------------------===//
 
 #include "AMDGPU.h"
+#include "AMDGPUCodeEmitter.h"
 #include "AMDGPUUtil.h"
-#include "AMDILCodeEmitter.h"
 #include "AMDILInstrInfo.h"
 #include "AMDILUtilityFunctions.h"
 #include "R600InstrInfo.h"
@@ -39,7 +39,7 @@ using namespace llvm;
 
 namespace {
 
-class R600CodeEmitter : public MachineFunctionPass, public AMDILCodeEmitter {
+class R600CodeEmitter : public MachineFunctionPass, public AMDGPUCodeEmitter {
 
 private:
 
index cefed0864e55407d3f0c2fa49470e3428f6854d5..573e6fae00721a79d7188ac5a364415801535581 100644 (file)
@@ -14,8 +14,8 @@
 
 
 #include "AMDGPU.h"
+#include "AMDGPUCodeEmitter.h"
 #include "AMDGPUUtil.h"
-#include "AMDILCodeEmitter.h"
 #include "SIInstrInfo.h"
 #include "SIMachineFunctionInfo.h"
 #include "llvm/CodeGen/MachineFunctionPass.h"
@@ -32,7 +32,7 @@ using namespace llvm;
 
 namespace {
 
-  class SICodeEmitter : public MachineFunctionPass, public AMDILCodeEmitter {
+  class SICodeEmitter : public MachineFunctionPass, public AMDGPUCodeEmitter {
 
   private:
     static char ID;