xref: /freebsd/contrib/llvm-project/llvm/lib/Target/VE/VVPInstrPatternsVec.td (revision 5e801ac66d24704442eba426ed13c3effb8a34e7)
1//===----------- VVPInstrPatternsVec.td - VVP_* SDNode patterns -----------===//
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// This file describes how VVP_* SDNodes are lowered to machine instructions.
10//
11//===----------------------------------------------------------------------===//
12
13//===----------------------------------------------------------------------===//
14//
15// VVP SDNode definitions.
16//
17//===----------------------------------------------------------------------===//
18include "VVPInstrInfo.td"
19
20multiclass VectorBinaryArith<
21    SDPatternOperator OpNode,
22    ValueType ScalarVT, ValueType DataVT, ValueType MaskVT,
23    string OpBaseName> {
24  // No mask.
25  def : Pat<(OpNode
26                (any_broadcast ScalarVT:$sx),
27                DataVT:$vy, (MaskVT true_mask), i32:$avl),
28            (!cast<Instruction>(OpBaseName#"rvl")
29                ScalarVT:$sx, $vy, $avl)>;
30  def : Pat<(OpNode DataVT:$vx, DataVT:$vy, (MaskVT true_mask), i32:$avl),
31            (!cast<Instruction>(OpBaseName#"vvl")
32                $vx, $vy, $avl)>;
33
34  // Mask.
35  def : Pat<(OpNode
36                (any_broadcast ScalarVT:$sx),
37                DataVT:$vy, MaskVT:$mask, i32:$avl),
38            (!cast<Instruction>(OpBaseName#"rvml")
39                ScalarVT:$sx, $vy, $mask, $avl)>;
40  def : Pat<(OpNode DataVT:$vx, DataVT:$vy, MaskVT:$mask, i32:$avl),
41            (!cast<Instruction>(OpBaseName#"vvml")
42                $vx, $vy, $mask, $avl)>;
43
44  // TODO We do not specify patterns for the immediate variants here. There
45  // will be an immediate folding pass that takes care of switching to the
46  // immediate variant where applicable.
47
48  // TODO Fold vvp_select into passthru.
49}
50
51// Expand both 64bit and 32 bit variant (256 elements)
52multiclass VectorBinaryArith_ShortLong<
53    SDPatternOperator OpNode,
54    ValueType LongScalarVT, ValueType LongDataVT, string LongOpBaseName,
55    ValueType ShortScalarVT, ValueType ShortDataVT, string ShortOpBaseName> {
56  defm : VectorBinaryArith<OpNode,
57                           LongScalarVT, LongDataVT, v256i1,
58                           LongOpBaseName>;
59  defm : VectorBinaryArith<OpNode,
60                           ShortScalarVT, ShortDataVT, v256i1,
61                           ShortOpBaseName>;
62}
63
64
65defm : VectorBinaryArith_ShortLong<c_vvp_add,
66                                   i64, v256i64, "VADDSL",
67                                   i32, v256i32, "VADDSWSX">;
68defm : VectorBinaryArith_ShortLong<c_vvp_and,
69                                   i64, v256i64, "VAND",
70                                   i32, v256i32, "PVANDLO">;
71