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"
|
2017-08-16 06:31:51 +08:00
|
|
|
#include "AMDGPUCallLowering.h"
|
2016-06-24 14:30:11 +08:00
|
|
|
#include "R600FrameLowering.h"
|
2017-06-06 19:49:48 +08:00
|
|
|
#include "R600ISelLowering.h"
|
|
|
|
#include "R600InstrInfo.h"
|
2016-06-24 14:30:11 +08:00
|
|
|
#include "SIFrameLowering.h"
|
2017-06-06 19:49:48 +08:00
|
|
|
#include "SIISelLowering.h"
|
|
|
|
#include "SIInstrInfo.h"
|
2017-03-21 21:15:46 +08:00
|
|
|
#include "SIMachineFunctionInfo.h"
|
2015-06-27 05:15:07 +08:00
|
|
|
#include "Utils/AMDGPUBaseInfo.h"
|
2016-12-10 06:06:55 +08:00
|
|
|
#include "llvm/ADT/Triple.h"
|
2017-08-16 06:31:51 +08:00
|
|
|
#include "llvm/CodeGen/GlobalISel/InstructionSelector.h"
|
|
|
|
#include "llvm/CodeGen/GlobalISel/LegalizerInfo.h"
|
|
|
|
#include "llvm/CodeGen/GlobalISel/RegisterBankInfo.h"
|
2016-12-10 06:06:55 +08:00
|
|
|
#include "llvm/CodeGen/MachineFunction.h"
|
2016-08-12 01:31:42 +08:00
|
|
|
#include "llvm/CodeGen/SelectionDAGTargetInfo.h"
|
2016-12-10 06:06:55 +08:00
|
|
|
#include "llvm/MC/MCInstrItineraries.h"
|
|
|
|
#include "llvm/Support/MathExtras.h"
|
|
|
|
#include <cassert>
|
|
|
|
#include <cstdint>
|
|
|
|
#include <memory>
|
|
|
|
#include <utility>
|
2012-12-12 05:25:42 +08:00
|
|
|
|
|
|
|
#define GET_SUBTARGETINFO_HEADER
|
|
|
|
#include "AMDGPUGenSubtargetInfo.inc"
|
|
|
|
|
|
|
|
namespace llvm {
|
|
|
|
|
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,
|
2017-02-19 02:29:53 +08:00
|
|
|
GFX9,
|
2013-06-08 04:37:48 +08:00
|
|
|
};
|
|
|
|
|
2015-06-27 05:15:07 +08:00
|
|
|
enum {
|
|
|
|
ISAVersion0_0_0,
|
2017-06-10 11:53:19 +08:00
|
|
|
ISAVersion6_0_0,
|
|
|
|
ISAVersion6_0_1,
|
2015-06-27 05:15:07 +08:00
|
|
|
ISAVersion7_0_0,
|
|
|
|
ISAVersion7_0_1,
|
2016-10-27 00:37:56 +08:00
|
|
|
ISAVersion7_0_2,
|
2017-06-10 11:53:19 +08:00
|
|
|
ISAVersion7_0_3,
|
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,
|
2017-02-19 02:29:53 +08:00
|
|
|
ISAVersion9_0_0,
|
2017-06-10 11:53:19 +08:00
|
|
|
ISAVersion9_0_1,
|
|
|
|
ISAVersion9_0_2,
|
|
|
|
ISAVersion9_0_3
|
2015-06-27 05:15:07 +08:00
|
|
|
};
|
|
|
|
|
2017-02-10 10:15:29 +08:00
|
|
|
enum TrapHandlerAbi {
|
|
|
|
TrapHandlerAbiNone = 0,
|
|
|
|
TrapHandlerAbiHsa = 1
|
|
|
|
};
|
|
|
|
|
2017-02-23 07:22:19 +08:00
|
|
|
enum TrapID {
|
|
|
|
TrapIDHardwareReserved = 0,
|
|
|
|
TrapIDHSADebugTrap = 1,
|
|
|
|
TrapIDLLVMTrap = 2,
|
|
|
|
TrapIDLLVMDebugTrap = 3,
|
|
|
|
TrapIDDebugBreakpoint = 7,
|
|
|
|
TrapIDDebugReserved8 = 8,
|
|
|
|
TrapIDDebugReservedFE = 0xfe,
|
|
|
|
TrapIDDebugReservedFF = 0xff
|
2017-02-10 10:15:29 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
enum TrapRegValues {
|
2017-02-23 07:22:19 +08:00
|
|
|
LLVMTrapHandlerRegValue = 1
|
2017-02-10 10:15:29 +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.
|
|
|
|
bool FP32Denormals;
|
2017-01-24 06:31:03 +08:00
|
|
|
bool FP64FP16Denormals;
|
2016-06-24 14:30:11 +08:00
|
|
|
bool FPExceptions;
|
2017-02-22 07:35:48 +08:00
|
|
|
bool DX10Clamp;
|
2015-12-23 04:55:23 +08:00
|
|
|
bool FlatForGlobal;
|
2017-06-03 01:40:26 +08:00
|
|
|
bool AutoWaitcntBeforeBarrier;
|
2017-10-14 23:59:07 +08:00
|
|
|
bool CodeObjectV3;
|
2016-10-15 02:10:39 +08:00
|
|
|
bool UnalignedScratchAccess;
|
2016-07-02 07:03:44 +08:00
|
|
|
bool UnalignedBufferAccess;
|
2017-02-19 02:29:53 +08:00
|
|
|
bool HasApertureRegs;
|
2016-06-24 14:30:11 +08:00
|
|
|
bool EnableXNACK;
|
2017-02-10 10:15:29 +08:00
|
|
|
bool TrapHandler;
|
2016-06-24 14:30:11 +08:00
|
|
|
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 GCN3Encoding;
|
2015-04-24 03:33:54 +08:00
|
|
|
bool CIInsts;
|
2017-02-19 03:12:26 +08:00
|
|
|
bool GFX9Insts;
|
2016-06-24 14:30:11 +08:00
|
|
|
bool SGPRInitBug;
|
2016-02-27 16:53:55 +08:00
|
|
|
bool HasSMemRealTime;
|
|
|
|
bool Has16BitInsts;
|
2017-08-16 21:51:56 +08:00
|
|
|
bool HasIntClamp;
|
2017-02-28 02:49:11 +08:00
|
|
|
bool HasVOP3PInsts;
|
2017-10-25 15:00:51 +08:00
|
|
|
bool HasMadMixInsts;
|
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;
|
2017-01-20 18:01:25 +08:00
|
|
|
bool HasSDWA;
|
2017-06-22 14:26:41 +08:00
|
|
|
bool HasSDWAOmod;
|
|
|
|
bool HasSDWAScalar;
|
|
|
|
bool HasSDWASdst;
|
|
|
|
bool HasSDWAMac;
|
[AMDGPU] SDWA: several fixes for V_CVT and VOPC instructions
Summary:
1. Instruction V_CVT_U32_F32 allow omod operand (see SIInstrInfo.td:1435). In fact this operand shouldn't be allowed here. This fix checks if SDWA pseudo instruction has OMod operand and then copy it.
2. There were several problems with support of VOPC instructions in SDWA peephole pass.
Reviewers: tstellar, arsenm, vpykhtin, airlied, kzhuravl
Subscribers: wdng, nhaehnle, yaxunl, dstuttard, tpr, sarnex, t-tye
Differential Revision: https://reviews.llvm.org/D34626
llvm-svn: 306413
2017-06-27 23:02:23 +08:00
|
|
|
bool HasSDWAOutModsVOPC;
|
2017-01-20 18:01:25 +08:00
|
|
|
bool HasDPP;
|
2016-06-24 14:30:11 +08:00
|
|
|
bool FlatAddressSpace;
|
2017-05-11 05:19:05 +08:00
|
|
|
bool FlatInstOffsets;
|
|
|
|
bool FlatGlobalInsts;
|
|
|
|
bool FlatScratchInsts;
|
2017-07-21 01:42:47 +08:00
|
|
|
bool AddNoCarryInsts;
|
2016-06-24 14:30:11 +08:00
|
|
|
bool R600ALUInst;
|
|
|
|
bool CaymanISA;
|
|
|
|
bool CFALUBug;
|
|
|
|
bool HasVertexCache;
|
|
|
|
short TexVTXClauseSize;
|
2016-12-09 01:28:47 +08:00
|
|
|
bool ScalarizeGlobal;
|
2016-06-24 14:30:11 +08:00
|
|
|
|
|
|
|
// 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;
|
2017-03-27 22:04:01 +08:00
|
|
|
AMDGPUAS AS;
|
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);
|
2016-12-10 06:06:55 +08:00
|
|
|
~AMDGPUSubtarget() override;
|
|
|
|
|
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 {
|
2017-06-02 05:31:53 +08:00
|
|
|
return TargetTriple.getEnvironment() == Triple::OpenCL ||
|
|
|
|
TargetTriple.getEnvironmentName() == "amdgizcl";
|
2016-09-23 09:33:26 +08:00
|
|
|
}
|
|
|
|
|
2017-09-29 17:48:12 +08:00
|
|
|
bool isAmdPalOS() const {
|
|
|
|
return TargetTriple.getOS() == Triple::AMDPAL;
|
|
|
|
}
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2017-11-14 06:55:05 +08:00
|
|
|
unsigned getWavefrontSizeLog2() const {
|
|
|
|
return Log2_32(WavefrontSize);
|
|
|
|
}
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2017-03-27 22:04:01 +08:00
|
|
|
AMDGPUAS getAMDGPUAS() const {
|
|
|
|
return AS;
|
|
|
|
}
|
|
|
|
|
2016-11-02 01:49:33 +08:00
|
|
|
bool has16BitInsts() const {
|
|
|
|
return Has16BitInsts;
|
|
|
|
}
|
|
|
|
|
2017-08-16 21:51:56 +08:00
|
|
|
bool hasIntClamp() const {
|
|
|
|
return HasIntClamp;
|
|
|
|
}
|
|
|
|
|
2017-02-28 02:49:11 +08:00
|
|
|
bool hasVOP3PInsts() const {
|
|
|
|
return HasVOP3PInsts;
|
|
|
|
}
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2017-02-28 06:40:39 +08:00
|
|
|
bool hasMed3_16() const {
|
|
|
|
return getGeneration() >= GFX9;
|
|
|
|
}
|
|
|
|
|
2017-05-18 03:25:06 +08:00
|
|
|
bool hasMin3Max3_16() const {
|
|
|
|
return getGeneration() >= GFX9;
|
|
|
|
}
|
|
|
|
|
2017-09-08 02:05:07 +08:00
|
|
|
bool hasMadMixInsts() const {
|
2017-10-25 15:00:51 +08:00
|
|
|
return HasMadMixInsts;
|
2017-09-08 02:05:07 +08:00
|
|
|
}
|
|
|
|
|
AMDGPU: Merge S_BUFFER_LOAD_DWORD_IMM into x2, x4
Summary:
Only constant offsets (*_IMM opcodes) are merged.
It reuses code for LDS load/store merging.
It relies on the scheduler to group loads.
The results are mixed, I think they are mostly positive. Most shaders are
affected, so here are total stats only:
SGPRS: 2072198 -> 2151462 (3.83 %)
VGPRS: 1628024 -> 1634612 (0.40 %)
Spilled SGPRs: 7883 -> 8942 (13.43 %)
Spilled VGPRs: 97 -> 101 (4.12 %)
Scratch size: 1488 -> 1492 (0.27 %) dwords per thread
Code Size: 60222620 -> 52940672 (-12.09 %) bytes
Max Waves: 374337 -> 373066 (-0.34 %)
There is 13.4% increase in SGPR spilling, DiRT Showdown spills a few more
VGPRs (now 37), but 12% decrease in code size.
These are the new stats for SGPR spilling. We already spill a lot SGPRs,
so it's uncertain whether more spilling will make any difference since
SGPRs are always spilled to VGPRs:
SGPR SPILLING APPS Shaders SpillSGPR AvgPerSh
alien_isolation 2938 100 0.0
batman_arkham_origins 589 6 0.0
bioshock-infinite 1769 4 0.0
borderlands2 3968 22 0.0
counter_strike_glob.. 1142 60 0.1
deus_ex_mankind_div.. 1410 79 0.1
dirt-showdown 533 4 0.0
dirt_rally 364 1163 3.2
divinity 1052 2 0.0
dota2 1747 7 0.0
f1-2015 776 1515 2.0
grid_autosport 1767 1505 0.9
hitman 1413 273 0.2
left_4_dead_2 1762 4 0.0
life_is_strange 1296 26 0.0
mad_max 358 96 0.3
metro_2033_redux 2670 60 0.0
payday2 1362 22 0.0
portal 474 3 0.0
saints_row_iv 1704 8 0.0
serious_sam_3_bfe 392 1348 3.4
shadow_of_mordor 1418 12 0.0
shadow_warrior 3956 239 0.1
talos_principle 324 1735 5.4
thea 172 17 0.1
tomb_raider 1449 215 0.1
total_war_warhammer 242 56 0.2
ue4_effects_cave 295 55 0.2
ue4_elemental 572 12 0.0
unigine_tropics 210 56 0.3
unigine_valley 278 152 0.5
victor_vran 1262 84 0.1
yofrankie 82 2 0.0
Reviewers: arsenm, nhaehnle
Subscribers: kzhuravl, wdng, yaxunl, dstuttard, tpr, llvm-commits, t-tye
Differential Revision: https://reviews.llvm.org/D38949
llvm-svn: 317751
2017-11-09 09:52:23 +08:00
|
|
|
bool hasSBufferLoadStoreAtomicDwordxN() const {
|
|
|
|
// Only use the "x1" variants on GFX9 or don't use the buffer variants.
|
|
|
|
// For x2 and higher variants, if the accessed region spans 2 VM pages and
|
|
|
|
// the second page is unmapped, the hw hangs.
|
|
|
|
// TODO: There is one future GFX9 chip that doesn't have this bug.
|
|
|
|
return getGeneration() != GFX9;
|
|
|
|
}
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2017-02-10 10:15:29 +08:00
|
|
|
TrapHandlerAbi getTrapHandlerAbi() const {
|
|
|
|
return isAmdHsaOS() ? TrapHandlerAbiHsa : TrapHandlerAbiNone;
|
|
|
|
}
|
|
|
|
|
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-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.
|
2017-02-02 06:59:50 +08:00
|
|
|
unsigned getMaxLocalMemSizeWithWaveCount(unsigned WaveCount,
|
|
|
|
const Function &) const;
|
2016-05-17 05:19:59 +08:00
|
|
|
|
|
|
|
/// Inverse of getMaxLocalMemWithWaveCount. Return the maximum wavecount if
|
|
|
|
/// the given LDS memory size is the only constraint.
|
2017-02-02 06:59:50 +08:00
|
|
|
unsigned getOccupancyWithLocalMemSize(uint32_t Bytes, const Function &) const;
|
2016-05-17 05:19:59 +08:00
|
|
|
|
2017-03-21 21:15:46 +08:00
|
|
|
unsigned getOccupancyWithLocalMemSize(const MachineFunction &MF) const {
|
|
|
|
const auto *MFI = MF.getInfo<SIMachineFunctionInfo>();
|
|
|
|
return getOccupancyWithLocalMemSize(MFI->getLDSSize(), *MF.getFunction());
|
|
|
|
}
|
|
|
|
|
2016-11-13 15:01:11 +08:00
|
|
|
bool hasFP16Denormals() const {
|
2017-01-24 06:31:03 +08:00
|
|
|
return FP64FP16Denormals;
|
2016-11-13 15:01:11 +08:00
|
|
|
}
|
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 {
|
2017-01-24 06:31:03 +08:00
|
|
|
return FP64FP16Denormals;
|
2016-02-12 10:40:47 +08:00
|
|
|
}
|
|
|
|
|
2017-07-14 07:59:15 +08:00
|
|
|
bool supportsMinMaxDenormModes() const {
|
|
|
|
return getGeneration() >= AMDGPUSubtarget::GFX9;
|
|
|
|
}
|
|
|
|
|
2016-06-24 14:30:11 +08:00
|
|
|
bool hasFPExceptions() const {
|
|
|
|
return FPExceptions;
|
2015-03-09 23:48:09 +08:00
|
|
|
}
|
|
|
|
|
2017-02-22 07:35:48 +08:00
|
|
|
bool enableDX10Clamp() const {
|
|
|
|
return DX10Clamp;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool enableIEEEBit(const MachineFunction &MF) const {
|
|
|
|
return AMDGPU::isCompute(MF.getFunction()->getCallingConv());
|
|
|
|
}
|
|
|
|
|
2016-06-24 14:30:11 +08:00
|
|
|
bool useFlatForGlobal() const {
|
|
|
|
return FlatForGlobal;
|
2015-05-26 00:15:54 +08:00
|
|
|
}
|
|
|
|
|
2017-06-03 01:40:26 +08:00
|
|
|
bool hasAutoWaitcntBeforeBarrier() const {
|
|
|
|
return AutoWaitcntBeforeBarrier;
|
|
|
|
}
|
|
|
|
|
2017-10-14 23:59:07 +08:00
|
|
|
bool hasCodeObjectV3() const {
|
|
|
|
return CodeObjectV3;
|
|
|
|
}
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2017-02-19 02:29:53 +08:00
|
|
|
bool hasApertureRegs() const {
|
|
|
|
return HasApertureRegs;
|
|
|
|
}
|
|
|
|
|
2017-02-10 10:15:29 +08:00
|
|
|
bool isTrapHandlerEnabled() const {
|
|
|
|
return TrapHandler;
|
|
|
|
}
|
|
|
|
|
2016-06-24 14:30:11 +08:00
|
|
|
bool isXNACKEnabled() const {
|
|
|
|
return EnableXNACK;
|
|
|
|
}
|
2014-12-03 06:00:07 +08:00
|
|
|
|
2017-01-31 09:20:54 +08:00
|
|
|
bool hasFlatAddressSpace() const {
|
|
|
|
return FlatAddressSpace;
|
|
|
|
}
|
|
|
|
|
2017-05-11 05:19:05 +08:00
|
|
|
bool hasFlatInstOffsets() const {
|
|
|
|
return FlatInstOffsets;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool hasFlatGlobalInsts() const {
|
|
|
|
return FlatGlobalInsts;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool hasFlatScratchInsts() const {
|
|
|
|
return FlatScratchInsts;
|
|
|
|
}
|
|
|
|
|
2017-09-02 02:36:06 +08:00
|
|
|
bool hasD16LoadStore() const {
|
|
|
|
return getGeneration() >= GFX9;
|
|
|
|
}
|
|
|
|
|
2017-07-21 01:42:47 +08:00
|
|
|
bool hasAddNoCarry() const {
|
|
|
|
return AddNoCarryInsts;
|
|
|
|
}
|
|
|
|
|
2017-01-25 09:25:13 +08:00
|
|
|
bool isMesaKernel(const MachineFunction &MF) const {
|
|
|
|
return isMesa3DOS() && !AMDGPU::isShader(MF.getFunction()->getCallingConv());
|
|
|
|
}
|
|
|
|
|
|
|
|
// Covers VS/PS/CS graphics shaders
|
|
|
|
bool isMesaGfxShader(const MachineFunction &MF) const {
|
|
|
|
return isMesa3DOS() && AMDGPU::isShader(MF.getFunction()->getCallingConv());
|
|
|
|
}
|
|
|
|
|
|
|
|
bool isAmdCodeObjectV2(const MachineFunction &MF) const {
|
|
|
|
return isAmdHsaOS() || isMesaKernel(MF);
|
2016-09-17 05:34:26 +08:00
|
|
|
}
|
|
|
|
|
2017-11-07 01:04:37 +08:00
|
|
|
bool hasMad64_32() const {
|
|
|
|
return getGeneration() >= SEA_ISLANDS;
|
|
|
|
}
|
|
|
|
|
2017-02-01 08:42:40 +08:00
|
|
|
bool hasFminFmaxLegacy() const {
|
|
|
|
return getGeneration() < AMDGPUSubtarget::VOLCANIC_ISLANDS;
|
|
|
|
}
|
|
|
|
|
2017-05-24 03:54:48 +08:00
|
|
|
bool hasSDWA() const {
|
|
|
|
return HasSDWA;
|
|
|
|
}
|
|
|
|
|
2017-06-22 14:26:41 +08:00
|
|
|
bool hasSDWAOmod() const {
|
|
|
|
return HasSDWAOmod;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool hasSDWAScalar() const {
|
|
|
|
return HasSDWAScalar;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool hasSDWASdst() const {
|
|
|
|
return HasSDWASdst;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool hasSDWAMac() const {
|
|
|
|
return HasSDWAMac;
|
|
|
|
}
|
|
|
|
|
[AMDGPU] SDWA: several fixes for V_CVT and VOPC instructions
Summary:
1. Instruction V_CVT_U32_F32 allow omod operand (see SIInstrInfo.td:1435). In fact this operand shouldn't be allowed here. This fix checks if SDWA pseudo instruction has OMod operand and then copy it.
2. There were several problems with support of VOPC instructions in SDWA peephole pass.
Reviewers: tstellar, arsenm, vpykhtin, airlied, kzhuravl
Subscribers: wdng, nhaehnle, yaxunl, dstuttard, tpr, sarnex, t-tye
Differential Revision: https://reviews.llvm.org/D34626
llvm-svn: 306413
2017-06-27 23:02:23 +08:00
|
|
|
bool hasSDWAOutModsVOPC() const {
|
|
|
|
return HasSDWAOutModsVOPC;
|
2017-06-22 14:26:41 +08:00
|
|
|
}
|
|
|
|
|
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.
|
2017-01-25 09:25:13 +08:00
|
|
|
unsigned getExplicitKernelArgOffset(const MachineFunction &MF) const {
|
|
|
|
return isAmdCodeObjectV2(MF) ? 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;
|
|
|
|
}
|
|
|
|
|
2017-01-25 09:25:13 +08:00
|
|
|
unsigned getImplicitArgNumBytes(const MachineFunction &MF) const {
|
|
|
|
if (isMesaKernel(MF))
|
2016-09-23 09:33:26 +08:00
|
|
|
return 16;
|
|
|
|
if (isAmdHsaOS() && isOpenCLEnv())
|
|
|
|
return 32;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2017-04-18 03:48:24 +08:00
|
|
|
// Scratch is allocated in 256 dword per wave blocks for the entire
|
|
|
|
// wavefront. When viewed from the perspecive of an arbitrary workitem, this
|
|
|
|
// is 4-byte aligned.
|
2016-06-24 14:30:11 +08:00
|
|
|
unsigned getStackAlignment() const {
|
2017-04-18 03:48:24 +08:00
|
|
|
return 4;
|
2016-06-24 14:30:11 +08:00
|
|
|
}
|
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
|
|
|
|
2017-02-08 22:05:23 +08:00
|
|
|
void setScalarizeGlobalBehavior(bool b) { ScalarizeGlobal = b;}
|
|
|
|
bool getScalarizeGlobalBehavior() const { return ScalarizeGlobal;}
|
|
|
|
|
2016-09-07 04:22:28 +08:00
|
|
|
/// \returns Number of execution units per compute unit supported by the
|
|
|
|
/// subtarget.
|
|
|
|
unsigned getEUsPerCU() const {
|
2017-02-08 22:05:23 +08:00
|
|
|
return AMDGPU::IsaInfo::getEUsPerCU(getFeatureBits());
|
2016-09-07 04:22:28 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/// \returns Maximum number of work groups per compute unit supported by the
|
2017-02-08 22:05:23 +08:00
|
|
|
/// subtarget and limited by given \p FlatWorkGroupSize.
|
2016-09-07 04:22:28 +08:00
|
|
|
unsigned getMaxWorkGroupsPerCU(unsigned FlatWorkGroupSize) const {
|
2017-02-08 22:05:23 +08:00
|
|
|
return AMDGPU::IsaInfo::getMaxWorkGroupsPerCU(getFeatureBits(),
|
|
|
|
FlatWorkGroupSize);
|
2016-09-07 04:22:28 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/// \returns Maximum number of waves per compute unit supported by the
|
|
|
|
/// subtarget without any kind of limitation.
|
|
|
|
unsigned getMaxWavesPerCU() const {
|
2017-02-08 22:05:23 +08:00
|
|
|
return AMDGPU::IsaInfo::getMaxWavesPerCU(getFeatureBits());
|
2016-09-07 04:22:28 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/// \returns Maximum number of waves per compute unit supported by the
|
2017-02-08 22:05:23 +08:00
|
|
|
/// subtarget and limited by given \p FlatWorkGroupSize.
|
2016-09-07 04:22:28 +08:00
|
|
|
unsigned getMaxWavesPerCU(unsigned FlatWorkGroupSize) const {
|
2017-02-08 22:05:23 +08:00
|
|
|
return AMDGPU::IsaInfo::getMaxWavesPerCU(getFeatureBits(),
|
|
|
|
FlatWorkGroupSize);
|
2016-09-07 04:22:28 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/// \returns Minimum number of waves per execution unit supported by the
|
|
|
|
/// subtarget.
|
|
|
|
unsigned getMinWavesPerEU() const {
|
2017-02-08 22:05:23 +08:00
|
|
|
return AMDGPU::IsaInfo::getMinWavesPerEU(getFeatureBits());
|
2016-09-07 04:22:28 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/// \returns Maximum number of waves per execution unit supported by the
|
|
|
|
/// subtarget without any kind of limitation.
|
|
|
|
unsigned getMaxWavesPerEU() const {
|
2017-02-08 22:05:23 +08:00
|
|
|
return AMDGPU::IsaInfo::getMaxWavesPerEU(getFeatureBits());
|
2016-09-07 04:22:28 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/// \returns Maximum number of waves per execution unit supported by the
|
2017-02-08 22:05:23 +08:00
|
|
|
/// subtarget and limited by given \p FlatWorkGroupSize.
|
2016-09-07 04:22:28 +08:00
|
|
|
unsigned getMaxWavesPerEU(unsigned FlatWorkGroupSize) const {
|
2017-02-08 22:05:23 +08:00
|
|
|
return AMDGPU::IsaInfo::getMaxWavesPerEU(getFeatureBits(),
|
|
|
|
FlatWorkGroupSize);
|
2016-09-07 04:22:28 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/// \returns Minimum flat work group size supported by the subtarget.
|
|
|
|
unsigned getMinFlatWorkGroupSize() const {
|
2017-02-08 22:05:23 +08:00
|
|
|
return AMDGPU::IsaInfo::getMinFlatWorkGroupSize(getFeatureBits());
|
2016-09-07 04:22:28 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/// \returns Maximum flat work group size supported by the subtarget.
|
|
|
|
unsigned getMaxFlatWorkGroupSize() const {
|
2017-02-08 22:05:23 +08:00
|
|
|
return AMDGPU::IsaInfo::getMaxFlatWorkGroupSize(getFeatureBits());
|
2016-09-07 04:22:28 +08:00
|
|
|
}
|
|
|
|
|
2017-02-08 22:05:23 +08:00
|
|
|
/// \returns Number of waves per work group supported by the subtarget and
|
|
|
|
/// limited by given \p FlatWorkGroupSize.
|
2016-09-07 04:22:28 +08:00
|
|
|
unsigned getWavesPerWorkGroup(unsigned FlatWorkGroupSize) const {
|
2017-02-08 22:05:23 +08:00
|
|
|
return AMDGPU::IsaInfo::getWavesPerWorkGroup(getFeatureBits(),
|
|
|
|
FlatWorkGroupSize);
|
2016-09-07 04:22:28 +08:00
|
|
|
}
|
|
|
|
|
2017-10-24 01:09:35 +08:00
|
|
|
/// \returns Default range flat work group size for a calling convention.
|
|
|
|
std::pair<unsigned, unsigned> getDefaultFlatWorkGroupSize(CallingConv::ID CC) const;
|
|
|
|
|
2016-09-07 04:22:28 +08:00
|
|
|
/// \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;
|
2017-04-13 04:48:56 +08:00
|
|
|
|
|
|
|
/// Creates value range metadata on an workitemid.* inrinsic call or load.
|
|
|
|
bool makeLIDRangeMetadata(Instruction *I) 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 {
|
|
|
|
private:
|
|
|
|
SIInstrInfo InstrInfo;
|
|
|
|
SIFrameLowering FrameLowering;
|
|
|
|
SITargetLowering TLInfo;
|
2017-08-16 06:31:51 +08:00
|
|
|
|
|
|
|
/// GlobalISel related APIs.
|
|
|
|
std::unique_ptr<AMDGPUCallLowering> CallLoweringInfo;
|
|
|
|
std::unique_ptr<InstructionSelector> InstSelector;
|
|
|
|
std::unique_ptr<LegalizerInfo> Legalizer;
|
|
|
|
std::unique_ptr<RegisterBankInfo> RegBankInfo;
|
2016-06-24 14:30:11 +08:00
|
|
|
|
|
|
|
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 {
|
2017-08-16 06:31:51 +08:00
|
|
|
return CallLoweringInfo.get();
|
2015-02-05 07:14:18 +08:00
|
|
|
}
|
2015-06-27 05:15:03 +08:00
|
|
|
|
Re-commit AMDGPU/GlobalISel: Add support for simple shaders
Fix build when global-isel is disabled and fix a warning.
Summary: We can select constant/global G_LOAD, global G_STORE, and G_GEP.
Reviewers: qcolombet, MatzeB, t.p.northover, ab, arsenm
Subscribers: mehdi_amini, vkalintiris, kzhuravl, wdng, nhaehnle, mgorny, yaxunl, tony-tye, modocache, llvm-commits, dberris
Differential Revision: https://reviews.llvm.org/D26730
llvm-svn: 293551
2017-01-31 05:56:46 +08:00
|
|
|
const InstructionSelector *getInstructionSelector() const override {
|
2017-08-16 06:31:51 +08:00
|
|
|
return InstSelector.get();
|
Re-commit AMDGPU/GlobalISel: Add support for simple shaders
Fix build when global-isel is disabled and fix a warning.
Summary: We can select constant/global G_LOAD, global G_STORE, and G_GEP.
Reviewers: qcolombet, MatzeB, t.p.northover, ab, arsenm
Subscribers: mehdi_amini, vkalintiris, kzhuravl, wdng, nhaehnle, mgorny, yaxunl, tony-tye, modocache, llvm-commits, dberris
Differential Revision: https://reviews.llvm.org/D26730
llvm-svn: 293551
2017-01-31 05:56:46 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
const LegalizerInfo *getLegalizerInfo() const override {
|
2017-08-16 06:31:51 +08:00
|
|
|
return Legalizer.get();
|
Re-commit AMDGPU/GlobalISel: Add support for simple shaders
Fix build when global-isel is disabled and fix a warning.
Summary: We can select constant/global G_LOAD, global G_STORE, and G_GEP.
Reviewers: qcolombet, MatzeB, t.p.northover, ab, arsenm
Subscribers: mehdi_amini, vkalintiris, kzhuravl, wdng, nhaehnle, mgorny, yaxunl, tony-tye, modocache, llvm-commits, dberris
Differential Revision: https://reviews.llvm.org/D26730
llvm-svn: 293551
2017-01-31 05:56:46 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
const RegisterBankInfo *getRegBankInfo() const override {
|
2017-08-16 06:31:51 +08:00
|
|
|
return RegBankInfo.get();
|
Re-commit AMDGPU/GlobalISel: Add support for simple shaders
Fix build when global-isel is disabled and fix a warning.
Summary: We can select constant/global G_LOAD, global G_STORE, and G_GEP.
Reviewers: qcolombet, MatzeB, t.p.northover, ab, arsenm
Subscribers: mehdi_amini, vkalintiris, kzhuravl, wdng, nhaehnle, mgorny, yaxunl, tony-tye, modocache, llvm-commits, dberris
Differential Revision: https://reviews.llvm.org/D26730
llvm-svn: 293551
2017-01-31 05:56:46 +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
|
|
|
}
|
|
|
|
|
2017-01-25 12:25:02 +08:00
|
|
|
// XXX - Why is this here if it isn't in the default pass set?
|
|
|
|
bool enableEarlyIfConversion() const override {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2016-06-24 14:30:11 +08:00
|
|
|
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 hasSMemRealTime() const {
|
|
|
|
return HasSMemRealTime;
|
|
|
|
}
|
|
|
|
|
2016-10-13 02:00:51 +08:00
|
|
|
bool hasMovrel() const {
|
|
|
|
return HasMovrel;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool hasVGPRIndexMode() const {
|
|
|
|
return HasVGPRIndexMode;
|
|
|
|
}
|
|
|
|
|
2017-03-22 01:00:32 +08:00
|
|
|
bool useVGPRIndexMode(bool UserEnable) const {
|
|
|
|
return !hasMovrel() || (UserEnable && 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;
|
|
|
|
}
|
|
|
|
|
2017-01-20 18:01:25 +08:00
|
|
|
bool hasDPP() const {
|
|
|
|
return HasDPP;
|
|
|
|
}
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2017-02-19 02:29:53 +08:00
|
|
|
bool hasSMovFedHazard() const {
|
|
|
|
return getGeneration() >= AMDGPUSubtarget::GFX9;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool hasReadM0Hazard() const {
|
|
|
|
return getGeneration() >= AMDGPUSubtarget::GFX9;
|
|
|
|
}
|
|
|
|
|
2017-07-28 23:52:08 +08:00
|
|
|
unsigned getKernArgSegmentSize(const MachineFunction &MF,
|
|
|
|
unsigned ExplictArgBytes) const;
|
2016-09-23 09:33:26 +08:00
|
|
|
|
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
|
|
|
|
2017-02-19 02:29:53 +08:00
|
|
|
/// \returns true if the flat_scratch register should be initialized with the
|
|
|
|
/// pointer to the wave's scratch memory rather than a size and offset.
|
|
|
|
bool flatScratchIsPointer() const {
|
|
|
|
return getGeneration() >= GFX9;
|
2016-10-01 00:50:36 +08:00
|
|
|
}
|
2016-10-29 04:31:47 +08:00
|
|
|
|
2017-02-08 21:02:33 +08:00
|
|
|
/// \returns SGPR allocation granularity supported by the subtarget.
|
|
|
|
unsigned getSGPRAllocGranule() const {
|
2017-02-08 22:05:23 +08:00
|
|
|
return AMDGPU::IsaInfo::getSGPRAllocGranule(getFeatureBits());
|
2017-02-08 21:18:40 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/// \returns SGPR encoding granularity supported by the subtarget.
|
|
|
|
unsigned getSGPREncodingGranule() const {
|
2017-02-08 22:05:23 +08:00
|
|
|
return AMDGPU::IsaInfo::getSGPREncodingGranule(getFeatureBits());
|
2017-02-08 21:02:33 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/// \returns Total number of SGPRs supported by the subtarget.
|
|
|
|
unsigned getTotalNumSGPRs() const {
|
2017-02-08 22:05:23 +08:00
|
|
|
return AMDGPU::IsaInfo::getTotalNumSGPRs(getFeatureBits());
|
2017-02-08 21:02:33 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/// \returns Addressable number of SGPRs supported by the subtarget.
|
|
|
|
unsigned getAddressableNumSGPRs() const {
|
2017-02-08 22:05:23 +08:00
|
|
|
return AMDGPU::IsaInfo::getAddressableNumSGPRs(getFeatureBits());
|
2017-02-08 21:02:33 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/// \returns Minimum number of SGPRs that meets the given number of waves per
|
|
|
|
/// execution unit requirement supported by the subtarget.
|
2017-02-08 22:05:23 +08:00
|
|
|
unsigned getMinNumSGPRs(unsigned WavesPerEU) const {
|
|
|
|
return AMDGPU::IsaInfo::getMinNumSGPRs(getFeatureBits(), WavesPerEU);
|
|
|
|
}
|
2017-02-08 21:02:33 +08:00
|
|
|
|
|
|
|
/// \returns Maximum number of SGPRs that meets the given number of waves per
|
|
|
|
/// execution unit requirement supported by the subtarget.
|
2017-02-08 22:05:23 +08:00
|
|
|
unsigned getMaxNumSGPRs(unsigned WavesPerEU, bool Addressable) const {
|
|
|
|
return AMDGPU::IsaInfo::getMaxNumSGPRs(getFeatureBits(), WavesPerEU,
|
|
|
|
Addressable);
|
|
|
|
}
|
2017-02-08 21:02:33 +08:00
|
|
|
|
|
|
|
/// \returns Reserved number of SGPRs for given function \p MF.
|
|
|
|
unsigned getReservedNumSGPRs(const MachineFunction &MF) const;
|
|
|
|
|
|
|
|
/// \returns Maximum number of SGPRs that meets number of waves per execution
|
|
|
|
/// unit requirement for function \p MF, or number of SGPRs explicitly
|
|
|
|
/// requested using "amdgpu-num-sgpr" attribute attached to function \p MF.
|
|
|
|
///
|
|
|
|
/// \returns Value that meets number of waves per execution unit requirement
|
|
|
|
/// if explicitly requested value cannot be converted to integer, violates
|
|
|
|
/// subtarget's specifications, or does not meet number of waves per execution
|
|
|
|
/// unit requirement.
|
|
|
|
unsigned getMaxNumSGPRs(const MachineFunction &MF) const;
|
|
|
|
|
|
|
|
/// \returns VGPR allocation granularity supported by the subtarget.
|
|
|
|
unsigned getVGPRAllocGranule() const {
|
2017-06-06 13:08:36 +08:00
|
|
|
return AMDGPU::IsaInfo::getVGPRAllocGranule(getFeatureBits());
|
2017-02-08 21:02:33 +08:00
|
|
|
}
|
|
|
|
|
2017-02-08 21:18:40 +08:00
|
|
|
/// \returns VGPR encoding granularity supported by the subtarget.
|
|
|
|
unsigned getVGPREncodingGranule() const {
|
2017-02-08 22:05:23 +08:00
|
|
|
return AMDGPU::IsaInfo::getVGPREncodingGranule(getFeatureBits());
|
2017-02-08 21:18:40 +08:00
|
|
|
}
|
|
|
|
|
2017-02-08 21:02:33 +08:00
|
|
|
/// \returns Total number of VGPRs supported by the subtarget.
|
|
|
|
unsigned getTotalNumVGPRs() const {
|
2017-02-08 22:05:23 +08:00
|
|
|
return AMDGPU::IsaInfo::getTotalNumVGPRs(getFeatureBits());
|
2017-02-08 21:02:33 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/// \returns Addressable number of VGPRs supported by the subtarget.
|
|
|
|
unsigned getAddressableNumVGPRs() const {
|
2017-02-08 22:05:23 +08:00
|
|
|
return AMDGPU::IsaInfo::getAddressableNumVGPRs(getFeatureBits());
|
2017-02-08 21:02:33 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/// \returns Minimum number of VGPRs that meets given number of waves per
|
|
|
|
/// execution unit requirement supported by the subtarget.
|
2017-02-08 22:05:23 +08:00
|
|
|
unsigned getMinNumVGPRs(unsigned WavesPerEU) const {
|
|
|
|
return AMDGPU::IsaInfo::getMinNumVGPRs(getFeatureBits(), WavesPerEU);
|
|
|
|
}
|
2017-02-08 21:02:33 +08:00
|
|
|
|
|
|
|
/// \returns Maximum number of VGPRs that meets given number of waves per
|
|
|
|
/// execution unit requirement supported by the subtarget.
|
2017-02-08 22:05:23 +08:00
|
|
|
unsigned getMaxNumVGPRs(unsigned WavesPerEU) const {
|
|
|
|
return AMDGPU::IsaInfo::getMaxNumVGPRs(getFeatureBits(), WavesPerEU);
|
|
|
|
}
|
2017-02-08 21:02:33 +08:00
|
|
|
|
|
|
|
/// \returns Reserved number of VGPRs for given function \p MF.
|
|
|
|
unsigned getReservedNumVGPRs(const MachineFunction &MF) const {
|
|
|
|
return debuggerReserveRegs() ? 4 : 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/// \returns Maximum number of VGPRs that meets number of waves per execution
|
|
|
|
/// unit requirement for function \p MF, or number of VGPRs explicitly
|
|
|
|
/// requested using "amdgpu-num-vgpr" attribute attached to function \p MF.
|
|
|
|
///
|
|
|
|
/// \returns Value that meets number of waves per execution unit requirement
|
|
|
|
/// if explicitly requested value cannot be converted to integer, violates
|
|
|
|
/// subtarget's specifications, or does not meet number of waves per execution
|
|
|
|
/// unit requirement.
|
|
|
|
unsigned getMaxNumVGPRs(const MachineFunction &MF) const;
|
2017-09-20 04:54:38 +08:00
|
|
|
|
|
|
|
void getPostRAMutations(
|
|
|
|
std::vector<std::unique_ptr<ScheduleDAGMutation>> &Mutations)
|
|
|
|
const override;
|
2012-12-12 05:25:42 +08:00
|
|
|
};
|
|
|
|
|
2016-12-10 06:06:55 +08:00
|
|
|
} // end namespace llvm
|
2012-12-12 05:25:42 +08:00
|
|
|
|
2016-12-10 06:06:55 +08:00
|
|
|
#endif // LLVM_LIB_TARGET_AMDGPU_AMDGPUSUBTARGET_H
|