2015-11-07 02:17:45 +08:00
|
|
|
//=====-- AMDGPUSubtarget.h - Define Subtarget for AMDGPU ------*- C++ -*-====//
|
2012-12-12 05:25:42 +08:00
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//==-----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
/// \file
|
|
|
|
/// \brief AMDGPU specific subclass of TargetSubtarget.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2015-11-07 02:17:45 +08:00
|
|
|
#ifndef LLVM_LIB_TARGET_AMDGPU_AMDGPUSUBTARGET_H
|
|
|
|
#define LLVM_LIB_TARGET_AMDGPU_AMDGPUSUBTARGET_H
|
2015-11-07 02:23:00 +08:00
|
|
|
|
2013-06-08 04:37:48 +08:00
|
|
|
#include "AMDGPU.h"
|
2016-06-24 14:30:11 +08:00
|
|
|
#include "R600InstrInfo.h"
|
|
|
|
#include "R600ISelLowering.h"
|
|
|
|
#include "R600FrameLowering.h"
|
|
|
|
#include "SIInstrInfo.h"
|
|
|
|
#include "SIISelLowering.h"
|
|
|
|
#include "SIFrameLowering.h"
|
2015-06-27 05:15:07 +08:00
|
|
|
#include "Utils/AMDGPUBaseInfo.h"
|
2016-04-15 03:09:28 +08:00
|
|
|
#include "llvm/CodeGen/GlobalISel/GISelAccessor.h"
|
2016-08-12 01:31:42 +08:00
|
|
|
#include "llvm/CodeGen/SelectionDAGTargetInfo.h"
|
2012-12-12 05:25:42 +08:00
|
|
|
#include "llvm/Target/TargetSubtargetInfo.h"
|
|
|
|
|
|
|
|
#define GET_SUBTARGETINFO_HEADER
|
|
|
|
#include "AMDGPUGenSubtargetInfo.inc"
|
|
|
|
|
|
|
|
namespace llvm {
|
|
|
|
|
2015-01-21 03:33:04 +08:00
|
|
|
class SIMachineFunctionInfo;
|
2016-06-24 14:30:11 +08:00
|
|
|
class StringRef;
|
2015-01-21 03:33:04 +08:00
|
|
|
|
2012-12-12 05:25:42 +08:00
|
|
|
class AMDGPUSubtarget : public AMDGPUGenSubtargetInfo {
|
2013-06-08 04:37:48 +08:00
|
|
|
public:
|
|
|
|
enum Generation {
|
|
|
|
R600 = 0,
|
|
|
|
R700,
|
|
|
|
EVERGREEN,
|
|
|
|
NORTHERN_ISLANDS,
|
2013-10-30 00:37:28 +08:00
|
|
|
SOUTHERN_ISLANDS,
|
2014-12-07 20:18:57 +08:00
|
|
|
SEA_ISLANDS,
|
|
|
|
VOLCANIC_ISLANDS,
|
2013-06-08 04:37:48 +08:00
|
|
|
};
|
|
|
|
|
2015-06-27 05:15:07 +08:00
|
|
|
enum {
|
|
|
|
ISAVersion0_0_0,
|
|
|
|
ISAVersion7_0_0,
|
|
|
|
ISAVersion7_0_1,
|
2016-10-27 00:37:56 +08:00
|
|
|
ISAVersion7_0_2,
|
2015-06-27 05:15:07 +08:00
|
|
|
ISAVersion8_0_0,
|
2016-01-14 04:39:25 +08:00
|
|
|
ISAVersion8_0_1,
|
2016-10-12 00:00:47 +08:00
|
|
|
ISAVersion8_0_2,
|
2016-10-27 00:37:56 +08:00
|
|
|
ISAVersion8_0_3,
|
|
|
|
ISAVersion8_0_4,
|
|
|
|
ISAVersion8_1_0,
|
2015-06-27 05:15:07 +08:00
|
|
|
};
|
|
|
|
|
2016-06-24 14:30:11 +08:00
|
|
|
protected:
|
|
|
|
// Basic subtarget description.
|
|
|
|
Triple TargetTriple;
|
2014-06-28 01:57:00 +08:00
|
|
|
Generation Gen;
|
2016-06-24 14:30:11 +08:00
|
|
|
unsigned IsaVersion;
|
|
|
|
unsigned WavefrontSize;
|
|
|
|
int LocalMemorySize;
|
|
|
|
int LDSBankCount;
|
|
|
|
unsigned MaxPrivateElementSize;
|
|
|
|
|
|
|
|
// Possibly statically set by tablegen, but may want to be overridden.
|
2015-01-30 03:34:25 +08:00
|
|
|
bool FastFMAF32;
|
2016-01-19 05:13:50 +08:00
|
|
|
bool HalfRate64Ops;
|
2016-06-24 14:30:11 +08:00
|
|
|
|
|
|
|
// Dynamially set bits that enable features.
|
2016-11-13 15:01:11 +08:00
|
|
|
bool FP16Denormals;
|
2016-06-24 14:30:11 +08:00
|
|
|
bool FP32Denormals;
|
|
|
|
bool FP64Denormals;
|
|
|
|
bool FPExceptions;
|
2015-12-23 04:55:23 +08:00
|
|
|
bool FlatForGlobal;
|
2016-10-15 02:10:39 +08:00
|
|
|
bool UnalignedScratchAccess;
|
2016-07-02 07:03:44 +08:00
|
|
|
bool UnalignedBufferAccess;
|
2016-06-24 14:30:11 +08:00
|
|
|
bool EnableXNACK;
|
|
|
|
bool DebuggerInsertNops;
|
|
|
|
bool DebuggerReserveRegs;
|
2016-06-25 11:11:28 +08:00
|
|
|
bool DebuggerEmitPrologue;
|
2016-06-24 14:30:11 +08:00
|
|
|
|
|
|
|
// Used as options.
|
|
|
|
bool EnableVGPRSpilling;
|
2014-07-13 10:08:26 +08:00
|
|
|
bool EnablePromoteAlloca;
|
2014-10-11 06:01:59 +08:00
|
|
|
bool EnableLoadStoreOpt;
|
2015-07-07 00:01:58 +08:00
|
|
|
bool EnableUnsafeDSOffsetFolding;
|
2016-06-24 14:30:11 +08:00
|
|
|
bool EnableSIScheduler;
|
|
|
|
bool DumpCode;
|
|
|
|
|
|
|
|
// Subtarget statically properties set by tablegen
|
|
|
|
bool FP64;
|
2015-04-08 09:09:26 +08:00
|
|
|
bool IsGCN;
|
|
|
|
bool GCN1Encoding;
|
|
|
|
bool GCN3Encoding;
|
2015-04-24 03:33:54 +08:00
|
|
|
bool CIInsts;
|
2016-06-24 14:30:11 +08:00
|
|
|
bool SGPRInitBug;
|
2016-02-27 16:53:55 +08:00
|
|
|
bool HasSMemRealTime;
|
|
|
|
bool Has16BitInsts;
|
2016-10-13 02:00:51 +08:00
|
|
|
bool HasMovrel;
|
|
|
|
bool HasVGPRIndexMode;
|
2016-10-29 05:55:15 +08:00
|
|
|
bool HasScalarStores;
|
2016-10-29 12:05:06 +08:00
|
|
|
bool HasInv2PiInlineImm;
|
2016-06-24 14:30:11 +08:00
|
|
|
bool FlatAddressSpace;
|
|
|
|
bool R600ALUInst;
|
|
|
|
bool CaymanISA;
|
|
|
|
bool CFALUBug;
|
|
|
|
bool HasVertexCache;
|
|
|
|
short TexVTXClauseSize;
|
|
|
|
|
|
|
|
// Dummy feature to use for assembler in tablegen.
|
2015-04-24 03:33:54 +08:00
|
|
|
bool FeatureDisable;
|
2012-12-12 05:25:42 +08:00
|
|
|
|
|
|
|
InstrItineraryData InstrItins;
|
2016-08-12 01:31:42 +08:00
|
|
|
SelectionDAGTargetInfo TSInfo;
|
2012-12-12 05:25:42 +08:00
|
|
|
|
|
|
|
public:
|
2016-06-24 14:30:11 +08:00
|
|
|
AMDGPUSubtarget(const Triple &TT, StringRef GPU, StringRef FS,
|
|
|
|
const TargetMachine &TM);
|
|
|
|
virtual ~AMDGPUSubtarget();
|
2015-06-10 20:11:26 +08:00
|
|
|
AMDGPUSubtarget &initializeSubtargetDependencies(const Triple &TT,
|
|
|
|
StringRef GPU, StringRef FS);
|
2014-06-28 01:57:00 +08:00
|
|
|
|
2016-07-23 01:01:25 +08:00
|
|
|
const AMDGPUInstrInfo *getInstrInfo() const override = 0;
|
|
|
|
const AMDGPUFrameLowering *getFrameLowering() const override = 0;
|
|
|
|
const AMDGPUTargetLowering *getTargetLowering() const override = 0;
|
|
|
|
const AMDGPURegisterInfo *getRegisterInfo() const override = 0;
|
2016-04-15 03:09:28 +08:00
|
|
|
|
2014-08-05 05:25:23 +08:00
|
|
|
const InstrItineraryData *getInstrItineraryData() const override {
|
|
|
|
return &InstrItins;
|
|
|
|
}
|
2014-06-28 01:57:00 +08:00
|
|
|
|
2016-08-12 01:31:42 +08:00
|
|
|
// Nothing implemented, just prevent crashes on use.
|
|
|
|
const SelectionDAGTargetInfo *getSelectionDAGInfo() const override {
|
|
|
|
return &TSInfo;
|
|
|
|
}
|
|
|
|
|
2014-04-30 13:53:27 +08:00
|
|
|
void ParseSubtargetFeatures(StringRef CPU, StringRef FS);
|
2012-12-12 05:25:42 +08:00
|
|
|
|
2016-06-24 14:30:11 +08:00
|
|
|
bool isAmdHsaOS() const {
|
|
|
|
return TargetTriple.getOS() == Triple::AMDHSA;
|
2014-06-28 01:57:00 +08:00
|
|
|
}
|
|
|
|
|
2016-09-17 05:34:26 +08:00
|
|
|
bool isMesa3DOS() const {
|
|
|
|
return TargetTriple.getOS() == Triple::Mesa3D;
|
|
|
|
}
|
|
|
|
|
2016-09-23 09:33:26 +08:00
|
|
|
bool isOpenCLEnv() const {
|
|
|
|
return TargetTriple.getEnvironment() == Triple::OpenCL;
|
|
|
|
}
|
|
|
|
|
2014-06-28 01:57:00 +08:00
|
|
|
Generation getGeneration() const {
|
|
|
|
return Gen;
|
|
|
|
}
|
|
|
|
|
2016-06-24 14:30:11 +08:00
|
|
|
unsigned getWavefrontSize() const {
|
|
|
|
return WavefrontSize;
|
2014-06-28 01:57:00 +08:00
|
|
|
}
|
|
|
|
|
2016-06-24 14:30:11 +08:00
|
|
|
int getLocalMemorySize() const {
|
|
|
|
return LocalMemorySize;
|
2014-06-28 01:57:00 +08:00
|
|
|
}
|
2014-03-18 02:58:11 +08:00
|
|
|
|
2016-06-24 14:30:11 +08:00
|
|
|
int getLDSBankCount() const {
|
|
|
|
return LDSBankCount;
|
2014-07-15 07:40:49 +08:00
|
|
|
}
|
|
|
|
|
2016-06-24 14:30:11 +08:00
|
|
|
unsigned getMaxPrivateElementSize() const {
|
|
|
|
return MaxPrivateElementSize;
|
2014-07-15 07:40:49 +08:00
|
|
|
}
|
|
|
|
|
2016-11-02 01:49:33 +08:00
|
|
|
bool has16BitInsts() const {
|
|
|
|
return Has16BitInsts;
|
|
|
|
}
|
|
|
|
|
2016-06-24 14:30:11 +08:00
|
|
|
bool hasHWFP64() const {
|
|
|
|
return FP64;
|
2016-01-29 04:53:42 +08:00
|
|
|
}
|
|
|
|
|
2015-01-30 03:34:25 +08:00
|
|
|
bool hasFastFMAF32() const {
|
|
|
|
return FastFMAF32;
|
|
|
|
}
|
|
|
|
|
2016-01-19 05:13:50 +08:00
|
|
|
bool hasHalfRate64Ops() const {
|
|
|
|
return HalfRate64Ops;
|
|
|
|
}
|
|
|
|
|
2016-06-10 07:42:48 +08:00
|
|
|
bool hasAddr64() const {
|
|
|
|
return (getGeneration() < VOLCANIC_ISLANDS);
|
|
|
|
}
|
|
|
|
|
2014-03-18 02:58:11 +08:00
|
|
|
bool hasBFE() const {
|
|
|
|
return (getGeneration() >= EVERGREEN);
|
|
|
|
}
|
|
|
|
|
2014-06-11 03:00:20 +08:00
|
|
|
bool hasBFI() const {
|
|
|
|
return (getGeneration() >= EVERGREEN);
|
|
|
|
}
|
|
|
|
|
2014-03-18 02:58:11 +08:00
|
|
|
bool hasBFM() const {
|
|
|
|
return hasBFE();
|
|
|
|
}
|
|
|
|
|
2014-06-11 03:18:28 +08:00
|
|
|
bool hasBCNT(unsigned Size) const {
|
|
|
|
if (Size == 32)
|
|
|
|
return (getGeneration() >= EVERGREEN);
|
|
|
|
|
2014-07-18 14:07:13 +08:00
|
|
|
if (Size == 64)
|
|
|
|
return (getGeneration() >= SOUTHERN_ISLANDS);
|
|
|
|
|
|
|
|
return false;
|
2014-06-11 03:18:28 +08:00
|
|
|
}
|
|
|
|
|
2014-04-08 03:45:41 +08:00
|
|
|
bool hasMulU24() const {
|
|
|
|
return (getGeneration() >= EVERGREEN);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool hasMulI24() const {
|
|
|
|
return (getGeneration() >= SOUTHERN_ISLANDS ||
|
|
|
|
hasCaymanISA());
|
|
|
|
}
|
|
|
|
|
2014-07-15 23:51:09 +08:00
|
|
|
bool hasFFBL() const {
|
|
|
|
return (getGeneration() >= EVERGREEN);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool hasFFBH() const {
|
|
|
|
return (getGeneration() >= EVERGREEN);
|
|
|
|
}
|
|
|
|
|
2015-05-01 01:15:56 +08:00
|
|
|
bool hasCARRY() const {
|
|
|
|
return (getGeneration() >= EVERGREEN);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool hasBORROW() const {
|
|
|
|
return (getGeneration() >= EVERGREEN);
|
|
|
|
}
|
|
|
|
|
2016-06-24 14:30:11 +08:00
|
|
|
bool hasCaymanISA() const {
|
|
|
|
return CaymanISA;
|
|
|
|
}
|
|
|
|
|
2014-07-13 10:08:26 +08:00
|
|
|
bool isPromoteAllocaEnabled() const {
|
|
|
|
return EnablePromoteAlloca;
|
|
|
|
}
|
|
|
|
|
2015-07-07 00:01:58 +08:00
|
|
|
bool unsafeDSOffsetFoldingEnabled() const {
|
|
|
|
return EnableUnsafeDSOffsetFolding;
|
|
|
|
}
|
|
|
|
|
2016-06-24 14:30:11 +08:00
|
|
|
bool dumpCode() const {
|
|
|
|
return DumpCode;
|
2014-06-28 01:57:00 +08:00
|
|
|
}
|
|
|
|
|
2016-10-20 06:34:49 +08:00
|
|
|
bool enableIEEEBit(const MachineFunction &MF) const {
|
|
|
|
return AMDGPU::isCompute(MF.getFunction()->getCallingConv());
|
|
|
|
}
|
|
|
|
|
2016-05-17 05:19:59 +08:00
|
|
|
/// Return the amount of LDS that can be used that will not restrict the
|
|
|
|
/// occupancy lower than WaveCount.
|
|
|
|
unsigned getMaxLocalMemSizeWithWaveCount(unsigned WaveCount) const;
|
|
|
|
|
|
|
|
/// Inverse of getMaxLocalMemWithWaveCount. Return the maximum wavecount if
|
|
|
|
/// the given LDS memory size is the only constraint.
|
|
|
|
unsigned getOccupancyWithLocalMemSize(uint32_t Bytes) const;
|
|
|
|
|
2016-11-13 15:01:11 +08:00
|
|
|
bool hasFP16Denormals() const {
|
|
|
|
return FP16Denormals;
|
|
|
|
}
|
2016-05-17 05:19:59 +08:00
|
|
|
|
2016-06-24 14:30:11 +08:00
|
|
|
bool hasFP32Denormals() const {
|
|
|
|
return FP32Denormals;
|
2014-06-28 01:57:00 +08:00
|
|
|
}
|
2012-12-12 05:25:42 +08:00
|
|
|
|
2016-06-24 14:30:11 +08:00
|
|
|
bool hasFP64Denormals() const {
|
|
|
|
return FP64Denormals;
|
2016-02-12 10:40:47 +08:00
|
|
|
}
|
|
|
|
|
2016-06-24 14:30:11 +08:00
|
|
|
bool hasFPExceptions() const {
|
|
|
|
return FPExceptions;
|
2015-03-09 23:48:09 +08:00
|
|
|
}
|
|
|
|
|
2016-06-24 14:30:11 +08:00
|
|
|
bool useFlatForGlobal() const {
|
|
|
|
return FlatForGlobal;
|
2015-05-26 00:15:54 +08:00
|
|
|
}
|
|
|
|
|
2016-07-02 07:03:44 +08:00
|
|
|
bool hasUnalignedBufferAccess() const {
|
|
|
|
return UnalignedBufferAccess;
|
|
|
|
}
|
|
|
|
|
2016-10-15 02:10:39 +08:00
|
|
|
bool hasUnalignedScratchAccess() const {
|
|
|
|
return UnalignedScratchAccess;
|
|
|
|
}
|
|
|
|
|
2016-06-24 14:30:11 +08:00
|
|
|
bool isXNACKEnabled() const {
|
|
|
|
return EnableXNACK;
|
|
|
|
}
|
2014-12-03 06:00:07 +08:00
|
|
|
|
2016-09-17 05:34:26 +08:00
|
|
|
bool isAmdCodeObjectV2() const {
|
|
|
|
return isAmdHsaOS() || isMesa3DOS();
|
|
|
|
}
|
|
|
|
|
2016-06-24 14:30:11 +08:00
|
|
|
/// \brief Returns the offset in bytes from the start of the input buffer
|
|
|
|
/// of the first explicit kernel argument.
|
|
|
|
unsigned getExplicitKernelArgOffset() const {
|
2016-09-17 05:34:26 +08:00
|
|
|
return isAmdCodeObjectV2() ? 0 : 36;
|
2016-06-24 14:30:11 +08:00
|
|
|
}
|
|
|
|
|
2016-09-10 03:28:00 +08:00
|
|
|
unsigned getAlignmentForImplicitArgPtr() const {
|
|
|
|
return isAmdHsaOS() ? 8 : 4;
|
|
|
|
}
|
|
|
|
|
2016-09-23 09:33:26 +08:00
|
|
|
unsigned getImplicitArgNumBytes() const {
|
|
|
|
if (isMesa3DOS())
|
|
|
|
return 16;
|
|
|
|
if (isAmdHsaOS() && isOpenCLEnv())
|
|
|
|
return 32;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2016-06-24 14:30:11 +08:00
|
|
|
unsigned getStackAlignment() const {
|
|
|
|
// Scratch is allocated in 256 dword per wave blocks.
|
|
|
|
return 4 * 256 / getWavefrontSize();
|
|
|
|
}
|
2015-06-27 05:15:07 +08:00
|
|
|
|
2014-04-29 15:57:24 +08:00
|
|
|
bool enableMachineScheduler() const override {
|
2015-01-30 00:55:25 +08:00
|
|
|
return true;
|
2013-09-20 13:14:41 +08:00
|
|
|
}
|
|
|
|
|
2016-06-24 14:30:11 +08:00
|
|
|
bool enableSubRegLiveness() const override {
|
|
|
|
return true;
|
|
|
|
}
|
2016-09-07 04:22:28 +08:00
|
|
|
|
|
|
|
/// \returns Number of execution units per compute unit supported by the
|
|
|
|
/// subtarget.
|
|
|
|
unsigned getEUsPerCU() const {
|
|
|
|
return 4;
|
|
|
|
}
|
|
|
|
|
|
|
|
/// \returns Maximum number of work groups per compute unit supported by the
|
|
|
|
/// subtarget and limited by given flat work group size.
|
|
|
|
unsigned getMaxWorkGroupsPerCU(unsigned FlatWorkGroupSize) const {
|
|
|
|
if (getGeneration() < AMDGPUSubtarget::SOUTHERN_ISLANDS)
|
|
|
|
return 8;
|
|
|
|
return getWavesPerWorkGroup(FlatWorkGroupSize) == 1 ? 40 : 16;
|
|
|
|
}
|
|
|
|
|
|
|
|
/// \returns Maximum number of waves per compute unit supported by the
|
|
|
|
/// subtarget without any kind of limitation.
|
|
|
|
unsigned getMaxWavesPerCU() const {
|
|
|
|
return getMaxWavesPerEU() * getEUsPerCU();
|
|
|
|
}
|
|
|
|
|
|
|
|
/// \returns Maximum number of waves per compute unit supported by the
|
|
|
|
/// subtarget and limited by given flat work group size.
|
|
|
|
unsigned getMaxWavesPerCU(unsigned FlatWorkGroupSize) const {
|
|
|
|
return getWavesPerWorkGroup(FlatWorkGroupSize);
|
|
|
|
}
|
|
|
|
|
|
|
|
/// \returns Minimum number of waves per execution unit supported by the
|
|
|
|
/// subtarget.
|
|
|
|
unsigned getMinWavesPerEU() const {
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/// \returns Maximum number of waves per execution unit supported by the
|
|
|
|
/// subtarget without any kind of limitation.
|
|
|
|
unsigned getMaxWavesPerEU() const {
|
|
|
|
if (getGeneration() < AMDGPUSubtarget::SOUTHERN_ISLANDS)
|
|
|
|
return 8;
|
|
|
|
// FIXME: Need to take scratch memory into account.
|
|
|
|
return 10;
|
|
|
|
}
|
|
|
|
|
|
|
|
/// \returns Maximum number of waves per execution unit supported by the
|
|
|
|
/// subtarget and limited by given flat work group size.
|
|
|
|
unsigned getMaxWavesPerEU(unsigned FlatWorkGroupSize) const {
|
|
|
|
return alignTo(getMaxWavesPerCU(FlatWorkGroupSize), getEUsPerCU()) /
|
|
|
|
getEUsPerCU();
|
|
|
|
}
|
|
|
|
|
|
|
|
/// \returns Minimum flat work group size supported by the subtarget.
|
|
|
|
unsigned getMinFlatWorkGroupSize() const {
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/// \returns Maximum flat work group size supported by the subtarget.
|
|
|
|
unsigned getMaxFlatWorkGroupSize() const {
|
|
|
|
return 2048;
|
|
|
|
}
|
|
|
|
|
|
|
|
/// \returns Number of waves per work group given the flat work group size.
|
|
|
|
unsigned getWavesPerWorkGroup(unsigned FlatWorkGroupSize) const {
|
|
|
|
return alignTo(FlatWorkGroupSize, getWavefrontSize()) / getWavefrontSize();
|
|
|
|
}
|
|
|
|
|
|
|
|
/// \returns Subtarget's default pair of minimum/maximum flat work group sizes
|
|
|
|
/// for function \p F, or minimum/maximum flat work group sizes explicitly
|
|
|
|
/// requested using "amdgpu-flat-work-group-size" attribute attached to
|
|
|
|
/// function \p F.
|
|
|
|
///
|
|
|
|
/// \returns Subtarget's default values if explicitly requested values cannot
|
|
|
|
/// be converted to integer, or violate subtarget's specifications.
|
|
|
|
std::pair<unsigned, unsigned> getFlatWorkGroupSizes(const Function &F) const;
|
|
|
|
|
|
|
|
/// \returns Subtarget's default pair of minimum/maximum number of waves per
|
|
|
|
/// execution unit for function \p F, or minimum/maximum number of waves per
|
|
|
|
/// execution unit explicitly requested using "amdgpu-waves-per-eu" attribute
|
|
|
|
/// attached to function \p F.
|
|
|
|
///
|
|
|
|
/// \returns Subtarget's default values if explicitly requested values cannot
|
|
|
|
/// be converted to integer, violate subtarget's specifications, or are not
|
|
|
|
/// compatible with minimum/maximum number of waves limited by flat work group
|
|
|
|
/// size, register usage, and/or lds usage.
|
|
|
|
std::pair<unsigned, unsigned> getWavesPerEU(const Function &F) const;
|
2016-06-24 14:30:11 +08:00
|
|
|
};
|
2015-01-30 00:55:25 +08:00
|
|
|
|
2016-06-24 14:30:11 +08:00
|
|
|
class R600Subtarget final : public AMDGPUSubtarget {
|
|
|
|
private:
|
|
|
|
R600InstrInfo InstrInfo;
|
|
|
|
R600FrameLowering FrameLowering;
|
|
|
|
R600TargetLowering TLInfo;
|
|
|
|
|
|
|
|
public:
|
|
|
|
R600Subtarget(const Triple &TT, StringRef CPU, StringRef FS,
|
|
|
|
const TargetMachine &TM);
|
|
|
|
|
|
|
|
const R600InstrInfo *getInstrInfo() const override {
|
|
|
|
return &InstrInfo;
|
2014-06-28 01:57:00 +08:00
|
|
|
}
|
2012-12-12 05:25:42 +08:00
|
|
|
|
2016-06-24 14:30:11 +08:00
|
|
|
const R600FrameLowering *getFrameLowering() const override {
|
|
|
|
return &FrameLowering;
|
2016-01-21 12:28:34 +08:00
|
|
|
}
|
|
|
|
|
2016-06-24 14:30:11 +08:00
|
|
|
const R600TargetLowering *getTargetLowering() const override {
|
|
|
|
return &TLInfo;
|
2016-04-19 00:28:23 +08:00
|
|
|
}
|
|
|
|
|
2016-06-24 14:30:11 +08:00
|
|
|
const R600RegisterInfo *getRegisterInfo() const override {
|
|
|
|
return &InstrInfo.getRegisterInfo();
|
2016-04-26 23:43:14 +08:00
|
|
|
}
|
|
|
|
|
2016-06-24 14:30:11 +08:00
|
|
|
bool hasCFAluBug() const {
|
|
|
|
return CFALUBug;
|
2014-06-28 01:57:00 +08:00
|
|
|
}
|
2016-06-24 14:30:11 +08:00
|
|
|
|
|
|
|
bool hasVertexCache() const {
|
|
|
|
return HasVertexCache;
|
2014-06-28 01:57:00 +08:00
|
|
|
}
|
2016-06-24 14:30:11 +08:00
|
|
|
|
|
|
|
short getTexVTXClauseSize() const {
|
|
|
|
return TexVTXClauseSize;
|
2014-12-03 01:05:41 +08:00
|
|
|
}
|
2016-06-24 14:30:11 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
class SISubtarget final : public AMDGPUSubtarget {
|
|
|
|
public:
|
|
|
|
enum {
|
2016-08-06 05:23:29 +08:00
|
|
|
// The closed Vulkan driver sets 96, which limits the wave count to 8 but
|
|
|
|
// doesn't spill SGPRs as much as when 80 is set.
|
|
|
|
FIXED_SGPR_COUNT_FOR_INIT_BUG = 96
|
2016-06-24 14:30:11 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
private:
|
|
|
|
SIInstrInfo InstrInfo;
|
|
|
|
SIFrameLowering FrameLowering;
|
|
|
|
SITargetLowering TLInfo;
|
|
|
|
std::unique_ptr<GISelAccessor> GISel;
|
|
|
|
|
|
|
|
public:
|
|
|
|
SISubtarget(const Triple &TT, StringRef CPU, StringRef FS,
|
|
|
|
const TargetMachine &TM);
|
|
|
|
|
|
|
|
const SIInstrInfo *getInstrInfo() const override {
|
|
|
|
return &InstrInfo;
|
2016-01-05 07:35:53 +08:00
|
|
|
}
|
|
|
|
|
2016-06-24 14:30:11 +08:00
|
|
|
const SIFrameLowering *getFrameLowering() const override {
|
|
|
|
return &FrameLowering;
|
|
|
|
}
|
2015-01-30 00:55:25 +08:00
|
|
|
|
2016-06-24 14:30:11 +08:00
|
|
|
const SITargetLowering *getTargetLowering() const override {
|
|
|
|
return &TLInfo;
|
2015-01-30 00:55:25 +08:00
|
|
|
}
|
2015-02-05 07:14:18 +08:00
|
|
|
|
2016-06-24 14:30:11 +08:00
|
|
|
const CallLowering *getCallLowering() const override {
|
|
|
|
assert(GISel && "Access to GlobalISel APIs not set");
|
|
|
|
return GISel->getCallLowering();
|
2015-02-05 07:14:18 +08:00
|
|
|
}
|
2015-06-27 05:15:03 +08:00
|
|
|
|
2016-06-24 14:30:11 +08:00
|
|
|
const SIRegisterInfo *getRegisterInfo() const override {
|
|
|
|
return &InstrInfo.getRegisterInfo();
|
2015-06-27 05:15:03 +08:00
|
|
|
}
|
|
|
|
|
2016-06-24 14:30:11 +08:00
|
|
|
void setGISelAccessor(GISelAccessor &GISel) {
|
|
|
|
this->GISel.reset(&GISel);
|
|
|
|
}
|
|
|
|
|
|
|
|
void overrideSchedPolicy(MachineSchedPolicy &Policy,
|
|
|
|
unsigned NumRegionInstrs) const override;
|
|
|
|
|
|
|
|
bool isVGPRSpillingEnabled(const Function& F) const;
|
|
|
|
|
2015-12-01 05:16:07 +08:00
|
|
|
unsigned getMaxNumUserSGPRs() const {
|
|
|
|
return 16;
|
|
|
|
}
|
2016-06-24 14:30:11 +08:00
|
|
|
|
|
|
|
bool hasFlatAddressSpace() const {
|
|
|
|
return FlatAddressSpace;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool hasSMemRealTime() const {
|
|
|
|
return HasSMemRealTime;
|
|
|
|
}
|
|
|
|
|
2016-10-13 02:00:51 +08:00
|
|
|
bool hasMovrel() const {
|
|
|
|
return HasMovrel;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool hasVGPRIndexMode() const {
|
|
|
|
return HasVGPRIndexMode;
|
|
|
|
}
|
|
|
|
|
2016-09-17 10:02:19 +08:00
|
|
|
bool hasScalarCompareEq64() const {
|
|
|
|
return getGeneration() >= VOLCANIC_ISLANDS;
|
|
|
|
}
|
|
|
|
|
2016-10-29 05:55:15 +08:00
|
|
|
bool hasScalarStores() const {
|
|
|
|
return HasScalarStores;
|
|
|
|
}
|
|
|
|
|
2016-10-29 12:05:06 +08:00
|
|
|
bool hasInv2PiInlineImm() const {
|
|
|
|
return HasInv2PiInlineImm;
|
|
|
|
}
|
|
|
|
|
2016-06-24 14:30:11 +08:00
|
|
|
bool enableSIScheduler() const {
|
|
|
|
return EnableSIScheduler;
|
|
|
|
}
|
|
|
|
|
2016-06-25 11:11:28 +08:00
|
|
|
bool debuggerSupported() const {
|
|
|
|
return debuggerInsertNops() && debuggerReserveRegs() &&
|
|
|
|
debuggerEmitPrologue();
|
|
|
|
}
|
|
|
|
|
2016-06-24 14:30:11 +08:00
|
|
|
bool debuggerInsertNops() const {
|
|
|
|
return DebuggerInsertNops;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool debuggerReserveRegs() const {
|
|
|
|
return DebuggerReserveRegs;
|
|
|
|
}
|
|
|
|
|
2016-06-25 11:11:28 +08:00
|
|
|
bool debuggerEmitPrologue() const {
|
|
|
|
return DebuggerEmitPrologue;
|
|
|
|
}
|
|
|
|
|
2016-06-24 14:30:11 +08:00
|
|
|
bool loadStoreOptEnabled() const {
|
|
|
|
return EnableLoadStoreOpt;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool hasSGPRInitBug() const {
|
|
|
|
return SGPRInitBug;
|
|
|
|
}
|
2016-08-30 03:42:52 +08:00
|
|
|
|
2016-10-28 07:05:31 +08:00
|
|
|
bool has12DWordStoreHazard() const {
|
|
|
|
return getGeneration() != AMDGPUSubtarget::SOUTHERN_ISLANDS;
|
|
|
|
}
|
|
|
|
|
2016-09-23 09:33:26 +08:00
|
|
|
unsigned getKernArgSegmentSize(unsigned ExplictArgBytes) const;
|
|
|
|
|
2016-08-30 03:42:52 +08:00
|
|
|
/// Return the maximum number of waves per SIMD for kernels using \p SGPRs SGPRs
|
|
|
|
unsigned getOccupancyWithNumSGPRs(unsigned SGPRs) const;
|
|
|
|
|
|
|
|
/// Return the maximum number of waves per SIMD for kernels using \p VGPRs VGPRs
|
|
|
|
unsigned getOccupancyWithNumVGPRs(unsigned VGPRs) const;
|
2016-10-01 00:50:36 +08:00
|
|
|
|
|
|
|
/// \returns True if waitcnt instruction is needed before barrier instruction,
|
|
|
|
/// false otherwise.
|
|
|
|
bool needWaitcntBeforeBarrier() const {
|
|
|
|
return true;
|
|
|
|
}
|
2016-10-29 04:31:47 +08:00
|
|
|
|
|
|
|
unsigned getMaxNumSGPRs() const;
|
2012-12-12 05:25:42 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
} // End namespace llvm
|
|
|
|
|
2014-08-14 00:26:38 +08:00
|
|
|
#endif
|