2015-11-06 18:17:45 +00:00
|
|
|
//=====-- AMDGPUSubtarget.h - Define Subtarget for AMDGPU ------*- C++ -*-====//
|
2012-12-11 21:25:42 +00: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-06 18:17:45 +00:00
|
|
|
#ifndef LLVM_LIB_TARGET_AMDGPU_AMDGPUSUBTARGET_H
|
|
|
|
#define LLVM_LIB_TARGET_AMDGPU_AMDGPUSUBTARGET_H
|
2015-11-06 18:23:00 +00:00
|
|
|
|
2013-06-07 20:37:48 +00:00
|
|
|
#include "AMDGPU.h"
|
2014-07-25 22:22:39 +00:00
|
|
|
#include "AMDGPUFrameLowering.h"
|
2014-06-13 01:32:00 +00:00
|
|
|
#include "AMDGPUInstrInfo.h"
|
2015-11-06 18:23:00 +00:00
|
|
|
#include "AMDGPUISelLowering.h"
|
2014-07-25 22:22:39 +00:00
|
|
|
#include "AMDGPUSubtarget.h"
|
2015-06-26 21:15:07 +00:00
|
|
|
#include "Utils/AMDGPUBaseInfo.h"
|
2012-12-11 21:25:42 +00:00
|
|
|
#include "llvm/ADT/StringRef.h"
|
|
|
|
#include "llvm/Target/TargetSubtargetInfo.h"
|
|
|
|
|
|
|
|
#define GET_SUBTARGETINFO_HEADER
|
|
|
|
#include "AMDGPUGenSubtargetInfo.inc"
|
|
|
|
|
|
|
|
namespace llvm {
|
|
|
|
|
2015-01-20 19:33:04 +00:00
|
|
|
class SIMachineFunctionInfo;
|
|
|
|
|
2012-12-11 21:25:42 +00:00
|
|
|
class AMDGPUSubtarget : public AMDGPUGenSubtargetInfo {
|
2014-06-13 01:32:00 +00:00
|
|
|
|
2013-06-07 20:37:48 +00:00
|
|
|
public:
|
|
|
|
enum Generation {
|
|
|
|
R600 = 0,
|
|
|
|
R700,
|
|
|
|
EVERGREEN,
|
|
|
|
NORTHERN_ISLANDS,
|
2013-10-29 16:37:28 +00:00
|
|
|
SOUTHERN_ISLANDS,
|
2014-12-07 12:18:57 +00:00
|
|
|
SEA_ISLANDS,
|
|
|
|
VOLCANIC_ISLANDS,
|
2013-06-07 20:37:48 +00:00
|
|
|
};
|
|
|
|
|
2015-03-09 15:48:09 +00:00
|
|
|
enum {
|
|
|
|
FIXED_SGPR_COUNT_FOR_INIT_BUG = 80
|
|
|
|
};
|
|
|
|
|
2015-06-26 21:15:07 +00:00
|
|
|
enum {
|
|
|
|
ISAVersion0_0_0,
|
|
|
|
ISAVersion7_0_0,
|
|
|
|
ISAVersion7_0_1,
|
|
|
|
ISAVersion8_0_0,
|
2016-01-13 20:39:25 +00:00
|
|
|
ISAVersion8_0_1,
|
|
|
|
ISAVersion8_0_3
|
2015-06-26 21:15:07 +00:00
|
|
|
};
|
|
|
|
|
2012-12-11 21:25:42 +00:00
|
|
|
private:
|
|
|
|
bool DumpCode;
|
|
|
|
bool R600ALUInst;
|
2013-04-30 00:13:39 +00:00
|
|
|
bool HasVertexCache;
|
2013-05-17 16:49:55 +00:00
|
|
|
short TexVTXClauseSize;
|
2014-06-27 17:57:00 +00:00
|
|
|
Generation Gen;
|
2013-06-07 20:37:48 +00:00
|
|
|
bool FP64;
|
2014-07-14 23:40:49 +00:00
|
|
|
bool FP64Denormals;
|
|
|
|
bool FP32Denormals;
|
2016-01-28 20:53:42 +00:00
|
|
|
bool FPExceptions;
|
2015-01-29 19:34:25 +00:00
|
|
|
bool FastFMAF32;
|
2016-01-18 21:13:50 +00:00
|
|
|
bool HalfRate64Ops;
|
2013-06-07 20:37:48 +00:00
|
|
|
bool CaymanISA;
|
2014-09-15 15:41:53 +00:00
|
|
|
bool FlatAddressSpace;
|
2015-12-22 20:55:23 +00:00
|
|
|
bool FlatForGlobal;
|
2013-10-10 17:11:12 +00:00
|
|
|
bool EnableIRStructurizer;
|
2014-07-13 02:08:26 +00:00
|
|
|
bool EnablePromoteAlloca;
|
2013-11-18 19:43:33 +00:00
|
|
|
bool EnableIfCvt;
|
2014-10-10 22:01:59 +00:00
|
|
|
bool EnableLoadStoreOpt;
|
2015-07-06 16:01:58 +00:00
|
|
|
bool EnableUnsafeDSOffsetFolding;
|
2016-01-04 23:35:53 +00:00
|
|
|
bool EnableXNACK;
|
2014-01-22 21:55:40 +00:00
|
|
|
unsigned WavefrontSize;
|
2014-01-23 16:18:02 +00:00
|
|
|
bool CFALUBug;
|
2014-06-17 16:53:14 +00:00
|
|
|
int LocalMemorySize;
|
2016-02-12 02:40:47 +00:00
|
|
|
unsigned MaxPrivateElementSize;
|
2015-01-20 19:33:04 +00:00
|
|
|
bool EnableVGPRSpilling;
|
2015-03-09 15:48:09 +00:00
|
|
|
bool SGPRInitBug;
|
2015-04-08 01:09:26 +00:00
|
|
|
bool IsGCN;
|
|
|
|
bool GCN1Encoding;
|
|
|
|
bool GCN3Encoding;
|
2015-04-23 19:33:54 +00:00
|
|
|
bool CIInsts;
|
2016-02-27 08:53:46 +00:00
|
|
|
bool VIInsts;
|
2015-04-23 19:33:54 +00:00
|
|
|
bool FeatureDisable;
|
2015-05-25 16:15:54 +00:00
|
|
|
int LDSBankCount;
|
2015-11-06 18:23:00 +00:00
|
|
|
unsigned IsaVersion;
|
2015-07-16 19:40:07 +00:00
|
|
|
bool EnableHugeScratchBuffer;
|
2016-01-21 04:28:34 +00:00
|
|
|
bool EnableSIScheduler;
|
2012-12-11 21:25:42 +00:00
|
|
|
|
2015-11-06 18:17:45 +00:00
|
|
|
std::unique_ptr<AMDGPUFrameLowering> FrameLowering;
|
2014-07-25 22:22:39 +00:00
|
|
|
std::unique_ptr<AMDGPUTargetLowering> TLInfo;
|
|
|
|
std::unique_ptr<AMDGPUInstrInfo> InstrInfo;
|
2012-12-11 21:25:42 +00:00
|
|
|
InstrItineraryData InstrItins;
|
2014-12-02 17:05:41 +00:00
|
|
|
Triple TargetTriple;
|
2012-12-11 21:25:42 +00:00
|
|
|
|
|
|
|
public:
|
2015-06-10 12:11:26 +00:00
|
|
|
AMDGPUSubtarget(const Triple &TT, StringRef CPU, StringRef FS,
|
|
|
|
TargetMachine &TM);
|
|
|
|
AMDGPUSubtarget &initializeSubtargetDependencies(const Triple &TT,
|
|
|
|
StringRef GPU, StringRef FS);
|
2014-06-27 17:57:00 +00:00
|
|
|
|
2014-08-04 21:25:23 +00:00
|
|
|
const AMDGPUFrameLowering *getFrameLowering() const override {
|
2015-11-06 18:17:45 +00:00
|
|
|
return FrameLowering.get();
|
2014-08-04 21:25:23 +00:00
|
|
|
}
|
|
|
|
const AMDGPUInstrInfo *getInstrInfo() const override {
|
|
|
|
return InstrInfo.get();
|
|
|
|
}
|
|
|
|
const AMDGPURegisterInfo *getRegisterInfo() const override {
|
2014-07-25 22:22:39 +00:00
|
|
|
return &InstrInfo->getRegisterInfo();
|
2014-06-27 17:57:00 +00:00
|
|
|
}
|
2014-08-04 21:25:23 +00:00
|
|
|
AMDGPUTargetLowering *getTargetLowering() const override {
|
|
|
|
return TLInfo.get();
|
|
|
|
}
|
|
|
|
const InstrItineraryData *getInstrItineraryData() const override {
|
|
|
|
return &InstrItins;
|
|
|
|
}
|
2014-06-27 17:57:00 +00:00
|
|
|
|
2014-04-30 05:53:27 +00:00
|
|
|
void ParseSubtargetFeatures(StringRef CPU, StringRef FS);
|
2012-12-11 21:25:42 +00:00
|
|
|
|
2014-06-27 17:57:00 +00:00
|
|
|
bool hasVertexCache() const {
|
|
|
|
return HasVertexCache;
|
|
|
|
}
|
|
|
|
|
|
|
|
short getTexVTXClauseSize() const {
|
2014-07-13 02:08:26 +00:00
|
|
|
return TexVTXClauseSize;
|
2014-06-27 17:57:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Generation getGeneration() const {
|
|
|
|
return Gen;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool hasHWFP64() const {
|
|
|
|
return FP64;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool hasCaymanISA() const {
|
|
|
|
return CaymanISA;
|
|
|
|
}
|
2014-03-17 18:58:11 +00:00
|
|
|
|
2014-07-14 23:40:49 +00:00
|
|
|
bool hasFP32Denormals() const {
|
|
|
|
return FP32Denormals;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool hasFP64Denormals() const {
|
|
|
|
return FP64Denormals;
|
|
|
|
}
|
|
|
|
|
2016-01-28 20:53:42 +00:00
|
|
|
bool hasFPExceptions() const {
|
|
|
|
return FPExceptions;
|
|
|
|
}
|
|
|
|
|
2015-01-29 19:34:25 +00:00
|
|
|
bool hasFastFMAF32() const {
|
|
|
|
return FastFMAF32;
|
|
|
|
}
|
|
|
|
|
2016-01-18 21:13:50 +00:00
|
|
|
bool hasHalfRate64Ops() const {
|
|
|
|
return HalfRate64Ops;
|
|
|
|
}
|
|
|
|
|
2014-09-15 15:41:53 +00:00
|
|
|
bool hasFlatAddressSpace() const {
|
|
|
|
return FlatAddressSpace;
|
|
|
|
}
|
|
|
|
|
2015-12-22 20:55:23 +00:00
|
|
|
bool useFlatForGlobal() const {
|
|
|
|
return FlatForGlobal;
|
|
|
|
}
|
|
|
|
|
2014-03-17 18:58:11 +00:00
|
|
|
bool hasBFE() const {
|
|
|
|
return (getGeneration() >= EVERGREEN);
|
|
|
|
}
|
|
|
|
|
2014-06-10 19:00:20 +00:00
|
|
|
bool hasBFI() const {
|
|
|
|
return (getGeneration() >= EVERGREEN);
|
|
|
|
}
|
|
|
|
|
2014-03-17 18:58:11 +00:00
|
|
|
bool hasBFM() const {
|
|
|
|
return hasBFE();
|
|
|
|
}
|
|
|
|
|
2014-06-10 19:18:28 +00:00
|
|
|
bool hasBCNT(unsigned Size) const {
|
|
|
|
if (Size == 32)
|
|
|
|
return (getGeneration() >= EVERGREEN);
|
|
|
|
|
2014-07-18 06:07:13 +00:00
|
|
|
if (Size == 64)
|
|
|
|
return (getGeneration() >= SOUTHERN_ISLANDS);
|
|
|
|
|
|
|
|
return false;
|
2014-06-10 19:18:28 +00:00
|
|
|
}
|
|
|
|
|
2014-04-07 19:45:41 +00:00
|
|
|
bool hasMulU24() const {
|
|
|
|
return (getGeneration() >= EVERGREEN);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool hasMulI24() const {
|
|
|
|
return (getGeneration() >= SOUTHERN_ISLANDS ||
|
|
|
|
hasCaymanISA());
|
|
|
|
}
|
|
|
|
|
2014-07-15 15:51:09 +00:00
|
|
|
bool hasFFBL() const {
|
|
|
|
return (getGeneration() >= EVERGREEN);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool hasFFBH() const {
|
|
|
|
return (getGeneration() >= EVERGREEN);
|
|
|
|
}
|
|
|
|
|
2015-04-30 17:15:56 +00:00
|
|
|
bool hasCARRY() const {
|
|
|
|
return (getGeneration() >= EVERGREEN);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool hasBORROW() const {
|
|
|
|
return (getGeneration() >= EVERGREEN);
|
|
|
|
}
|
|
|
|
|
2014-06-27 17:57:00 +00:00
|
|
|
bool IsIRStructurizerEnabled() const {
|
|
|
|
return EnableIRStructurizer;
|
|
|
|
}
|
|
|
|
|
2014-07-13 02:08:26 +00:00
|
|
|
bool isPromoteAllocaEnabled() const {
|
|
|
|
return EnablePromoteAlloca;
|
|
|
|
}
|
|
|
|
|
2014-06-27 17:57:00 +00:00
|
|
|
bool isIfCvtEnabled() const {
|
|
|
|
return EnableIfCvt;
|
|
|
|
}
|
|
|
|
|
2014-10-10 22:01:59 +00:00
|
|
|
bool loadStoreOptEnabled() const {
|
|
|
|
return EnableLoadStoreOpt;
|
|
|
|
}
|
|
|
|
|
2015-07-06 16:01:58 +00:00
|
|
|
bool unsafeDSOffsetFoldingEnabled() const {
|
|
|
|
return EnableUnsafeDSOffsetFolding;
|
|
|
|
}
|
|
|
|
|
2014-06-27 17:57:00 +00:00
|
|
|
unsigned getWavefrontSize() const {
|
|
|
|
return WavefrontSize;
|
|
|
|
}
|
|
|
|
|
2014-01-22 21:55:43 +00:00
|
|
|
unsigned getStackEntrySize() const;
|
2014-06-27 17:57:00 +00:00
|
|
|
|
|
|
|
bool hasCFAluBug() const {
|
|
|
|
assert(getGeneration() <= NORTHERN_ISLANDS);
|
|
|
|
return CFALUBug;
|
|
|
|
}
|
|
|
|
|
|
|
|
int getLocalMemorySize() const {
|
|
|
|
return LocalMemorySize;
|
|
|
|
}
|
2012-12-11 21:25:42 +00:00
|
|
|
|
2016-02-12 02:40:47 +00:00
|
|
|
unsigned getMaxPrivateElementSize() const {
|
|
|
|
return MaxPrivateElementSize;
|
|
|
|
}
|
|
|
|
|
2015-03-09 15:48:09 +00:00
|
|
|
bool hasSGPRInitBug() const {
|
|
|
|
return SGPRInitBug;
|
|
|
|
}
|
|
|
|
|
2015-05-25 16:15:54 +00:00
|
|
|
int getLDSBankCount() const {
|
|
|
|
return LDSBankCount;
|
|
|
|
}
|
|
|
|
|
2014-12-02 22:00:07 +00:00
|
|
|
unsigned getAmdKernelCodeChipID() const;
|
|
|
|
|
2015-06-26 21:15:07 +00:00
|
|
|
AMDGPU::IsaVersion getIsaVersion() const;
|
|
|
|
|
2014-04-29 07:57:24 +00:00
|
|
|
bool enableMachineScheduler() const override {
|
2015-01-29 16:55:25 +00:00
|
|
|
return true;
|
2013-09-20 05:14:41 +00:00
|
|
|
}
|
|
|
|
|
2015-01-29 16:55:25 +00:00
|
|
|
void overrideSchedPolicy(MachineSchedPolicy &Policy,
|
|
|
|
MachineInstr *begin, MachineInstr *end,
|
|
|
|
unsigned NumRegionInstrs) const override;
|
|
|
|
|
2012-12-11 21:25:42 +00:00
|
|
|
// Helper functions to simplify if statements
|
2014-06-27 17:57:00 +00:00
|
|
|
bool isTargetELF() const {
|
|
|
|
return false;
|
|
|
|
}
|
2012-12-11 21:25:42 +00:00
|
|
|
|
2015-07-16 19:40:07 +00:00
|
|
|
bool enableHugeScratchBuffer() const {
|
|
|
|
return EnableHugeScratchBuffer;
|
|
|
|
}
|
|
|
|
|
2016-01-21 04:28:34 +00:00
|
|
|
bool enableSIScheduler() const {
|
|
|
|
return EnableSIScheduler;
|
|
|
|
}
|
|
|
|
|
2014-06-27 17:57:00 +00:00
|
|
|
bool dumpCode() const {
|
|
|
|
return DumpCode;
|
|
|
|
}
|
|
|
|
bool r600ALUEncoding() const {
|
|
|
|
return R600ALUInst;
|
|
|
|
}
|
2014-12-02 17:05:41 +00:00
|
|
|
bool isAmdHsaOS() const {
|
|
|
|
return TargetTriple.getOS() == Triple::AMDHSA;
|
|
|
|
}
|
2015-01-20 19:33:04 +00:00
|
|
|
bool isVGPRSpillingEnabled(const SIMachineFunctionInfo *MFI) const;
|
2015-01-29 16:55:25 +00:00
|
|
|
|
2016-01-04 23:35:53 +00:00
|
|
|
bool isXNACKEnabled() const {
|
|
|
|
return EnableXNACK;
|
|
|
|
}
|
|
|
|
|
2015-01-29 16:55:25 +00:00
|
|
|
unsigned getMaxWavesPerCU() const {
|
|
|
|
if (getGeneration() >= AMDGPUSubtarget::SOUTHERN_ISLANDS)
|
|
|
|
return 10;
|
|
|
|
|
|
|
|
// FIXME: Not sure what this is for other subtagets.
|
|
|
|
llvm_unreachable("do not know max waves per CU for this subtarget.");
|
|
|
|
}
|
2015-02-04 23:14:18 +00:00
|
|
|
|
|
|
|
bool enableSubRegLiveness() const override {
|
2015-06-04 01:20:04 +00:00
|
|
|
return true;
|
2015-02-04 23:14:18 +00:00
|
|
|
}
|
2015-06-26 21:15:03 +00:00
|
|
|
|
|
|
|
/// \brief Returns the offset in bytes from the start of the input buffer
|
|
|
|
/// of the first explicit kernel argument.
|
|
|
|
unsigned getExplicitKernelArgOffset() const {
|
|
|
|
return isAmdHsaOS() ? 0 : 36;
|
|
|
|
}
|
|
|
|
|
2015-11-30 21:16:07 +00:00
|
|
|
unsigned getMaxNumUserSGPRs() const {
|
|
|
|
return 16;
|
|
|
|
}
|
2012-12-11 21:25:42 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
} // End namespace llvm
|
|
|
|
|
2014-08-13 16:26:38 +00:00
|
|
|
#endif
|