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