LLVM  15.0.0git
SPIRVSubtarget.h
Go to the documentation of this file.
1 //===-- SPIRVSubtarget.h - SPIR-V Subtarget Information --------*- C++ -*--===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This file declares the SPIR-V specific subclass of TargetSubtargetInfo.
10 //
11 //===----------------------------------------------------------------------===//
12 
13 #ifndef LLVM_LIB_TARGET_SPIRV_SPIRVSUBTARGET_H
14 #define LLVM_LIB_TARGET_SPIRV_SPIRVSUBTARGET_H
15 
16 #include "SPIRVCallLowering.h"
17 #include "SPIRVFrameLowering.h"
18 #include "SPIRVISelLowering.h"
19 #include "SPIRVInstrInfo.h"
25 #include "llvm/IR/DataLayout.h"
27 
28 #define GET_SUBTARGETINFO_HEADER
29 #include "SPIRVGenSubtargetInfo.inc"
30 
31 namespace llvm {
32 class StringRef;
33 class SPIRVGlobalRegistry;
34 class SPIRVTargetMachine;
35 
37 private:
38  const unsigned PointerSize;
39  uint32_t SPIRVVersion;
40 
41  std::unique_ptr<SPIRVGlobalRegistry> GR;
42 
43  SPIRVInstrInfo InstrInfo;
44  SPIRVFrameLowering FrameLowering;
45  SPIRVTargetLowering TLInfo;
46 
47  // GlobalISel related APIs.
48  std::unique_ptr<CallLowering> CallLoweringInfo;
49  std::unique_ptr<RegisterBankInfo> RegBankInfo;
50  std::unique_ptr<LegalizerInfo> Legalizer;
51  std::unique_ptr<InstructionSelector> InstSelector;
52 
53 public:
54  // This constructor initializes the data members to match that
55  // of the specified triple.
56  SPIRVSubtarget(const Triple &TT, const std::string &CPU,
57  const std::string &FS, const SPIRVTargetMachine &TM);
59 
60  // Parses features string setting specified subtarget options.
61  // The definition of this function is auto generated by tblgen.
63  unsigned getPointerSize() const { return PointerSize; }
64  bool canDirectlyComparePointers() const;
65  uint32_t getSPIRVVersion() const { return SPIRVVersion; };
66  SPIRVGlobalRegistry *getSPIRVGlobalRegistry() const { return GR.get(); }
67 
68  const CallLowering *getCallLowering() const override {
69  return CallLoweringInfo.get();
70  }
71  const RegisterBankInfo *getRegBankInfo() const override {
72  return RegBankInfo.get();
73  }
74  const LegalizerInfo *getLegalizerInfo() const override {
75  return Legalizer.get();
76  }
78  return InstSelector.get();
79  }
80  const SPIRVInstrInfo *getInstrInfo() const override { return &InstrInfo; }
81  const SPIRVFrameLowering *getFrameLowering() const override {
82  return &FrameLowering;
83  }
84  const SPIRVTargetLowering *getTargetLowering() const override {
85  return &TLInfo;
86  }
87  const SPIRVRegisterInfo *getRegisterInfo() const override {
88  return &InstrInfo.getRegisterInfo();
89  }
90 };
91 } // namespace llvm
92 
93 #endif // LLVM_LIB_TARGET_SPIRV_SPIRVSUBTARGET_H
llvm::SPIRVSubtarget::getLegalizerInfo
const LegalizerInfo * getLegalizerInfo() const override
Definition: SPIRVSubtarget.h:74
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:17
llvm::SPIRVSubtarget::canDirectlyComparePointers
bool canDirectlyComparePointers() const
Definition: SPIRVSubtarget.cpp:66
SPIRVCallLowering.h
CallLowering.h
llvm::SPIRVFrameLowering
Definition: SPIRVFrameLowering.h:26
llvm::SPIRVSubtarget::getInstructionSelector
InstructionSelector * getInstructionSelector() const override
Definition: SPIRVSubtarget.h:77
llvm::Triple
Triple - Helper class for working with autoconf configuration names.
Definition: Triple.h:44
llvm::SPIRVSubtarget::initSubtargetDependencies
SPIRVSubtarget & initSubtargetDependencies(StringRef CPU, StringRef FS)
Definition: SPIRVSubtarget.cpp:57
llvm::SPIRVSubtarget
Definition: SPIRVSubtarget.h:36
llvm::SPIRVSubtarget::getCallLowering
const CallLowering * getCallLowering() const override
Definition: SPIRVSubtarget.h:68
LegalizerInfo.h
SPIRVGenSubtargetInfo
llvm::SPIRVInstrInfo::getRegisterInfo
const SPIRVRegisterInfo & getRegisterInfo() const
Definition: SPIRVInstrInfo.h:30
TargetMachine.h
llvm::SPIRVSubtarget::getInstrInfo
const SPIRVInstrInfo * getInstrInfo() const override
Definition: SPIRVSubtarget.h:80
llvm::Legalizer
Definition: Legalizer.h:36
llvm::SPIRVSubtarget::ParseSubtargetFeatures
void ParseSubtargetFeatures(StringRef CPU, StringRef TuneCPU, StringRef FS)
llvm::SPIRVSubtarget::getSPIRVVersion
uint32_t getSPIRVVersion() const
Definition: SPIRVSubtarget.h:65
SPIRVFrameLowering.h
llvm::SPIRVSubtarget::getRegBankInfo
const RegisterBankInfo * getRegBankInfo() const override
Definition: SPIRVSubtarget.h:71
InstructionSelector.h
SPIRVInstrInfo.h
llvm::SPIRVRegisterInfo
Definition: SPIRVRegisterInfo.h:23
llvm::RegisterBankInfo
Holds all the information related to register banks.
Definition: RegisterBankInfo.h:39
llvm::InstructionSelector
Provides the logic to select generic machine instructions.
Definition: InstructionSelector.h:428
llvm::SPIRVSubtarget::getPointerSize
unsigned getPointerSize() const
Definition: SPIRVSubtarget.h:63
llvm::SPIRVSubtarget::SPIRVSubtarget
SPIRVSubtarget(const Triple &TT, const std::string &CPU, const std::string &FS, const SPIRVTargetMachine &TM)
Definition: SPIRVSubtarget.cpp:42
SPIRVISelLowering.h
llvm::X86AS::FS
@ FS
Definition: X86.h:196
llvm::SPIRVTargetLowering
Definition: SPIRVISelLowering.h:22
llvm::SPIRVGlobalRegistry
Definition: SPIRVGlobalRegistry.h:27
llvm::SPIRVInstrInfo
Definition: SPIRVInstrInfo.h:24
DataLayout.h
llvm::StringRef
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:58
uint32_t
TargetSubtargetInfo.h
llvm::SPIRVSubtarget::getFrameLowering
const SPIRVFrameLowering * getFrameLowering() const override
Definition: SPIRVSubtarget.h:81
llvm::SPIRVTargetMachine
Definition: SPIRVTargetMachine.h:20
SelectionDAGTargetInfo.h
llvm::SPIRVSubtarget::getSPIRVGlobalRegistry
SPIRVGlobalRegistry * getSPIRVGlobalRegistry() const
Definition: SPIRVSubtarget.h:66
llvm::LegalizerInfo
Definition: LegalizerInfo.h:1180
TM
const char LLVMTargetMachineRef TM
Definition: PassBuilderBindings.cpp:47
llvm::SPIRVSubtarget::getTargetLowering
const SPIRVTargetLowering * getTargetLowering() const override
Definition: SPIRVSubtarget.h:84
llvm::CallLowering
Definition: CallLowering.h:44
llvm::SPIRVSubtarget::getRegisterInfo
const SPIRVRegisterInfo * getRegisterInfo() const override
Definition: SPIRVSubtarget.h:87