xref: /freebsd/contrib/llvm-project/llvm/lib/Target/VE/VVPInstrPatternsVec.td (revision ec0ea6efa1ad229d75c394c1a9b9cac33af2b1d3)
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    SDPatternOperator ImmOp, SDNodeXForm ImmCast> {
25  // No mask.
26  def : Pat<(OpNode
27                (any_broadcast ScalarVT:$sx),
28                DataVT:$vy, (MaskVT true_mask), i32:$avl),
29            (!cast<Instruction>(OpBaseName#"rvl")
30                ScalarVT:$sx, $vy, $avl)>;
31  def : Pat<(OpNode DataVT:$vx, DataVT:$vy, (MaskVT true_mask), i32:$avl),
32            (!cast<Instruction>(OpBaseName#"vvl")
33                $vx, $vy, $avl)>;
34
35  // Mask.
36  def : Pat<(OpNode
37                (any_broadcast ScalarVT:$sx),
38                DataVT:$vy, MaskVT:$mask, i32:$avl),
39            (!cast<Instruction>(OpBaseName#"rvml")
40                ScalarVT:$sx, $vy, $mask, $avl)>;
41  def : Pat<(OpNode DataVT:$vx, DataVT:$vy, MaskVT:$mask, i32:$avl),
42            (!cast<Instruction>(OpBaseName#"vvml")
43                $vx, $vy, $mask, $avl)>;
44
45  // TODO We do not specify patterns for the immediate variants here. There
46  // will be an immediate folding pass that takes care of switching to the
47  // immediate variant where applicable.
48
49  // TODO Fold vvp_select into passthru.
50}
51
52// Expand both 64bit and 32 bit variant (256 elements)
53multiclass VectorBinaryArith_ShortLong<
54    SDPatternOperator OpNode,
55    ValueType LongScalarVT, ValueType LongDataVT, string LongOpBaseName,
56    ValueType ShortScalarVT, ValueType ShortDataVT, string ShortOpBaseName> {
57  defm : VectorBinaryArith<OpNode,
58                           LongScalarVT, LongDataVT, v256i1,
59                           LongOpBaseName, simm7, LO7>;
60  defm : VectorBinaryArith<OpNode,
61                           ShortScalarVT, ShortDataVT, v256i1,
62                           ShortOpBaseName, simm7, LO7>;
63}
64
65
66defm : VectorBinaryArith_ShortLong<c_vvp_add,
67                                   i64, v256i64, "VADDSL",
68                                   i32, v256i32, "VADDSWSX">;
69defm : VectorBinaryArith_ShortLong<c_vvp_and,
70                                   i64, v256i64, "VAND",
71                                   i32, v256i32, "PVANDLO">;
72