LLVM 17.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
31namespace llvm {
32class StringRef;
33class SPIRVTargetMachine;
34
36private:
37 const unsigned PointerSize;
38 uint32_t SPIRVVersion;
39 uint32_t OpenCLVersion;
40
43 std::unique_ptr<SPIRVGlobalRegistry> GR;
44
45 SPIRVInstrInfo InstrInfo;
46 SPIRVFrameLowering FrameLowering;
48
49 // GlobalISel related APIs.
50 std::unique_ptr<CallLowering> CallLoweringInfo;
51 std::unique_ptr<RegisterBankInfo> RegBankInfo;
52 std::unique_ptr<LegalizerInfo> Legalizer;
53 std::unique_ptr<InstructionSelector> InstSelector;
54
55 // TODO: Initialise the available extensions, extended instruction sets
56 // based on the environment settings.
57 void initAvailableExtensions();
58 void initAvailableExtInstSets();
59
60public:
61 // This constructor initializes the data members to match that
62 // of the specified triple.
63 SPIRVSubtarget(const Triple &TT, const std::string &CPU,
64 const std::string &FS, const SPIRVTargetMachine &TM);
66
67 // Parses features string setting specified subtarget options.
68 // The definition of this function is auto generated by tblgen.
70 unsigned getPointerSize() const { return PointerSize; }
71 bool canDirectlyComparePointers() const;
72 // TODO: this environment is not implemented in Triple, we need to decide
73 // how to standartize its support. For now, let's assume that we always
74 // operate with OpenCL.
75 bool isOpenCLEnv() const { return true; }
76 uint32_t getSPIRVVersion() const { return SPIRVVersion; };
77 bool isAtLeastSPIRVVer(uint32_t VerToCompareTo) const;
78 bool isAtLeastOpenCLVer(uint32_t VerToCompareTo) const;
79 // TODO: implement command line args or other ways to determine this.
80 bool hasOpenCLFullProfile() const { return true; }
81 bool hasOpenCLImageSupport() const { return true; }
82 bool canUseExtension(SPIRV::Extension::Extension E) const;
83 bool canUseExtInstSet(SPIRV::InstructionSet::InstructionSet E) const;
84
85 SPIRVGlobalRegistry *getSPIRVGlobalRegistry() const { return GR.get(); }
86
87 const CallLowering *getCallLowering() const override {
88 return CallLoweringInfo.get();
89 }
90 const RegisterBankInfo *getRegBankInfo() const override {
91 return RegBankInfo.get();
92 }
93 const LegalizerInfo *getLegalizerInfo() const override {
94 return Legalizer.get();
95 }
97 return InstSelector.get();
98 }
99 const SPIRVInstrInfo *getInstrInfo() const override { return &InstrInfo; }
100 const SPIRVFrameLowering *getFrameLowering() const override {
101 return &FrameLowering;
102 }
103 const SPIRVTargetLowering *getTargetLowering() const override {
104 return &TLInfo;
105 }
106 const SPIRVRegisterInfo *getRegisterInfo() const override {
107 return &InstrInfo.getRegisterInfo();
108 }
109};
110} // namespace llvm
111
112#endif // LLVM_LIB_TARGET_SPIRV_SPIRVSUBTARGET_H
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
This file describes how to lower LLVM calls to machine code calls.
Interface for Targets to specify which operations they can successfully select and how the others sho...
const char LLVMTargetMachineRef TM
return InstrInfo
Provides the logic to select generic machine instructions.
Holds all the information related to register banks.
unsigned getPointerSize() const
bool hasOpenCLImageSupport() const
SPIRVSubtarget & initSubtargetDependencies(StringRef CPU, StringRef FS)
bool isAtLeastOpenCLVer(uint32_t VerToCompareTo) const
InstructionSelector * getInstructionSelector() const override
const LegalizerInfo * getLegalizerInfo() const override
bool canDirectlyComparePointers() const
const SPIRVInstrInfo * getInstrInfo() const override
SPIRVGlobalRegistry * getSPIRVGlobalRegistry() const
bool isAtLeastSPIRVVer(uint32_t VerToCompareTo) const
const SPIRVRegisterInfo * getRegisterInfo() const override
bool isOpenCLEnv() const
const SPIRVTargetLowering * getTargetLowering() const override
void ParseSubtargetFeatures(StringRef CPU, StringRef TuneCPU, StringRef FS)
bool canUseExtInstSet(SPIRV::InstructionSet::InstructionSet E) const
uint32_t getSPIRVVersion() const
const RegisterBankInfo * getRegBankInfo() const override
const CallLowering * getCallLowering() const override
bool hasOpenCLFullProfile() const
bool canUseExtension(SPIRV::Extension::Extension E) const
const SPIRVFrameLowering * getFrameLowering() const override
SmallSet - This maintains a set of unique values, optimizing for the case when the set is small (less...
Definition: SmallSet.h:135
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:50
Triple - Helper class for working with autoconf configuration names.
Definition: Triple.h:44
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18