[llvm] r265567 - [AArch64] Teach the subtarget how to get to the RegisterBankInfo.
Eric Christopher via llvm-commits
llvm-commits at lists.llvm.org
Fri Apr 14 22:28:35 PDT 2017
Hi Quentin,
I realize this is some definite archaeology, but the code is still there
so...
Taking a look at r265567 I see this:
+#ifndef LLVM_BUILD_GLOBAL_ISEL
+ AArch64GISelAccessor *GISelAccessor = new AArch64GISelAccessor();
+#else
+ AArch64GISelActualAccessor *GISelAccessor =
+ new AArch64GISelActualAccessor();
+ GISelAccessor->CallLoweringInfo.reset(
+ new AArch64CallLowering(*I->getTargetLowering()));
+ GISelAccessor->RegBankInfo.reset(
+ new AArch64RegisterBankInfo(*I->getRegisterInfo()));
+#endif
+ I->setGISelAccessor(*GISelAccessor);
and I don't think that this is the right place to do this work.
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.
Thoughts?
Thanks!
-eric
On Wed, Apr 6, 2016 at 10:31 AM Quentin Colombet via llvm-commits <
llvm-commits at lists.llvm.org> wrote:
> Author: qcolombet
> Date: Wed Apr 6 12:26:03 2016
> New Revision: 265567
>
> URL: http://llvm.org/viewvc/llvm-project?rev=265567&view=rev
> Log:
> [AArch64] Teach the subtarget how to get to the RegisterBankInfo.
>
> Rework the access to GlobalISel APIs to contain how much of
> the APIs we need to access for the final executable to build when
> GlobalISel is not built.
>
> This prevents massive usage of ifdefs in various places. Now, all the
> GlobalISel ifdefs will be happing only in AArch64TargetMachine.cpp.
>
> Added:
> llvm/trunk/lib/Target/AArch64/AArch64GISelAccessor.h
> Modified:
> llvm/trunk/lib/Target/AArch64/AArch64Subtarget.cpp
> llvm/trunk/lib/Target/AArch64/AArch64Subtarget.h
> llvm/trunk/lib/Target/AArch64/AArch64TargetMachine.cpp
>
> Added: llvm/trunk/lib/Target/AArch64/AArch64GISelAccessor.h
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/AArch64/AArch64GISelAccessor.h?rev=265567&view=auto
>
> ==============================================================================
> --- llvm/trunk/lib/Target/AArch64/AArch64GISelAccessor.h (added)
> +++ llvm/trunk/lib/Target/AArch64/AArch64GISelAccessor.h Wed Apr 6
> 12:26:03 2016
> @@ -0,0 +1,33 @@
> +//===-- AArch64GISelAccessor.h - AArch64 GISel Accessor ---------*- C++
> -*-===//
> +//
> +// The LLVM Compiler Infrastructure
> +//
> +// This file is distributed under the University of Illinois Open Source
> +// License. See LICENSE.TXT for details.
> +//
>
> +//===----------------------------------------------------------------------===//
> +//
> +/// This file declares the API to access the various APIs related
> +/// to GlobalISel.
> +//
>
> +//===----------------------------------------------------------------------===/
> +
> +#ifndef LLVM_LIB_TARGET_AARCH64_AARCH64GISELACCESSOR_H
> +#define LLVM_LIB_TARGET_AARCH64_AARCH64GISELACCESSOR_H
> +
> +namespace llvm {
> +class CallLowering;
> +class RegisterBankInfo;
> +
> +/// The goal of this helper class is to gather the accessor to all
> +/// the APIs related to GlobalISel.
> +/// It should be derived to feature an actual accessor to the GISel APIs.
> +/// The reason why this is not simply done into the subtarget is to avoid
> +/// spreading ifdefs around.
> +struct AArch64GISelAccessor {
> + virtual ~AArch64GISelAccessor() {}
> + virtual const CallLowering *getCallLowering() const { return nullptr;}
> + virtual const RegisterBankInfo *getRegBankInfo() const { return
> nullptr;}
> +};
> +} // End namespace llvm;
> +#endif
>
> Modified: llvm/trunk/lib/Target/AArch64/AArch64Subtarget.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/AArch64/AArch64Subtarget.cpp?rev=265567&r1=265566&r2=265567&view=diff
>
> ==============================================================================
> --- llvm/trunk/lib/Target/AArch64/AArch64Subtarget.cpp (original)
> +++ llvm/trunk/lib/Target/AArch64/AArch64Subtarget.cpp Wed Apr 6 12:26:03
> 2016
> @@ -57,12 +57,16 @@ AArch64Subtarget::AArch64Subtarget(const
> StrictAlign(false), ReserveX18(TT.isOSDarwin()),
> IsLittle(LittleEndian),
> CPUString(CPU), TargetTriple(TT), FrameLowering(),
> InstrInfo(initializeSubtargetDependencies(FS)), TSInfo(),
> - TLInfo(TM, *this), CallLoweringInfo(nullptr) {}
> + TLInfo(TM, *this), GISelAccessor() {}
>
> const CallLowering *AArch64Subtarget::getCallLowering() const {
> - if (!CallLoweringInfo)
> - CallLoweringInfo.reset(new AArch64CallLowering(TLInfo));
> - return CallLoweringInfo.get();
> + assert(GISelAccessor && "Access to GlobalISel APIs not set");
> + return GISelAccessor->getCallLowering();
> +}
> +
> +const RegisterBankInfo *AArch64Subtarget::getRegBankInfo() const {
> + assert(GISelAccessor && "Access to GlobalISel APIs not set");
> + return GISelAccessor->getRegBankInfo();
> }
>
> /// ClassifyGlobalReference - Find the target operand flags that describe
>
> Modified: llvm/trunk/lib/Target/AArch64/AArch64Subtarget.h
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/AArch64/AArch64Subtarget.h?rev=265567&r1=265566&r2=265567&view=diff
>
> ==============================================================================
> --- llvm/trunk/lib/Target/AArch64/AArch64Subtarget.h (original)
> +++ llvm/trunk/lib/Target/AArch64/AArch64Subtarget.h Wed Apr 6 12:26:03
> 2016
> @@ -14,8 +14,8 @@
> #ifndef LLVM_LIB_TARGET_AARCH64_AARCH64SUBTARGET_H
> #define LLVM_LIB_TARGET_AARCH64_AARCH64SUBTARGET_H
>
> -#include "AArch64CallLowering.h"
> #include "AArch64FrameLowering.h"
> +#include "AArch64GISelAccessor.h"
> #include "AArch64ISelLowering.h"
> #include "AArch64InstrInfo.h"
> #include "AArch64RegisterInfo.h"
> @@ -82,7 +82,10 @@ protected:
> AArch64InstrInfo InstrInfo;
> AArch64SelectionDAGInfo TSInfo;
> AArch64TargetLowering TLInfo;
> - mutable std::unique_ptr<AArch64CallLowering> CallLoweringInfo;
> + /// Gather the accessor points to GlobalISel-related APIs.
> + /// This is used to avoid ifndefs spreading around while GISel is
> + /// an optional library.
> + std::unique_ptr<AArch64GISelAccessor> GISelAccessor;
>
> private:
> /// initializeSubtargetDependencies - Initializes using CPUString and
> the
> @@ -97,6 +100,11 @@ public:
> const std::string &FS, const TargetMachine &TM,
> bool LittleEndian);
>
> + /// This object will take onwership of \p GISelAccessor.
> + void setGISelAccessor(AArch64GISelAccessor &GISelAccessor) {
> + this->GISelAccessor.reset(&GISelAccessor);
> + }
> +
> const AArch64SelectionDAGInfo *getSelectionDAGInfo() const override {
> return &TSInfo;
> }
> @@ -111,6 +119,7 @@ public:
> return &getInstrInfo()->getRegisterInfo();
> }
> const CallLowering *getCallLowering() const override;
> + const RegisterBankInfo *getRegBankInfo() const override;
> const Triple &getTargetTriple() const { return TargetTriple; }
> bool enableMachineScheduler() const override { return true; }
> bool enablePostRAScheduler() const override {
>
> Modified: llvm/trunk/lib/Target/AArch64/AArch64TargetMachine.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/AArch64/AArch64TargetMachine.cpp?rev=265567&r1=265566&r2=265567&view=diff
>
> ==============================================================================
> --- llvm/trunk/lib/Target/AArch64/AArch64TargetMachine.cpp (original)
> +++ llvm/trunk/lib/Target/AArch64/AArch64TargetMachine.cpp Wed Apr 6
> 12:26:03 2016
> @@ -11,6 +11,8 @@
>
> //===----------------------------------------------------------------------===//
>
> #include "AArch64.h"
> +#include "AArch64CallLowering.h"
> +#include "AArch64RegisterBankInfo.h"
> #include "AArch64TargetMachine.h"
> #include "AArch64TargetObjectFile.h"
> #include "AArch64TargetTransformInfo.h"
> @@ -154,6 +156,21 @@ AArch64TargetMachine::AArch64TargetMachi
>
> AArch64TargetMachine::~AArch64TargetMachine() {}
>
> +#ifdef LLVM_BUILD_GLOBAL_ISEL
> +namespace {
> +struct AArch64GISelActualAccessor : public AArch64GISelAccessor {
> + std::unique_ptr<CallLowering> CallLoweringInfo;
> + std::unique_ptr<RegisterBankInfo> RegBankInfo;
> + const CallLowering *getCallLowering() const override {
> + return CallLoweringInfo.get();
> + }
> + const RegisterBankInfo *getRegBankInfo() const override {
> + return RegBankInfo.get();
> + }
> +};
> +} // End anonymous namespace.
> +#endif
> +
> const AArch64Subtarget *
> AArch64TargetMachine::getSubtargetImpl(const Function &F) const {
> Attribute CPUAttr = F.getFnAttribute("target-cpu");
> @@ -174,6 +191,17 @@ AArch64TargetMachine::getSubtargetImpl(c
> resetTargetOptions(F);
> I = llvm::make_unique<AArch64Subtarget>(TargetTriple, CPU, FS, *this,
> isLittle);
> +#ifndef LLVM_BUILD_GLOBAL_ISEL
> + AArch64GISelAccessor *GISelAccessor = new AArch64GISelAccessor();
> +#else
> + AArch64GISelActualAccessor *GISelAccessor =
> + new AArch64GISelActualAccessor();
> + GISelAccessor->CallLoweringInfo.reset(
> + new AArch64CallLowering(*I->getTargetLowering()));
> + GISelAccessor->RegBankInfo.reset(
> + new AArch64RegisterBankInfo(*I->getRegisterInfo()));
> +#endif
> + I->setGISelAccessor(*GISelAccessor);
> }
> return I.get();
> }
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170415/7ac9f060/attachment.html>
More information about the llvm-commits
mailing list