1//===-- EXPInstructions.td - Export Instruction Definitions ---------------===// 2// 3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4// See https://llvm.org/LICENSE.txt for license information. 5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6// 7//===----------------------------------------------------------------------===// 8 9//===----------------------------------------------------------------------===// 10// EXP classes 11//===----------------------------------------------------------------------===// 12 13class EXPCommon<bit row, bit done, string asm = ""> : InstSI< 14 (outs), 15 (ins exp_tgt:$tgt, 16 ExpSrc0:$src0, ExpSrc1:$src1, ExpSrc2:$src2, ExpSrc3:$src3, 17 exp_vm:$vm, exp_compr:$compr, i32imm:$en), 18 asm> { 19 let EXP = 1; 20 let EXP_CNT = 1; 21 let mayLoad = done; 22 let mayStore = 1; 23 let UseNamedOperandTable = 1; 24 let Uses = !if(row, [EXEC, M0], [EXEC]); 25 let SchedRW = [WriteExport]; 26 let DisableWQM = 1; 27} 28 29class EXP_Pseudo<bit row, bit done> 30 : EXPCommon<row, done>, SIMCInstr<NAME, SIEncodingFamily.NONE> { 31 let isPseudo = 1; 32 let isCodeGenOnly = 1; 33} 34 35// Real instruction with optional asm operands "compr" and "vm". 36class EXP_Real_ComprVM<bit done, string pseudo, int subtarget> 37 : EXPCommon<0, done, "exp$tgt $src0, $src1, $src2, $src3" 38 #!if(done, " done", "")#"$compr$vm">, 39 SIMCInstr<pseudo, subtarget> { 40 let AsmMatchConverter = "cvtExp"; 41} 42 43// Real instruction with optional asm operand "row_en". 44class EXP_Real_Row<bit row, bit done, string pseudo, int subtarget> 45 : EXPCommon<row, done, "exp$tgt $src0, $src1, $src2, $src3" 46 #!if(done, " done", "")#!if(row, " row_en", "")>, 47 SIMCInstr<pseudo, subtarget> { 48 let AsmMatchConverter = "cvtExp"; 49} 50 51//===----------------------------------------------------------------------===// 52// EXP Instructions 53//===----------------------------------------------------------------------===// 54 55// DONE variants have mayLoad = 1. 56// ROW variants have an implicit use of M0. 57let SubtargetPredicate = isNotGFX90APlus in { 58def EXP : EXP_Pseudo<0, 0>; 59def EXP_DONE : EXP_Pseudo<0, 1>; 60def EXP_ROW : EXP_Pseudo<1, 0>; 61def EXP_ROW_DONE : EXP_Pseudo<1, 1>; 62} // let SubtargetPredicate = isNotGFX90APlus 63 64//===----------------------------------------------------------------------===// 65// SI 66//===----------------------------------------------------------------------===// 67 68class EXP_Real_si<bit _done, string pseudo> 69 : EXP_Real_ComprVM<_done, pseudo, SIEncodingFamily.SI>, EXPe_ComprVM { 70 let AssemblerPredicate = isGFX6GFX7; 71 let DecoderNamespace = "GFX6GFX7"; 72 let done = _done; 73} 74 75def EXP_si : EXP_Real_si<0, "EXP">; 76def EXP_DONE_si : EXP_Real_si<1, "EXP_DONE">; 77 78//===----------------------------------------------------------------------===// 79// VI 80//===----------------------------------------------------------------------===// 81 82class EXP_Real_vi<bit _done, string pseudo> 83 : EXP_Real_ComprVM<_done, pseudo, SIEncodingFamily.VI>, EXPe_vi { 84 let AssemblerPredicate = isGFX8GFX9; 85 let SubtargetPredicate = isNotGFX90APlus; 86 let DecoderNamespace = "GFX8"; 87 let done = _done; 88} 89 90def EXP_vi : EXP_Real_vi<0, "EXP">; 91def EXP_DONE_vi : EXP_Real_vi<1, "EXP_DONE">; 92 93//===----------------------------------------------------------------------===// 94// GFX10 95//===----------------------------------------------------------------------===// 96 97class EXP_Real_gfx10<bit _done, string pseudo> 98 : EXP_Real_ComprVM<_done, pseudo, SIEncodingFamily.GFX10>, EXPe_ComprVM { 99 let AssemblerPredicate = isGFX10Only; 100 let DecoderNamespace = "GFX10"; 101 let done = _done; 102} 103 104def EXP_gfx10 : EXP_Real_gfx10<0, "EXP">; 105def EXP_DONE_gfx10 : EXP_Real_gfx10<1, "EXP_DONE">; 106 107//===----------------------------------------------------------------------===// 108// GFX11+ 109//===----------------------------------------------------------------------===// 110 111class EXP_Real_gfx11<bit _row, bit _done, string pseudo> 112 : EXP_Real_Row<_row, _done, pseudo, SIEncodingFamily.GFX11>, EXPe_Row { 113 let AssemblerPredicate = isGFX11Plus; 114 let DecoderNamespace = "GFX11"; 115 let row = _row; 116 let done = _done; 117} 118 119def EXP_gfx11 : EXP_Real_gfx11<0, 0, "EXP">; 120def EXP_DONE_gfx11 : EXP_Real_gfx11<0, 1, "EXP_DONE">; 121def EXP_ROW_gfx11 : EXP_Real_gfx11<1, 0, "EXP_ROW">; 122def EXP_ROW_DONE_gfx11 : EXP_Real_gfx11<1, 1, "EXP_ROW_DONE">; 123 124//===----------------------------------------------------------------------===// 125// EXP Patterns 126//===----------------------------------------------------------------------===// 127 128class ExpPattern<ValueType vt, Instruction Inst, int done_val> : GCNPat< 129 (int_amdgcn_exp timm:$tgt, timm:$en, 130 (vt ExpSrc0:$src0), (vt ExpSrc1:$src1), 131 (vt ExpSrc2:$src2), (vt ExpSrc3:$src3), 132 done_val, timm:$vm), 133 (Inst timm:$tgt, ExpSrc0:$src0, ExpSrc1:$src1, 134 ExpSrc2:$src2, ExpSrc3:$src3, timm:$vm, 0, timm:$en) 135>; 136 137class ExpRowPattern<ValueType vt, Instruction Inst, int done_val> : GCNPat< 138 (int_amdgcn_exp_row timm:$tgt, timm:$en, 139 (vt ExpSrc0:$src0), (vt ExpSrc1:$src1), 140 (vt ExpSrc2:$src2), (vt ExpSrc3:$src3), 141 done_val, M0), 142 (Inst timm:$tgt, ExpSrc0:$src0, ExpSrc1:$src1, 143 ExpSrc2:$src2, ExpSrc3:$src3, 0, 0, timm:$en) 144>; 145 146class ExpComprPattern<ValueType vt, Instruction Inst, int done_val> : GCNPat< 147 (int_amdgcn_exp_compr timm:$tgt, timm:$en, 148 (vt ExpSrc0:$src0), (vt ExpSrc1:$src1), 149 done_val, timm:$vm), 150 (Inst timm:$tgt, ExpSrc0:$src0, ExpSrc1:$src1, 151 (IMPLICIT_DEF), (IMPLICIT_DEF), timm:$vm, 1, timm:$en) 152>; 153 154// FIXME: The generated DAG matcher seems to have strange behavior 155// with a 1-bit literal to match, so use a -1 for checking a true 156// 1-bit value. 157def : ExpPattern<i32, EXP, 0>; 158def : ExpPattern<i32, EXP_DONE, -1>; 159def : ExpPattern<f32, EXP, 0>; 160def : ExpPattern<f32, EXP_DONE, -1>; 161 162def : ExpRowPattern<i32, EXP_ROW, 0>; 163def : ExpRowPattern<i32, EXP_ROW_DONE, -1>; 164def : ExpRowPattern<f32, EXP_ROW, 0>; 165def : ExpRowPattern<f32, EXP_ROW_DONE, -1>; 166 167def : ExpComprPattern<v2i16, EXP, 0>; 168def : ExpComprPattern<v2i16, EXP_DONE, -1>; 169def : ExpComprPattern<v2f16, EXP, 0>; 170def : ExpComprPattern<v2f16, EXP_DONE, -1>; 171