15ffd83dbSDimitry Andric//===---- X86InstrAMX.td - AMX Instruction Set Extension --*- tablegen -*--===// 25ffd83dbSDimitry Andric// 35ffd83dbSDimitry Andric// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 45ffd83dbSDimitry Andric// See https://llvm.org/LICENSE.txt for license information. 55ffd83dbSDimitry Andric// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 65ffd83dbSDimitry Andric// 75ffd83dbSDimitry Andric//===----------------------------------------------------------------------===// 85ffd83dbSDimitry Andric// 95ffd83dbSDimitry Andric// This file describes the instructions that make up the Intel AMX instruction 105ffd83dbSDimitry Andric// set. 115ffd83dbSDimitry Andric// 125ffd83dbSDimitry Andric//===----------------------------------------------------------------------===// 135ffd83dbSDimitry Andric 145ffd83dbSDimitry Andric//===----------------------------------------------------------------------===// 155ffd83dbSDimitry Andric// AMX instructions 165ffd83dbSDimitry Andric 17647cbc5dSDimitry Andricmulticlass AMX_TILE_COMMON<string Suffix, Predicate HasEGPR> { 18647cbc5dSDimitry Andriclet Predicates = [HasAMXTILE, HasEGPR, In64BitMode] in { 19e8d8bef9SDimitry Andric let hasSideEffects = 1, 20e8d8bef9SDimitry Andric Defs = [TMM0,TMM1,TMM2,TMM3,TMM4,TMM5,TMM6,TMM7] in 21647cbc5dSDimitry Andric def LDTILECFG#Suffix : I<0x49, MRM0m, (outs), (ins opaquemem:$src), 225ffd83dbSDimitry Andric "ldtilecfg\t$src", 23647cbc5dSDimitry Andric [(int_x86_ldtilecfg addr:$src)]>, 24647cbc5dSDimitry Andric T8, PS; 25e8d8bef9SDimitry Andric let hasSideEffects = 1 in 26647cbc5dSDimitry Andric def STTILECFG#Suffix : I<0x49, MRM0m, (outs), (ins opaquemem:$src), 275ffd83dbSDimitry Andric "sttilecfg\t$src", 28647cbc5dSDimitry Andric [(int_x86_sttilecfg addr:$src)]>, 29647cbc5dSDimitry Andric T8, PD; 30e8d8bef9SDimitry Andric let mayLoad = 1 in 31647cbc5dSDimitry Andric def TILELOADD#Suffix : I<0x4b, MRMSrcMemFSIB, (outs TILE:$dst), 325ffd83dbSDimitry Andric (ins sibmem:$src), 335ffd83dbSDimitry Andric "tileloadd\t{$src, $dst|$dst, $src}", []>, 34647cbc5dSDimitry Andric T8, XD; 35e8d8bef9SDimitry Andric let mayLoad = 1 in 36647cbc5dSDimitry Andric def TILELOADDT1#Suffix : I<0x4b, MRMSrcMemFSIB, (outs TILE:$dst), 375ffd83dbSDimitry Andric (ins sibmem:$src), 385ffd83dbSDimitry Andric "tileloaddt1\t{$src, $dst|$dst, $src}", []>, 39647cbc5dSDimitry Andric T8, PD; 40e8d8bef9SDimitry Andric let mayStore = 1 in 41647cbc5dSDimitry Andric def TILESTORED#Suffix : I<0x4b, MRMDestMemFSIB, (outs), 425ffd83dbSDimitry Andric (ins sibmem:$dst, TILE:$src), 435ffd83dbSDimitry Andric "tilestored\t{$src, $dst|$dst, $src}", []>, 44647cbc5dSDimitry Andric T8, XS; 45647cbc5dSDimitry Andric} 46647cbc5dSDimitry Andric} 47647cbc5dSDimitry Andric 48647cbc5dSDimitry Andriclet SchedRW = [WriteSystem] in { 49647cbc5dSDimitry Andric defm "" : AMX_TILE_COMMON<"", NoEGPR>, VEX; 50647cbc5dSDimitry Andric defm "" : AMX_TILE_COMMON<"_EVEX", HasEGPR>, EVEX, NoCD8; 51647cbc5dSDimitry Andric 52647cbc5dSDimitry Andric let Predicates = [HasAMXTILE, In64BitMode] in { 53647cbc5dSDimitry Andric let Defs = [TMM0,TMM1,TMM2,TMM3,TMM4,TMM5,TMM6,TMM7] in 54647cbc5dSDimitry Andric def TILERELEASE : I<0x49, MRM_C0, (outs), (ins), 55647cbc5dSDimitry Andric "tilerelease", [(int_x86_tilerelease)]>, VEX, T8, PS; 565ffd83dbSDimitry Andric def TILEZERO : I<0x49, MRMr0, (outs TILE:$dst), (ins), 575ffd83dbSDimitry Andric "tilezero\t$dst", []>, 58cb14a3feSDimitry Andric VEX, T8, XD; 595ffd83dbSDimitry Andric 60e8d8bef9SDimitry Andric // Pseduo instruction for RA. 6181ad6265SDimitry Andric let isPseudo = true, mayLoad = 1, hasSideEffects = 1, 6281ad6265SDimitry Andric Defs = [TMM0,TMM1,TMM2,TMM3,TMM4,TMM5,TMM6,TMM7] in 6381ad6265SDimitry Andric def PLDTILECFGV : PseudoI<(outs), (ins opaquemem:$src), []>; 6481ad6265SDimitry Andric let isPseudo = true, mayLoad = 1 in 65e8d8bef9SDimitry Andric def PTILELOADDV : PseudoI<(outs TILE:$dst), (ins GR16:$src1, 66e8d8bef9SDimitry Andric GR16:$src2, 67fe6060f1SDimitry Andric opaquemem:$src3), []>; 6881ad6265SDimitry Andric let isPseudo = true, mayLoad = 1 in 69fe6060f1SDimitry Andric def PTILELOADDT1V : PseudoI<(outs TILE:$dst), (ins GR16:$src1, 70fe6060f1SDimitry Andric GR16:$src2, 71fe6060f1SDimitry Andric opaquemem:$src3), []>; 7281ad6265SDimitry Andric let isPseudo = true, mayStore = 1 in 73e8d8bef9SDimitry Andric def PTILESTOREDV : PseudoI<(outs), (ins GR16:$src1, 74e8d8bef9SDimitry Andric GR16:$src2, opaquemem:$src3, 75fe6060f1SDimitry Andric TILE:$src4), []>; 7681ad6265SDimitry Andric let isPseudo = true, isReMaterializable = 1, isAsCheapAsAMove = 1, 77*0fca6ea1SDimitry Andric canFoldAsLoad = 1, usesCustomInserter = 1 in 78fe6060f1SDimitry Andric def PTILEZEROV : PseudoI<(outs TILE:$dst), (ins GR16:$src1, GR16:$src2), 79fe6060f1SDimitry Andric [(set TILE:$dst, (int_x86_tilezero_internal 80fe6060f1SDimitry Andric GR16:$src1, GR16:$src2))]>; 81e8d8bef9SDimitry Andric 825ffd83dbSDimitry Andric let usesCustomInserter = 1 in { 835ffd83dbSDimitry Andric // Pseudo instructions, using immediates instead of tile registers. 845ffd83dbSDimitry Andric // To be translated to the actual instructions in X86ISelLowering.cpp 8581ad6265SDimitry Andric let mayLoad = 1 in 865ffd83dbSDimitry Andric def PTILELOADD : PseudoI<(outs), (ins u8imm:$src1, sibmem:$src2), []>; 8781ad6265SDimitry Andric let mayLoad = 1 in 885ffd83dbSDimitry Andric def PTILELOADDT1 : PseudoI<(outs), (ins u8imm:$src1, 895ffd83dbSDimitry Andric sibmem:$src2), []>; 9081ad6265SDimitry Andric let mayStore = 1 in 915ffd83dbSDimitry Andric def PTILESTORED : PseudoI<(outs), (ins i8mem:$dst, u8imm:$src), []>; 925ffd83dbSDimitry Andric def PTILEZERO : PseudoI<(outs), (ins u8imm:$src), 93e8d8bef9SDimitry Andric [(int_x86_tilezero timm:$src)]>; 945ffd83dbSDimitry Andric } 95647cbc5dSDimitry Andric } // Predicates 965ffd83dbSDimitry Andric} // SchedRW 975ffd83dbSDimitry Andric 985ffd83dbSDimitry Andriclet Predicates = [HasAMXINT8, In64BitMode] in { 995ffd83dbSDimitry Andric let SchedRW = [WriteSystem] in { 1005ffd83dbSDimitry Andric let Constraints = "$src1 = $dst" in { 1015ffd83dbSDimitry Andric def TDPBSSD : I<0x5e, MRMSrcReg4VOp3, (outs TILE:$dst), 1025ffd83dbSDimitry Andric (ins TILE:$src1, TILE:$src2, TILE:$src3), 1035ffd83dbSDimitry Andric "tdpbssd\t{$src3, $src2, $dst|$dst, $src2, $src3}", []>, 104cb14a3feSDimitry Andric VEX, VVVV, T8, XD; 1055ffd83dbSDimitry Andric def TDPBSUD : I<0x5e, MRMSrcReg4VOp3, (outs TILE:$dst), 1065ffd83dbSDimitry Andric (ins TILE:$src1, TILE:$src2, TILE:$src3), 1075ffd83dbSDimitry Andric "tdpbsud\t{$src3, $src2, $dst|$dst, $src2, $src3}", []>, 108cb14a3feSDimitry Andric VEX, VVVV, T8, XS; 1095ffd83dbSDimitry Andric def TDPBUSD : I<0x5e, MRMSrcReg4VOp3, (outs TILE:$dst), 1105ffd83dbSDimitry Andric (ins TILE:$src1, TILE:$src2, TILE:$src3), 1115ffd83dbSDimitry Andric "tdpbusd\t{$src3, $src2, $dst|$dst, $src2, $src3}", []>, 112cb14a3feSDimitry Andric VEX, VVVV, T8, PD; 1135ffd83dbSDimitry Andric def TDPBUUD : I<0x5e, MRMSrcReg4VOp3, (outs TILE:$dst), 1145ffd83dbSDimitry Andric (ins TILE:$src1, TILE:$src2, TILE:$src3), 1155ffd83dbSDimitry Andric "tdpbuud\t{$src3, $src2, $dst|$dst, $src2, $src3}", []>, 116cb14a3feSDimitry Andric VEX, VVVV, T8; 1175ffd83dbSDimitry Andric } 1185ffd83dbSDimitry Andric 119e8d8bef9SDimitry Andric // Pseduo instruction for RA. 12081ad6265SDimitry Andric let isPseudo = true, Constraints = "$src4 = $dst" in { 121e8d8bef9SDimitry Andric def PTDPBSSDV : PseudoI<(outs TILE:$dst), (ins GR16:$src1, 122e8d8bef9SDimitry Andric GR16:$src2, GR16:$src3, TILE:$src4, 123fe6060f1SDimitry Andric TILE:$src5, TILE:$src6), 124fe6060f1SDimitry Andric [(set TILE: $dst, 125fe6060f1SDimitry Andric (int_x86_tdpbssd_internal GR16:$src1, GR16:$src2, 126fe6060f1SDimitry Andric GR16:$src3, TILE:$src4, TILE:$src5, TILE:$src6))]>; 127fe6060f1SDimitry Andric def PTDPBSUDV : PseudoI<(outs TILE: $dst), (ins GR16:$src1, 128fe6060f1SDimitry Andric GR16:$src2, GR16:$src3, TILE:$src4, 129fe6060f1SDimitry Andric TILE:$src5, TILE:$src6), 130fe6060f1SDimitry Andric [(set TILE: $dst, 131fe6060f1SDimitry Andric (int_x86_tdpbsud_internal GR16:$src1, GR16:$src2, 132fe6060f1SDimitry Andric GR16:$src3, TILE:$src4, TILE:$src5, TILE:$src6))]>; 133fe6060f1SDimitry Andric def PTDPBUSDV : PseudoI<(outs TILE: $dst), (ins GR16:$src1, 134fe6060f1SDimitry Andric GR16:$src2, GR16:$src3, TILE:$src4, 135fe6060f1SDimitry Andric TILE:$src5, TILE:$src6), 136fe6060f1SDimitry Andric [(set TILE: $dst, 137fe6060f1SDimitry Andric (int_x86_tdpbusd_internal GR16:$src1, GR16:$src2, 138fe6060f1SDimitry Andric GR16:$src3, TILE:$src4, TILE:$src5, TILE:$src6))]>; 139fe6060f1SDimitry Andric def PTDPBUUDV : PseudoI<(outs TILE: $dst), (ins GR16:$src1, 140fe6060f1SDimitry Andric GR16:$src2, GR16:$src3, TILE:$src4, 141fe6060f1SDimitry Andric TILE:$src5, TILE:$src6), 142fe6060f1SDimitry Andric [(set TILE: $dst, 143fe6060f1SDimitry Andric (int_x86_tdpbuud_internal GR16:$src1, GR16:$src2, 144fe6060f1SDimitry Andric GR16:$src3, TILE:$src4, TILE:$src5, TILE:$src6))]>; 145fe6060f1SDimitry Andric } 146e8d8bef9SDimitry Andric 1475ffd83dbSDimitry Andric let usesCustomInserter = 1 in { 1485ffd83dbSDimitry Andric // Pseudo instructions, using immediates instead of tile registers. 1495ffd83dbSDimitry Andric // To be translated to the actual instructions in X86ISelLowering.cpp 1505ffd83dbSDimitry Andric def PTDPBSSD : PseudoI<(outs), (ins u8imm:$src1, 1515ffd83dbSDimitry Andric u8imm:$src2, u8imm:$src3), 152e8d8bef9SDimitry Andric [(int_x86_tdpbssd timm:$src1, 153e8d8bef9SDimitry Andric timm:$src2, timm:$src3)]>; 1545ffd83dbSDimitry Andric def PTDPBSUD : PseudoI<(outs), (ins u8imm:$src1, 1555ffd83dbSDimitry Andric u8imm:$src2, u8imm:$src3), 156e8d8bef9SDimitry Andric [(int_x86_tdpbsud timm:$src1, 157e8d8bef9SDimitry Andric timm:$src2, timm:$src3)]>; 1585ffd83dbSDimitry Andric def PTDPBUSD : PseudoI<(outs), (ins u8imm:$src1, 1595ffd83dbSDimitry Andric u8imm:$src2, u8imm:$src3), 160e8d8bef9SDimitry Andric [(int_x86_tdpbusd timm:$src1, 161e8d8bef9SDimitry Andric timm:$src2, timm:$src3)]>; 1625ffd83dbSDimitry Andric def PTDPBUUD : PseudoI<(outs), (ins u8imm:$src1, 1635ffd83dbSDimitry Andric u8imm:$src2, u8imm:$src3), 164e8d8bef9SDimitry Andric [(int_x86_tdpbuud timm:$src1, 165e8d8bef9SDimitry Andric timm:$src2, timm:$src3)]>; 1665ffd83dbSDimitry Andric } 1675ffd83dbSDimitry Andric } 1685ffd83dbSDimitry Andric} // HasAMXTILE 1695ffd83dbSDimitry Andric 1705ffd83dbSDimitry Andriclet Predicates = [HasAMXBF16, In64BitMode] in { 1715ffd83dbSDimitry Andric let SchedRW = [WriteSystem] in { 1725ffd83dbSDimitry Andric let Constraints = "$src1 = $dst" in 1735ffd83dbSDimitry Andric def TDPBF16PS : I<0x5c, MRMSrcReg4VOp3, (outs TILE:$dst), 1745ffd83dbSDimitry Andric (ins TILE:$src1, TILE:$src2, TILE:$src3), 1755ffd83dbSDimitry Andric "tdpbf16ps\t{$src3, $src2, $dst|$dst, $src2, $src3}", 176cb14a3feSDimitry Andric []>, VEX, VVVV, T8, XS; 1775ffd83dbSDimitry Andric 178fe6060f1SDimitry Andric // Pseduo instruction for RA. 17981ad6265SDimitry Andric let isPseudo = true, Constraints = "$src4 = $dst" in 180fe6060f1SDimitry Andric def PTDPBF16PSV : PseudoI<(outs TILE: $dst), (ins GR16:$src1, 181fe6060f1SDimitry Andric GR16:$src2, GR16:$src3, TILE:$src4, 182fe6060f1SDimitry Andric TILE:$src5, TILE:$src6), 183fe6060f1SDimitry Andric [(set TILE: $dst, 184fe6060f1SDimitry Andric (int_x86_tdpbf16ps_internal GR16:$src1, 185fe6060f1SDimitry Andric GR16:$src2, GR16:$src3, TILE:$src4, 186fe6060f1SDimitry Andric TILE:$src5, TILE:$src6))]>; 187fe6060f1SDimitry Andric 1885ffd83dbSDimitry Andric let usesCustomInserter = 1 in { 1895ffd83dbSDimitry Andric // Pseudo instructions, using immediates instead of tile registers. 1905ffd83dbSDimitry Andric // To be translated to the actual instructions in X86ISelLowering.cpp 1915ffd83dbSDimitry Andric def PTDPBF16PS : PseudoI<(outs), (ins u8imm:$src1, 1925ffd83dbSDimitry Andric u8imm:$src2, u8imm:$src3), 193e8d8bef9SDimitry Andric [(int_x86_tdpbf16ps timm:$src1, 194e8d8bef9SDimitry Andric timm:$src2, timm:$src3)]>; 1955ffd83dbSDimitry Andric } 1965ffd83dbSDimitry Andric } 1975ffd83dbSDimitry Andric} // HasAMXTILE, HasAMXBF16 198bdd1243dSDimitry Andric 199bdd1243dSDimitry Andric//AMX-FP16 200bdd1243dSDimitry Andriclet Predicates = [HasAMXFP16, In64BitMode] in { 201bdd1243dSDimitry Andric let SchedRW = [WriteSystem] in { 202bdd1243dSDimitry Andric let Constraints = "$src1 = $dst" in { 203bdd1243dSDimitry Andric def TDPFP16PS : I<0x5c, MRMSrcReg4VOp3, (outs TILE:$dst), 204bdd1243dSDimitry Andric (ins TILE:$src1, TILE:$src2, TILE:$src3), 205bdd1243dSDimitry Andric "tdpfp16ps\t{$src3, $src2, $src1|$src1, $src2, $src3}", 206cb14a3feSDimitry Andric []>, VEX, VVVV, T8, XD; 207bdd1243dSDimitry Andric } 208bdd1243dSDimitry Andric 209bdd1243dSDimitry Andric // Pseduo instruction for RA. 210bdd1243dSDimitry Andric let isPseudo = true, Constraints = "$src4 = $dst" in { 211bdd1243dSDimitry Andric def PTDPFP16PSV : PseudoI<(outs TILE: $dst), (ins GR16:$src1, 212bdd1243dSDimitry Andric GR16:$src2, GR16:$src3, TILE:$src4, 213bdd1243dSDimitry Andric TILE:$src5, TILE:$src6), 214bdd1243dSDimitry Andric [(set TILE: $dst, 215bdd1243dSDimitry Andric (int_x86_tdpfp16ps_internal GR16:$src1, 216bdd1243dSDimitry Andric GR16:$src2, GR16:$src3, TILE:$src4, 217bdd1243dSDimitry Andric TILE:$src5, TILE:$src6))]>; 218bdd1243dSDimitry Andric } 219bdd1243dSDimitry Andric 220bdd1243dSDimitry Andric let usesCustomInserter = 1 in { 221bdd1243dSDimitry Andric def PTDPFP16PS : PseudoI<(outs), (ins u8imm:$src1, 222bdd1243dSDimitry Andric u8imm:$src2, u8imm:$src3), 223bdd1243dSDimitry Andric [(int_x86_tdpfp16ps timm:$src1, 224bdd1243dSDimitry Andric timm:$src2, timm:$src3)]>; 225bdd1243dSDimitry Andric } 226bdd1243dSDimitry Andric } 227bdd1243dSDimitry Andric} // HasAMXTILE, HasAMXFP16 22806c3fb27SDimitry Andric 22906c3fb27SDimitry Andriclet Predicates = [HasAMXCOMPLEX, In64BitMode] in { 23006c3fb27SDimitry Andric let SchedRW = [WriteSystem] in { 23106c3fb27SDimitry Andric let Constraints = "$src1 = $dst" in { 23206c3fb27SDimitry Andric def TCMMIMFP16PS : I<0x6c, MRMSrcReg4VOp3, (outs TILE:$dst), 23306c3fb27SDimitry Andric (ins TILE:$src1, TILE:$src2, TILE:$src3), 23406c3fb27SDimitry Andric "tcmmimfp16ps\t{$src3, $src2, $src1|$src1, $src2, $src3}", 235cb14a3feSDimitry Andric []>, T8, PD, VEX, VVVV; 23606c3fb27SDimitry Andric def TCMMRLFP16PS : I<0x6c, MRMSrcReg4VOp3, (outs TILE:$dst), 23706c3fb27SDimitry Andric (ins TILE:$src1, TILE:$src2, TILE:$src3), 23806c3fb27SDimitry Andric "tcmmrlfp16ps\t{$src3, $src2, $src1|$src1, $src2, $src3}", 239cb14a3feSDimitry Andric []>, VEX, VVVV, WIG, T8; 24006c3fb27SDimitry Andric 24106c3fb27SDimitry Andric } // Constraints = "$src1 = $dst" 24206c3fb27SDimitry Andric 24306c3fb27SDimitry Andric let Constraints = "$src4 = $dst" in { 24406c3fb27SDimitry Andric def PTCMMIMFP16PSV : PseudoI<(outs TILE:$dst), (ins GR16:$src1, 24506c3fb27SDimitry Andric GR16:$src2, GR16:$src3, TILE:$src4, 24606c3fb27SDimitry Andric TILE:$src5, TILE:$src6), 24706c3fb27SDimitry Andric [(set TILE: $dst, 24806c3fb27SDimitry Andric (int_x86_tcmmimfp16ps_internal GR16:$src1, GR16:$src2, 24906c3fb27SDimitry Andric GR16:$src3, TILE:$src4, TILE:$src5, TILE:$src6))]>; 25006c3fb27SDimitry Andric def PTCMMRLFP16PSV : PseudoI<(outs TILE:$dst), (ins GR16:$src1, 25106c3fb27SDimitry Andric GR16:$src2, GR16:$src3, TILE:$src4, 25206c3fb27SDimitry Andric TILE:$src5, TILE:$src6), 25306c3fb27SDimitry Andric [(set TILE: $dst, 25406c3fb27SDimitry Andric (int_x86_tcmmrlfp16ps_internal GR16:$src1, GR16:$src2, 25506c3fb27SDimitry Andric GR16:$src3, TILE:$src4, TILE:$src5, TILE:$src6))]>; 25606c3fb27SDimitry Andric } 25706c3fb27SDimitry Andric 25806c3fb27SDimitry Andric let usesCustomInserter = 1 in { 25906c3fb27SDimitry Andric def PTCMMIMFP16PS : PseudoI<(outs), (ins u8imm:$src1, 26006c3fb27SDimitry Andric u8imm:$src2, u8imm:$src3), 26106c3fb27SDimitry Andric [(int_x86_tcmmimfp16ps timm:$src1, 26206c3fb27SDimitry Andric timm:$src2, timm:$src3)]>; 26306c3fb27SDimitry Andric def PTCMMRLFP16PS : PseudoI<(outs), (ins u8imm:$src1, 26406c3fb27SDimitry Andric u8imm:$src2, u8imm:$src3), 26506c3fb27SDimitry Andric [(int_x86_tcmmrlfp16ps timm:$src1, 26606c3fb27SDimitry Andric timm:$src2, timm:$src3)]>; 26706c3fb27SDimitry Andric } 26806c3fb27SDimitry Andric } // SchedRW = [WriteSystem] 26906c3fb27SDimitry Andric} 270