1*e8d8bef9SDimitry Andric //=====-- R600Subtarget.h - Define Subtarget for AMDGPU R600 ----*- C++ -*-===// 2*e8d8bef9SDimitry Andric // 3*e8d8bef9SDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4*e8d8bef9SDimitry Andric // See https://llvm.org/LICENSE.txt for license information. 5*e8d8bef9SDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6*e8d8bef9SDimitry Andric // 7*e8d8bef9SDimitry Andric //==-----------------------------------------------------------------------===// 8*e8d8bef9SDimitry Andric // 9*e8d8bef9SDimitry Andric /// \file 10*e8d8bef9SDimitry Andric /// AMDGPU R600 specific subclass of TargetSubtarget. 11*e8d8bef9SDimitry Andric // 12*e8d8bef9SDimitry Andric //===----------------------------------------------------------------------===// 13*e8d8bef9SDimitry Andric 14*e8d8bef9SDimitry Andric #ifndef LLVM_LIB_TARGET_AMDGPU_R600SUBTARGET_H 15*e8d8bef9SDimitry Andric #define LLVM_LIB_TARGET_AMDGPU_R600SUBTARGET_H 16*e8d8bef9SDimitry Andric 17*e8d8bef9SDimitry Andric #include "AMDGPUSubtarget.h" 18*e8d8bef9SDimitry Andric #include "R600FrameLowering.h" 19*e8d8bef9SDimitry Andric #include "R600ISelLowering.h" 20*e8d8bef9SDimitry Andric #include "R600InstrInfo.h" 21*e8d8bef9SDimitry Andric #include "Utils/AMDGPUBaseInfo.h" 22*e8d8bef9SDimitry Andric #include "llvm/CodeGen/SelectionDAGTargetInfo.h" 23*e8d8bef9SDimitry Andric 24*e8d8bef9SDimitry Andric namespace llvm { 25*e8d8bef9SDimitry Andric 26*e8d8bef9SDimitry Andric class MCInst; 27*e8d8bef9SDimitry Andric class MCInstrInfo; 28*e8d8bef9SDimitry Andric 29*e8d8bef9SDimitry Andric } // namespace llvm 30*e8d8bef9SDimitry Andric 31*e8d8bef9SDimitry Andric #define GET_SUBTARGETINFO_HEADER 32*e8d8bef9SDimitry Andric #include "R600GenSubtargetInfo.inc" 33*e8d8bef9SDimitry Andric 34*e8d8bef9SDimitry Andric namespace llvm { 35*e8d8bef9SDimitry Andric 36*e8d8bef9SDimitry Andric class R600Subtarget final : public R600GenSubtargetInfo, 37*e8d8bef9SDimitry Andric public AMDGPUSubtarget { 38*e8d8bef9SDimitry Andric private: 39*e8d8bef9SDimitry Andric R600InstrInfo InstrInfo; 40*e8d8bef9SDimitry Andric R600FrameLowering FrameLowering; 41*e8d8bef9SDimitry Andric bool FMA; 42*e8d8bef9SDimitry Andric bool CaymanISA; 43*e8d8bef9SDimitry Andric bool CFALUBug; 44*e8d8bef9SDimitry Andric bool HasVertexCache; 45*e8d8bef9SDimitry Andric bool R600ALUInst; 46*e8d8bef9SDimitry Andric bool FP64; 47*e8d8bef9SDimitry Andric short TexVTXClauseSize; 48*e8d8bef9SDimitry Andric Generation Gen; 49*e8d8bef9SDimitry Andric R600TargetLowering TLInfo; 50*e8d8bef9SDimitry Andric InstrItineraryData InstrItins; 51*e8d8bef9SDimitry Andric SelectionDAGTargetInfo TSInfo; 52*e8d8bef9SDimitry Andric 53*e8d8bef9SDimitry Andric public: 54*e8d8bef9SDimitry Andric R600Subtarget(const Triple &TT, StringRef CPU, StringRef FS, 55*e8d8bef9SDimitry Andric const TargetMachine &TM); 56*e8d8bef9SDimitry Andric 57*e8d8bef9SDimitry Andric const R600InstrInfo *getInstrInfo() const override { return &InstrInfo; } 58*e8d8bef9SDimitry Andric 59*e8d8bef9SDimitry Andric const R600FrameLowering *getFrameLowering() const override { 60*e8d8bef9SDimitry Andric return &FrameLowering; 61*e8d8bef9SDimitry Andric } 62*e8d8bef9SDimitry Andric 63*e8d8bef9SDimitry Andric const R600TargetLowering *getTargetLowering() const override { 64*e8d8bef9SDimitry Andric return &TLInfo; 65*e8d8bef9SDimitry Andric } 66*e8d8bef9SDimitry Andric 67*e8d8bef9SDimitry Andric const R600RegisterInfo *getRegisterInfo() const override { 68*e8d8bef9SDimitry Andric return &InstrInfo.getRegisterInfo(); 69*e8d8bef9SDimitry Andric } 70*e8d8bef9SDimitry Andric 71*e8d8bef9SDimitry Andric const InstrItineraryData *getInstrItineraryData() const override { 72*e8d8bef9SDimitry Andric return &InstrItins; 73*e8d8bef9SDimitry Andric } 74*e8d8bef9SDimitry Andric 75*e8d8bef9SDimitry Andric // Nothing implemented, just prevent crashes on use. 76*e8d8bef9SDimitry Andric const SelectionDAGTargetInfo *getSelectionDAGInfo() const override { 77*e8d8bef9SDimitry Andric return &TSInfo; 78*e8d8bef9SDimitry Andric } 79*e8d8bef9SDimitry Andric 80*e8d8bef9SDimitry Andric void ParseSubtargetFeatures(StringRef CPU, StringRef TuneCPU, StringRef FS); 81*e8d8bef9SDimitry Andric 82*e8d8bef9SDimitry Andric Generation getGeneration() const { 83*e8d8bef9SDimitry Andric return Gen; 84*e8d8bef9SDimitry Andric } 85*e8d8bef9SDimitry Andric 86*e8d8bef9SDimitry Andric Align getStackAlignment() const { return Align(4); } 87*e8d8bef9SDimitry Andric 88*e8d8bef9SDimitry Andric R600Subtarget &initializeSubtargetDependencies(const Triple &TT, 89*e8d8bef9SDimitry Andric StringRef GPU, StringRef FS); 90*e8d8bef9SDimitry Andric 91*e8d8bef9SDimitry Andric bool hasBFE() const { 92*e8d8bef9SDimitry Andric return (getGeneration() >= EVERGREEN); 93*e8d8bef9SDimitry Andric } 94*e8d8bef9SDimitry Andric 95*e8d8bef9SDimitry Andric bool hasBFI() const { 96*e8d8bef9SDimitry Andric return (getGeneration() >= EVERGREEN); 97*e8d8bef9SDimitry Andric } 98*e8d8bef9SDimitry Andric 99*e8d8bef9SDimitry Andric bool hasBCNT(unsigned Size) const { 100*e8d8bef9SDimitry Andric if (Size == 32) 101*e8d8bef9SDimitry Andric return (getGeneration() >= EVERGREEN); 102*e8d8bef9SDimitry Andric 103*e8d8bef9SDimitry Andric return false; 104*e8d8bef9SDimitry Andric } 105*e8d8bef9SDimitry Andric 106*e8d8bef9SDimitry Andric bool hasBORROW() const { 107*e8d8bef9SDimitry Andric return (getGeneration() >= EVERGREEN); 108*e8d8bef9SDimitry Andric } 109*e8d8bef9SDimitry Andric 110*e8d8bef9SDimitry Andric bool hasCARRY() const { 111*e8d8bef9SDimitry Andric return (getGeneration() >= EVERGREEN); 112*e8d8bef9SDimitry Andric } 113*e8d8bef9SDimitry Andric 114*e8d8bef9SDimitry Andric bool hasCaymanISA() const { 115*e8d8bef9SDimitry Andric return CaymanISA; 116*e8d8bef9SDimitry Andric } 117*e8d8bef9SDimitry Andric 118*e8d8bef9SDimitry Andric bool hasFFBL() const { 119*e8d8bef9SDimitry Andric return (getGeneration() >= EVERGREEN); 120*e8d8bef9SDimitry Andric } 121*e8d8bef9SDimitry Andric 122*e8d8bef9SDimitry Andric bool hasFFBH() const { 123*e8d8bef9SDimitry Andric return (getGeneration() >= EVERGREEN); 124*e8d8bef9SDimitry Andric } 125*e8d8bef9SDimitry Andric 126*e8d8bef9SDimitry Andric bool hasFMA() const { return FMA; } 127*e8d8bef9SDimitry Andric 128*e8d8bef9SDimitry Andric bool hasCFAluBug() const { return CFALUBug; } 129*e8d8bef9SDimitry Andric 130*e8d8bef9SDimitry Andric bool hasVertexCache() const { return HasVertexCache; } 131*e8d8bef9SDimitry Andric 132*e8d8bef9SDimitry Andric short getTexVTXClauseSize() const { return TexVTXClauseSize; } 133*e8d8bef9SDimitry Andric 134*e8d8bef9SDimitry Andric bool enableMachineScheduler() const override { 135*e8d8bef9SDimitry Andric return true; 136*e8d8bef9SDimitry Andric } 137*e8d8bef9SDimitry Andric 138*e8d8bef9SDimitry Andric bool enableSubRegLiveness() const override { 139*e8d8bef9SDimitry Andric return true; 140*e8d8bef9SDimitry Andric } 141*e8d8bef9SDimitry Andric 142*e8d8bef9SDimitry Andric /// \returns Maximum number of work groups per compute unit supported by the 143*e8d8bef9SDimitry Andric /// subtarget and limited by given \p FlatWorkGroupSize. 144*e8d8bef9SDimitry Andric unsigned getMaxWorkGroupsPerCU(unsigned FlatWorkGroupSize) const override { 145*e8d8bef9SDimitry Andric return AMDGPU::IsaInfo::getMaxWorkGroupsPerCU(this, FlatWorkGroupSize); 146*e8d8bef9SDimitry Andric } 147*e8d8bef9SDimitry Andric 148*e8d8bef9SDimitry Andric /// \returns Minimum flat work group size supported by the subtarget. 149*e8d8bef9SDimitry Andric unsigned getMinFlatWorkGroupSize() const override { 150*e8d8bef9SDimitry Andric return AMDGPU::IsaInfo::getMinFlatWorkGroupSize(this); 151*e8d8bef9SDimitry Andric } 152*e8d8bef9SDimitry Andric 153*e8d8bef9SDimitry Andric /// \returns Maximum flat work group size supported by the subtarget. 154*e8d8bef9SDimitry Andric unsigned getMaxFlatWorkGroupSize() const override { 155*e8d8bef9SDimitry Andric return AMDGPU::IsaInfo::getMaxFlatWorkGroupSize(this); 156*e8d8bef9SDimitry Andric } 157*e8d8bef9SDimitry Andric 158*e8d8bef9SDimitry Andric /// \returns Number of waves per execution unit required to support the given 159*e8d8bef9SDimitry Andric /// \p FlatWorkGroupSize. 160*e8d8bef9SDimitry Andric unsigned 161*e8d8bef9SDimitry Andric getWavesPerEUForWorkGroup(unsigned FlatWorkGroupSize) const override { 162*e8d8bef9SDimitry Andric return AMDGPU::IsaInfo::getWavesPerEUForWorkGroup(this, FlatWorkGroupSize); 163*e8d8bef9SDimitry Andric } 164*e8d8bef9SDimitry Andric 165*e8d8bef9SDimitry Andric /// \returns Minimum number of waves per execution unit supported by the 166*e8d8bef9SDimitry Andric /// subtarget. 167*e8d8bef9SDimitry Andric unsigned getMinWavesPerEU() const override { 168*e8d8bef9SDimitry Andric return AMDGPU::IsaInfo::getMinWavesPerEU(this); 169*e8d8bef9SDimitry Andric } 170*e8d8bef9SDimitry Andric }; 171*e8d8bef9SDimitry Andric 172*e8d8bef9SDimitry Andric } // end namespace llvm 173*e8d8bef9SDimitry Andric 174*e8d8bef9SDimitry Andric #endif // LLVM_LIB_TARGET_AMDGPU_R600SUBTARGET_H 175