[llvm] r210614 - Move to a private function to initialize the subtarget dependencies

Eric Christopher echristo at gmail.com
Tue Jun 10 17:25:19 PDT 2014


Author: echristo
Date: Tue Jun 10 19:25:19 2014
New Revision: 210614

URL: http://llvm.org/viewvc/llvm-project?rev=210614&view=rev
Log:
Move to a private function to initialize the subtarget dependencies
so that we can use initializer lists for the X86Subtarget.

Modified:
    llvm/trunk/lib/Target/X86/X86Subtarget.cpp
    llvm/trunk/lib/Target/X86/X86Subtarget.h

Modified: llvm/trunk/lib/Target/X86/X86Subtarget.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86Subtarget.cpp?rev=210614&r1=210613&r2=210614&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/X86Subtarget.cpp (original)
+++ llvm/trunk/lib/Target/X86/X86Subtarget.cpp Tue Jun 10 19:25:19 2014
@@ -335,6 +335,13 @@ static std::string computeDataLayout(con
   return Ret;
 }
 
+X86Subtarget &X86Subtarget::initializeSubtargetDependencies(StringRef CPU,
+                                                            StringRef FS) {
+  initializeEnvironment();
+  resetSubtargetFeatures(CPU, FS);
+  return *this;
+}
+
 X86Subtarget::X86Subtarget(const std::string &TT, const std::string &CPU,
                            const std::string &FS, X86TargetMachine &TM,
                            unsigned StackAlignOverride)
@@ -346,18 +353,11 @@ X86Subtarget::X86Subtarget(const std::st
                   TargetTriple.getEnvironment() != Triple::CODE16),
       In16BitMode(TargetTriple.getArch() == Triple::x86 &&
                   TargetTriple.getEnvironment() == Triple::CODE16),
-      DL(computeDataLayout(*this)), TSInfo(DL) {
-  initializeEnvironment();
-  resetSubtargetFeatures(CPU, FS);
-  // Ordering here is important. X86InstrInfo initializes X86RegisterInfo which
-  // X86TargetLowering needs.
-  InstrInfo = make_unique<X86InstrInfo>(*this);
-  TLInfo = make_unique<X86TargetLowering>(TM);
-  FrameLowering =
-      make_unique<X86FrameLowering>(TargetFrameLowering::StackGrowsDown,
-                                    getStackAlignment(), is64Bit() ? -8 : -4);
-  JITInfo = make_unique<X86JITInfo>(hasSSE1());
-}
+      DL(computeDataLayout(*this)), TSInfo(DL),
+      InstrInfo(initializeSubtargetDependencies(CPU, FS)), TLInfo(TM),
+      FrameLowering(TargetFrameLowering::StackGrowsDown, getStackAlignment(),
+                    is64Bit() ? -8 : -4),
+      JITInfo(hasSSE1()) {}
 
 bool
 X86Subtarget::enablePostRAScheduler(CodeGenOpt::Level OptLevel,

Modified: llvm/trunk/lib/Target/X86/X86Subtarget.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86Subtarget.h?rev=210614&r1=210613&r2=210614&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/X86Subtarget.h (original)
+++ llvm/trunk/lib/Target/X86/X86Subtarget.h Tue Jun 10 19:25:19 2014
@@ -229,10 +229,12 @@ private:
   // Calculates type size & alignment
   const DataLayout DL;
   X86SelectionDAGInfo TSInfo;
-  std::unique_ptr<X86TargetLowering> TLInfo;
-  std::unique_ptr<X86InstrInfo> InstrInfo;
-  std::unique_ptr<X86FrameLowering> FrameLowering;
-  std::unique_ptr<X86JITInfo> JITInfo;
+  // Ordering here is important. X86InstrInfo initializes X86RegisterInfo which
+  // X86TargetLowering needs.
+  X86InstrInfo InstrInfo;
+  X86TargetLowering TLInfo;
+  X86FrameLowering FrameLowering;
+  X86JITInfo JITInfo;
 
 public:
   /// This constructor initializes the data members to match that
@@ -242,14 +244,12 @@ public:
                const std::string &FS, X86TargetMachine &TM,
                unsigned StackAlignOverride);
 
-  const X86TargetLowering *getTargetLowering() const { return TLInfo.get(); }
-  const X86InstrInfo *getInstrInfo() const { return InstrInfo.get(); }
+  const X86TargetLowering *getTargetLowering() const { return &TLInfo; }
+  const X86InstrInfo *getInstrInfo() const { return &InstrInfo; }
   const DataLayout *getDataLayout() const { return &DL; }
-  const X86FrameLowering *getFrameLowering() const {
-    return FrameLowering.get();
-  }
+  const X86FrameLowering *getFrameLowering() const { return &FrameLowering; }
   const X86SelectionDAGInfo *getSelectionDAGInfo() const { return &TSInfo; }
-  X86JITInfo *getJITInfo() { return JITInfo.get(); }
+  X86JITInfo *getJITInfo() { return &JITInfo; }
 
   /// getStackAlignment - Returns the minimum alignment known to hold of the
   /// stack frame on entry to the function and which must be maintained by every
@@ -267,6 +267,9 @@ public:
   /// \brief Reset the features for the X86 target.
   void resetSubtargetFeatures(const MachineFunction *MF) override;
 private:
+  /// \brief Initialize the full set of dependencies so we can use an initializer
+  /// list for X86Subtarget.
+  X86Subtarget &initializeSubtargetDependencies(StringRef CPU, StringRef FS);
   void initializeEnvironment();
   void resetSubtargetFeatures(StringRef CPU, StringRef FS);
 public:





More information about the llvm-commits mailing list