xref: /freebsd/contrib/llvm-project/llvm/lib/Target/VE/VEInstrPatternsVec.td (revision 924226fba12cc9a228c73b956e1b7fa24c60b055)
1//===-- VEInstrPatternsVec.td - VEC_-type SDNodes and isel for VE Target --===//
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 the VEC_* prefixed intermediate SDNodes and their
10// isel patterns.
11//
12//===----------------------------------------------------------------------===//
13
14//===----------------------------------------------------------------------===//
15// Instruction format superclass
16//===----------------------------------------------------------------------===//
17
18// Sub-register replication for packed broadcast.
19def: Pat<(i64 (repl_f32 f32:$val)),
20            (ORrr
21              (SRLri (f2l $val), 32),
22              (zero_i32 (f2l $val)))>;
23def: Pat<(i64 (repl_i32 i32:$val)),
24            (ORrr
25              (zero_f32 (i2l $val)),
26              (SLLri (i2l $val), 32))>;
27
28
29multiclass vbrd_elem32<ValueType v32, ValueType s32, SDPatternOperator ImmOp,
30                       SDNodeXForm ImmCast, OutPatFrag SuperRegCast> {
31  // VBRDil
32  def : Pat<(v32 (vec_broadcast (s32 ImmOp:$sy), i32:$vl)),
33            (VBRDil (ImmCast $sy), i32:$vl)>;
34
35  // VBRDrl
36  def : Pat<(v32 (vec_broadcast s32:$sy, i32:$vl)),
37            (VBRDrl (SuperRegCast $sy), i32:$vl)>;
38}
39
40multiclass vbrd_elem64<ValueType v64, ValueType s64,
41                       SDPatternOperator ImmOp, SDNodeXForm ImmCast> {
42  // VBRDil
43  def : Pat<(v64 (vec_broadcast (s64 ImmOp:$sy), i32:$vl)),
44            (VBRDil (ImmCast $sy), i32:$vl)>;
45
46  // VBRDrl
47  def : Pat<(v64 (vec_broadcast s64:$sy, i32:$vl)),
48            (VBRDrl s64:$sy, i32:$vl)>;
49}
50
51multiclass extract_insert_elem32<ValueType v32, ValueType s32,
52                                 OutPatFrag SubRegCast,
53                                 OutPatFrag SuperRegCast> {
54  // LVSvi
55  def: Pat<(s32 (extractelt v32:$vec, uimm7:$idx)),
56           (SubRegCast (LVSvi v32:$vec, (ULO7 $idx)))>;
57  // LVSvr
58  def: Pat<(s32 (extractelt v32:$vec, i64:$idx)),
59           (SubRegCast (LVSvr v32:$vec, $idx))>;
60
61  // LSVir
62  def: Pat<(v32 (insertelt v32:$vec, s32:$val, uimm7:$idx)),
63           (LSVir_v (ULO7 $idx), (SuperRegCast $val), $vec)>;
64  // LSVrr
65  def: Pat<(v32 (insertelt v32:$vec, s32:$val, i64:$idx)),
66           (LSVrr_v $idx, (SuperRegCast $val), $vec)>;
67}
68
69multiclass extract_insert_elem64<ValueType v64, ValueType s64> {
70  // LVSvi
71  def: Pat<(s64 (extractelt v64:$vec, uimm7:$idx)),
72           (LVSvi v64:$vec, (ULO7 $idx))>;
73  // LVSvr
74  def: Pat<(s64 (extractelt v64:$vec, i64:$idx)),
75           (LVSvr v64:$vec, $idx)>;
76
77  // LSVir
78  def: Pat<(v64 (insertelt v64:$vec, s64:$val, uimm7:$idx)),
79           (LSVir_v (ULO7 $idx), $val, $vec)>;
80  // LSVrr
81  def: Pat<(v64 (insertelt v64:$vec, s64:$val, i64:$idx)),
82           (LSVrr_v $idx, $val, $vec)>;
83}
84
85multiclass patterns_elem32<ValueType v32, ValueType s32,
86                           SDPatternOperator ImmOp, SDNodeXForm ImmCast,
87                           OutPatFrag SubRegCast, OutPatFrag SuperRegCast> {
88  defm : vbrd_elem32<v32, s32, ImmOp, ImmCast, SuperRegCast>;
89  defm : extract_insert_elem32<v32, s32, SubRegCast, SuperRegCast>;
90}
91
92multiclass patterns_elem64<ValueType v64, ValueType s64,
93                           SDPatternOperator ImmOp, SDNodeXForm ImmCast> {
94  defm : vbrd_elem64<v64, s64, ImmOp, ImmCast>;
95  defm : extract_insert_elem64<v64, s64>;
96}
97
98defm : patterns_elem32<v256i32, i32, simm7, LO7, l2i, i2l>;
99defm : patterns_elem32<v256f32, f32, simm7fp, LO7FP, l2f, f2l>;
100
101defm : patterns_elem64<v256i64, i64, simm7, LO7>;
102defm : patterns_elem64<v256f64, f64, simm7fp, LO7FP>;
103
104defm : vbrd_elem64<v512i32, i64, simm7, LO7>;
105defm : vbrd_elem64<v512f32, i64, simm7, LO7>;
106defm : vbrd_elem64<v512i32, f64, simm7fp, LO7FP>;
107defm : vbrd_elem64<v512f32, f64, simm7fp, LO7FP>;
108