<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">And AMDGPU is <span style="font-family: Menlo; font-size: 11px; background-color: rgb(255, 255, 255);" class="">r307186</span><div class=""><font face="Menlo" class=""><span style="font-size: 11px; background-color: rgb(255, 255, 255);" class=""><br class=""></span></font><div><blockquote type="cite" class=""><div class="">On Jun 30, 2017, at 5:46 PM, Quentin Colombet <<a href="mailto:qcolombet@apple.com" class="">qcolombet@apple.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><meta http-equiv="Content-Type" content="text/html charset=utf-8" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">Looks like I forgot about that stuff! Thanks for reminding me offline!<div class=""><br class=""></div><div class="">ARM: <span style="font-family: Menlo; font-size: 11px; background-color: rgb(255, 255, 255);" class="">r306920</span></div><div class="">X86: <span style="font-family: Menlo; font-size: 11px; background-color: rgb(255, 255, 255);" class="">r306921</span></div><div class=""><br class=""></div><div class="">Cheers,</div><div class="">Q.<br class=""><div class=""><blockquote type="cite" class=""><div class="">On May 1, 2017, at 3:26 PM, Quentin Colombet via llvm-commits <<a href="mailto:llvm-commits@lists.llvm.org" class="">llvm-commits@lists.llvm.org</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><meta http-equiv="Content-Type" content="text/html charset=utf-8" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">That’s r<span style="font-family: Menlo; font-size: 11px; background-color: rgb(255, 255, 255);" class="">301841</span><div class=""><font face="Menlo" class=""><span style="font-size: 11px; background-color: rgb(255, 255, 255);" class=""><br class=""></span></font></div><div class=""><div class="">I’m guessing ARM and X86 copied their code from AArch64, so the problem is likely to be there too. I’ll do that too.</div><div class=""><br class=""><blockquote type="cite" class=""><div class="">On Apr 27, 2017, at 11:25 AM, Eric Christopher <<a href="mailto:echristo@gmail.com" class="">echristo@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class="">Thank you! </div><br class=""><div class="gmail_quote"><div dir="ltr" class="">On Thu, Apr 27, 2017 at 11:24 AM Quentin Colombet <<a href="mailto:qcolombet@apple.com" class="">qcolombet@apple.com</a>> wrote:<br class=""></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word" class="">Hi Eric,<div class=""><br class=""></div><div class="">Catching up with my emails after my paternity leave.</div><div class=""><br class=""></div><div class=""><br class=""><div class=""></div></div></div><div style="word-wrap:break-word" class=""><div class=""><div class=""><blockquote type="cite" class=""><div class="">On Apr 25, 2017, at 2:57 PM, Eric Christopher <<a href="mailto:echristo@gmail.com" target="_blank" class="">echristo@gmail.com</a>> wrote:</div><br class="m_-6373834264525791603Apple-interchange-newline"><div class=""><div dir="ltr" class="">Adding in Gerolf since he's interested in this stuff too.<div class=""><br class=""></div><div class="">And a quick ping. :)</div><div class=""><br class=""></div><div class="">-eric<br class=""><br class=""><div class="gmail_quote"><div dir="ltr" class="">On Fri, Apr 14, 2017 at 10:28 PM Eric Christopher <<a href="mailto:echristo@gmail.com" target="_blank" class="">echristo@gmail.com</a>> wrote:<br class=""></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr" class=""><div class="">Hi Quentin,</div><div class=""><br class=""></div><div class="">I realize this is some definite archaeology, but the code is still there so...</div><div class=""><br class=""></div><div class="">Taking a look at r265567 I see this:</div></div><div dir="ltr" class=""><div class=""><br class=""></div><div class="">+#ifndef LLVM_BUILD_GLOBAL_ISEL</div><div class="">+    AArch64GISelAccessor *GISelAccessor = new AArch64GISelAccessor();</div><div class="">+#else</div><div class="">+    AArch64GISelActualAccessor *GISelAccessor =</div><div class="">+        new AArch64GISelActualAccessor();</div><div class="">+    GISelAccessor->CallLoweringInfo.reset(</div><div class="">+        new AArch64CallLowering(*I->getTargetLowering()));</div><div class="">+    GISelAccessor->RegBankInfo.reset(</div><div class="">+        new AArch64RegisterBankInfo(*I->getRegisterInfo()));</div><div class="">+#endif</div><div class="">+    I->setGISelAccessor(*GISelAccessor);</div><div class=""><br class=""></div></div><div dir="ltr" class=""><div class="">and I don't think that this is the right place to do this work.</div><div class=""><br class=""></div><div class="">It seems reasonable that all of this happens inside the subtarget construction rather than after we've constructed a new subtarget. Also means you can simplify a lot of the accesses.</div><div class=""><br class=""></div><div class="">Thoughts?</div></div></blockquote></div></div></div></div></blockquote><div class=""><br class=""></div></div></div></div><div style="word-wrap:break-word" class=""><div class=""><div class=""><div class="">Sounds reasonable.</div><div class=""><br class=""></div><div class="">I could have sworn there was a good reason why I didn’t do that, but it seems I am just stupid!</div><div class=""><br class=""></div><div class="">I’ll fix that in the coming days.</div><div class=""><br class=""></div><div class="">Thanks,</div><div class="">-Quentin</div></div></div></div><div style="word-wrap:break-word" class=""><div class=""><div class=""><br class=""><blockquote type="cite" class=""><div class=""><div dir="ltr" class=""><div class=""><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr" class=""><div class=""><br class=""></div><div class="">Thanks!</div></div><div dir="ltr" class=""><div class=""><br class=""></div><div class="">-eric</div><div class=""><br class=""></div></div><br class=""><div class="gmail_quote"><div dir="ltr" class="">On Wed, Apr 6, 2016 at 10:31 AM Quentin Colombet via llvm-commits <<a href="mailto:llvm-commits@lists.llvm.org" target="_blank" class="">llvm-commits@lists.llvm.org</a>> wrote:<br class=""></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: qcolombet<br class="">
Date: Wed Apr  6 12:26:03 2016<br class="">
New Revision: 265567<br class="">
<br class="">
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=265567&view=rev" rel="noreferrer" target="_blank" class="">http://llvm.org/viewvc/llvm-project?rev=265567&view=rev</a><br class="">
Log:<br class="">
[AArch64] Teach the subtarget how to get to the RegisterBankInfo.<br class="">
<br class="">
Rework the access to GlobalISel APIs to contain how much of<br class="">
the APIs we need to access for the final executable to build when<br class="">
GlobalISel is not built.<br class="">
<br class="">
This prevents massive usage of ifdefs in various places. Now, all the<br class="">
GlobalISel ifdefs will be happing only in AArch64TargetMachine.cpp.<br class="">
<br class="">
Added:<br class="">
    llvm/trunk/lib/Target/AArch64/AArch64GISelAccessor.h<br class="">
