Skip to content

Commit

Permalink
[AIE2] Implement vshuffle instruction selection
Browse files Browse the repository at this point in the history
  • Loading branch information
ValentijnvdBeek committed Aug 15, 2024
1 parent 4c349de commit d1d0a3a
Show file tree
Hide file tree
Showing 2 changed files with 95 additions and 0 deletions.
12 changes: 12 additions & 0 deletions llvm/lib/Target/AIE/AIE2InstrPatterns.td
Original file line number Diff line number Diff line change
Expand Up @@ -597,6 +597,18 @@ def : Pat<(int_aie2_vshuffle VEC512:$s1, VEC512:$s2, eR:$mod),
def : Pat<(int_aie2_vshuffle_bf16 VEC512:$s1, VEC512:$s2, eR:$mod),
(VSHUFFLE VEC512:$s1, VEC512:$s2, eR:$mod)>;

// VSHUFFLE generic opcodes translation
def vshuffle_node : SDNode<"AIE2::G_AIE_VSHUFFLE",
SDTypeProfile<1, 3, [SDTCisVec<1>, SDTCisVec<2>, SDTCisInt<3>]>>;
def : GINodeEquiv<G_AIE_VSHUFFLE, vshuffle_node>;

def : Pat<(v16i32 (vshuffle_node (v16i32 VEC512:$v0), (v16i32 VEC512:$v1), (i32 eR:$mode))),
(VSHUFFLE VEC512:$v0, VEC512:$v1, i32:$mode)>;
def : Pat<(v32i16 (vshuffle_node (v32i16 VEC512:$v0), (v32i16 VEC512:$v1), (i32 eR:$mode))),
(VSHUFFLE VEC512:$v0, VEC512:$v1, i32:$mode)>;
def : Pat<(v64i8 (vshuffle_node (v64i8 VEC512:$v0), (v64i8 VEC512:$v1), (i32 eR:$mode))),
(VSHUFFLE VEC512:$v0, VEC512:$v1, i32:$mode)>;

// VSHIFT Intrinsic (shift/shiftx/shift_bytes)
def : Pat<(int_aie2_vshift_I512_I512 VEC512:$s1, VEC512:$s2, 0x0, eR:$shift),
(VSHIFT VEC512:$s1, VEC512:$s2, eR:$shift)>;
Expand Down
83 changes: 83 additions & 0 deletions llvm/test/CodeGen/AIE/aie2/GlobalISel/inst-select-aie-vshuffle.mir
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
#
# This file is licensed 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
#
# (c) Copyright 2023-2024 Advanced Micro Devices, Inc. or its affiliates
#
# RUN: llc -mtriple aie2 -run-pass=instruction-select %s -verify-machineinstrs -o - | FileCheck %s

---
name: vshuffle_32_m35
legalized: true
regBankSelected: true
tracksRegLiveness: true
stack:
- { id: 0, name: "", size: 128, alignment: 32 }
body: |
bb.0.entry:
liveins: $x2
; CHECK-LABEL: name: vshuffle_32_m35
; CHECK: liveins: $x2
; CHECK-NEXT: {{ $}}
; CHECK-NEXT: [[COPY:%[0-9]+]]:vec512 = COPY $x2
; CHECK-NEXT: [[MOV_RLC_imm10_pseudo:%[0-9]+]]:er = MOV_RLC_imm10_pseudo 29
; CHECK-NEXT: [[VSHUFFLE:%[0-9]+]]:vec512 = VSHUFFLE [[COPY]], [[COPY]], [[MOV_RLC_imm10_pseudo]]
; CHECK-NEXT: $x0 = COPY [[VSHUFFLE]]
; CHECK-NEXT: PseudoRET implicit $lr, implicit $x0
%1:vregbank(<16 x s32>) = COPY $x2
%2:gprregbank(s32) = G_CONSTANT i32 29
%0:vregbank(<16 x s32>) = G_AIE_VSHUFFLE %1:vregbank, %1:vregbank, %2:gprregbank(s32)
$x0 = COPY %0:vregbank(<16 x s32>)
PseudoRET implicit $lr, implicit $x0
...

---
name: vshuffle_16_m35
legalized: true
regBankSelected: true
tracksRegLiveness: true
stack:
- { id: 0, name: "", size: 128, alignment: 32 }
body: |
bb.0.entry:
liveins: $x2
; CHECK-LABEL: name: vshuffle_16_m35
; CHECK: liveins: $x2
; CHECK-NEXT: {{ $}}
; CHECK-NEXT: [[COPY:%[0-9]+]]:vec512 = COPY $x2
; CHECK-NEXT: [[MOV_RLC_imm10_pseudo:%[0-9]+]]:er = MOV_RLC_imm10_pseudo 29
; CHECK-NEXT: [[VSHUFFLE:%[0-9]+]]:vec512 = VSHUFFLE [[COPY]], [[COPY]], [[MOV_RLC_imm10_pseudo]]
; CHECK-NEXT: $x0 = COPY [[VSHUFFLE]]
; CHECK-NEXT: PseudoRET implicit $lr, implicit $x0
%1:vregbank(<32 x s16>) = COPY $x2
%2:gprregbank(s32) = G_CONSTANT i32 29
%0:vregbank(<32 x s16>) = G_AIE_VSHUFFLE %1:vregbank, %1:vregbank, %2:gprregbank(s32)
$x0 = COPY %0:vregbank(<32 x s16>)
PseudoRET implicit $lr, implicit $x0
...

---
name: vshuffle_8_m35
legalized: true
regBankSelected: true
tracksRegLiveness: true
stack:
- { id: 0, name: "", size: 128, alignment: 32 }
body: |
bb.0.entry:
liveins: $x2
; CHECK-LABEL: name: vshuffle_8_m35
; CHECK: liveins: $x2
; CHECK-NEXT: {{ $}}
; CHECK-NEXT: [[COPY:%[0-9]+]]:vec512 = COPY $x2
; CHECK-NEXT: [[MOV_RLC_imm10_pseudo:%[0-9]+]]:er = MOV_RLC_imm10_pseudo 29
; CHECK-NEXT: [[VSHUFFLE:%[0-9]+]]:vec512 = VSHUFFLE [[COPY]], [[COPY]], [[MOV_RLC_imm10_pseudo]]
; CHECK-NEXT: $x0 = COPY [[VSHUFFLE]]
; CHECK-NEXT: PseudoRET implicit $lr, implicit $x0
%1:vregbank(<64 x s8>) = COPY $x2
%2:gprregbank(s32) = G_CONSTANT i32 29
%0:vregbank(<64 x s8>) = G_AIE_VSHUFFLE %1:vregbank, %1:vregbank, %2:gprregbank(s32)
$x0 = COPY %0:vregbank(<64 x s8>)
PseudoRET implicit $lr, implicit $x0

0 comments on commit d1d0a3a

Please sign in to comment.