#ifndef LLVM_LIB_TARGET_AMDGPU_UTILS_AMDGPUBASEINFO_H
#define LLVM_LIB_TARGET_AMDGPU_UTILS_AMDGPUBASEINFO_H
#include "SIDefines.h"
#include "llvm/IR/CallingConv.h"
#include "llvm/Support/Alignment.h"
struct amd_kernel_code_t;
namespace llvm {
struct Align;
class Argument;
class Function;
class GCNSubtarget;
class GlobalValue;
class MCRegisterClass;
class MCRegisterInfo;
class MCSubtargetInfo;
class StringRef;
class Triple;
namespace amdhsa {
struct kernel_descriptor_t;
}
namespace AMDGPU {
struct IsaVersion;
Optional<uint8_t> getHsaAbiVersion(const MCSubtargetInfo *STI);
bool isHsaAbiVersion2(const MCSubtargetInfo *STI);
bool isHsaAbiVersion3(const MCSubtargetInfo *STI);
bool isHsaAbiVersion4(const MCSubtargetInfo *STI);
bool isHsaAbiVersion5(const MCSubtargetInfo *STI);
bool isHsaAbiVersion3AndAbove(const MCSubtargetInfo *STI);
unsigned getMultigridSyncArgImplicitArgPosition();
unsigned getHostcallImplicitArgPosition();
unsigned getAmdhsaCodeObjectVersion();
struct GcnBufferFormatInfo {
unsigned Format;
unsigned BitsPerComp;
unsigned NumComponents;
unsigned NumFormat;
unsigned DataFormat;
};
struct MAIInstInfo {
uint16_t Opcode;
bool is_dgemm;
bool is_gfx940_xdl;
};
#define GET_MIMGBaseOpcode_DECL
#define GET_MIMGDim_DECL
#define GET_MIMGEncoding_DECL
#define GET_MIMGLZMapping_DECL
#define GET_MIMGMIPMapping_DECL
#define GET_MIMGBiASMapping_DECL
#define GET_MAIInstInfoTable_DECL
#include "AMDGPUGenSearchableTables.inc"
namespace IsaInfo {
enum {
FIXED_NUM_SGPRS_FOR_INIT_BUG = 96,
TRAP_NUM_SGPRS = 16
};
enum class TargetIDSetting {
Unsupported,
Any,
Off,
On
};
class AMDGPUTargetID {
private:
const MCSubtargetInfo &STI;
TargetIDSetting XnackSetting;
TargetIDSetting SramEccSetting;
public:
explicit AMDGPUTargetID(const MCSubtargetInfo &STI);
~AMDGPUTargetID() = default;
bool isXnackSupported() const {
return XnackSetting != TargetIDSetting::Unsupported;
}
bool isXnackOnOrAny() const {
return XnackSetting == TargetIDSetting::On ||
XnackSetting == TargetIDSetting::Any;
}
bool isXnackOnOrOff() const {
return getXnackSetting() == TargetIDSetting::On ||
getXnackSetting() == TargetIDSetting::Off;
}
TargetIDSetting getXnackSetting() const {
return XnackSetting;
}
void setXnackSetting(TargetIDSetting NewXnackSetting) {
XnackSetting = NewXnackSetting;
}
bool isSramEccSupported() const {
return SramEccSetting != TargetIDSetting::Unsupported;
}
bool isSramEccOnOrAny() const {
return SramEccSetting == TargetIDSetting::On ||
SramEccSetting == TargetIDSetting::Any;
}
bool isSramEccOnOrOff() const {
return getSramEccSetting() == TargetIDSetting::On ||
getSramEccSetting() == TargetIDSetting::Off;
}
TargetIDSetting getSramEccSetting() const {
return SramEccSetting;
}
void setSramEccSetting(TargetIDSetting NewSramEccSetting) {
SramEccSetting = NewSramEccSetting;
}
void setTargetIDFromFeaturesString(StringRef FS);
void setTargetIDFromTargetIDStream(StringRef TargetID);
std::string toString() const;
};
unsigned getWavefrontSize(const MCSubtargetInfo *STI);
unsigned getLocalMemorySize(const MCSubtargetInfo *STI);
unsigned getEUsPerCU(const MCSubtargetInfo *STI);
unsigned getMaxWorkGroupsPerCU(const MCSubtargetInfo *STI,
unsigned FlatWorkGroupSize);
unsigned getMinWavesPerEU(const MCSubtargetInfo *STI);
unsigned getMaxWavesPerEU(const MCSubtargetInfo *STI);
unsigned getWavesPerEUForWorkGroup(const MCSubtargetInfo *STI,
unsigned FlatWorkGroupSize);
unsigned getMinFlatWorkGroupSize(const MCSubtargetInfo *STI);
unsigned getMaxFlatWorkGroupSize(const MCSubtargetInfo *STI);
unsigned getWavesPerWorkGroup(const MCSubtargetInfo *STI,
unsigned FlatWorkGroupSize);
unsigned getSGPRAllocGranule(const MCSubtargetInfo *STI);
unsigned getSGPREncodingGranule(const MCSubtargetInfo *STI);
unsigned getTotalNumSGPRs(const MCSubtargetInfo *STI);
unsigned getAddressableNumSGPRs(const MCSubtargetInfo *STI);
unsigned getMinNumSGPRs(const MCSubtargetInfo *STI, unsigned WavesPerEU);
unsigned getMaxNumSGPRs(const MCSubtargetInfo *STI, unsigned WavesPerEU,
bool Addressable);
unsigned getNumExtraSGPRs(const MCSubtargetInfo *STI, bool VCCUsed,
bool FlatScrUsed, bool XNACKUsed);
unsigned getNumExtraSGPRs(const MCSubtargetInfo *STI, bool VCCUsed,
bool FlatScrUsed);
unsigned getNumSGPRBlocks(const MCSubtargetInfo *STI, unsigned NumSGPRs);
unsigned getVGPRAllocGranule(const MCSubtargetInfo *STI,
Optional<bool> EnableWavefrontSize32 = None);
unsigned getVGPREncodingGranule(const MCSubtargetInfo *STI,
Optional<bool> EnableWavefrontSize32 = None);
unsigned getTotalNumVGPRs(const MCSubtargetInfo *STI);
unsigned getAddressableNumVGPRs(const MCSubtargetInfo *STI);
unsigned getMinNumVGPRs(const MCSubtargetInfo *STI, unsigned WavesPerEU);
unsigned getMaxNumVGPRs(const MCSubtargetInfo *STI, unsigned WavesPerEU);
unsigned getNumVGPRBlocks(const MCSubtargetInfo *STI, unsigned NumSGPRs,
Optional<bool> EnableWavefrontSize32 = None);
}
LLVM_READONLY
int16_t getNamedOperandIdx(uint16_t Opcode, uint16_t NamedIdx);
LLVM_READONLY
int getSOPPWithRelaxation(uint16_t Opcode);
struct MIMGBaseOpcodeInfo {
MIMGBaseOpcode BaseOpcode;
bool Store;
bool Atomic;
bool AtomicX2;
bool Sampler;
bool Gather4;
uint8_t NumExtraArgs;
bool Gradients;
bool G16;
bool Coordinates;
bool LodOrClampOrMip;
bool HasD16;
bool MSAA;
bool BVH;
};
LLVM_READONLY
const MIMGBaseOpcodeInfo *getMIMGBaseOpcode(unsigned Opc);
LLVM_READONLY
const MIMGBaseOpcodeInfo *getMIMGBaseOpcodeInfo(unsigned BaseOpcode);
struct MIMGDimInfo {
MIMGDim Dim;
uint8_t NumCoords;
uint8_t NumGradients;
bool MSAA;
bool DA;
uint8_t Encoding;
const char *AsmSuffix;
};
LLVM_READONLY
const MIMGDimInfo *getMIMGDimInfo(unsigned DimEnum);
LLVM_READONLY
const MIMGDimInfo *getMIMGDimInfoByEncoding(uint8_t DimEnc);
LLVM_READONLY
const MIMGDimInfo *getMIMGDimInfoByAsmSuffix(StringRef AsmSuffix);
struct MIMGLZMappingInfo {
MIMGBaseOpcode L;
MIMGBaseOpcode LZ;
};
struct MIMGMIPMappingInfo {
MIMGBaseOpcode MIP;
MIMGBaseOpcode NONMIP;
};
struct MIMGBiasMappingInfo {
MIMGBaseOpcode Bias;
MIMGBaseOpcode NoBias;
};
struct MIMGOffsetMappingInfo {
MIMGBaseOpcode Offset;
MIMGBaseOpcode NoOffset;
};
struct MIMGG16MappingInfo {
MIMGBaseOpcode G;
MIMGBaseOpcode G16;
};
LLVM_READONLY
const MIMGLZMappingInfo *getMIMGLZMappingInfo(unsigned L);
struct WMMAOpcodeMappingInfo {
unsigned Opcode2Addr;
unsigned Opcode3Addr;
};
LLVM_READONLY
const MIMGMIPMappingInfo *getMIMGMIPMappingInfo(unsigned MIP);
LLVM_READONLY
const MIMGBiasMappingInfo *getMIMGBiasMappingInfo(unsigned Bias);
LLVM_READONLY
const MIMGOffsetMappingInfo *getMIMGOffsetMappingInfo(unsigned Offset);
LLVM_READONLY
const MIMGG16MappingInfo *getMIMGG16MappingInfo(unsigned G);
LLVM_READONLY
int getMIMGOpcode(unsigned BaseOpcode, unsigned MIMGEncoding,
unsigned VDataDwords, unsigned VAddrDwords);
LLVM_READONLY
int getMaskedMIMGOp(unsigned Opc, unsigned NewChannels);
LLVM_READONLY
unsigned getAddrSizeMIMGOp(const MIMGBaseOpcodeInfo *BaseOpcode,
const MIMGDimInfo *Dim, bool IsA16,
bool IsG16Supported);
struct MIMGInfo {
uint16_t Opcode;
uint16_t BaseOpcode;
uint8_t MIMGEncoding;
uint8_t VDataDwords;
uint8_t VAddrDwords;
uint8_t VAddrOperands;
};
LLVM_READONLY
const MIMGInfo *getMIMGInfo(unsigned Opc);
LLVM_READONLY
int getMTBUFBaseOpcode(unsigned Opc);
LLVM_READONLY
int getMTBUFOpcode(unsigned BaseOpc, unsigned Elements);
LLVM_READONLY
int getMTBUFElements(unsigned Opc);
LLVM_READONLY
bool getMTBUFHasVAddr(unsigned Opc);
LLVM_READONLY
bool getMTBUFHasSrsrc(unsigned Opc);
LLVM_READONLY
bool getMTBUFHasSoffset(unsigned Opc);
LLVM_READONLY
int getMUBUFBaseOpcode(unsigned Opc);
LLVM_READONLY
int getMUBUFOpcode(unsigned BaseOpc, unsigned Elements);
LLVM_READONLY
int getMUBUFElements(unsigned Opc);
LLVM_READONLY
bool getMUBUFHasVAddr(unsigned Opc);
LLVM_READONLY
bool getMUBUFHasSrsrc(unsigned Opc);
LLVM_READONLY
bool getMUBUFHasSoffset(unsigned Opc);
LLVM_READONLY
bool getMUBUFIsBufferInv(unsigned Opc);
LLVM_READONLY
bool getSMEMIsBuffer(unsigned Opc);
LLVM_READONLY
bool getVOP1IsSingle(unsigned Opc);
LLVM_READONLY
bool getVOP2IsSingle(unsigned Opc);
LLVM_READONLY
bool getVOP3IsSingle(unsigned Opc);
LLVM_READONLY
bool isVOPC64DPP(unsigned Opc);
LLVM_READONLY
bool getMAIIsDGEMM(unsigned Opc);
LLVM_READONLY
bool getMAIIsGFX940XDL(unsigned Opc);
struct CanBeVOPD {
bool X;
bool Y;
};
LLVM_READONLY
CanBeVOPD getCanBeVOPD(unsigned Opc);
LLVM_READONLY
const GcnBufferFormatInfo *getGcnBufferFormatInfo(uint8_t BitsPerComp,
uint8_t NumComponents,
uint8_t NumFormat,
const MCSubtargetInfo &STI);
LLVM_READONLY
const GcnBufferFormatInfo *getGcnBufferFormatInfo(uint8_t Format,
const MCSubtargetInfo &STI);
LLVM_READONLY
int getMCOpcode(uint16_t Opcode, unsigned Gen);
LLVM_READONLY
unsigned getVOPDOpcode(unsigned Opc);
LLVM_READONLY
int getVOPDFull(unsigned OpX, unsigned OpY);
LLVM_READONLY
unsigned mapWMMA2AddrTo3AddrOpcode(unsigned Opc);
LLVM_READONLY
unsigned mapWMMA3AddrTo2AddrOpcode(unsigned Opc);
void initDefaultAMDKernelCodeT(amd_kernel_code_t &Header,
const MCSubtargetInfo *STI);
amdhsa::kernel_descriptor_t getDefaultAmdhsaKernelDescriptor(
const MCSubtargetInfo *STI);
bool isGroupSegment(const GlobalValue *GV);
bool isGlobalSegment(const GlobalValue *GV);
bool isReadOnlySegment(const GlobalValue *GV);
bool shouldEmitConstantsToTextSection(const Triple &TT);
int getIntegerAttribute(const Function &F, StringRef Name, int Default);
std::pair<int, int> getIntegerPairAttribute(const Function &F,
StringRef Name,
std::pair<int, int> Default,
bool OnlyFirstRequired = false);
struct Waitcnt {
unsigned VmCnt = ~0u;
unsigned ExpCnt = ~0u;
unsigned LgkmCnt = ~0u;
unsigned VsCnt = ~0u;
Waitcnt() = default;
Waitcnt(unsigned VmCnt, unsigned ExpCnt, unsigned LgkmCnt, unsigned VsCnt)
: VmCnt(VmCnt), ExpCnt(ExpCnt), LgkmCnt(LgkmCnt), VsCnt(VsCnt) {}
static Waitcnt allZero(bool HasVscnt) {
return Waitcnt(0, 0, 0, HasVscnt ? 0 : ~0u);
}
static Waitcnt allZeroExceptVsCnt() { return Waitcnt(0, 0, 0, ~0u); }
bool hasWait() const {
return VmCnt != ~0u || ExpCnt != ~0u || LgkmCnt != ~0u || VsCnt != ~0u;
}
bool hasWaitExceptVsCnt() const {
return VmCnt != ~0u || ExpCnt != ~0u || LgkmCnt != ~0u;
}
bool hasWaitVsCnt() const {
return VsCnt != ~0u;
}
bool dominates(const Waitcnt &Other) const {
return VmCnt <= Other.VmCnt && ExpCnt <= Other.ExpCnt &&
LgkmCnt <= Other.LgkmCnt && VsCnt <= Other.VsCnt;
}
Waitcnt combined(const Waitcnt &Other) const {
return Waitcnt(std::min(VmCnt, Other.VmCnt), std::min(ExpCnt, Other.ExpCnt),
std::min(LgkmCnt, Other.LgkmCnt),
std::min(VsCnt, Other.VsCnt));
}
};
unsigned getVmcntBitMask(const IsaVersion &Version);
unsigned getExpcntBitMask(const IsaVersion &Version);
unsigned getLgkmcntBitMask(const IsaVersion &Version);
unsigned getWaitcntBitMask(const IsaVersion &Version);
unsigned decodeVmcnt(const IsaVersion &Version, unsigned Waitcnt);
unsigned decodeExpcnt(const IsaVersion &Version, unsigned Waitcnt);
unsigned decodeLgkmcnt(const IsaVersion &Version, unsigned Waitcnt);
void decodeWaitcnt(const IsaVersion &Version, unsigned Waitcnt,
unsigned &Vmcnt, unsigned &Expcnt, unsigned &Lgkmcnt);
Waitcnt decodeWaitcnt(const IsaVersion &Version, unsigned Encoded);
unsigned encodeVmcnt(const IsaVersion &Version, unsigned Waitcnt,
unsigned Vmcnt);
unsigned encodeExpcnt(const IsaVersion &Version, unsigned Waitcnt,
unsigned Expcnt);
unsigned encodeLgkmcnt(const IsaVersion &Version, unsigned Waitcnt,
unsigned Lgkmcnt);
unsigned encodeWaitcnt(const IsaVersion &Version,
unsigned Vmcnt, unsigned Expcnt, unsigned Lgkmcnt);
unsigned encodeWaitcnt(const IsaVersion &Version, const Waitcnt &Decoded);
namespace Hwreg {
LLVM_READONLY
int64_t getHwregId(const StringRef Name, const MCSubtargetInfo &STI);
LLVM_READNONE
bool isValidHwreg(int64_t Id);
LLVM_READNONE
bool isValidHwregOffset(int64_t Offset);
LLVM_READNONE
bool isValidHwregWidth(int64_t Width);
LLVM_READNONE
uint64_t encodeHwreg(uint64_t Id, uint64_t Offset, uint64_t Width);
LLVM_READNONE
StringRef getHwreg(unsigned Id, const MCSubtargetInfo &STI);
void decodeHwreg(unsigned Val, unsigned &Id, unsigned &Offset, unsigned &Width);
}
namespace DepCtr {
int getDefaultDepCtrEncoding(const MCSubtargetInfo &STI);
int encodeDepCtr(const StringRef Name, int64_t Val, unsigned &UsedOprMask,
const MCSubtargetInfo &STI);
bool isSymbolicDepCtrEncoding(unsigned Code, bool &HasNonDefaultVal,
const MCSubtargetInfo &STI);
bool decodeDepCtr(unsigned Code, int &Id, StringRef &Name, unsigned &Val,
bool &IsDefault, const MCSubtargetInfo &STI);
}
namespace Exp {
bool getTgtName(unsigned Id, StringRef &Name, int &Index);
LLVM_READONLY
unsigned getTgtId(const StringRef Name);
LLVM_READNONE
bool isSupportedTgtId(unsigned Id, const MCSubtargetInfo &STI);
}
namespace MTBUFFormat {
LLVM_READNONE
int64_t encodeDfmtNfmt(unsigned Dfmt, unsigned Nfmt);
void decodeDfmtNfmt(unsigned Format, unsigned &Dfmt, unsigned &Nfmt);
int64_t getDfmt(const StringRef Name);
StringRef getDfmtName(unsigned Id);
int64_t getNfmt(const StringRef Name, const MCSubtargetInfo &STI);
StringRef getNfmtName(unsigned Id, const MCSubtargetInfo &STI);
bool isValidDfmtNfmt(unsigned Val, const MCSubtargetInfo &STI);
bool isValidNfmt(unsigned Val, const MCSubtargetInfo &STI);
int64_t getUnifiedFormat(const StringRef Name, const MCSubtargetInfo &STI);
StringRef getUnifiedFormatName(unsigned Id, const MCSubtargetInfo &STI);
bool isValidUnifiedFormat(unsigned Val, const MCSubtargetInfo &STI);
int64_t convertDfmtNfmt2Ufmt(unsigned Dfmt, unsigned Nfmt,
const MCSubtargetInfo &STI);
bool isValidFormatEncoding(unsigned Val, const MCSubtargetInfo &STI);
unsigned getDefaultFormatEncoding(const MCSubtargetInfo &STI);
}
namespace SendMsg {
LLVM_READONLY
int64_t getMsgId(const StringRef Name, const MCSubtargetInfo &STI);
LLVM_READONLY
int64_t getMsgOpId(int64_t MsgId, const StringRef Name);
LLVM_READNONE
StringRef getMsgName(int64_t MsgId, const MCSubtargetInfo &STI);
LLVM_READNONE
StringRef getMsgOpName(int64_t MsgId, int64_t OpId, const MCSubtargetInfo &STI);
LLVM_READNONE
bool isValidMsgId(int64_t MsgId, const MCSubtargetInfo &STI);
LLVM_READNONE
bool isValidMsgOp(int64_t MsgId, int64_t OpId, const MCSubtargetInfo &STI,
bool Strict = true);
LLVM_READNONE
bool isValidMsgStream(int64_t MsgId, int64_t OpId, int64_t StreamId,
const MCSubtargetInfo &STI, bool Strict = true);
LLVM_READNONE
bool msgRequiresOp(int64_t MsgId, const MCSubtargetInfo &STI);
LLVM_READNONE
bool msgSupportsStream(int64_t MsgId, int64_t OpId, const MCSubtargetInfo &STI);
void decodeMsg(unsigned Val, uint16_t &MsgId, uint16_t &OpId,
uint16_t &StreamId, const MCSubtargetInfo &STI);
LLVM_READNONE
uint64_t encodeMsg(uint64_t MsgId,
uint64_t OpId,
uint64_t StreamId);
}
unsigned getInitialPSInputAddr(const Function &F);
bool getHasColorExport(const Function &F);
bool getHasDepthExport(const Function &F);
LLVM_READNONE
bool isShader(CallingConv::ID CC);
LLVM_READNONE
bool isGraphics(CallingConv::ID CC);
LLVM_READNONE
bool isCompute(CallingConv::ID CC);
LLVM_READNONE
bool isEntryFunctionCC(CallingConv::ID CC);
LLVM_READNONE
bool isModuleEntryFunctionCC(CallingConv::ID CC);
bool isKernelCC(const Function *Func);
LLVM_READNONE
inline bool isKernel(CallingConv::ID CC) {
switch (CC) {
case CallingConv::AMDGPU_KERNEL:
case CallingConv::SPIR_KERNEL:
return true;
default:
return false;
}
}
bool hasXNACK(const MCSubtargetInfo &STI);
bool hasSRAMECC(const MCSubtargetInfo &STI);
bool hasMIMG_R128(const MCSubtargetInfo &STI);
bool hasGFX10A16(const MCSubtargetInfo &STI);
bool hasG16(const MCSubtargetInfo &STI);
bool hasPackedD16(const MCSubtargetInfo &STI);
bool isSI(const MCSubtargetInfo &STI);
bool isCI(const MCSubtargetInfo &STI);
bool isVI(const MCSubtargetInfo &STI);
bool isGFX9(const MCSubtargetInfo &STI);
bool isGFX9_GFX10(const MCSubtargetInfo &STI);
bool isGFX8_GFX9_GFX10(const MCSubtargetInfo &STI);
bool isGFX8Plus(const MCSubtargetInfo &STI);
bool isGFX9Plus(const MCSubtargetInfo &STI);
bool isGFX10(const MCSubtargetInfo &STI);
bool isGFX10Plus(const MCSubtargetInfo &STI);
bool isNotGFX10Plus(const MCSubtargetInfo &STI);
bool isGFX10Before1030(const MCSubtargetInfo &STI);
bool isGFX11(const MCSubtargetInfo &STI);
bool isGFX11Plus(const MCSubtargetInfo &STI);
bool isNotGFX11Plus(const MCSubtargetInfo &STI);
bool isGCN3Encoding(const MCSubtargetInfo &STI);
bool isGFX10_AEncoding(const MCSubtargetInfo &STI);
bool isGFX10_BEncoding(const MCSubtargetInfo &STI);
bool hasGFX10_3Insts(const MCSubtargetInfo &STI);
bool isGFX90A(const MCSubtargetInfo &STI);
bool isGFX940(const MCSubtargetInfo &STI);
bool hasArchitectedFlatScratch(const MCSubtargetInfo &STI);
bool hasMAIInsts(const MCSubtargetInfo &STI);
bool hasVOPD(const MCSubtargetInfo &STI);
int getTotalNumVGPRs(bool has90AInsts, int32_t ArgNumAGPR, int32_t ArgNumVGPR);
bool isSGPR(unsigned Reg, const MCRegisterInfo* TRI);
unsigned getMCReg(unsigned Reg, const MCSubtargetInfo &STI);
LLVM_READNONE
unsigned mc2PseudoReg(unsigned Reg);
bool isSISrcOperand(const MCInstrDesc &Desc, unsigned OpNo);
bool isSISrcFPOperand(const MCInstrDesc &Desc, unsigned OpNo);
bool isSISrcInlinableOperand(const MCInstrDesc &Desc, unsigned OpNo);
unsigned getRegBitWidth(unsigned RCID);
unsigned getRegBitWidth(const MCRegisterClass &RC);
unsigned getRegOperandSize(const MCRegisterInfo *MRI, const MCInstrDesc &Desc,
unsigned OpNo);
LLVM_READNONE
inline unsigned getOperandSize(const MCOperandInfo &OpInfo) {
switch (OpInfo.OperandType) {
case AMDGPU::OPERAND_REG_IMM_INT32:
case AMDGPU::OPERAND_REG_IMM_FP32:
case AMDGPU::OPERAND_REG_IMM_FP32_DEFERRED:
case AMDGPU::OPERAND_REG_INLINE_C_INT32:
case AMDGPU::OPERAND_REG_INLINE_C_FP32:
case AMDGPU::OPERAND_REG_INLINE_AC_INT32:
case AMDGPU::OPERAND_REG_INLINE_AC_FP32:
case AMDGPU::OPERAND_REG_IMM_V2INT32:
case AMDGPU::OPERAND_REG_IMM_V2FP32:
case AMDGPU::OPERAND_REG_INLINE_C_V2INT32:
case AMDGPU::OPERAND_REG_INLINE_C_V2FP32:
case AMDGPU::OPERAND_KIMM32:
case AMDGPU::OPERAND_KIMM16: return 4;
case AMDGPU::OPERAND_REG_IMM_INT64:
case AMDGPU::OPERAND_REG_IMM_FP64:
case AMDGPU::OPERAND_REG_INLINE_C_INT64:
case AMDGPU::OPERAND_REG_INLINE_C_FP64:
case AMDGPU::OPERAND_REG_INLINE_AC_FP64:
return 8;
case AMDGPU::OPERAND_REG_IMM_INT16:
case AMDGPU::OPERAND_REG_IMM_FP16:
case AMDGPU::OPERAND_REG_IMM_FP16_DEFERRED:
case AMDGPU::OPERAND_REG_INLINE_C_INT16:
case AMDGPU::OPERAND_REG_INLINE_C_FP16:
case AMDGPU::OPERAND_REG_INLINE_C_V2INT16:
case AMDGPU::OPERAND_REG_INLINE_C_V2FP16:
case AMDGPU::OPERAND_REG_INLINE_AC_INT16:
case AMDGPU::OPERAND_REG_INLINE_AC_FP16:
case AMDGPU::OPERAND_REG_INLINE_AC_V2INT16:
case AMDGPU::OPERAND_REG_INLINE_AC_V2FP16:
case AMDGPU::OPERAND_REG_IMM_V2INT16:
case AMDGPU::OPERAND_REG_IMM_V2FP16:
return 2;
default:
llvm_unreachable("unhandled operand type");
}
}
LLVM_READNONE
inline unsigned getOperandSize(const MCInstrDesc &Desc, unsigned OpNo) {
return getOperandSize(Desc.OpInfo[OpNo]);
}
LLVM_READNONE
inline bool isInlinableIntLiteral(int64_t Literal) {
return Literal >= -16 && Literal <= 64;
}
LLVM_READNONE
bool isInlinableLiteral64(int64_t Literal, bool HasInv2Pi);
LLVM_READNONE
bool isInlinableLiteral32(int32_t Literal, bool HasInv2Pi);
LLVM_READNONE
bool isInlinableLiteral16(int16_t Literal, bool HasInv2Pi);
LLVM_READNONE
bool isInlinableLiteralV216(int32_t Literal, bool HasInv2Pi);
LLVM_READNONE
bool isInlinableIntLiteralV216(int32_t Literal);
LLVM_READNONE
bool isFoldableLiteralV216(int32_t Literal, bool HasInv2Pi);
bool isArgPassedInSGPR(const Argument *Arg);
LLVM_READONLY
bool isLegalSMRDEncodedUnsignedOffset(const MCSubtargetInfo &ST,
int64_t EncodedOffset);
LLVM_READONLY
bool isLegalSMRDEncodedSignedOffset(const MCSubtargetInfo &ST,
int64_t EncodedOffset,
bool IsBuffer);
uint64_t convertSMRDOffsetUnits(const MCSubtargetInfo &ST, uint64_t ByteOffset);
Optional<int64_t> getSMRDEncodedOffset(const MCSubtargetInfo &ST,
int64_t ByteOffset, bool IsBuffer);
Optional<int64_t> getSMRDEncodedLiteralOffset32(const MCSubtargetInfo &ST,
int64_t ByteOffset);
unsigned getNumFlatOffsetBits(const MCSubtargetInfo &ST, bool Signed);
bool isLegalSMRDImmOffset(const MCSubtargetInfo &ST, int64_t ByteOffset);
bool splitMUBUFOffset(uint32_t Imm, uint32_t &SOffset, uint32_t &ImmOffset,
const GCNSubtarget *Subtarget,
Align Alignment = Align(4));
LLVM_READNONE
inline bool isLegal64BitDPPControl(unsigned DC) {
return DC >= DPP::ROW_NEWBCAST_FIRST && DC <= DPP::ROW_NEWBCAST_LAST;
}
bool isIntrinsicSourceOfDivergence(unsigned IntrID);
struct SIModeRegisterDefaults {
bool IEEE : 1;
bool DX10Clamp : 1;
bool FP32InputDenormals : 1;
bool FP32OutputDenormals : 1;
bool FP64FP16InputDenormals : 1;
bool FP64FP16OutputDenormals : 1;
SIModeRegisterDefaults() :
IEEE(true),
DX10Clamp(true),
FP32InputDenormals(true),
FP32OutputDenormals(true),
FP64FP16InputDenormals(true),
FP64FP16OutputDenormals(true) {}
SIModeRegisterDefaults(const Function &F);
static SIModeRegisterDefaults getDefaultForCallingConv(CallingConv::ID CC) {
SIModeRegisterDefaults Mode;
Mode.IEEE = !AMDGPU::isShader(CC);
return Mode;
}
bool operator ==(const SIModeRegisterDefaults Other) const {
return IEEE == Other.IEEE && DX10Clamp == Other.DX10Clamp &&
FP32InputDenormals == Other.FP32InputDenormals &&
FP32OutputDenormals == Other.FP32OutputDenormals &&
FP64FP16InputDenormals == Other.FP64FP16InputDenormals &&
FP64FP16OutputDenormals == Other.FP64FP16OutputDenormals;
}
bool allFP32Denormals() const {
return FP32InputDenormals && FP32OutputDenormals;
}
bool allFP64FP16Denormals() const {
return FP64FP16InputDenormals && FP64FP16OutputDenormals;
}
uint32_t fpDenormModeSPValue() const {
if (FP32InputDenormals && FP32OutputDenormals)
return FP_DENORM_FLUSH_NONE;
if (FP32InputDenormals)
return FP_DENORM_FLUSH_OUT;
if (FP32OutputDenormals)
return FP_DENORM_FLUSH_IN;
return FP_DENORM_FLUSH_IN_FLUSH_OUT;
}
uint32_t fpDenormModeDPValue() const {
if (FP64FP16InputDenormals && FP64FP16OutputDenormals)
return FP_DENORM_FLUSH_NONE;
if (FP64FP16InputDenormals)
return FP_DENORM_FLUSH_OUT;
if (FP64FP16OutputDenormals)
return FP_DENORM_FLUSH_IN;
return FP_DENORM_FLUSH_IN_FLUSH_OUT;
}
static bool oneWayCompatible(bool CallerMode, bool CalleeMode) {
return CallerMode == CalleeMode || (!CallerMode && CalleeMode);
}
bool isInlineCompatible(SIModeRegisterDefaults CalleeMode) const {
if (DX10Clamp != CalleeMode.DX10Clamp)
return false;
if (IEEE != CalleeMode.IEEE)
return false;
return oneWayCompatible(FP64FP16InputDenormals, CalleeMode.FP64FP16InputDenormals) &&
oneWayCompatible(FP64FP16OutputDenormals, CalleeMode.FP64FP16OutputDenormals) &&
oneWayCompatible(FP32InputDenormals, CalleeMode.FP32InputDenormals) &&
oneWayCompatible(FP32OutputDenormals, CalleeMode.FP32OutputDenormals);
}
};
}
raw_ostream &operator<<(raw_ostream &OS,
const AMDGPU::IsaInfo::TargetIDSetting S);
}
#endif