llvm.org GIT mirror llvm / d268a8d
[AMDGPU] Move GISel accessor initialization from TargetMachine to Subtarget. NFC git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@307186 91177308-0d34-0410-b5e6-96231b3b80d8 Quentin Colombet 2 years ago
2 changed file(s) with 50 addition(s) and 48 deletion(s). Raw diff Collapse all Expand all
1212 //===----------------------------------------------------------------------===//
1313
1414 #include "AMDGPUSubtarget.h"
15 #include "AMDGPU.h"
16 #include "AMDGPUTargetMachine.h"
17 #ifdef LLVM_BUILD_GLOBAL_ISEL
18 #include "AMDGPUCallLowering.h"
19 #include "AMDGPUInstructionSelector.h"
20 #include "AMDGPULegalizerInfo.h"
21 #include "AMDGPURegisterBankInfo.h"
22 #endif
1523 #include "SIMachineFunctionInfo.h"
1624 #include "llvm/ADT/SmallString.h"
1725 #include "llvm/CodeGen/MachineScheduler.h"
7078
7179 return *this;
7280 }
81
82 #ifdef LLVM_BUILD_GLOBAL_ISEL
83 namespace {
84
85 struct SIGISelActualAccessor : public GISelAccessor {
86 std::unique_ptr CallLoweringInfo;
87 std::unique_ptr InstSelector;
88 std::unique_ptr Legalizer;
89 std::unique_ptr RegBankInfo;
90 const AMDGPUCallLowering *getCallLowering() const override {
91 return CallLoweringInfo.get();
92 }
93 const InstructionSelector *getInstructionSelector() const override {
94 return InstSelector.get();
95 }
96 const LegalizerInfo *getLegalizerInfo() const override {
97 return Legalizer.get();
98 }
99 const RegisterBankInfo *getRegBankInfo() const override {
100 return RegBankInfo.get();
101 }
102 };
103
104 } // end anonymous namespace
105 #endif
73106
74107 AMDGPUSubtarget::AMDGPUSubtarget(const Triple &TT, StringRef GPU, StringRef FS,
75108 const TargetMachine &TM)
316349 TLInfo(TM, *this) {}
317350
318351 SISubtarget::SISubtarget(const Triple &TT, StringRef GPU, StringRef FS,
319 const TargetMachine &TM) :
320 AMDGPUSubtarget(TT, GPU, FS, TM),
321 InstrInfo(*this),
322 FrameLowering(TargetFrameLowering::StackGrowsUp, getStackAlignment(), 0),
323 TLInfo(TM, *this) {}
352 const TargetMachine &TM)
353 : AMDGPUSubtarget(TT, GPU, FS, TM), InstrInfo(*this),
354 FrameLowering(TargetFrameLowering::StackGrowsUp, getStackAlignment(), 0),
355 TLInfo(TM, *this) {
356 #ifndef LLVM_BUILD_GLOBAL_ISEL
357 GISelAccessor *GISel = new GISelAccessor();
358 #else
359 SIGISelActualAccessor *GISel = new SIGISelActualAccessor();
360 GISel->CallLoweringInfo.reset(new AMDGPUCallLowering(*getTargetLowering()));
361 GISel->Legalizer.reset(new AMDGPULegalizerInfo());
362
363 GISel->RegBankInfo.reset(new AMDGPURegisterBankInfo(*getRegisterInfo()));
364 GISel->InstSelector.reset(new AMDGPUInstructionSelector(
365 *this, *static_cast(GISel->RegBankInfo.get())));
366 #endif
367 setGISelAccessor(*GISel);
368 }
324369
325370 void SISubtarget::overrideSchedPolicy(MachineSchedPolicy &Policy,
326371 unsigned NumRegionInstrs) const {
1818 #include "AMDGPUCallLowering.h"
1919 #include "AMDGPUInstructionSelector.h"
2020 #include "AMDGPULegalizerInfo.h"
21 #ifdef LLVM_BUILD_GLOBAL_ISEL
22 #include "AMDGPURegisterBankInfo.h"
23 #endif
2421 #include "AMDGPUTargetObjectFile.h"
2522 #include "AMDGPUTargetTransformInfo.h"
2623 #include "GCNIterativeScheduler.h"
388385 // GCN Target Machine (SI+)
389386 //===----------------------------------------------------------------------===//
390387
391 #ifdef LLVM_BUILD_GLOBAL_ISEL
392 namespace {
393
394 struct SIGISelActualAccessor : public GISelAccessor {
395 std::unique_ptr CallLoweringInfo;
396 std::unique_ptr InstSelector;
397 std::unique_ptr Legalizer;
398 std::unique_ptr RegBankInfo;
399 const AMDGPUCallLowering *getCallLowering() const override {
400 return CallLoweringInfo.get();
401 }
402 const InstructionSelector *getInstructionSelector() const override {
403 return InstSelector.get();
404 }
405 const LegalizerInfo *getLegalizerInfo() const override {
406 return Legalizer.get();
407 }
408 const RegisterBankInfo *getRegBankInfo() const override {
409 return RegBankInfo.get();
410 }
411 };
412
413 } // end anonymous namespace
414 #endif
415
416388 GCNTargetMachine::GCNTargetMachine(const Target &T, const Triple &TT,
417389 StringRef CPU, StringRef FS,
418390 TargetOptions Options,
434406 // function that reside in TargetOptions.
435407 resetTargetOptions(F);
436408 I = llvm::make_unique(TargetTriple, GPU, FS, *this);
437
438 #ifndef LLVM_BUILD_GLOBAL_ISEL
439 GISelAccessor *GISel = new GISelAccessor();
440 #else
441 SIGISelActualAccessor *GISel = new SIGISelActualAccessor();
442 GISel->CallLoweringInfo.reset(
443 new AMDGPUCallLowering(*I->getTargetLowering()));
444 GISel->Legalizer.reset(new AMDGPULegalizerInfo());
445
446 GISel->RegBankInfo.reset(new AMDGPURegisterBankInfo(*I->getRegisterInfo()));
447 GISel->InstSelector.reset(new AMDGPUInstructionSelector(*I,
448 *static_cast(GISel->RegBankInfo.get())));
449 #endif
450
451 I->setGISelAccessor(*GISel);
452409 }
453410
454411 I->setScalarizeGlobalBehavior(ScalarizeGlobal);