//===-- SIInstrInfo.td - SI Instruction Infos -------------*- tablegen -*--===// // // The LLVM Compiler Infrastructure // // This file is distributed under the University of Illinois Open Source // License. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// def isCI : Predicate<"Subtarget->getGeneration() " ">= AMDGPUSubtarget::SEA_ISLANDS">; def isCIOnly : Predicate<"Subtarget->getGeneration() ==" "AMDGPUSubtarget::SEA_ISLANDS">, AssemblerPredicate <"FeatureSeaIslands">; def DisableInst : Predicate <"false">, AssemblerPredicate<"FeatureDisable">; class vop { field bits<9> SI3; field bits<10> VI3; } class vopc si, bits<8> vi = !add(0x40, si)> : vop { field bits<8> SI = si; field bits<8> VI = vi; field bits<9> SI3 = {0, si{7-0}}; field bits<10> VI3 = {0, 0, vi{7-0}}; } class vop1 si, bits<8> vi = si> : vop { field bits<8> SI = si; field bits<8> VI = vi; field bits<9> SI3 = {1, 1, si{6-0}}; field bits<10> VI3 = !add(0x140, vi); } class vop2 si, bits<6> vi = si> : vop { field bits<6> SI = si; field bits<6> VI = vi; field bits<9> SI3 = {1, 0, 0, si{5-0}}; field bits<10> VI3 = {0, 1, 0, 0, vi{5-0}}; } // Specify a VOP2 opcode for SI and VOP3 opcode for VI // that doesn't have VOP2 encoding on VI class vop23 si, bits<10> vi> : vop2 { let VI3 = vi; } class vop3 si, bits<10> vi = {0, si}> : vop { let SI3 = si; let VI3 = vi; } class sop1 si, bits<8> vi = si> { field bits<8> SI = si; field bits<8> VI = vi; } class sop2 si, bits<7> vi = si> { field bits<7> SI = si; field bits<7> VI = vi; } class sopk si, bits<5> vi = si> { field bits<5> SI = si; field bits<5> VI = vi; } // Specify an SMRD opcode for SI and SMEM opcode for VI // FIXME: This should really be bits<5> si, Tablegen crashes if // parameter default value is other parameter with different bit size class smrd si, bits<8> vi = si> { field bits<5> SI = si{4-0}; field bits<8> VI = vi; } // Execpt for the NONE field, this must be kept in sync with the SISubtarget enum // in AMDGPUInstrInfo.cpp def SISubtarget { int NONE = -1; int SI = 0; int VI = 1; } //===----------------------------------------------------------------------===// // SI DAG Nodes //===----------------------------------------------------------------------===// def SIload_constant : SDNode<"AMDGPUISD::LOAD_CONSTANT", SDTypeProfile<1, 2, [SDTCisVT<0, f32>, SDTCisVT<1, v4i32>, SDTCisVT<2, i32>]>, [SDNPMayLoad, SDNPMemOperand] >; def SItbuffer_store : SDNode<"AMDGPUISD::TBUFFER_STORE_FORMAT", SDTypeProfile<0, 13, [SDTCisVT<0, v4i32>, // rsrc(SGPR) SDTCisVT<1, iAny>, // vdata(VGPR) SDTCisVT<2, i32>, // num_channels(imm) SDTCisVT<3, i32>, // vaddr(VGPR) SDTCisVT<4, i32>, // soffset(SGPR) SDTCisVT<5, i32>, // inst_offset(imm) SDTCisVT<6, i32>, // dfmt(imm) SDTCisVT<7, i32>, // nfmt(imm) SDTCisVT<8, i32>, // offen(imm) SDTCisVT<9, i32>, // idxen(imm) SDTCisVT<10, i32>, // glc(imm) SDTCisVT<11, i32>, // slc(imm) SDTCisVT<12, i32> // tfe(imm) ]>, [SDNPMayStore, SDNPMemOperand, SDNPHasChain] >; def SIload_input : SDNode<"AMDGPUISD::LOAD_INPUT", SDTypeProfile<1, 3, [SDTCisVT<0, v4f32>, SDTCisVT<1, v4i32>, SDTCisVT<2, i16>, SDTCisVT<3, i32>]> >; class SDSample : SDNode , SDTCisVT<2, v32i8>, SDTCisVT<3, v4i32>, SDTCisVT<4, i32>]> >; def SIsample : SDSample<"AMDGPUISD::SAMPLE">; def SIsampleb : SDSample<"AMDGPUISD::SAMPLEB">; def SIsampled : SDSample<"AMDGPUISD::SAMPLED">; def SIsamplel : SDSample<"AMDGPUISD::SAMPLEL">; def SIconstdata_ptr : SDNode< "AMDGPUISD::CONST_DATA_PTR", SDTypeProfile <1, 1, [SDTCisVT<0, i64>, SDTCisVT<0, i64>]> >; //===----------------------------------------------------------------------===// // PatFrags for FLAT instructions //===----------------------------------------------------------------------===// class flat_ld : PatFrag<(ops node:$ptr), (ld node:$ptr), [{ return isFlatLoad(dyn_cast(N)) || isGlobalLoad(dyn_cast(N)) || isConstantLoad(cast(N), -1); }]>; def flat_load : flat_ld ; def flat_az_extloadi8 : flat_ld ; def flat_sextloadi8 : flat_ld ; def flat_az_extloadi16 : flat_ld ; def flat_sextloadi16 : flat_ld ; class flat_st : PatFrag<(ops node:$val, node:$ptr), (st node:$val, node:$ptr), [{ return isFlatStore(dyn_cast(N)) || isGlobalStore(dyn_cast(N)); }]>; def flat_store: flat_st ; def flat_truncstorei8 : flat_st ; def flat_truncstorei16 : flat_st ; def mubuf_load : PatFrag <(ops node:$ptr), (load node:$ptr), [{ return isGlobalLoad(cast(N)) || isConstantLoad(cast(N), -1); }]>; def smrd_load : PatFrag <(ops node:$ptr), (load node:$ptr), [{ return isConstantLoad(cast(N), -1) && static_cast(getTargetLowering())->isMemOpUniform(N); }]>; //===----------------------------------------------------------------------===// // SDNodes and PatFrag for local loads and stores to enable s_mov_b32 m0, -1 // to be glued to the memory instructions. //===----------------------------------------------------------------------===// def SIld_local : SDNode <"ISD::LOAD", SDTLoad, [SDNPHasChain, SDNPMayLoad, SDNPMemOperand, SDNPInGlue] >; def si_ld_local : PatFrag <(ops node:$ptr), (SIld_local node:$ptr), [{ return isLocalLoad(cast(N)); }]>; def si_load_local : PatFrag <(ops node:$ptr), (si_ld_local node:$ptr), [{ return cast(N)->getAddressingMode() == ISD::UNINDEXED && cast(N)->getExtensionType() == ISD::NON_EXTLOAD; }]>; def si_load_local_align8 : Aligned8Bytes < (ops node:$ptr), (si_load_local node:$ptr) >; def si_sextload_local : PatFrag <(ops node:$ptr), (si_ld_local node:$ptr), [{ return cast(N)->getExtensionType() == ISD::SEXTLOAD; }]>; def si_az_extload_local : AZExtLoadBase ; multiclass SIExtLoadLocal { def _i8 : PatFrag <(ops node:$ptr), (ld_node node:$ptr), [{return cast(N)->getMemoryVT() == MVT::i8;}] >; def _i16 : PatFrag <(ops node:$ptr), (ld_node node:$ptr), [{return cast(N)->getMemoryVT() == MVT::i16;}] >; } defm si_sextload_local : SIExtLoadLocal ; defm si_az_extload_local : SIExtLoadLocal ; def SIst_local : SDNode <"ISD::STORE", SDTStore, [SDNPHasChain, SDNPMayStore, SDNPMemOperand, SDNPInGlue] >; def si_st_local : PatFrag < (ops node:$val, node:$ptr), (SIst_local node:$val, node:$ptr), [{ return isLocalStore(cast(N)); }]>; def si_store_local : PatFrag < (ops node:$val, node:$ptr), (si_st_local node:$val, node:$ptr), [{ return cast(N)->getAddressingMode() == ISD::UNINDEXED && !cast(N)->isTruncatingStore(); }]>; def si_store_local_align8 : Aligned8Bytes < (ops node:$val, node:$ptr), (si_store_local node:$val, node:$ptr) >; def si_truncstore_local : PatFrag < (ops node:$val, node:$ptr), (si_st_local node:$val, node:$ptr), [{ return cast(N)->isTruncatingStore(); }]>; def si_truncstore_local_i8 : PatFrag < (ops node:$val, node:$ptr), (si_truncstore_local node:$val, node:$ptr), [{ return cast(N)->getMemoryVT() == MVT::i8; }]>; def si_truncstore_local_i16 : PatFrag < (ops node:$val, node:$ptr), (si_truncstore_local node:$val, node:$ptr), [{ return cast(N)->getMemoryVT() == MVT::i16; }]>; multiclass SIAtomicM0Glue2 { def _glue : SDNode <"ISD::ATOMIC_"#op_name, SDTAtomic2, [SDNPHasChain, SDNPMayStore, SDNPMayLoad, SDNPMemOperand, SDNPInGlue] >; def _local : local_binary_atomic_op (NAME#"_glue")>; } defm si_atomic_load_add : SIAtomicM0Glue2 <"LOAD_ADD">; defm si_atomic_load_and : SIAtomicM0Glue2 <"LOAD_AND">; defm si_atomic_load_min : SIAtomicM0Glue2 <"LOAD_MIN">; defm si_atomic_load_max : SIAtomicM0Glue2 <"LOAD_MAX">; defm si_atomic_load_or : SIAtomicM0Glue2 <"LOAD_OR">; defm si_atomic_load_sub : SIAtomicM0Glue2 <"LOAD_SUB">; defm si_atomic_load_xor : SIAtomicM0Glue2 <"LOAD_XOR">; defm si_atomic_load_umin : SIAtomicM0Glue2 <"LOAD_UMIN">; defm si_atomic_load_umax : SIAtomicM0Glue2 <"LOAD_UMAX">; defm si_atomic_swap : SIAtomicM0Glue2 <"SWAP">; def si_atomic_cmp_swap_glue : SDNode <"ISD::ATOMIC_CMP_SWAP", SDTAtomic3, [SDNPHasChain, SDNPMayStore, SDNPMayLoad, SDNPMemOperand, SDNPInGlue] >; defm si_atomic_cmp_swap : AtomicCmpSwapLocal ; // Transformation function, extract the lower 32bit of a 64bit immediate def LO32 : SDNodeXFormgetTargetConstant(N->getZExtValue() & 0xffffffff, SDLoc(N), MVT::i32); }]>; def LO32f : SDNodeXFormgetValueAPF().bitcastToAPInt().trunc(32); return CurDAG->getTargetConstantFP(APFloat(APFloat::IEEEsingle, V), MVT::f32); }]>; // Transformation function, extract the upper 32bit of a 64bit immediate def HI32 : SDNodeXFormgetTargetConstant(N->getZExtValue() >> 32, SDLoc(N), MVT::i32); }]>; def HI32f : SDNodeXFormgetValueAPF().bitcastToAPInt().lshr(32).trunc(32); return CurDAG->getTargetConstantFP(APFloat(APFloat::IEEEsingle, V), SDLoc(N), MVT::f32); }]>; def IMM8bitDWORD : PatLeaf <(imm), [{return (N->getZExtValue() & ~0x3FC) == 0;}] >; def as_dword_i32imm : SDNodeXFormgetTargetConstant(N->getZExtValue() >> 2, SDLoc(N), MVT::i32); }]>; def as_i1imm : SDNodeXFormgetTargetConstant(N->getZExtValue(), SDLoc(N), MVT::i1); }]>; def as_i8imm : SDNodeXFormgetTargetConstant(N->getZExtValue(), SDLoc(N), MVT::i8); }]>; def as_i16imm : SDNodeXFormgetTargetConstant(N->getSExtValue(), SDLoc(N), MVT::i16); }]>; def as_i32imm: SDNodeXFormgetTargetConstant(N->getSExtValue(), SDLoc(N), MVT::i32); }]>; def as_i64imm: SDNodeXFormgetTargetConstant(N->getSExtValue(), SDLoc(N), MVT::i64); }]>; // Copied from the AArch64 backend: def bitcast_fpimm_to_i32 : SDNodeXFormgetTargetConstant( N->getValueAPF().bitcastToAPInt().getZExtValue(), SDLoc(N), MVT::i32); }]>; // Copied from the AArch64 backend: def bitcast_fpimm_to_i64 : SDNodeXFormgetTargetConstant( N->getValueAPF().bitcastToAPInt().getZExtValue(), SDLoc(N), MVT::i64); }]>; def IMM8bit : PatLeaf <(imm), [{return isUInt<8>(N->getZExtValue());}] >; def IMM12bit : PatLeaf <(imm), [{return isUInt<12>(N->getZExtValue());}] >; def IMM16bit : PatLeaf <(imm), [{return isUInt<16>(N->getZExtValue());}] >; def IMM20bit : PatLeaf <(imm), [{return isUInt<20>(N->getZExtValue());}] >; def IMM32bit : PatLeaf <(imm), [{return isUInt<32>(N->getZExtValue());}] >; def mubuf_vaddr_offset : PatFrag< (ops node:$ptr, node:$offset, node:$imm_offset), (add (add node:$ptr, node:$offset), node:$imm_offset) >; class InlineImm : PatLeaf <(vt imm), [{ return isInlineImmediate(N); }]>; class InlineFPImm : PatLeaf <(vt fpimm), [{ return isInlineImmediate(N); }]>; class SGPRImm : PatLeafgetGeneration() < AMDGPUSubtarget::SOUTHERN_ISLANDS) { return false; } const SIRegisterInfo *SIRI = static_cast(Subtarget->getRegisterInfo()); for (SDNode::use_iterator U = N->use_begin(), E = SDNode::use_end(); U != E; ++U) { const TargetRegisterClass *RC = getOperandRegClass(*U, U.getOperandNo()); if (RC && SIRI->isSGPRClass(RC)) return true; } return false; }]>; //===----------------------------------------------------------------------===// // Custom Operands //===----------------------------------------------------------------------===// def FRAMEri32 : Operand { let MIOperandInfo = (ops i32:$ptr, i32imm:$index); } def SoppBrTarget : AsmOperandClass { let Name = "SoppBrTarget"; let ParserMethod = "parseSOppBrTarget"; } def sopp_brtarget : Operand { let EncoderMethod = "getSOPPBrEncoding"; let OperandType = "OPERAND_PCREL"; let ParserMatchClass = SoppBrTarget; } def const_ga : Operand; include "SIInstrFormats.td" include "VIInstrFormats.td" def MubufOffsetMatchClass : AsmOperandClass { let Name = "MubufOffset"; let ParserMethod = "parseMubufOptionalOps"; let RenderMethod = "addImmOperands"; } class DSOffsetBaseMatchClass : AsmOperandClass { let Name = "DSOffset"#parser; let ParserMethod = parser; let RenderMethod = "addImmOperands"; let PredicateMethod = "isDSOffset"; } def DSOffsetMatchClass : DSOffsetBaseMatchClass <"parseDSOptionalOps">; def DSOffsetGDSMatchClass : DSOffsetBaseMatchClass <"parseDSOffsetOptional">; def DSOffset01MatchClass : AsmOperandClass { let Name = "DSOffset1"; let ParserMethod = "parseDSOff01OptionalOps"; let RenderMethod = "addImmOperands"; let PredicateMethod = "isDSOffset01"; } class GDSBaseMatchClass : AsmOperandClass { let Name = "GDS"#parser; let PredicateMethod = "isImm"; let ParserMethod = parser; let RenderMethod = "addImmOperands"; } def GDSMatchClass : GDSBaseMatchClass <"parseDSOptionalOps">; def GDS01MatchClass : GDSBaseMatchClass <"parseDSOff01OptionalOps">; class GLCBaseMatchClass : AsmOperandClass { let Name = "GLC"#parser; let PredicateMethod = "isImm"; let ParserMethod = parser; let RenderMethod = "addImmOperands"; } def GLCMubufMatchClass : GLCBaseMatchClass <"parseMubufOptionalOps">; def GLCFlatMatchClass : GLCBaseMatchClass <"parseFlatOptionalOps">; class SLCBaseMatchClass : AsmOperandClass { let Name = "SLC"#parser; let PredicateMethod = "isImm"; let ParserMethod = parser; let RenderMethod = "addImmOperands"; } def SLCMubufMatchClass : SLCBaseMatchClass <"parseMubufOptionalOps">; def SLCFlatMatchClass : SLCBaseMatchClass <"parseFlatOptionalOps">; def SLCFlatAtomicMatchClass : SLCBaseMatchClass <"parseFlatAtomicOptionalOps">; class TFEBaseMatchClass : AsmOperandClass { let Name = "TFE"#parser; let PredicateMethod = "isImm"; let ParserMethod = parser; let RenderMethod = "addImmOperands"; } def TFEMubufMatchClass : TFEBaseMatchClass <"parseMubufOptionalOps">; def TFEFlatMatchClass : TFEBaseMatchClass <"parseFlatOptionalOps">; def TFEFlatAtomicMatchClass : TFEBaseMatchClass <"parseFlatAtomicOptionalOps">; def OModMatchClass : AsmOperandClass { let Name = "OMod"; let PredicateMethod = "isImm"; let ParserMethod = "parseVOP3OptionalOps"; let RenderMethod = "addImmOperands"; } def ClampMatchClass : AsmOperandClass { let Name = "Clamp"; let PredicateMethod = "isImm"; let ParserMethod = "parseVOP3OptionalOps"; let RenderMethod = "addImmOperands"; } class SMRDOffsetBaseMatchClass : AsmOperandClass { let Name = "SMRDOffset"#predicate; let PredicateMethod = predicate; let RenderMethod = "addImmOperands"; } def SMRDOffsetMatchClass : SMRDOffsetBaseMatchClass <"isSMRDOffset">; def SMRDLiteralOffsetMatchClass : SMRDOffsetBaseMatchClass < "isSMRDLiteralOffset" >; let OperandType = "OPERAND_IMMEDIATE" in { def offen : Operand { let PrintMethod = "printOffen"; } def idxen : Operand { let PrintMethod = "printIdxen"; } def addr64 : Operand { let PrintMethod = "printAddr64"; } def mbuf_offset : Operand { let PrintMethod = "printMBUFOffset"; let ParserMatchClass = MubufOffsetMatchClass; } class ds_offset_base : Operand { let PrintMethod = "printDSOffset"; let ParserMatchClass = mc; } def ds_offset : ds_offset_base ; def ds_offset_gds : ds_offset_base ; def ds_offset0 : Operand { let PrintMethod = "printDSOffset0"; let ParserMatchClass = DSOffset01MatchClass; } def ds_offset1 : Operand { let PrintMethod = "printDSOffset1"; let ParserMatchClass = DSOffset01MatchClass; } class gds_base : Operand { let PrintMethod = "printGDS"; let ParserMatchClass = mc; } def gds : gds_base ; def gds01 : gds_base ; class glc_base : Operand { let PrintMethod = "printGLC"; let ParserMatchClass = mc; } def glc : glc_base ; def glc_flat : glc_base ; class slc_base : Operand { let PrintMethod = "printSLC"; let ParserMatchClass = mc; } def slc : slc_base ; def slc_flat : slc_base ; def slc_flat_atomic : slc_base ; class tfe_base : Operand { let PrintMethod = "printTFE"; let ParserMatchClass = mc; } def tfe : tfe_base ; def tfe_flat : tfe_base ; def tfe_flat_atomic : tfe_base ; def omod : Operand { let PrintMethod = "printOModSI"; let ParserMatchClass = OModMatchClass; } def ClampMod : Operand { let PrintMethod = "printClampSI"; let ParserMatchClass = ClampMatchClass; } def smrd_offset : Operand { let PrintMethod = "printU32ImmOperand"; let ParserMatchClass = SMRDOffsetMatchClass; } def smrd_literal_offset : Operand { let PrintMethod = "printU32ImmOperand"; let ParserMatchClass = SMRDLiteralOffsetMatchClass; } } // End OperandType = "OPERAND_IMMEDIATE" def VOPDstS64 : VOPDstOperand ; //===----------------------------------------------------------------------===// // Complex patterns //===----------------------------------------------------------------------===// def DS1Addr1Offset : ComplexPattern; def DS64Bit4ByteAligned : ComplexPattern; def MUBUFAddr32 : ComplexPattern; def MUBUFAddr64 : ComplexPattern; def MUBUFAddr64Atomic : ComplexPattern; def MUBUFScratch : ComplexPattern; def MUBUFOffset : ComplexPattern; def MUBUFOffsetAtomic : ComplexPattern; def SMRDImm : ComplexPattern; def SMRDImm32 : ComplexPattern; def SMRDSgpr : ComplexPattern; def SMRDBufferImm : ComplexPattern; def SMRDBufferImm32 : ComplexPattern; def SMRDBufferSgpr : ComplexPattern; def VOP3Mods0 : ComplexPattern; def VOP3NoMods0 : ComplexPattern; def VOP3Mods0Clamp : ComplexPattern; def VOP3Mods0Clamp0OMod : ComplexPattern; def VOP3Mods : ComplexPattern; def VOP3NoMods : ComplexPattern; //===----------------------------------------------------------------------===// // SI assembler operands //===----------------------------------------------------------------------===// def SIOperand { int ZERO = 0x80; int VCC = 0x6A; int FLAT_SCR = 0x68; } def SRCMODS { int NONE = 0; int NEG = 1; } def DSTCLAMP { int NONE = 0; } def DSTOMOD { int NONE = 0; } //===----------------------------------------------------------------------===// // // SI Instruction multiclass helpers. // // Instructions with _32 take 32-bit operands. // Instructions with _64 take 64-bit operands. // // VOP_* instructions can use either a 32-bit or 64-bit encoding. The 32-bit // encoding is the standard encoding, but instruction that make use of // any of the instruction modifiers must use the 64-bit encoding. // // Instructions with _e32 use the 32-bit encoding. // Instructions with _e64 use the 64-bit encoding. // //===----------------------------------------------------------------------===// class SIMCInstr { string PseudoInstr = pseudo; int Subtarget = subtarget; } //===----------------------------------------------------------------------===// // EXP classes //===----------------------------------------------------------------------===// class EXPCommon : InstSI< (outs), (ins i32imm:$en, i32imm:$tgt, i32imm:$compr, i32imm:$done, i32imm:$vm, VGPR_32:$src0, VGPR_32:$src1, VGPR_32:$src2, VGPR_32:$src3), "exp $en, $tgt, $compr, $done, $vm, $src0, $src1, $src2, $src3", [] > { let EXP_CNT = 1; let Uses = [EXEC]; } multiclass EXP_m { let isPseudo = 1, isCodeGenOnly = 1 in { def "" : EXPCommon, SIMCInstr <"exp", SISubtarget.NONE> ; } def _si : EXPCommon, SIMCInstr <"exp", SISubtarget.SI>, EXPe; def _vi : EXPCommon, SIMCInstr <"exp", SISubtarget.VI>, EXPe_vi; } //===----------------------------------------------------------------------===// // Scalar classes //===----------------------------------------------------------------------===// class SOP1_Pseudo pattern> : SOP1 , SIMCInstr { let isPseudo = 1; let isCodeGenOnly = 1; } class SOP1_Real_si : SOP1 , SOP1e , SIMCInstr { let isCodeGenOnly = 0; let AssemblerPredicates = [isSICI]; } class SOP1_Real_vi : SOP1 , SOP1e , SIMCInstr { let isCodeGenOnly = 0; let AssemblerPredicates = [isVI]; } multiclass SOP1_m pattern> { def "" : SOP1_Pseudo ; def _si : SOP1_Real_si ; def _vi : SOP1_Real_vi ; } multiclass SOP1_32 pattern> : SOP1_m < op, opName, (outs SReg_32:$dst), (ins SSrc_32:$src0), opName#" $dst, $src0", pattern >; multiclass SOP1_64 pattern> : SOP1_m < op, opName, (outs SReg_64:$dst), (ins SSrc_64:$src0), opName#" $dst, $src0", pattern >; // no input, 64-bit output. multiclass SOP1_64_0 pattern> { def "" : SOP1_Pseudo ; def _si : SOP1_Real_si { let ssrc0 = 0; } def _vi : SOP1_Real_vi { let ssrc0 = 0; } } // 64-bit input, no output multiclass SOP1_1 pattern> { def "" : SOP1_Pseudo ; def _si : SOP1_Real_si { let sdst = 0; } def _vi : SOP1_Real_vi { let sdst = 0; } } // 64-bit input, 32-bit output. multiclass SOP1_32_64 pattern> : SOP1_m < op, opName, (outs SReg_32:$dst), (ins SSrc_64:$src0), opName#" $dst, $src0", pattern >; class SOP2_Pseudo pattern> : SOP2, SIMCInstr { let isPseudo = 1; let isCodeGenOnly = 1; let Size = 4; // Pseudo instructions have no encodings, but adding this field here allows // us to do: // let sdst = xxx in { // for multiclasses that include both real and pseudo instructions. field bits<7> sdst = 0; } class SOP2_Real_si : SOP2, SOP2e, SIMCInstr { let AssemblerPredicates = [isSICI]; } class SOP2_Real_vi : SOP2, SOP2e, SIMCInstr { let AssemblerPredicates = [isVI]; } multiclass SOP2_m pattern> { def "" : SOP2_Pseudo ; def _si : SOP2_Real_si ; def _vi : SOP2_Real_vi ; } multiclass SOP2_32 pattern> : SOP2_m < op, opName, (outs SReg_32:$dst), (ins SSrc_32:$src0, SSrc_32:$src1), opName#" $dst, $src0, $src1", pattern >; multiclass SOP2_64 pattern> : SOP2_m < op, opName, (outs SReg_64:$dst), (ins SSrc_64:$src0, SSrc_64:$src1), opName#" $dst, $src0, $src1", pattern >; multiclass SOP2_64_32 pattern> : SOP2_m < op, opName, (outs SReg_64:$dst), (ins SSrc_64:$src0, SSrc_32:$src1), opName#" $dst, $src0, $src1", pattern >; class SOPC_Helper op, RegisterOperand rc, ValueType vt, string opName, PatLeaf cond> : SOPC < op, (outs), (ins rc:$src0, rc:$src1), opName#" $src0, $src1", []> { let Defs = [SCC]; } class SOPC_32 op, string opName, PatLeaf cond = COND_NULL> : SOPC_Helper; class SOPC_64 op, string opName, PatLeaf cond = COND_NULL> : SOPC_Helper; class SOPK_Pseudo pattern> : SOPK , SIMCInstr { let isPseudo = 1; let isCodeGenOnly = 1; } class SOPK_Real_si : SOPK , SOPKe , SIMCInstr { let AssemblerPredicates = [isSICI]; let isCodeGenOnly = 0; } class SOPK_Real_vi : SOPK , SOPKe , SIMCInstr { let AssemblerPredicates = [isVI]; let isCodeGenOnly = 0; } multiclass SOPK_m { def "" : SOPK_Pseudo ; def _si : SOPK_Real_si ; def _vi : SOPK_Real_vi ; } multiclass SOPK_32 pattern> { def "" : SOPK_Pseudo ; def _si : SOPK_Real_si ; def _vi : SOPK_Real_vi ; } multiclass SOPK_SCC pattern> { def "" : SOPK_Pseudo { let Defs = [SCC]; } def _si : SOPK_Real_si { let Defs = [SCC]; } def _vi : SOPK_Real_vi { let Defs = [SCC]; } } multiclass SOPK_32TIE pattern> : SOPK_m < op, opName, (outs SReg_32:$sdst), (ins SReg_32:$src0, u16imm:$simm16), " $sdst, $simm16" >; multiclass SOPK_IMM32 { def "" : SOPK_Pseudo ; def _si : SOPK , SOPK64e , SIMCInstr { let AssemblerPredicates = [isSICI]; let isCodeGenOnly = 0; } def _vi : SOPK , SOPK64e , SIMCInstr { let AssemblerPredicates = [isVI]; let isCodeGenOnly = 0; } } //===----------------------------------------------------------------------===// // SMRD classes //===----------------------------------------------------------------------===// class SMRD_Pseudo pattern> : SMRD , SIMCInstr { let isPseudo = 1; let isCodeGenOnly = 1; } class SMRD_Real_si op, string opName, bit imm, dag outs, dag ins, string asm> : SMRD , SMRDe , SIMCInstr { let AssemblerPredicates = [isSICI]; } class SMRD_Real_vi op, string opName, bit imm, dag outs, dag ins, string asm, list pattern = []> : SMRD , SMEMe_vi , SIMCInstr { let AssemblerPredicates = [isVI]; } multiclass SMRD_m pattern> { def "" : SMRD_Pseudo ; def _si : SMRD_Real_si ; // glc is only applicable to scalar stores, which are not yet // implemented. let glc = 0 in { def _vi : SMRD_Real_vi ; } } multiclass SMRD_Inval { let hasSideEffects = 1, mayStore = 1 in { def "" : SMRD_Pseudo ; let sbase = 0, offset = 0 in { let sdst = 0 in { def _si : SMRD_Real_si ; } let glc = 0, sdata = 0 in { def _vi : SMRD_Real_vi ; } } } } class SMEM_Inval op, string opName, SDPatternOperator node> : SMRD_Real_vi { let hasSideEffects = 1; let mayStore = 1; let sbase = 0; let sdata = 0; let glc = 0; let offset = 0; } multiclass SMRD_Helper { defm _IMM : SMRD_m < op, opName#"_IMM", 1, (outs dstClass:$dst), (ins baseClass:$sbase, smrd_offset:$offset), opName#" $dst, $sbase, $offset", [] >; def _IMM_ci : SMRD < (outs dstClass:$dst), (ins baseClass:$sbase, smrd_literal_offset:$offset), opName#" $dst, $sbase, $offset", []>, SMRD_IMMe_ci { let AssemblerPredicates = [isCIOnly]; } defm _SGPR : SMRD_m < op, opName#"_SGPR", 0, (outs dstClass:$dst), (ins baseClass:$sbase, SReg_32:$soff), opName#" $dst, $sbase, $soff", [] >; } //===----------------------------------------------------------------------===// // Vector ALU classes //===----------------------------------------------------------------------===// // This must always be right before the operand being input modified. def InputMods : OperandWithDefaultOps { let PrintMethod = "printOperandAndMods"; } def InputModsMatchClass : AsmOperandClass { let Name = "RegWithInputMods"; } def InputModsNoDefault : Operand { let PrintMethod = "printOperandAndMods"; let ParserMatchClass = InputModsMatchClass; } class getNumSrcArgs { int ret = !if (!eq(Src0.Value, untyped.Value), 0, !if (!eq(Src1.Value, untyped.Value), 1, // VOP1 !if (!eq(Src2.Value, untyped.Value), 2, // VOP2 3))); // VOP3 } // Returns the register class to use for the destination of VOP[123C] // instructions for the given VT. class getVALUDstForVT { RegisterOperand ret = !if(!eq(VT.Size, 32), VOPDstOperand, !if(!eq(VT.Size, 64), VOPDstOperand, !if(!eq(VT.Size, 16), VOPDstOperand, VOPDstOperand))); // else VT == i1 } // Returns the register class to use for source 0 of VOP[12C] // instructions for the given VT. class getVOPSrc0ForVT { RegisterOperand ret = !if(!eq(VT.Size, 64), VSrc_64, VSrc_32); } // Returns the register class to use for source 1 of VOP[12C] for the // given VT. class getVOPSrc1ForVT { RegisterClass ret = !if(!eq(VT.Size, 64), VReg_64, VGPR_32); } // Returns the register class to use for sources of VOP3 instructions for the // given VT. class getVOP3SrcForVT { RegisterOperand ret = !if(!eq(VT.Size, 64), VCSrc_64, !if(!eq(VT.Value, i1.Value), SCSrc_64, VCSrc_32 ) ); } // Returns 1 if the source arguments have modifiers, 0 if they do not. // XXX - do f16 instructions? class hasModifiers { bit ret = !if(!eq(SrcVT.Value, f32.Value), 1, !if(!eq(SrcVT.Value, f64.Value), 1, 0)); } // Returns the input arguments for VOP[12C] instructions for the given SrcVT. class getIns32 { dag ret = !if(!eq(NumSrcArgs, 1), (ins Src0RC:$src0), // VOP1 !if(!eq(NumSrcArgs, 2), (ins Src0RC:$src0, Src1RC:$src1), // VOP2 (ins))); } // Returns the input arguments for VOP3 instructions for the given SrcVT. class getIns64 { dag ret = !if (!eq(NumSrcArgs, 1), !if (!eq(HasModifiers, 1), // VOP1 with modifiers (ins InputModsNoDefault:$src0_modifiers, Src0RC:$src0, ClampMod:$clamp, omod:$omod) /* else */, // VOP1 without modifiers (ins Src0RC:$src0) /* endif */ ), !if (!eq(NumSrcArgs, 2), !if (!eq(HasModifiers, 1), // VOP 2 with modifiers (ins InputModsNoDefault:$src0_modifiers, Src0RC:$src0, InputModsNoDefault:$src1_modifiers, Src1RC:$src1, ClampMod:$clamp, omod:$omod) /* else */, // VOP2 without modifiers (ins Src0RC:$src0, Src1RC:$src1) /* endif */ ) /* NumSrcArgs == 3 */, !if (!eq(HasModifiers, 1), // VOP3 with modifiers (ins InputModsNoDefault:$src0_modifiers, Src0RC:$src0, InputModsNoDefault:$src1_modifiers, Src1RC:$src1, InputModsNoDefault:$src2_modifiers, Src2RC:$src2, ClampMod:$clamp, omod:$omod) /* else */, // VOP3 without modifiers (ins Src0RC:$src0, Src1RC:$src1, Src2RC:$src2) /* endif */ ))); } // Returns the assembly string for the inputs and outputs of a VOP[12C] // instruction. This does not add the _e32 suffix, so it can be reused // by getAsm64. class getAsm32 { string dst = "$dst"; string src0 = ", $src0"; string src1 = ", $src1"; string src2 = ", $src2"; string ret = !if(HasDst, dst, "") # !if(!eq(NumSrcArgs, 1), src0, "") # !if(!eq(NumSrcArgs, 2), src0#src1, "") # !if(!eq(NumSrcArgs, 3), src0#src1#src2, ""); } // Returns the assembly string for the inputs and outputs of a VOP3 // instruction. class getAsm64 { string src0 = !if(!eq(NumSrcArgs, 1), "$src0_modifiers", "$src0_modifiers,"); string src1 = !if(!eq(NumSrcArgs, 1), "", !if(!eq(NumSrcArgs, 2), " $src1_modifiers", " $src1_modifiers,")); string src2 = !if(!eq(NumSrcArgs, 3), " $src2_modifiers", ""); string ret = !if(!eq(HasModifiers, 0), getAsm32.ret, "$dst, "#src0#src1#src2#"$clamp"#"$omod"); } class VOPProfile _ArgVT> { field list ArgVT = _ArgVT; field ValueType DstVT = ArgVT[0]; field ValueType Src0VT = ArgVT[1]; field ValueType Src1VT = ArgVT[2]; field ValueType Src2VT = ArgVT[3]; field RegisterOperand DstRC = getVALUDstForVT.ret; field RegisterOperand Src0RC32 = getVOPSrc0ForVT.ret; field RegisterClass Src1RC32 = getVOPSrc1ForVT.ret; field RegisterOperand Src0RC64 = getVOP3SrcForVT.ret; field RegisterOperand Src1RC64 = getVOP3SrcForVT.ret; field RegisterOperand Src2RC64 = getVOP3SrcForVT.ret; field bit HasDst = !if(!eq(DstVT.Value, untyped.Value), 0, 1); field bit HasDst32 = HasDst; field int NumSrcArgs = getNumSrcArgs.ret; field bit HasModifiers = hasModifiers.ret; field dag Outs = !if(HasDst,(outs DstRC:$dst),(outs)); // VOP3b instructions are a special case with a second explicit // output. This is manually overridden for them. field dag Outs32 = Outs; field dag Outs64 = Outs; field dag Ins32 = getIns32.ret; field dag Ins64 = getIns64.ret; field string Asm32 = getAsm32.ret; field string Asm64 = getAsm64.ret; } // FIXME: I think these F16/I16 profiles will need to use f16/i16 types in order // for the instruction patterns to work. def VOP_F16_F16 : VOPProfile <[f16, f16, untyped, untyped]>; def VOP_F16_I16 : VOPProfile <[f16, i32, untyped, untyped]>; def VOP_I16_F16 : VOPProfile <[i32, f16, untyped, untyped]>; def VOP_F16_F16_F16 : VOPProfile <[f16, f16, f16, untyped]>; def VOP_F16_F16_I16 : VOPProfile <[f16, f16, i32, untyped]>; def VOP_I16_I16_I16 : VOPProfile <[i32, i32, i32, untyped]>; def VOP_NONE : VOPProfile <[untyped, untyped, untyped, untyped]>; def VOP_F32_F32 : VOPProfile <[f32, f32, untyped, untyped]>; def VOP_F32_F64 : VOPProfile <[f32, f64, untyped, untyped]>; def VOP_F32_I32 : VOPProfile <[f32, i32, untyped, untyped]>; def VOP_F64_F32 : VOPProfile <[f64, f32, untyped, untyped]>; def VOP_F64_F64 : VOPProfile <[f64, f64, untyped, untyped]>; def VOP_F64_I32 : VOPProfile <[f64, i32, untyped, untyped]>; def VOP_I32_F32 : VOPProfile <[i32, f32, untyped, untyped]>; def VOP_I32_F64 : VOPProfile <[i32, f64, untyped, untyped]>; def VOP_I32_I32 : VOPProfile <[i32, i32, untyped, untyped]>; def VOP_F32_F32_F32 : VOPProfile <[f32, f32, f32, untyped]>; def VOP_F32_F32_I32 : VOPProfile <[f32, f32, i32, untyped]>; def VOP_F64_F64_F64 : VOPProfile <[f64, f64, f64, untyped]>; def VOP_F64_F64_I32 : VOPProfile <[f64, f64, i32, untyped]>; def VOP_I32_F32_F32 : VOPProfile <[i32, f32, f32, untyped]>; def VOP_I32_F32_I32 : VOPProfile <[i32, f32, i32, untyped]>; def VOP_I32_I32_I32 : VOPProfile <[i32, i32, i32, untyped]>; // Write out to vcc or arbitrary SGPR. def VOP2b_I32_I1_I32_I32 : VOPProfile<[i32, i32, i32, untyped]> { let Asm32 = "$dst, vcc, $src0, $src1"; let Asm64 = "$dst, $sdst, $src0, $src1"; let Outs32 = (outs DstRC:$dst); let Outs64 = (outs DstRC:$dst, SReg_64:$sdst); } // Write out to vcc or arbitrary SGPR and read in from vcc or // arbitrary SGPR. def VOP2b_I32_I1_I32_I32_I1 : VOPProfile<[i32, i32, i32, i1]> { // We use VCSrc_32 to exclude literal constants, even though the // encoding normally allows them since the implicit VCC use means // using one would always violate the constant bus // restriction. SGPRs are still allowed because it should // technically be possible to use VCC again as src0. let Src0RC32 = VCSrc_32; let Asm32 = "$dst, vcc, $src0, $src1, vcc"; let Asm64 = "$dst, $sdst, $src0, $src1, $src2"; let Outs32 = (outs DstRC:$dst); let Outs64 = (outs DstRC:$dst, SReg_64:$sdst); // Suppress src2 implied by type since the 32-bit encoding uses an // implicit VCC use. let Ins32 = (ins Src0RC32:$src0, Src1RC32:$src1); } class VOP3b_Profile : VOPProfile<[vt, vt, vt, vt]> { let Outs64 = (outs DstRC:$vdst, SReg_64:$sdst); let Asm64 = "$vdst, $sdst, $src0_modifiers, $src1_modifiers, $src2_modifiers"#"$clamp"#"$omod"; } def VOP3b_F32_I1_F32_F32_F32 : VOP3b_Profile { // FIXME: Hack to stop printing _e64 let DstRC = RegisterOperand; } def VOP3b_F64_I1_F64_F64_F64 : VOP3b_Profile { // FIXME: Hack to stop printing _e64 let DstRC = RegisterOperand; } // VOPC instructions are a special case because for the 32-bit // encoding, we want to display the implicit vcc write as if it were // an explicit $dst. class VOPC_Profile : VOPProfile <[i1, vt0, vt1, untyped]> { let Asm32 = "vcc, $src0, $src1"; // The destination for 32-bit encoding is implicit. let HasDst32 = 0; } class VOPC_Class_Profile : VOPC_Profile { let Ins64 = (ins InputModsNoDefault:$src0_modifiers, Src0RC64:$src0, Src1RC64:$src1); let Asm64 = "$dst, $src0_modifiers, $src1"; } def VOPC_I1_F32_F32 : VOPC_Profile; def VOPC_I1_F64_F64 : VOPC_Profile; def VOPC_I1_I32_I32 : VOPC_Profile; def VOPC_I1_I64_I64 : VOPC_Profile; def VOPC_I1_F32_I32 : VOPC_Class_Profile; def VOPC_I1_F64_I32 : VOPC_Class_Profile; def VOP_I64_I64_I32 : VOPProfile <[i64, i64, i32, untyped]>; def VOP_I64_I32_I64 : VOPProfile <[i64, i32, i64, untyped]>; def VOP_I64_I64_I64 : VOPProfile <[i64, i64, i64, untyped]>; def VOP_CNDMASK : VOPProfile <[i32, i32, i32, untyped]> { let Ins32 = (ins Src0RC32:$src0, Src1RC32:$src1); let Ins64 = (ins Src0RC64:$src0, Src1RC64:$src1, SSrc_64:$src2); let Asm64 = "$dst, $src0, $src1, $src2"; } def VOP_F32_F32_F32_F32 : VOPProfile <[f32, f32, f32, f32]>; def VOP_MADK : VOPProfile <[f32, f32, f32, f32]> { field dag Ins = (ins VCSrc_32:$src0, VGPR_32:$vsrc1, u32imm:$src2); field string Asm = "$dst, $src0, $vsrc1, $src2"; } def VOP_MAC : VOPProfile <[f32, f32, f32, f32]> { let Ins32 = (ins Src0RC32:$src0, Src1RC32:$src1, VGPR_32:$src2); let Ins64 = getIns64, 3, HasModifiers>.ret; let Asm32 = getAsm32<1, 2>.ret; let Asm64 = getAsm64<1, 2, HasModifiers>.ret; } def VOP_F64_F64_F64_F64 : VOPProfile <[f64, f64, f64, f64]>; def VOP_I32_I32_I32_I32 : VOPProfile <[i32, i32, i32, i32]>; def VOP_I64_I32_I32_I64 : VOPProfile <[i64, i32, i32, i64]>; class SIInstAlias : InstAlias , PredicateControl { field bit isCompare; field bit isCommutable; let ResultInst = !if (p.HasDst32, !if (!eq(p.NumSrcArgs, 0), // 1 dst, 0 src (inst p.DstRC:$dst), !if (!eq(p.NumSrcArgs, 1), // 1 dst, 1 src (inst p.DstRC:$dst, p.Src0RC32:$src0), !if (!eq(p.NumSrcArgs, 2), // 1 dst, 2 src (inst p.DstRC:$dst, p.Src0RC32:$src0, p.Src1RC32:$src1), // else - unreachable (inst)))), // else !if (!eq(p.NumSrcArgs, 2), // 0 dst, 2 src (inst p.Src0RC32:$src0, p.Src1RC32:$src1), !if (!eq(p.NumSrcArgs, 1), // 0 dst, 1 src (inst p.Src0RC32:$src1), // else // 0 dst, 0 src (inst)))); } class SIInstAliasSI : SIInstAlias (op_name#"_e32_si"), p> { let AssemblerPredicate = SIAssemblerPredicate; } class SIInstAliasVI : SIInstAlias (op_name#"_e32_vi"), p> { let AssemblerPredicates = [isVI]; } multiclass SIInstAliasBuilder { def : SIInstAliasSI ; def : SIInstAliasVI ; } class VOP { string OpName = opName; } class VOP2_REV { string RevOp = revOp; bit IsOrig = isOrig; } class AtomicNoRet { string NoRetOp = noRetOp; bit IsRet = isRet; } class VOP1_Pseudo pattern, string opName> : VOP1Common , VOP , SIMCInstr , MnemonicAlias { let isPseudo = 1; let isCodeGenOnly = 1; field bits<8> vdst; field bits<9> src0; } class VOP1_Real_si : VOP1, SIMCInstr { let AssemblerPredicate = SIAssemblerPredicate; } class VOP1_Real_vi : VOP1, SIMCInstr { let AssemblerPredicates = [isVI]; } multiclass VOP1_m pattern, string asm = opName#p.Asm32> { def "" : VOP1_Pseudo ; def _si : VOP1_Real_si ; def _vi : VOP1_Real_vi ; } multiclass VOP1SI_m pattern, string asm = opName#p.Asm32> { def "" : VOP1_Pseudo ; def _si : VOP1_Real_si ; } class VOP2_Pseudo pattern, string opName> : VOP2Common , VOP , SIMCInstr, MnemonicAlias { let isPseudo = 1; let isCodeGenOnly = 1; } class VOP2_Real_si : VOP2 , SIMCInstr { let AssemblerPredicates = [isSICI]; } class VOP2_Real_vi : VOP2 , SIMCInstr { let AssemblerPredicates = [isVI]; } multiclass VOP2SI_m pattern, string revOp> { def "" : VOP2_Pseudo , VOP2_REV; def _si : VOP2_Real_si ; } multiclass VOP2_m pattern, string revOp> { def "" : VOP2_Pseudo , VOP2_REV; def _si : VOP2_Real_si ; def _vi : VOP2_Real_vi ; } class VOP3DisableFields { bits<2> src0_modifiers = !if(HasModifiers, ?, 0); bits<2> src1_modifiers = !if(HasModifiers, !if(HasSrc1, ?, 0), 0); bits<2> src2_modifiers = !if(HasModifiers, !if(HasSrc2, ?, 0), 0); bits<2> omod = !if(HasModifiers, ?, 0); bits<1> clamp = !if(HasModifiers, ?, 0); bits<9> src1 = !if(HasSrc1, ?, 0); bits<9> src2 = !if(HasSrc2, ?, 0); } class VOP3DisableModFields { bits<2> src0_modifiers = !if(HasSrc0Mods, ?, 0); bits<2> src1_modifiers = !if(HasSrc1Mods, ?, 0); bits<2> src2_modifiers = !if(HasSrc2Mods, ?, 0); bits<2> omod = !if(HasOutputMods, ?, 0); bits<1> clamp = !if(HasOutputMods, ?, 0); } class VOP3_Pseudo pattern, string opName> : VOP3Common , VOP , SIMCInstr, MnemonicAlias { let isPseudo = 1; let isCodeGenOnly = 1; field bit vdst; field bit src0; } class VOP3_Real_si op, dag outs, dag ins, string asm, string opName> : VOP3Common , VOP3e , SIMCInstr { let AssemblerPredicates = [isSICI]; } class VOP3_Real_vi op, dag outs, dag ins, string asm, string opName> : VOP3Common , VOP3e_vi , SIMCInstr { let AssemblerPredicates = [isVI]; } class VOP3b_Real_si op, dag outs, dag ins, string asm, string opName> : VOP3Common , VOP3be , SIMCInstr { let AssemblerPredicates = [isSICI]; } class VOP3b_Real_vi op, dag outs, dag ins, string asm, string opName> : VOP3Common , VOP3be_vi , SIMCInstr { let AssemblerPredicates = [isVI]; } multiclass VOP3_m pattern, string opName, int NumSrcArgs, bit HasMods = 1> { def "" : VOP3_Pseudo ; def _si : VOP3_Real_si , VOP3DisableFields; def _vi : VOP3_Real_vi , VOP3DisableFields; } multiclass VOP3_1_m pattern, string opName, bit HasMods = 1> { def "" : VOP3_Pseudo ; def _si : VOP3_Real_si , VOP3DisableFields<0, 0, HasMods>; def _vi : VOP3_Real_vi , VOP3DisableFields<0, 0, HasMods>; } multiclass VOP3SI_1_m pattern, string opName, bit HasMods = 1> { def "" : VOP3_Pseudo ; def _si : VOP3_Real_si , VOP3DisableFields<0, 0, HasMods>; // No VI instruction. This class is for SI only. } multiclass VOP3_2_m pattern, string opName, string revOp, bit HasMods = 1> { def "" : VOP3_Pseudo , VOP2_REV; def _si : VOP3_Real_si , VOP3DisableFields<1, 0, HasMods>; def _vi : VOP3_Real_vi , VOP3DisableFields<1, 0, HasMods>; } multiclass VOP3SI_2_m pattern, string opName, string revOp, bit HasMods = 1> { def "" : VOP3_Pseudo , VOP2_REV; def _si : VOP3_Real_si , VOP3DisableFields<1, 0, HasMods>; // No VI instruction. This class is for SI only. } // Two operand VOP3b instruction that may have a 3rd SGPR bool operand // instead of an implicit VCC as in the VOP2b format. multiclass VOP3b_2_3_m pattern, string opName, string revOp, bit HasMods = 1, bit useSrc2Input = 0> { def "" : VOP3_Pseudo ; def _si : VOP3b_Real_si , VOP3DisableFields<1, useSrc2Input, HasMods>; def _vi : VOP3b_Real_vi , VOP3DisableFields<1, useSrc2Input, HasMods>; } multiclass VOP3_C_m pattern, string opName, bit HasMods, bit defExec, string revOp, list sched> { def "" : VOP3_Pseudo , VOP2_REV { let Defs = !if(defExec, [EXEC], []); let SchedRW = sched; } def _si : VOP3_Real_si , VOP3DisableFields<1, 0, HasMods> { let Defs = !if(defExec, [EXEC], []); let SchedRW = sched; } def _vi : VOP3_Real_vi , VOP3DisableFields<1, 0, HasMods> { let Defs = !if(defExec, [EXEC], []); let SchedRW = sched; } } // An instruction that is VOP2 on SI and VOP3 on VI, no modifiers. multiclass VOP2SI_3VI_m pattern = []> { let isPseudo = 1, isCodeGenOnly = 1 in { def "" : VOPAnyCommon , SIMCInstr; } def _si : VOP2 , SIMCInstr { let AssemblerPredicates = [isSICI]; } def _vi : VOP3Common , VOP3e_vi , VOP3DisableFields <1, 0, 0>, SIMCInstr { let AssemblerPredicates = [isVI]; } } multiclass VOP1_Helper pat32, list pat64> { defm _e32 : VOP1_m ; defm _e64 : VOP3_1_m ; } multiclass VOP1Inst : VOP1_Helper < op, opName, P, [], !if(P.HasModifiers, [(set P.DstVT:$dst, (node (P.Src0VT (VOP3Mods0 P.Src0VT:$src0, i32:$src0_modifiers, i1:$clamp, i32:$omod))))], [(set P.DstVT:$dst, (node P.Src0VT:$src0))]) >; multiclass VOP1InstSI { defm _e32 : VOP1SI_m ; defm _e64 : VOP3SI_1_m ; } multiclass VOP2_Helper pat32, list pat64, string revOp> { defm _e32 : VOP2_m ; defm _e64 : VOP3_2_m ; } multiclass VOP2Inst : VOP2_Helper < op, opName, P, [], !if(P.HasModifiers, [(set P.DstVT:$dst, (node (P.Src0VT (VOP3Mods0 P.Src0VT:$src0, i32:$src0_modifiers, i1:$clamp, i32:$omod)), (P.Src1VT (VOP3Mods P.Src1VT:$src1, i32:$src1_modifiers))))], [(set P.DstVT:$dst, (node P.Src0VT:$src0, P.Src1VT:$src1))]), revOp >; multiclass VOP2InstSI { defm _e32 : VOP2SI_m ; defm _e64 : VOP3SI_2_m ; } multiclass VOP2b_Helper pat32, list pat64, string revOp, bit useSGPRInput> { let SchedRW = [Write32Bit, WriteSALU] in { let Uses = !if(useSGPRInput, [VCC, EXEC], [EXEC]), Defs = [VCC] in { defm _e32 : VOP2_m ; } defm _e64 : VOP3b_2_3_m ; } } multiclass VOP2bInst : VOP2b_Helper < op, opName, P, [], !if(P.HasModifiers, [(set P.DstVT:$dst, (node (P.Src0VT (VOP3Mods0 P.Src0VT:$src0, i32:$src0_modifiers, i1:$clamp, i32:$omod)), (P.Src1VT (VOP3Mods P.Src1VT:$src1, i32:$src1_modifiers))))], [(set P.DstVT:$dst, (node P.Src0VT:$src0, P.Src1VT:$src1))]), revOp, !eq(P.NumSrcArgs, 3) >; // A VOP2 instruction that is VOP3-only on VI. multiclass VOP2_VI3_Helper pat32, list pat64, string revOp> { defm _e32 : VOP2SI_m ; defm _e64 : VOP3_2_m ; } multiclass VOP2_VI3_Inst : VOP2_VI3_Helper < op, opName, P, [], !if(P.HasModifiers, [(set P.DstVT:$dst, (node (P.Src0VT (VOP3Mods0 P.Src0VT:$src0, i32:$src0_modifiers, i1:$clamp, i32:$omod)), (P.Src1VT (VOP3Mods P.Src1VT:$src1, i32:$src1_modifiers))))], [(set P.DstVT:$dst, (node P.Src0VT:$src0, P.Src1VT:$src1))]), revOp >; multiclass VOP2MADK pattern = []> { def "" : VOP2_Pseudo ; let isCodeGenOnly = 0 in { def _si : VOP2Common , SIMCInstr , VOP2_MADKe { let AssemblerPredicates = [isSICI]; } def _vi : VOP2Common , SIMCInstr , VOP2_MADKe { let AssemblerPredicates = [isVI]; } } // End isCodeGenOnly = 0 } class VOPC_Pseudo pattern, string opName> : VOPCCommon , VOP , SIMCInstr { let isPseudo = 1; let isCodeGenOnly = 1; } multiclass VOPC_m pattern, string opName, bit DefExec, VOPProfile p, list sched, string revOpName = "", string asm = opName#"_e32 "#op_asm, string alias_asm = opName#" "#op_asm> { def "" : VOPC_Pseudo , VOP2_REV { let Defs = !if(DefExec, [VCC, EXEC], [VCC]); let SchedRW = sched; } let AssemblerPredicates = [isSICI] in { def _si : VOPC, SIMCInstr { let Defs = !if(DefExec, [VCC, EXEC], [VCC]); let hasSideEffects = DefExec; let SchedRW = sched; } } // End AssemblerPredicates = [isSICI] let AssemblerPredicates = [isVI] in { def _vi : VOPC, SIMCInstr { let Defs = !if(DefExec, [VCC, EXEC], [VCC]); let hasSideEffects = DefExec; let SchedRW = sched; } } // End AssemblerPredicates = [isVI] defm : SIInstAliasBuilder; } multiclass VOPC_Helper pat32, list pat64, bit DefExec, string revOp, VOPProfile p, list sched> { defm _e32 : VOPC_m ; defm _e64 : VOP3_C_m ; } // Special case for class instructions which only have modifiers on // the 1st source operand. multiclass VOPC_Class_Helper pat32, list pat64, bit DefExec, string revOp, VOPProfile p, list sched> { defm _e32 : VOPC_m ; defm _e64 : VOP3_C_m , VOP3DisableModFields<1, 0, 0>; } multiclass VOPCInst sched = [Write32Bit]> : VOPC_Helper < op, opName, [], !if(P.HasModifiers, [(set i1:$dst, (setcc (P.Src0VT (VOP3Mods0 P.Src0VT:$src0, i32:$src0_modifiers, i1:$clamp, i32:$omod)), (P.Src1VT (VOP3Mods P.Src1VT:$src1, i32:$src1_modifiers)), cond))], [(set i1:$dst, (setcc P.Src0VT:$src0, P.Src1VT:$src1, cond))]), DefExec, revOp, P, sched >; multiclass VOPCClassInst sched> : VOPC_Class_Helper < op, opName, [], !if(P.HasModifiers, [(set i1:$dst, (AMDGPUfp_class (P.Src0VT (VOP3Mods0Clamp0OMod P.Src0VT:$src0, i32:$src0_modifiers)), P.Src1VT:$src1))], [(set i1:$dst, (AMDGPUfp_class P.Src0VT:$src0, P.Src1VT:$src1))]), DefExec, opName, P, sched >; multiclass VOPC_F32 : VOPCInst ; multiclass VOPC_F64 : VOPCInst ; multiclass VOPC_I32 : VOPCInst ; multiclass VOPC_I64 : VOPCInst ; multiclass VOPCX sched, string revOp = ""> : VOPCInst ; multiclass VOPCX_F32 : VOPCX ; multiclass VOPCX_F64 : VOPCX ; multiclass VOPCX_I32 : VOPCX ; multiclass VOPCX_I64 : VOPCX ; multiclass VOP3_Helper pat, int NumSrcArgs, bit HasMods> : VOP3_m < op, outs, ins, opName#" "#asm, pat, opName, NumSrcArgs, HasMods >; multiclass VOPC_CLASS_F32 : VOPCClassInst ; multiclass VOPCX_CLASS_F32 : VOPCClassInst ; multiclass VOPC_CLASS_F64 : VOPCClassInst ; multiclass VOPCX_CLASS_F64 : VOPCClassInst ; multiclass VOP3Inst : VOP3_Helper < op, opName, (outs P.DstRC.RegClass:$dst), P.Ins64, P.Asm64, !if(!eq(P.NumSrcArgs, 3), !if(P.HasModifiers, [(set P.DstVT:$dst, (node (P.Src0VT (VOP3Mods0 P.Src0VT:$src0, i32:$src0_modifiers, i1:$clamp, i32:$omod)), (P.Src1VT (VOP3Mods P.Src1VT:$src1, i32:$src1_modifiers)), (P.Src2VT (VOP3Mods P.Src2VT:$src2, i32:$src2_modifiers))))], [(set P.DstVT:$dst, (node P.Src0VT:$src0, P.Src1VT:$src1, P.Src2VT:$src2))]), !if(!eq(P.NumSrcArgs, 2), !if(P.HasModifiers, [(set P.DstVT:$dst, (node (P.Src0VT (VOP3Mods0 P.Src0VT:$src0, i32:$src0_modifiers, i1:$clamp, i32:$omod)), (P.Src1VT (VOP3Mods P.Src1VT:$src1, i32:$src1_modifiers))))], [(set P.DstVT:$dst, (node P.Src0VT:$src0, P.Src1VT:$src1))]) /* P.NumSrcArgs == 1 */, !if(P.HasModifiers, [(set P.DstVT:$dst, (node (P.Src0VT (VOP3Mods0 P.Src0VT:$src0, i32:$src0_modifiers, i1:$clamp, i32:$omod))))], [(set P.DstVT:$dst, (node P.Src0VT:$src0))]))), P.NumSrcArgs, P.HasModifiers >; // Special case for v_div_fmas_{f32|f64}, since it seems to be the // only VOP instruction that implicitly reads VCC. multiclass VOP3_VCC_Inst : VOP3_Helper < op, opName, (outs P.DstRC.RegClass:$dst), (ins InputModsNoDefault:$src0_modifiers, P.Src0RC64:$src0, InputModsNoDefault:$src1_modifiers, P.Src1RC64:$src1, InputModsNoDefault:$src2_modifiers, P.Src2RC64:$src2, ClampMod:$clamp, omod:$omod), "$dst, $src0_modifiers, $src1_modifiers, $src2_modifiers"#"$clamp"#"$omod", [(set P.DstVT:$dst, (node (P.Src0VT (VOP3Mods0 P.Src0VT:$src0, i32:$src0_modifiers, i1:$clamp, i32:$omod)), (P.Src1VT (VOP3Mods P.Src1VT:$src1, i32:$src1_modifiers)), (P.Src2VT (VOP3Mods P.Src2VT:$src2, i32:$src2_modifiers)), (i1 VCC)))], 3, 1 >; multiclass VOP3bInst pattern = []> : VOP3b_2_3_m < op, P.Outs64, P.Ins64, opName#" "#P.Asm64, pattern, opName, "", 1, 1 >; class Vop3ModPat : Pat< (node (P.Src0VT (VOP3Mods0 P.Src0VT:$src0, i32:$src0_modifiers, i1:$clamp, i32:$omod)), (P.Src1VT (VOP3Mods P.Src1VT:$src1, i32:$src1_modifiers)), (P.Src2VT (VOP3Mods P.Src2VT:$src2, i32:$src2_modifiers))), (Inst i32:$src0_modifiers, P.Src0VT:$src0, i32:$src1_modifiers, P.Src1VT:$src1, i32:$src2_modifiers, P.Src2VT:$src2, i1:$clamp, i32:$omod)>; //===----------------------------------------------------------------------===// // Interpolation opcodes //===----------------------------------------------------------------------===// class VINTRP_Pseudo pattern> : VINTRPCommon , SIMCInstr { let isPseudo = 1; let isCodeGenOnly = 1; } class VINTRP_Real_si op, string opName, dag outs, dag ins, string asm> : VINTRPCommon , VINTRPe , SIMCInstr; class VINTRP_Real_vi op, string opName, dag outs, dag ins, string asm> : VINTRPCommon , VINTRPe_vi , SIMCInstr; multiclass VINTRP_m op, dag outs, dag ins, string asm, list pattern = []> { def "" : VINTRP_Pseudo ; def _si : VINTRP_Real_si ; def _vi : VINTRP_Real_vi ; } //===----------------------------------------------------------------------===// // Vector I/O classes //===----------------------------------------------------------------------===// class DS_Pseudo pattern> : DS , SIMCInstr { let isPseudo = 1; let isCodeGenOnly = 1; } class DS_Real_si op, string opName, dag outs, dag ins, string asm> : DS , DSe , SIMCInstr { let isCodeGenOnly = 0; } class DS_Real_vi op, string opName, dag outs, dag ins, string asm> : DS , DSe_vi , SIMCInstr ; class DS_Off16_Real_si op, string opName, dag outs, dag ins, string asm> : DS_Real_si { // Single load interpret the 2 i8imm operands as a single i16 offset. bits<16> offset; let offset0 = offset{7-0}; let offset1 = offset{15-8}; let isCodeGenOnly = 0; } class DS_Off16_Real_vi op, string opName, dag outs, dag ins, string asm> : DS_Real_vi { // Single load interpret the 2 i8imm operands as a single i16 offset. bits<16> offset; let offset0 = offset{7-0}; let offset1 = offset{15-8}; } multiclass DS_1A_RET op, string opName, RegisterClass rc, dag outs = (outs rc:$vdst), dag ins = (ins VGPR_32:$addr, ds_offset:$offset, gds:$gds), string asm = opName#" $vdst, $addr"#"$offset$gds"> { def "" : DS_Pseudo ; let data0 = 0, data1 = 0 in { def _si : DS_Off16_Real_si ; def _vi : DS_Off16_Real_vi ; } } multiclass DS_1A_Off8_RET op, string opName, RegisterClass rc, dag outs = (outs rc:$vdst), dag ins = (ins VGPR_32:$addr, ds_offset0:$offset0, ds_offset1:$offset1, gds01:$gds), string asm = opName#" $vdst, $addr"#"$offset0"#"$offset1$gds"> { def "" : DS_Pseudo ; let data0 = 0, data1 = 0, AsmMatchConverter = "cvtDSOffset01" in { def _si : DS_Real_si ; def _vi : DS_Real_vi ; } } multiclass DS_1A1D_NORET op, string opName, RegisterClass rc, dag outs = (outs), dag ins = (ins VGPR_32:$addr, rc:$data0, ds_offset:$offset, gds:$gds), string asm = opName#" $addr, $data0"#"$offset$gds"> { def "" : DS_Pseudo , AtomicNoRet; let data1 = 0, vdst = 0 in { def _si : DS_Off16_Real_si ; def _vi : DS_Off16_Real_vi ; } } multiclass DS_1A1D_Off8_NORET op, string opName, RegisterClass rc, dag outs = (outs), dag ins = (ins VGPR_32:$addr, rc:$data0, rc:$data1, ds_offset0:$offset0, ds_offset1:$offset1, gds01:$gds), string asm = opName#" $addr, $data0, $data1"#"$offset0"#"$offset1"#"$gds"> { def "" : DS_Pseudo ; let vdst = 0, AsmMatchConverter = "cvtDSOffset01" in { def _si : DS_Real_si ; def _vi : DS_Real_vi ; } } multiclass DS_1A1D_RET op, string opName, RegisterClass rc, string noRetOp = "", dag outs = (outs rc:$vdst), dag ins = (ins VGPR_32:$addr, rc:$data0, ds_offset:$offset, gds:$gds), string asm = opName#" $vdst, $addr, $data0"#"$offset$gds"> { let hasPostISelHook = 1 in { def "" : DS_Pseudo , AtomicNoRet; let data1 = 0 in { def _si : DS_Off16_Real_si ; def _vi : DS_Off16_Real_vi ; } } } multiclass DS_1A2D_RET_m op, string opName, RegisterClass rc, string noRetOp = "", dag ins, dag outs = (outs rc:$vdst), string asm = opName#" $vdst, $addr, $data0, $data1"#"$offset"#"$gds"> { let hasPostISelHook = 1 in { def "" : DS_Pseudo , AtomicNoRet; def _si : DS_Off16_Real_si ; def _vi : DS_Off16_Real_vi ; } } multiclass DS_1A2D_RET op, string asm, RegisterClass rc, string noRetOp = "", RegisterClass src = rc> : DS_1A2D_RET_m ; multiclass DS_1A2D_NORET op, string opName, RegisterClass rc, string noRetOp = opName, dag outs = (outs), dag ins = (ins VGPR_32:$addr, rc:$data0, rc:$data1, ds_offset:$offset, gds:$gds), string asm = opName#" $addr, $data0, $data1"#"$offset"#"$gds"> { def "" : DS_Pseudo , AtomicNoRet; let vdst = 0 in { def _si : DS_Off16_Real_si ; def _vi : DS_Off16_Real_vi ; } } multiclass DS_0A_RET op, string opName, dag outs = (outs VGPR_32:$vdst), dag ins = (ins ds_offset:$offset, gds:$gds), string asm = opName#" $vdst"#"$offset"#"$gds"> { let mayLoad = 1, mayStore = 1 in { def "" : DS_Pseudo ; let addr = 0, data0 = 0, data1 = 0 in { def _si : DS_Off16_Real_si ; def _vi : DS_Off16_Real_vi ; } // end addr = 0, data0 = 0, data1 = 0 } // end mayLoad = 1, mayStore = 1 } multiclass DS_1A_RET_GDS op, string opName, dag outs = (outs VGPR_32:$vdst), dag ins = (ins VGPR_32:$addr, ds_offset_gds:$offset), string asm = opName#" $vdst, $addr"#"$offset gds"> { def "" : DS_Pseudo ; let data0 = 0, data1 = 0, gds = 1 in { def _si : DS_Off16_Real_si ; def _vi : DS_Off16_Real_vi ; } // end data0 = 0, data1 = 0, gds = 1 } multiclass DS_1A_GDS op, string opName, dag outs = (outs), dag ins = (ins VGPR_32:$addr), string asm = opName#" $addr gds"> { def "" : DS_Pseudo ; let vdst = 0, data0 = 0, data1 = 0, offset0 = 0, offset1 = 0, gds = 1 in { def _si : DS_Real_si ; def _vi : DS_Real_vi ; } // end vdst = 0, data = 0, data1 = 0, gds = 1 } multiclass DS_1A op, string opName, dag outs = (outs), dag ins = (ins VGPR_32:$addr, ds_offset:$offset, gds:$gds), string asm = opName#" $addr"#"$offset"#"$gds"> { let mayLoad = 1, mayStore = 1 in { def "" : DS_Pseudo ; let vdst = 0, data0 = 0, data1 = 0 in { def _si : DS_Off16_Real_si ; def _vi : DS_Off16_Real_vi ; } // let vdst = 0, data0 = 0, data1 = 0 } // end mayLoad = 1, mayStore = 1 } //===----------------------------------------------------------------------===// // MTBUF classes //===----------------------------------------------------------------------===// class MTBUF_Pseudo pattern> : MTBUF , SIMCInstr { let isPseudo = 1; let isCodeGenOnly = 1; } class MTBUF_Real_si op, string opName, dag outs, dag ins, string asm> : MTBUF , MTBUFe , SIMCInstr; class MTBUF_Real_vi op, string opName, dag outs, dag ins, string asm> : MTBUF , MTBUFe_vi , SIMCInstr ; multiclass MTBUF_m op, string opName, dag outs, dag ins, string asm, list pattern> { def "" : MTBUF_Pseudo ; def _si : MTBUF_Real_si ; def _vi : MTBUF_Real_vi <{0, op{2}, op{1}, op{0}}, opName, outs, ins, asm>; } let mayStore = 1, mayLoad = 0 in { multiclass MTBUF_Store_Helper op, string opName, RegisterClass regClass> : MTBUF_m < op, opName, (outs), (ins regClass:$vdata, u16imm:$offset, i1imm:$offen, i1imm:$idxen, i1imm:$glc, i1imm:$addr64, i8imm:$dfmt, i8imm:$nfmt, VGPR_32:$vaddr, SReg_128:$srsrc, i1imm:$slc, i1imm:$tfe, SCSrc_32:$soffset), opName#" $vdata, $offset, $offen, $idxen, $glc, $addr64, $dfmt," #" $nfmt, $vaddr, $srsrc, $slc, $tfe, $soffset", [] >; } // mayStore = 1, mayLoad = 0 let mayLoad = 1, mayStore = 0 in { multiclass MTBUF_Load_Helper op, string opName, RegisterClass regClass> : MTBUF_m < op, opName, (outs regClass:$dst), (ins u16imm:$offset, i1imm:$offen, i1imm:$idxen, i1imm:$glc, i1imm:$addr64, i8imm:$dfmt, i8imm:$nfmt, VGPR_32:$vaddr, SReg_128:$srsrc, i1imm:$slc, i1imm:$tfe, SCSrc_32:$soffset), opName#" $dst, $offset, $offen, $idxen, $glc, $addr64, $dfmt," #" $nfmt, $vaddr, $srsrc, $slc, $tfe, $soffset", [] >; } // mayLoad = 1, mayStore = 0 //===----------------------------------------------------------------------===// // MUBUF classes //===----------------------------------------------------------------------===// class mubuf si, bits<7> vi = si> { field bits<7> SI = si; field bits<7> VI = vi; } let isCodeGenOnly = 0 in { class MUBUF_si op, dag outs, dag ins, string asm, list pattern> : MUBUF , MUBUFe { let lds = 0; } } // End let isCodeGenOnly = 0 class MUBUF_vi op, dag outs, dag ins, string asm, list pattern> : MUBUF , MUBUFe_vi { let lds = 0; } class MUBUFAddr64Table { bit IsAddr64 = is_addr64; string OpName = NAME # suffix; } class MUBUF_Pseudo pattern> : MUBUF , SIMCInstr { let isPseudo = 1; let isCodeGenOnly = 1; // dummy fields, so that we can use let statements around multiclasses bits<1> offen; bits<1> idxen; bits<8> vaddr; bits<1> glc; bits<1> slc; bits<1> tfe; bits<8> soffset; } class MUBUF_Real_si : MUBUF , MUBUFe , SIMCInstr { let lds = 0; } class MUBUF_Real_vi : MUBUF , MUBUFe_vi , SIMCInstr { let lds = 0; } multiclass MUBUF_m pattern> { def "" : MUBUF_Pseudo , MUBUFAddr64Table <0>; let addr64 = 0, isCodeGenOnly = 0 in { def _si : MUBUF_Real_si ; } def _vi : MUBUF_Real_vi ; } multiclass MUBUFAddr64_m pattern> { def "" : MUBUF_Pseudo , MUBUFAddr64Table <1>; let addr64 = 1, isCodeGenOnly = 0 in { def _si : MUBUF_Real_si ; } // There is no VI version. If the pseudo is selected, it should be lowered // for VI appropriately. } multiclass MUBUFAtomicOffset_m pattern, bit is_return> { def "" : MUBUF_Pseudo , MUBUFAddr64Table <0, !if(is_return, "_RTN", "")>, AtomicNoRet; let offen = 0, idxen = 0, tfe = 0, vaddr = 0 in { let addr64 = 0 in { def _si : MUBUF_Real_si ; } def _vi : MUBUF_Real_vi ; } } multiclass MUBUFAtomicAddr64_m pattern, bit is_return> { def "" : MUBUF_Pseudo , MUBUFAddr64Table <1, !if(is_return, "_RTN", "")>, AtomicNoRet; let offen = 0, idxen = 0, addr64 = 1, tfe = 0 in { def _si : MUBUF_Real_si ; } // There is no VI version. If the pseudo is selected, it should be lowered // for VI appropriately. } multiclass MUBUF_Atomic { let mayStore = 1, mayLoad = 1, hasPostISelHook = 1 in { // No return variants let glc = 0 in { defm _ADDR64 : MUBUFAtomicAddr64_m < op, name#"_addr64", (outs), (ins rc:$vdata, VReg_64:$vaddr, SReg_128:$srsrc, SCSrc_32:$soffset, mbuf_offset:$offset, slc:$slc), name#" $vdata, $vaddr, $srsrc, $soffset addr64"#"$offset"#"$slc", [], 0 >; defm _OFFSET : MUBUFAtomicOffset_m < op, name#"_offset", (outs), (ins rc:$vdata, SReg_128:$srsrc, SCSrc_32:$soffset, mbuf_offset:$offset, slc:$slc), name#" $vdata, $srsrc, $soffset"#"$offset"#"$slc", [], 0 >; } // glc = 0 // Variant that return values let glc = 1, Constraints = "$vdata = $vdata_in", DisableEncoding = "$vdata_in" in { defm _RTN_ADDR64 : MUBUFAtomicAddr64_m < op, name#"_rtn_addr64", (outs rc:$vdata), (ins rc:$vdata_in, VReg_64:$vaddr, SReg_128:$srsrc, SCSrc_32:$soffset, mbuf_offset:$offset, slc:$slc), name#" $vdata, $vaddr, $srsrc, $soffset addr64"#"$offset"#" glc"#"$slc", [(set vt:$vdata, (atomic (MUBUFAddr64Atomic v4i32:$srsrc, i64:$vaddr, i32:$soffset, i16:$offset, i1:$slc), vt:$vdata_in))], 1 >; defm _RTN_OFFSET : MUBUFAtomicOffset_m < op, name#"_rtn_offset", (outs rc:$vdata), (ins rc:$vdata_in, SReg_128:$srsrc, SCSrc_32:$soffset, mbuf_offset:$offset, slc:$slc), name#" $vdata, $srsrc, $soffset"#"$offset"#" glc$slc", [(set vt:$vdata, (atomic (MUBUFOffsetAtomic v4i32:$srsrc, i32:$soffset, i16:$offset, i1:$slc), vt:$vdata_in))], 1 >; } // glc = 1 } // mayStore = 1, mayLoad = 1, hasPostISelHook = 1 } // FIXME: tfe can't be an operand because it requires a separate // opcode because it needs an N+1 register class dest register. multiclass MUBUF_Load_Helper { let mayLoad = 1, mayStore = 0 in { let offen = 0, idxen = 0, vaddr = 0 in { defm _OFFSET : MUBUF_m ; } let offen = 1, idxen = 0 in { defm _OFFEN : MUBUF_m ; } let offen = 0, idxen = 1 in { defm _IDXEN : MUBUF_m ; } let offen = 1, idxen = 1 in { defm _BOTHEN : MUBUF_m ; } let offen = 0, idxen = 0 in { defm _ADDR64 : MUBUFAddr64_m ; } } } multiclass MUBUF_Store_Helper { let mayLoad = 0, mayStore = 1 in { defm : MUBUF_m ; let offen = 0, idxen = 0, vaddr = 0 in { defm _OFFSET : MUBUF_m ; } // offen = 0, idxen = 0, vaddr = 0 let offen = 1, idxen = 0 in { defm _OFFEN : MUBUF_m ; } // end offen = 1, idxen = 0 let offen = 0, idxen = 1 in { defm _IDXEN : MUBUF_m ; } let offen = 1, idxen = 1 in { defm _BOTHEN : MUBUF_m ; } let offen = 0, idxen = 0 in { defm _ADDR64 : MUBUFAddr64_m ; } } // End mayLoad = 0, mayStore = 1 } // For cache invalidation instructions. multiclass MUBUF_Invalidate { let hasSideEffects = 1, mayStore = 1, AsmMatchConverter = "" in { def "" : MUBUF_Pseudo ; // Set everything to 0. let offset = 0, offen = 0, idxen = 0, glc = 0, vaddr = 0, vdata = 0, srsrc = 0, slc = 0, tfe = 0, soffset = 0 in { let addr64 = 0 in { def _si : MUBUF_Real_si ; } def _vi : MUBUF_Real_vi ; } } // End hasSideEffects = 1, mayStore = 1, AsmMatchConverter = "" } //===----------------------------------------------------------------------===// // FLAT classes //===----------------------------------------------------------------------===// class flat ci, bits<7> vi = ci> { field bits<7> CI = ci; field bits<7> VI = vi; } class FLAT_Pseudo pattern> : FLAT <0, outs, ins, "", pattern>, SIMCInstr { let isPseudo = 1; let isCodeGenOnly = 1; } class FLAT_Real_ci op, string opName, dag outs, dag ins, string asm> : FLAT , SIMCInstr { let AssemblerPredicate = isCIOnly; } class FLAT_Real_vi op, string opName, dag outs, dag ins, string asm> : FLAT , SIMCInstr { let AssemblerPredicate = VIAssemblerPredicate; } multiclass FLAT_AtomicRet_m pattern> { def "" : FLAT_Pseudo , AtomicNoRet ; def _ci : FLAT_Real_ci ; def _vi : FLAT_Real_vi ; } multiclass FLAT_Load_Helper { let data = 0, mayLoad = 1 in { def "" : FLAT_Pseudo ; def _ci : FLAT_Real_ci ; def _vi : FLAT_Real_vi ; } } multiclass FLAT_Store_Helper { let mayLoad = 0, mayStore = 1, vdst = 0 in { def "" : FLAT_Pseudo ; def _ci : FLAT_Real_ci ; def _vi : FLAT_Real_vi ; } } multiclass FLAT_ATOMIC { let mayLoad = 1, mayStore = 1, glc = 0, vdst = 0 in { def "" : FLAT_Pseudo , AtomicNoRet ; def _ci : FLAT_Real_ci ; def _vi : FLAT_Real_vi ; } let glc = 1, hasPostISelHook = 1 in { defm _RTN : FLAT_AtomicRet_m ; } } class MIMG_Mask { string Op = op; int Channels = channels; } class MIMG_NoSampler_Helper op, string asm, RegisterClass dst_rc, RegisterClass src_rc> : MIMG < op, (outs dst_rc:$vdata), (ins i32imm:$dmask, i1imm:$unorm, i1imm:$glc, i1imm:$da, i1imm:$r128, i1imm:$tfe, i1imm:$lwe, i1imm:$slc, src_rc:$vaddr, SReg_256:$srsrc), asm#" $vdata, $dmask, $unorm, $glc, $da, $r128," #" $tfe, $lwe, $slc, $vaddr, $srsrc", []> { let ssamp = 0; let mayLoad = 1; let mayStore = 0; let hasPostISelHook = 1; } multiclass MIMG_NoSampler_Src_Helper op, string asm, RegisterClass dst_rc, int channels> { def _V1 : MIMG_NoSampler_Helper , MIMG_Mask; def _V2 : MIMG_NoSampler_Helper , MIMG_Mask; def _V4 : MIMG_NoSampler_Helper , MIMG_Mask; } multiclass MIMG_NoSampler op, string asm> { defm _V1 : MIMG_NoSampler_Src_Helper ; defm _V2 : MIMG_NoSampler_Src_Helper ; defm _V3 : MIMG_NoSampler_Src_Helper ; defm _V4 : MIMG_NoSampler_Src_Helper ; } class MIMG_Sampler_Helper op, string asm, RegisterClass dst_rc, RegisterClass src_rc, int wqm> : MIMG < op, (outs dst_rc:$vdata), (ins i32imm:$dmask, i1imm:$unorm, i1imm:$glc, i1imm:$da, i1imm:$r128, i1imm:$tfe, i1imm:$lwe, i1imm:$slc, src_rc:$vaddr, SReg_256:$srsrc, SReg_128:$ssamp), asm#" $vdata, $dmask, $unorm, $glc, $da, $r128," #" $tfe, $lwe, $slc, $vaddr, $srsrc, $ssamp", []> { let mayLoad = 1; let mayStore = 0; let hasPostISelHook = 1; let WQM = wqm; } multiclass MIMG_Sampler_Src_Helper op, string asm, RegisterClass dst_rc, int channels, int wqm> { def _V1 : MIMG_Sampler_Helper , MIMG_Mask; def _V2 : MIMG_Sampler_Helper , MIMG_Mask; def _V4 : MIMG_Sampler_Helper , MIMG_Mask; def _V8 : MIMG_Sampler_Helper , MIMG_Mask; def _V16 : MIMG_Sampler_Helper , MIMG_Mask; } multiclass MIMG_Sampler op, string asm> { defm _V1 : MIMG_Sampler_Src_Helper; defm _V2 : MIMG_Sampler_Src_Helper; defm _V3 : MIMG_Sampler_Src_Helper; defm _V4 : MIMG_Sampler_Src_Helper; } multiclass MIMG_Sampler_WQM op, string asm> { defm _V1 : MIMG_Sampler_Src_Helper; defm _V2 : MIMG_Sampler_Src_Helper; defm _V3 : MIMG_Sampler_Src_Helper; defm _V4 : MIMG_Sampler_Src_Helper; } class MIMG_Gather_Helper op, string asm, RegisterClass dst_rc, RegisterClass src_rc, int wqm> : MIMG < op, (outs dst_rc:$vdata), (ins i32imm:$dmask, i1imm:$unorm, i1imm:$glc, i1imm:$da, i1imm:$r128, i1imm:$tfe, i1imm:$lwe, i1imm:$slc, src_rc:$vaddr, SReg_256:$srsrc, SReg_128:$ssamp), asm#" $vdata, $dmask, $unorm, $glc, $da, $r128," #" $tfe, $lwe, $slc, $vaddr, $srsrc, $ssamp", []> { let mayLoad = 1; let mayStore = 0; // DMASK was repurposed for GATHER4. 4 components are always // returned and DMASK works like a swizzle - it selects // the component to fetch. The only useful DMASK values are // 1=red, 2=green, 4=blue, 8=alpha. (e.g. 1 returns // (red,red,red,red) etc.) The ISA document doesn't mention // this. // Therefore, disable all code which updates DMASK by setting these two: let MIMG = 0; let hasPostISelHook = 0; let WQM = wqm; } multiclass MIMG_Gather_Src_Helper op, string asm, RegisterClass dst_rc, int channels, int wqm> { def _V1 : MIMG_Gather_Helper , MIMG_Mask; def _V2 : MIMG_Gather_Helper , MIMG_Mask; def _V4 : MIMG_Gather_Helper , MIMG_Mask; def _V8 : MIMG_Gather_Helper , MIMG_Mask; def _V16 : MIMG_Gather_Helper , MIMG_Mask; } multiclass MIMG_Gather op, string asm> { defm _V1 : MIMG_Gather_Src_Helper; defm _V2 : MIMG_Gather_Src_Helper; defm _V3 : MIMG_Gather_Src_Helper; defm _V4 : MIMG_Gather_Src_Helper; } multiclass MIMG_Gather_WQM op, string asm> { defm _V1 : MIMG_Gather_Src_Helper; defm _V2 : MIMG_Gather_Src_Helper; defm _V3 : MIMG_Gather_Src_Helper; defm _V4 : MIMG_Gather_Src_Helper; } //===----------------------------------------------------------------------===// // Vector instruction mappings //===----------------------------------------------------------------------===// // Maps an opcode in e32 form to its e64 equivalent def getVOPe64 : InstrMapping { let FilterClass = "VOP"; let RowFields = ["OpName"]; let ColFields = ["Size"]; let KeyCol = ["4"]; let ValueCols = [["8"]]; } // Maps an opcode in e64 form to its e32 equivalent def getVOPe32 : InstrMapping { let FilterClass = "VOP"; let RowFields = ["OpName"]; let ColFields = ["Size"]; let KeyCol = ["8"]; let ValueCols = [["4"]]; } def getMaskedMIMGOp : InstrMapping { let FilterClass = "MIMG_Mask"; let RowFields = ["Op"]; let ColFields = ["Channels"]; let KeyCol = ["4"]; let ValueCols = [["1"], ["2"], ["3"] ]; } // Maps an commuted opcode to its original version def getCommuteOrig : InstrMapping { let FilterClass = "VOP2_REV"; let RowFields = ["RevOp"]; let ColFields = ["IsOrig"]; let KeyCol = ["0"]; let ValueCols = [["1"]]; } // Maps an original opcode to its commuted version def getCommuteRev : InstrMapping { let FilterClass = "VOP2_REV"; let RowFields = ["RevOp"]; let ColFields = ["IsOrig"]; let KeyCol = ["1"]; let ValueCols = [["0"]]; } def getCommuteCmpOrig : InstrMapping { let FilterClass = "VOP2_REV"; let RowFields = ["RevOp"]; let ColFields = ["IsOrig"]; let KeyCol = ["0"]; let ValueCols = [["1"]]; } // Maps an original opcode to its commuted version def getCommuteCmpRev : InstrMapping { let FilterClass = "VOP2_REV"; let RowFields = ["RevOp"]; let ColFields = ["IsOrig"]; let KeyCol = ["1"]; let ValueCols = [["0"]]; } def getMCOpcodeGen : InstrMapping { let FilterClass = "SIMCInstr"; let RowFields = ["PseudoInstr"]; let ColFields = ["Subtarget"]; let KeyCol = [!cast(SISubtarget.NONE)]; let ValueCols = [[!cast(SISubtarget.SI)],[!cast(SISubtarget.VI)]]; } def getAddr64Inst : InstrMapping { let FilterClass = "MUBUFAddr64Table"; let RowFields = ["OpName"]; let ColFields = ["IsAddr64"]; let KeyCol = ["0"]; let ValueCols = [["1"]]; } // Maps an atomic opcode to its version with a return value. def getAtomicRetOp : InstrMapping { let FilterClass = "AtomicNoRet"; let RowFields = ["NoRetOp"]; let ColFields = ["IsRet"]; let KeyCol = ["0"]; let ValueCols = [["1"]]; } // Maps an atomic opcode to its returnless version. def getAtomicNoRetOp : InstrMapping { let FilterClass = "AtomicNoRet"; let RowFields = ["NoRetOp"]; let ColFields = ["IsRet"]; let KeyCol = ["1"]; let ValueCols = [["0"]]; } include "SIInstructions.td" include "CIInstructions.td" include "VIInstructions.td"