1. Remove condition on delete.
authorJim Laskey <jlaskey@mac.com>
Thu, 7 Sep 2006 23:39:26 +0000 (23:39 +0000)
committerJim Laskey <jlaskey@mac.com>
Thu, 7 Sep 2006 23:39:26 +0000 (23:39 +0000)
2. Protect and outline createTargetAsmInfo.

3. Misc. kruft.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@30169 91177308-0d34-0410-b5e6-96231b3b80d8

14 files changed:
include/llvm/Target/TargetMachine.h
lib/Target/ARM/ARMTargetMachine.cpp
lib/Target/ARM/ARMTargetMachine.h
lib/Target/Alpha/AlphaTargetMachine.cpp
lib/Target/Alpha/AlphaTargetMachine.h
lib/Target/IA64/IA64TargetMachine.cpp
lib/Target/IA64/IA64TargetMachine.h
lib/Target/PowerPC/PPCTargetMachine.cpp
lib/Target/PowerPC/PPCTargetMachine.h
lib/Target/Sparc/SparcTargetMachine.cpp
lib/Target/Sparc/SparcTargetMachine.h
lib/Target/TargetMachine.cpp
lib/Target/X86/X86TargetMachine.cpp
lib/Target/X86/X86TargetMachine.h

index 6b5efd41496cda7355cbbb1265f40bf027da35cd..13b0d37d5b4a7052b6992ba7659950c3253326da 100644 (file)
@@ -76,6 +76,10 @@ protected: // Can only create subclasses.
   ///
   mutable const TargetAsmInfo *AsmInfo;
   
+  /// createTargetAsmInfo - Create a new instance of target specific asm
+  /// information.
+  virtual const TargetAsmInfo *createTargetAsmInfo() const { return NULL; }
+
 public:
   virtual ~TargetMachine();
 
@@ -111,10 +115,6 @@ public:
     return AsmInfo;
   }
   
-  /// createTargetAsmInfo - Create a new instance of target specific asm
-  /// information.
-  virtual const TargetAsmInfo *createTargetAsmInfo() const { return NULL; }
-
   /// getSubtarget - This method returns a pointer to the specified type of
   /// TargetSubtarget.  In debug builds, it verifies that the object being
   /// returned is of the correct type.
index 175335f5c1164845221d32802db7224ab40976d0..ccf0fb7ed6758409f81980be360ac2bdd1c1e100 100644 (file)
@@ -11,6 +11,7 @@
 //
 //===----------------------------------------------------------------------===//
 
+#include "ARMTargetAsmInfo.h"
 #include "ARMTargetMachine.h"
 #include "ARMFrameInfo.h"
 #include "ARM.h"
@@ -24,6 +25,12 @@ namespace {
   RegisterTarget<ARMTargetMachine> X("arm", "  ARM");
 }
 
+
+const TargetAsmInfo *ARMTargetMachine::createTargetAsmInfo() const {
+  return new ARMTargetAsmInfo(*this);
+}
+
+
 /// TargetMachine ctor - Create an ILP32 architecture model
 ///
 ARMTargetMachine::ARMTargetMachine(const Module &M, const std::string &FS)
index bf8deba9c3bd1840c34716ad6b8371afa95f02fd..b453f0b64785b3c04ba611626419e3fedd68e0d5 100644 (file)
@@ -20,7 +20,6 @@
 #include "llvm/Target/TargetFrameInfo.h"
 #include "ARMInstrInfo.h"
 #include "ARMFrameInfo.h"
