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