Reimplement the temporary non-const getSubtargetImpl routine so
authorEric Christopher <echristo@gmail.com>
Mon, 4 Aug 2014 21:24:07 +0000 (21:24 +0000)
committerEric Christopher <echristo@gmail.com>
Mon, 4 Aug 2014 21:24:07 +0000 (21:24 +0000)
that we can avoid implementing it on every target. Thanks to Richard
Smith for the suggestions!

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

include/llvm/Target/TargetMachine.h

index d48f746..3b0c60d 100644 (file)
@@ -100,7 +100,10 @@ public:
   virtual const TargetSubtargetInfo *getSubtargetImpl() const {
     return nullptr;
   }
-  virtual TargetSubtargetInfo *getSubtargetImpl() { return nullptr; }
+  virtual TargetSubtargetInfo *getSubtargetImpl() {
+    const TargetMachine *TM = this;
+    return const_cast<TargetSubtargetInfo *>(TM->getSubtargetImpl());
+  }
 
   mutable TargetOptions Options;