-#include "ARMTargetAsmInfo.h"
 
 namespace llvm {
 
@@ -30,6 +29,10 @@ class ARMTargetMachine : public LLVMTargetMachine {
   const TargetData DataLayout;       // Calculates type size & alignment
   ARMInstrInfo InstrInfo;
   ARMFrameInfo FrameInfo;
+  
+protected:
+  virtual const TargetAsmInfo *createTargetAsmInfo() const;
+
 public:
   ARMTargetMachine(const Module &M, const std::string &FS);
 
@@ -41,10 +44,6 @@ public:
   virtual const TargetData       *getTargetData() const { return &DataLayout; }
   static unsigned getModuleMatchQuality(const Module &M);
 
-  virtual const TargetAsmInfo *createTargetAsmInfo() const {
-    return static_cast<const TargetAsmInfo *>(new ARMTargetAsmInfo(*this));
-  }
-
   // Pass Pipeline Configuration
   virtual bool addInstSelector(FunctionPassManager &PM, bool Fast);
   virtual bool addAssemblyEmitter(FunctionPassManager &PM, bool Fast, 
index cbe0cdbf4d7304cf8d05ee553dd1923c5c174cd8..b752e4c1043f50cb2641ffc44a8156c88b0da663 100644 (file)
@@ -12,6 +12,7 @@
 
 #include "Alpha.h"
 #include "AlphaJITInfo.h"
+#include "AlphaTargetAsmInfo.h"
 #include "AlphaTargetMachine.h"
 #include "llvm/Module.h"
 #include "llvm/PassManager.h"
@@ -24,6 +25,10 @@ namespace {
   RegisterTarget<AlphaTargetMachine> X("alpha", "  Alpha (incomplete)");
 }
 
+const TargetAsmInfo *AlphaTargetMachine::createTargetAsmInfo() const {
+  return new AlphaTargetAsmInfo(*this);
+}
+
 unsigned AlphaTargetMachine::getModuleMatchQuality(const Module &M) {
   // We strongly match "alpha*".
   std::string TT = M.getTargetTriple();
@@ -53,8 +58,7 @@ AlphaTargetMachine::AlphaTargetMachine(const Module &M, const std::string &FS)
   : DataLayout("e"),
     FrameInfo(TargetFrameInfo::StackGrowsDown, 16, 0),
     JITInfo(*this),
-    Subtarget(M, FS),
-    AsmInfo(NULL) {
+    Subtarget(M, FS) {
 }
 
 
index d47ca8215c9fa663343e50a3c55684fc4f5afaec..c00e71c87531e87b55074f883615899b5f16800f 100644 (file)
@@ -20,7 +20,6 @@
 #include "AlphaInstrInfo.h"
 #include "AlphaJITInfo.h"
 #include "AlphaSubtarget.h"
-#include "AlphaTargetAsmInfo.h"
 
 namespace llvm {
 
@@ -32,13 +31,12 @@ class AlphaTargetMachine : public LLVMTargetMachine {
   TargetFrameInfo FrameInfo;
   AlphaJITInfo JITInfo;
   AlphaSubtarget Subtarget;
-  AlphaTargetAsmInfo *AsmInfo;
+  
+protected:
+  virtual const TargetAsmInfo *createTargetAsmInfo() const;
   
 public:
   AlphaTargetMachine(const Module &M, const std::string &FS);
-  ~AlphaTargetMachine() {
-    if (AsmInfo) delete AsmInfo;
-  }
 
   virtual const AlphaInstrInfo *getInstrInfo() const { return &InstrInfo; }
   virtual const TargetFrameInfo  *getFrameInfo() const { return &FrameInfo; }
@@ -51,10 +49,6 @@ public:
     return &JITInfo;
   }
 
-  virtual const TargetAsmInfo *createTargetAsmInfo() const {
-    return static_cast<const TargetAsmInfo *>(new AlphaTargetAsmInfo(*this));
-  }
-
   static unsigned getJITMatchQuality();
   static unsigned getModuleMatchQuality(const Module &M);
   
index 0f7821f5af7053432791f97de75bd3e4b6ba601d..d65ad3c4e1c0e1c28585da1bc21bdd5683aea68e 100644 (file)
@@ -11,6 +11,7 @@
 //
 //===----------------------------------------------------------------------===//
 
+#include "IA64TargetAsmInfo.h"
 #include "IA64TargetMachine.h"
 #include "IA64.h"
 #include "llvm/Module.h"
@@ -29,6 +30,10 @@ namespace {
   RegisterTarget<IA64TargetMachine> X("ia64", "  IA-64 (Itanium)");
 }
 
+const TargetAsmInfo *IA64TargetMachine::createTargetAsmInfo() const {
+  return new IA64TargetAsmInfo(*this);
+}
+
 unsigned IA64TargetMachine::getModuleMatchQuality(const Module &M) {
   // we match [iI][aA]*64
   bool seenIA64=false;
index 61ac05f6a2bf4c12e46f65a662200f261c07c0f4..538a3303d3b20553293939f215efa8448641cf61 100644 (file)
@@ -19,7 +19,6 @@
 #include "llvm/Target/TargetFrameInfo.h"
 #include "IA64InstrInfo.h"
 #include "IA64ISelLowering.h"
-#include "IA64TargetAsmInfo.h"
 
 namespace llvm {
 
@@ -29,6 +28,10 @@ class IA64TargetMachine : public LLVMTargetMachine {
   TargetFrameInfo    FrameInfo;
   //IA64JITInfo      JITInfo;
   IA64TargetLowering TLInfo;
+  
+protected:
+  virtual const TargetAsmInfo *createTargetAsmInfo() const;
+
 public:
   IA64TargetMachine(const Module &M, const std::string &FS);
 
@@ -42,10 +45,6 @@ public:
   }
   virtual const TargetData       *getTargetData() const { return &DataLayout; }
   
-  virtual const TargetAsmInfo *createTargetAsmInfo() const {
-    return static_cast<const TargetAsmInfo *>(new IA64TargetAsmInfo(*this));
-  }
-
   static unsigned getModuleMatchQuality(const Module &M);
 
   // Pass Pipeline Configuration
index 91fc0a6b99ee38b4cfeed4f3ee2eff7cf600a808..ac20022d50e3148f80ecbba49a67258d82314f7b 100644 (file)
@@ -12,6 +12,7 @@
 //===----------------------------------------------------------------------===//
 
 #include "PPC.h"
+#include "PPCTargetAsmInfo.h"
 #include "PPCTargetMachine.h"
 #include "llvm/Module.h"
 #include "llvm/PassManager.h"
@@ -26,6 +27,10 @@ namespace {
   Y("ppc64", "  PowerPC 64");
 }
 
+const TargetAsmInfo *PPCTargetMachine::createTargetAsmInfo() const {
+  return new DarwinTargetAsmInfo(*this);
+}
+
 unsigned PPC32TargetMachine::getJITMatchQuality() {
 #if defined(__POWERPC__) || defined (__ppc__) || defined(_POWER)
   if (sizeof(void*) == 4)
index d11f0158a02d793661f9b81a82adffc3c2eeebf5..777772e1fae84319f27bbfa66917ea1ebb044e31 100644 (file)
@@ -19,7 +19,6 @@
 #include "PPCJITInfo.h"
 #include "PPCInstrInfo.h"
 #include "PPCISelLowering.h"
-#include "PPCTargetAsmInfo.h"
 #include "llvm/Target/TargetMachine.h"
 #include "llvm/Target/TargetData.h"
 
@@ -37,6 +36,10 @@ class PPCTargetMachine : public LLVMTargetMachine {
   PPCJITInfo          JITInfo;
   PPCTargetLowering   TLInfo;
   InstrItineraryData  InstrItins;
+  
+protected:
+  virtual const TargetAsmInfo *createTargetAsmInfo() const;
+  
 public:
   PPCTargetMachine(const Module &M, const std::string &FS, bool is64Bit);
 
@@ -56,10 +59,6 @@ public:
     return InstrItins;
   }
   
-  virtual const TargetAsmInfo *createTargetAsmInfo() const {
-    return static_cast<const TargetAsmInfo *>(new DarwinTargetAsmInfo(*this));
-  }
-  
   // Pass Pipeline Configuration
   virtual bool addInstSelector(FunctionPassManager &PM, bool Fast);
   virtual bool addPreEmitPass(FunctionPassManager &PM, bool Fast);
index 477e9544140cb3793c9759e9474a79744508bbf4..98912a2353127e578281e2c466628e7f48539b4b 100644 (file)
@@ -10,6 +10,7 @@
 //
 //===----------------------------------------------------------------------===//
 
+#include "SparcTargetAsmInfo.h"
 #include "SparcTargetMachine.h"
 #include "Sparc.h"
 #include "llvm/Module.h"
@@ -23,6 +24,10 @@ namespace {
   RegisterTarget<SparcTargetMachine> X("sparc", "  SPARC");
 }
 
+const TargetAsmInfo *SparcTargetMachine::createTargetAsmInfo() const {
+  return new SparcTargetAsmInfo(*this);
+}
+
 /// SparcTargetMachine ctor - Create an ILP32 architecture model
 ///
 SparcTargetMachine::SparcTargetMachine(const Module &M, const std::string &FS)
index 995d346f92440254395a29c10e15e1230b1388c6..cec0a446c0c3568784efea1a1c5374dc044096f9 100644 (file)
@@ -19,7 +19,6 @@
 #include "llvm/Target/TargetFrameInfo.h"
 #include "SparcInstrInfo.h"
 #include "SparcSubtarget.h"
-#include "SparcTargetAsmInfo.h"
 
 namespace llvm {
 
@@ -30,6 +29,10 @@ class SparcTargetMachine : public LLVMTargetMachine {
   SparcSubtarget Subtarget;
   SparcInstrInfo InstrInfo;
   TargetFrameInfo FrameInfo;
+  
+protected:
+  virtual const TargetAsmInfo *createTargetAsmInfo() const;
+  
 public:
   SparcTargetMachine(const Module &M, const std::string &FS);
 
@@ -42,10 +45,6 @@ public:
   virtual const TargetData       *getTargetData() const { return &DataLayout; }
   static unsigned getModuleMatchQuality(const Module &M);
 
-  virtual const TargetAsmInfo *createTargetAsmInfo() const {
-    return static_cast<const TargetAsmInfo *>(new SparcTargetAsmInfo(*this));
-  }
-  
   // Pass Pipeline Configuration
   virtual bool addInstSelector(FunctionPassManager &PM, bool Fast);
   virtual bool addPreEmitPass(FunctionPassManager &PM, bool Fast);
index 3ca64c44edba1099e640cb47069192ad41fdb208..e4ece7b4d52b4996504ae872e1b57be5469c50d8 100644 (file)
@@ -96,7 +96,7 @@ namespace {
 //
 
 TargetMachine::~TargetMachine() {
-  if (AsmInfo) delete AsmInfo;
+  delete AsmInfo;
 }
 
 /// getRelocationModel - Returns the code generation relocation model. The
index ec449e42c49328935f0e5207540543e29d4a0b13..807b462b90b0968cd709b0a6a5eadebebbf5bc3e 100644 (file)
@@ -11,6 +11,7 @@
 //
 //===----------------------------------------------------------------------===//
 
+#include "X86TargetAsmInfo.h"
 #include "X86TargetMachine.h"
 #include "X86.h"
 #include "llvm/Module.h"
@@ -35,6 +36,10 @@ namespace {
   RegisterTarget<X86TargetMachine> X("x86", "  IA-32 (Pentium and above)");
 }
 
+const TargetAsmInfo *X86TargetMachine::createTargetAsmInfo() const {
+  return new X86TargetAsmInfo(*this);
+}
+
 unsigned X86TargetMachine::getJITMatchQuality() {
 #if defined(i386) || defined(__i386__) || defined(__x86__) || defined(_M_IX86)
   return 10;
index 0bbef0582ff44627fe121a895c9b2d40ba748b08..8278cf1b22a0de64a690d2f52f67e30411d10cbe 100644 (file)
@@ -21,7 +21,6 @@
 #include "X86InstrInfo.h"
 #include "X86JITInfo.h"
 #include "X86Subtarget.h"
-#include "X86TargetAsmInfo.h"
 #include "X86ISelLowering.h"
 
 namespace llvm {
@@ -33,6 +32,10 @@ class X86TargetMachine : public LLVMTargetMachine {
   X86InstrInfo      InstrInfo;
   X86JITInfo        JITInfo;
   X86TargetLowering TLInfo;
+
+protected:
+  virtual const TargetAsmInfo *createTargetAsmInfo() const;
+  
 public:
   X86TargetMachine(const Module &M, const std::string &FS);
 
@@ -51,10 +54,6 @@ public:
   static unsigned getModuleMatchQuality(const Module &M);
   static unsigned getJITMatchQuality();
   
-  virtual const TargetAsmInfo *createTargetAsmInfo() const {
-    return static_cast<const TargetAsmInfo *>(new X86TargetAsmInfo(*this));
-  }
-  
   // Set up the pass pipeline.
   virtual bool addInstSelector(FunctionPassManager &PM, bool Fast);  
   virtual bool addPostRegAlloc(FunctionPassManager &PM, bool Fast);