blob: 0d38d573757529b970686bfcc50bfc76ab77294d [file] [log] [blame]
Aart Bikf8f5a162017-02-06 15:35:29 -08001/*
2 * Copyright (C) 2017 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#ifndef ART_COMPILER_OPTIMIZING_NODES_VECTOR_H_
18#define ART_COMPILER_OPTIMIZING_NODES_VECTOR_H_
19
20// This #include should never be used by compilation, because this header file (nodes_vector.h)
21// is included in the header file nodes.h itself. However it gives editing tools better context.
22#include "nodes.h"
23
24namespace art {
25
26// Memory alignment, represented as an offset relative to a base, where 0 <= offset < base,
27// and base is a power of two. For example, the value Alignment(16, 0) means memory is
28// perfectly aligned at a 16-byte boundary, whereas the value Alignment(16, 4) means
29// memory is always exactly 4 bytes above such a boundary.
30class Alignment {
31 public:
32 Alignment(size_t base, size_t offset) : base_(base), offset_(offset) {
33 DCHECK_LT(offset, base);
34 DCHECK(IsPowerOfTwo(base));
35 }
36
Aart Bik46b6dbc2017-10-03 11:37:37 -070037 // Returns true if memory is at least aligned at the given boundary.
Aart Bikf8f5a162017-02-06 15:35:29 -080038 // Assumes requested base is power of two.
39 bool IsAlignedAt(size_t base) const {
40 DCHECK_NE(0u, base);
41 DCHECK(IsPowerOfTwo(base));
42 return ((offset_ | base_) & (base - 1u)) == 0;
43 }
44
Aart Bik46b6dbc2017-10-03 11:37:37 -070045 size_t Base() const { return base_; }
46
47 size_t Offset() const { return offset_; }
48
Aart Bikf8f5a162017-02-06 15:35:29 -080049 std::string ToString() const {
50 return "ALIGN(" + std::to_string(base_) + "," + std::to_string(offset_) + ")";
51 }
52
Aart Bikb79f4ac2017-07-10 10:10:37 -070053 bool operator==(const Alignment& other) const {
54 return base_ == other.base_ && offset_ == other.offset_;
55 }
56
Aart Bikf8f5a162017-02-06 15:35:29 -080057 private:
58 size_t base_;
59 size_t offset_;
60};
61
62//
63// Definitions of abstract vector operations in HIR.
64//
65
66// Abstraction of a vector operation, i.e., an operation that performs
67// GetVectorLength() x GetPackedType() operations simultaneously.
68class HVecOperation : public HVariableInputSizeInstruction {
69 public:
Aart Bik0148de42017-09-05 09:25:01 -070070 // A SIMD operation looks like a FPU location.
71 // TODO: we could introduce SIMD types in HIR.
Vladimir Marko0ebe0d82017-09-21 22:50:39 +010072 static constexpr DataType::Type kSIMDType = DataType::Type::kFloat64;
Aart Bik0148de42017-09-05 09:25:01 -070073
Gupta Kumar, Sanjivd9e4d732018-02-05 13:35:03 +053074 HVecOperation(InstructionKind kind,
75 ArenaAllocator* allocator,
Vladimir Marko0ebe0d82017-09-21 22:50:39 +010076 DataType::Type packed_type,
Aart Bikf8f5a162017-02-06 15:35:29 -080077 SideEffects side_effects,
78 size_t number_of_inputs,
79 size_t vector_length,
80 uint32_t dex_pc)
Gupta Kumar, Sanjivd9e4d732018-02-05 13:35:03 +053081 : HVariableInputSizeInstruction(kind,
82 side_effects,
Aart Bikf8f5a162017-02-06 15:35:29 -080083 dex_pc,
Vladimir Markoe764d2e2017-10-05 14:35:55 +010084 allocator,
Aart Bikf8f5a162017-02-06 15:35:29 -080085 number_of_inputs,
86 kArenaAllocVectorNode),
87 vector_length_(vector_length) {
88 SetPackedField<TypeField>(packed_type);
89 DCHECK_LT(1u, vector_length);
90 }
91
92 // Returns the number of elements packed in a vector.
93 size_t GetVectorLength() const {
94 return vector_length_;
95 }
96
97 // Returns the number of bytes in a full vector.
98 size_t GetVectorNumberOfBytes() const {
Vladimir Marko0ebe0d82017-09-21 22:50:39 +010099 return vector_length_ * DataType::Size(GetPackedType());
Aart Bikf8f5a162017-02-06 15:35:29 -0800100 }
101
Aart Bik0148de42017-09-05 09:25:01 -0700102 // Returns the type of the vector operation.
Vladimir Marko0ebe0d82017-09-21 22:50:39 +0100103 DataType::Type GetType() const OVERRIDE {
Aart Bik0148de42017-09-05 09:25:01 -0700104 return kSIMDType;
Aart Bikf8f5a162017-02-06 15:35:29 -0800105 }
106
107 // Returns the true component type packed in a vector.
Vladimir Marko0ebe0d82017-09-21 22:50:39 +0100108 DataType::Type GetPackedType() const {
Aart Bikf8f5a162017-02-06 15:35:29 -0800109 return GetPackedField<TypeField>();
110 }
111
Aart Bikb79f4ac2017-07-10 10:10:37 -0700112 // Assumes vector nodes cannot be moved by default. Each concrete implementation
113 // that can be moved should override this method and return true.
Artem Serov89ff8b22017-11-20 11:51:05 +0000114 //
115 // Note: similar approach is used for instruction scheduling (if it is turned on for the target):
116 // by default HScheduler::IsSchedulable returns false for a particular HVecOperation.
117 // HScheduler${ARCH}::IsSchedulable can be overridden to return true for an instruction (see
118 // scheduler_arm64.h for example) if it is safe to schedule it; in this case one *must* also
119 // look at/update HScheduler${ARCH}::IsSchedulingBarrier for this instruction.
120 //
121 // Note: For newly introduced vector instructions HScheduler${ARCH}::IsSchedulingBarrier must be
122 // altered to return true if the instruction might reside outside the SIMD loop body since SIMD
123 // registers are not kept alive across vector loop boundaries (yet).
Aart Bikb79f4ac2017-07-10 10:10:37 -0700124 bool CanBeMoved() const OVERRIDE { return false; }
125
126 // Tests if all data of a vector node (vector length and packed type) is equal.
127 // Each concrete implementation that adds more fields should test equality of
128 // those fields in its own method *and* call all super methods.
129 bool InstructionDataEquals(const HInstruction* other) const OVERRIDE {
130 DCHECK(other->IsVecOperation());
131 const HVecOperation* o = other->AsVecOperation();
132 return GetVectorLength() == o->GetVectorLength() && GetPackedType() == o->GetPackedType();
133 }
134
Aart Bik46b6dbc2017-10-03 11:37:37 -0700135 // Maps an integral type to the same-size signed type and leaves other types alone.
Aart Bik46b6dbc2017-10-03 11:37:37 -0700136 static DataType::Type ToSignedType(DataType::Type type) {
137 switch (type) {
138 case DataType::Type::kBool: // 1-byte storage unit
139 case DataType::Type::kUint8:
140 return DataType::Type::kInt8;
141 case DataType::Type::kUint16:
142 return DataType::Type::kInt16;
143 default:
144 DCHECK(type != DataType::Type::kVoid && type != DataType::Type::kReference) << type;
145 return type;
146 }
147 }
148
Aart Bik4d1a9d42017-10-19 14:40:55 -0700149 // Maps an integral type to the same-size unsigned type and leaves other types alone.
150 static DataType::Type ToUnsignedType(DataType::Type type) {
151 switch (type) {
152 case DataType::Type::kBool: // 1-byte storage unit
153 case DataType::Type::kInt8:
154 return DataType::Type::kUint8;
155 case DataType::Type::kInt16:
156 return DataType::Type::kUint16;
157 default:
158 DCHECK(type != DataType::Type::kVoid && type != DataType::Type::kReference) << type;
159 return type;
160 }
161 }
162
Aart Bik66c158e2018-01-31 12:55:04 -0800163 // Maps an integral type to the same-size (un)signed type. Leaves other types alone.
164 static DataType::Type ToProperType(DataType::Type type, bool is_unsigned) {
165 return is_unsigned ? ToUnsignedType(type) : ToSignedType(type);
166 }
167
Aart Bik2dd7b672017-12-07 11:11:22 -0800168 // Helper method to determine if an instruction returns a SIMD value.
169 // TODO: This method is needed until we introduce SIMD as proper type.
170 static bool ReturnsSIMDValue(HInstruction* instruction) {
171 if (instruction->IsVecOperation()) {
172 return !instruction->IsVecExtractScalar(); // only scalar returning vec op
173 } else if (instruction->IsPhi()) {
174 return
175 instruction->GetType() == kSIMDType &&
176 instruction->InputAt(1)->IsVecOperation(); // vectorizer does not go deeper
177 }
178 return false;
179 }
180
Aart Bikf8f5a162017-02-06 15:35:29 -0800181 DECLARE_ABSTRACT_INSTRUCTION(VecOperation);
182
Aart Bikdb14fcf2017-04-25 15:53:58 -0700183 protected:
Aart Bikf8f5a162017-02-06 15:35:29 -0800184 // Additional packed bits.
185 static constexpr size_t kFieldType = HInstruction::kNumberOfGenericPackedBits;
186 static constexpr size_t kFieldTypeSize =
Vladimir Marko0ebe0d82017-09-21 22:50:39 +0100187 MinimumBitsToStore(static_cast<size_t>(DataType::Type::kLast));
Aart Bikf8f5a162017-02-06 15:35:29 -0800188 static constexpr size_t kNumberOfVectorOpPackedBits = kFieldType + kFieldTypeSize;
189 static_assert(kNumberOfVectorOpPackedBits <= kMaxNumberOfPackedBits, "Too many packed fields.");
Vladimir Marko0ebe0d82017-09-21 22:50:39 +0100190 using TypeField = BitField<DataType::Type, kFieldType, kFieldTypeSize>;
Aart Bikf8f5a162017-02-06 15:35:29 -0800191
Artem Serovcced8ba2017-07-19 18:18:09 +0100192 DEFAULT_COPY_CONSTRUCTOR(VecOperation);
193
Aart Bikdb14fcf2017-04-25 15:53:58 -0700194 private:
Aart Bikf8f5a162017-02-06 15:35:29 -0800195 const size_t vector_length_;
Aart Bikf8f5a162017-02-06 15:35:29 -0800196};
197
198// Abstraction of a unary vector operation.
199class HVecUnaryOperation : public HVecOperation {
200 public:
Gupta Kumar, Sanjivd9e4d732018-02-05 13:35:03 +0530201 HVecUnaryOperation(InstructionKind kind,
202 ArenaAllocator* allocator,
Aart Bik8de59162017-04-21 09:42:01 -0700203 HInstruction* input,
Vladimir Marko0ebe0d82017-09-21 22:50:39 +0100204 DataType::Type packed_type,
Aart Bikf8f5a162017-02-06 15:35:29 -0800205 size_t vector_length,
206 uint32_t dex_pc)
Gupta Kumar, Sanjivd9e4d732018-02-05 13:35:03 +0530207 : HVecOperation(kind,
208 allocator,
Aart Bikf8f5a162017-02-06 15:35:29 -0800209 packed_type,
210 SideEffects::None(),
Aart Bik8de59162017-04-21 09:42:01 -0700211 /* number_of_inputs */ 1,
Aart Bikf8f5a162017-02-06 15:35:29 -0800212 vector_length,
Aart Bik8de59162017-04-21 09:42:01 -0700213 dex_pc) {
214 SetRawInputAt(0, input);
215 }
216
217 HInstruction* GetInput() const { return InputAt(0); }
218
Aart Bikf8f5a162017-02-06 15:35:29 -0800219 DECLARE_ABSTRACT_INSTRUCTION(VecUnaryOperation);
Aart Bik8de59162017-04-21 09:42:01 -0700220
Artem Serovcced8ba2017-07-19 18:18:09 +0100221 protected:
222 DEFAULT_COPY_CONSTRUCTOR(VecUnaryOperation);
Aart Bikf8f5a162017-02-06 15:35:29 -0800223};
224
225// Abstraction of a binary vector operation.
226class HVecBinaryOperation : public HVecOperation {
227 public:
Gupta Kumar, Sanjivd9e4d732018-02-05 13:35:03 +0530228 HVecBinaryOperation(InstructionKind kind,
229 ArenaAllocator* allocator,
Aart Bik8de59162017-04-21 09:42:01 -0700230 HInstruction* left,
231 HInstruction* right,
Vladimir Marko0ebe0d82017-09-21 22:50:39 +0100232 DataType::Type packed_type,
Aart Bikf8f5a162017-02-06 15:35:29 -0800233 size_t vector_length,
234 uint32_t dex_pc)
Gupta Kumar, Sanjivd9e4d732018-02-05 13:35:03 +0530235 : HVecOperation(kind,
236 allocator,
Aart Bikf8f5a162017-02-06 15:35:29 -0800237 packed_type,
238 SideEffects::None(),
Aart Bik8de59162017-04-21 09:42:01 -0700239 /* number_of_inputs */ 2,
Aart Bikf8f5a162017-02-06 15:35:29 -0800240 vector_length,
Aart Bik8de59162017-04-21 09:42:01 -0700241 dex_pc) {
242 SetRawInputAt(0, left);
243 SetRawInputAt(1, right);
244 }
Artem Serovf34dd202017-04-10 17:41:46 +0100245
246 HInstruction* GetLeft() const { return InputAt(0); }
247 HInstruction* GetRight() const { return InputAt(1); }
248
Aart Bikf8f5a162017-02-06 15:35:29 -0800249 DECLARE_ABSTRACT_INSTRUCTION(VecBinaryOperation);
Aart Bik8de59162017-04-21 09:42:01 -0700250
Artem Serovcced8ba2017-07-19 18:18:09 +0100251 protected:
252 DEFAULT_COPY_CONSTRUCTOR(VecBinaryOperation);
Aart Bikf8f5a162017-02-06 15:35:29 -0800253};
254
255// Abstraction of a vector operation that references memory, with an alignment.
Aart Bik46b6dbc2017-10-03 11:37:37 -0700256// The Android runtime guarantees elements have at least natural alignment.
Aart Bikf8f5a162017-02-06 15:35:29 -0800257class HVecMemoryOperation : public HVecOperation {
258 public:
Gupta Kumar, Sanjivd9e4d732018-02-05 13:35:03 +0530259 HVecMemoryOperation(InstructionKind kind,
260 ArenaAllocator* allocator,
Vladimir Marko0ebe0d82017-09-21 22:50:39 +0100261 DataType::Type packed_type,
Aart Bikf8f5a162017-02-06 15:35:29 -0800262 SideEffects side_effects,
263 size_t number_of_inputs,
264 size_t vector_length,
265 uint32_t dex_pc)
Gupta Kumar, Sanjivd9e4d732018-02-05 13:35:03 +0530266 : HVecOperation(kind,
267 allocator,
Vladimir Markoe764d2e2017-10-05 14:35:55 +0100268 packed_type,
269 side_effects,
270 number_of_inputs,
271 vector_length,
272 dex_pc),
Vladimir Marko0ebe0d82017-09-21 22:50:39 +0100273 alignment_(DataType::Size(packed_type), 0) {
Artem Serove1811ed2017-04-27 16:50:47 +0100274 DCHECK_GE(number_of_inputs, 2u);
275 }
Aart Bikf8f5a162017-02-06 15:35:29 -0800276
277 void SetAlignment(Alignment alignment) { alignment_ = alignment; }
278
279 Alignment GetAlignment() const { return alignment_; }
280
Artem Serove1811ed2017-04-27 16:50:47 +0100281 HInstruction* GetArray() const { return InputAt(0); }
282 HInstruction* GetIndex() const { return InputAt(1); }
283
Aart Bikb79f4ac2017-07-10 10:10:37 -0700284 bool InstructionDataEquals(const HInstruction* other) const OVERRIDE {
285 DCHECK(other->IsVecMemoryOperation());
286 const HVecMemoryOperation* o = other->AsVecMemoryOperation();
287 return HVecOperation::InstructionDataEquals(o) && GetAlignment() == o->GetAlignment();
288 }
289
Aart Bikf8f5a162017-02-06 15:35:29 -0800290 DECLARE_ABSTRACT_INSTRUCTION(VecMemoryOperation);
291
Artem Serovcced8ba2017-07-19 18:18:09 +0100292 protected:
293 DEFAULT_COPY_CONSTRUCTOR(VecMemoryOperation);
294
Aart Bikf8f5a162017-02-06 15:35:29 -0800295 private:
296 Alignment alignment_;
Aart Bikf8f5a162017-02-06 15:35:29 -0800297};
298
Aart Bik0148de42017-09-05 09:25:01 -0700299// Packed type consistency checker ("same vector length" integral types may mix freely).
Aart Bik66c158e2018-01-31 12:55:04 -0800300// Tests relaxed type consistency in which packed same-size integral types can co-exist,
301// but other type mixes are an error.
Vladimir Marko0ebe0d82017-09-21 22:50:39 +0100302inline static bool HasConsistentPackedTypes(HInstruction* input, DataType::Type type) {
Aart Bik0148de42017-09-05 09:25:01 -0700303 if (input->IsPhi()) {
304 return input->GetType() == HVecOperation::kSIMDType; // carries SIMD
305 }
Aart Bikd58bc322017-05-01 14:49:18 -0700306 DCHECK(input->IsVecOperation());
Vladimir Marko0ebe0d82017-09-21 22:50:39 +0100307 DataType::Type input_type = input->AsVecOperation()->GetPackedType();
Aart Bik4d1a9d42017-10-19 14:40:55 -0700308 DCHECK_EQ(HVecOperation::ToUnsignedType(input_type) == HVecOperation::ToUnsignedType(type),
309 HVecOperation::ToSignedType(input_type) == HVecOperation::ToSignedType(type));
Aart Bik46b6dbc2017-10-03 11:37:37 -0700310 return HVecOperation::ToSignedType(input_type) == HVecOperation::ToSignedType(type);
Aart Bikd58bc322017-05-01 14:49:18 -0700311}
312
Aart Bikf8f5a162017-02-06 15:35:29 -0800313//
Aart Bik8de59162017-04-21 09:42:01 -0700314// Definitions of concrete unary vector operations in HIR.
Aart Bikf8f5a162017-02-06 15:35:29 -0800315//
316
317// Replicates the given scalar into a vector,
318// viz. replicate(x) = [ x, .. , x ].
319class HVecReplicateScalar FINAL : public HVecUnaryOperation {
320 public:
Vladimir Markoe764d2e2017-10-05 14:35:55 +0100321 HVecReplicateScalar(ArenaAllocator* allocator,
Aart Bikf8f5a162017-02-06 15:35:29 -0800322 HInstruction* scalar,
Vladimir Marko0ebe0d82017-09-21 22:50:39 +0100323 DataType::Type packed_type,
Aart Bikf8f5a162017-02-06 15:35:29 -0800324 size_t vector_length,
Aart Bik46b6dbc2017-10-03 11:37:37 -0700325 uint32_t dex_pc)
Gupta Kumar, Sanjivd9e4d732018-02-05 13:35:03 +0530326 : HVecUnaryOperation(
327 kVecReplicateScalar, allocator, scalar, packed_type, vector_length, dex_pc) {
Aart Bik8de59162017-04-21 09:42:01 -0700328 DCHECK(!scalar->IsVecOperation());
Aart Bikf8f5a162017-02-06 15:35:29 -0800329 }
Aart Bikb79f4ac2017-07-10 10:10:37 -0700330
331 // A replicate needs to stay in place, since SIMD registers are not
332 // kept alive across vector loop boundaries (yet).
333 bool CanBeMoved() const OVERRIDE { return false; }
334
Aart Bikf8f5a162017-02-06 15:35:29 -0800335 DECLARE_INSTRUCTION(VecReplicateScalar);
Aart Bikb79f4ac2017-07-10 10:10:37 -0700336
Artem Serovcced8ba2017-07-19 18:18:09 +0100337 protected:
338 DEFAULT_COPY_CONSTRUCTOR(VecReplicateScalar);
Aart Bikf8f5a162017-02-06 15:35:29 -0800339};
340
Aart Bik0148de42017-09-05 09:25:01 -0700341// Extracts a particular scalar from the given vector,
342// viz. extract[ x1, .. , xn ] = x_i.
343//
344// TODO: for now only i == 1 case supported.
345class HVecExtractScalar FINAL : public HVecUnaryOperation {
346 public:
Vladimir Markoe764d2e2017-10-05 14:35:55 +0100347 HVecExtractScalar(ArenaAllocator* allocator,
Aart Bik0148de42017-09-05 09:25:01 -0700348 HInstruction* input,
Vladimir Marko0ebe0d82017-09-21 22:50:39 +0100349 DataType::Type packed_type,
Aart Bik0148de42017-09-05 09:25:01 -0700350 size_t vector_length,
351 size_t index,
Aart Bik46b6dbc2017-10-03 11:37:37 -0700352 uint32_t dex_pc)
Gupta Kumar, Sanjivd9e4d732018-02-05 13:35:03 +0530353 : HVecUnaryOperation(
354 kVecExtractScalar, allocator, input, packed_type, vector_length, dex_pc) {
Aart Bikd58bc322017-05-01 14:49:18 -0700355 DCHECK(HasConsistentPackedTypes(input, packed_type));
Aart Bik0148de42017-09-05 09:25:01 -0700356 DCHECK_LT(index, vector_length);
357 DCHECK_EQ(index, 0u);
358 }
359
360 // Yields a single component in the vector.
Vladimir Marko0ebe0d82017-09-21 22:50:39 +0100361 DataType::Type GetType() const OVERRIDE {
Aart Bik0148de42017-09-05 09:25:01 -0700362 return GetPackedType();
363 }
364
365 // An extract needs to stay in place, since SIMD registers are not
366 // kept alive across vector loop boundaries (yet).
367 bool CanBeMoved() const OVERRIDE { return false; }
368
369 DECLARE_INSTRUCTION(VecExtractScalar);
370
Artem Serovcced8ba2017-07-19 18:18:09 +0100371 protected:
372 DEFAULT_COPY_CONSTRUCTOR(VecExtractScalar);
Aart Bik0148de42017-09-05 09:25:01 -0700373};
374
375// Reduces the given vector into the first element as sum/min/max,
376// viz. sum-reduce[ x1, .. , xn ] = [ y, ---- ], where y = sum xi
377// and the "-" denotes "don't care" (implementation dependent).
378class HVecReduce FINAL : public HVecUnaryOperation {
379 public:
380 enum ReductionKind {
381 kSum = 1,
382 kMin = 2,
383 kMax = 3
384 };
385
Vladimir Markoe764d2e2017-10-05 14:35:55 +0100386 HVecReduce(ArenaAllocator* allocator,
Aart Bik0148de42017-09-05 09:25:01 -0700387 HInstruction* input,
Vladimir Marko0ebe0d82017-09-21 22:50:39 +0100388 DataType::Type packed_type,
Aart Bik0148de42017-09-05 09:25:01 -0700389 size_t vector_length,
390 ReductionKind kind,
Aart Bik46b6dbc2017-10-03 11:37:37 -0700391 uint32_t dex_pc)
Gupta Kumar, Sanjivd9e4d732018-02-05 13:35:03 +0530392 : HVecUnaryOperation(kVecReduce, allocator, input, packed_type, vector_length, dex_pc),
Aart Bik0148de42017-09-05 09:25:01 -0700393 kind_(kind) {
394 DCHECK(HasConsistentPackedTypes(input, packed_type));
Aart Bikcfa59b42017-08-31 09:08:13 -0700395 }
396
Aart Bik0148de42017-09-05 09:25:01 -0700397 ReductionKind GetKind() const { return kind_; }
Aart Bikf8f5a162017-02-06 15:35:29 -0800398
Aart Bikb79f4ac2017-07-10 10:10:37 -0700399 bool CanBeMoved() const OVERRIDE { return true; }
400
Aart Bik0148de42017-09-05 09:25:01 -0700401 bool InstructionDataEquals(const HInstruction* other) const OVERRIDE {
402 DCHECK(other->IsVecReduce());
403 const HVecReduce* o = other->AsVecReduce();
404 return HVecOperation::InstructionDataEquals(o) && GetKind() == o->GetKind();
405 }
406
407 DECLARE_INSTRUCTION(VecReduce);
Aart Bikb79f4ac2017-07-10 10:10:37 -0700408
Artem Serovcced8ba2017-07-19 18:18:09 +0100409 protected:
410 DEFAULT_COPY_CONSTRUCTOR(VecReduce);
411
Aart Bikf8f5a162017-02-06 15:35:29 -0800412 private:
Aart Bik0148de42017-09-05 09:25:01 -0700413 const ReductionKind kind_;
Aart Bikf8f5a162017-02-06 15:35:29 -0800414};
415
416// Converts every component in the vector,
417// viz. cnv[ x1, .. , xn ] = [ cnv(x1), .. , cnv(xn) ].
418class HVecCnv FINAL : public HVecUnaryOperation {
419 public:
Vladimir Markoe764d2e2017-10-05 14:35:55 +0100420 HVecCnv(ArenaAllocator* allocator,
Aart Bikf8f5a162017-02-06 15:35:29 -0800421 HInstruction* input,
Vladimir Marko0ebe0d82017-09-21 22:50:39 +0100422 DataType::Type packed_type,
Aart Bikf8f5a162017-02-06 15:35:29 -0800423 size_t vector_length,
Aart Bik46b6dbc2017-10-03 11:37:37 -0700424 uint32_t dex_pc)
Gupta Kumar, Sanjivd9e4d732018-02-05 13:35:03 +0530425 : HVecUnaryOperation(kVecCnv, allocator, input, packed_type, vector_length, dex_pc) {
Aart Bikf8f5a162017-02-06 15:35:29 -0800426 DCHECK(input->IsVecOperation());
Aart Bikd58bc322017-05-01 14:49:18 -0700427 DCHECK_NE(GetInputType(), GetResultType()); // actual convert
Aart Bikf8f5a162017-02-06 15:35:29 -0800428 }
429
Vladimir Marko0ebe0d82017-09-21 22:50:39 +0100430 DataType::Type GetInputType() const { return InputAt(0)->AsVecOperation()->GetPackedType(); }
431 DataType::Type GetResultType() const { return GetPackedType(); }
Aart Bikf8f5a162017-02-06 15:35:29 -0800432
Aart Bikb79f4ac2017-07-10 10:10:37 -0700433 bool CanBeMoved() const OVERRIDE { return true; }
434
Aart Bikf8f5a162017-02-06 15:35:29 -0800435 DECLARE_INSTRUCTION(VecCnv);
436
Artem Serovcced8ba2017-07-19 18:18:09 +0100437 protected:
438 DEFAULT_COPY_CONSTRUCTOR(VecCnv);
Aart Bikf8f5a162017-02-06 15:35:29 -0800439};
440
441// Negates every component in the vector,
442// viz. neg[ x1, .. , xn ] = [ -x1, .. , -xn ].
443class HVecNeg FINAL : public HVecUnaryOperation {
444 public:
Vladimir Markoe764d2e2017-10-05 14:35:55 +0100445 HVecNeg(ArenaAllocator* allocator,
Aart Bikf8f5a162017-02-06 15:35:29 -0800446 HInstruction* input,
Vladimir Marko0ebe0d82017-09-21 22:50:39 +0100447 DataType::Type packed_type,
Aart Bikf8f5a162017-02-06 15:35:29 -0800448 size_t vector_length,
Aart Bik46b6dbc2017-10-03 11:37:37 -0700449 uint32_t dex_pc)
Gupta Kumar, Sanjivd9e4d732018-02-05 13:35:03 +0530450 : HVecUnaryOperation(kVecNeg, allocator, input, packed_type, vector_length, dex_pc) {
Aart Bikd58bc322017-05-01 14:49:18 -0700451 DCHECK(HasConsistentPackedTypes(input, packed_type));
Aart Bikf8f5a162017-02-06 15:35:29 -0800452 }
Aart Bikb79f4ac2017-07-10 10:10:37 -0700453
454 bool CanBeMoved() const OVERRIDE { return true; }
455
Aart Bikf8f5a162017-02-06 15:35:29 -0800456 DECLARE_INSTRUCTION(VecNeg);
Aart Bikb79f4ac2017-07-10 10:10:37 -0700457
Artem Serovcced8ba2017-07-19 18:18:09 +0100458 protected:
459 DEFAULT_COPY_CONSTRUCTOR(VecNeg);
Aart Bikf8f5a162017-02-06 15:35:29 -0800460};
461
Aart Bik6daebeb2017-04-03 14:35:41 -0700462// Takes absolute value of every component in the vector,
Aart Bik46b6dbc2017-10-03 11:37:37 -0700463// viz. abs[ x1, .. , xn ] = [ |x1|, .. , |xn| ]
464// for signed operand x.
Aart Bik6daebeb2017-04-03 14:35:41 -0700465class HVecAbs FINAL : public HVecUnaryOperation {
466 public:
Vladimir Markoe764d2e2017-10-05 14:35:55 +0100467 HVecAbs(ArenaAllocator* allocator,
Aart Bik6daebeb2017-04-03 14:35:41 -0700468 HInstruction* input,
Vladimir Marko0ebe0d82017-09-21 22:50:39 +0100469 DataType::Type packed_type,
Aart Bik6daebeb2017-04-03 14:35:41 -0700470 size_t vector_length,
Aart Bik46b6dbc2017-10-03 11:37:37 -0700471 uint32_t dex_pc)
Gupta Kumar, Sanjivd9e4d732018-02-05 13:35:03 +0530472 : HVecUnaryOperation(kVecAbs, allocator, input, packed_type, vector_length, dex_pc) {
Aart Bikd58bc322017-05-01 14:49:18 -0700473 DCHECK(HasConsistentPackedTypes(input, packed_type));
Aart Bik6daebeb2017-04-03 14:35:41 -0700474 }
Aart Bikb79f4ac2017-07-10 10:10:37 -0700475
476 bool CanBeMoved() const OVERRIDE { return true; }
477
Aart Bik6daebeb2017-04-03 14:35:41 -0700478 DECLARE_INSTRUCTION(VecAbs);
Aart Bikb79f4ac2017-07-10 10:10:37 -0700479
Artem Serovcced8ba2017-07-19 18:18:09 +0100480 protected:
481 DEFAULT_COPY_CONSTRUCTOR(VecAbs);
Aart Bik6daebeb2017-04-03 14:35:41 -0700482};
483
Aart Bikf8f5a162017-02-06 15:35:29 -0800484// Bitwise- or boolean-nots every component in the vector,
485// viz. not[ x1, .. , xn ] = [ ~x1, .. , ~xn ], or
486// not[ x1, .. , xn ] = [ !x1, .. , !xn ] for boolean.
487class HVecNot FINAL : public HVecUnaryOperation {
488 public:
Vladimir Markoe764d2e2017-10-05 14:35:55 +0100489 HVecNot(ArenaAllocator* allocator,
Aart Bikf8f5a162017-02-06 15:35:29 -0800490 HInstruction* input,
Vladimir Marko0ebe0d82017-09-21 22:50:39 +0100491 DataType::Type packed_type,
Aart Bikf8f5a162017-02-06 15:35:29 -0800492 size_t vector_length,
Aart Bik46b6dbc2017-10-03 11:37:37 -0700493 uint32_t dex_pc)
Gupta Kumar, Sanjivd9e4d732018-02-05 13:35:03 +0530494 : HVecUnaryOperation(kVecNot, allocator, input, packed_type, vector_length, dex_pc) {
Aart Bikf8f5a162017-02-06 15:35:29 -0800495 DCHECK(input->IsVecOperation());
Aart Bikf8f5a162017-02-06 15:35:29 -0800496 }
Aart Bikb79f4ac2017-07-10 10:10:37 -0700497
498 bool CanBeMoved() const OVERRIDE { return true; }
499
Aart Bikf8f5a162017-02-06 15:35:29 -0800500 DECLARE_INSTRUCTION(VecNot);
Aart Bikb79f4ac2017-07-10 10:10:37 -0700501
Artem Serovcced8ba2017-07-19 18:18:09 +0100502 protected:
503 DEFAULT_COPY_CONSTRUCTOR(VecNot);
Aart Bikf8f5a162017-02-06 15:35:29 -0800504};
505
Aart Bik8de59162017-04-21 09:42:01 -0700506//
507// Definitions of concrete binary vector operations in HIR.
508//
509
Aart Bikf8f5a162017-02-06 15:35:29 -0800510// Adds every component in the two vectors,
511// viz. [ x1, .. , xn ] + [ y1, .. , yn ] = [ x1 + y1, .. , xn + yn ].
512class HVecAdd FINAL : public HVecBinaryOperation {
513 public:
Vladimir Markoe764d2e2017-10-05 14:35:55 +0100514 HVecAdd(ArenaAllocator* allocator,
Aart Bikf8f5a162017-02-06 15:35:29 -0800515 HInstruction* left,
516 HInstruction* right,
Vladimir Marko0ebe0d82017-09-21 22:50:39 +0100517 DataType::Type packed_type,
Aart Bikf8f5a162017-02-06 15:35:29 -0800518 size_t vector_length,
Aart Bik46b6dbc2017-10-03 11:37:37 -0700519 uint32_t dex_pc)
Gupta Kumar, Sanjivd9e4d732018-02-05 13:35:03 +0530520 : HVecBinaryOperation(kVecAdd, allocator, left, right, packed_type, vector_length, dex_pc) {
Aart Bikd58bc322017-05-01 14:49:18 -0700521 DCHECK(HasConsistentPackedTypes(left, packed_type));
522 DCHECK(HasConsistentPackedTypes(right, packed_type));
Aart Bikf8f5a162017-02-06 15:35:29 -0800523 }
Aart Bikb79f4ac2017-07-10 10:10:37 -0700524
525 bool CanBeMoved() const OVERRIDE { return true; }
526
Aart Bikf8f5a162017-02-06 15:35:29 -0800527 DECLARE_INSTRUCTION(VecAdd);
Aart Bikb79f4ac2017-07-10 10:10:37 -0700528
Artem Serovcced8ba2017-07-19 18:18:09 +0100529 protected:
530 DEFAULT_COPY_CONSTRUCTOR(VecAdd);
Aart Bikf8f5a162017-02-06 15:35:29 -0800531};
532
Aart Bikf3e61ee2017-04-12 17:09:20 -0700533// Performs halving add on every component in the two vectors, viz.
Aart Bikdbbac8f2017-09-01 13:06:08 -0700534// rounded [ x1, .. , xn ] hradd [ y1, .. , yn ] = [ (x1 + y1 + 1) >> 1, .. , (xn + yn + 1) >> 1 ]
535// truncated [ x1, .. , xn ] hadd [ y1, .. , yn ] = [ (x1 + y1) >> 1, .. , (xn + yn ) >> 1 ]
Aart Bik66c158e2018-01-31 12:55:04 -0800536// for either both signed or both unsigned operands x, y (reflected in packed_type).
Aart Bikf3e61ee2017-04-12 17:09:20 -0700537class HVecHalvingAdd FINAL : public HVecBinaryOperation {
538 public:
Vladimir Markoe764d2e2017-10-05 14:35:55 +0100539 HVecHalvingAdd(ArenaAllocator* allocator,
Aart Bikf3e61ee2017-04-12 17:09:20 -0700540 HInstruction* left,
541 HInstruction* right,
Vladimir Marko0ebe0d82017-09-21 22:50:39 +0100542 DataType::Type packed_type,
Aart Bikf3e61ee2017-04-12 17:09:20 -0700543 size_t vector_length,
Aart Bikf3e61ee2017-04-12 17:09:20 -0700544 bool is_rounded,
Aart Bik46b6dbc2017-10-03 11:37:37 -0700545 uint32_t dex_pc)
Gupta Kumar, Sanjivd9e4d732018-02-05 13:35:03 +0530546 : HVecBinaryOperation(
547 kVecHalvingAdd, allocator, left, right, packed_type, vector_length, dex_pc) {
Aart Bikd58bc322017-05-01 14:49:18 -0700548 DCHECK(HasConsistentPackedTypes(left, packed_type));
549 DCHECK(HasConsistentPackedTypes(right, packed_type));
Aart Bikdb14fcf2017-04-25 15:53:58 -0700550 SetPackedFlag<kFieldHAddIsRounded>(is_rounded);
Aart Bikf3e61ee2017-04-12 17:09:20 -0700551 }
552
Aart Bikdb14fcf2017-04-25 15:53:58 -0700553 bool IsRounded() const { return GetPackedFlag<kFieldHAddIsRounded>(); }
Aart Bikf3e61ee2017-04-12 17:09:20 -0700554
Aart Bikb79f4ac2017-07-10 10:10:37 -0700555 bool CanBeMoved() const OVERRIDE { return true; }
556
557 bool InstructionDataEquals(const HInstruction* other) const OVERRIDE {
558 DCHECK(other->IsVecHalvingAdd());
559 const HVecHalvingAdd* o = other->AsVecHalvingAdd();
Aart Bik66c158e2018-01-31 12:55:04 -0800560 return HVecOperation::InstructionDataEquals(o) && IsRounded() == o->IsRounded();
Aart Bikb79f4ac2017-07-10 10:10:37 -0700561 }
562
Aart Bikf3e61ee2017-04-12 17:09:20 -0700563 DECLARE_INSTRUCTION(VecHalvingAdd);
564
Artem Serovcced8ba2017-07-19 18:18:09 +0100565 protected:
566 DEFAULT_COPY_CONSTRUCTOR(VecHalvingAdd);
567
Aart Bikf3e61ee2017-04-12 17:09:20 -0700568 private:
Aart Bikdb14fcf2017-04-25 15:53:58 -0700569 // Additional packed bits.
Aart Bik66c158e2018-01-31 12:55:04 -0800570 static constexpr size_t kFieldHAddIsRounded = HVecOperation::kNumberOfVectorOpPackedBits;
Aart Bikdb14fcf2017-04-25 15:53:58 -0700571 static constexpr size_t kNumberOfHAddPackedBits = kFieldHAddIsRounded + 1;
572 static_assert(kNumberOfHAddPackedBits <= kMaxNumberOfPackedBits, "Too many packed fields.");
Aart Bikf3e61ee2017-04-12 17:09:20 -0700573};
574
Aart Bikf8f5a162017-02-06 15:35:29 -0800575// Subtracts every component in the two vectors,
576// viz. [ x1, .. , xn ] - [ y1, .. , yn ] = [ x1 - y1, .. , xn - yn ].
577class HVecSub FINAL : public HVecBinaryOperation {
578 public:
Vladimir Markoe764d2e2017-10-05 14:35:55 +0100579 HVecSub(ArenaAllocator* allocator,
Aart Bikf8f5a162017-02-06 15:35:29 -0800580 HInstruction* left,
581 HInstruction* right,
Vladimir Marko0ebe0d82017-09-21 22:50:39 +0100582 DataType::Type packed_type,
Aart Bikf8f5a162017-02-06 15:35:29 -0800583 size_t vector_length,
Aart Bik46b6dbc2017-10-03 11:37:37 -0700584 uint32_t dex_pc)
Gupta Kumar, Sanjivd9e4d732018-02-05 13:35:03 +0530585 : HVecBinaryOperation(kVecSub, allocator, left, right, packed_type, vector_length, dex_pc) {
Aart Bikd58bc322017-05-01 14:49:18 -0700586 DCHECK(HasConsistentPackedTypes(left, packed_type));
587 DCHECK(HasConsistentPackedTypes(right, packed_type));
Aart Bikf8f5a162017-02-06 15:35:29 -0800588 }
Aart Bikb79f4ac2017-07-10 10:10:37 -0700589
590 bool CanBeMoved() const OVERRIDE { return true; }
591
Aart Bikf8f5a162017-02-06 15:35:29 -0800592 DECLARE_INSTRUCTION(VecSub);
Aart Bikb79f4ac2017-07-10 10:10:37 -0700593
Artem Serovcced8ba2017-07-19 18:18:09 +0100594 protected:
595 DEFAULT_COPY_CONSTRUCTOR(VecSub);
Aart Bikf8f5a162017-02-06 15:35:29 -0800596};
597
598// Multiplies every component in the two vectors,
599// viz. [ x1, .. , xn ] * [ y1, .. , yn ] = [ x1 * y1, .. , xn * yn ].
600class HVecMul FINAL : public HVecBinaryOperation {
601 public:
Vladimir Markoe764d2e2017-10-05 14:35:55 +0100602 HVecMul(ArenaAllocator* allocator,
Aart Bikf8f5a162017-02-06 15:35:29 -0800603 HInstruction* left,
604 HInstruction* right,
Vladimir Marko0ebe0d82017-09-21 22:50:39 +0100605 DataType::Type packed_type,
Aart Bikf8f5a162017-02-06 15:35:29 -0800606 size_t vector_length,
Aart Bik46b6dbc2017-10-03 11:37:37 -0700607 uint32_t dex_pc)
Gupta Kumar, Sanjivd9e4d732018-02-05 13:35:03 +0530608 : HVecBinaryOperation(kVecMul, allocator, left, right, packed_type, vector_length, dex_pc) {
Aart Bikd58bc322017-05-01 14:49:18 -0700609 DCHECK(HasConsistentPackedTypes(left, packed_type));
610 DCHECK(HasConsistentPackedTypes(right, packed_type));
Aart Bikf8f5a162017-02-06 15:35:29 -0800611 }
Aart Bikb79f4ac2017-07-10 10:10:37 -0700612
613 bool CanBeMoved() const OVERRIDE { return true; }
614
Aart Bikf8f5a162017-02-06 15:35:29 -0800615 DECLARE_INSTRUCTION(VecMul);
Aart Bikb79f4ac2017-07-10 10:10:37 -0700616
Artem Serovcced8ba2017-07-19 18:18:09 +0100617 protected:
618 DEFAULT_COPY_CONSTRUCTOR(VecMul);
Aart Bikf8f5a162017-02-06 15:35:29 -0800619};
620
621// Divides every component in the two vectors,
622// viz. [ x1, .. , xn ] / [ y1, .. , yn ] = [ x1 / y1, .. , xn / yn ].
623class HVecDiv FINAL : public HVecBinaryOperation {
624 public:
Vladimir Markoe764d2e2017-10-05 14:35:55 +0100625 HVecDiv(ArenaAllocator* allocator,
Aart Bikf8f5a162017-02-06 15:35:29 -0800626 HInstruction* left,
627 HInstruction* right,
Vladimir Marko0ebe0d82017-09-21 22:50:39 +0100628 DataType::Type packed_type,
Aart Bikf8f5a162017-02-06 15:35:29 -0800629 size_t vector_length,
Aart Bik46b6dbc2017-10-03 11:37:37 -0700630 uint32_t dex_pc)
Gupta Kumar, Sanjivd9e4d732018-02-05 13:35:03 +0530631 : HVecBinaryOperation(kVecDiv, allocator, left, right, packed_type, vector_length, dex_pc) {
Aart Bikd58bc322017-05-01 14:49:18 -0700632 DCHECK(HasConsistentPackedTypes(left, packed_type));
633 DCHECK(HasConsistentPackedTypes(right, packed_type));
Aart Bikf8f5a162017-02-06 15:35:29 -0800634 }
Aart Bikb79f4ac2017-07-10 10:10:37 -0700635
636 bool CanBeMoved() const OVERRIDE { return true; }
637
Aart Bikf8f5a162017-02-06 15:35:29 -0800638 DECLARE_INSTRUCTION(VecDiv);
Aart Bikb79f4ac2017-07-10 10:10:37 -0700639
Artem Serovcced8ba2017-07-19 18:18:09 +0100640 protected:
641 DEFAULT_COPY_CONSTRUCTOR(VecDiv);
Aart Bikf8f5a162017-02-06 15:35:29 -0800642};
643
Aart Bikf3e61ee2017-04-12 17:09:20 -0700644// Takes minimum of every component in the two vectors,
Aart Bik46b6dbc2017-10-03 11:37:37 -0700645// viz. MIN( [ x1, .. , xn ] , [ y1, .. , yn ]) = [ min(x1, y1), .. , min(xn, yn) ]
Aart Bik66c158e2018-01-31 12:55:04 -0800646// for either both signed or both unsigned operands x, y (reflected in packed_type).
Aart Bikf3e61ee2017-04-12 17:09:20 -0700647class HVecMin FINAL : public HVecBinaryOperation {
648 public:
Vladimir Markoe764d2e2017-10-05 14:35:55 +0100649 HVecMin(ArenaAllocator* allocator,
Aart Bikf3e61ee2017-04-12 17:09:20 -0700650 HInstruction* left,
651 HInstruction* right,
Vladimir Marko0ebe0d82017-09-21 22:50:39 +0100652 DataType::Type packed_type,
Aart Bikf3e61ee2017-04-12 17:09:20 -0700653 size_t vector_length,
Aart Bik46b6dbc2017-10-03 11:37:37 -0700654 uint32_t dex_pc)
Gupta Kumar, Sanjivd9e4d732018-02-05 13:35:03 +0530655 : HVecBinaryOperation(kVecMin, allocator, left, right, packed_type, vector_length, dex_pc) {
Aart Bikd58bc322017-05-01 14:49:18 -0700656 DCHECK(HasConsistentPackedTypes(left, packed_type));
657 DCHECK(HasConsistentPackedTypes(right, packed_type));
Aart Bikf3e61ee2017-04-12 17:09:20 -0700658 }
Aart Bikc8e93c72017-05-10 10:49:22 -0700659
Aart Bikb79f4ac2017-07-10 10:10:37 -0700660 bool CanBeMoved() const OVERRIDE { return true; }
661
Aart Bikf3e61ee2017-04-12 17:09:20 -0700662 DECLARE_INSTRUCTION(VecMin);
Aart Bikc8e93c72017-05-10 10:49:22 -0700663
Artem Serovcced8ba2017-07-19 18:18:09 +0100664 protected:
665 DEFAULT_COPY_CONSTRUCTOR(VecMin);
Aart Bikf3e61ee2017-04-12 17:09:20 -0700666};
667
668// Takes maximum of every component in the two vectors,
Aart Bik46b6dbc2017-10-03 11:37:37 -0700669// viz. MAX( [ x1, .. , xn ] , [ y1, .. , yn ]) = [ max(x1, y1), .. , max(xn, yn) ]
Aart Bik66c158e2018-01-31 12:55:04 -0800670// for either both signed or both unsigned operands x, y (reflected in packed_type).
Aart Bikf3e61ee2017-04-12 17:09:20 -0700671class HVecMax FINAL : public HVecBinaryOperation {
672 public:
Vladimir Markoe764d2e2017-10-05 14:35:55 +0100673 HVecMax(ArenaAllocator* allocator,
Aart Bikf3e61ee2017-04-12 17:09:20 -0700674 HInstruction* left,
675 HInstruction* right,
Vladimir Marko0ebe0d82017-09-21 22:50:39 +0100676 DataType::Type packed_type,
Aart Bikf3e61ee2017-04-12 17:09:20 -0700677 size_t vector_length,
Aart Bik46b6dbc2017-10-03 11:37:37 -0700678 uint32_t dex_pc)
Gupta Kumar, Sanjivd9e4d732018-02-05 13:35:03 +0530679 : HVecBinaryOperation(kVecMax, allocator, left, right, packed_type, vector_length, dex_pc) {
Aart Bikd58bc322017-05-01 14:49:18 -0700680 DCHECK(HasConsistentPackedTypes(left, packed_type));
681 DCHECK(HasConsistentPackedTypes(right, packed_type));
Aart Bikf3e61ee2017-04-12 17:09:20 -0700682 }
Aart Bikc8e93c72017-05-10 10:49:22 -0700683
Aart Bikb79f4ac2017-07-10 10:10:37 -0700684 bool CanBeMoved() const OVERRIDE { return true; }
685
Aart Bikf3e61ee2017-04-12 17:09:20 -0700686 DECLARE_INSTRUCTION(VecMax);
Aart Bikc8e93c72017-05-10 10:49:22 -0700687
Artem Serovcced8ba2017-07-19 18:18:09 +0100688 protected:
689 DEFAULT_COPY_CONSTRUCTOR(VecMax);
Aart Bikf3e61ee2017-04-12 17:09:20 -0700690};
691
Aart Bikf8f5a162017-02-06 15:35:29 -0800692// Bitwise-ands every component in the two vectors,
693// viz. [ x1, .. , xn ] & [ y1, .. , yn ] = [ x1 & y1, .. , xn & yn ].
694class HVecAnd FINAL : public HVecBinaryOperation {
695 public:
Vladimir Markoe764d2e2017-10-05 14:35:55 +0100696 HVecAnd(ArenaAllocator* allocator,
Aart Bikf8f5a162017-02-06 15:35:29 -0800697 HInstruction* left,
698 HInstruction* right,
Vladimir Marko0ebe0d82017-09-21 22:50:39 +0100699 DataType::Type packed_type,
Aart Bikf8f5a162017-02-06 15:35:29 -0800700 size_t vector_length,
Aart Bik46b6dbc2017-10-03 11:37:37 -0700701 uint32_t dex_pc)
Gupta Kumar, Sanjivd9e4d732018-02-05 13:35:03 +0530702 : HVecBinaryOperation(kVecAnd, allocator, left, right, packed_type, vector_length, dex_pc) {
Aart Bikf8f5a162017-02-06 15:35:29 -0800703 DCHECK(left->IsVecOperation() && right->IsVecOperation());
Aart Bikf8f5a162017-02-06 15:35:29 -0800704 }
Aart Bikb79f4ac2017-07-10 10:10:37 -0700705
706 bool CanBeMoved() const OVERRIDE { return true; }
707
Aart Bikf8f5a162017-02-06 15:35:29 -0800708 DECLARE_INSTRUCTION(VecAnd);
Aart Bikb79f4ac2017-07-10 10:10:37 -0700709
Artem Serovcced8ba2017-07-19 18:18:09 +0100710 protected:
711 DEFAULT_COPY_CONSTRUCTOR(VecAnd);
Aart Bikf8f5a162017-02-06 15:35:29 -0800712};
713
714// Bitwise-and-nots every component in the two vectors,
715// viz. [ x1, .. , xn ] and-not [ y1, .. , yn ] = [ ~x1 & y1, .. , ~xn & yn ].
716class HVecAndNot FINAL : public HVecBinaryOperation {
717 public:
Vladimir Markoe764d2e2017-10-05 14:35:55 +0100718 HVecAndNot(ArenaAllocator* allocator,
Aart Bikf8f5a162017-02-06 15:35:29 -0800719 HInstruction* left,
720 HInstruction* right,
Vladimir Marko0ebe0d82017-09-21 22:50:39 +0100721 DataType::Type packed_type,
Aart Bikf8f5a162017-02-06 15:35:29 -0800722 size_t vector_length,
Aart Bik46b6dbc2017-10-03 11:37:37 -0700723 uint32_t dex_pc)
Gupta Kumar, Sanjivd9e4d732018-02-05 13:35:03 +0530724 : HVecBinaryOperation(
725 kVecAndNot, allocator, left, right, packed_type, vector_length, dex_pc) {
Aart Bikf8f5a162017-02-06 15:35:29 -0800726 DCHECK(left->IsVecOperation() && right->IsVecOperation());
Aart Bikf8f5a162017-02-06 15:35:29 -0800727 }
Aart Bikb79f4ac2017-07-10 10:10:37 -0700728
729 bool CanBeMoved() const OVERRIDE { return true; }
730
Aart Bikf8f5a162017-02-06 15:35:29 -0800731 DECLARE_INSTRUCTION(VecAndNot);
Aart Bikb79f4ac2017-07-10 10:10:37 -0700732
Artem Serovcced8ba2017-07-19 18:18:09 +0100733 protected:
734 DEFAULT_COPY_CONSTRUCTOR(VecAndNot);
Aart Bikf8f5a162017-02-06 15:35:29 -0800735};
736
737// Bitwise-ors every component in the two vectors,
738// viz. [ x1, .. , xn ] | [ y1, .. , yn ] = [ x1 | y1, .. , xn | yn ].
739class HVecOr FINAL : public HVecBinaryOperation {
740 public:
Vladimir Markoe764d2e2017-10-05 14:35:55 +0100741 HVecOr(ArenaAllocator* allocator,
Aart Bikf8f5a162017-02-06 15:35:29 -0800742 HInstruction* left,
743 HInstruction* right,
Vladimir Marko0ebe0d82017-09-21 22:50:39 +0100744 DataType::Type packed_type,
Aart Bikf8f5a162017-02-06 15:35:29 -0800745 size_t vector_length,
Aart Bik46b6dbc2017-10-03 11:37:37 -0700746 uint32_t dex_pc)
Gupta Kumar, Sanjivd9e4d732018-02-05 13:35:03 +0530747 : HVecBinaryOperation(kVecOr, allocator, left, right, packed_type, vector_length, dex_pc) {
Aart Bikf8f5a162017-02-06 15:35:29 -0800748 DCHECK(left->IsVecOperation() && right->IsVecOperation());
Aart Bikf8f5a162017-02-06 15:35:29 -0800749 }
Aart Bikb79f4ac2017-07-10 10:10:37 -0700750
751 bool CanBeMoved() const OVERRIDE { return true; }
752
Aart Bikf8f5a162017-02-06 15:35:29 -0800753 DECLARE_INSTRUCTION(VecOr);
Aart Bikb79f4ac2017-07-10 10:10:37 -0700754
Artem Serovcced8ba2017-07-19 18:18:09 +0100755 protected:
756 DEFAULT_COPY_CONSTRUCTOR(VecOr);
Aart Bikf8f5a162017-02-06 15:35:29 -0800757};
758
759// Bitwise-xors every component in the two vectors,
760// viz. [ x1, .. , xn ] ^ [ y1, .. , yn ] = [ x1 ^ y1, .. , xn ^ yn ].
761class HVecXor FINAL : public HVecBinaryOperation {
762 public:
Vladimir Markoe764d2e2017-10-05 14:35:55 +0100763 HVecXor(ArenaAllocator* allocator,
Aart Bikf8f5a162017-02-06 15:35:29 -0800764 HInstruction* left,
765 HInstruction* right,
Vladimir Marko0ebe0d82017-09-21 22:50:39 +0100766 DataType::Type packed_type,
Aart Bikf8f5a162017-02-06 15:35:29 -0800767 size_t vector_length,
Aart Bik46b6dbc2017-10-03 11:37:37 -0700768 uint32_t dex_pc)
Gupta Kumar, Sanjivd9e4d732018-02-05 13:35:03 +0530769 : HVecBinaryOperation(kVecXor, allocator, left, right, packed_type, vector_length, dex_pc) {
Aart Bikf8f5a162017-02-06 15:35:29 -0800770 DCHECK(left->IsVecOperation() && right->IsVecOperation());
Aart Bikf8f5a162017-02-06 15:35:29 -0800771 }
Aart Bikb79f4ac2017-07-10 10:10:37 -0700772
773 bool CanBeMoved() const OVERRIDE { return true; }
774
Aart Bikf8f5a162017-02-06 15:35:29 -0800775 DECLARE_INSTRUCTION(VecXor);
Aart Bikb79f4ac2017-07-10 10:10:37 -0700776
Artem Serovcced8ba2017-07-19 18:18:09 +0100777 protected:
778 DEFAULT_COPY_CONSTRUCTOR(VecXor);
Aart Bikf8f5a162017-02-06 15:35:29 -0800779};
780
781// Logically shifts every component in the vector left by the given distance,
782// viz. [ x1, .. , xn ] << d = [ x1 << d, .. , xn << d ].
783class HVecShl FINAL : public HVecBinaryOperation {
784 public:
Vladimir Markoe764d2e2017-10-05 14:35:55 +0100785 HVecShl(ArenaAllocator* allocator,
Aart Bikf8f5a162017-02-06 15:35:29 -0800786 HInstruction* left,
787 HInstruction* right,
Vladimir Marko0ebe0d82017-09-21 22:50:39 +0100788 DataType::Type packed_type,
Aart Bikf8f5a162017-02-06 15:35:29 -0800789 size_t vector_length,
Aart Bik46b6dbc2017-10-03 11:37:37 -0700790 uint32_t dex_pc)
Gupta Kumar, Sanjivd9e4d732018-02-05 13:35:03 +0530791 : HVecBinaryOperation(kVecShl, allocator, left, right, packed_type, vector_length, dex_pc) {
Aart Bikd58bc322017-05-01 14:49:18 -0700792 DCHECK(HasConsistentPackedTypes(left, packed_type));
Aart Bikf8f5a162017-02-06 15:35:29 -0800793 }
Aart Bikb79f4ac2017-07-10 10:10:37 -0700794
795 bool CanBeMoved() const OVERRIDE { return true; }
796
Aart Bikf8f5a162017-02-06 15:35:29 -0800797 DECLARE_INSTRUCTION(VecShl);
Aart Bikb79f4ac2017-07-10 10:10:37 -0700798
Artem Serovcced8ba2017-07-19 18:18:09 +0100799 protected:
800 DEFAULT_COPY_CONSTRUCTOR(VecShl);
Aart Bikf8f5a162017-02-06 15:35:29 -0800801};
802
803// Arithmetically shifts every component in the vector right by the given distance,
804// viz. [ x1, .. , xn ] >> d = [ x1 >> d, .. , xn >> d ].
805class HVecShr FINAL : public HVecBinaryOperation {
806 public:
Vladimir Markoe764d2e2017-10-05 14:35:55 +0100807 HVecShr(ArenaAllocator* allocator,
Aart Bikf8f5a162017-02-06 15:35:29 -0800808 HInstruction* left,
809 HInstruction* right,
Vladimir Marko0ebe0d82017-09-21 22:50:39 +0100810 DataType::Type packed_type,
Aart Bikf8f5a162017-02-06 15:35:29 -0800811 size_t vector_length,
Aart Bik46b6dbc2017-10-03 11:37:37 -0700812 uint32_t dex_pc)
Gupta Kumar, Sanjivd9e4d732018-02-05 13:35:03 +0530813 : HVecBinaryOperation(kVecShr, allocator, left, right, packed_type, vector_length, dex_pc) {
Aart Bikd58bc322017-05-01 14:49:18 -0700814 DCHECK(HasConsistentPackedTypes(left, packed_type));
Aart Bikf8f5a162017-02-06 15:35:29 -0800815 }
Aart Bikb79f4ac2017-07-10 10:10:37 -0700816
817 bool CanBeMoved() const OVERRIDE { return true; }
818
Aart Bikf8f5a162017-02-06 15:35:29 -0800819 DECLARE_INSTRUCTION(VecShr);
Aart Bikb79f4ac2017-07-10 10:10:37 -0700820
Artem Serovcced8ba2017-07-19 18:18:09 +0100821 protected:
822 DEFAULT_COPY_CONSTRUCTOR(VecShr);
Aart Bikf8f5a162017-02-06 15:35:29 -0800823};
824
825// Logically shifts every component in the vector right by the given distance,
826// viz. [ x1, .. , xn ] >>> d = [ x1 >>> d, .. , xn >>> d ].
827class HVecUShr FINAL : public HVecBinaryOperation {
828 public:
Vladimir Markoe764d2e2017-10-05 14:35:55 +0100829 HVecUShr(ArenaAllocator* allocator,
Aart Bikf8f5a162017-02-06 15:35:29 -0800830 HInstruction* left,
831 HInstruction* right,
Vladimir Marko0ebe0d82017-09-21 22:50:39 +0100832 DataType::Type packed_type,
Aart Bikf8f5a162017-02-06 15:35:29 -0800833 size_t vector_length,
Aart Bik46b6dbc2017-10-03 11:37:37 -0700834 uint32_t dex_pc)
Gupta Kumar, Sanjivd9e4d732018-02-05 13:35:03 +0530835 : HVecBinaryOperation(kVecUShr, allocator, left, right, packed_type, vector_length, dex_pc) {
Aart Bikd58bc322017-05-01 14:49:18 -0700836 DCHECK(HasConsistentPackedTypes(left, packed_type));
Aart Bikf8f5a162017-02-06 15:35:29 -0800837 }
Aart Bikb79f4ac2017-07-10 10:10:37 -0700838
839 bool CanBeMoved() const OVERRIDE { return true; }
840
Aart Bikf8f5a162017-02-06 15:35:29 -0800841 DECLARE_INSTRUCTION(VecUShr);
Aart Bikb79f4ac2017-07-10 10:10:37 -0700842
Artem Serovcced8ba2017-07-19 18:18:09 +0100843 protected:
844 DEFAULT_COPY_CONSTRUCTOR(VecUShr);
Aart Bikf8f5a162017-02-06 15:35:29 -0800845};
846
Aart Bik8de59162017-04-21 09:42:01 -0700847//
848// Definitions of concrete miscellaneous vector operations in HIR.
849//
850
851// Assigns the given scalar elements to a vector,
Aart Bikdbbac8f2017-09-01 13:06:08 -0700852// viz. set( array(x1, .. , xn) ) = [ x1, .. , xn ] if n == m,
853// set( array(x1, .. , xm) ) = [ x1, .. , xm, 0, .. , 0 ] if m < n.
Aart Bik8de59162017-04-21 09:42:01 -0700854class HVecSetScalars FINAL : public HVecOperation {
Aart Bik0148de42017-09-05 09:25:01 -0700855 public:
Vladimir Markoe764d2e2017-10-05 14:35:55 +0100856 HVecSetScalars(ArenaAllocator* allocator,
Aart Bik5e3afa92017-09-20 14:11:11 -0700857 HInstruction* scalars[],
Vladimir Marko0ebe0d82017-09-21 22:50:39 +0100858 DataType::Type packed_type,
Aart Bik8de59162017-04-21 09:42:01 -0700859 size_t vector_length,
Aart Bik0148de42017-09-05 09:25:01 -0700860 size_t number_of_scalars,
Aart Bik46b6dbc2017-10-03 11:37:37 -0700861 uint32_t dex_pc)
Gupta Kumar, Sanjivd9e4d732018-02-05 13:35:03 +0530862 : HVecOperation(kVecSetScalars,
863 allocator,
Aart Bik8de59162017-04-21 09:42:01 -0700864 packed_type,
865 SideEffects::None(),
Aart Bik0148de42017-09-05 09:25:01 -0700866 number_of_scalars,
Aart Bik8de59162017-04-21 09:42:01 -0700867 vector_length,
868 dex_pc) {
Aart Bik0148de42017-09-05 09:25:01 -0700869 for (size_t i = 0; i < number_of_scalars; i++) {
Aart Bik2dd7b672017-12-07 11:11:22 -0800870 DCHECK(!ReturnsSIMDValue(scalars[i]));
Aart Bik8de59162017-04-21 09:42:01 -0700871 SetRawInputAt(0, scalars[i]);
872 }
873 }
Aart Bikb79f4ac2017-07-10 10:10:37 -0700874
875 // Setting scalars needs to stay in place, since SIMD registers are not
876 // kept alive across vector loop boundaries (yet).
877 bool CanBeMoved() const OVERRIDE { return false; }
878
Aart Bik8de59162017-04-21 09:42:01 -0700879 DECLARE_INSTRUCTION(VecSetScalars);
Aart Bikb79f4ac2017-07-10 10:10:37 -0700880
Artem Serovcced8ba2017-07-19 18:18:09 +0100881 protected:
882 DEFAULT_COPY_CONSTRUCTOR(VecSetScalars);
Aart Bik8de59162017-04-21 09:42:01 -0700883};
884
Aart Bikdbbac8f2017-09-01 13:06:08 -0700885// Multiplies every component in the two vectors, adds the result vector to the accumulator vector,
886// viz. [ a1, .. , an ] + [ x1, .. , xn ] * [ y1, .. , yn ] = [ a1 + x1 * y1, .. , an + xn * yn ].
Artem Serovf34dd202017-04-10 17:41:46 +0100887class HVecMultiplyAccumulate FINAL : public HVecOperation {
888 public:
Vladimir Markoe764d2e2017-10-05 14:35:55 +0100889 HVecMultiplyAccumulate(ArenaAllocator* allocator,
Artem Serovf34dd202017-04-10 17:41:46 +0100890 InstructionKind op,
891 HInstruction* accumulator,
892 HInstruction* mul_left,
893 HInstruction* mul_right,
Vladimir Marko0ebe0d82017-09-21 22:50:39 +0100894 DataType::Type packed_type,
Artem Serovf34dd202017-04-10 17:41:46 +0100895 size_t vector_length,
Aart Bik46b6dbc2017-10-03 11:37:37 -0700896 uint32_t dex_pc)
Gupta Kumar, Sanjivd9e4d732018-02-05 13:35:03 +0530897 : HVecOperation(kVecMultiplyAccumulate,
898 allocator,
Artem Serovf34dd202017-04-10 17:41:46 +0100899 packed_type,
900 SideEffects::None(),
Aart Bik8de59162017-04-21 09:42:01 -0700901 /* number_of_inputs */ 3,
Artem Serovf34dd202017-04-10 17:41:46 +0100902 vector_length,
903 dex_pc),
904 op_kind_(op) {
905 DCHECK(op == InstructionKind::kAdd || op == InstructionKind::kSub);
Aart Bikd58bc322017-05-01 14:49:18 -0700906 DCHECK(HasConsistentPackedTypes(accumulator, packed_type));
907 DCHECK(HasConsistentPackedTypes(mul_left, packed_type));
908 DCHECK(HasConsistentPackedTypes(mul_right, packed_type));
Aart Bikdbbac8f2017-09-01 13:06:08 -0700909 SetRawInputAt(0, accumulator);
910 SetRawInputAt(1, mul_left);
911 SetRawInputAt(2, mul_right);
Artem Serovf34dd202017-04-10 17:41:46 +0100912 }
913
Nicolas Geoffray9858bf72017-07-08 12:34:55 +0000914 bool CanBeMoved() const OVERRIDE { return true; }
915
Artem Serovf34dd202017-04-10 17:41:46 +0100916 bool InstructionDataEquals(const HInstruction* other) const OVERRIDE {
Aart Bikb79f4ac2017-07-10 10:10:37 -0700917 DCHECK(other->IsVecMultiplyAccumulate());
918 const HVecMultiplyAccumulate* o = other->AsVecMultiplyAccumulate();
919 return HVecOperation::InstructionDataEquals(o) && GetOpKind() == o->GetOpKind();
Artem Serovf34dd202017-04-10 17:41:46 +0100920 }
921
922 InstructionKind GetOpKind() const { return op_kind_; }
923
924 DECLARE_INSTRUCTION(VecMultiplyAccumulate);
925
Artem Serovcced8ba2017-07-19 18:18:09 +0100926 protected:
927 DEFAULT_COPY_CONSTRUCTOR(VecMultiplyAccumulate);
928
Artem Serovf34dd202017-04-10 17:41:46 +0100929 private:
930 // Indicates if this is a MADD or MSUB.
931 const InstructionKind op_kind_;
Artem Serovf34dd202017-04-10 17:41:46 +0100932};
933
Aart Bikdbbac8f2017-09-01 13:06:08 -0700934// Takes the absolute difference of two vectors, and adds the results to
935// same-precision or wider-precision components in the accumulator,
Aart Bik46b6dbc2017-10-03 11:37:37 -0700936// viz. SAD([ a1, .. , am ], [ x1, .. , xn ], [ y1, .. , yn ]) =
Aart Bikdbbac8f2017-09-01 13:06:08 -0700937// [ a1 + sum abs(xi-yi), .. , am + sum abs(xj-yj) ],
Aart Bik46b6dbc2017-10-03 11:37:37 -0700938// for m <= n, non-overlapping sums, and signed operands x, y.
Aart Bikdbbac8f2017-09-01 13:06:08 -0700939class HVecSADAccumulate FINAL : public HVecOperation {
940 public:
Vladimir Markoe764d2e2017-10-05 14:35:55 +0100941 HVecSADAccumulate(ArenaAllocator* allocator,
Aart Bikdbbac8f2017-09-01 13:06:08 -0700942 HInstruction* accumulator,
943 HInstruction* sad_left,
944 HInstruction* sad_right,
Vladimir Marko0ebe0d82017-09-21 22:50:39 +0100945 DataType::Type packed_type,
Aart Bikdbbac8f2017-09-01 13:06:08 -0700946 size_t vector_length,
Aart Bik46b6dbc2017-10-03 11:37:37 -0700947 uint32_t dex_pc)
Gupta Kumar, Sanjivd9e4d732018-02-05 13:35:03 +0530948 : HVecOperation(kVecSADAccumulate,
949 allocator,
Aart Bikdbbac8f2017-09-01 13:06:08 -0700950 packed_type,
951 SideEffects::None(),
952 /* number_of_inputs */ 3,
953 vector_length,
954 dex_pc) {
955 DCHECK(HasConsistentPackedTypes(accumulator, packed_type));
956 DCHECK(sad_left->IsVecOperation());
957 DCHECK(sad_right->IsVecOperation());
Vladimir Marko61b92282017-10-11 13:23:17 +0100958 DCHECK_EQ(ToSignedType(sad_left->AsVecOperation()->GetPackedType()),
959 ToSignedType(sad_right->AsVecOperation()->GetPackedType()));
Aart Bikdbbac8f2017-09-01 13:06:08 -0700960 SetRawInputAt(0, accumulator);
961 SetRawInputAt(1, sad_left);
962 SetRawInputAt(2, sad_right);
963 }
964
965 DECLARE_INSTRUCTION(VecSADAccumulate);
966
Artem Serovcced8ba2017-07-19 18:18:09 +0100967 protected:
968 DEFAULT_COPY_CONSTRUCTOR(VecSADAccumulate);
Aart Bikdbbac8f2017-09-01 13:06:08 -0700969};
970
Aart Bikf8f5a162017-02-06 15:35:29 -0800971// Loads a vector from memory, viz. load(mem, 1)
972// yield the vector [ mem(1), .. , mem(n) ].
973class HVecLoad FINAL : public HVecMemoryOperation {
974 public:
Vladimir Markoe764d2e2017-10-05 14:35:55 +0100975 HVecLoad(ArenaAllocator* allocator,
Aart Bikf8f5a162017-02-06 15:35:29 -0800976 HInstruction* base,
977 HInstruction* index,
Vladimir Marko0ebe0d82017-09-21 22:50:39 +0100978 DataType::Type packed_type,
Vladimir Markod5d2f2c2017-09-26 12:37:26 +0100979 SideEffects side_effects,
Aart Bikf8f5a162017-02-06 15:35:29 -0800980 size_t vector_length,
Aart Bikdb14fcf2017-04-25 15:53:58 -0700981 bool is_string_char_at,
Aart Bik46b6dbc2017-10-03 11:37:37 -0700982 uint32_t dex_pc)
Gupta Kumar, Sanjivd9e4d732018-02-05 13:35:03 +0530983 : HVecMemoryOperation(kVecLoad,
984 allocator,
Aart Bikf8f5a162017-02-06 15:35:29 -0800985 packed_type,
Vladimir Markod5d2f2c2017-09-26 12:37:26 +0100986 side_effects,
Aart Bik8de59162017-04-21 09:42:01 -0700987 /* number_of_inputs */ 2,
Aart Bikf8f5a162017-02-06 15:35:29 -0800988 vector_length,
989 dex_pc) {
990 SetRawInputAt(0, base);
991 SetRawInputAt(1, index);
Aart Bikdb14fcf2017-04-25 15:53:58 -0700992 SetPackedFlag<kFieldIsStringCharAt>(is_string_char_at);
Aart Bikf8f5a162017-02-06 15:35:29 -0800993 }
Aart Bikdb14fcf2017-04-25 15:53:58 -0700994
995 bool IsStringCharAt() const { return GetPackedFlag<kFieldIsStringCharAt>(); }
996
Aart Bikb79f4ac2017-07-10 10:10:37 -0700997 bool CanBeMoved() const OVERRIDE { return true; }
998
999 bool InstructionDataEquals(const HInstruction* other) const OVERRIDE {
1000 DCHECK(other->IsVecLoad());
1001 const HVecLoad* o = other->AsVecLoad();
1002 return HVecMemoryOperation::InstructionDataEquals(o) && IsStringCharAt() == o->IsStringCharAt();
1003 }
1004
1005 DECLARE_INSTRUCTION(VecLoad);
1006
Artem Serovcced8ba2017-07-19 18:18:09 +01001007 protected:
1008 DEFAULT_COPY_CONSTRUCTOR(VecLoad);
1009
Aart Bikf8f5a162017-02-06 15:35:29 -08001010 private:
Aart Bikdb14fcf2017-04-25 15:53:58 -07001011 // Additional packed bits.
1012 static constexpr size_t kFieldIsStringCharAt = HVecOperation::kNumberOfVectorOpPackedBits;
1013 static constexpr size_t kNumberOfVecLoadPackedBits = kFieldIsStringCharAt + 1;
1014 static_assert(kNumberOfVecLoadPackedBits <= kMaxNumberOfPackedBits, "Too many packed fields.");
Aart Bikf8f5a162017-02-06 15:35:29 -08001015};
1016
1017// Stores a vector to memory, viz. store(m, 1, [x1, .. , xn] )
1018// sets mem(1) = x1, .. , mem(n) = xn.
1019class HVecStore FINAL : public HVecMemoryOperation {
1020 public:
Vladimir Markoe764d2e2017-10-05 14:35:55 +01001021 HVecStore(ArenaAllocator* allocator,
Aart Bikf8f5a162017-02-06 15:35:29 -08001022 HInstruction* base,
1023 HInstruction* index,
1024 HInstruction* value,
Vladimir Marko0ebe0d82017-09-21 22:50:39 +01001025 DataType::Type packed_type,
Vladimir Markod5d2f2c2017-09-26 12:37:26 +01001026 SideEffects side_effects,
Aart Bikf8f5a162017-02-06 15:35:29 -08001027 size_t vector_length,
Aart Bik46b6dbc2017-10-03 11:37:37 -07001028 uint32_t dex_pc)
Gupta Kumar, Sanjivd9e4d732018-02-05 13:35:03 +05301029 : HVecMemoryOperation(kVecStore,
1030 allocator,
Aart Bikf8f5a162017-02-06 15:35:29 -08001031 packed_type,
Vladimir Markod5d2f2c2017-09-26 12:37:26 +01001032 side_effects,
Aart Bik8de59162017-04-21 09:42:01 -07001033 /* number_of_inputs */ 3,
Aart Bikf8f5a162017-02-06 15:35:29 -08001034 vector_length,
1035 dex_pc) {
Aart Bikd58bc322017-05-01 14:49:18 -07001036 DCHECK(HasConsistentPackedTypes(value, packed_type));
Aart Bikf8f5a162017-02-06 15:35:29 -08001037 SetRawInputAt(0, base);
1038 SetRawInputAt(1, index);
1039 SetRawInputAt(2, value);
1040 }
Aart Bikb79f4ac2017-07-10 10:10:37 -07001041
1042 // A store needs to stay in place.
1043 bool CanBeMoved() const OVERRIDE { return false; }
1044
Aart Bikf8f5a162017-02-06 15:35:29 -08001045 DECLARE_INSTRUCTION(VecStore);
Aart Bikb79f4ac2017-07-10 10:10:37 -07001046
Artem Serovcced8ba2017-07-19 18:18:09 +01001047 protected:
1048 DEFAULT_COPY_CONSTRUCTOR(VecStore)
Aart Bikf8f5a162017-02-06 15:35:29 -08001049};
1050
1051} // namespace art
1052
1053#endif // ART_COMPILER_OPTIMIZING_NODES_VECTOR_H_