Modified:<br class="">
    llvm/trunk/lib/Target/AArch64/AArch64Subtarget.cpp<br class="">
    llvm/trunk/lib/Target/AArch64/AArch64Subtarget.h<br class="">
    llvm/trunk/lib/Target/AArch64/AArch64TargetMachine.cpp<br class="">
<br class="">
Added: llvm/trunk/lib/Target/AArch64/AArch64GISelAccessor.h<br class="">
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/AArch64/AArch64GISelAccessor.h?rev=265567&view=auto" rel="noreferrer" target="_blank" class="">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/AArch64/AArch64GISelAccessor.h?rev=265567&view=auto</a><br class="">
==============================================================================<br class="">
--- llvm/trunk/lib/Target/AArch64/AArch64GISelAccessor.h (added)<br class="">
+++ llvm/trunk/lib/Target/AArch64/AArch64GISelAccessor.h Wed Apr  6 12:26:03 2016<br class="">
@@ -0,0 +1,33 @@<br class="">
+//===-- AArch64GISelAccessor.h - AArch64 GISel Accessor ---------*- C++ -*-===//<br class="">
+//<br class="">
+//                     The LLVM Compiler Infrastructure<br class="">
+//<br class="">
+// This file is distributed under the University of Illinois Open Source<br class="">
+// License. See LICENSE.TXT for details.<br class="">
+//<br class="">
+//===----------------------------------------------------------------------===//<br class="">
+//<br class="">
+/// This file declares the API to access the various APIs related<br class="">
+/// to GlobalISel.<br class="">
+//<br class="">
+//===----------------------------------------------------------------------===/<br class="">
+<br class="">
+#ifndef LLVM_LIB_TARGET_AARCH64_AARCH64GISELACCESSOR_H<br class="">
+#define LLVM_LIB_TARGET_AARCH64_AARCH64GISELACCESSOR_H<br class="">
+<br class="">
+namespace llvm {<br class="">
+class CallLowering;<br class="">
+class RegisterBankInfo;<br class="">
+<br class="">
+/// The goal of this helper class is to gather the accessor to all<br class="">
+/// the APIs related to GlobalISel.<br class="">
+/// It should be derived to feature an actual accessor to the GISel APIs.<br class="">
+/// The reason why this is not simply done into the subtarget is to avoid<br class="">
+/// spreading ifdefs around.<br class="">
+struct AArch64GISelAccessor {<br class="">
+  virtual ~AArch64GISelAccessor() {}<br class="">
+  virtual const CallLowering *getCallLowering() const { return nullptr;}<br class="">
+  virtual const RegisterBankInfo *getRegBankInfo() const { return nullptr;}<br class="">
+};<br class="">
+} // End namespace llvm;<br class="">
+#endif<br class="">
<br class="">
Modified: llvm/trunk/lib/Target/AArch64/AArch64Subtarget.cpp<br class="">
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/AArch64/AArch64Subtarget.cpp?rev=265567&r1=265566&r2=265567&view=diff" rel="noreferrer" target="_blank" class="">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/AArch64/AArch64Subtarget.cpp?rev=265567&r1=265566&r2=265567&view=diff</a><br class="">
==============================================================================<br class="">
--- llvm/trunk/lib/Target/AArch64/AArch64Subtarget.cpp (original)<br class="">
+++ llvm/trunk/lib/Target/AArch64/AArch64Subtarget.cpp Wed Apr  6 12:26:03 2016<br class="">
@@ -57,12 +57,16 @@ AArch64Subtarget::AArch64Subtarget(const<br class="">
       StrictAlign(false), ReserveX18(TT.isOSDarwin()), IsLittle(LittleEndian),<br class="">
       CPUString(CPU), TargetTriple(TT), FrameLowering(),<br class="">
       InstrInfo(initializeSubtargetDependencies(FS)), TSInfo(),<br class="">
-      TLInfo(TM, *this), CallLoweringInfo(nullptr) {}<br class="">
+      TLInfo(TM, *this), GISelAccessor() {}<br class="">
<br class="">
 const CallLowering *AArch64Subtarget::getCallLowering() const {<br class="">
-  if (!CallLoweringInfo)<br class="">
-    CallLoweringInfo.reset(new AArch64CallLowering(TLInfo));<br class="">
-  return CallLoweringInfo.get();<br class="">
+  assert(GISelAccessor && "Access to GlobalISel APIs not set");<br class="">
+  return GISelAccessor->getCallLowering();<br class="">
+}<br class="">
+<br class="">
+const RegisterBankInfo *AArch64Subtarget::getRegBankInfo() const {<br class="">
+  assert(GISelAccessor && "Access to GlobalISel APIs not set");<br class="">
+  return GISelAccessor->getRegBankInfo();<br class="">
 }<br class="">
<br class="">
 /// ClassifyGlobalReference - Find the target operand flags that describe<br class="">
<br class="">
Modified: llvm/trunk/lib/Target/AArch64/AArch64Subtarget.h<br class="">
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/AArch64/AArch64Subtarget.h?rev=265567&r1=265566&r2=265567&view=diff" rel="noreferrer" target="_blank" class="">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/AArch64/AArch64Subtarget.h?rev=265567&r1=265566&r2=265567&view=diff</a><br class="">
==============================================================================<br class="">
--- llvm/trunk/lib/Target/AArch64/AArch64Subtarget.h (original)<br class="">
+++ llvm/trunk/lib/Target/AArch64/AArch64Subtarget.h Wed Apr  6 12:26:03 2016<br class="">
@@ -14,8 +14,8 @@<br class="">
 #ifndef LLVM_LIB_TARGET_AARCH64_AARCH64SUBTARGET_H<br class="">
 #define LLVM_LIB_TARGET_AARCH64_AARCH64SUBTARGET_H<br class="">
<br class="">
-#include "AArch64CallLowering.h"<br class="">
 #include "AArch64FrameLowering.h"<br class="">
+#include "AArch64GISelAccessor.h"<br class="">
 #include "AArch64ISelLowering.h"<br class="">
 #include "AArch64InstrInfo.h"<br class="">
 #include "AArch64RegisterInfo.h"<br class="">
@@ -82,7 +82,10 @@ protected:<br class="">
   AArch64InstrInfo InstrInfo;<br class="">
   AArch64SelectionDAGInfo TSInfo;<br class="">
   AArch64TargetLowering TLInfo;<br class="">
-  mutable std::unique_ptr<AArch64CallLowering> CallLoweringInfo;<br class="">
+  /// Gather the accessor points to GlobalISel-related APIs.<br class="">
+  /// This is used to avoid ifndefs spreading around while GISel is<br class="">
+  /// an optional library.<br class="">
+  std::unique_ptr<AArch64GISelAccessor> GISelAccessor;<br class="">
<br class="">
 private:<br class="">
   /// initializeSubtargetDependencies - Initializes using CPUString and the<br class="">
@@ -97,6 +100,11 @@ public:<br class="">
                    const std::string &FS, const TargetMachine &TM,<br class="">
                    bool LittleEndian);<br class="">
