llvm.org GIT mirror llvm / f646c27
[GlobalISel] Remove the GISelAccessor API. Its sole purpose was to avoid spreading around ifdefs related to building global-isel. Since r309990, GlobalISel is not optional anymore, thus, we can get rid of this mechanism all together. NFC. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@310115 91177308-0d34-0410-b5e6-96231b3b80d8 Quentin Colombet 2 years ago
10 changed file(s) with 76 addition(s) and 242 deletion(s). Raw diff Collapse all Expand all
632632
633633 * ``TargetPassConfig`` --- create the passes constituting the pipeline,
634634 including additional passes not included in the :ref:`pipeline`.
635 * ``GISelAccessor`` --- setup the various subtarget-provided classes, with a
636 graceful fallback to no-op when GlobalISel isn't enabled.
+0
-39
include/llvm/CodeGen/GlobalISel/GISelAccessor.h less more
None //===-- GISelAccessor.h - GISel Accessor ------------------------*- C++ -*-===//
1 //
2 // The LLVM Compiler Infrastructure
3 //
4 // This file is distributed under the University of Illinois Open Source
5 // License. See LICENSE.TXT for details.
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 /// This file declares the API to access the various APIs related
10 /// to GlobalISel.
11 //
12 //===----------------------------------------------------------------------===/
13
14 #ifndef LLVM_CODEGEN_GLOBALISEL_GISELACCESSOR_H
15 #define LLVM_CODEGEN_GLOBALISEL_GISELACCESSOR_H
16
17 namespace llvm {
18 class CallLowering;
19 class InstructionSelector;
20 class LegalizerInfo;
21 class RegisterBankInfo;
22
23 /// The goal of this helper class is to gather the accessor to all
24 /// the APIs related to GlobalISel.
25 /// It should be derived to feature an actual accessor to the GISel APIs.
26 /// The reason why this is not simply done into the subtarget is to avoid
27 /// spreading ifdefs around.
28 struct GISelAccessor {
29 virtual ~GISelAccessor() {}
30 virtual const CallLowering *getCallLowering() const { return nullptr;}
31 virtual const InstructionSelector *getInstructionSelector() const {
32 return nullptr;
33 }
34 virtual const LegalizerInfo *getLegalizerInfo() const { return nullptr; }
35 virtual const RegisterBankInfo *getRegBankInfo() const { return nullptr;}
36 };
37 } // End namespace llvm;
38 #endif
2020 #include "AArch64CallLowering.h"
2121 #include "AArch64LegalizerInfo.h"
2222 #include "AArch64RegisterBankInfo.h"
23 #include "llvm/CodeGen/GlobalISel/GISelAccessor.h"
2423 #include "llvm/CodeGen/GlobalISel/IRTranslator.h"
2524 #include "llvm/CodeGen/GlobalISel/InstructionSelect.h"
2625 #include "llvm/CodeGen/GlobalISel/Legalizer.h"
140139 }
141140 }
142141
143 namespace {
144
145 struct AArch64GISelActualAccessor : public GISelAccessor {
146 std::unique_ptr CallLoweringInfo;
147 std::unique_ptr InstSelector;
148 std::unique_ptr Legalizer;
149 std::unique_ptr RegBankInfo;
150
151 const CallLowering *getCallLowering() const override {
152 return CallLoweringInfo.get();
153 }
154
155 const InstructionSelector *getInstructionSelector() const override {
156 return InstSelector.get();
157 }
158
159 const LegalizerInfo *getLegalizerInfo() const override {
160 return Legalizer.get();
161 }
162
163 const RegisterBankInfo *getRegBankInfo() const override {
164 return RegBankInfo.get();
165 }
166 };
167
168 } // end anonymous namespace
169
170142 AArch64Subtarget::AArch64Subtarget(const Triple &TT, const std::string &CPU,
171143 const std::string &FS,
172144 const TargetMachine &TM, bool LittleEndian)
173145 : AArch64GenSubtargetInfo(TT, CPU, FS),
174 ReserveX18(TT.isOSDarwin() || TT.isOSWindows()),
175 IsLittle(LittleEndian), TargetTriple(TT), FrameLowering(),
146 ReserveX18(TT.isOSDarwin() || TT.isOSWindows()), IsLittle(LittleEndian),
147 TargetTriple(TT), FrameLowering(),
176148 InstrInfo(initializeSubtargetDependencies(FS, CPU)), TSInfo(),
177 TLInfo(TM, *this), GISel() {
178 AArch64GISelActualAccessor *AArch64GISel = new AArch64GISelActualAccessor();
179 AArch64GISel->CallLoweringInfo.reset(
180 new AArch64CallLowering(*getTargetLowering()));
181 AArch64GISel->Legalizer.reset(new AArch64LegalizerInfo());
149 TLInfo(TM, *this) {
150 CallLoweringInfo.reset(new AArch64CallLowering(*getTargetLowering()));
151 Legalizer.reset(new AArch64LegalizerInfo());
182152
183153 auto *RBI = new AArch64RegisterBankInfo(*getRegisterInfo());
184154
185155 // FIXME: At this point, we can't rely on Subtarget having RBI.
186156 // It's awkward to mix passing RBI and the Subtarget; should we pass
187157 // TII/TRI as well?
188 AArch64GISel->InstSelector.reset(createAArch64InstructionSelector(
158 InstSelector.reset(createAArch64InstructionSelector(
189159 *static_cast(&TM), *this, *RBI));
190160
191 AArch64GISel->RegBankInfo.reset(RBI);
192 setGISelAccessor(*AArch64GISel);
161 RegBankInfo.reset(RBI);
193162 }
194163
195164 const CallLowering *AArch64Subtarget::getCallLowering() const {
196 assert(GISel && "Access to GlobalISel APIs not set");
197 return GISel->getCallLowering();
165 return CallLoweringInfo.get();
198166 }
199167
200168 const InstructionSelector *AArch64Subtarget::getInstructionSelector() const {
201 assert(GISel && "Access to GlobalISel APIs not set");
202 return GISel->getInstructionSelector();
169 return InstSelector.get();
203170 }
204171
205172 const LegalizerInfo *AArch64Subtarget::getLegalizerInfo() const {
206 assert(GISel && "Access to GlobalISel APIs not set");
207 return GISel->getLegalizerInfo();
173 return Legalizer.get();
208174 }
209175
210176 const RegisterBankInfo *AArch64Subtarget::getRegBankInfo() const {
211 assert(GISel && "Access to GlobalISel APIs not set");
212 return GISel->getRegBankInfo();
177 return RegBankInfo.get();
213178 }
214179
215180 /// Find the target operand flags that describe how a global value should be
1818 #include "AArch64InstrInfo.h"
1919 #include "AArch64RegisterInfo.h"
2020 #include "AArch64SelectionDAGInfo.h"
21 #include "llvm/CodeGen/GlobalISel/GISelAccessor.h"
21 #include "llvm/CodeGen/GlobalISel/CallLowering.h"
22 #include "llvm/CodeGen/GlobalISel/InstructionSelector.h"
23 #include "llvm/CodeGen/GlobalISel/LegalizerInfo.h"
24 #include "llvm/CodeGen/GlobalISel/RegisterBankInfo.h"
2225 #include "llvm/IR/DataLayout.h"
2326 #include "llvm/Target/TargetSubtargetInfo.h"
2427 #include
123126 AArch64InstrInfo InstrInfo;
124127 AArch64SelectionDAGInfo TSInfo;
125128 AArch64TargetLowering TLInfo;
126 /// Gather the accessor points to GlobalISel-related APIs.
127 /// This is used to avoid ifndefs spreading around while GISel is
128 /// an optional library.
129 std::unique_ptr GISel;
129
130 /// GlobalISel related APIs.
131 std::unique_ptr CallLoweringInfo;
132 std::unique_ptr InstSelector;
133 std::unique_ptr Legalizer;
134 std::unique_ptr RegBankInfo;
130135
131136 private:
132137 /// initializeSubtargetDependencies - Initializes using CPUString and the
144149 AArch64Subtarget(const Triple &TT, const std::string &CPU,
145150 const std::string &FS, const TargetMachine &TM,
146151 bool LittleEndian);
147
148 /// This object will take onwership of \p GISelAccessor.
149 void setGISelAccessor(GISelAccessor &GISel) {
150 this->GISel.reset(&GISel);
151 }
152152
153153 const AArch64SelectionDAGInfo *getSelectionDAGInfo() const override {
154154 return &TSInfo;
7676
7777 return *this;
7878 }
79
80 namespace {
81
82 struct SIGISelActualAccessor : public GISelAccessor {
83 std::unique_ptr CallLoweringInfo;
84 std::unique_ptr InstSelector;
85 std::unique_ptr Legalizer;
86 std::unique_ptr RegBankInfo;
87 const AMDGPUCallLowering *getCallLowering() const override {
88 return CallLoweringInfo.get();
89 }
90 const InstructionSelector *getInstructionSelector() const override {
91 return InstSelector.get();
92 }
93 const LegalizerInfo *getLegalizerInfo() const override {
94 return Legalizer.get();
95 }
96 const RegisterBankInfo *getRegBankInfo() const override {
97 return RegBankInfo.get();
98 }
99 };
100
101 } // end anonymous namespace
10279
10380 AMDGPUSubtarget::AMDGPUSubtarget(const Triple &TT, StringRef GPU, StringRef FS,
10481 const TargetMachine &TM)
353330 : AMDGPUSubtarget(TT, GPU, FS, TM), InstrInfo(*this),
354331 FrameLowering(TargetFrameLowering::StackGrowsUp, getStackAlignment(), 0),
355332 TLInfo(TM, *this) {
356 SIGISelActualAccessor *GISel = new SIGISelActualAccessor();
357 GISel->CallLoweringInfo.reset(new AMDGPUCallLowering(*getTargetLowering()));
358 GISel->Legalizer.reset(new AMDGPULegalizerInfo());
359
360 GISel->RegBankInfo.reset(new AMDGPURegisterBankInfo(*getRegisterInfo()));
361 GISel->InstSelector.reset(new AMDGPUInstructionSelector(
362 *this, *static_cast(GISel->RegBankInfo.get())));
363 setGISelAccessor(*GISel);
333 CallLoweringInfo.reset(new AMDGPUCallLowering(*getTargetLowering()));
334 Legalizer.reset(new AMDGPULegalizerInfo());
335
336 RegBankInfo.reset(new AMDGPURegisterBankInfo(*getRegisterInfo()));
337 InstSelector.reset(new AMDGPUInstructionSelector(
338 *this, *static_cast(RegBankInfo.get())));
364339 }
365340
366341 void SISubtarget::overrideSchedPolicy(MachineSchedPolicy &Policy,
1515 #define LLVM_LIB_TARGET_AMDGPU_AMDGPUSUBTARGET_H
1616
1717 #include "AMDGPU.h"
18 #include "AMDGPUCallLowering.h"
1819 #include "R600FrameLowering.h"
1920 #include "R600ISelLowering.h"
2021 #include "R600InstrInfo.h"
2425 #include "SIMachineFunctionInfo.h"
2526 #include "Utils/AMDGPUBaseInfo.h"
2627 #include "llvm/ADT/Triple.h"
27 #include "llvm/CodeGen/GlobalISel/GISelAccessor.h"
28 #include "llvm/CodeGen/GlobalISel/InstructionSelector.h"
29 #include "llvm/CodeGen/GlobalISel/LegalizerInfo.h"
30 #include "llvm/CodeGen/GlobalISel/RegisterBankInfo.h"
2831 #include "llvm/CodeGen/MachineFunction.h"
2932 #include "llvm/CodeGen/SelectionDAGTargetInfo.h"
3033 #include "llvm/MC/MCInstrItineraries.h"
630633 SIInstrInfo InstrInfo;
631634 SIFrameLowering FrameLowering;
632635 SITargetLowering TLInfo;
633 std::unique_ptr GISel;
636
637 /// GlobalISel related APIs.
638 std::unique_ptr CallLoweringInfo;
639 std::unique_ptr InstSelector;
640 std::unique_ptr Legalizer;
641 std::unique_ptr RegBankInfo;
634642
635643 public:
636644 SISubtarget(const Triple &TT, StringRef CPU, StringRef FS,
649657 }
650658
651659 const CallLowering *getCallLowering() const override {
652 assert(GISel && "Access to GlobalISel APIs not set");
653 return GISel->getCallLowering();
660 return CallLoweringInfo.get();
654661 }
655662
656663 const InstructionSelector *getInstructionSelector() const override {
657 assert(GISel && "Access to GlobalISel APIs not set");
658 return GISel->getInstructionSelector();
664 return InstSelector.get();
659665 }
660666
661667 const LegalizerInfo *getLegalizerInfo() const override {
662 assert(GISel && "Access to GlobalISel APIs not set");
663 return GISel->getLegalizerInfo();
668 return Legalizer.get();
664669 }
665670
666671 const RegisterBankInfo *getRegBankInfo() const override {
667 assert(GISel && "Access to GlobalISel APIs not set");
668 return GISel->getRegBankInfo();
672 return RegBankInfo.get();
669673 }
670674
671675 const SIRegisterInfo *getRegisterInfo() const override {
672676 return &InstrInfo.getRegisterInfo();
673 }
674
675 void setGISelAccessor(GISelAccessor &GISel) {
676 this->GISel.reset(&GISel);
677677 }
678678
679679 // XXX - Why is this here if it isn't in the default pass set?
2727 #include "llvm/ADT/StringRef.h"
2828 #include "llvm/ADT/Triple.h"
2929 #include "llvm/ADT/Twine.h"
30 #include "llvm/CodeGen/GlobalISel/GISelAccessor.h"
3130 #include "llvm/CodeGen/GlobalISel/IRTranslator.h"
3231 #include "llvm/CodeGen/GlobalISel/InstructionSelect.h"
3332 #include "llvm/CodeGen/GlobalISel/Legalizer.h"
9594
9695 return new ARMFrameLowering(STI);
9796 }
98
99 namespace {
100
101 struct ARMGISelActualAccessor : public GISelAccessor {
102 std::unique_ptr CallLoweringInfo;
103 std::unique_ptr InstSelector;
104 std::unique_ptr Legalizer;
105 std::unique_ptr RegBankInfo;
106
107 const CallLowering *getCallLowering() const override {
108 return CallLoweringInfo.get();
109 }
110
111 const InstructionSelector *getInstructionSelector() const override {
112 return InstSelector.get();
113 }
114
115 const LegalizerInfo *getLegalizerInfo() const override {
116 return Legalizer.get();
117 }
118
119 const RegisterBankInfo *getRegBankInfo() const override {
120 return RegBankInfo.get();
121 }
122 };
123
124 } // end anonymous namespace
12597
12698 ARMSubtarget::ARMSubtarget(const Triple &TT, const std::string &CPU,
12799 const std::string &FS,
140112 assert((isThumb() || hasARMOps()) &&
141113 "Target must either be thumb or support ARM operations!");
142114
143 ARMGISelActualAccessor *GISel = new ARMGISelActualAccessor();
144 GISel->CallLoweringInfo.reset(new ARMCallLowering(*getTargetLowering()));
145 GISel->Legalizer.reset(new ARMLegalizerInfo(*this));
115 CallLoweringInfo.reset(new ARMCallLowering(*getTargetLowering()));
116 Legalizer.reset(new ARMLegalizerInfo(*this));
146117
147118 auto *RBI = new ARMRegisterBankInfo(*getRegisterInfo());
148119
149120 // FIXME: At this point, we can't rely on Subtarget having RBI.
150121 // It's awkward to mix passing RBI and the Subtarget; should we pass
151122 // TII/TRI as well?
152 GISel->InstSelector.reset(createARMInstructionSelector(
123 InstSelector.reset(createARMInstructionSelector(
153124 *static_cast(&TM), *this, *RBI));
154125
155 GISel->RegBankInfo.reset(RBI);
156 setGISelAccessor(*GISel);
126 RegBankInfo.reset(RBI);
157127 }
158128
159129 const CallLowering *ARMSubtarget::getCallLowering() const {
160 assert(GISel && "Access to GlobalISel APIs not set");
161 return GISel->getCallLowering();
130 return CallLoweringInfo.get();
162131 }
163132
164133 const InstructionSelector *ARMSubtarget::getInstructionSelector() const {
165 assert(GISel && "Access to GlobalISel APIs not set");
166 return GISel->getInstructionSelector();
134 return InstSelector.get();
167135 }
168136
169137 const LegalizerInfo *ARMSubtarget::getLegalizerInfo() const {
170 assert(GISel && "Access to GlobalISel APIs not set");
171 return GISel->getLegalizerInfo();
138 return Legalizer.get();
172139 }
173140
174141 const RegisterBankInfo *ARMSubtarget::getRegBankInfo() const {
175 assert(GISel && "Access to GlobalISel APIs not set");
176 return GISel->getRegBankInfo();
142 return RegBankInfo.get();
177143 }
178144
179145 bool ARMSubtarget::isXRaySupported() const {
1919 #include "ARMISelLowering.h"
2020 #include "ARMSelectionDAGInfo.h"
2121 #include "llvm/ADT/Triple.h"
22 #include "llvm/CodeGen/GlobalISel/GISelAccessor.h"
22 #include "llvm/CodeGen/GlobalISel/CallLowering.h"
23 #include "llvm/CodeGen/GlobalISel/InstructionSelector.h"
24 #include "llvm/CodeGen/GlobalISel/LegalizerInfo.h"
25 #include "llvm/CodeGen/GlobalISel/RegisterBankInfo.h"
2326 #include "llvm/CodeGen/MachineFunction.h"
2427 #include "llvm/MC/MCInstrItineraries.h"
2528 #include "llvm/MC/MCSchedule.h"
418421 ARMSubtarget(const Triple &TT, const std::string &CPU, const std::string &FS,
419422 const ARMBaseTargetMachine &TM, bool IsLittle);
420423
421 /// This object will take onwership of \p GISelAccessor.
422 void setGISelAccessor(GISelAccessor &GISel) { this->GISel.reset(&GISel); }
423
424424 /// getMaxInlineSizeThreshold - Returns the maximum memset / memcpy size
425425 /// that still makes it profitable to inline the call.
426426 unsigned getMaxInlineSizeThreshold() const {
468468 std::unique_ptr InstrInfo;
469469 ARMTargetLowering TLInfo;
470470
471 /// Gather the accessor points to GlobalISel-related APIs.
472 /// This is used to avoid ifndefs spreading around while GISel is
473 /// an optional library.
474 std::unique_ptr GISel;
471 /// GlobalISel related APIs.
472 std::unique_ptr CallLoweringInfo;
473 std::unique_ptr InstSelector;
474 std::unique_ptr Legalizer;
475 std::unique_ptr RegBankInfo;
475476
476477 void initializeEnvironment();
477478 void initSubtargetFeatures(StringRef CPU, StringRef FS);
347347 return *this;
348348 }
349349
350 namespace {
351
352 struct X86GISelActualAccessor : public GISelAccessor {
353 std::unique_ptr CallLoweringInfo;
354 std::unique_ptr Legalizer;
355 std::unique_ptr RegBankInfo;
356 std::unique_ptr InstSelector;
357
358 const CallLowering *getCallLowering() const override {
359 return CallLoweringInfo.get();
360 }
361
362 const InstructionSelector *getInstructionSelector() const override {
363 return InstSelector.get();
364 }
365
366 const LegalizerInfo *getLegalizerInfo() const override {
367 return Legalizer.get();
368 }
369
370 const RegisterBankInfo *getRegBankInfo() const override {
371 return RegBankInfo.get();
372 }
373 };
374
375 } // end anonymous namespace
376
377350 X86Subtarget::X86Subtarget(const Triple &TT, StringRef CPU, StringRef FS,
378351 const X86TargetMachine &TM,
379352 unsigned StackAlignOverride)
398371 setPICStyle(PICStyles::StubPIC);
399372 else if (isTargetELF())
400373 setPICStyle(PICStyles::GOT);
401 X86GISelActualAccessor *GISel = new X86GISelActualAccessor();
402
403 GISel->CallLoweringInfo.reset(new X86CallLowering(*getTargetLowering()));
404 GISel->Legalizer.reset(new X86LegalizerInfo(*this, TM));
374
375 CallLoweringInfo.reset(new X86CallLowering(*getTargetLowering()));
376 Legalizer.reset(new X86LegalizerInfo(*this, TM));
405377
406378 auto *RBI = new X86RegisterBankInfo(*getRegisterInfo());
407 GISel->RegBankInfo.reset(RBI);
408 GISel->InstSelector.reset(createX86InstructionSelector(TM, *this, *RBI));
409 setGISelAccessor(*GISel);
379 RegBankInfo.reset(RBI);
380 InstSelector.reset(createX86InstructionSelector(TM, *this, *RBI));
410381 }
411382
412383 const CallLowering *X86Subtarget::getCallLowering() const {
413 assert(GISel && "Access to GlobalISel APIs not set");
414 return GISel->getCallLowering();
384 return CallLoweringInfo.get();
415385 }
416386
417387 const InstructionSelector *X86Subtarget::getInstructionSelector() const {
418 assert(GISel && "Access to GlobalISel APIs not set");
419 return GISel->getInstructionSelector();
388 return InstSelector.get();
420389 }
421390
422391 const LegalizerInfo *X86Subtarget::getLegalizerInfo() const {
423 assert(GISel && "Access to GlobalISel APIs not set");
424 return GISel->getLegalizerInfo();
392 return Legalizer.get();
425393 }
426394
427395 const RegisterBankInfo *X86Subtarget::getRegBankInfo() const {
428 assert(GISel && "Access to GlobalISel APIs not set");
429 return GISel->getRegBankInfo();
396 return RegBankInfo.get();
430397 }
431398
432399 bool X86Subtarget::enableEarlyIfConversion() const {
1919 #include "X86SelectionDAGInfo.h"
2020 #include "llvm/ADT/StringRef.h"
2121 #include "llvm/ADT/Triple.h"
22 #include "llvm/CodeGen/GlobalISel/GISelAccessor.h"
22 #include "llvm/CodeGen/GlobalISel/CallLowering.h"
23 #include "llvm/CodeGen/GlobalISel/InstructionSelector.h"
24 #include "llvm/CodeGen/GlobalISel/LegalizerInfo.h"
25 #include "llvm/CodeGen/GlobalISel/RegisterBankInfo.h"
2326 #include "llvm/IR/CallingConv.h"
2427 #include "llvm/MC/MCInstrItineraries.h"
2528 #include "llvm/Target/TargetMachine.h"
313316 /// Instruction itineraries for scheduling
314317 InstrItineraryData InstrItins;
315318
316 /// Gather the accessor points to GlobalISel-related APIs.
317 /// This is used to avoid ifndefs spreading around while GISel is
318 /// an optional library.
319 std::unique_ptr GISel;
319 /// GlobalISel related APIs.
320 std::unique_ptr CallLoweringInfo;
321 std::unique_ptr Legalizer;
322 std::unique_ptr RegBankInfo;
323 std::unique_ptr InstSelector;
320324
321325 private:
322326 /// Override the stack alignment.
344348 ///
345349 X86Subtarget(const Triple &TT, StringRef CPU, StringRef FS,
346350 const X86TargetMachine &TM, unsigned StackAlignOverride);
347
348 /// This object will take onwership of \p GISelAccessor.
349 void setGISelAccessor(GISelAccessor &GISel) { this->GISel.reset(&GISel); }
350351
351352 const X86TargetLowering *getTargetLowering() const override {
352353 return &TLInfo;