2013-02-21 23:16:44 +08:00
|
|
|
//===-- SIInstrFormats.td - SI Instruction Encodings ----------------------===//
|
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.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// SI Instruction format definitions.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2017-10-03 08:06:41 +08:00
|
|
|
def isGCN : Predicate<"Subtarget->getGeneration() "
|
|
|
|
">= SISubtarget::SOUTHERN_ISLANDS">,
|
|
|
|
AssemblerPredicate<"FeatureGCN">;
|
|
|
|
def isSI : Predicate<"Subtarget->getGeneration() "
|
|
|
|
"== SISubtarget::SOUTHERN_ISLANDS">,
|
|
|
|
AssemblerPredicate<"FeatureSouthernIslands">;
|
|
|
|
|
|
|
|
|
2016-06-23 04:15:28 +08:00
|
|
|
class InstSI <dag outs, dag ins, string asm = "",
|
|
|
|
list<dag> pattern = []> :
|
|
|
|
AMDGPUInst<outs, ins, asm, pattern>, PredicateControl {
|
2017-10-03 08:06:41 +08:00
|
|
|
let SubtargetPredicate = isGCN;
|
2013-02-21 23:16:44 +08:00
|
|
|
|
2016-12-10 01:49:08 +08:00
|
|
|
// Low bits - basic encoding information.
|
2016-11-15 21:39:07 +08:00
|
|
|
field bit SALU = 0;
|
|
|
|
field bit VALU = 0;
|
|
|
|
|
2016-12-10 01:49:08 +08:00
|
|
|
// SALU instruction formats.
|
2016-11-15 21:39:07 +08:00
|
|
|
field bit SOP1 = 0;
|
|
|
|
field bit SOP2 = 0;
|
|
|
|
field bit SOPC = 0;
|
|
|
|
field bit SOPK = 0;
|
|
|
|
field bit SOPP = 0;
|
|
|
|
|
2016-12-10 01:49:08 +08:00
|
|
|
// VALU instruction formats.
|
2016-11-15 21:39:07 +08:00
|
|
|
field bit VOP1 = 0;
|
|
|
|
field bit VOP2 = 0;
|
|
|
|
field bit VOPC = 0;
|
2016-12-10 01:49:08 +08:00
|
|
|
field bit VOP3 = 0;
|
2017-02-28 02:49:11 +08:00
|
|
|
field bit VOP3P = 0;
|
2016-12-10 01:49:08 +08:00
|
|
|
field bit VINTRP = 0;
|
2016-11-15 21:39:07 +08:00
|
|
|
field bit SDWA = 0;
|
|
|
|
field bit DPP = 0;
|
|
|
|
|
2016-12-10 01:49:08 +08:00
|
|
|
// Memory instruction formats.
|
2016-11-15 21:39:07 +08:00
|
|
|
field bit MUBUF = 0;
|
|
|
|
field bit MTBUF = 0;
|
|
|
|
field bit SMRD = 0;
|
|
|
|
field bit MIMG = 0;
|
2016-12-06 04:23:10 +08:00
|
|
|
field bit EXP = 0;
|
2016-12-10 01:49:08 +08:00
|
|
|
field bit FLAT = 0;
|
|
|
|
field bit DS = 0;
|
2016-08-03 03:31:14 +08:00
|
|
|
|
2017-07-22 05:05:45 +08:00
|
|
|
// Pseudo instruction formats.
|
2016-11-15 21:39:07 +08:00
|
|
|
field bit VGPRSpill = 0;
|
|
|
|
field bit SGPRSpill = 0;
|
2013-02-21 23:16:44 +08:00
|
|
|
|
2016-12-10 01:49:08 +08:00
|
|
|
// High bits - other information.
|
|
|
|
field bit VM_CNT = 0;
|
|
|
|
field bit EXP_CNT = 0;
|
|
|
|
field bit LGKM_CNT = 0;
|
2015-10-06 23:57:53 +08:00
|
|
|
|
2016-12-10 01:49:08 +08:00
|
|
|
// Whether WQM _must_ be enabled for this instruction.
|
|
|
|
field bit WQM = 0;
|
2016-07-12 05:59:43 +08:00
|
|
|
|
2016-08-03 03:31:14 +08:00
|
|
|
// Whether WQM _must_ be disabled for this instruction.
|
2016-11-15 21:39:07 +08:00
|
|
|
field bit DisableWQM = 0;
|
2016-08-03 03:31:14 +08:00
|
|
|
|
2016-12-10 01:49:08 +08:00
|
|
|
field bit Gather4 = 0;
|
|
|
|
|
2016-09-17 05:41:16 +08:00
|
|
|
// Most sopk treat the immediate as a signed 16-bit, however some
|
|
|
|
// use it as unsigned.
|
2016-11-15 21:39:07 +08:00
|
|
|
field bit SOPKZext = 0;
|
2016-09-17 05:41:16 +08:00
|
|
|
|
2016-10-29 05:55:15 +08:00
|
|
|
// This is an s_store_dword* instruction that requires a cache flush
|
|
|
|
// on wave termination. It is necessary to distinguish from mayStore
|
|
|
|
// SMEM instructions like the cache flush ones.
|
2016-11-15 21:39:07 +08:00
|
|
|
field bit ScalarStore = 0;
|
2016-10-29 05:55:15 +08:00
|
|
|
|
2016-11-02 04:42:24 +08:00
|
|
|
// Whether the operands can be ignored when computing the
|
|
|
|
// instruction size.
|
2016-11-15 21:39:07 +08:00
|
|
|
field bit FixedSize = 0;
|
2016-11-02 04:42:24 +08:00
|
|
|
|
2016-12-10 01:49:08 +08:00
|
|
|
// This bit tells the assembler to use the 32-bit encoding in case it
|
|
|
|
// is unable to infer the encoding from the operands.
|
|
|
|
field bit VOPAsmPrefer32Bit = 0;
|
|
|
|
|
2017-07-21 21:54:11 +08:00
|
|
|
// This bit indicates that this is a VOP3 opcode which supports op_sel
|
|
|
|
// modifier (gfx9 only).
|
|
|
|
field bit VOP3_OPSEL = 0;
|
|
|
|
|
2017-07-22 05:05:45 +08:00
|
|
|
// Is it possible for this instruction to be atomic?
|
|
|
|
field bit maybeAtomic = 0;
|
|
|
|
|
2017-11-21 02:24:21 +08:00
|
|
|
// This bit indicates that this is a VI instruction which is renamed
|
|
|
|
// in GFX9. Required for correct mapping from pseudo to MC.
|
|
|
|
field bit renamedInGFX9 = 0;
|
2017-08-10 01:10:47 +08:00
|
|
|
|
2017-09-01 07:53:50 +08:00
|
|
|
// This bit indicates that this has a floating point result type, so
|
|
|
|
// the clamp modifier has floating point semantics.
|
|
|
|
field bit FPClamp = 0;
|
|
|
|
|
2017-08-16 21:51:56 +08:00
|
|
|
// This bit indicates that instruction may support integer clamping
|
|
|
|
// which depends on GPU features.
|
|
|
|
field bit IntClamp = 0;
|
|
|
|
|
2017-09-01 07:53:50 +08:00
|
|
|
// This field indicates that the clamp applies to the low component
|
|
|
|
// of a packed output register.
|
|
|
|
field bit ClampLo = 0;
|
|
|
|
|
|
|
|
// This field indicates that the clamp applies to the high component
|
|
|
|
// of a packed output register.
|
|
|
|
field bit ClampHi = 0;
|
|
|
|
|
2017-11-17 23:15:40 +08:00
|
|
|
// This bit indicates that this is a packed VOP3P instruction
|
|
|
|
field bit IsPacked = 0;
|
|
|
|
|
2018-01-19 06:08:53 +08:00
|
|
|
// This bit indicates that this is a D16 instruction.
|
|
|
|
field bit D16 = 0;
|
|
|
|
|
2014-07-30 02:51:56 +08:00
|
|
|
// These need to be kept in sync with the enum in SIInstrFlags.
|
2016-12-10 01:49:08 +08:00
|
|
|
let TSFlags{0} = SALU;
|
|
|
|
let TSFlags{1} = VALU;
|
|
|
|
|
|
|
|
let TSFlags{2} = SOP1;
|
|
|
|
let TSFlags{3} = SOP2;
|
|
|
|
let TSFlags{4} = SOPC;
|
|
|
|
let TSFlags{5} = SOPK;
|
|
|
|
let TSFlags{6} = SOPP;
|
|
|
|
|
|
|
|
let TSFlags{7} = VOP1;
|
|
|
|
let TSFlags{8} = VOP2;
|
|
|
|
let TSFlags{9} = VOPC;
|
|
|
|
let TSFlags{10} = VOP3;
|
2017-02-28 02:49:11 +08:00
|
|
|
let TSFlags{12} = VOP3P;
|
2016-12-10 01:49:08 +08:00
|
|
|
|
|
|
|
let TSFlags{13} = VINTRP;
|
2016-04-26 21:33:56 +08:00
|
|
|
let TSFlags{14} = SDWA;
|
|
|
|
let TSFlags{15} = DPP;
|
|
|
|
|
|
|
|
let TSFlags{16} = MUBUF;
|
|
|
|
let TSFlags{17} = MTBUF;
|
|
|
|
let TSFlags{18} = SMRD;
|
2016-12-10 01:49:08 +08:00
|
|
|
let TSFlags{19} = MIMG;
|
|
|
|
let TSFlags{20} = EXP;
|
2016-04-26 21:33:56 +08:00
|
|
|
let TSFlags{21} = FLAT;
|
2016-12-10 01:49:08 +08:00
|
|
|
let TSFlags{22} = DS;
|
|
|
|
|
|
|
|
let TSFlags{23} = VGPRSpill;
|
|
|
|
let TSFlags{24} = SGPRSpill;
|
|
|
|
|
|
|
|
let TSFlags{32} = VM_CNT;
|
|
|
|
let TSFlags{33} = EXP_CNT;
|
|
|
|
let TSFlags{34} = LGKM_CNT;
|
|
|
|
|
|
|
|
let TSFlags{35} = WQM;
|
|
|
|
let TSFlags{36} = DisableWQM;
|
|
|
|
let TSFlags{37} = Gather4;
|
|
|
|
|
|
|
|
let TSFlags{38} = SOPKZext;
|
|
|
|
let TSFlags{39} = ScalarStore;
|
|
|
|
let TSFlags{40} = FixedSize;
|
|
|
|
let TSFlags{41} = VOPAsmPrefer32Bit;
|
2017-09-01 07:53:50 +08:00
|
|
|
let TSFlags{42} = VOP3_OPSEL;
|
|
|
|
|
|
|
|
let TSFlags{43} = maybeAtomic;
|
2017-11-21 02:24:21 +08:00
|
|
|
let TSFlags{44} = renamedInGFX9;
|
2014-09-27 01:54:59 +08:00
|
|
|
|
2017-09-01 07:53:50 +08:00
|
|
|
let TSFlags{45} = FPClamp;
|
2017-08-16 21:51:56 +08:00
|
|
|
let TSFlags{46} = IntClamp;
|
2017-09-01 07:53:50 +08:00
|
|
|
let TSFlags{47} = ClampLo;
|
|
|
|
let TSFlags{48} = ClampHi;
|
2017-07-22 05:05:45 +08:00
|
|
|
|
2017-11-17 23:15:40 +08:00
|
|
|
let TSFlags{49} = IsPacked;
|
|
|
|
|
2018-01-19 06:08:53 +08:00
|
|
|
let TSFlags{50} = D16;
|
|
|
|
|
2015-01-14 09:13:19 +08:00
|
|
|
let SchedRW = [Write32Bit];
|
2016-02-18 11:42:32 +08:00
|
|
|
|
|
|
|
field bits<1> DisableSIDecoder = 0;
|
|
|
|
field bits<1> DisableVIDecoder = 0;
|
|
|
|
field bits<1> DisableDecoder = 0;
|
|
|
|
|
|
|
|
let isAsmParserOnly = !if(!eq(DisableDecoder{0}, {0}), 0, 1);
|
2016-09-09 17:37:51 +08:00
|
|
|
let AsmVariantName = AMDGPUAsmVariants.Default;
|
[MachineOperand][Target] MachineOperand::isRenamable semantics changes
Summary:
Add a target option AllowRegisterRenaming that is used to opt in to
post-register-allocation renaming of registers. This is set to 0 by
default, which causes the hasExtraSrcRegAllocReq/hasExtraDstRegAllocReq
fields of all opcodes to be set to 1, causing
MachineOperand::isRenamable to always return false.
Set the AllowRegisterRenaming flag to 1 for all in-tree targets that
have lit tests that were effected by enabling COPY forwarding in
MachineCopyPropagation (AArch64, AMDGPU, ARM, Hexagon, Mips, PowerPC,
RISCV, Sparc, SystemZ and X86).
Add some more comments describing the semantics of the
MachineOperand::isRenamable function and how it is set and maintained.
Change isRenamable to check the operand's opcode
hasExtraSrcRegAllocReq/hasExtraDstRegAllocReq bit directly instead of
relying on it being consistently reflected in the IsRenamable bit
setting.
Clear the IsRenamable bit when changing an operand's register value.
Remove target code that was clearing the IsRenamable bit when changing
registers/opcodes now that this is done conservatively by default.
Change setting of hasExtraSrcRegAllocReq in AMDGPU target to be done in
one place covering all opcodes that have constant pipe read limit
restrictions.
Reviewers: qcolombet, MatzeB
Subscribers: aemerson, arsenm, jyknight, mcrosier, sdardis, nhaehnle, javed.absar, tpr, arichardson, kristof.beyls, kbarton, fedor.sergeev, asb, rbar, johnrusso, simoncook, jordy.potman.lists, apazos, sabuasal, niosHD, escha, nemanjai, llvm-commits
Differential Revision: https://reviews.llvm.org/D43042
llvm-svn: 325931
2018-02-24 02:25:08 +08:00
|
|
|
|
|
|
|
// Avoid changing source registers in a way that violates constant bus read limitations.
|
|
|
|
let hasExtraSrcRegAllocReq = !if(VOP1,1,!if(VOP2,1,!if(VOP3,1,!if(VOPC,1,!if(SDWA,1, !if(VALU,1,0))))));
|
2013-02-21 23:16:44 +08:00
|
|
|
}
|
|
|
|
|
2017-03-25 03:52:05 +08:00
|
|
|
class PseudoInstSI<dag outs, dag ins, list<dag> pattern = [], string asm = "">
|
|
|
|
: InstSI<outs, ins, asm, pattern> {
|
2016-07-12 08:23:17 +08:00
|
|
|
let isPseudo = 1;
|
|
|
|
let isCodeGenOnly = 1;
|
|
|
|
}
|
|
|
|
|
2017-03-25 03:52:05 +08:00
|
|
|
class SPseudoInstSI<dag outs, dag ins, list<dag> pattern = [], string asm = "">
|
|
|
|
: PseudoInstSI<outs, ins, pattern, asm> {
|
2016-08-27 11:00:51 +08:00
|
|
|
let SALU = 1;
|
|
|
|
}
|
|
|
|
|
2017-03-25 03:52:05 +08:00
|
|
|
class VPseudoInstSI<dag outs, dag ins, list<dag> pattern = [], string asm = "">
|
|
|
|
: PseudoInstSI<outs, ins, pattern, asm> {
|
2016-08-27 11:00:51 +08:00
|
|
|
let VALU = 1;
|
|
|
|
let Uses = [EXEC];
|
|
|
|
}
|
|
|
|
|
|
|
|
class CFPseudoInstSI<dag outs, dag ins, list<dag> pattern = [],
|
|
|
|
bit UseExec = 0, bit DefExec = 0> :
|
|
|
|
SPseudoInstSI<outs, ins, pattern> {
|
|
|
|
|
|
|
|
let Uses = !if(UseExec, [EXEC], []);
|
|
|
|
let Defs = !if(DefExec, [EXEC, SCC], [SCC]);
|
2016-09-17 06:11:18 +08:00
|
|
|
let mayLoad = 0;
|
|
|
|
let mayStore = 0;
|
|
|
|
let hasSideEffects = 0;
|
2016-08-27 11:00:51 +08:00
|
|
|
}
|
|
|
|
|
2014-07-22 01:44:28 +08:00
|
|
|
class Enc32 {
|
2013-02-21 23:16:44 +08:00
|
|
|
field bits<32> Inst;
|
2014-07-22 01:44:28 +08:00
|
|
|
int Size = 4;
|
2013-02-21 23:16:44 +08:00
|
|
|
}
|
2012-12-12 05:25:42 +08:00
|
|
|
|
2014-07-22 01:44:28 +08:00
|
|
|
class Enc64 {
|
2013-02-21 23:16:44 +08:00
|
|
|
field bits<64> Inst;
|
2014-07-22 01:44:28 +08:00
|
|
|
int Size = 8;
|
2013-02-21 23:16:44 +08:00
|
|
|
}
|
2012-12-12 05:25:42 +08:00
|
|
|
|
2015-03-13 05:34:22 +08:00
|
|
|
class VOPDstOperand <RegisterClass rc> : RegisterOperand <rc, "printVOPDst">;
|
|
|
|
|
2014-07-22 01:44:28 +08:00
|
|
|
class VINTRPe <bits<2> op> : Enc32 {
|
2015-02-18 10:15:35 +08:00
|
|
|
bits<8> vdst;
|
|
|
|
bits<8> vsrc;
|
|
|
|
bits<2> attrchan;
|
|
|
|
bits<6> attr;
|
2013-02-21 23:16:44 +08:00
|
|
|
|
2015-02-18 10:15:35 +08:00
|
|
|
let Inst{7-0} = vsrc;
|
|
|
|
let Inst{9-8} = attrchan;
|
|
|
|
let Inst{15-10} = attr;
|
2013-02-21 23:16:44 +08:00
|
|
|
let Inst{17-16} = op;
|
2015-02-18 10:15:35 +08:00
|
|
|
let Inst{25-18} = vdst;
|
2013-02-21 23:16:44 +08:00
|
|
|
let Inst{31-26} = 0x32; // encoding
|
2013-02-16 19:28:02 +08:00
|
|
|
}
|
|
|
|
|
2014-07-22 01:44:28 +08:00
|
|
|
class MIMGe <bits<7> op> : Enc64 {
|
2015-02-18 10:15:35 +08:00
|
|
|
bits<8> vdata;
|
|
|
|
bits<4> dmask;
|
|
|
|
bits<1> unorm;
|
|
|
|
bits<1> glc;
|
|
|
|
bits<1> da;
|
|
|
|
bits<1> r128;
|
|
|
|
bits<1> tfe;
|
|
|
|
bits<1> lwe;
|
|
|
|
bits<1> slc;
|
2018-01-19 06:08:53 +08:00
|
|
|
bits<1> d16 = 0;
|
2015-02-18 10:15:35 +08:00
|
|
|
bits<8> vaddr;
|
|
|
|
bits<7> srsrc;
|
|
|
|
bits<7> ssamp;
|
|
|
|
|
|
|
|
let Inst{11-8} = dmask;
|
|
|
|
let Inst{12} = unorm;
|
|
|
|
let Inst{13} = glc;
|
|
|
|
let Inst{14} = da;
|
|
|
|
let Inst{15} = r128;
|
|
|
|
let Inst{16} = tfe;
|
|
|
|
let Inst{17} = lwe;
|
2013-02-21 23:16:44 +08:00
|
|
|
let Inst{24-18} = op;
|
2015-02-18 10:15:35 +08:00
|
|
|
let Inst{25} = slc;
|
2013-02-21 23:16:44 +08:00
|
|
|
let Inst{31-26} = 0x3c;
|
2015-02-18 10:15:35 +08:00
|
|
|
let Inst{39-32} = vaddr;
|
|
|
|
let Inst{47-40} = vdata;
|
|
|
|
let Inst{52-48} = srsrc{6-2};
|
|
|
|
let Inst{57-53} = ssamp{6-2};
|
2018-01-19 06:08:53 +08:00
|
|
|
let Inst{63} = d16;
|
2013-02-21 23:16:44 +08:00
|
|
|
}
|
|
|
|
|
2014-09-15 23:41:53 +08:00
|
|
|
class EXPe : Enc64 {
|
2015-02-18 10:15:35 +08:00
|
|
|
bits<4> en;
|
|
|
|
bits<6> tgt;
|
|
|
|
bits<1> compr;
|
|
|
|
bits<1> done;
|
|
|
|
bits<1> vm;
|
2017-05-19 21:36:09 +08:00
|
|
|
bits<8> src0;
|
|
|
|
bits<8> src1;
|
|
|
|
bits<8> src2;
|
|
|
|
bits<8> src3;
|
2015-02-18 10:15:35 +08:00
|
|
|
|
|
|
|
let Inst{3-0} = en;
|
|
|
|
let Inst{9-4} = tgt;
|
|
|
|
let Inst{10} = compr;
|
|
|
|
let Inst{11} = done;
|
|
|
|
let Inst{12} = vm;
|
2013-02-21 23:16:44 +08:00
|
|
|
let Inst{31-26} = 0x3e;
|
2017-05-19 21:36:09 +08:00
|
|
|
let Inst{39-32} = src0;
|
|
|
|
let Inst{47-40} = src1;
|
|
|
|
let Inst{55-48} = src2;
|
|
|
|
let Inst{63-56} = src3;
|
2014-07-22 01:44:28 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
let Uses = [EXEC] in {
|
|
|
|
|
2014-12-07 20:18:57 +08:00
|
|
|
class VINTRPCommon <dag outs, dag ins, string asm, list<dag> pattern> :
|
|
|
|
InstSI <outs, ins, asm, pattern> {
|
2016-12-10 08:29:55 +08:00
|
|
|
let VINTRP = 1;
|
2016-12-09 23:57:15 +08:00
|
|
|
// VINTRP instructions read parameter values from LDS, but these parameter
|
|
|
|
// values are stored outside of the LDS memory that is allocated to the
|
|
|
|
// shader for general purpose use.
|
|
|
|
//
|
|
|
|
// While it may be possible for ds_read/ds_write instructions to access
|
|
|
|
// the parameter values in LDS, this would essentially be an out-of-bounds
|
|
|
|
// memory access which we consider to be undefined behavior.
|
|
|
|
//
|
|
|
|
// So even though these instructions read memory, this memory is outside the
|
|
|
|
// addressable memory space for the shader, and we consider these instructions
|
|
|
|
// to be readnone.
|
|
|
|
let mayLoad = 0;
|
2014-07-22 01:44:28 +08:00
|
|
|
let mayStore = 0;
|
2014-11-19 07:57:33 +08:00
|
|
|
let hasSideEffects = 0;
|
2014-07-22 01:44:28 +08:00
|
|
|
}
|
|
|
|
|
2016-12-06 04:23:10 +08:00
|
|
|
class EXPCommon<dag outs, dag ins, string asm, list<dag> pattern> :
|
|
|
|
InstSI<outs, ins, asm, pattern> {
|
|
|
|
let EXP = 1;
|
|
|
|
let EXP_CNT = 1;
|
|
|
|
let mayLoad = 0; // Set to 1 if done bit is set.
|
|
|
|
let mayStore = 1;
|
|
|
|
let UseNamedOperandTable = 1;
|
|
|
|
let Uses = [EXEC];
|
|
|
|
let SchedRW = [WriteExport];
|
|
|
|
}
|
|
|
|
|
2014-07-22 01:44:28 +08:00
|
|
|
} // End Uses = [EXEC]
|
|
|
|
|
2016-03-04 18:39:50 +08:00
|
|
|
class MIMG <dag outs, dag ins, string asm, list<dag> pattern> :
|
|
|
|
InstSI <outs, ins, asm, pattern> {
|
2014-07-22 01:44:28 +08:00
|
|
|
|
|
|
|
let VM_CNT = 1;
|
|
|
|
let EXP_CNT = 1;
|
|
|
|
let MIMG = 1;
|
2015-09-10 09:23:28 +08:00
|
|
|
let Uses = [EXEC];
|
2014-11-19 07:57:33 +08:00
|
|
|
|
2016-02-12 05:45:07 +08:00
|
|
|
let UseNamedOperandTable = 1;
|
2014-11-19 07:57:33 +08:00
|
|
|
let hasSideEffects = 0; // XXX ????
|
2014-07-22 01:44:28 +08:00
|
|
|
}
|