blob: 92b046c1eeb12a6d5cf27709f9648bb9c22f8f57 [file] [log] [blame]
Ulrich Weiganda8b04e12015-05-05 19:23:40 +00001//==- SystemZInstrVector.td - SystemZ Vector instructions ------*- tblgen-*-==//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9
10//===----------------------------------------------------------------------===//
11// Move instructions
12//===----------------------------------------------------------------------===//
13
14let Predicates = [FeatureVector] in {
15 // Register move.
16 def VLR : UnaryVRRa<"vlr", 0xE756, null_frag, v128any, v128any>;
Ulrich Weigand49506d72015-05-05 19:28:34 +000017 def VLR32 : UnaryAliasVRR<null_frag, v32eb, v32eb>;
18 def VLR64 : UnaryAliasVRR<null_frag, v64db, v64db>;
Ulrich Weiganda8b04e12015-05-05 19:23:40 +000019
20 // Load GR from VR element.
Ulrich Weigand6e31ab32016-10-19 13:03:18 +000021 def VLGV : BinaryVRScGeneric<"vlgv", 0xE721>;
Ulrich Weiganda8b04e12015-05-05 19:23:40 +000022 def VLGVB : BinaryVRSc<"vlgvb", 0xE721, null_frag, v128b, 0>;
23 def VLGVH : BinaryVRSc<"vlgvh", 0xE721, null_frag, v128h, 1>;
24 def VLGVF : BinaryVRSc<"vlgvf", 0xE721, null_frag, v128f, 2>;
Ulrich Weigandce4c1092015-05-05 19:25:42 +000025 def VLGVG : BinaryVRSc<"vlgvg", 0xE721, z_vector_extract, v128g, 3>;
Ulrich Weiganda8b04e12015-05-05 19:23:40 +000026
27 // Load VR element from GR.
Ulrich Weigand6e31ab32016-10-19 13:03:18 +000028 def VLVG : TernaryVRSbGeneric<"vlvg", 0xE722>;
Ulrich Weigandce4c1092015-05-05 19:25:42 +000029 def VLVGB : TernaryVRSb<"vlvgb", 0xE722, z_vector_insert,
30 v128b, v128b, GR32, 0>;
31 def VLVGH : TernaryVRSb<"vlvgh", 0xE722, z_vector_insert,
32 v128h, v128h, GR32, 1>;
33 def VLVGF : TernaryVRSb<"vlvgf", 0xE722, z_vector_insert,
34 v128f, v128f, GR32, 2>;
35 def VLVGG : TernaryVRSb<"vlvgg", 0xE722, z_vector_insert,
36 v128g, v128g, GR64, 3>;
Ulrich Weiganda8b04e12015-05-05 19:23:40 +000037
38 // Load VR from GRs disjoint.
Ulrich Weigandce4c1092015-05-05 19:25:42 +000039 def VLVGP : BinaryVRRf<"vlvgp", 0xE762, z_join_dwords, v128g>;
40 def VLVGP32 : BinaryAliasVRRf<GR32>;
Ulrich Weiganda8b04e12015-05-05 19:23:40 +000041}
42
Ulrich Weigandce4c1092015-05-05 19:25:42 +000043// Extractions always assign to the full GR64, even if the element would
44// fit in the lower 32 bits. Sub-i64 extracts therefore need to take a
45// subreg of the result.
46class VectorExtractSubreg<ValueType type, Instruction insn>
47 : Pat<(i32 (z_vector_extract (type VR128:$vec), shift12only:$index)),
48 (EXTRACT_SUBREG (insn VR128:$vec, shift12only:$index), subreg_l32)>;
49
50def : VectorExtractSubreg<v16i8, VLGVB>;
51def : VectorExtractSubreg<v8i16, VLGVH>;
52def : VectorExtractSubreg<v4i32, VLGVF>;
53
Ulrich Weiganda8b04e12015-05-05 19:23:40 +000054//===----------------------------------------------------------------------===//
55// Immediate instructions
56//===----------------------------------------------------------------------===//
57
58let Predicates = [FeatureVector] in {
59 // Generate byte mask.
60 def VZERO : InherentVRIa<"vzero", 0xE744, 0>;
61 def VONE : InherentVRIa<"vone", 0xE744, 0xffff>;
Ulrich Weigandce4c1092015-05-05 19:25:42 +000062 def VGBM : UnaryVRIa<"vgbm", 0xE744, z_byte_mask, v128b, imm32zx16>;
Ulrich Weiganda8b04e12015-05-05 19:23:40 +000063
64 // Generate mask.
Ulrich Weigand6e31ab32016-10-19 13:03:18 +000065 def VGM : BinaryVRIbGeneric<"vgm", 0xE746>;
Ulrich Weigandce4c1092015-05-05 19:25:42 +000066 def VGMB : BinaryVRIb<"vgmb", 0xE746, z_rotate_mask, v128b, 0>;
67 def VGMH : BinaryVRIb<"vgmh", 0xE746, z_rotate_mask, v128h, 1>;
68 def VGMF : BinaryVRIb<"vgmf", 0xE746, z_rotate_mask, v128f, 2>;
69 def VGMG : BinaryVRIb<"vgmg", 0xE746, z_rotate_mask, v128g, 3>;
Ulrich Weiganda8b04e12015-05-05 19:23:40 +000070
71 // Load element immediate.
Ulrich Weigandce4c1092015-05-05 19:25:42 +000072 //
73 // We want these instructions to be used ahead of VLVG* where possible.
74 // However, VLVG* takes a variable BD-format index whereas VLEI takes
75 // a plain immediate index. This means that VLVG* has an extra "base"
76 // register operand and is 3 units more complex. Bumping the complexity
77 // of the VLEI* instructions by 4 means that they are strictly better
78 // than VLVG* in cases where both forms match.
79 let AddedComplexity = 4 in {
80 def VLEIB : TernaryVRIa<"vleib", 0xE740, z_vector_insert,
81 v128b, v128b, imm32sx16trunc, imm32zx4>;
82 def VLEIH : TernaryVRIa<"vleih", 0xE741, z_vector_insert,
83 v128h, v128h, imm32sx16trunc, imm32zx3>;
84 def VLEIF : TernaryVRIa<"vleif", 0xE743, z_vector_insert,
85 v128f, v128f, imm32sx16, imm32zx2>;
86 def VLEIG : TernaryVRIa<"vleig", 0xE742, z_vector_insert,
87 v128g, v128g, imm64sx16, imm32zx1>;
88 }
Ulrich Weiganda8b04e12015-05-05 19:23:40 +000089
90 // Replicate immediate.
Ulrich Weigand6e31ab32016-10-19 13:03:18 +000091 def VREPI : UnaryVRIaGeneric<"vrepi", 0xE745, imm32sx16>;
Ulrich Weigandce4c1092015-05-05 19:25:42 +000092 def VREPIB : UnaryVRIa<"vrepib", 0xE745, z_replicate, v128b, imm32sx16, 0>;
93 def VREPIH : UnaryVRIa<"vrepih", 0xE745, z_replicate, v128h, imm32sx16, 1>;
94 def VREPIF : UnaryVRIa<"vrepif", 0xE745, z_replicate, v128f, imm32sx16, 2>;
95 def VREPIG : UnaryVRIa<"vrepig", 0xE745, z_replicate, v128g, imm32sx16, 3>;
Ulrich Weiganda8b04e12015-05-05 19:23:40 +000096}
97
98//===----------------------------------------------------------------------===//
99// Loads
100//===----------------------------------------------------------------------===//
101
102let Predicates = [FeatureVector] in {
103 // Load.
104 def VL : UnaryVRX<"vl", 0xE706, null_frag, v128any, 16>;
105
106 // Load to block boundary. The number of loaded bytes is only known
Ulrich Weigandc1708b22015-05-05 19:31:09 +0000107 // at run time. The instruction is really polymorphic, but v128b matches
108 // the return type of the associated intrinsic.
109 def VLBB : BinaryVRX<"vlbb", 0xE707, int_s390_vlbb, v128b, 0>;
Ulrich Weiganda8b04e12015-05-05 19:23:40 +0000110
111 // Load count to block boundary.
112 let Defs = [CC] in
113 def LCBB : InstRXE<0xE727, (outs GR32:$R1),
114 (ins bdxaddr12only:$XBD2, imm32zx4:$M3),
Ulrich Weigandc1708b22015-05-05 19:31:09 +0000115 "lcbb\t$R1, $XBD2, $M3",
116 [(set GR32:$R1, (int_s390_lcbb bdxaddr12only:$XBD2,
117 imm32zx4:$M3))]>;
Ulrich Weiganda8b04e12015-05-05 19:23:40 +0000118
119 // Load with length. The number of loaded bytes is only known at run time.
Ulrich Weigandc1708b22015-05-05 19:31:09 +0000120 def VLL : BinaryVRSb<"vll", 0xE737, int_s390_vll, 0>;
Ulrich Weiganda8b04e12015-05-05 19:23:40 +0000121
122 // Load multiple.
123 def VLM : LoadMultipleVRSa<"vlm", 0xE736>;
124
125 // Load and replicate
Ulrich Weigand6e31ab32016-10-19 13:03:18 +0000126 def VLREP : UnaryVRXGeneric<"vlrep", 0xE705>;
Ulrich Weigandce4c1092015-05-05 19:25:42 +0000127 def VLREPB : UnaryVRX<"vlrepb", 0xE705, z_replicate_loadi8, v128b, 1, 0>;
128 def VLREPH : UnaryVRX<"vlreph", 0xE705, z_replicate_loadi16, v128h, 2, 1>;
129 def VLREPF : UnaryVRX<"vlrepf", 0xE705, z_replicate_loadi32, v128f, 4, 2>;
130 def VLREPG : UnaryVRX<"vlrepg", 0xE705, z_replicate_loadi64, v128g, 8, 3>;
Ulrich Weigand80b3af72015-05-05 19:27:45 +0000131 def : Pat<(v4f32 (z_replicate_loadf32 bdxaddr12only:$addr)),
132 (VLREPF bdxaddr12only:$addr)>;
Ulrich Weigandcd808232015-05-05 19:26:48 +0000133 def : Pat<(v2f64 (z_replicate_loadf64 bdxaddr12only:$addr)),
134 (VLREPG bdxaddr12only:$addr)>;
Ulrich Weiganda8b04e12015-05-05 19:23:40 +0000135
Ulrich Weigand49506d72015-05-05 19:28:34 +0000136 // Use VLREP to load subvectors. These patterns use "12pair" because
137 // LEY and LDY offer full 20-bit displacement fields. It's often better
138 // to use those instructions rather than force a 20-bit displacement
139 // into a GPR temporary.
140 def VL32 : UnaryAliasVRX<load, v32eb, bdxaddr12pair>;
141 def VL64 : UnaryAliasVRX<load, v64db, bdxaddr12pair>;
142
Ulrich Weiganda8b04e12015-05-05 19:23:40 +0000143 // Load logical element and zero.
Ulrich Weigand6e31ab32016-10-19 13:03:18 +0000144 def VLLEZ : UnaryVRXGeneric<"vllez", 0xE704>;
Ulrich Weigandce4c1092015-05-05 19:25:42 +0000145 def VLLEZB : UnaryVRX<"vllezb", 0xE704, z_vllezi8, v128b, 1, 0>;
146 def VLLEZH : UnaryVRX<"vllezh", 0xE704, z_vllezi16, v128h, 2, 1>;
147 def VLLEZF : UnaryVRX<"vllezf", 0xE704, z_vllezi32, v128f, 4, 2>;
148 def VLLEZG : UnaryVRX<"vllezg", 0xE704, z_vllezi64, v128g, 8, 3>;
Ulrich Weigand80b3af72015-05-05 19:27:45 +0000149 def : Pat<(v4f32 (z_vllezf32 bdxaddr12only:$addr)),
150 (VLLEZF bdxaddr12only:$addr)>;
Ulrich Weigandcd808232015-05-05 19:26:48 +0000151 def : Pat<(v2f64 (z_vllezf64 bdxaddr12only:$addr)),
152 (VLLEZG bdxaddr12only:$addr)>;
Ulrich Weiganda8b04e12015-05-05 19:23:40 +0000153
154 // Load element.
Ulrich Weigandce4c1092015-05-05 19:25:42 +0000155 def VLEB : TernaryVRX<"vleb", 0xE700, z_vlei8, v128b, v128b, 1, imm32zx4>;
156 def VLEH : TernaryVRX<"vleh", 0xE701, z_vlei16, v128h, v128h, 2, imm32zx3>;
157 def VLEF : TernaryVRX<"vlef", 0xE703, z_vlei32, v128f, v128f, 4, imm32zx2>;
158 def VLEG : TernaryVRX<"vleg", 0xE702, z_vlei64, v128g, v128g, 8, imm32zx1>;
Ulrich Weigand80b3af72015-05-05 19:27:45 +0000159 def : Pat<(z_vlef32 (v4f32 VR128:$val), bdxaddr12only:$addr, imm32zx2:$index),
160 (VLEF VR128:$val, bdxaddr12only:$addr, imm32zx2:$index)>;
Ulrich Weigandcd808232015-05-05 19:26:48 +0000161 def : Pat<(z_vlef64 (v2f64 VR128:$val), bdxaddr12only:$addr, imm32zx1:$index),
162 (VLEG VR128:$val, bdxaddr12only:$addr, imm32zx1:$index)>;
Ulrich Weiganda8b04e12015-05-05 19:23:40 +0000163
164 // Gather element.
165 def VGEF : TernaryVRV<"vgef", 0xE713, 4, imm32zx2>;
166 def VGEG : TernaryVRV<"vgeg", 0xE712, 8, imm32zx1>;
167}
168
Ulrich Weigandce4c1092015-05-05 19:25:42 +0000169// Use replicating loads if we're inserting a single element into an
170// undefined vector. This avoids a false dependency on the previous
171// register contents.
172multiclass ReplicatePeephole<Instruction vlrep, ValueType vectype,
173 SDPatternOperator load, ValueType scalartype> {
174 def : Pat<(vectype (z_vector_insert
175 (undef), (scalartype (load bdxaddr12only:$addr)), 0)),
176 (vlrep bdxaddr12only:$addr)>;
177 def : Pat<(vectype (scalar_to_vector
178 (scalartype (load bdxaddr12only:$addr)))),
179 (vlrep bdxaddr12only:$addr)>;
180}
181defm : ReplicatePeephole<VLREPB, v16i8, anyextloadi8, i32>;
182defm : ReplicatePeephole<VLREPH, v8i16, anyextloadi16, i32>;
183defm : ReplicatePeephole<VLREPF, v4i32, load, i32>;
184defm : ReplicatePeephole<VLREPG, v2i64, load, i64>;
Ulrich Weigand80b3af72015-05-05 19:27:45 +0000185defm : ReplicatePeephole<VLREPF, v4f32, load, f32>;
Ulrich Weigandcd808232015-05-05 19:26:48 +0000186defm : ReplicatePeephole<VLREPG, v2f64, load, f64>;
Ulrich Weigandce4c1092015-05-05 19:25:42 +0000187
Ulrich Weiganda8b04e12015-05-05 19:23:40 +0000188//===----------------------------------------------------------------------===//
189// Stores
190//===----------------------------------------------------------------------===//
191
192let Predicates = [FeatureVector] in {
193 // Store.
194 def VST : StoreVRX<"vst", 0xE70E, null_frag, v128any, 16>;
195
196 // Store with length. The number of stored bytes is only known at run time.
Ulrich Weigandc1708b22015-05-05 19:31:09 +0000197 def VSTL : StoreLengthVRSb<"vstl", 0xE73F, int_s390_vstl, 0>;
Ulrich Weiganda8b04e12015-05-05 19:23:40 +0000198
199 // Store multiple.
200 def VSTM : StoreMultipleVRSa<"vstm", 0xE73E>;
201
202 // Store element.
Ulrich Weigandce4c1092015-05-05 19:25:42 +0000203 def VSTEB : StoreBinaryVRX<"vsteb", 0xE708, z_vstei8, v128b, 1, imm32zx4>;
204 def VSTEH : StoreBinaryVRX<"vsteh", 0xE709, z_vstei16, v128h, 2, imm32zx3>;
205 def VSTEF : StoreBinaryVRX<"vstef", 0xE70B, z_vstei32, v128f, 4, imm32zx2>;
206 def VSTEG : StoreBinaryVRX<"vsteg", 0xE70A, z_vstei64, v128g, 8, imm32zx1>;
Ulrich Weigand80b3af72015-05-05 19:27:45 +0000207 def : Pat<(z_vstef32 (v4f32 VR128:$val), bdxaddr12only:$addr,
208 imm32zx2:$index),
209 (VSTEF VR128:$val, bdxaddr12only:$addr, imm32zx2:$index)>;
Ulrich Weigandcd808232015-05-05 19:26:48 +0000210 def : Pat<(z_vstef64 (v2f64 VR128:$val), bdxaddr12only:$addr,
211 imm32zx1:$index),
212 (VSTEG VR128:$val, bdxaddr12only:$addr, imm32zx1:$index)>;
Ulrich Weiganda8b04e12015-05-05 19:23:40 +0000213
Ulrich Weigand49506d72015-05-05 19:28:34 +0000214 // Use VSTE to store subvectors. These patterns use "12pair" because
215 // STEY and STDY offer full 20-bit displacement fields. It's often better
216 // to use those instructions rather than force a 20-bit displacement
217 // into a GPR temporary.
218 def VST32 : StoreAliasVRX<store, v32eb, bdxaddr12pair>;
219 def VST64 : StoreAliasVRX<store, v64db, bdxaddr12pair>;
220
Ulrich Weiganda8b04e12015-05-05 19:23:40 +0000221 // Scatter element.
222 def VSCEF : StoreBinaryVRV<"vscef", 0xE71B, 4, imm32zx2>;
223 def VSCEG : StoreBinaryVRV<"vsceg", 0xE71A, 8, imm32zx1>;
224}
225
226//===----------------------------------------------------------------------===//
227// Selects and permutes
228//===----------------------------------------------------------------------===//
229
230let Predicates = [FeatureVector] in {
231 // Merge high.
Ulrich Weigand6e31ab32016-10-19 13:03:18 +0000232 def VMRH: BinaryVRRcGeneric<"vmrh", 0xE761>;
Ulrich Weigandce4c1092015-05-05 19:25:42 +0000233 def VMRHB : BinaryVRRc<"vmrhb", 0xE761, z_merge_high, v128b, v128b, 0>;
234 def VMRHH : BinaryVRRc<"vmrhh", 0xE761, z_merge_high, v128h, v128h, 1>;
235 def VMRHF : BinaryVRRc<"vmrhf", 0xE761, z_merge_high, v128f, v128f, 2>;
236 def VMRHG : BinaryVRRc<"vmrhg", 0xE761, z_merge_high, v128g, v128g, 3>;
Ulrich Weigand80b3af72015-05-05 19:27:45 +0000237 def : BinaryRRWithType<VMRHF, VR128, z_merge_high, v4f32>;
Ulrich Weigandcd808232015-05-05 19:26:48 +0000238 def : BinaryRRWithType<VMRHG, VR128, z_merge_high, v2f64>;
Ulrich Weiganda8b04e12015-05-05 19:23:40 +0000239
240 // Merge low.
Ulrich Weigand6e31ab32016-10-19 13:03:18 +0000241 def VMRL: BinaryVRRcGeneric<"vmrl", 0xE760>;
Ulrich Weigandce4c1092015-05-05 19:25:42 +0000242 def VMRLB : BinaryVRRc<"vmrlb", 0xE760, z_merge_low, v128b, v128b, 0>;
243 def VMRLH : BinaryVRRc<"vmrlh", 0xE760, z_merge_low, v128h, v128h, 1>;
244 def VMRLF : BinaryVRRc<"vmrlf", 0xE760, z_merge_low, v128f, v128f, 2>;
245 def VMRLG : BinaryVRRc<"vmrlg", 0xE760, z_merge_low, v128g, v128g, 3>;
Ulrich Weigand80b3af72015-05-05 19:27:45 +0000246 def : BinaryRRWithType<VMRLF, VR128, z_merge_low, v4f32>;
Ulrich Weigandcd808232015-05-05 19:26:48 +0000247 def : BinaryRRWithType<VMRLG, VR128, z_merge_low, v2f64>;
Ulrich Weiganda8b04e12015-05-05 19:23:40 +0000248
249 // Permute.
Ulrich Weigandce4c1092015-05-05 19:25:42 +0000250 def VPERM : TernaryVRRe<"vperm", 0xE78C, z_permute, v128b, v128b>;
Ulrich Weiganda8b04e12015-05-05 19:23:40 +0000251
252 // Permute doubleword immediate.
Ulrich Weigandce4c1092015-05-05 19:25:42 +0000253 def VPDI : TernaryVRRc<"vpdi", 0xE784, z_permute_dwords, v128g, v128g>;
Ulrich Weiganda8b04e12015-05-05 19:23:40 +0000254
255 // Replicate.
Ulrich Weigand6e31ab32016-10-19 13:03:18 +0000256 def VREP: BinaryVRIcGeneric<"vrep", 0xE74D>;
Ulrich Weigandce4c1092015-05-05 19:25:42 +0000257 def VREPB : BinaryVRIc<"vrepb", 0xE74D, z_splat, v128b, v128b, 0>;
258 def VREPH : BinaryVRIc<"vreph", 0xE74D, z_splat, v128h, v128h, 1>;
259 def VREPF : BinaryVRIc<"vrepf", 0xE74D, z_splat, v128f, v128f, 2>;
260 def VREPG : BinaryVRIc<"vrepg", 0xE74D, z_splat, v128g, v128g, 3>;
Ulrich Weigand80b3af72015-05-05 19:27:45 +0000261 def : Pat<(v4f32 (z_splat VR128:$vec, imm32zx16:$index)),
262 (VREPF VR128:$vec, imm32zx16:$index)>;
Ulrich Weigandcd808232015-05-05 19:26:48 +0000263 def : Pat<(v2f64 (z_splat VR128:$vec, imm32zx16:$index)),
264 (VREPG VR128:$vec, imm32zx16:$index)>;
Ulrich Weiganda8b04e12015-05-05 19:23:40 +0000265
266 // Select.
267 def VSEL : TernaryVRRe<"vsel", 0xE78D, null_frag, v128any, v128any>;
268}
269
270//===----------------------------------------------------------------------===//
271// Widening and narrowing
272//===----------------------------------------------------------------------===//
273
274let Predicates = [FeatureVector] in {
275 // Pack
Ulrich Weigand6e31ab32016-10-19 13:03:18 +0000276 def VPK : BinaryVRRcGeneric<"vpk", 0xE794>;
Ulrich Weigandce4c1092015-05-05 19:25:42 +0000277 def VPKH : BinaryVRRc<"vpkh", 0xE794, z_pack, v128b, v128h, 1>;
278 def VPKF : BinaryVRRc<"vpkf", 0xE794, z_pack, v128h, v128f, 2>;
279 def VPKG : BinaryVRRc<"vpkg", 0xE794, z_pack, v128f, v128g, 3>;
Ulrich Weiganda8b04e12015-05-05 19:23:40 +0000280
281 // Pack saturate.
Ulrich Weigand6e31ab32016-10-19 13:03:18 +0000282 def VPKS : BinaryVRRbSPairGeneric<"vpks", 0xE797>;
Ulrich Weigandc1708b22015-05-05 19:31:09 +0000283 defm VPKSH : BinaryVRRbSPair<"vpksh", 0xE797, int_s390_vpksh, z_packs_cc,
Ulrich Weiganda8b04e12015-05-05 19:23:40 +0000284 v128b, v128h, 1>;
Ulrich Weigandc1708b22015-05-05 19:31:09 +0000285 defm VPKSF : BinaryVRRbSPair<"vpksf", 0xE797, int_s390_vpksf, z_packs_cc,
Ulrich Weiganda8b04e12015-05-05 19:23:40 +0000286 v128h, v128f, 2>;
Ulrich Weigandc1708b22015-05-05 19:31:09 +0000287 defm VPKSG : BinaryVRRbSPair<"vpksg", 0xE797, int_s390_vpksg, z_packs_cc,
Ulrich Weiganda8b04e12015-05-05 19:23:40 +0000288 v128f, v128g, 3>;
289
290 // Pack saturate logical.
Ulrich Weigand6e31ab32016-10-19 13:03:18 +0000291 def VPKLS : BinaryVRRbSPairGeneric<"vpkls", 0xE795>;
Ulrich Weigandc1708b22015-05-05 19:31:09 +0000292 defm VPKLSH : BinaryVRRbSPair<"vpklsh", 0xE795, int_s390_vpklsh, z_packls_cc,
Ulrich Weiganda8b04e12015-05-05 19:23:40 +0000293 v128b, v128h, 1>;
Ulrich Weigandc1708b22015-05-05 19:31:09 +0000294 defm VPKLSF : BinaryVRRbSPair<"vpklsf", 0xE795, int_s390_vpklsf, z_packls_cc,
Ulrich Weiganda8b04e12015-05-05 19:23:40 +0000295 v128h, v128f, 2>;
Ulrich Weigandc1708b22015-05-05 19:31:09 +0000296 defm VPKLSG : BinaryVRRbSPair<"vpklsg", 0xE795, int_s390_vpklsg, z_packls_cc,
Ulrich Weiganda8b04e12015-05-05 19:23:40 +0000297 v128f, v128g, 3>;
298
299 // Sign-extend to doubleword.
Ulrich Weigand6e31ab32016-10-19 13:03:18 +0000300 def VSEG : UnaryVRRaGeneric<"vseg", 0xE75F>;
Ulrich Weigandce4c1092015-05-05 19:25:42 +0000301 def VSEGB : UnaryVRRa<"vsegb", 0xE75F, z_vsei8, v128g, v128g, 0>;
302 def VSEGH : UnaryVRRa<"vsegh", 0xE75F, z_vsei16, v128g, v128g, 1>;
303 def VSEGF : UnaryVRRa<"vsegf", 0xE75F, z_vsei32, v128g, v128g, 2>;
304 def : Pat<(z_vsei8_by_parts (v16i8 VR128:$src)), (VSEGB VR128:$src)>;
305 def : Pat<(z_vsei16_by_parts (v8i16 VR128:$src)), (VSEGH VR128:$src)>;
306 def : Pat<(z_vsei32_by_parts (v4i32 VR128:$src)), (VSEGF VR128:$src)>;
Ulrich Weiganda8b04e12015-05-05 19:23:40 +0000307
308 // Unpack high.
Ulrich Weigand6e31ab32016-10-19 13:03:18 +0000309 def VUPH : UnaryVRRaGeneric<"vuph", 0xE7D7>;
Ulrich Weigandcd2a1b52015-05-05 19:29:21 +0000310 def VUPHB : UnaryVRRa<"vuphb", 0xE7D7, z_unpack_high, v128h, v128b, 0>;
311 def VUPHH : UnaryVRRa<"vuphh", 0xE7D7, z_unpack_high, v128f, v128h, 1>;
312 def VUPHF : UnaryVRRa<"vuphf", 0xE7D7, z_unpack_high, v128g, v128f, 2>;
Ulrich Weiganda8b04e12015-05-05 19:23:40 +0000313
314 // Unpack logical high.
Ulrich Weigand6e31ab32016-10-19 13:03:18 +0000315 def VUPLH : UnaryVRRaGeneric<"vuplh", 0xE7D5>;
Ulrich Weigandcd2a1b52015-05-05 19:29:21 +0000316 def VUPLHB : UnaryVRRa<"vuplhb", 0xE7D5, z_unpackl_high, v128h, v128b, 0>;
317 def VUPLHH : UnaryVRRa<"vuplhh", 0xE7D5, z_unpackl_high, v128f, v128h, 1>;
318 def VUPLHF : UnaryVRRa<"vuplhf", 0xE7D5, z_unpackl_high, v128g, v128f, 2>;
Ulrich Weiganda8b04e12015-05-05 19:23:40 +0000319
320 // Unpack low.
Ulrich Weigand6e31ab32016-10-19 13:03:18 +0000321 def VUPL : UnaryVRRaGeneric<"vupl", 0xE7D6>;
Ulrich Weigandcd2a1b52015-05-05 19:29:21 +0000322 def VUPLB : UnaryVRRa<"vuplb", 0xE7D6, z_unpack_low, v128h, v128b, 0>;
323 def VUPLHW : UnaryVRRa<"vuplhw", 0xE7D6, z_unpack_low, v128f, v128h, 1>;
324 def VUPLF : UnaryVRRa<"vuplf", 0xE7D6, z_unpack_low, v128g, v128f, 2>;
Ulrich Weiganda8b04e12015-05-05 19:23:40 +0000325
326 // Unpack logical low.
Ulrich Weigand6e31ab32016-10-19 13:03:18 +0000327 def VUPLL : UnaryVRRaGeneric<"vupll", 0xE7D4>;
Ulrich Weigandcd2a1b52015-05-05 19:29:21 +0000328 def VUPLLB : UnaryVRRa<"vupllb", 0xE7D4, z_unpackl_low, v128h, v128b, 0>;
329 def VUPLLH : UnaryVRRa<"vupllh", 0xE7D4, z_unpackl_low, v128f, v128h, 1>;
330 def VUPLLF : UnaryVRRa<"vupllf", 0xE7D4, z_unpackl_low, v128g, v128f, 2>;
Ulrich Weiganda8b04e12015-05-05 19:23:40 +0000331}
332
333//===----------------------------------------------------------------------===//
Ulrich Weigandce4c1092015-05-05 19:25:42 +0000334// Instantiating generic operations for specific types.
335//===----------------------------------------------------------------------===//
336
337multiclass GenericVectorOps<ValueType type, ValueType inttype> {
338 let Predicates = [FeatureVector] in {
339 def : Pat<(type (load bdxaddr12only:$addr)),
340 (VL bdxaddr12only:$addr)>;
341 def : Pat<(store (type VR128:$src), bdxaddr12only:$addr),
342 (VST VR128:$src, bdxaddr12only:$addr)>;
343 def : Pat<(type (vselect (inttype VR128:$x), VR128:$y, VR128:$z)),
344 (VSEL VR128:$y, VR128:$z, VR128:$x)>;
345 def : Pat<(type (vselect (inttype (z_vnot VR128:$x)), VR128:$y, VR128:$z)),
346 (VSEL VR128:$z, VR128:$y, VR128:$x)>;
347 }
348}
349
350defm : GenericVectorOps<v16i8, v16i8>;
351defm : GenericVectorOps<v8i16, v8i16>;
352defm : GenericVectorOps<v4i32, v4i32>;
353defm : GenericVectorOps<v2i64, v2i64>;
Ulrich Weigand80b3af72015-05-05 19:27:45 +0000354defm : GenericVectorOps<v4f32, v4i32>;
Ulrich Weigandcd808232015-05-05 19:26:48 +0000355defm : GenericVectorOps<v2f64, v2i64>;
Ulrich Weigandce4c1092015-05-05 19:25:42 +0000356
357//===----------------------------------------------------------------------===//
Ulrich Weiganda8b04e12015-05-05 19:23:40 +0000358// Integer arithmetic
359//===----------------------------------------------------------------------===//
360
361let Predicates = [FeatureVector] in {
362 // Add.
Ulrich Weigand6e31ab32016-10-19 13:03:18 +0000363 def VA : BinaryVRRcGeneric<"va", 0xE7F3>;
Ulrich Weigandce4c1092015-05-05 19:25:42 +0000364 def VAB : BinaryVRRc<"vab", 0xE7F3, add, v128b, v128b, 0>;
365 def VAH : BinaryVRRc<"vah", 0xE7F3, add, v128h, v128h, 1>;
366 def VAF : BinaryVRRc<"vaf", 0xE7F3, add, v128f, v128f, 2>;
367 def VAG : BinaryVRRc<"vag", 0xE7F3, add, v128g, v128g, 3>;
Ulrich Weigandc1708b22015-05-05 19:31:09 +0000368 def VAQ : BinaryVRRc<"vaq", 0xE7F3, int_s390_vaq, v128q, v128q, 4>;
Ulrich Weiganda8b04e12015-05-05 19:23:40 +0000369
370 // Add compute carry.
Ulrich Weigand6e31ab32016-10-19 13:03:18 +0000371 def VACC : BinaryVRRcGeneric<"vacc", 0xE7F1>;
Ulrich Weigandc1708b22015-05-05 19:31:09 +0000372 def VACCB : BinaryVRRc<"vaccb", 0xE7F1, int_s390_vaccb, v128b, v128b, 0>;
373 def VACCH : BinaryVRRc<"vacch", 0xE7F1, int_s390_vacch, v128h, v128h, 1>;
374 def VACCF : BinaryVRRc<"vaccf", 0xE7F1, int_s390_vaccf, v128f, v128f, 2>;
375 def VACCG : BinaryVRRc<"vaccg", 0xE7F1, int_s390_vaccg, v128g, v128g, 3>;
376 def VACCQ : BinaryVRRc<"vaccq", 0xE7F1, int_s390_vaccq, v128q, v128q, 4>;
Ulrich Weiganda8b04e12015-05-05 19:23:40 +0000377
378 // Add with carry.
Ulrich Weigand6e31ab32016-10-19 13:03:18 +0000379 def VAC : TernaryVRRdGeneric<"vac", 0xE7BB>;
Ulrich Weigandc1708b22015-05-05 19:31:09 +0000380 def VACQ : TernaryVRRd<"vacq", 0xE7BB, int_s390_vacq, v128q, v128q, 4>;
Ulrich Weiganda8b04e12015-05-05 19:23:40 +0000381
382 // Add with carry compute carry.
Ulrich Weigand6e31ab32016-10-19 13:03:18 +0000383 def VACCC : TernaryVRRdGeneric<"vaccc", 0xE7B9>;
Ulrich Weigandc1708b22015-05-05 19:31:09 +0000384 def VACCCQ : TernaryVRRd<"vacccq", 0xE7B9, int_s390_vacccq, v128q, v128q, 4>;
Ulrich Weiganda8b04e12015-05-05 19:23:40 +0000385
386 // And.
387 def VN : BinaryVRRc<"vn", 0xE768, null_frag, v128any, v128any>;
388
389 // And with complement.
390 def VNC : BinaryVRRc<"vnc", 0xE769, null_frag, v128any, v128any>;
391
392 // Average.
Ulrich Weigand6e31ab32016-10-19 13:03:18 +0000393 def VAVG : BinaryVRRcGeneric<"vavg", 0xE7F2>;
Ulrich Weigandc1708b22015-05-05 19:31:09 +0000394 def VAVGB : BinaryVRRc<"vavgb", 0xE7F2, int_s390_vavgb, v128b, v128b, 0>;
395 def VAVGH : BinaryVRRc<"vavgh", 0xE7F2, int_s390_vavgh, v128h, v128h, 1>;
396 def VAVGF : BinaryVRRc<"vavgf", 0xE7F2, int_s390_vavgf, v128f, v128f, 2>;
397 def VAVGG : BinaryVRRc<"vavgg", 0xE7F2, int_s390_vavgg, v128g, v128g, 3>;
Ulrich Weiganda8b04e12015-05-05 19:23:40 +0000398
399 // Average logical.
Ulrich Weigand6e31ab32016-10-19 13:03:18 +0000400 def VAVGL : BinaryVRRcGeneric<"vavgl", 0xE7F0>;
Ulrich Weigandc1708b22015-05-05 19:31:09 +0000401 def VAVGLB : BinaryVRRc<"vavglb", 0xE7F0, int_s390_vavglb, v128b, v128b, 0>;
402 def VAVGLH : BinaryVRRc<"vavglh", 0xE7F0, int_s390_vavglh, v128h, v128h, 1>;
403 def VAVGLF : BinaryVRRc<"vavglf", 0xE7F0, int_s390_vavglf, v128f, v128f, 2>;
404 def VAVGLG : BinaryVRRc<"vavglg", 0xE7F0, int_s390_vavglg, v128g, v128g, 3>;
Ulrich Weiganda8b04e12015-05-05 19:23:40 +0000405
406 // Checksum.
Ulrich Weigandc1708b22015-05-05 19:31:09 +0000407 def VCKSM : BinaryVRRc<"vcksm", 0xE766, int_s390_vcksm, v128f, v128f>;
Ulrich Weiganda8b04e12015-05-05 19:23:40 +0000408
409 // Count leading zeros.
Ulrich Weigand6e31ab32016-10-19 13:03:18 +0000410 def VCLZ : UnaryVRRaGeneric<"vclz", 0xE753>;
Ulrich Weigandce4c1092015-05-05 19:25:42 +0000411 def VCLZB : UnaryVRRa<"vclzb", 0xE753, ctlz, v128b, v128b, 0>;
412 def VCLZH : UnaryVRRa<"vclzh", 0xE753, ctlz, v128h, v128h, 1>;
413 def VCLZF : UnaryVRRa<"vclzf", 0xE753, ctlz, v128f, v128f, 2>;
414 def VCLZG : UnaryVRRa<"vclzg", 0xE753, ctlz, v128g, v128g, 3>;
Ulrich Weiganda8b04e12015-05-05 19:23:40 +0000415
416 // Count trailing zeros.
Jonas Paulsson8010b632016-10-20 08:27:16 +0000417 def VCTZ : UnaryVRRaGeneric<"vctz", 0xE752>;
Ulrich Weigandce4c1092015-05-05 19:25:42 +0000418 def VCTZB : UnaryVRRa<"vctzb", 0xE752, cttz, v128b, v128b, 0>;
419 def VCTZH : UnaryVRRa<"vctzh", 0xE752, cttz, v128h, v128h, 1>;
420 def VCTZF : UnaryVRRa<"vctzf", 0xE752, cttz, v128f, v128f, 2>;
421 def VCTZG : UnaryVRRa<"vctzg", 0xE752, cttz, v128g, v128g, 3>;
Ulrich Weiganda8b04e12015-05-05 19:23:40 +0000422
423 // Exclusive or.
424 def VX : BinaryVRRc<"vx", 0xE76D, null_frag, v128any, v128any>;
425
426 // Galois field multiply sum.
Ulrich Weigand6e31ab32016-10-19 13:03:18 +0000427 def VGFM : BinaryVRRcGeneric<"vgfm", 0xE7B4>;
Ulrich Weigandc1708b22015-05-05 19:31:09 +0000428 def VGFMB : BinaryVRRc<"vgfmb", 0xE7B4, int_s390_vgfmb, v128h, v128b, 0>;
429 def VGFMH : BinaryVRRc<"vgfmh", 0xE7B4, int_s390_vgfmh, v128f, v128h, 1>;
430 def VGFMF : BinaryVRRc<"vgfmf", 0xE7B4, int_s390_vgfmf, v128g, v128f, 2>;
431 def VGFMG : BinaryVRRc<"vgfmg", 0xE7B4, int_s390_vgfmg, v128q, v128g, 3>;
Ulrich Weiganda8b04e12015-05-05 19:23:40 +0000432
433 // Galois field multiply sum and accumulate.
Ulrich Weigand6e31ab32016-10-19 13:03:18 +0000434 def VGFMA : TernaryVRRdGeneric<"vgfma", 0xE7BC>;
Ulrich Weigandc1708b22015-05-05 19:31:09 +0000435 def VGFMAB : TernaryVRRd<"vgfmab", 0xE7BC, int_s390_vgfmab, v128h, v128b, 0>;
436 def VGFMAH : TernaryVRRd<"vgfmah", 0xE7BC, int_s390_vgfmah, v128f, v128h, 1>;
437 def VGFMAF : TernaryVRRd<"vgfmaf", 0xE7BC, int_s390_vgfmaf, v128g, v128f, 2>;
438 def VGFMAG : TernaryVRRd<"vgfmag", 0xE7BC, int_s390_vgfmag, v128q, v128g, 3>;
Ulrich Weiganda8b04e12015-05-05 19:23:40 +0000439
440 // Load complement.
Ulrich Weigand6e31ab32016-10-19 13:03:18 +0000441 def VLC : UnaryVRRaGeneric<"vlc", 0xE7DE>;
Ulrich Weigandce4c1092015-05-05 19:25:42 +0000442 def VLCB : UnaryVRRa<"vlcb", 0xE7DE, z_vneg, v128b, v128b, 0>;
443 def VLCH : UnaryVRRa<"vlch", 0xE7DE, z_vneg, v128h, v128h, 1>;
444 def VLCF : UnaryVRRa<"vlcf", 0xE7DE, z_vneg, v128f, v128f, 2>;
445 def VLCG : UnaryVRRa<"vlcg", 0xE7DE, z_vneg, v128g, v128g, 3>;
Ulrich Weiganda8b04e12015-05-05 19:23:40 +0000446
447 // Load positive.
Ulrich Weigand6e31ab32016-10-19 13:03:18 +0000448 def VLP : UnaryVRRaGeneric<"vlp", 0xE7DF>;
Ulrich Weigandce4c1092015-05-05 19:25:42 +0000449 def VLPB : UnaryVRRa<"vlpb", 0xE7DF, z_viabs8, v128b, v128b, 0>;
450 def VLPH : UnaryVRRa<"vlph", 0xE7DF, z_viabs16, v128h, v128h, 1>;
451 def VLPF : UnaryVRRa<"vlpf", 0xE7DF, z_viabs32, v128f, v128f, 2>;
452 def VLPG : UnaryVRRa<"vlpg", 0xE7DF, z_viabs64, v128g, v128g, 3>;
Ulrich Weiganda8b04e12015-05-05 19:23:40 +0000453
454 // Maximum.
Ulrich Weigand6e31ab32016-10-19 13:03:18 +0000455 def VMX : BinaryVRRcGeneric<"vmx", 0xE7FF>;
Ulrich Weiganda8b04e12015-05-05 19:23:40 +0000456 def VMXB : BinaryVRRc<"vmxb", 0xE7FF, null_frag, v128b, v128b, 0>;
457 def VMXH : BinaryVRRc<"vmxh", 0xE7FF, null_frag, v128h, v128h, 1>;
458 def VMXF : BinaryVRRc<"vmxf", 0xE7FF, null_frag, v128f, v128f, 2>;
459 def VMXG : BinaryVRRc<"vmxg", 0xE7FF, null_frag, v128g, v128g, 3>;
460
461 // Maximum logical.
Ulrich Weigand6e31ab32016-10-19 13:03:18 +0000462 def VMXL : BinaryVRRcGeneric<"vmxl", 0xE7FD>;
Ulrich Weiganda8b04e12015-05-05 19:23:40 +0000463 def VMXLB : BinaryVRRc<"vmxlb", 0xE7FD, null_frag, v128b, v128b, 0>;
464 def VMXLH : BinaryVRRc<"vmxlh", 0xE7FD, null_frag, v128h, v128h, 1>;
465 def VMXLF : BinaryVRRc<"vmxlf", 0xE7FD, null_frag, v128f, v128f, 2>;
466 def VMXLG : BinaryVRRc<"vmxlg", 0xE7FD, null_frag, v128g, v128g, 3>;
467
468 // Minimum.
Ulrich Weigand6e31ab32016-10-19 13:03:18 +0000469 def VMN : BinaryVRRcGeneric<"vmn", 0xE7FE>;
Ulrich Weiganda8b04e12015-05-05 19:23:40 +0000470 def VMNB : BinaryVRRc<"vmnb", 0xE7FE, null_frag, v128b, v128b, 0>;
471 def VMNH : BinaryVRRc<"vmnh", 0xE7FE, null_frag, v128h, v128h, 1>;
472 def VMNF : BinaryVRRc<"vmnf", 0xE7FE, null_frag, v128f, v128f, 2>;
473 def VMNG : BinaryVRRc<"vmng", 0xE7FE, null_frag, v128g, v128g, 3>;
474
475 // Minimum logical.
Ulrich Weigand6e31ab32016-10-19 13:03:18 +0000476 def VMNL : BinaryVRRcGeneric<"vmnl", 0xE7FC>;
Ulrich Weiganda8b04e12015-05-05 19:23:40 +0000477 def VMNLB : BinaryVRRc<"vmnlb", 0xE7FC, null_frag, v128b, v128b, 0>;
478 def VMNLH : BinaryVRRc<"vmnlh", 0xE7FC, null_frag, v128h, v128h, 1>;
479 def VMNLF : BinaryVRRc<"vmnlf", 0xE7FC, null_frag, v128f, v128f, 2>;
480 def VMNLG : BinaryVRRc<"vmnlg", 0xE7FC, null_frag, v128g, v128g, 3>;
481
482 // Multiply and add low.
Ulrich Weigand6e31ab32016-10-19 13:03:18 +0000483 def VMAL : TernaryVRRdGeneric<"vmal", 0xE7AA>;
Ulrich Weigandce4c1092015-05-05 19:25:42 +0000484 def VMALB : TernaryVRRd<"vmalb", 0xE7AA, z_muladd, v128b, v128b, 0>;
485 def VMALHW : TernaryVRRd<"vmalhw", 0xE7AA, z_muladd, v128h, v128h, 1>;
486 def VMALF : TernaryVRRd<"vmalf", 0xE7AA, z_muladd, v128f, v128f, 2>;
Ulrich Weiganda8b04e12015-05-05 19:23:40 +0000487
488 // Multiply and add high.
Ulrich Weigand6e31ab32016-10-19 13:03:18 +0000489 def VMAH : TernaryVRRdGeneric<"vmah", 0xE7AB>;
Ulrich Weigandc1708b22015-05-05 19:31:09 +0000490 def VMAHB : TernaryVRRd<"vmahb", 0xE7AB, int_s390_vmahb, v128b, v128b, 0>;
491 def VMAHH : TernaryVRRd<"vmahh", 0xE7AB, int_s390_vmahh, v128h, v128h, 1>;
492 def VMAHF : TernaryVRRd<"vmahf", 0xE7AB, int_s390_vmahf, v128f, v128f, 2>;
Ulrich Weiganda8b04e12015-05-05 19:23:40 +0000493
494 // Multiply and add logical high.
Ulrich Weigand6e31ab32016-10-19 13:03:18 +0000495 def VMALH : TernaryVRRdGeneric<"vmalh", 0xE7A9>;
Ulrich Weigandc1708b22015-05-05 19:31:09 +0000496 def VMALHB : TernaryVRRd<"vmalhb", 0xE7A9, int_s390_vmalhb, v128b, v128b, 0>;
497 def VMALHH : TernaryVRRd<"vmalhh", 0xE7A9, int_s390_vmalhh, v128h, v128h, 1>;
498 def VMALHF : TernaryVRRd<"vmalhf", 0xE7A9, int_s390_vmalhf, v128f, v128f, 2>;
Ulrich Weiganda8b04e12015-05-05 19:23:40 +0000499
500 // Multiply and add even.
Ulrich Weigand6e31ab32016-10-19 13:03:18 +0000501 def VMAE : TernaryVRRdGeneric<"vmae", 0xE7AE>;
Ulrich Weigandc1708b22015-05-05 19:31:09 +0000502 def VMAEB : TernaryVRRd<"vmaeb", 0xE7AE, int_s390_vmaeb, v128h, v128b, 0>;
503 def VMAEH : TernaryVRRd<"vmaeh", 0xE7AE, int_s390_vmaeh, v128f, v128h, 1>;
504 def VMAEF : TernaryVRRd<"vmaef", 0xE7AE, int_s390_vmaef, v128g, v128f, 2>;
Ulrich Weiganda8b04e12015-05-05 19:23:40 +0000505
506 // Multiply and add logical even.
Ulrich Weigand6e31ab32016-10-19 13:03:18 +0000507 def VMALE : TernaryVRRdGeneric<"vmale", 0xE7AC>;
Ulrich Weigandc1708b22015-05-05 19:31:09 +0000508 def VMALEB : TernaryVRRd<"vmaleb", 0xE7AC, int_s390_vmaleb, v128h, v128b, 0>;
509 def VMALEH : TernaryVRRd<"vmaleh", 0xE7AC, int_s390_vmaleh, v128f, v128h, 1>;
510 def VMALEF : TernaryVRRd<"vmalef", 0xE7AC, int_s390_vmalef, v128g, v128f, 2>;
Ulrich Weiganda8b04e12015-05-05 19:23:40 +0000511
512 // Multiply and add odd.
Ulrich Weigand6e31ab32016-10-19 13:03:18 +0000513 def VMAO : TernaryVRRdGeneric<"vmao", 0xE7AF>;
Ulrich Weigandc1708b22015-05-05 19:31:09 +0000514 def VMAOB : TernaryVRRd<"vmaob", 0xE7AF, int_s390_vmaob, v128h, v128b, 0>;
515 def VMAOH : TernaryVRRd<"vmaoh", 0xE7AF, int_s390_vmaoh, v128f, v128h, 1>;
516 def VMAOF : TernaryVRRd<"vmaof", 0xE7AF, int_s390_vmaof, v128g, v128f, 2>;
Ulrich Weiganda8b04e12015-05-05 19:23:40 +0000517
518 // Multiply and add logical odd.
Ulrich Weigand6e31ab32016-10-19 13:03:18 +0000519 def VMALO : TernaryVRRdGeneric<"vmalo", 0xE7AD>;
Ulrich Weigandc1708b22015-05-05 19:31:09 +0000520 def VMALOB : TernaryVRRd<"vmalob", 0xE7AD, int_s390_vmalob, v128h, v128b, 0>;
521 def VMALOH : TernaryVRRd<"vmaloh", 0xE7AD, int_s390_vmaloh, v128f, v128h, 1>;
522 def VMALOF : TernaryVRRd<"vmalof", 0xE7AD, int_s390_vmalof, v128g, v128f, 2>;
Ulrich Weiganda8b04e12015-05-05 19:23:40 +0000523
524 // Multiply high.
Ulrich Weigand6e31ab32016-10-19 13:03:18 +0000525 def VMH : BinaryVRRcGeneric<"vmh", 0xE7A3>;
Ulrich Weigandc1708b22015-05-05 19:31:09 +0000526 def VMHB : BinaryVRRc<"vmhb", 0xE7A3, int_s390_vmhb, v128b, v128b, 0>;
527 def VMHH : BinaryVRRc<"vmhh", 0xE7A3, int_s390_vmhh, v128h, v128h, 1>;
528 def VMHF : BinaryVRRc<"vmhf", 0xE7A3, int_s390_vmhf, v128f, v128f, 2>;
Ulrich Weiganda8b04e12015-05-05 19:23:40 +0000529
530 // Multiply logical high.
Ulrich Weigand6e31ab32016-10-19 13:03:18 +0000531 def VMLH : BinaryVRRcGeneric<"vmlh", 0xE7A1>;
Ulrich Weigandc1708b22015-05-05 19:31:09 +0000532 def VMLHB : BinaryVRRc<"vmlhb", 0xE7A1, int_s390_vmlhb, v128b, v128b, 0>;
533 def VMLHH : BinaryVRRc<"vmlhh", 0xE7A1, int_s390_vmlhh, v128h, v128h, 1>;
534 def VMLHF : BinaryVRRc<"vmlhf", 0xE7A1, int_s390_vmlhf, v128f, v128f, 2>;
Ulrich Weiganda8b04e12015-05-05 19:23:40 +0000535
536 // Multiply low.
Ulrich Weigand6e31ab32016-10-19 13:03:18 +0000537 def VML : BinaryVRRcGeneric<"vml", 0xE7A2>;
Ulrich Weigandce4c1092015-05-05 19:25:42 +0000538 def VMLB : BinaryVRRc<"vmlb", 0xE7A2, mul, v128b, v128b, 0>;
539 def VMLHW : BinaryVRRc<"vmlhw", 0xE7A2, mul, v128h, v128h, 1>;
540 def VMLF : BinaryVRRc<"vmlf", 0xE7A2, mul, v128f, v128f, 2>;
Ulrich Weiganda8b04e12015-05-05 19:23:40 +0000541
542 // Multiply even.
Ulrich Weigand6e31ab32016-10-19 13:03:18 +0000543 def VME : BinaryVRRcGeneric<"vme", 0xE7A6>;
Ulrich Weigandc1708b22015-05-05 19:31:09 +0000544 def VMEB : BinaryVRRc<"vmeb", 0xE7A6, int_s390_vmeb, v128h, v128b, 0>;
545 def VMEH : BinaryVRRc<"vmeh", 0xE7A6, int_s390_vmeh, v128f, v128h, 1>;
546 def VMEF : BinaryVRRc<"vmef", 0xE7A6, int_s390_vmef, v128g, v128f, 2>;
Ulrich Weiganda8b04e12015-05-05 19:23:40 +0000547
548 // Multiply logical even.
Ulrich Weigand6e31ab32016-10-19 13:03:18 +0000549 def VMLE : BinaryVRRcGeneric<"vmle", 0xE7A4>;
Ulrich Weigandc1708b22015-05-05 19:31:09 +0000550 def VMLEB : BinaryVRRc<"vmleb", 0xE7A4, int_s390_vmleb, v128h, v128b, 0>;
551 def VMLEH : BinaryVRRc<"vmleh", 0xE7A4, int_s390_vmleh, v128f, v128h, 1>;
552 def VMLEF : BinaryVRRc<"vmlef", 0xE7A4, int_s390_vmlef, v128g, v128f, 2>;
Ulrich Weiganda8b04e12015-05-05 19:23:40 +0000553
554 // Multiply odd.
Ulrich Weigand6e31ab32016-10-19 13:03:18 +0000555 def VMO : BinaryVRRcGeneric<"vmo", 0xE7A7>;
Ulrich Weigandc1708b22015-05-05 19:31:09 +0000556 def VMOB : BinaryVRRc<"vmob", 0xE7A7, int_s390_vmob, v128h, v128b, 0>;
557 def VMOH : BinaryVRRc<"vmoh", 0xE7A7, int_s390_vmoh, v128f, v128h, 1>;
558 def VMOF : BinaryVRRc<"vmof", 0xE7A7, int_s390_vmof, v128g, v128f, 2>;
Ulrich Weiganda8b04e12015-05-05 19:23:40 +0000559
560 // Multiply logical odd.
Ulrich Weigand6e31ab32016-10-19 13:03:18 +0000561 def VMLO : BinaryVRRcGeneric<"vmlo", 0xE7A5>;
Ulrich Weigandc1708b22015-05-05 19:31:09 +0000562 def VMLOB : BinaryVRRc<"vmlob", 0xE7A5, int_s390_vmlob, v128h, v128b, 0>;
563 def VMLOH : BinaryVRRc<"vmloh", 0xE7A5, int_s390_vmloh, v128f, v128h, 1>;
564 def VMLOF : BinaryVRRc<"vmlof", 0xE7A5, int_s390_vmlof, v128g, v128f, 2>;
Ulrich Weiganda8b04e12015-05-05 19:23:40 +0000565
566 // Nor.
567 def VNO : BinaryVRRc<"vno", 0xE76B, null_frag, v128any, v128any>;
Ulrich Weigand6e31ab32016-10-19 13:03:18 +0000568 def : InstAlias<"vnot\t$V1, $V2", (VNO VR128:$V1, VR128:$V2, VR128:$V2), 0>;
Ulrich Weiganda8b04e12015-05-05 19:23:40 +0000569
570 // Or.
571 def VO : BinaryVRRc<"vo", 0xE76A, null_frag, v128any, v128any>;
572
573 // Population count.
Ulrich Weigand6e31ab32016-10-19 13:03:18 +0000574 def VPOPCT : UnaryVRRaGeneric<"vpopct", 0xE750>;
Ulrich Weigandce4c1092015-05-05 19:25:42 +0000575 def : Pat<(v16i8 (z_popcnt VR128:$x)), (VPOPCT VR128:$x, 0)>;
Ulrich Weiganda8b04e12015-05-05 19:23:40 +0000576
577 // Element rotate left logical (with vector shift amount).
Ulrich Weigand6e31ab32016-10-19 13:03:18 +0000578 def VERLLV : BinaryVRRcGeneric<"verllv", 0xE773>;
Ulrich Weigandc1708b22015-05-05 19:31:09 +0000579 def VERLLVB : BinaryVRRc<"verllvb", 0xE773, int_s390_verllvb,
580 v128b, v128b, 0>;
581 def VERLLVH : BinaryVRRc<"verllvh", 0xE773, int_s390_verllvh,
582 v128h, v128h, 1>;
583 def VERLLVF : BinaryVRRc<"verllvf", 0xE773, int_s390_verllvf,
584 v128f, v128f, 2>;
585 def VERLLVG : BinaryVRRc<"verllvg", 0xE773, int_s390_verllvg,
586 v128g, v128g, 3>;
Ulrich Weiganda8b04e12015-05-05 19:23:40 +0000587
588 // Element rotate left logical (with scalar shift amount).
Ulrich Weigand6e31ab32016-10-19 13:03:18 +0000589 def VERLL : BinaryVRSaGeneric<"verll", 0xE733>;
Ulrich Weigandc1708b22015-05-05 19:31:09 +0000590 def VERLLB : BinaryVRSa<"verllb", 0xE733, int_s390_verllb, v128b, v128b, 0>;
591 def VERLLH : BinaryVRSa<"verllh", 0xE733, int_s390_verllh, v128h, v128h, 1>;
592 def VERLLF : BinaryVRSa<"verllf", 0xE733, int_s390_verllf, v128f, v128f, 2>;
593 def VERLLG : BinaryVRSa<"verllg", 0xE733, int_s390_verllg, v128g, v128g, 3>;
Ulrich Weiganda8b04e12015-05-05 19:23:40 +0000594
595 // Element rotate and insert under mask.
Ulrich Weigand6e31ab32016-10-19 13:03:18 +0000596 def VERIM : QuaternaryVRIdGeneric<"verim", 0xE772>;
Ulrich Weigandc1708b22015-05-05 19:31:09 +0000597 def VERIMB : QuaternaryVRId<"verimb", 0xE772, int_s390_verimb, v128b, v128b, 0>;
598 def VERIMH : QuaternaryVRId<"verimh", 0xE772, int_s390_verimh, v128h, v128h, 1>;
599 def VERIMF : QuaternaryVRId<"verimf", 0xE772, int_s390_verimf, v128f, v128f, 2>;
600 def VERIMG : QuaternaryVRId<"verimg", 0xE772, int_s390_verimg, v128g, v128g, 3>;
Ulrich Weiganda8b04e12015-05-05 19:23:40 +0000601
602 // Element shift left (with vector shift amount).
Ulrich Weigand6e31ab32016-10-19 13:03:18 +0000603 def VESLV : BinaryVRRcGeneric<"veslv", 0xE770>;
Ulrich Weigandce4c1092015-05-05 19:25:42 +0000604 def VESLVB : BinaryVRRc<"veslvb", 0xE770, z_vshl, v128b, v128b, 0>;
605 def VESLVH : BinaryVRRc<"veslvh", 0xE770, z_vshl, v128h, v128h, 1>;
606 def VESLVF : BinaryVRRc<"veslvf", 0xE770, z_vshl, v128f, v128f, 2>;
607 def VESLVG : BinaryVRRc<"veslvg", 0xE770, z_vshl, v128g, v128g, 3>;
Ulrich Weiganda8b04e12015-05-05 19:23:40 +0000608
609 // Element shift left (with scalar shift amount).
Ulrich Weigand6e31ab32016-10-19 13:03:18 +0000610 def VESL : BinaryVRSaGeneric<"vesl", 0xE730>;
Ulrich Weigandce4c1092015-05-05 19:25:42 +0000611 def VESLB : BinaryVRSa<"veslb", 0xE730, z_vshl_by_scalar, v128b, v128b, 0>;
612 def VESLH : BinaryVRSa<"veslh", 0xE730, z_vshl_by_scalar, v128h, v128h, 1>;
613 def VESLF : BinaryVRSa<"veslf", 0xE730, z_vshl_by_scalar, v128f, v128f, 2>;
614 def VESLG : BinaryVRSa<"veslg", 0xE730, z_vshl_by_scalar, v128g, v128g, 3>;
Ulrich Weiganda8b04e12015-05-05 19:23:40 +0000615
616 // Element shift right arithmetic (with vector shift amount).
Ulrich Weigand6e31ab32016-10-19 13:03:18 +0000617 def VESRAV : BinaryVRRcGeneric<"vesrav", 0xE77A>;
Ulrich Weigandce4c1092015-05-05 19:25:42 +0000618 def VESRAVB : BinaryVRRc<"vesravb", 0xE77A, z_vsra, v128b, v128b, 0>;
619 def VESRAVH : BinaryVRRc<"vesravh", 0xE77A, z_vsra, v128h, v128h, 1>;
620 def VESRAVF : BinaryVRRc<"vesravf", 0xE77A, z_vsra, v128f, v128f, 2>;
621 def VESRAVG : BinaryVRRc<"vesravg", 0xE77A, z_vsra, v128g, v128g, 3>;
Ulrich Weiganda8b04e12015-05-05 19:23:40 +0000622
623 // Element shift right arithmetic (with scalar shift amount).
Ulrich Weigand6e31ab32016-10-19 13:03:18 +0000624 def VESRA : BinaryVRSaGeneric<"vesra", 0xE73A>;
Ulrich Weigandce4c1092015-05-05 19:25:42 +0000625 def VESRAB : BinaryVRSa<"vesrab", 0xE73A, z_vsra_by_scalar, v128b, v128b, 0>;
626 def VESRAH : BinaryVRSa<"vesrah", 0xE73A, z_vsra_by_scalar, v128h, v128h, 1>;
627 def VESRAF : BinaryVRSa<"vesraf", 0xE73A, z_vsra_by_scalar, v128f, v128f, 2>;
628 def VESRAG : BinaryVRSa<"vesrag", 0xE73A, z_vsra_by_scalar, v128g, v128g, 3>;
Ulrich Weiganda8b04e12015-05-05 19:23:40 +0000629
630 // Element shift right logical (with vector shift amount).
Ulrich Weigand6e31ab32016-10-19 13:03:18 +0000631 def VESRLV : BinaryVRRcGeneric<"vesrlv", 0xE778>;
Ulrich Weigandce4c1092015-05-05 19:25:42 +0000632 def VESRLVB : BinaryVRRc<"vesrlvb", 0xE778, z_vsrl, v128b, v128b, 0>;
633 def VESRLVH : BinaryVRRc<"vesrlvh", 0xE778, z_vsrl, v128h, v128h, 1>;
634 def VESRLVF : BinaryVRRc<"vesrlvf", 0xE778, z_vsrl, v128f, v128f, 2>;
635 def VESRLVG : BinaryVRRc<"vesrlvg", 0xE778, z_vsrl, v128g, v128g, 3>;
Ulrich Weiganda8b04e12015-05-05 19:23:40 +0000636
637 // Element shift right logical (with scalar shift amount).
Ulrich Weigand6e31ab32016-10-19 13:03:18 +0000638 def VESRL : BinaryVRSaGeneric<"vesrl", 0xE738>;
Ulrich Weigandce4c1092015-05-05 19:25:42 +0000639 def VESRLB : BinaryVRSa<"vesrlb", 0xE738, z_vsrl_by_scalar, v128b, v128b, 0>;
640 def VESRLH : BinaryVRSa<"vesrlh", 0xE738, z_vsrl_by_scalar, v128h, v128h, 1>;
641 def VESRLF : BinaryVRSa<"vesrlf", 0xE738, z_vsrl_by_scalar, v128f, v128f, 2>;
642 def VESRLG : BinaryVRSa<"vesrlg", 0xE738, z_vsrl_by_scalar, v128g, v128g, 3>;
Ulrich Weiganda8b04e12015-05-05 19:23:40 +0000643
644 // Shift left.
Ulrich Weigandc1708b22015-05-05 19:31:09 +0000645 def VSL : BinaryVRRc<"vsl", 0xE774, int_s390_vsl, v128b, v128b>;
Ulrich Weiganda8b04e12015-05-05 19:23:40 +0000646
647 // Shift left by byte.
Ulrich Weigandc1708b22015-05-05 19:31:09 +0000648 def VSLB : BinaryVRRc<"vslb", 0xE775, int_s390_vslb, v128b, v128b>;
Ulrich Weiganda8b04e12015-05-05 19:23:40 +0000649
650 // Shift left double by byte.
Ulrich Weigandce4c1092015-05-05 19:25:42 +0000651 def VSLDB : TernaryVRId<"vsldb", 0xE777, z_shl_double, v128b, v128b, 0>;
Ulrich Weigandc1708b22015-05-05 19:31:09 +0000652 def : Pat<(int_s390_vsldb VR128:$x, VR128:$y, imm32zx8:$z),
653 (VSLDB VR128:$x, VR128:$y, imm32zx8:$z)>;
Ulrich Weiganda8b04e12015-05-05 19:23:40 +0000654
655 // Shift right arithmetic.
Ulrich Weigandc1708b22015-05-05 19:31:09 +0000656 def VSRA : BinaryVRRc<"vsra", 0xE77E, int_s390_vsra, v128b, v128b>;
Ulrich Weiganda8b04e12015-05-05 19:23:40 +0000657
658 // Shift right arithmetic by byte.
Ulrich Weigandc1708b22015-05-05 19:31:09 +0000659 def VSRAB : BinaryVRRc<"vsrab", 0xE77F, int_s390_vsrab, v128b, v128b>;
Ulrich Weiganda8b04e12015-05-05 19:23:40 +0000660
661 // Shift right logical.
Ulrich Weigandc1708b22015-05-05 19:31:09 +0000662 def VSRL : BinaryVRRc<"vsrl", 0xE77C, int_s390_vsrl, v128b, v128b>;
Ulrich Weiganda8b04e12015-05-05 19:23:40 +0000663
664 // Shift right logical by byte.
Ulrich Weigandc1708b22015-05-05 19:31:09 +0000665 def VSRLB : BinaryVRRc<"vsrlb", 0xE77D, int_s390_vsrlb, v128b, v128b>;
Ulrich Weiganda8b04e12015-05-05 19:23:40 +0000666
667 // Subtract.
Ulrich Weigand6e31ab32016-10-19 13:03:18 +0000668 def VS : BinaryVRRcGeneric<"vs", 0xE7F7>;
Ulrich Weigandce4c1092015-05-05 19:25:42 +0000669 def VSB : BinaryVRRc<"vsb", 0xE7F7, sub, v128b, v128b, 0>;
670 def VSH : BinaryVRRc<"vsh", 0xE7F7, sub, v128h, v128h, 1>;
671 def VSF : BinaryVRRc<"vsf", 0xE7F7, sub, v128f, v128f, 2>;
672 def VSG : BinaryVRRc<"vsg", 0xE7F7, sub, v128g, v128g, 3>;
Ulrich Weigandc1708b22015-05-05 19:31:09 +0000673 def VSQ : BinaryVRRc<"vsq", 0xE7F7, int_s390_vsq, v128q, v128q, 4>;
Ulrich Weiganda8b04e12015-05-05 19:23:40 +0000674
675 // Subtract compute borrow indication.
Ulrich Weigand6e31ab32016-10-19 13:03:18 +0000676 def VSCBI : BinaryVRRcGeneric<"vscbi", 0xE7F5>;
Ulrich Weigandc1708b22015-05-05 19:31:09 +0000677 def VSCBIB : BinaryVRRc<"vscbib", 0xE7F5, int_s390_vscbib, v128b, v128b, 0>;
678 def VSCBIH : BinaryVRRc<"vscbih", 0xE7F5, int_s390_vscbih, v128h, v128h, 1>;
679 def VSCBIF : BinaryVRRc<"vscbif", 0xE7F5, int_s390_vscbif, v128f, v128f, 2>;
680 def VSCBIG : BinaryVRRc<"vscbig", 0xE7F5, int_s390_vscbig, v128g, v128g, 3>;
681 def VSCBIQ : BinaryVRRc<"vscbiq", 0xE7F5, int_s390_vscbiq, v128q, v128q, 4>;
Ulrich Weiganda8b04e12015-05-05 19:23:40 +0000682
683 // Subtract with borrow indication.
Ulrich Weigand6e31ab32016-10-19 13:03:18 +0000684 def VSBI : TernaryVRRdGeneric<"vsbi", 0xE7BF>;
Ulrich Weigandc1708b22015-05-05 19:31:09 +0000685 def VSBIQ : TernaryVRRd<"vsbiq", 0xE7BF, int_s390_vsbiq, v128q, v128q, 4>;
Ulrich Weiganda8b04e12015-05-05 19:23:40 +0000686
687 // Subtract with borrow compute borrow indication.
Ulrich Weigand6e31ab32016-10-19 13:03:18 +0000688 def VSBCBI : TernaryVRRdGeneric<"vsbcbi", 0xE7BD>;
Ulrich Weigandc1708b22015-05-05 19:31:09 +0000689 def VSBCBIQ : TernaryVRRd<"vsbcbiq", 0xE7BD, int_s390_vsbcbiq,
690 v128q, v128q, 4>;
Ulrich Weiganda8b04e12015-05-05 19:23:40 +0000691
692 // Sum across doubleword.
Ulrich Weigand6e31ab32016-10-19 13:03:18 +0000693 def VSUMG : BinaryVRRcGeneric<"vsumg", 0xE765>;
Ulrich Weigandce4c1092015-05-05 19:25:42 +0000694 def VSUMGH : BinaryVRRc<"vsumgh", 0xE765, z_vsum, v128g, v128h, 1>;
695 def VSUMGF : BinaryVRRc<"vsumgf", 0xE765, z_vsum, v128g, v128f, 2>;
Ulrich Weiganda8b04e12015-05-05 19:23:40 +0000696
697 // Sum across quadword.
Ulrich Weigand6e31ab32016-10-19 13:03:18 +0000698 def VSUMQ : BinaryVRRcGeneric<"vsumq", 0xE767>;
Ulrich Weigandce4c1092015-05-05 19:25:42 +0000699 def VSUMQF : BinaryVRRc<"vsumqf", 0xE767, z_vsum, v128q, v128f, 2>;
700 def VSUMQG : BinaryVRRc<"vsumqg", 0xE767, z_vsum, v128q, v128g, 3>;
Ulrich Weiganda8b04e12015-05-05 19:23:40 +0000701
702 // Sum across word.
Ulrich Weigand6e31ab32016-10-19 13:03:18 +0000703 def VSUM : BinaryVRRcGeneric<"vsum", 0xE764>;
Ulrich Weigandce4c1092015-05-05 19:25:42 +0000704 def VSUMB : BinaryVRRc<"vsumb", 0xE764, z_vsum, v128f, v128b, 0>;
705 def VSUMH : BinaryVRRc<"vsumh", 0xE764, z_vsum, v128f, v128h, 1>;
Ulrich Weiganda8b04e12015-05-05 19:23:40 +0000706}
707
Ulrich Weigandce4c1092015-05-05 19:25:42 +0000708// Instantiate the bitwise ops for type TYPE.
709multiclass BitwiseVectorOps<ValueType type> {
710 let Predicates = [FeatureVector] in {
711 def : Pat<(type (and VR128:$x, VR128:$y)), (VN VR128:$x, VR128:$y)>;
712 def : Pat<(type (and VR128:$x, (z_vnot VR128:$y))),
713 (VNC VR128:$x, VR128:$y)>;
714 def : Pat<(type (or VR128:$x, VR128:$y)), (VO VR128:$x, VR128:$y)>;
715 def : Pat<(type (xor VR128:$x, VR128:$y)), (VX VR128:$x, VR128:$y)>;
716 def : Pat<(type (or (and VR128:$x, VR128:$z),
717 (and VR128:$y, (z_vnot VR128:$z)))),
718 (VSEL VR128:$x, VR128:$y, VR128:$z)>;
719 def : Pat<(type (z_vnot (or VR128:$x, VR128:$y))),
720 (VNO VR128:$x, VR128:$y)>;
721 def : Pat<(type (z_vnot VR128:$x)), (VNO VR128:$x, VR128:$x)>;
722 }
723}
724
725defm : BitwiseVectorOps<v16i8>;
726defm : BitwiseVectorOps<v8i16>;
727defm : BitwiseVectorOps<v4i32>;
728defm : BitwiseVectorOps<v2i64>;
729
730// Instantiate additional patterns for absolute-related expressions on
731// type TYPE. LC is the negate instruction for TYPE and LP is the absolute
732// instruction.
733multiclass IntegerAbsoluteVectorOps<ValueType type, Instruction lc,
734 Instruction lp, int shift> {
735 let Predicates = [FeatureVector] in {
736 def : Pat<(type (vselect (type (z_vicmph_zero VR128:$x)),
737 (z_vneg VR128:$x), VR128:$x)),
738 (lc (lp VR128:$x))>;
739 def : Pat<(type (vselect (type (z_vnot (z_vicmph_zero VR128:$x))),
740 VR128:$x, (z_vneg VR128:$x))),
741 (lc (lp VR128:$x))>;
742 def : Pat<(type (vselect (type (z_vicmpl_zero VR128:$x)),
743 VR128:$x, (z_vneg VR128:$x))),
744 (lc (lp VR128:$x))>;
745 def : Pat<(type (vselect (type (z_vnot (z_vicmpl_zero VR128:$x))),
746 (z_vneg VR128:$x), VR128:$x)),
747 (lc (lp VR128:$x))>;
748 def : Pat<(type (or (and (z_vsra_by_scalar VR128:$x, (i32 shift)),
749 (z_vneg VR128:$x)),
750 (and (z_vnot (z_vsra_by_scalar VR128:$x, (i32 shift))),
751 VR128:$x))),
752 (lp VR128:$x)>;
753 def : Pat<(type (or (and (z_vsra_by_scalar VR128:$x, (i32 shift)),
754 VR128:$x),
755 (and (z_vnot (z_vsra_by_scalar VR128:$x, (i32 shift))),
756 (z_vneg VR128:$x)))),
757 (lc (lp VR128:$x))>;
758 }
759}
760
761defm : IntegerAbsoluteVectorOps<v16i8, VLCB, VLPB, 7>;
762defm : IntegerAbsoluteVectorOps<v8i16, VLCH, VLPH, 15>;
763defm : IntegerAbsoluteVectorOps<v4i32, VLCF, VLPF, 31>;
764defm : IntegerAbsoluteVectorOps<v2i64, VLCG, VLPG, 63>;
765
766// Instantiate minimum- and maximum-related patterns for TYPE. CMPH is the
767// signed or unsigned "set if greater than" comparison instruction and
768// MIN and MAX are the associated minimum and maximum instructions.
769multiclass IntegerMinMaxVectorOps<ValueType type, SDPatternOperator cmph,
770 Instruction min, Instruction max> {
771 let Predicates = [FeatureVector] in {
772 def : Pat<(type (vselect (cmph VR128:$x, VR128:$y), VR128:$x, VR128:$y)),
773 (max VR128:$x, VR128:$y)>;
774 def : Pat<(type (vselect (cmph VR128:$x, VR128:$y), VR128:$y, VR128:$x)),
775 (min VR128:$x, VR128:$y)>;
776 def : Pat<(type (vselect (z_vnot (cmph VR128:$x, VR128:$y)),
777 VR128:$x, VR128:$y)),
778 (min VR128:$x, VR128:$y)>;
779 def : Pat<(type (vselect (z_vnot (cmph VR128:$x, VR128:$y)),
780 VR128:$y, VR128:$x)),
781 (max VR128:$x, VR128:$y)>;
782 }
783}
784
785// Signed min/max.
786defm : IntegerMinMaxVectorOps<v16i8, z_vicmph, VMNB, VMXB>;
787defm : IntegerMinMaxVectorOps<v8i16, z_vicmph, VMNH, VMXH>;
788defm : IntegerMinMaxVectorOps<v4i32, z_vicmph, VMNF, VMXF>;
789defm : IntegerMinMaxVectorOps<v2i64, z_vicmph, VMNG, VMXG>;
790
791// Unsigned min/max.
792defm : IntegerMinMaxVectorOps<v16i8, z_vicmphl, VMNLB, VMXLB>;
793defm : IntegerMinMaxVectorOps<v8i16, z_vicmphl, VMNLH, VMXLH>;
794defm : IntegerMinMaxVectorOps<v4i32, z_vicmphl, VMNLF, VMXLF>;
795defm : IntegerMinMaxVectorOps<v2i64, z_vicmphl, VMNLG, VMXLG>;
796
Ulrich Weiganda8b04e12015-05-05 19:23:40 +0000797//===----------------------------------------------------------------------===//
798// Integer comparison
799//===----------------------------------------------------------------------===//
800
801let Predicates = [FeatureVector] in {
802 // Element compare.
803 let Defs = [CC] in {
Ulrich Weigand6e31ab32016-10-19 13:03:18 +0000804 def VEC : CompareVRRaGeneric<"vec", 0xE7DB>;
Ulrich Weiganda8b04e12015-05-05 19:23:40 +0000805 def VECB : CompareVRRa<"vecb", 0xE7DB, null_frag, v128b, 0>;
806 def VECH : CompareVRRa<"vech", 0xE7DB, null_frag, v128h, 1>;
807 def VECF : CompareVRRa<"vecf", 0xE7DB, null_frag, v128f, 2>;
808 def VECG : CompareVRRa<"vecg", 0xE7DB, null_frag, v128g, 3>;
809 }
810
811 // Element compare logical.
812 let Defs = [CC] in {
Ulrich Weigand6e31ab32016-10-19 13:03:18 +0000813 def VECL : CompareVRRaGeneric<"vecl", 0xE7D9>;
Ulrich Weiganda8b04e12015-05-05 19:23:40 +0000814 def VECLB : CompareVRRa<"veclb", 0xE7D9, null_frag, v128b, 0>;
815 def VECLH : CompareVRRa<"veclh", 0xE7D9, null_frag, v128h, 1>;
816 def VECLF : CompareVRRa<"veclf", 0xE7D9, null_frag, v128f, 2>;
817 def VECLG : CompareVRRa<"veclg", 0xE7D9, null_frag, v128g, 3>;
818 }
819
820 // Compare equal.
Ulrich Weigand6e31ab32016-10-19 13:03:18 +0000821 def VCEQ : BinaryVRRbSPairGeneric<"vceq", 0xE7F8>;
Ulrich Weigandc1708b22015-05-05 19:31:09 +0000822 defm VCEQB : BinaryVRRbSPair<"vceqb", 0xE7F8, z_vicmpe, z_vicmpes,
Ulrich Weiganda8b04e12015-05-05 19:23:40 +0000823 v128b, v128b, 0>;
Ulrich Weigandc1708b22015-05-05 19:31:09 +0000824 defm VCEQH : BinaryVRRbSPair<"vceqh", 0xE7F8, z_vicmpe, z_vicmpes,
Ulrich Weiganda8b04e12015-05-05 19:23:40 +0000825 v128h, v128h, 1>;
Ulrich Weigandc1708b22015-05-05 19:31:09 +0000826 defm VCEQF : BinaryVRRbSPair<"vceqf", 0xE7F8, z_vicmpe, z_vicmpes,
Ulrich Weiganda8b04e12015-05-05 19:23:40 +0000827 v128f, v128f, 2>;
Ulrich Weigandc1708b22015-05-05 19:31:09 +0000828 defm VCEQG : BinaryVRRbSPair<"vceqg", 0xE7F8, z_vicmpe, z_vicmpes,
Ulrich Weiganda8b04e12015-05-05 19:23:40 +0000829 v128g, v128g, 3>;
830
831 // Compare high.
Ulrich Weigand6e31ab32016-10-19 13:03:18 +0000832 def VCH : BinaryVRRbSPairGeneric<"vch", 0xE7FB>;
Ulrich Weigandc1708b22015-05-05 19:31:09 +0000833 defm VCHB : BinaryVRRbSPair<"vchb", 0xE7FB, z_vicmph, z_vicmphs,
Ulrich Weiganda8b04e12015-05-05 19:23:40 +0000834 v128b, v128b, 0>;
Ulrich Weigandc1708b22015-05-05 19:31:09 +0000835 defm VCHH : BinaryVRRbSPair<"vchh", 0xE7FB, z_vicmph, z_vicmphs,
Ulrich Weiganda8b04e12015-05-05 19:23:40 +0000836 v128h, v128h, 1>;
Ulrich Weigandc1708b22015-05-05 19:31:09 +0000837 defm VCHF : BinaryVRRbSPair<"vchf", 0xE7FB, z_vicmph, z_vicmphs,
Ulrich Weiganda8b04e12015-05-05 19:23:40 +0000838 v128f, v128f, 2>;
Ulrich Weigandc1708b22015-05-05 19:31:09 +0000839 defm VCHG : BinaryVRRbSPair<"vchg", 0xE7FB, z_vicmph, z_vicmphs,
Ulrich Weiganda8b04e12015-05-05 19:23:40 +0000840 v128g, v128g, 3>;
841
842 // Compare high logical.
Ulrich Weigand6e31ab32016-10-19 13:03:18 +0000843 def VCHL : BinaryVRRbSPairGeneric<"vchl", 0xE7F9>;
Ulrich Weigandc1708b22015-05-05 19:31:09 +0000844 defm VCHLB : BinaryVRRbSPair<"vchlb", 0xE7F9, z_vicmphl, z_vicmphls,
Ulrich Weiganda8b04e12015-05-05 19:23:40 +0000845 v128b, v128b, 0>;
Ulrich Weigandc1708b22015-05-05 19:31:09 +0000846 defm VCHLH : BinaryVRRbSPair<"vchlh", 0xE7F9, z_vicmphl, z_vicmphls,
Ulrich Weiganda8b04e12015-05-05 19:23:40 +0000847 v128h, v128h, 1>;
Ulrich Weigandc1708b22015-05-05 19:31:09 +0000848 defm VCHLF : BinaryVRRbSPair<"vchlf", 0xE7F9, z_vicmphl, z_vicmphls,
Ulrich Weiganda8b04e12015-05-05 19:23:40 +0000849 v128f, v128f, 2>;
Ulrich Weigandc1708b22015-05-05 19:31:09 +0000850 defm VCHLG : BinaryVRRbSPair<"vchlg", 0xE7F9, z_vicmphl, z_vicmphls,
Ulrich Weiganda8b04e12015-05-05 19:23:40 +0000851 v128g, v128g, 3>;
852
853 // Test under mask.
854 let Defs = [CC] in
Ulrich Weigandc1708b22015-05-05 19:31:09 +0000855 def VTM : CompareVRRa<"vtm", 0xE7D8, z_vtm, v128b, 0>;
Ulrich Weiganda8b04e12015-05-05 19:23:40 +0000856}
857
858//===----------------------------------------------------------------------===//
859// Floating-point arithmetic
860//===----------------------------------------------------------------------===//
861
Ulrich Weigandcd808232015-05-05 19:26:48 +0000862// See comments in SystemZInstrFP.td for the suppression flags and
863// rounding modes.
864multiclass VectorRounding<Instruction insn, TypedReg tr> {
865 def : FPConversion<insn, frint, tr, tr, 0, 0>;
866 def : FPConversion<insn, fnearbyint, tr, tr, 4, 0>;
867 def : FPConversion<insn, ffloor, tr, tr, 4, 7>;
868 def : FPConversion<insn, fceil, tr, tr, 4, 6>;
869 def : FPConversion<insn, ftrunc, tr, tr, 4, 5>;
Michael Kuperstein2bc3d4d2016-08-18 20:08:15 +0000870 def : FPConversion<insn, fround, tr, tr, 4, 1>;
Ulrich Weigandcd808232015-05-05 19:26:48 +0000871}
872
Ulrich Weiganda8b04e12015-05-05 19:23:40 +0000873let Predicates = [FeatureVector] in {
874 // Add.
Ulrich Weigand6e31ab32016-10-19 13:03:18 +0000875 def VFA : BinaryVRRcFloatGeneric<"vfa", 0xE7E3>;
Ulrich Weigandcd808232015-05-05 19:26:48 +0000876 def VFADB : BinaryVRRc<"vfadb", 0xE7E3, fadd, v128db, v128db, 3, 0>;
Ulrich Weigand49506d72015-05-05 19:28:34 +0000877 def WFADB : BinaryVRRc<"wfadb", 0xE7E3, fadd, v64db, v64db, 3, 8>;
Ulrich Weiganda8b04e12015-05-05 19:23:40 +0000878
879 // Convert from fixed 64-bit.
Ulrich Weigand6e31ab32016-10-19 13:03:18 +0000880 def VCDG : TernaryVRRaFloatGeneric<"vcdg", 0xE7C3>;
Ulrich Weiganda8b04e12015-05-05 19:23:40 +0000881 def VCDGB : TernaryVRRa<"vcdgb", 0xE7C3, null_frag, v128db, v128g, 3, 0>;
882 def WCDGB : TernaryVRRa<"wcdgb", 0xE7C3, null_frag, v64db, v64g, 3, 8>;
Ulrich Weigandcd808232015-05-05 19:26:48 +0000883 def : FPConversion<VCDGB, sint_to_fp, v128db, v128g, 0, 0>;
Ulrich Weiganda8b04e12015-05-05 19:23:40 +0000884
885 // Convert from logical 64-bit.
Ulrich Weigand6e31ab32016-10-19 13:03:18 +0000886 def VCDLG : TernaryVRRaFloatGeneric<"vcdlg", 0xE7C1>;
Ulrich Weiganda8b04e12015-05-05 19:23:40 +0000887 def VCDLGB : TernaryVRRa<"vcdlgb", 0xE7C1, null_frag, v128db, v128g, 3, 0>;
888 def WCDLGB : TernaryVRRa<"wcdlgb", 0xE7C1, null_frag, v64db, v64g, 3, 8>;
Ulrich Weigandcd808232015-05-05 19:26:48 +0000889 def : FPConversion<VCDLGB, uint_to_fp, v128db, v128g, 0, 0>;
Ulrich Weiganda8b04e12015-05-05 19:23:40 +0000890
891 // Convert to fixed 64-bit.
Ulrich Weigand6e31ab32016-10-19 13:03:18 +0000892 def VCGD : TernaryVRRaFloatGeneric<"vcgd", 0xE7C2>;
Ulrich Weiganda8b04e12015-05-05 19:23:40 +0000893 def VCGDB : TernaryVRRa<"vcgdb", 0xE7C2, null_frag, v128g, v128db, 3, 0>;
894 def WCGDB : TernaryVRRa<"wcgdb", 0xE7C2, null_frag, v64g, v64db, 3, 8>;
Ulrich Weigandcd808232015-05-05 19:26:48 +0000895 // Rounding mode should agree with SystemZInstrFP.td.
896 def : FPConversion<VCGDB, fp_to_sint, v128g, v128db, 0, 5>;
Ulrich Weiganda8b04e12015-05-05 19:23:40 +0000897
898 // Convert to logical 64-bit.
Ulrich Weigand6e31ab32016-10-19 13:03:18 +0000899 def VCLGD : TernaryVRRaFloatGeneric<"vclgd", 0xE7C0>;
Ulrich Weiganda8b04e12015-05-05 19:23:40 +0000900 def VCLGDB : TernaryVRRa<"vclgdb", 0xE7C0, null_frag, v128g, v128db, 3, 0>;
901 def WCLGDB : TernaryVRRa<"wclgdb", 0xE7C0, null_frag, v64g, v64db, 3, 8>;
Ulrich Weigandcd808232015-05-05 19:26:48 +0000902 // Rounding mode should agree with SystemZInstrFP.td.
903 def : FPConversion<VCLGDB, fp_to_uint, v128g, v128db, 0, 5>;
Ulrich Weiganda8b04e12015-05-05 19:23:40 +0000904
905 // Divide.
Ulrich Weigand6e31ab32016-10-19 13:03:18 +0000906 def VFD : BinaryVRRcFloatGeneric<"vfd", 0xE7E5>;
Ulrich Weigandcd808232015-05-05 19:26:48 +0000907 def VFDDB : BinaryVRRc<"vfddb", 0xE7E5, fdiv, v128db, v128db, 3, 0>;
Ulrich Weigand49506d72015-05-05 19:28:34 +0000908 def WFDDB : BinaryVRRc<"wfddb", 0xE7E5, fdiv, v64db, v64db, 3, 8>;
Ulrich Weiganda8b04e12015-05-05 19:23:40 +0000909
910 // Load FP integer.
Ulrich Weigand6e31ab32016-10-19 13:03:18 +0000911 def VFI : TernaryVRRaFloatGeneric<"vfi", 0xE7C7>;
Ulrich Weigandc1708b22015-05-05 19:31:09 +0000912 def VFIDB : TernaryVRRa<"vfidb", 0xE7C7, int_s390_vfidb, v128db, v128db, 3, 0>;
Ulrich Weiganda8b04e12015-05-05 19:23:40 +0000913 def WFIDB : TernaryVRRa<"wfidb", 0xE7C7, null_frag, v64db, v64db, 3, 8>;
Ulrich Weigandcd808232015-05-05 19:26:48 +0000914 defm : VectorRounding<VFIDB, v128db>;
Ulrich Weigand49506d72015-05-05 19:28:34 +0000915 defm : VectorRounding<WFIDB, v64db>;
Ulrich Weiganda8b04e12015-05-05 19:23:40 +0000916
917 // Load lengthened.
Ulrich Weigand6e31ab32016-10-19 13:03:18 +0000918 def VLDE : UnaryVRRaFloatGeneric<"vlde", 0xE7C4>;
Ulrich Weigand80b3af72015-05-05 19:27:45 +0000919 def VLDEB : UnaryVRRa<"vldeb", 0xE7C4, z_vextend, v128db, v128eb, 2, 0>;
Michael Kuperstein2bc3d4d2016-08-18 20:08:15 +0000920 def WLDEB : UnaryVRRa<"wldeb", 0xE7C4, fpextend, v64db, v32eb, 2, 8>;
Ulrich Weiganda8b04e12015-05-05 19:23:40 +0000921
922 // Load rounded,
Ulrich Weigand6e31ab32016-10-19 13:03:18 +0000923 def VLED : TernaryVRRaFloatGeneric<"vled", 0xE7C5>;
Ulrich Weiganda8b04e12015-05-05 19:23:40 +0000924 def VLEDB : TernaryVRRa<"vledb", 0xE7C5, null_frag, v128eb, v128db, 3, 0>;
925 def WLEDB : TernaryVRRa<"wledb", 0xE7C5, null_frag, v32eb, v64db, 3, 8>;
Ulrich Weigand80b3af72015-05-05 19:27:45 +0000926 def : Pat<(v4f32 (z_vround (v2f64 VR128:$src))), (VLEDB VR128:$src, 0, 0)>;
Michael Kuperstein2bc3d4d2016-08-18 20:08:15 +0000927 def : FPConversion<WLEDB, fpround, v32eb, v64db, 0, 0>;
Ulrich Weiganda8b04e12015-05-05 19:23:40 +0000928
929 // Multiply.
Ulrich Weigand6e31ab32016-10-19 13:03:18 +0000930 def VFM : BinaryVRRcFloatGeneric<"vfm", 0xE7E7>;
Ulrich Weigandcd808232015-05-05 19:26:48 +0000931 def VFMDB : BinaryVRRc<"vfmdb", 0xE7E7, fmul, v128db, v128db, 3, 0>;
Ulrich Weigand49506d72015-05-05 19:28:34 +0000932 def WFMDB : BinaryVRRc<"wfmdb", 0xE7E7, fmul, v64db, v64db, 3, 8>;
Ulrich Weiganda8b04e12015-05-05 19:23:40 +0000933
934 // Multiply and add.
Ulrich Weigand6e31ab32016-10-19 13:03:18 +0000935 def VFMA : TernaryVRReFloatGeneric<"vfma", 0xE78F>;
Ulrich Weigandcd808232015-05-05 19:26:48 +0000936 def VFMADB : TernaryVRRe<"vfmadb", 0xE78F, fma, v128db, v128db, 0, 3>;
Ulrich Weigand49506d72015-05-05 19:28:34 +0000937 def WFMADB : TernaryVRRe<"wfmadb", 0xE78F, fma, v64db, v64db, 8, 3>;
Ulrich Weiganda8b04e12015-05-05 19:23:40 +0000938
939 // Multiply and subtract.
Ulrich Weigand6e31ab32016-10-19 13:03:18 +0000940 def VFMS : TernaryVRReFloatGeneric<"vfms", 0xE78E>;
Ulrich Weigandcd808232015-05-05 19:26:48 +0000941 def VFMSDB : TernaryVRRe<"vfmsdb", 0xE78E, fms, v128db, v128db, 0, 3>;
Ulrich Weigand49506d72015-05-05 19:28:34 +0000942 def WFMSDB : TernaryVRRe<"wfmsdb", 0xE78E, fms, v64db, v64db, 8, 3>;
Ulrich Weiganda8b04e12015-05-05 19:23:40 +0000943
Ulrich Weigand6e31ab32016-10-19 13:03:18 +0000944 // Perform sign operation.
945 def VFPSO : BinaryVRRaFloatGeneric<"vfpso", 0xE7CC>;
946 def VFPSODB : BinaryVRRa<"vfpsodb", 0xE7CC, null_frag, v128db, v128db, 3, 0>;
947 def WFPSODB : BinaryVRRa<"wfpsodb", 0xE7CC, null_frag, v64db, v64db, 3, 8>;
948
949 // Load complement.
Ulrich Weigandcd808232015-05-05 19:26:48 +0000950 def VFLCDB : UnaryVRRa<"vflcdb", 0xE7CC, fneg, v128db, v128db, 3, 0, 0>;
Ulrich Weigand49506d72015-05-05 19:28:34 +0000951 def WFLCDB : UnaryVRRa<"wflcdb", 0xE7CC, fneg, v64db, v64db, 3, 8, 0>;
Ulrich Weiganda8b04e12015-05-05 19:23:40 +0000952
953 // Load negative.
Ulrich Weigandcd808232015-05-05 19:26:48 +0000954 def VFLNDB : UnaryVRRa<"vflndb", 0xE7CC, fnabs, v128db, v128db, 3, 0, 1>;
Ulrich Weigand49506d72015-05-05 19:28:34 +0000955 def WFLNDB : UnaryVRRa<"wflndb", 0xE7CC, fnabs, v64db, v64db, 3, 8, 1>;
Ulrich Weiganda8b04e12015-05-05 19:23:40 +0000956
957 // Load positive.
Ulrich Weigandcd808232015-05-05 19:26:48 +0000958 def VFLPDB : UnaryVRRa<"vflpdb", 0xE7CC, fabs, v128db, v128db, 3, 0, 2>;
Ulrich Weigand49506d72015-05-05 19:28:34 +0000959 def WFLPDB : UnaryVRRa<"wflpdb", 0xE7CC, fabs, v64db, v64db, 3, 8, 2>;
Ulrich Weiganda8b04e12015-05-05 19:23:40 +0000960
961 // Square root.
Ulrich Weigand6e31ab32016-10-19 13:03:18 +0000962 def VFSQ : UnaryVRRaFloatGeneric<"vfsq", 0xE7CE>;
Ulrich Weigandcd808232015-05-05 19:26:48 +0000963 def VFSQDB : UnaryVRRa<"vfsqdb", 0xE7CE, fsqrt, v128db, v128db, 3, 0>;
Ulrich Weigand49506d72015-05-05 19:28:34 +0000964 def WFSQDB : UnaryVRRa<"wfsqdb", 0xE7CE, fsqrt, v64db, v64db, 3, 8>;
Ulrich Weiganda8b04e12015-05-05 19:23:40 +0000965
966 // Subtract.
Ulrich Weigand6e31ab32016-10-19 13:03:18 +0000967 def VFS : BinaryVRRcFloatGeneric<"vfs", 0xE7E2>;
Ulrich Weigandcd808232015-05-05 19:26:48 +0000968 def VFSDB : BinaryVRRc<"vfsdb", 0xE7E2, fsub, v128db, v128db, 3, 0>;
Ulrich Weigand49506d72015-05-05 19:28:34 +0000969 def WFSDB : BinaryVRRc<"wfsdb", 0xE7E2, fsub, v64db, v64db, 3, 8>;
Ulrich Weiganda8b04e12015-05-05 19:23:40 +0000970
971 // Test data class immediate.
972 let Defs = [CC] in {
Ulrich Weigand6e31ab32016-10-19 13:03:18 +0000973 def VFTCI : BinaryVRIeFloatGeneric<"vftci", 0xE74A>;
Ulrich Weigandc1708b22015-05-05 19:31:09 +0000974 def VFTCIDB : BinaryVRIe<"vftcidb", 0xE74A, z_vftci, v128g, v128db, 3, 0>;
Ulrich Weiganda8b04e12015-05-05 19:23:40 +0000975 def WFTCIDB : BinaryVRIe<"wftcidb", 0xE74A, null_frag, v64g, v64db, 3, 8>;
976 }
977}
978
979//===----------------------------------------------------------------------===//
980// Floating-point comparison
981//===----------------------------------------------------------------------===//
982
983let Predicates = [FeatureVector] in {
984 // Compare scalar.
Ulrich Weigand6e31ab32016-10-19 13:03:18 +0000985 let Defs = [CC] in {
986 def WFC : CompareVRRaFloatGeneric<"wfc", 0xE7CB>;
Ulrich Weigand49506d72015-05-05 19:28:34 +0000987 def WFCDB : CompareVRRa<"wfcdb", 0xE7CB, z_fcmp, v64db, 3>;
Ulrich Weigand6e31ab32016-10-19 13:03:18 +0000988 }
Ulrich Weiganda8b04e12015-05-05 19:23:40 +0000989
990 // Compare and signal scalar.
Ulrich Weigand6e31ab32016-10-19 13:03:18 +0000991 let Defs = [CC] in {
992 def WFK : CompareVRRaFloatGeneric<"wfk", 0xE7CA>;
Ulrich Weiganda8b04e12015-05-05 19:23:40 +0000993 def WFKDB : CompareVRRa<"wfkdb", 0xE7CA, null_frag, v64db, 3>;
Ulrich Weigand6e31ab32016-10-19 13:03:18 +0000994 }
Ulrich Weiganda8b04e12015-05-05 19:23:40 +0000995
996 // Compare equal.
Ulrich Weigand6e31ab32016-10-19 13:03:18 +0000997 def VFCE : BinaryVRRcSPairFloatGeneric<"vfce", 0xE7E8>;
Ulrich Weigandc1708b22015-05-05 19:31:09 +0000998 defm VFCEDB : BinaryVRRcSPair<"vfcedb", 0xE7E8, z_vfcmpe, z_vfcmpes,
Ulrich Weiganda8b04e12015-05-05 19:23:40 +0000999 v128g, v128db, 3, 0>;
1000 defm WFCEDB : BinaryVRRcSPair<"wfcedb", 0xE7E8, null_frag, null_frag,
1001 v64g, v64db, 3, 8>;
1002
1003 // Compare high.
Ulrich Weigand6e31ab32016-10-19 13:03:18 +00001004 def VFCH : BinaryVRRcSPairFloatGeneric<"vfch", 0xE7EB>;
Ulrich Weigandc1708b22015-05-05 19:31:09 +00001005 defm VFCHDB : BinaryVRRcSPair<"vfchdb", 0xE7EB, z_vfcmph, z_vfcmphs,
Ulrich Weiganda8b04e12015-05-05 19:23:40 +00001006 v128g, v128db, 3, 0>;
1007 defm WFCHDB : BinaryVRRcSPair<"wfchdb", 0xE7EB, null_frag, null_frag,
1008 v64g, v64db, 3, 8>;
1009
1010 // Compare high or equal.
Ulrich Weigand6e31ab32016-10-19 13:03:18 +00001011 def VFCHE : BinaryVRRcSPairFloatGeneric<"vfche", 0xE7EA>;
Ulrich Weigandc1708b22015-05-05 19:31:09 +00001012 defm VFCHEDB : BinaryVRRcSPair<"vfchedb", 0xE7EA, z_vfcmphe, z_vfcmphes,
Ulrich Weiganda8b04e12015-05-05 19:23:40 +00001013 v128g, v128db, 3, 0>;
1014 defm WFCHEDB : BinaryVRRcSPair<"wfchedb", 0xE7EA, null_frag, null_frag,
1015 v64g, v64db, 3, 8>;
1016}
1017
1018//===----------------------------------------------------------------------===//
Ulrich Weigandce4c1092015-05-05 19:25:42 +00001019// Conversions
1020//===----------------------------------------------------------------------===//
1021
1022def : Pat<(v16i8 (bitconvert (v8i16 VR128:$src))), (v16i8 VR128:$src)>;
1023def : Pat<(v16i8 (bitconvert (v4i32 VR128:$src))), (v16i8 VR128:$src)>;
1024def : Pat<(v16i8 (bitconvert (v2i64 VR128:$src))), (v16i8 VR128:$src)>;
Ulrich Weigand80b3af72015-05-05 19:27:45 +00001025def : Pat<(v16i8 (bitconvert (v4f32 VR128:$src))), (v16i8 VR128:$src)>;
Ulrich Weigandcd808232015-05-05 19:26:48 +00001026def : Pat<(v16i8 (bitconvert (v2f64 VR128:$src))), (v16i8 VR128:$src)>;
Ulrich Weigandce4c1092015-05-05 19:25:42 +00001027
1028def : Pat<(v8i16 (bitconvert (v16i8 VR128:$src))), (v8i16 VR128:$src)>;
1029def : Pat<(v8i16 (bitconvert (v4i32 VR128:$src))), (v8i16 VR128:$src)>;
1030def : Pat<(v8i16 (bitconvert (v2i64 VR128:$src))), (v8i16 VR128:$src)>;
Ulrich Weigand80b3af72015-05-05 19:27:45 +00001031def : Pat<(v8i16 (bitconvert (v4f32 VR128:$src))), (v8i16 VR128:$src)>;
Ulrich Weigandcd808232015-05-05 19:26:48 +00001032def : Pat<(v8i16 (bitconvert (v2f64 VR128:$src))), (v8i16 VR128:$src)>;
Ulrich Weigandce4c1092015-05-05 19:25:42 +00001033
1034def : Pat<(v4i32 (bitconvert (v16i8 VR128:$src))), (v4i32 VR128:$src)>;
1035def : Pat<(v4i32 (bitconvert (v8i16 VR128:$src))), (v4i32 VR128:$src)>;
1036def : Pat<(v4i32 (bitconvert (v2i64 VR128:$src))), (v4i32 VR128:$src)>;
Ulrich Weigand80b3af72015-05-05 19:27:45 +00001037def : Pat<(v4i32 (bitconvert (v4f32 VR128:$src))), (v4i32 VR128:$src)>;
Ulrich Weigandcd808232015-05-05 19:26:48 +00001038def : Pat<(v4i32 (bitconvert (v2f64 VR128:$src))), (v4i32 VR128:$src)>;
Ulrich Weigandce4c1092015-05-05 19:25:42 +00001039
1040def : Pat<(v2i64 (bitconvert (v16i8 VR128:$src))), (v2i64 VR128:$src)>;
1041def : Pat<(v2i64 (bitconvert (v8i16 VR128:$src))), (v2i64 VR128:$src)>;
1042def : Pat<(v2i64 (bitconvert (v4i32 VR128:$src))), (v2i64 VR128:$src)>;
Ulrich Weigand80b3af72015-05-05 19:27:45 +00001043def : Pat<(v2i64 (bitconvert (v4f32 VR128:$src))), (v2i64 VR128:$src)>;
Ulrich Weigandcd808232015-05-05 19:26:48 +00001044def : Pat<(v2i64 (bitconvert (v2f64 VR128:$src))), (v2i64 VR128:$src)>;
1045
Ulrich Weigand80b3af72015-05-05 19:27:45 +00001046def : Pat<(v4f32 (bitconvert (v16i8 VR128:$src))), (v4f32 VR128:$src)>;
1047def : Pat<(v4f32 (bitconvert (v8i16 VR128:$src))), (v4f32 VR128:$src)>;
1048def : Pat<(v4f32 (bitconvert (v4i32 VR128:$src))), (v4f32 VR128:$src)>;
1049def : Pat<(v4f32 (bitconvert (v2i64 VR128:$src))), (v4f32 VR128:$src)>;
1050def : Pat<(v4f32 (bitconvert (v2f64 VR128:$src))), (v4f32 VR128:$src)>;
1051
Ulrich Weigandcd808232015-05-05 19:26:48 +00001052def : Pat<(v2f64 (bitconvert (v16i8 VR128:$src))), (v2f64 VR128:$src)>;
1053def : Pat<(v2f64 (bitconvert (v8i16 VR128:$src))), (v2f64 VR128:$src)>;
1054def : Pat<(v2f64 (bitconvert (v4i32 VR128:$src))), (v2f64 VR128:$src)>;
1055def : Pat<(v2f64 (bitconvert (v2i64 VR128:$src))), (v2f64 VR128:$src)>;
Ulrich Weigand80b3af72015-05-05 19:27:45 +00001056def : Pat<(v2f64 (bitconvert (v4f32 VR128:$src))), (v2f64 VR128:$src)>;
Ulrich Weigandce4c1092015-05-05 19:25:42 +00001057
1058//===----------------------------------------------------------------------===//
1059// Replicating scalars
1060//===----------------------------------------------------------------------===//
1061
1062// Define patterns for replicating a scalar GR32 into a vector of type TYPE.
1063// INDEX is 8 minus the element size in bytes.
1064class VectorReplicateScalar<ValueType type, Instruction insn, bits<16> index>
1065 : Pat<(type (z_replicate GR32:$scalar)),
1066 (insn (VLVGP32 GR32:$scalar, GR32:$scalar), index)>;
1067
1068def : VectorReplicateScalar<v16i8, VREPB, 7>;
1069def : VectorReplicateScalar<v8i16, VREPH, 3>;
1070def : VectorReplicateScalar<v4i32, VREPF, 1>;
1071
1072// i64 replications are just a single isntruction.
1073def : Pat<(v2i64 (z_replicate GR64:$scalar)),
1074 (VLVGP GR64:$scalar, GR64:$scalar)>;
1075
1076//===----------------------------------------------------------------------===//
Ulrich Weigandcd808232015-05-05 19:26:48 +00001077// Floating-point insertion and extraction
1078//===----------------------------------------------------------------------===//
1079
Ulrich Weigand80b3af72015-05-05 19:27:45 +00001080// Moving 32-bit values between GPRs and FPRs can be done using VLVGF
1081// and VLGVF.
1082def LEFR : UnaryAliasVRS<VR32, GR32>;
1083def LFER : UnaryAliasVRS<GR64, VR32>;
1084def : Pat<(f32 (bitconvert (i32 GR32:$src))), (LEFR GR32:$src)>;
1085def : Pat<(i32 (bitconvert (f32 VR32:$src))),
1086 (EXTRACT_SUBREG (LFER VR32:$src), subreg_l32)>;
1087
Ulrich Weigandcd808232015-05-05 19:26:48 +00001088// Floating-point values are stored in element 0 of the corresponding
1089// vector register. Scalar to vector conversion is just a subreg and
1090// scalar replication can just replicate element 0 of the vector register.
1091multiclass ScalarToVectorFP<Instruction vrep, ValueType vt, RegisterOperand cls,
1092 SubRegIndex subreg> {
1093 def : Pat<(vt (scalar_to_vector cls:$scalar)),
1094 (INSERT_SUBREG (vt (IMPLICIT_DEF)), cls:$scalar, subreg)>;
1095 def : Pat<(vt (z_replicate cls:$scalar)),
1096 (vrep (INSERT_SUBREG (vt (IMPLICIT_DEF)), cls:$scalar,
1097 subreg), 0)>;
1098}
Ulrich Weigand80b3af72015-05-05 19:27:45 +00001099defm : ScalarToVectorFP<VREPF, v4f32, FP32, subreg_r32>;
Ulrich Weigandcd808232015-05-05 19:26:48 +00001100defm : ScalarToVectorFP<VREPG, v2f64, FP64, subreg_r64>;
1101
1102// Match v2f64 insertions. The AddedComplexity counters the 3 added by
1103// TableGen for the base register operand in VLVG-based integer insertions
1104// and ensures that this version is strictly better.
1105let AddedComplexity = 4 in {
1106 def : Pat<(z_vector_insert (v2f64 VR128:$vec), FP64:$elt, 0),
1107 (VPDI (INSERT_SUBREG (v2f64 (IMPLICIT_DEF)), FP64:$elt,
1108 subreg_r64), VR128:$vec, 1)>;
1109 def : Pat<(z_vector_insert (v2f64 VR128:$vec), FP64:$elt, 1),
1110 (VPDI VR128:$vec, (INSERT_SUBREG (v2f64 (IMPLICIT_DEF)), FP64:$elt,
1111 subreg_r64), 0)>;
1112}
1113
Ulrich Weigand80b3af72015-05-05 19:27:45 +00001114// We extract floating-point element X by replicating (for elements other
1115// than 0) and then taking a high subreg. The AddedComplexity counters the
1116// 3 added by TableGen for the base register operand in VLGV-based integer
Ulrich Weigandcd808232015-05-05 19:26:48 +00001117// extractions and ensures that this version is strictly better.
1118let AddedComplexity = 4 in {
Ulrich Weigand80b3af72015-05-05 19:27:45 +00001119 def : Pat<(f32 (z_vector_extract (v4f32 VR128:$vec), 0)),
1120 (EXTRACT_SUBREG VR128:$vec, subreg_r32)>;
1121 def : Pat<(f32 (z_vector_extract (v4f32 VR128:$vec), imm32zx2:$index)),
1122 (EXTRACT_SUBREG (VREPF VR128:$vec, imm32zx2:$index), subreg_r32)>;
1123
Ulrich Weigandcd808232015-05-05 19:26:48 +00001124 def : Pat<(f64 (z_vector_extract (v2f64 VR128:$vec), 0)),
1125 (EXTRACT_SUBREG VR128:$vec, subreg_r64)>;
1126 def : Pat<(f64 (z_vector_extract (v2f64 VR128:$vec), imm32zx1:$index)),
1127 (EXTRACT_SUBREG (VREPG VR128:$vec, imm32zx1:$index), subreg_r64)>;
1128}
1129
1130//===----------------------------------------------------------------------===//
Ulrich Weiganda8b04e12015-05-05 19:23:40 +00001131// String instructions
1132//===----------------------------------------------------------------------===//
1133
1134let Predicates = [FeatureVector] in {
Ulrich Weigand6e31ab32016-10-19 13:03:18 +00001135 defm VFAE : TernaryOptVRRbSPairGeneric<"vfae", 0xE782>;
Ulrich Weigand556a90c2016-10-19 12:57:46 +00001136 defm VFAEB : TernaryOptVRRbSPair<"vfaeb", 0xE782, int_s390_vfaeb,
1137 z_vfae_cc, v128b, v128b, 0>;
1138 defm VFAEH : TernaryOptVRRbSPair<"vfaeh", 0xE782, int_s390_vfaeh,
1139 z_vfae_cc, v128h, v128h, 1>;
1140 defm VFAEF : TernaryOptVRRbSPair<"vfaef", 0xE782, int_s390_vfaef,
1141 z_vfae_cc, v128f, v128f, 2>;
1142 defm VFAEZB : TernaryOptVRRbSPair<"vfaezb", 0xE782, int_s390_vfaezb,
1143 z_vfaez_cc, v128b, v128b, 0, 2>;
1144 defm VFAEZH : TernaryOptVRRbSPair<"vfaezh", 0xE782, int_s390_vfaezh,
1145 z_vfaez_cc, v128h, v128h, 1, 2>;
1146 defm VFAEZF : TernaryOptVRRbSPair<"vfaezf", 0xE782, int_s390_vfaezf,
1147 z_vfaez_cc, v128f, v128f, 2, 2>;
Ulrich Weiganda8b04e12015-05-05 19:23:40 +00001148
Ulrich Weigand6e31ab32016-10-19 13:03:18 +00001149 defm VFEE : BinaryExtraVRRbSPairGeneric<"vfee", 0xE780>;
Ulrich Weigand556a90c2016-10-19 12:57:46 +00001150 defm VFEEB : BinaryExtraVRRbSPair<"vfeeb", 0xE780, int_s390_vfeeb,
1151 z_vfee_cc, v128b, v128b, 0>;
1152 defm VFEEH : BinaryExtraVRRbSPair<"vfeeh", 0xE780, int_s390_vfeeh,
1153 z_vfee_cc, v128h, v128h, 1>;
1154 defm VFEEF : BinaryExtraVRRbSPair<"vfeef", 0xE780, int_s390_vfeef,
1155 z_vfee_cc, v128f, v128f, 2>;
1156 defm VFEEZB : BinaryVRRbSPair<"vfeezb", 0xE780, int_s390_vfeezb,
1157 z_vfeez_cc, v128b, v128b, 0, 2>;
1158 defm VFEEZH : BinaryVRRbSPair<"vfeezh", 0xE780, int_s390_vfeezh,
1159 z_vfeez_cc, v128h, v128h, 1, 2>;
1160 defm VFEEZF : BinaryVRRbSPair<"vfeezf", 0xE780, int_s390_vfeezf,
1161 z_vfeez_cc, v128f, v128f, 2, 2>;
Ulrich Weiganda8b04e12015-05-05 19:23:40 +00001162
Ulrich Weigand6e31ab32016-10-19 13:03:18 +00001163 defm VFENE : BinaryExtraVRRbSPairGeneric<"vfene", 0xE781>;
Ulrich Weigand556a90c2016-10-19 12:57:46 +00001164 defm VFENEB : BinaryExtraVRRbSPair<"vfeneb", 0xE781, int_s390_vfeneb,
1165 z_vfene_cc, v128b, v128b, 0>;
1166 defm VFENEH : BinaryExtraVRRbSPair<"vfeneh", 0xE781, int_s390_vfeneh,
1167 z_vfene_cc, v128h, v128h, 1>;
1168 defm VFENEF : BinaryExtraVRRbSPair<"vfenef", 0xE781, int_s390_vfenef,
1169 z_vfene_cc, v128f, v128f, 2>;
Ulrich Weigandc1708b22015-05-05 19:31:09 +00001170 defm VFENEZB : BinaryVRRbSPair<"vfenezb", 0xE781, int_s390_vfenezb,
Ulrich Weigand556a90c2016-10-19 12:57:46 +00001171 z_vfenez_cc, v128b, v128b, 0, 2>;
Ulrich Weigandc1708b22015-05-05 19:31:09 +00001172 defm VFENEZH : BinaryVRRbSPair<"vfenezh", 0xE781, int_s390_vfenezh,
Ulrich Weigand556a90c2016-10-19 12:57:46 +00001173 z_vfenez_cc, v128h, v128h, 1, 2>;
Ulrich Weigandc1708b22015-05-05 19:31:09 +00001174 defm VFENEZF : BinaryVRRbSPair<"vfenezf", 0xE781, int_s390_vfenezf,
Ulrich Weigand556a90c2016-10-19 12:57:46 +00001175 z_vfenez_cc, v128f, v128f, 2, 2>;
Ulrich Weiganda8b04e12015-05-05 19:23:40 +00001176
Ulrich Weigand6e31ab32016-10-19 13:03:18 +00001177 defm VISTR : UnaryExtraVRRaSPairGeneric<"vistr", 0xE75C>;
Ulrich Weigand556a90c2016-10-19 12:57:46 +00001178 defm VISTRB : UnaryExtraVRRaSPair<"vistrb", 0xE75C, int_s390_vistrb,
1179 z_vistr_cc, v128b, v128b, 0>;
1180 defm VISTRH : UnaryExtraVRRaSPair<"vistrh", 0xE75C, int_s390_vistrh,
1181 z_vistr_cc, v128h, v128h, 1>;
1182 defm VISTRF : UnaryExtraVRRaSPair<"vistrf", 0xE75C, int_s390_vistrf,
1183 z_vistr_cc, v128f, v128f, 2>;
Ulrich Weiganda8b04e12015-05-05 19:23:40 +00001184
Ulrich Weigand6e31ab32016-10-19 13:03:18 +00001185 defm VSTRC : QuaternaryOptVRRdSPairGeneric<"vstrc", 0xE78A>;
Ulrich Weigand556a90c2016-10-19 12:57:46 +00001186 defm VSTRCB : QuaternaryOptVRRdSPair<"vstrcb", 0xE78A, int_s390_vstrcb,
1187 z_vstrc_cc, v128b, v128b, 0>;
1188 defm VSTRCH : QuaternaryOptVRRdSPair<"vstrch", 0xE78A, int_s390_vstrch,
1189 z_vstrc_cc, v128h, v128h, 1>;
1190 defm VSTRCF : QuaternaryOptVRRdSPair<"vstrcf", 0xE78A, int_s390_vstrcf,
1191 z_vstrc_cc, v128f, v128f, 2>;
1192 defm VSTRCZB : QuaternaryOptVRRdSPair<"vstrczb", 0xE78A, int_s390_vstrczb,
1193 z_vstrcz_cc, v128b, v128b, 0, 2>;
1194 defm VSTRCZH : QuaternaryOptVRRdSPair<"vstrczh", 0xE78A, int_s390_vstrczh,
1195 z_vstrcz_cc, v128h, v128h, 1, 2>;
1196 defm VSTRCZF : QuaternaryOptVRRdSPair<"vstrczf", 0xE78A, int_s390_vstrczf,
1197 z_vstrcz_cc, v128f, v128f, 2, 2>;
Ulrich Weiganda8b04e12015-05-05 19:23:40 +00001198}