================
@@ -0,0 +1,287 @@
+//===---- X86InstrACE.td - ACE Instruction Set Extension --*- tablegen 
-*--===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+//
+// This file describes the instructions that make up the ACE (AI Compute
+// Extensions) instruction set.
+//
+//===----------------------------------------------------------------------===//
+
+//===----------------------------------------------------------------------===//
+// ACE multiclasses
+//
+// Most ACE operations need three definitions: the instruction itself, a pseudo
+// for the user-facing intrinsic that takes an immediate tile ID, and a pseudo
+// for the internal intrinsic that takes a shape and a tile register so the
+// register allocator can assign TMMs. The multiclasses below emit all of them
+// from one mnemonic, which also names the intrinsics.
+//===----------------------------------------------------------------------===//
+
+// BSRMOVH and BSRMOVL move half of the block scale register, which is wider
+// than a vector register, in either direction.
+multiclass ACE_BSRMOV_HALF<string Half, Prefix P> {
+  defvar Insert = !cast<Intrinsic>("int_x86_acev1_bsr0mov"#Half#"insert");
+  defvar Extract = !cast<Intrinsic>("int_x86_acev1_bsr0mov"#Half#"extract");
+
+  let SchedRW = [WriteSystem], OpPrefix = P in {
+    let Defs = [BSR0], Uses = [BSR0] in {
+      def rr_set : I<0x95, MRM0r, (outs),
+                     (ins VR512:$src),
+                     !strconcat("bsrmov", Half, "\t{$src, %bsr0|bsr0, $src}"),
+                     [(Insert (v64i8 VR512:$src))]>,
+                     EVEX, T_MAP6, REX_W, EVEX_V512;
+
+      let mayLoad = 1 in
+      def rm_set : I<0x95, MRM0m, (outs),
+                     (ins f512mem:$src),
+                     !strconcat("bsrmov", Half, "\t{$src, %bsr0|bsr0, $src}"),
+                     []>,
+                     EVEX, T_MAP6, REX_W, EVEX_V512, EVEX_CD8<64, CD8VF>;
+    }
+
+    let Uses = [BSR0] in {
+      def rr_get : I<0x95, MRM0r, (outs VR512:$dst),
+                     (ins),
+                     !strconcat("bsrmov", Half, "\t{%bsr0, $dst|$dst, bsr0}"),
+                     [(set (v64i8 VR512:$dst), (Extract))]>,
+                     EVEX, T_MAP6, EVEX_V512;
+
+      let mayStore = 1 in
+      def mr_get : I<0x95, MRM0m, (outs),
+                     (ins f512mem:$dst),
+                     !strconcat("bsrmov", Half, "\t{%bsr0, $dst|$dst, bsr0}"),
+                     [(store (v64i8 (Extract)), addr:$dst)]>,
+                     EVEX, T_MAP6, EVEX_V512, EVEX_CD8<64, CD8VF>;
+    }
+  }
+}
+
+// TILEMOVCOL and TILEMOVROW in the tile-destination direction write one column
+// or row and keep the rest, so $dst is a source too. Only the register index
+// form has an internal twin; the shape operands carry the index.
+multiclass ACE_TILEMOVE<bits<8> OpcImm, bits<8> OpcReg, string Opstr,
+                        string IntName> {
+  let Constraints = "$src0 = $dst", SchedRW = [WriteSystem] in {
+    def tri : Ii8<OpcImm, MRMSrcReg, (outs TILE:$dst),
+                  (ins TILE:$src0, VR512:$src, u8imm:$idx),
+                  !strconcat(Opstr, "\t{$idx, $src, $dst|$dst, $src, $idx}"),
+                  []>,
+                  EVEX, PD, TA, REX_W, EVEX_V512;
+
+    def tre : I<OpcReg, MRMSrcReg4VOp3, (outs TILE:$dst),
+                (ins TILE:$src0, VR512:$src, GR32:$idx),
+                !strconcat(Opstr, "\t{$idx, $src, $dst|$dst, $src, $idx}"),
+                []>,
+                EVEX, PD, T8, REX_W, VVVV, EVEX_V512;
+  }
+
+  let usesCustomInserter = 1, hasNoSchedulingInfo = 1 in {
+    def "P"#NAME#"tri" : PseudoI<(outs),
+                                 (ins u8imm:$dst, VR512:$src, u8imm:$idx), []>;
+
+    def "P"#NAME#"tre" : PseudoI<(outs),
+                                 (ins u8imm:$dst, VR512:$src, GR32:$idx), []>;
+  }
+
+  let isPseudo = true, hasNoSchedulingInfo = 1, usesCustomInserter = 1 in
+  def "P"#NAME#"treV"
+      : PseudoI<(outs TILE:$dst),
+                (ins GR16:$row, GR16:$col, VR512:$src, GR32:$idx),
+                [(set TILE:$dst,
+                  (!cast<Intrinsic>("int_x86_acev1_"#IntName#"_internal")
+                   GR16:$row, GR16:$col, VR512:$src, GR32:$idx))]>;
+}
+
+// Outer products accumulate into the destination tile, so $src1 is tied to it.
+multiclass ACE_TOP<bits<8> Opc, string Opstr, Prefix P> {
+  let Constraints = "$src1 = $dst", SchedRW = [WriteSystem], OpPrefix = P in
+  def trr : I<Opc, MRMSrcReg4VOp3, (outs TILE:$dst),
+              (ins TILE:$src1, VR512:$src2, VR512:$src3),
+              !strconcat(Opstr, "\t{$src3, $src2, $dst|$dst, $src2, $src3}"),
+              []>,
+              EVEX, VVVV, T8, EVEX_V512;
+
+  let usesCustomInserter = 1, hasNoSchedulingInfo = 1 in
+  def "P"#NAME#"trr"
+      : PseudoI<(outs), (ins u8imm:$dst, VR512:$src1, VR512:$src2),
+                [(!cast<Intrinsic>("int_x86_acev1_"#Opstr)
+                  timm:$dst, VR512:$src1, VR512:$src2)]>;
+
+  let isPseudo = true, hasNoSchedulingInfo = 1, usesCustomInserter = 1,
+      Constraints = "$src1 = $dst" in
+  def "P"#NAME#"trrV"
+      : PseudoI<(outs TILE:$dst),
+                (ins GR16:$row, GR16:$col, GR16:$k,
+                     TILE:$src1, VR512:$src2, VR512:$src3),
+                [(set TILE:$dst,
+                  (!cast<Intrinsic>("int_x86_acev1_"#Opstr#"_internal")
+                   GR16:$row, GR16:$col, GR16:$k,
----------------
arun-thmn wrote:

Do we need `$k` for all outer-products? As far as I think, row and col are 
needed for tiles (acc). The `A` or `B` matrix input are in `AVX512`.

https://github.com/llvm/llvm-project/pull/208408
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to