<br class="">
+  /// This object will take onwership of \p GISelAccessor.<br class="">
+  void setGISelAccessor(AArch64GISelAccessor &GISelAccessor) {<br class="">
+    this->GISelAccessor.reset(&GISelAccessor);<br class="">
+  }<br class="">
+<br class="">
   const AArch64SelectionDAGInfo *getSelectionDAGInfo() const override {<br class="">
     return &TSInfo;<br class="">
   }<br class="">
@@ -111,6 +119,7 @@ public:<br class="">
     return &getInstrInfo()->getRegisterInfo();<br class="">
   }<br class="">
   const CallLowering *getCallLowering() const override;<br class="">
+  const RegisterBankInfo *getRegBankInfo() const override;<br class="">
   const Triple &getTargetTriple() const { return TargetTriple; }<br class="">
   bool enableMachineScheduler() const override { return true; }<br class="">
   bool enablePostRAScheduler() const override {<br class="">
<br class="">
Modified: llvm/trunk/lib/Target/AArch64/AArch64TargetMachine.cpp<br class="">
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/AArch64/AArch64TargetMachine.cpp?rev=265567&r1=265566&r2=265567&view=diff" rel="noreferrer" target="_blank" class="">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/AArch64/AArch64TargetMachine.cpp?rev=265567&r1=265566&r2=265567&view=diff</a><br class="">
==============================================================================<br class="">
--- llvm/trunk/lib/Target/AArch64/AArch64TargetMachine.cpp (original)<br class="">
+++ llvm/trunk/lib/Target/AArch64/AArch64TargetMachine.cpp Wed Apr  6 12:26:03 2016<br class="">
@@ -11,6 +11,8 @@<br class="">
 //===----------------------------------------------------------------------===//<br class="">
<br class="">
 #include "AArch64.h"<br class="">
+#include "AArch64CallLowering.h"<br class="">
+#include "AArch64RegisterBankInfo.h"<br class="">
 #include "AArch64TargetMachine.h"<br class="">
 #include "AArch64TargetObjectFile.h"<br class="">
 #include "AArch64TargetTransformInfo.h"<br class="">
@@ -154,6 +156,21 @@ AArch64TargetMachine::AArch64TargetMachi<br class="">
<br class="">
 AArch64TargetMachine::~AArch64TargetMachine() {}<br class="">
<br class="">
+#ifdef LLVM_BUILD_GLOBAL_ISEL<br class="">
+namespace {<br class="">
+struct AArch64GISelActualAccessor : public AArch64GISelAccessor {<br class="">
+  std::unique_ptr<CallLowering> CallLoweringInfo;<br class="">
+  std::unique_ptr<RegisterBankInfo> RegBankInfo;<br class="">
+  const CallLowering *getCallLowering() const override {<br class="">
+    return CallLoweringInfo.get();<br class="">
+  }<br class="">
+  const RegisterBankInfo *getRegBankInfo() const override {<br class="">
+    return RegBankInfo.get();<br class="">
+  }<br class="">
+};<br class="">
+} // End anonymous namespace.<br class="">
+#endif<br class="">
+<br class="">
 const AArch64Subtarget *<br class="">
 AArch64TargetMachine::getSubtargetImpl(const Function &F) const {<br class="">
   Attribute CPUAttr = F.getFnAttribute("target-cpu");<br class="">
@@ -174,6 +191,17 @@ AArch64TargetMachine::getSubtargetImpl(c<br class="">
     resetTargetOptions(F);<br class="">
     I = llvm::make_unique<AArch64Subtarget>(TargetTriple, CPU, FS, *this,<br class="">
                                             isLittle);<br class="">
+#ifndef LLVM_BUILD_GLOBAL_ISEL<br class="">
+    AArch64GISelAccessor *GISelAccessor = new AArch64GISelAccessor();<br class="">
+#else<br class="">
+    AArch64GISelActualAccessor *GISelAccessor =<br class="">
+        new AArch64GISelActualAccessor();<br class="">
+    GISelAccessor->CallLoweringInfo.reset(<br class="">
+        new AArch64CallLowering(*I->getTargetLowering()));<br class="">
+    GISelAccessor->RegBankInfo.reset(<br class="">
+        new AArch64RegisterBankInfo(*I->getRegisterInfo()));<br class="">
+#endif<br class="">
+    I->setGISelAccessor(*GISelAccessor);<br class="">
   }<br class="">
   return I.get();<br class="">
 }<br class="">
<br class="">
<br class="">
_______________________________________________<br class="">
llvm-commits mailing list<br class="">
<a href="mailto:llvm-commits@lists.llvm.org" target="_blank" class="">llvm-commits@lists.llvm.org</a><br class="">
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits" rel="noreferrer" target="_blank" class="">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits</a><br class="">
</blockquote></div></blockquote></div></div></div>
</div></blockquote></div></div></div></blockquote></div>
</div></blockquote></div><br class=""></div></div>_______________________________________________<br class="">llvm-commits mailing list<br class=""><a href="mailto:llvm-commits@lists.llvm.org" class="">llvm-commits@lists.llvm.org</a><br class=""><a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits" class="">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits</a><br class=""></div></blockquote></div><br class=""></div></div></div></blockquote></div><br class=""></div></body></html>