Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 1 | /* |
| 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 | |
| 24 | namespace 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. |
| 30 | class 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 Bik | 46b6dbc | 2017-10-03 11:37:37 -0700 | [diff] [blame] | 37 | // Returns true if memory is at least aligned at the given boundary. |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 38 | // 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 Bik | 46b6dbc | 2017-10-03 11:37:37 -0700 | [diff] [blame] | 45 | size_t Base() const { return base_; } |
| 46 | |
| 47 | size_t Offset() const { return offset_; } |
| 48 | |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 49 | std::string ToString() const { |
| 50 | return "ALIGN(" + std::to_string(base_) + "," + std::to_string(offset_) + ")"; |
| 51 | } |
| 52 | |
Aart Bik | b79f4ac | 2017-07-10 10:10:37 -0700 | [diff] [blame] | 53 | bool operator==(const Alignment& other) const { |
| 54 | return base_ == other.base_ && offset_ == other.offset_; |
| 55 | } |
| 56 | |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 57 | 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. |
| 68 | class HVecOperation : public HVariableInputSizeInstruction { |
| 69 | public: |
Aart Bik | 0148de4 | 2017-09-05 09:25:01 -0700 | [diff] [blame] | 70 | // A SIMD operation looks like a FPU location. |
| 71 | // TODO: we could introduce SIMD types in HIR. |
Vladimir Marko | 0ebe0d8 | 2017-09-21 22:50:39 +0100 | [diff] [blame] | 72 | static constexpr DataType::Type kSIMDType = DataType::Type::kFloat64; |
Aart Bik | 0148de4 | 2017-09-05 09:25:01 -0700 | [diff] [blame] | 73 | |
Vladimir Marko | e764d2e | 2017-10-05 14:35:55 +0100 | [diff] [blame] | 74 | HVecOperation(ArenaAllocator* allocator, |
Vladimir Marko | 0ebe0d8 | 2017-09-21 22:50:39 +0100 | [diff] [blame] | 75 | DataType::Type packed_type, |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 76 | SideEffects side_effects, |
| 77 | size_t number_of_inputs, |
| 78 | size_t vector_length, |
| 79 | uint32_t dex_pc) |
| 80 | : HVariableInputSizeInstruction(side_effects, |
| 81 | dex_pc, |
Vladimir Marko | e764d2e | 2017-10-05 14:35:55 +0100 | [diff] [blame] | 82 | allocator, |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 83 | number_of_inputs, |
| 84 | kArenaAllocVectorNode), |
| 85 | vector_length_(vector_length) { |
| 86 | SetPackedField<TypeField>(packed_type); |
| 87 | DCHECK_LT(1u, vector_length); |
| 88 | } |
| 89 | |
| 90 | // Returns the number of elements packed in a vector. |
| 91 | size_t GetVectorLength() const { |
| 92 | return vector_length_; |
| 93 | } |
| 94 | |
| 95 | // Returns the number of bytes in a full vector. |
| 96 | size_t GetVectorNumberOfBytes() const { |
Vladimir Marko | 0ebe0d8 | 2017-09-21 22:50:39 +0100 | [diff] [blame] | 97 | return vector_length_ * DataType::Size(GetPackedType()); |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 98 | } |
| 99 | |
Aart Bik | 0148de4 | 2017-09-05 09:25:01 -0700 | [diff] [blame] | 100 | // Returns the type of the vector operation. |
Vladimir Marko | 0ebe0d8 | 2017-09-21 22:50:39 +0100 | [diff] [blame] | 101 | DataType::Type GetType() const OVERRIDE { |
Aart Bik | 0148de4 | 2017-09-05 09:25:01 -0700 | [diff] [blame] | 102 | return kSIMDType; |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 103 | } |
| 104 | |
| 105 | // Returns the true component type packed in a vector. |
Vladimir Marko | 0ebe0d8 | 2017-09-21 22:50:39 +0100 | [diff] [blame] | 106 | DataType::Type GetPackedType() const { |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 107 | return GetPackedField<TypeField>(); |
| 108 | } |
| 109 | |
Aart Bik | b79f4ac | 2017-07-10 10:10:37 -0700 | [diff] [blame] | 110 | // Assumes vector nodes cannot be moved by default. Each concrete implementation |
| 111 | // that can be moved should override this method and return true. |
| 112 | bool CanBeMoved() const OVERRIDE { return false; } |
| 113 | |
| 114 | // Tests if all data of a vector node (vector length and packed type) is equal. |
| 115 | // Each concrete implementation that adds more fields should test equality of |
| 116 | // those fields in its own method *and* call all super methods. |
| 117 | bool InstructionDataEquals(const HInstruction* other) const OVERRIDE { |
| 118 | DCHECK(other->IsVecOperation()); |
| 119 | const HVecOperation* o = other->AsVecOperation(); |
| 120 | return GetVectorLength() == o->GetVectorLength() && GetPackedType() == o->GetPackedType(); |
| 121 | } |
| 122 | |
Aart Bik | 46b6dbc | 2017-10-03 11:37:37 -0700 | [diff] [blame] | 123 | // Maps an integral type to the same-size signed type and leaves other types alone. |
| 124 | // Can be used to test relaxed type consistency in which packed same-size integral |
| 125 | // types can co-exist, but other type mixes are an error. |
| 126 | static DataType::Type ToSignedType(DataType::Type type) { |
| 127 | switch (type) { |
| 128 | case DataType::Type::kBool: // 1-byte storage unit |
| 129 | case DataType::Type::kUint8: |
| 130 | return DataType::Type::kInt8; |
| 131 | case DataType::Type::kUint16: |
| 132 | return DataType::Type::kInt16; |
| 133 | default: |
| 134 | DCHECK(type != DataType::Type::kVoid && type != DataType::Type::kReference) << type; |
| 135 | return type; |
| 136 | } |
| 137 | } |
| 138 | |
Aart Bik | 4d1a9d4 | 2017-10-19 14:40:55 -0700 | [diff] [blame] | 139 | // Maps an integral type to the same-size unsigned type and leaves other types alone. |
| 140 | static DataType::Type ToUnsignedType(DataType::Type type) { |
| 141 | switch (type) { |
| 142 | case DataType::Type::kBool: // 1-byte storage unit |
| 143 | case DataType::Type::kInt8: |
| 144 | return DataType::Type::kUint8; |
| 145 | case DataType::Type::kInt16: |
| 146 | return DataType::Type::kUint16; |
| 147 | default: |
| 148 | DCHECK(type != DataType::Type::kVoid && type != DataType::Type::kReference) << type; |
| 149 | return type; |
| 150 | } |
| 151 | } |
| 152 | |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 153 | DECLARE_ABSTRACT_INSTRUCTION(VecOperation); |
| 154 | |
Aart Bik | db14fcf | 2017-04-25 15:53:58 -0700 | [diff] [blame] | 155 | protected: |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 156 | // Additional packed bits. |
| 157 | static constexpr size_t kFieldType = HInstruction::kNumberOfGenericPackedBits; |
| 158 | static constexpr size_t kFieldTypeSize = |
Vladimir Marko | 0ebe0d8 | 2017-09-21 22:50:39 +0100 | [diff] [blame] | 159 | MinimumBitsToStore(static_cast<size_t>(DataType::Type::kLast)); |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 160 | static constexpr size_t kNumberOfVectorOpPackedBits = kFieldType + kFieldTypeSize; |
| 161 | static_assert(kNumberOfVectorOpPackedBits <= kMaxNumberOfPackedBits, "Too many packed fields."); |
Vladimir Marko | 0ebe0d8 | 2017-09-21 22:50:39 +0100 | [diff] [blame] | 162 | using TypeField = BitField<DataType::Type, kFieldType, kFieldTypeSize>; |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 163 | |
Aart Bik | db14fcf | 2017-04-25 15:53:58 -0700 | [diff] [blame] | 164 | private: |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 165 | const size_t vector_length_; |
| 166 | |
| 167 | DISALLOW_COPY_AND_ASSIGN(HVecOperation); |
| 168 | }; |
| 169 | |
| 170 | // Abstraction of a unary vector operation. |
| 171 | class HVecUnaryOperation : public HVecOperation { |
| 172 | public: |
Vladimir Marko | e764d2e | 2017-10-05 14:35:55 +0100 | [diff] [blame] | 173 | HVecUnaryOperation(ArenaAllocator* allocator, |
Aart Bik | 8de5916 | 2017-04-21 09:42:01 -0700 | [diff] [blame] | 174 | HInstruction* input, |
Vladimir Marko | 0ebe0d8 | 2017-09-21 22:50:39 +0100 | [diff] [blame] | 175 | DataType::Type packed_type, |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 176 | size_t vector_length, |
| 177 | uint32_t dex_pc) |
Vladimir Marko | e764d2e | 2017-10-05 14:35:55 +0100 | [diff] [blame] | 178 | : HVecOperation(allocator, |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 179 | packed_type, |
| 180 | SideEffects::None(), |
Aart Bik | 8de5916 | 2017-04-21 09:42:01 -0700 | [diff] [blame] | 181 | /* number_of_inputs */ 1, |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 182 | vector_length, |
Aart Bik | 8de5916 | 2017-04-21 09:42:01 -0700 | [diff] [blame] | 183 | dex_pc) { |
| 184 | SetRawInputAt(0, input); |
| 185 | } |
| 186 | |
| 187 | HInstruction* GetInput() const { return InputAt(0); } |
| 188 | |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 189 | DECLARE_ABSTRACT_INSTRUCTION(VecUnaryOperation); |
Aart Bik | 8de5916 | 2017-04-21 09:42:01 -0700 | [diff] [blame] | 190 | |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 191 | private: |
| 192 | DISALLOW_COPY_AND_ASSIGN(HVecUnaryOperation); |
| 193 | }; |
| 194 | |
| 195 | // Abstraction of a binary vector operation. |
| 196 | class HVecBinaryOperation : public HVecOperation { |
| 197 | public: |
Vladimir Marko | e764d2e | 2017-10-05 14:35:55 +0100 | [diff] [blame] | 198 | HVecBinaryOperation(ArenaAllocator* allocator, |
Aart Bik | 8de5916 | 2017-04-21 09:42:01 -0700 | [diff] [blame] | 199 | HInstruction* left, |
| 200 | HInstruction* right, |
Vladimir Marko | 0ebe0d8 | 2017-09-21 22:50:39 +0100 | [diff] [blame] | 201 | DataType::Type packed_type, |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 202 | size_t vector_length, |
| 203 | uint32_t dex_pc) |
Vladimir Marko | e764d2e | 2017-10-05 14:35:55 +0100 | [diff] [blame] | 204 | : HVecOperation(allocator, |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 205 | packed_type, |
| 206 | SideEffects::None(), |
Aart Bik | 8de5916 | 2017-04-21 09:42:01 -0700 | [diff] [blame] | 207 | /* number_of_inputs */ 2, |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 208 | vector_length, |
Aart Bik | 8de5916 | 2017-04-21 09:42:01 -0700 | [diff] [blame] | 209 | dex_pc) { |
| 210 | SetRawInputAt(0, left); |
| 211 | SetRawInputAt(1, right); |
| 212 | } |
Artem Serov | f34dd20 | 2017-04-10 17:41:46 +0100 | [diff] [blame] | 213 | |
| 214 | HInstruction* GetLeft() const { return InputAt(0); } |
| 215 | HInstruction* GetRight() const { return InputAt(1); } |
| 216 | |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 217 | DECLARE_ABSTRACT_INSTRUCTION(VecBinaryOperation); |
Aart Bik | 8de5916 | 2017-04-21 09:42:01 -0700 | [diff] [blame] | 218 | |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 219 | private: |
| 220 | DISALLOW_COPY_AND_ASSIGN(HVecBinaryOperation); |
| 221 | }; |
| 222 | |
| 223 | // Abstraction of a vector operation that references memory, with an alignment. |
Aart Bik | 46b6dbc | 2017-10-03 11:37:37 -0700 | [diff] [blame] | 224 | // The Android runtime guarantees elements have at least natural alignment. |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 225 | class HVecMemoryOperation : public HVecOperation { |
| 226 | public: |
Vladimir Marko | e764d2e | 2017-10-05 14:35:55 +0100 | [diff] [blame] | 227 | HVecMemoryOperation(ArenaAllocator* allocator, |
Vladimir Marko | 0ebe0d8 | 2017-09-21 22:50:39 +0100 | [diff] [blame] | 228 | DataType::Type packed_type, |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 229 | SideEffects side_effects, |
| 230 | size_t number_of_inputs, |
| 231 | size_t vector_length, |
| 232 | uint32_t dex_pc) |
Vladimir Marko | e764d2e | 2017-10-05 14:35:55 +0100 | [diff] [blame] | 233 | : HVecOperation(allocator, |
| 234 | packed_type, |
| 235 | side_effects, |
| 236 | number_of_inputs, |
| 237 | vector_length, |
| 238 | dex_pc), |
Vladimir Marko | 0ebe0d8 | 2017-09-21 22:50:39 +0100 | [diff] [blame] | 239 | alignment_(DataType::Size(packed_type), 0) { |
Artem Serov | e1811ed | 2017-04-27 16:50:47 +0100 | [diff] [blame] | 240 | DCHECK_GE(number_of_inputs, 2u); |
| 241 | } |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 242 | |
| 243 | void SetAlignment(Alignment alignment) { alignment_ = alignment; } |
| 244 | |
| 245 | Alignment GetAlignment() const { return alignment_; } |
| 246 | |
Artem Serov | e1811ed | 2017-04-27 16:50:47 +0100 | [diff] [blame] | 247 | HInstruction* GetArray() const { return InputAt(0); } |
| 248 | HInstruction* GetIndex() const { return InputAt(1); } |
| 249 | |
Aart Bik | b79f4ac | 2017-07-10 10:10:37 -0700 | [diff] [blame] | 250 | bool InstructionDataEquals(const HInstruction* other) const OVERRIDE { |
| 251 | DCHECK(other->IsVecMemoryOperation()); |
| 252 | const HVecMemoryOperation* o = other->AsVecMemoryOperation(); |
| 253 | return HVecOperation::InstructionDataEquals(o) && GetAlignment() == o->GetAlignment(); |
| 254 | } |
| 255 | |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 256 | DECLARE_ABSTRACT_INSTRUCTION(VecMemoryOperation); |
| 257 | |
| 258 | private: |
| 259 | Alignment alignment_; |
| 260 | |
| 261 | DISALLOW_COPY_AND_ASSIGN(HVecMemoryOperation); |
| 262 | }; |
| 263 | |
Aart Bik | 0148de4 | 2017-09-05 09:25:01 -0700 | [diff] [blame] | 264 | // Packed type consistency checker ("same vector length" integral types may mix freely). |
Vladimir Marko | 0ebe0d8 | 2017-09-21 22:50:39 +0100 | [diff] [blame] | 265 | inline static bool HasConsistentPackedTypes(HInstruction* input, DataType::Type type) { |
Aart Bik | 0148de4 | 2017-09-05 09:25:01 -0700 | [diff] [blame] | 266 | if (input->IsPhi()) { |
| 267 | return input->GetType() == HVecOperation::kSIMDType; // carries SIMD |
| 268 | } |
Aart Bik | d58bc32 | 2017-05-01 14:49:18 -0700 | [diff] [blame] | 269 | DCHECK(input->IsVecOperation()); |
Vladimir Marko | 0ebe0d8 | 2017-09-21 22:50:39 +0100 | [diff] [blame] | 270 | DataType::Type input_type = input->AsVecOperation()->GetPackedType(); |
Aart Bik | 4d1a9d4 | 2017-10-19 14:40:55 -0700 | [diff] [blame] | 271 | DCHECK_EQ(HVecOperation::ToUnsignedType(input_type) == HVecOperation::ToUnsignedType(type), |
| 272 | HVecOperation::ToSignedType(input_type) == HVecOperation::ToSignedType(type)); |
Aart Bik | 46b6dbc | 2017-10-03 11:37:37 -0700 | [diff] [blame] | 273 | return HVecOperation::ToSignedType(input_type) == HVecOperation::ToSignedType(type); |
Aart Bik | d58bc32 | 2017-05-01 14:49:18 -0700 | [diff] [blame] | 274 | } |
| 275 | |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 276 | // |
Aart Bik | 8de5916 | 2017-04-21 09:42:01 -0700 | [diff] [blame] | 277 | // Definitions of concrete unary vector operations in HIR. |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 278 | // |
| 279 | |
| 280 | // Replicates the given scalar into a vector, |
| 281 | // viz. replicate(x) = [ x, .. , x ]. |
| 282 | class HVecReplicateScalar FINAL : public HVecUnaryOperation { |
| 283 | public: |
Vladimir Marko | e764d2e | 2017-10-05 14:35:55 +0100 | [diff] [blame] | 284 | HVecReplicateScalar(ArenaAllocator* allocator, |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 285 | HInstruction* scalar, |
Vladimir Marko | 0ebe0d8 | 2017-09-21 22:50:39 +0100 | [diff] [blame] | 286 | DataType::Type packed_type, |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 287 | size_t vector_length, |
Aart Bik | 46b6dbc | 2017-10-03 11:37:37 -0700 | [diff] [blame] | 288 | uint32_t dex_pc) |
Vladimir Marko | e764d2e | 2017-10-05 14:35:55 +0100 | [diff] [blame] | 289 | : HVecUnaryOperation(allocator, scalar, packed_type, vector_length, dex_pc) { |
Aart Bik | 8de5916 | 2017-04-21 09:42:01 -0700 | [diff] [blame] | 290 | DCHECK(!scalar->IsVecOperation()); |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 291 | } |
Aart Bik | b79f4ac | 2017-07-10 10:10:37 -0700 | [diff] [blame] | 292 | |
| 293 | // A replicate needs to stay in place, since SIMD registers are not |
| 294 | // kept alive across vector loop boundaries (yet). |
| 295 | bool CanBeMoved() const OVERRIDE { return false; } |
| 296 | |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 297 | DECLARE_INSTRUCTION(VecReplicateScalar); |
Aart Bik | b79f4ac | 2017-07-10 10:10:37 -0700 | [diff] [blame] | 298 | |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 299 | private: |
| 300 | DISALLOW_COPY_AND_ASSIGN(HVecReplicateScalar); |
| 301 | }; |
| 302 | |
Aart Bik | 0148de4 | 2017-09-05 09:25:01 -0700 | [diff] [blame] | 303 | // Extracts a particular scalar from the given vector, |
| 304 | // viz. extract[ x1, .. , xn ] = x_i. |
| 305 | // |
| 306 | // TODO: for now only i == 1 case supported. |
| 307 | class HVecExtractScalar FINAL : public HVecUnaryOperation { |
| 308 | public: |
Vladimir Marko | e764d2e | 2017-10-05 14:35:55 +0100 | [diff] [blame] | 309 | HVecExtractScalar(ArenaAllocator* allocator, |
Aart Bik | 0148de4 | 2017-09-05 09:25:01 -0700 | [diff] [blame] | 310 | HInstruction* input, |
Vladimir Marko | 0ebe0d8 | 2017-09-21 22:50:39 +0100 | [diff] [blame] | 311 | DataType::Type packed_type, |
Aart Bik | 0148de4 | 2017-09-05 09:25:01 -0700 | [diff] [blame] | 312 | size_t vector_length, |
| 313 | size_t index, |
Aart Bik | 46b6dbc | 2017-10-03 11:37:37 -0700 | [diff] [blame] | 314 | uint32_t dex_pc) |
Vladimir Marko | e764d2e | 2017-10-05 14:35:55 +0100 | [diff] [blame] | 315 | : HVecUnaryOperation(allocator, input, packed_type, vector_length, dex_pc) { |
Aart Bik | d58bc32 | 2017-05-01 14:49:18 -0700 | [diff] [blame] | 316 | DCHECK(HasConsistentPackedTypes(input, packed_type)); |
Aart Bik | 0148de4 | 2017-09-05 09:25:01 -0700 | [diff] [blame] | 317 | DCHECK_LT(index, vector_length); |
| 318 | DCHECK_EQ(index, 0u); |
| 319 | } |
| 320 | |
| 321 | // Yields a single component in the vector. |
Vladimir Marko | 0ebe0d8 | 2017-09-21 22:50:39 +0100 | [diff] [blame] | 322 | DataType::Type GetType() const OVERRIDE { |
Aart Bik | 0148de4 | 2017-09-05 09:25:01 -0700 | [diff] [blame] | 323 | return GetPackedType(); |
| 324 | } |
| 325 | |
| 326 | // An extract needs to stay in place, since SIMD registers are not |
| 327 | // kept alive across vector loop boundaries (yet). |
| 328 | bool CanBeMoved() const OVERRIDE { return false; } |
| 329 | |
| 330 | DECLARE_INSTRUCTION(VecExtractScalar); |
| 331 | |
| 332 | private: |
| 333 | DISALLOW_COPY_AND_ASSIGN(HVecExtractScalar); |
| 334 | }; |
| 335 | |
| 336 | // Reduces the given vector into the first element as sum/min/max, |
| 337 | // viz. sum-reduce[ x1, .. , xn ] = [ y, ---- ], where y = sum xi |
| 338 | // and the "-" denotes "don't care" (implementation dependent). |
| 339 | class HVecReduce FINAL : public HVecUnaryOperation { |
| 340 | public: |
| 341 | enum ReductionKind { |
| 342 | kSum = 1, |
| 343 | kMin = 2, |
| 344 | kMax = 3 |
| 345 | }; |
| 346 | |
Vladimir Marko | e764d2e | 2017-10-05 14:35:55 +0100 | [diff] [blame] | 347 | HVecReduce(ArenaAllocator* allocator, |
Aart Bik | 0148de4 | 2017-09-05 09:25:01 -0700 | [diff] [blame] | 348 | HInstruction* input, |
Vladimir Marko | 0ebe0d8 | 2017-09-21 22:50:39 +0100 | [diff] [blame] | 349 | DataType::Type packed_type, |
Aart Bik | 0148de4 | 2017-09-05 09:25:01 -0700 | [diff] [blame] | 350 | size_t vector_length, |
| 351 | ReductionKind kind, |
Aart Bik | 46b6dbc | 2017-10-03 11:37:37 -0700 | [diff] [blame] | 352 | uint32_t dex_pc) |
Vladimir Marko | e764d2e | 2017-10-05 14:35:55 +0100 | [diff] [blame] | 353 | : HVecUnaryOperation(allocator, input, packed_type, vector_length, dex_pc), |
Aart Bik | 0148de4 | 2017-09-05 09:25:01 -0700 | [diff] [blame] | 354 | kind_(kind) { |
| 355 | DCHECK(HasConsistentPackedTypes(input, packed_type)); |
Aart Bik | cfa59b4 | 2017-08-31 09:08:13 -0700 | [diff] [blame] | 356 | } |
| 357 | |
Aart Bik | 0148de4 | 2017-09-05 09:25:01 -0700 | [diff] [blame] | 358 | ReductionKind GetKind() const { return kind_; } |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 359 | |
Aart Bik | b79f4ac | 2017-07-10 10:10:37 -0700 | [diff] [blame] | 360 | bool CanBeMoved() const OVERRIDE { return true; } |
| 361 | |
Aart Bik | 0148de4 | 2017-09-05 09:25:01 -0700 | [diff] [blame] | 362 | bool InstructionDataEquals(const HInstruction* other) const OVERRIDE { |
| 363 | DCHECK(other->IsVecReduce()); |
| 364 | const HVecReduce* o = other->AsVecReduce(); |
| 365 | return HVecOperation::InstructionDataEquals(o) && GetKind() == o->GetKind(); |
| 366 | } |
| 367 | |
| 368 | DECLARE_INSTRUCTION(VecReduce); |
Aart Bik | b79f4ac | 2017-07-10 10:10:37 -0700 | [diff] [blame] | 369 | |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 370 | private: |
Aart Bik | 0148de4 | 2017-09-05 09:25:01 -0700 | [diff] [blame] | 371 | const ReductionKind kind_; |
| 372 | |
| 373 | DISALLOW_COPY_AND_ASSIGN(HVecReduce); |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 374 | }; |
| 375 | |
| 376 | // Converts every component in the vector, |
| 377 | // viz. cnv[ x1, .. , xn ] = [ cnv(x1), .. , cnv(xn) ]. |
| 378 | class HVecCnv FINAL : public HVecUnaryOperation { |
| 379 | public: |
Vladimir Marko | e764d2e | 2017-10-05 14:35:55 +0100 | [diff] [blame] | 380 | HVecCnv(ArenaAllocator* allocator, |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 381 | HInstruction* input, |
Vladimir Marko | 0ebe0d8 | 2017-09-21 22:50:39 +0100 | [diff] [blame] | 382 | DataType::Type packed_type, |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 383 | size_t vector_length, |
Aart Bik | 46b6dbc | 2017-10-03 11:37:37 -0700 | [diff] [blame] | 384 | uint32_t dex_pc) |
Vladimir Marko | e764d2e | 2017-10-05 14:35:55 +0100 | [diff] [blame] | 385 | : HVecUnaryOperation(allocator, input, packed_type, vector_length, dex_pc) { |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 386 | DCHECK(input->IsVecOperation()); |
Aart Bik | d58bc32 | 2017-05-01 14:49:18 -0700 | [diff] [blame] | 387 | DCHECK_NE(GetInputType(), GetResultType()); // actual convert |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 388 | } |
| 389 | |
Vladimir Marko | 0ebe0d8 | 2017-09-21 22:50:39 +0100 | [diff] [blame] | 390 | DataType::Type GetInputType() const { return InputAt(0)->AsVecOperation()->GetPackedType(); } |
| 391 | DataType::Type GetResultType() const { return GetPackedType(); } |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 392 | |
Aart Bik | b79f4ac | 2017-07-10 10:10:37 -0700 | [diff] [blame] | 393 | bool CanBeMoved() const OVERRIDE { return true; } |
| 394 | |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 395 | DECLARE_INSTRUCTION(VecCnv); |
| 396 | |
| 397 | private: |
| 398 | DISALLOW_COPY_AND_ASSIGN(HVecCnv); |
| 399 | }; |
| 400 | |
| 401 | // Negates every component in the vector, |
| 402 | // viz. neg[ x1, .. , xn ] = [ -x1, .. , -xn ]. |
| 403 | class HVecNeg FINAL : public HVecUnaryOperation { |
| 404 | public: |
Vladimir Marko | e764d2e | 2017-10-05 14:35:55 +0100 | [diff] [blame] | 405 | HVecNeg(ArenaAllocator* allocator, |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 406 | HInstruction* input, |
Vladimir Marko | 0ebe0d8 | 2017-09-21 22:50:39 +0100 | [diff] [blame] | 407 | DataType::Type packed_type, |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 408 | size_t vector_length, |
Aart Bik | 46b6dbc | 2017-10-03 11:37:37 -0700 | [diff] [blame] | 409 | uint32_t dex_pc) |
Vladimir Marko | e764d2e | 2017-10-05 14:35:55 +0100 | [diff] [blame] | 410 | : HVecUnaryOperation(allocator, input, packed_type, vector_length, dex_pc) { |
Aart Bik | d58bc32 | 2017-05-01 14:49:18 -0700 | [diff] [blame] | 411 | DCHECK(HasConsistentPackedTypes(input, packed_type)); |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 412 | } |
Aart Bik | b79f4ac | 2017-07-10 10:10:37 -0700 | [diff] [blame] | 413 | |
| 414 | bool CanBeMoved() const OVERRIDE { return true; } |
| 415 | |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 416 | DECLARE_INSTRUCTION(VecNeg); |
Aart Bik | b79f4ac | 2017-07-10 10:10:37 -0700 | [diff] [blame] | 417 | |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 418 | private: |
| 419 | DISALLOW_COPY_AND_ASSIGN(HVecNeg); |
| 420 | }; |
| 421 | |
Aart Bik | 6daebeb | 2017-04-03 14:35:41 -0700 | [diff] [blame] | 422 | // Takes absolute value of every component in the vector, |
Aart Bik | 46b6dbc | 2017-10-03 11:37:37 -0700 | [diff] [blame] | 423 | // viz. abs[ x1, .. , xn ] = [ |x1|, .. , |xn| ] |
| 424 | // for signed operand x. |
Aart Bik | 6daebeb | 2017-04-03 14:35:41 -0700 | [diff] [blame] | 425 | class HVecAbs FINAL : public HVecUnaryOperation { |
| 426 | public: |
Vladimir Marko | e764d2e | 2017-10-05 14:35:55 +0100 | [diff] [blame] | 427 | HVecAbs(ArenaAllocator* allocator, |
Aart Bik | 6daebeb | 2017-04-03 14:35:41 -0700 | [diff] [blame] | 428 | HInstruction* input, |
Vladimir Marko | 0ebe0d8 | 2017-09-21 22:50:39 +0100 | [diff] [blame] | 429 | DataType::Type packed_type, |
Aart Bik | 6daebeb | 2017-04-03 14:35:41 -0700 | [diff] [blame] | 430 | size_t vector_length, |
Aart Bik | 46b6dbc | 2017-10-03 11:37:37 -0700 | [diff] [blame] | 431 | uint32_t dex_pc) |
Vladimir Marko | e764d2e | 2017-10-05 14:35:55 +0100 | [diff] [blame] | 432 | : HVecUnaryOperation(allocator, input, packed_type, vector_length, dex_pc) { |
Aart Bik | d58bc32 | 2017-05-01 14:49:18 -0700 | [diff] [blame] | 433 | DCHECK(HasConsistentPackedTypes(input, packed_type)); |
Aart Bik | 6daebeb | 2017-04-03 14:35:41 -0700 | [diff] [blame] | 434 | } |
Aart Bik | b79f4ac | 2017-07-10 10:10:37 -0700 | [diff] [blame] | 435 | |
| 436 | bool CanBeMoved() const OVERRIDE { return true; } |
| 437 | |
Aart Bik | 6daebeb | 2017-04-03 14:35:41 -0700 | [diff] [blame] | 438 | DECLARE_INSTRUCTION(VecAbs); |
Aart Bik | b79f4ac | 2017-07-10 10:10:37 -0700 | [diff] [blame] | 439 | |
Aart Bik | 6daebeb | 2017-04-03 14:35:41 -0700 | [diff] [blame] | 440 | private: |
| 441 | DISALLOW_COPY_AND_ASSIGN(HVecAbs); |
| 442 | }; |
| 443 | |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 444 | // Bitwise- or boolean-nots every component in the vector, |
| 445 | // viz. not[ x1, .. , xn ] = [ ~x1, .. , ~xn ], or |
| 446 | // not[ x1, .. , xn ] = [ !x1, .. , !xn ] for boolean. |
| 447 | class HVecNot FINAL : public HVecUnaryOperation { |
| 448 | public: |
Vladimir Marko | e764d2e | 2017-10-05 14:35:55 +0100 | [diff] [blame] | 449 | HVecNot(ArenaAllocator* allocator, |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 450 | HInstruction* input, |
Vladimir Marko | 0ebe0d8 | 2017-09-21 22:50:39 +0100 | [diff] [blame] | 451 | DataType::Type packed_type, |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 452 | size_t vector_length, |
Aart Bik | 46b6dbc | 2017-10-03 11:37:37 -0700 | [diff] [blame] | 453 | uint32_t dex_pc) |
Vladimir Marko | e764d2e | 2017-10-05 14:35:55 +0100 | [diff] [blame] | 454 | : HVecUnaryOperation(allocator, input, packed_type, vector_length, dex_pc) { |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 455 | DCHECK(input->IsVecOperation()); |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 456 | } |
Aart Bik | b79f4ac | 2017-07-10 10:10:37 -0700 | [diff] [blame] | 457 | |
| 458 | bool CanBeMoved() const OVERRIDE { return true; } |
| 459 | |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 460 | DECLARE_INSTRUCTION(VecNot); |
Aart Bik | b79f4ac | 2017-07-10 10:10:37 -0700 | [diff] [blame] | 461 | |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 462 | private: |
| 463 | DISALLOW_COPY_AND_ASSIGN(HVecNot); |
| 464 | }; |
| 465 | |
Aart Bik | 8de5916 | 2017-04-21 09:42:01 -0700 | [diff] [blame] | 466 | // |
| 467 | // Definitions of concrete binary vector operations in HIR. |
| 468 | // |
| 469 | |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 470 | // Adds every component in the two vectors, |
| 471 | // viz. [ x1, .. , xn ] + [ y1, .. , yn ] = [ x1 + y1, .. , xn + yn ]. |
| 472 | class HVecAdd FINAL : public HVecBinaryOperation { |
| 473 | public: |
Vladimir Marko | e764d2e | 2017-10-05 14:35:55 +0100 | [diff] [blame] | 474 | HVecAdd(ArenaAllocator* allocator, |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 475 | HInstruction* left, |
| 476 | HInstruction* right, |
Vladimir Marko | 0ebe0d8 | 2017-09-21 22:50:39 +0100 | [diff] [blame] | 477 | DataType::Type packed_type, |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 478 | size_t vector_length, |
Aart Bik | 46b6dbc | 2017-10-03 11:37:37 -0700 | [diff] [blame] | 479 | uint32_t dex_pc) |
Vladimir Marko | e764d2e | 2017-10-05 14:35:55 +0100 | [diff] [blame] | 480 | : HVecBinaryOperation(allocator, left, right, packed_type, vector_length, dex_pc) { |
Aart Bik | d58bc32 | 2017-05-01 14:49:18 -0700 | [diff] [blame] | 481 | DCHECK(HasConsistentPackedTypes(left, packed_type)); |
| 482 | DCHECK(HasConsistentPackedTypes(right, packed_type)); |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 483 | } |
Aart Bik | b79f4ac | 2017-07-10 10:10:37 -0700 | [diff] [blame] | 484 | |
| 485 | bool CanBeMoved() const OVERRIDE { return true; } |
| 486 | |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 487 | DECLARE_INSTRUCTION(VecAdd); |
Aart Bik | b79f4ac | 2017-07-10 10:10:37 -0700 | [diff] [blame] | 488 | |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 489 | private: |
| 490 | DISALLOW_COPY_AND_ASSIGN(HVecAdd); |
| 491 | }; |
| 492 | |
Aart Bik | f3e61ee | 2017-04-12 17:09:20 -0700 | [diff] [blame] | 493 | // Performs halving add on every component in the two vectors, viz. |
Aart Bik | dbbac8f | 2017-09-01 13:06:08 -0700 | [diff] [blame] | 494 | // rounded [ x1, .. , xn ] hradd [ y1, .. , yn ] = [ (x1 + y1 + 1) >> 1, .. , (xn + yn + 1) >> 1 ] |
| 495 | // truncated [ x1, .. , xn ] hadd [ y1, .. , yn ] = [ (x1 + y1) >> 1, .. , (xn + yn ) >> 1 ] |
Aart Bik | 46b6dbc | 2017-10-03 11:37:37 -0700 | [diff] [blame] | 496 | // for either both signed or both unsigned operands x, y. |
Aart Bik | f3e61ee | 2017-04-12 17:09:20 -0700 | [diff] [blame] | 497 | class HVecHalvingAdd FINAL : public HVecBinaryOperation { |
| 498 | public: |
Vladimir Marko | e764d2e | 2017-10-05 14:35:55 +0100 | [diff] [blame] | 499 | HVecHalvingAdd(ArenaAllocator* allocator, |
Aart Bik | f3e61ee | 2017-04-12 17:09:20 -0700 | [diff] [blame] | 500 | HInstruction* left, |
| 501 | HInstruction* right, |
Vladimir Marko | 0ebe0d8 | 2017-09-21 22:50:39 +0100 | [diff] [blame] | 502 | DataType::Type packed_type, |
Aart Bik | f3e61ee | 2017-04-12 17:09:20 -0700 | [diff] [blame] | 503 | size_t vector_length, |
Aart Bik | f3e61ee | 2017-04-12 17:09:20 -0700 | [diff] [blame] | 504 | bool is_rounded, |
Aart Bik | 46b6dbc | 2017-10-03 11:37:37 -0700 | [diff] [blame] | 505 | bool is_unsigned, |
| 506 | uint32_t dex_pc) |
Vladimir Marko | e764d2e | 2017-10-05 14:35:55 +0100 | [diff] [blame] | 507 | : HVecBinaryOperation(allocator, left, right, packed_type, vector_length, dex_pc) { |
Vladimir Marko | d5d2f2c | 2017-09-26 12:37:26 +0100 | [diff] [blame] | 508 | // The `is_unsigned` flag should be used exclusively with the Int32 or Int64. |
| 509 | // This flag is a temporary measure while we do not have the Uint32 and Uint64 data types. |
| 510 | DCHECK(!is_unsigned || |
| 511 | packed_type == DataType::Type::kInt32 || |
| 512 | packed_type == DataType::Type::kInt64) << packed_type; |
Aart Bik | d58bc32 | 2017-05-01 14:49:18 -0700 | [diff] [blame] | 513 | DCHECK(HasConsistentPackedTypes(left, packed_type)); |
| 514 | DCHECK(HasConsistentPackedTypes(right, packed_type)); |
Aart Bik | db14fcf | 2017-04-25 15:53:58 -0700 | [diff] [blame] | 515 | SetPackedFlag<kFieldHAddIsUnsigned>(is_unsigned); |
| 516 | SetPackedFlag<kFieldHAddIsRounded>(is_rounded); |
Aart Bik | f3e61ee | 2017-04-12 17:09:20 -0700 | [diff] [blame] | 517 | } |
| 518 | |
Aart Bik | db14fcf | 2017-04-25 15:53:58 -0700 | [diff] [blame] | 519 | bool IsUnsigned() const { return GetPackedFlag<kFieldHAddIsUnsigned>(); } |
| 520 | bool IsRounded() const { return GetPackedFlag<kFieldHAddIsRounded>(); } |
Aart Bik | f3e61ee | 2017-04-12 17:09:20 -0700 | [diff] [blame] | 521 | |
Aart Bik | b79f4ac | 2017-07-10 10:10:37 -0700 | [diff] [blame] | 522 | bool CanBeMoved() const OVERRIDE { return true; } |
| 523 | |
| 524 | bool InstructionDataEquals(const HInstruction* other) const OVERRIDE { |
| 525 | DCHECK(other->IsVecHalvingAdd()); |
| 526 | const HVecHalvingAdd* o = other->AsVecHalvingAdd(); |
| 527 | return HVecOperation::InstructionDataEquals(o) && |
| 528 | IsUnsigned() == o->IsUnsigned() && |
| 529 | IsRounded() == o->IsRounded(); |
| 530 | } |
| 531 | |
Aart Bik | f3e61ee | 2017-04-12 17:09:20 -0700 | [diff] [blame] | 532 | DECLARE_INSTRUCTION(VecHalvingAdd); |
| 533 | |
| 534 | private: |
Aart Bik | db14fcf | 2017-04-25 15:53:58 -0700 | [diff] [blame] | 535 | // Additional packed bits. |
| 536 | static constexpr size_t kFieldHAddIsUnsigned = HVecOperation::kNumberOfVectorOpPackedBits; |
| 537 | static constexpr size_t kFieldHAddIsRounded = kFieldHAddIsUnsigned + 1; |
| 538 | static constexpr size_t kNumberOfHAddPackedBits = kFieldHAddIsRounded + 1; |
| 539 | static_assert(kNumberOfHAddPackedBits <= kMaxNumberOfPackedBits, "Too many packed fields."); |
Aart Bik | f3e61ee | 2017-04-12 17:09:20 -0700 | [diff] [blame] | 540 | |
| 541 | DISALLOW_COPY_AND_ASSIGN(HVecHalvingAdd); |
| 542 | }; |
| 543 | |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 544 | // Subtracts every component in the two vectors, |
| 545 | // viz. [ x1, .. , xn ] - [ y1, .. , yn ] = [ x1 - y1, .. , xn - yn ]. |
| 546 | class HVecSub FINAL : public HVecBinaryOperation { |
| 547 | public: |
Vladimir Marko | e764d2e | 2017-10-05 14:35:55 +0100 | [diff] [blame] | 548 | HVecSub(ArenaAllocator* allocator, |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 549 | HInstruction* left, |
| 550 | HInstruction* right, |
Vladimir Marko | 0ebe0d8 | 2017-09-21 22:50:39 +0100 | [diff] [blame] | 551 | DataType::Type packed_type, |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 552 | size_t vector_length, |
Aart Bik | 46b6dbc | 2017-10-03 11:37:37 -0700 | [diff] [blame] | 553 | uint32_t dex_pc) |
Vladimir Marko | e764d2e | 2017-10-05 14:35:55 +0100 | [diff] [blame] | 554 | : HVecBinaryOperation(allocator, left, right, packed_type, vector_length, dex_pc) { |
Aart Bik | d58bc32 | 2017-05-01 14:49:18 -0700 | [diff] [blame] | 555 | DCHECK(HasConsistentPackedTypes(left, packed_type)); |
| 556 | DCHECK(HasConsistentPackedTypes(right, packed_type)); |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 557 | } |
Aart Bik | b79f4ac | 2017-07-10 10:10:37 -0700 | [diff] [blame] | 558 | |
| 559 | bool CanBeMoved() const OVERRIDE { return true; } |
| 560 | |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 561 | DECLARE_INSTRUCTION(VecSub); |
Aart Bik | b79f4ac | 2017-07-10 10:10:37 -0700 | [diff] [blame] | 562 | |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 563 | private: |
| 564 | DISALLOW_COPY_AND_ASSIGN(HVecSub); |
| 565 | }; |
| 566 | |
| 567 | // Multiplies every component in the two vectors, |
| 568 | // viz. [ x1, .. , xn ] * [ y1, .. , yn ] = [ x1 * y1, .. , xn * yn ]. |
| 569 | class HVecMul FINAL : public HVecBinaryOperation { |
| 570 | public: |
Vladimir Marko | e764d2e | 2017-10-05 14:35:55 +0100 | [diff] [blame] | 571 | HVecMul(ArenaAllocator* allocator, |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 572 | HInstruction* left, |
| 573 | HInstruction* right, |
Vladimir Marko | 0ebe0d8 | 2017-09-21 22:50:39 +0100 | [diff] [blame] | 574 | DataType::Type packed_type, |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 575 | size_t vector_length, |
Aart Bik | 46b6dbc | 2017-10-03 11:37:37 -0700 | [diff] [blame] | 576 | uint32_t dex_pc) |
Vladimir Marko | e764d2e | 2017-10-05 14:35:55 +0100 | [diff] [blame] | 577 | : HVecBinaryOperation(allocator, left, right, packed_type, vector_length, dex_pc) { |
Aart Bik | d58bc32 | 2017-05-01 14:49:18 -0700 | [diff] [blame] | 578 | DCHECK(HasConsistentPackedTypes(left, packed_type)); |
| 579 | DCHECK(HasConsistentPackedTypes(right, packed_type)); |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 580 | } |
Aart Bik | b79f4ac | 2017-07-10 10:10:37 -0700 | [diff] [blame] | 581 | |
| 582 | bool CanBeMoved() const OVERRIDE { return true; } |
| 583 | |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 584 | DECLARE_INSTRUCTION(VecMul); |
Aart Bik | b79f4ac | 2017-07-10 10:10:37 -0700 | [diff] [blame] | 585 | |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 586 | private: |
| 587 | DISALLOW_COPY_AND_ASSIGN(HVecMul); |
| 588 | }; |
| 589 | |
| 590 | // Divides every component in the two vectors, |
| 591 | // viz. [ x1, .. , xn ] / [ y1, .. , yn ] = [ x1 / y1, .. , xn / yn ]. |
| 592 | class HVecDiv FINAL : public HVecBinaryOperation { |
| 593 | public: |
Vladimir Marko | e764d2e | 2017-10-05 14:35:55 +0100 | [diff] [blame] | 594 | HVecDiv(ArenaAllocator* allocator, |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 595 | HInstruction* left, |
| 596 | HInstruction* right, |
Vladimir Marko | 0ebe0d8 | 2017-09-21 22:50:39 +0100 | [diff] [blame] | 597 | DataType::Type packed_type, |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 598 | size_t vector_length, |
Aart Bik | 46b6dbc | 2017-10-03 11:37:37 -0700 | [diff] [blame] | 599 | uint32_t dex_pc) |
Vladimir Marko | e764d2e | 2017-10-05 14:35:55 +0100 | [diff] [blame] | 600 | : HVecBinaryOperation(allocator, left, right, packed_type, vector_length, dex_pc) { |
Aart Bik | d58bc32 | 2017-05-01 14:49:18 -0700 | [diff] [blame] | 601 | DCHECK(HasConsistentPackedTypes(left, packed_type)); |
| 602 | DCHECK(HasConsistentPackedTypes(right, packed_type)); |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 603 | } |
Aart Bik | b79f4ac | 2017-07-10 10:10:37 -0700 | [diff] [blame] | 604 | |
| 605 | bool CanBeMoved() const OVERRIDE { return true; } |
| 606 | |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 607 | DECLARE_INSTRUCTION(VecDiv); |
Aart Bik | b79f4ac | 2017-07-10 10:10:37 -0700 | [diff] [blame] | 608 | |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 609 | private: |
| 610 | DISALLOW_COPY_AND_ASSIGN(HVecDiv); |
| 611 | }; |
| 612 | |
Aart Bik | f3e61ee | 2017-04-12 17:09:20 -0700 | [diff] [blame] | 613 | // Takes minimum of every component in the two vectors, |
Aart Bik | 46b6dbc | 2017-10-03 11:37:37 -0700 | [diff] [blame] | 614 | // viz. MIN( [ x1, .. , xn ] , [ y1, .. , yn ]) = [ min(x1, y1), .. , min(xn, yn) ] |
| 615 | // for either both signed or both unsigned operands x, y. |
Aart Bik | f3e61ee | 2017-04-12 17:09:20 -0700 | [diff] [blame] | 616 | class HVecMin FINAL : public HVecBinaryOperation { |
| 617 | public: |
Vladimir Marko | e764d2e | 2017-10-05 14:35:55 +0100 | [diff] [blame] | 618 | HVecMin(ArenaAllocator* allocator, |
Aart Bik | f3e61ee | 2017-04-12 17:09:20 -0700 | [diff] [blame] | 619 | HInstruction* left, |
| 620 | HInstruction* right, |
Vladimir Marko | 0ebe0d8 | 2017-09-21 22:50:39 +0100 | [diff] [blame] | 621 | DataType::Type packed_type, |
Aart Bik | f3e61ee | 2017-04-12 17:09:20 -0700 | [diff] [blame] | 622 | size_t vector_length, |
Aart Bik | 46b6dbc | 2017-10-03 11:37:37 -0700 | [diff] [blame] | 623 | bool is_unsigned, |
| 624 | uint32_t dex_pc) |
Vladimir Marko | e764d2e | 2017-10-05 14:35:55 +0100 | [diff] [blame] | 625 | : HVecBinaryOperation(allocator, left, right, packed_type, vector_length, dex_pc) { |
Vladimir Marko | d5d2f2c | 2017-09-26 12:37:26 +0100 | [diff] [blame] | 626 | // The `is_unsigned` flag should be used exclusively with the Int32 or Int64. |
| 627 | // This flag is a temporary measure while we do not have the Uint32 and Uint64 data types. |
| 628 | DCHECK(!is_unsigned || |
| 629 | packed_type == DataType::Type::kInt32 || |
| 630 | packed_type == DataType::Type::kInt64) << packed_type; |
Aart Bik | d58bc32 | 2017-05-01 14:49:18 -0700 | [diff] [blame] | 631 | DCHECK(HasConsistentPackedTypes(left, packed_type)); |
| 632 | DCHECK(HasConsistentPackedTypes(right, packed_type)); |
Aart Bik | c8e93c7 | 2017-05-10 10:49:22 -0700 | [diff] [blame] | 633 | SetPackedFlag<kFieldMinOpIsUnsigned>(is_unsigned); |
Aart Bik | f3e61ee | 2017-04-12 17:09:20 -0700 | [diff] [blame] | 634 | } |
Aart Bik | c8e93c7 | 2017-05-10 10:49:22 -0700 | [diff] [blame] | 635 | |
| 636 | bool IsUnsigned() const { return GetPackedFlag<kFieldMinOpIsUnsigned>(); } |
| 637 | |
Aart Bik | b79f4ac | 2017-07-10 10:10:37 -0700 | [diff] [blame] | 638 | bool CanBeMoved() const OVERRIDE { return true; } |
| 639 | |
| 640 | bool InstructionDataEquals(const HInstruction* other) const OVERRIDE { |
| 641 | DCHECK(other->IsVecMin()); |
| 642 | const HVecMin* o = other->AsVecMin(); |
| 643 | return HVecOperation::InstructionDataEquals(o) && IsUnsigned() == o->IsUnsigned(); |
| 644 | } |
| 645 | |
Aart Bik | f3e61ee | 2017-04-12 17:09:20 -0700 | [diff] [blame] | 646 | DECLARE_INSTRUCTION(VecMin); |
Aart Bik | c8e93c7 | 2017-05-10 10:49:22 -0700 | [diff] [blame] | 647 | |
Aart Bik | f3e61ee | 2017-04-12 17:09:20 -0700 | [diff] [blame] | 648 | private: |
Aart Bik | c8e93c7 | 2017-05-10 10:49:22 -0700 | [diff] [blame] | 649 | // Additional packed bits. |
| 650 | static constexpr size_t kFieldMinOpIsUnsigned = HVecOperation::kNumberOfVectorOpPackedBits; |
| 651 | static constexpr size_t kNumberOfMinOpPackedBits = kFieldMinOpIsUnsigned + 1; |
| 652 | static_assert(kNumberOfMinOpPackedBits <= kMaxNumberOfPackedBits, "Too many packed fields."); |
| 653 | |
Aart Bik | f3e61ee | 2017-04-12 17:09:20 -0700 | [diff] [blame] | 654 | DISALLOW_COPY_AND_ASSIGN(HVecMin); |
| 655 | }; |
| 656 | |
| 657 | // Takes maximum of every component in the two vectors, |
Aart Bik | 46b6dbc | 2017-10-03 11:37:37 -0700 | [diff] [blame] | 658 | // viz. MAX( [ x1, .. , xn ] , [ y1, .. , yn ]) = [ max(x1, y1), .. , max(xn, yn) ] |
| 659 | // for either both signed or both unsigned operands x, y. |
Aart Bik | f3e61ee | 2017-04-12 17:09:20 -0700 | [diff] [blame] | 660 | class HVecMax FINAL : public HVecBinaryOperation { |
| 661 | public: |
Vladimir Marko | e764d2e | 2017-10-05 14:35:55 +0100 | [diff] [blame] | 662 | HVecMax(ArenaAllocator* allocator, |
Aart Bik | f3e61ee | 2017-04-12 17:09:20 -0700 | [diff] [blame] | 663 | HInstruction* left, |
| 664 | HInstruction* right, |
Vladimir Marko | 0ebe0d8 | 2017-09-21 22:50:39 +0100 | [diff] [blame] | 665 | DataType::Type packed_type, |
Aart Bik | f3e61ee | 2017-04-12 17:09:20 -0700 | [diff] [blame] | 666 | size_t vector_length, |
Aart Bik | 46b6dbc | 2017-10-03 11:37:37 -0700 | [diff] [blame] | 667 | bool is_unsigned, |
| 668 | uint32_t dex_pc) |
Vladimir Marko | e764d2e | 2017-10-05 14:35:55 +0100 | [diff] [blame] | 669 | : HVecBinaryOperation(allocator, left, right, packed_type, vector_length, dex_pc) { |
Vladimir Marko | d5d2f2c | 2017-09-26 12:37:26 +0100 | [diff] [blame] | 670 | // The `is_unsigned` flag should be used exclusively with the Int32 or Int64. |
| 671 | // This flag is a temporary measure while we do not have the Uint32 and Uint64 data types. |
| 672 | DCHECK(!is_unsigned || |
| 673 | packed_type == DataType::Type::kInt32 || |
| 674 | packed_type == DataType::Type::kInt64) << packed_type; |
Aart Bik | d58bc32 | 2017-05-01 14:49:18 -0700 | [diff] [blame] | 675 | DCHECK(HasConsistentPackedTypes(left, packed_type)); |
| 676 | DCHECK(HasConsistentPackedTypes(right, packed_type)); |
Aart Bik | c8e93c7 | 2017-05-10 10:49:22 -0700 | [diff] [blame] | 677 | SetPackedFlag<kFieldMaxOpIsUnsigned>(is_unsigned); |
Aart Bik | f3e61ee | 2017-04-12 17:09:20 -0700 | [diff] [blame] | 678 | } |
Aart Bik | c8e93c7 | 2017-05-10 10:49:22 -0700 | [diff] [blame] | 679 | |
| 680 | bool IsUnsigned() const { return GetPackedFlag<kFieldMaxOpIsUnsigned>(); } |
| 681 | |
Aart Bik | b79f4ac | 2017-07-10 10:10:37 -0700 | [diff] [blame] | 682 | bool CanBeMoved() const OVERRIDE { return true; } |
| 683 | |
| 684 | bool InstructionDataEquals(const HInstruction* other) const OVERRIDE { |
| 685 | DCHECK(other->IsVecMax()); |
| 686 | const HVecMax* o = other->AsVecMax(); |
| 687 | return HVecOperation::InstructionDataEquals(o) && IsUnsigned() == o->IsUnsigned(); |
| 688 | } |
| 689 | |
Aart Bik | f3e61ee | 2017-04-12 17:09:20 -0700 | [diff] [blame] | 690 | DECLARE_INSTRUCTION(VecMax); |
Aart Bik | c8e93c7 | 2017-05-10 10:49:22 -0700 | [diff] [blame] | 691 | |
Aart Bik | f3e61ee | 2017-04-12 17:09:20 -0700 | [diff] [blame] | 692 | private: |
Aart Bik | c8e93c7 | 2017-05-10 10:49:22 -0700 | [diff] [blame] | 693 | // Additional packed bits. |
| 694 | static constexpr size_t kFieldMaxOpIsUnsigned = HVecOperation::kNumberOfVectorOpPackedBits; |
| 695 | static constexpr size_t kNumberOfMaxOpPackedBits = kFieldMaxOpIsUnsigned + 1; |
| 696 | static_assert(kNumberOfMaxOpPackedBits <= kMaxNumberOfPackedBits, "Too many packed fields."); |
| 697 | |
Aart Bik | f3e61ee | 2017-04-12 17:09:20 -0700 | [diff] [blame] | 698 | DISALLOW_COPY_AND_ASSIGN(HVecMax); |
| 699 | }; |
| 700 | |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 701 | // Bitwise-ands every component in the two vectors, |
| 702 | // viz. [ x1, .. , xn ] & [ y1, .. , yn ] = [ x1 & y1, .. , xn & yn ]. |
| 703 | class HVecAnd FINAL : public HVecBinaryOperation { |
| 704 | public: |
Vladimir Marko | e764d2e | 2017-10-05 14:35:55 +0100 | [diff] [blame] | 705 | HVecAnd(ArenaAllocator* allocator, |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 706 | HInstruction* left, |
| 707 | HInstruction* right, |
Vladimir Marko | 0ebe0d8 | 2017-09-21 22:50:39 +0100 | [diff] [blame] | 708 | DataType::Type packed_type, |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 709 | size_t vector_length, |
Aart Bik | 46b6dbc | 2017-10-03 11:37:37 -0700 | [diff] [blame] | 710 | uint32_t dex_pc) |
Vladimir Marko | e764d2e | 2017-10-05 14:35:55 +0100 | [diff] [blame] | 711 | : HVecBinaryOperation(allocator, left, right, packed_type, vector_length, dex_pc) { |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 712 | DCHECK(left->IsVecOperation() && right->IsVecOperation()); |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 713 | } |
Aart Bik | b79f4ac | 2017-07-10 10:10:37 -0700 | [diff] [blame] | 714 | |
| 715 | bool CanBeMoved() const OVERRIDE { return true; } |
| 716 | |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 717 | DECLARE_INSTRUCTION(VecAnd); |
Aart Bik | b79f4ac | 2017-07-10 10:10:37 -0700 | [diff] [blame] | 718 | |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 719 | private: |
| 720 | DISALLOW_COPY_AND_ASSIGN(HVecAnd); |
| 721 | }; |
| 722 | |
| 723 | // Bitwise-and-nots every component in the two vectors, |
| 724 | // viz. [ x1, .. , xn ] and-not [ y1, .. , yn ] = [ ~x1 & y1, .. , ~xn & yn ]. |
| 725 | class HVecAndNot FINAL : public HVecBinaryOperation { |
| 726 | public: |
Vladimir Marko | e764d2e | 2017-10-05 14:35:55 +0100 | [diff] [blame] | 727 | HVecAndNot(ArenaAllocator* allocator, |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 728 | HInstruction* left, |
| 729 | HInstruction* right, |
Vladimir Marko | 0ebe0d8 | 2017-09-21 22:50:39 +0100 | [diff] [blame] | 730 | DataType::Type packed_type, |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 731 | size_t vector_length, |
Aart Bik | 46b6dbc | 2017-10-03 11:37:37 -0700 | [diff] [blame] | 732 | uint32_t dex_pc) |
Vladimir Marko | e764d2e | 2017-10-05 14:35:55 +0100 | [diff] [blame] | 733 | : HVecBinaryOperation(allocator, left, right, packed_type, vector_length, dex_pc) { |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 734 | DCHECK(left->IsVecOperation() && right->IsVecOperation()); |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 735 | } |
Aart Bik | b79f4ac | 2017-07-10 10:10:37 -0700 | [diff] [blame] | 736 | |
| 737 | bool CanBeMoved() const OVERRIDE { return true; } |
| 738 | |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 739 | DECLARE_INSTRUCTION(VecAndNot); |
Aart Bik | b79f4ac | 2017-07-10 10:10:37 -0700 | [diff] [blame] | 740 | |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 741 | private: |
| 742 | DISALLOW_COPY_AND_ASSIGN(HVecAndNot); |
| 743 | }; |
| 744 | |
| 745 | // Bitwise-ors every component in the two vectors, |
| 746 | // viz. [ x1, .. , xn ] | [ y1, .. , yn ] = [ x1 | y1, .. , xn | yn ]. |
| 747 | class HVecOr FINAL : public HVecBinaryOperation { |
| 748 | public: |
Vladimir Marko | e764d2e | 2017-10-05 14:35:55 +0100 | [diff] [blame] | 749 | HVecOr(ArenaAllocator* allocator, |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 750 | HInstruction* left, |
| 751 | HInstruction* right, |
Vladimir Marko | 0ebe0d8 | 2017-09-21 22:50:39 +0100 | [diff] [blame] | 752 | DataType::Type packed_type, |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 753 | size_t vector_length, |
Aart Bik | 46b6dbc | 2017-10-03 11:37:37 -0700 | [diff] [blame] | 754 | uint32_t dex_pc) |
Vladimir Marko | e764d2e | 2017-10-05 14:35:55 +0100 | [diff] [blame] | 755 | : HVecBinaryOperation(allocator, left, right, packed_type, vector_length, dex_pc) { |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 756 | DCHECK(left->IsVecOperation() && right->IsVecOperation()); |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 757 | } |
Aart Bik | b79f4ac | 2017-07-10 10:10:37 -0700 | [diff] [blame] | 758 | |
| 759 | bool CanBeMoved() const OVERRIDE { return true; } |
| 760 | |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 761 | DECLARE_INSTRUCTION(VecOr); |
Aart Bik | b79f4ac | 2017-07-10 10:10:37 -0700 | [diff] [blame] | 762 | |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 763 | private: |
| 764 | DISALLOW_COPY_AND_ASSIGN(HVecOr); |
| 765 | }; |
| 766 | |
| 767 | // Bitwise-xors every component in the two vectors, |
| 768 | // viz. [ x1, .. , xn ] ^ [ y1, .. , yn ] = [ x1 ^ y1, .. , xn ^ yn ]. |
| 769 | class HVecXor FINAL : public HVecBinaryOperation { |
| 770 | public: |
Vladimir Marko | e764d2e | 2017-10-05 14:35:55 +0100 | [diff] [blame] | 771 | HVecXor(ArenaAllocator* allocator, |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 772 | HInstruction* left, |
| 773 | HInstruction* right, |
Vladimir Marko | 0ebe0d8 | 2017-09-21 22:50:39 +0100 | [diff] [blame] | 774 | DataType::Type packed_type, |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 775 | size_t vector_length, |
Aart Bik | 46b6dbc | 2017-10-03 11:37:37 -0700 | [diff] [blame] | 776 | uint32_t dex_pc) |
Vladimir Marko | e764d2e | 2017-10-05 14:35:55 +0100 | [diff] [blame] | 777 | : HVecBinaryOperation(allocator, left, right, packed_type, vector_length, dex_pc) { |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 778 | DCHECK(left->IsVecOperation() && right->IsVecOperation()); |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 779 | } |
Aart Bik | b79f4ac | 2017-07-10 10:10:37 -0700 | [diff] [blame] | 780 | |
| 781 | bool CanBeMoved() const OVERRIDE { return true; } |
| 782 | |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 783 | DECLARE_INSTRUCTION(VecXor); |
Aart Bik | b79f4ac | 2017-07-10 10:10:37 -0700 | [diff] [blame] | 784 | |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 785 | private: |
| 786 | DISALLOW_COPY_AND_ASSIGN(HVecXor); |
| 787 | }; |
| 788 | |
| 789 | // Logically shifts every component in the vector left by the given distance, |
| 790 | // viz. [ x1, .. , xn ] << d = [ x1 << d, .. , xn << d ]. |
| 791 | class HVecShl FINAL : public HVecBinaryOperation { |
| 792 | public: |
Vladimir Marko | e764d2e | 2017-10-05 14:35:55 +0100 | [diff] [blame] | 793 | HVecShl(ArenaAllocator* allocator, |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 794 | HInstruction* left, |
| 795 | HInstruction* right, |
Vladimir Marko | 0ebe0d8 | 2017-09-21 22:50:39 +0100 | [diff] [blame] | 796 | DataType::Type packed_type, |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 797 | size_t vector_length, |
Aart Bik | 46b6dbc | 2017-10-03 11:37:37 -0700 | [diff] [blame] | 798 | uint32_t dex_pc) |
Vladimir Marko | e764d2e | 2017-10-05 14:35:55 +0100 | [diff] [blame] | 799 | : HVecBinaryOperation(allocator, left, right, packed_type, vector_length, dex_pc) { |
Aart Bik | d58bc32 | 2017-05-01 14:49:18 -0700 | [diff] [blame] | 800 | DCHECK(HasConsistentPackedTypes(left, packed_type)); |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 801 | } |
Aart Bik | b79f4ac | 2017-07-10 10:10:37 -0700 | [diff] [blame] | 802 | |
| 803 | bool CanBeMoved() const OVERRIDE { return true; } |
| 804 | |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 805 | DECLARE_INSTRUCTION(VecShl); |
Aart Bik | b79f4ac | 2017-07-10 10:10:37 -0700 | [diff] [blame] | 806 | |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 807 | private: |
| 808 | DISALLOW_COPY_AND_ASSIGN(HVecShl); |
| 809 | }; |
| 810 | |
| 811 | // Arithmetically shifts every component in the vector right by the given distance, |
| 812 | // viz. [ x1, .. , xn ] >> d = [ x1 >> d, .. , xn >> d ]. |
| 813 | class HVecShr FINAL : public HVecBinaryOperation { |
| 814 | public: |
Vladimir Marko | e764d2e | 2017-10-05 14:35:55 +0100 | [diff] [blame] | 815 | HVecShr(ArenaAllocator* allocator, |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 816 | HInstruction* left, |
| 817 | HInstruction* right, |
Vladimir Marko | 0ebe0d8 | 2017-09-21 22:50:39 +0100 | [diff] [blame] | 818 | DataType::Type packed_type, |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 819 | size_t vector_length, |
Aart Bik | 46b6dbc | 2017-10-03 11:37:37 -0700 | [diff] [blame] | 820 | uint32_t dex_pc) |
Vladimir Marko | e764d2e | 2017-10-05 14:35:55 +0100 | [diff] [blame] | 821 | : HVecBinaryOperation(allocator, left, right, packed_type, vector_length, dex_pc) { |
Aart Bik | d58bc32 | 2017-05-01 14:49:18 -0700 | [diff] [blame] | 822 | DCHECK(HasConsistentPackedTypes(left, packed_type)); |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 823 | } |
Aart Bik | b79f4ac | 2017-07-10 10:10:37 -0700 | [diff] [blame] | 824 | |
| 825 | bool CanBeMoved() const OVERRIDE { return true; } |
| 826 | |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 827 | DECLARE_INSTRUCTION(VecShr); |
Aart Bik | b79f4ac | 2017-07-10 10:10:37 -0700 | [diff] [blame] | 828 | |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 829 | private: |
| 830 | DISALLOW_COPY_AND_ASSIGN(HVecShr); |
| 831 | }; |
| 832 | |
| 833 | // Logically shifts every component in the vector right by the given distance, |
| 834 | // viz. [ x1, .. , xn ] >>> d = [ x1 >>> d, .. , xn >>> d ]. |
| 835 | class HVecUShr FINAL : public HVecBinaryOperation { |
| 836 | public: |
Vladimir Marko | e764d2e | 2017-10-05 14:35:55 +0100 | [diff] [blame] | 837 | HVecUShr(ArenaAllocator* allocator, |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 838 | HInstruction* left, |
| 839 | HInstruction* right, |
Vladimir Marko | 0ebe0d8 | 2017-09-21 22:50:39 +0100 | [diff] [blame] | 840 | DataType::Type packed_type, |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 841 | size_t vector_length, |
Aart Bik | 46b6dbc | 2017-10-03 11:37:37 -0700 | [diff] [blame] | 842 | uint32_t dex_pc) |
Vladimir Marko | e764d2e | 2017-10-05 14:35:55 +0100 | [diff] [blame] | 843 | : HVecBinaryOperation(allocator, left, right, packed_type, vector_length, dex_pc) { |
Aart Bik | d58bc32 | 2017-05-01 14:49:18 -0700 | [diff] [blame] | 844 | DCHECK(HasConsistentPackedTypes(left, packed_type)); |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 845 | } |
Aart Bik | b79f4ac | 2017-07-10 10:10:37 -0700 | [diff] [blame] | 846 | |
| 847 | bool CanBeMoved() const OVERRIDE { return true; } |
| 848 | |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 849 | DECLARE_INSTRUCTION(VecUShr); |
Aart Bik | b79f4ac | 2017-07-10 10:10:37 -0700 | [diff] [blame] | 850 | |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 851 | private: |
| 852 | DISALLOW_COPY_AND_ASSIGN(HVecUShr); |
| 853 | }; |
| 854 | |
Aart Bik | 8de5916 | 2017-04-21 09:42:01 -0700 | [diff] [blame] | 855 | // |
| 856 | // Definitions of concrete miscellaneous vector operations in HIR. |
| 857 | // |
| 858 | |
| 859 | // Assigns the given scalar elements to a vector, |
Aart Bik | dbbac8f | 2017-09-01 13:06:08 -0700 | [diff] [blame] | 860 | // viz. set( array(x1, .. , xn) ) = [ x1, .. , xn ] if n == m, |
| 861 | // set( array(x1, .. , xm) ) = [ x1, .. , xm, 0, .. , 0 ] if m < n. |
Aart Bik | 8de5916 | 2017-04-21 09:42:01 -0700 | [diff] [blame] | 862 | class HVecSetScalars FINAL : public HVecOperation { |
Aart Bik | 0148de4 | 2017-09-05 09:25:01 -0700 | [diff] [blame] | 863 | public: |
Vladimir Marko | e764d2e | 2017-10-05 14:35:55 +0100 | [diff] [blame] | 864 | HVecSetScalars(ArenaAllocator* allocator, |
Aart Bik | 5e3afa9 | 2017-09-20 14:11:11 -0700 | [diff] [blame] | 865 | HInstruction* scalars[], |
Vladimir Marko | 0ebe0d8 | 2017-09-21 22:50:39 +0100 | [diff] [blame] | 866 | DataType::Type packed_type, |
Aart Bik | 8de5916 | 2017-04-21 09:42:01 -0700 | [diff] [blame] | 867 | size_t vector_length, |
Aart Bik | 0148de4 | 2017-09-05 09:25:01 -0700 | [diff] [blame] | 868 | size_t number_of_scalars, |
Aart Bik | 46b6dbc | 2017-10-03 11:37:37 -0700 | [diff] [blame] | 869 | uint32_t dex_pc) |
Vladimir Marko | e764d2e | 2017-10-05 14:35:55 +0100 | [diff] [blame] | 870 | : HVecOperation(allocator, |
Aart Bik | 8de5916 | 2017-04-21 09:42:01 -0700 | [diff] [blame] | 871 | packed_type, |
| 872 | SideEffects::None(), |
Aart Bik | 0148de4 | 2017-09-05 09:25:01 -0700 | [diff] [blame] | 873 | number_of_scalars, |
Aart Bik | 8de5916 | 2017-04-21 09:42:01 -0700 | [diff] [blame] | 874 | vector_length, |
| 875 | dex_pc) { |
Aart Bik | 0148de4 | 2017-09-05 09:25:01 -0700 | [diff] [blame] | 876 | for (size_t i = 0; i < number_of_scalars; i++) { |
Aart Bik | 5e3afa9 | 2017-09-20 14:11:11 -0700 | [diff] [blame] | 877 | DCHECK(!scalars[i]->IsVecOperation() || scalars[i]->IsVecExtractScalar()); |
Aart Bik | 8de5916 | 2017-04-21 09:42:01 -0700 | [diff] [blame] | 878 | SetRawInputAt(0, scalars[i]); |
| 879 | } |
| 880 | } |
Aart Bik | b79f4ac | 2017-07-10 10:10:37 -0700 | [diff] [blame] | 881 | |
| 882 | // Setting scalars needs to stay in place, since SIMD registers are not |
| 883 | // kept alive across vector loop boundaries (yet). |
| 884 | bool CanBeMoved() const OVERRIDE { return false; } |
| 885 | |
Aart Bik | 8de5916 | 2017-04-21 09:42:01 -0700 | [diff] [blame] | 886 | DECLARE_INSTRUCTION(VecSetScalars); |
Aart Bik | b79f4ac | 2017-07-10 10:10:37 -0700 | [diff] [blame] | 887 | |
Aart Bik | 8de5916 | 2017-04-21 09:42:01 -0700 | [diff] [blame] | 888 | private: |
| 889 | DISALLOW_COPY_AND_ASSIGN(HVecSetScalars); |
| 890 | }; |
| 891 | |
Aart Bik | dbbac8f | 2017-09-01 13:06:08 -0700 | [diff] [blame] | 892 | // Multiplies every component in the two vectors, adds the result vector to the accumulator vector, |
| 893 | // viz. [ a1, .. , an ] + [ x1, .. , xn ] * [ y1, .. , yn ] = [ a1 + x1 * y1, .. , an + xn * yn ]. |
Artem Serov | f34dd20 | 2017-04-10 17:41:46 +0100 | [diff] [blame] | 894 | class HVecMultiplyAccumulate FINAL : public HVecOperation { |
| 895 | public: |
Vladimir Marko | e764d2e | 2017-10-05 14:35:55 +0100 | [diff] [blame] | 896 | HVecMultiplyAccumulate(ArenaAllocator* allocator, |
Artem Serov | f34dd20 | 2017-04-10 17:41:46 +0100 | [diff] [blame] | 897 | InstructionKind op, |
| 898 | HInstruction* accumulator, |
| 899 | HInstruction* mul_left, |
| 900 | HInstruction* mul_right, |
Vladimir Marko | 0ebe0d8 | 2017-09-21 22:50:39 +0100 | [diff] [blame] | 901 | DataType::Type packed_type, |
Artem Serov | f34dd20 | 2017-04-10 17:41:46 +0100 | [diff] [blame] | 902 | size_t vector_length, |
Aart Bik | 46b6dbc | 2017-10-03 11:37:37 -0700 | [diff] [blame] | 903 | uint32_t dex_pc) |
Vladimir Marko | e764d2e | 2017-10-05 14:35:55 +0100 | [diff] [blame] | 904 | : HVecOperation(allocator, |
Artem Serov | f34dd20 | 2017-04-10 17:41:46 +0100 | [diff] [blame] | 905 | packed_type, |
| 906 | SideEffects::None(), |
Aart Bik | 8de5916 | 2017-04-21 09:42:01 -0700 | [diff] [blame] | 907 | /* number_of_inputs */ 3, |
Artem Serov | f34dd20 | 2017-04-10 17:41:46 +0100 | [diff] [blame] | 908 | vector_length, |
| 909 | dex_pc), |
| 910 | op_kind_(op) { |
| 911 | DCHECK(op == InstructionKind::kAdd || op == InstructionKind::kSub); |
Aart Bik | d58bc32 | 2017-05-01 14:49:18 -0700 | [diff] [blame] | 912 | DCHECK(HasConsistentPackedTypes(accumulator, packed_type)); |
| 913 | DCHECK(HasConsistentPackedTypes(mul_left, packed_type)); |
| 914 | DCHECK(HasConsistentPackedTypes(mul_right, packed_type)); |
Aart Bik | dbbac8f | 2017-09-01 13:06:08 -0700 | [diff] [blame] | 915 | SetRawInputAt(0, accumulator); |
| 916 | SetRawInputAt(1, mul_left); |
| 917 | SetRawInputAt(2, mul_right); |
Artem Serov | f34dd20 | 2017-04-10 17:41:46 +0100 | [diff] [blame] | 918 | } |
| 919 | |
Nicolas Geoffray | 9858bf7 | 2017-07-08 12:34:55 +0000 | [diff] [blame] | 920 | bool CanBeMoved() const OVERRIDE { return true; } |
| 921 | |
Artem Serov | f34dd20 | 2017-04-10 17:41:46 +0100 | [diff] [blame] | 922 | bool InstructionDataEquals(const HInstruction* other) const OVERRIDE { |
Aart Bik | b79f4ac | 2017-07-10 10:10:37 -0700 | [diff] [blame] | 923 | DCHECK(other->IsVecMultiplyAccumulate()); |
| 924 | const HVecMultiplyAccumulate* o = other->AsVecMultiplyAccumulate(); |
| 925 | return HVecOperation::InstructionDataEquals(o) && GetOpKind() == o->GetOpKind(); |
Artem Serov | f34dd20 | 2017-04-10 17:41:46 +0100 | [diff] [blame] | 926 | } |
| 927 | |
| 928 | InstructionKind GetOpKind() const { return op_kind_; } |
| 929 | |
| 930 | DECLARE_INSTRUCTION(VecMultiplyAccumulate); |
| 931 | |
| 932 | private: |
| 933 | // Indicates if this is a MADD or MSUB. |
| 934 | const InstructionKind op_kind_; |
| 935 | |
| 936 | DISALLOW_COPY_AND_ASSIGN(HVecMultiplyAccumulate); |
| 937 | }; |
| 938 | |
Aart Bik | dbbac8f | 2017-09-01 13:06:08 -0700 | [diff] [blame] | 939 | // Takes the absolute difference of two vectors, and adds the results to |
| 940 | // same-precision or wider-precision components in the accumulator, |
Aart Bik | 46b6dbc | 2017-10-03 11:37:37 -0700 | [diff] [blame] | 941 | // viz. SAD([ a1, .. , am ], [ x1, .. , xn ], [ y1, .. , yn ]) = |
Aart Bik | dbbac8f | 2017-09-01 13:06:08 -0700 | [diff] [blame] | 942 | // [ a1 + sum abs(xi-yi), .. , am + sum abs(xj-yj) ], |
Aart Bik | 46b6dbc | 2017-10-03 11:37:37 -0700 | [diff] [blame] | 943 | // for m <= n, non-overlapping sums, and signed operands x, y. |
Aart Bik | dbbac8f | 2017-09-01 13:06:08 -0700 | [diff] [blame] | 944 | class HVecSADAccumulate FINAL : public HVecOperation { |
| 945 | public: |
Vladimir Marko | e764d2e | 2017-10-05 14:35:55 +0100 | [diff] [blame] | 946 | HVecSADAccumulate(ArenaAllocator* allocator, |
Aart Bik | dbbac8f | 2017-09-01 13:06:08 -0700 | [diff] [blame] | 947 | HInstruction* accumulator, |
| 948 | HInstruction* sad_left, |
| 949 | HInstruction* sad_right, |
Vladimir Marko | 0ebe0d8 | 2017-09-21 22:50:39 +0100 | [diff] [blame] | 950 | DataType::Type packed_type, |
Aart Bik | dbbac8f | 2017-09-01 13:06:08 -0700 | [diff] [blame] | 951 | size_t vector_length, |
Aart Bik | 46b6dbc | 2017-10-03 11:37:37 -0700 | [diff] [blame] | 952 | uint32_t dex_pc) |
Vladimir Marko | e764d2e | 2017-10-05 14:35:55 +0100 | [diff] [blame] | 953 | : HVecOperation(allocator, |
Aart Bik | dbbac8f | 2017-09-01 13:06:08 -0700 | [diff] [blame] | 954 | packed_type, |
| 955 | SideEffects::None(), |
| 956 | /* number_of_inputs */ 3, |
| 957 | vector_length, |
| 958 | dex_pc) { |
| 959 | DCHECK(HasConsistentPackedTypes(accumulator, packed_type)); |
| 960 | DCHECK(sad_left->IsVecOperation()); |
| 961 | DCHECK(sad_right->IsVecOperation()); |
Vladimir Marko | 61b9228 | 2017-10-11 13:23:17 +0100 | [diff] [blame] | 962 | DCHECK_EQ(ToSignedType(sad_left->AsVecOperation()->GetPackedType()), |
| 963 | ToSignedType(sad_right->AsVecOperation()->GetPackedType())); |
Aart Bik | dbbac8f | 2017-09-01 13:06:08 -0700 | [diff] [blame] | 964 | SetRawInputAt(0, accumulator); |
| 965 | SetRawInputAt(1, sad_left); |
| 966 | SetRawInputAt(2, sad_right); |
| 967 | } |
| 968 | |
| 969 | DECLARE_INSTRUCTION(VecSADAccumulate); |
| 970 | |
| 971 | private: |
| 972 | DISALLOW_COPY_AND_ASSIGN(HVecSADAccumulate); |
| 973 | }; |
| 974 | |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 975 | // Loads a vector from memory, viz. load(mem, 1) |
| 976 | // yield the vector [ mem(1), .. , mem(n) ]. |
| 977 | class HVecLoad FINAL : public HVecMemoryOperation { |
| 978 | public: |
Vladimir Marko | e764d2e | 2017-10-05 14:35:55 +0100 | [diff] [blame] | 979 | HVecLoad(ArenaAllocator* allocator, |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 980 | HInstruction* base, |
| 981 | HInstruction* index, |
Vladimir Marko | 0ebe0d8 | 2017-09-21 22:50:39 +0100 | [diff] [blame] | 982 | DataType::Type packed_type, |
Vladimir Marko | d5d2f2c | 2017-09-26 12:37:26 +0100 | [diff] [blame] | 983 | SideEffects side_effects, |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 984 | size_t vector_length, |
Aart Bik | db14fcf | 2017-04-25 15:53:58 -0700 | [diff] [blame] | 985 | bool is_string_char_at, |
Aart Bik | 46b6dbc | 2017-10-03 11:37:37 -0700 | [diff] [blame] | 986 | uint32_t dex_pc) |
Vladimir Marko | e764d2e | 2017-10-05 14:35:55 +0100 | [diff] [blame] | 987 | : HVecMemoryOperation(allocator, |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 988 | packed_type, |
Vladimir Marko | d5d2f2c | 2017-09-26 12:37:26 +0100 | [diff] [blame] | 989 | side_effects, |
Aart Bik | 8de5916 | 2017-04-21 09:42:01 -0700 | [diff] [blame] | 990 | /* number_of_inputs */ 2, |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 991 | vector_length, |
| 992 | dex_pc) { |
| 993 | SetRawInputAt(0, base); |
| 994 | SetRawInputAt(1, index); |
Aart Bik | db14fcf | 2017-04-25 15:53:58 -0700 | [diff] [blame] | 995 | SetPackedFlag<kFieldIsStringCharAt>(is_string_char_at); |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 996 | } |
Aart Bik | db14fcf | 2017-04-25 15:53:58 -0700 | [diff] [blame] | 997 | |
| 998 | bool IsStringCharAt() const { return GetPackedFlag<kFieldIsStringCharAt>(); } |
| 999 | |
Aart Bik | b79f4ac | 2017-07-10 10:10:37 -0700 | [diff] [blame] | 1000 | bool CanBeMoved() const OVERRIDE { return true; } |
| 1001 | |
| 1002 | bool InstructionDataEquals(const HInstruction* other) const OVERRIDE { |
| 1003 | DCHECK(other->IsVecLoad()); |
| 1004 | const HVecLoad* o = other->AsVecLoad(); |
| 1005 | return HVecMemoryOperation::InstructionDataEquals(o) && IsStringCharAt() == o->IsStringCharAt(); |
| 1006 | } |
| 1007 | |
| 1008 | DECLARE_INSTRUCTION(VecLoad); |
| 1009 | |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 1010 | private: |
Aart Bik | db14fcf | 2017-04-25 15:53:58 -0700 | [diff] [blame] | 1011 | // 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."); |
| 1015 | |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 1016 | DISALLOW_COPY_AND_ASSIGN(HVecLoad); |
| 1017 | }; |
| 1018 | |
| 1019 | // Stores a vector to memory, viz. store(m, 1, [x1, .. , xn] ) |
| 1020 | // sets mem(1) = x1, .. , mem(n) = xn. |
| 1021 | class HVecStore FINAL : public HVecMemoryOperation { |
| 1022 | public: |
Vladimir Marko | e764d2e | 2017-10-05 14:35:55 +0100 | [diff] [blame] | 1023 | HVecStore(ArenaAllocator* allocator, |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 1024 | HInstruction* base, |
| 1025 | HInstruction* index, |
| 1026 | HInstruction* value, |
Vladimir Marko | 0ebe0d8 | 2017-09-21 22:50:39 +0100 | [diff] [blame] | 1027 | DataType::Type packed_type, |
Vladimir Marko | d5d2f2c | 2017-09-26 12:37:26 +0100 | [diff] [blame] | 1028 | SideEffects side_effects, |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 1029 | size_t vector_length, |
Aart Bik | 46b6dbc | 2017-10-03 11:37:37 -0700 | [diff] [blame] | 1030 | uint32_t dex_pc) |
Vladimir Marko | e764d2e | 2017-10-05 14:35:55 +0100 | [diff] [blame] | 1031 | : HVecMemoryOperation(allocator, |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 1032 | packed_type, |
Vladimir Marko | d5d2f2c | 2017-09-26 12:37:26 +0100 | [diff] [blame] | 1033 | side_effects, |
Aart Bik | 8de5916 | 2017-04-21 09:42:01 -0700 | [diff] [blame] | 1034 | /* number_of_inputs */ 3, |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 1035 | vector_length, |
| 1036 | dex_pc) { |
Aart Bik | d58bc32 | 2017-05-01 14:49:18 -0700 | [diff] [blame] | 1037 | DCHECK(HasConsistentPackedTypes(value, packed_type)); |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 1038 | SetRawInputAt(0, base); |
| 1039 | SetRawInputAt(1, index); |
| 1040 | SetRawInputAt(2, value); |
| 1041 | } |
Aart Bik | b79f4ac | 2017-07-10 10:10:37 -0700 | [diff] [blame] | 1042 | |
| 1043 | // A store needs to stay in place. |
| 1044 | bool CanBeMoved() const OVERRIDE { return false; } |
| 1045 | |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 1046 | DECLARE_INSTRUCTION(VecStore); |
Aart Bik | b79f4ac | 2017-07-10 10:10:37 -0700 | [diff] [blame] | 1047 | |
Aart Bik | f8f5a16 | 2017-02-06 15:35:29 -0800 | [diff] [blame] | 1048 | private: |
| 1049 | DISALLOW_COPY_AND_ASSIGN(HVecStore); |
| 1050 | }; |
| 1051 | |
| 1052 | } // namespace art |
| 1053 | |
| 1054 | #endif // ART_COMPILER_OPTIMIZING_NODES_VECTOR_H_ |